mirror of
https://github.com/jellyfin/jellyfin-ffmpeg.git
synced 2026-09-03 05:09:58 +03:00
Imported Upstream version 2.6.3
This commit is contained in:
@@ -1,6 +1,77 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 2.6.3:
|
||||
- avcodec/libtheoraenc: Check for av_malloc failure
|
||||
- ffmpeg_opt: Fix -timestamp parsing
|
||||
- hevc: make avcodec_decode_video2() fail if get_format() fails
|
||||
- avcodec/cavsdec: Use ff_set_dimensions()
|
||||
- swr: fix alignment issue caused by 8ch sse functions
|
||||
- avcodec/mjpegdec: fix len computation in ff_mjpeg_decode_dqt()
|
||||
- avcodec/jpeg2000dec: fix boolean operator
|
||||
- avcodec/hevc_ps: Explicitly check num_tile_* for negative values
|
||||
- avformat/matroskadec: Cleanup error handling for bz2 & zlib
|
||||
- avformat/nutdec: Fix use of uinitialized value
|
||||
- tools/graph2dot: use larger data types than int for array/string sizes
|
||||
- avformat/matroskaenc: Check ff_vorbiscomment_length in put_flac_codecpriv()
|
||||
- avcodec/mpeg12dec: use the correct dimensions for checking SAR
|
||||
- xcbgrab: Validate the capture area
|
||||
- xcbgrab: Do not assume the non shm image data is always available
|
||||
- avfilter/lavfutils: disable frame threads when decoding a single image
|
||||
- avformat/mov: Do not read ACLR into extradata for H.264
|
||||
- ffmpeg: remove incorrect network deinit
|
||||
- OpenCL: Avoid potential buffer overflow in cmdutils_opencl.c
|
||||
- libvpxenc: only set noise reduction w/vp8
|
||||
- vp9: remove another optimization branch in iadst16 which causes overflows.
|
||||
- lavf: Reset global flag on deinit
|
||||
- network: Do not leave context locked on error
|
||||
- vp9: remove one optimization branch in iadst16 which causes overflows.
|
||||
- fate: Include branch information in the payload header
|
||||
- avformat/utils: Ensure that AVFMT_FLAG_CUSTOM_IO is set before use
|
||||
- avformat/img2dec: do not rewind custom io buffers
|
||||
- avcodec/alsdec: Use av_mallocz_array() for chan_data to ensure the arrays never contain random data
|
||||
- avcodec/atrac3plusdsp: fix on stack alignment
|
||||
- swresample/swresample-test: Randomly wipe out channel counts
|
||||
- swresample: Check channel layouts and channels against each other and print human readable error messages
|
||||
- swresample: Allow reinitialization without ever setting channel layouts (cherry picked from commit 80a28c7509a11114e1aea5b208d56c6646d69c07)
|
||||
- swresample: Allow reinitialization without ever setting channel counts
|
||||
- dashenc: replace attribute id with contentType for the AdaptationSet element
|
||||
- avformat/matroskaenc: Use avoid_negative_ts_use_pts if no stream writes dts
|
||||
- avformat/mux: Add avoid_negative_ts_use_pts
|
||||
- tests/fate-run: do not attempt to parse tiny_psnrs output if it failed
|
||||
- cafdec: free extradata before allocating it
|
||||
- imgutils: initialize palette padding bytes in av_image_alloc
|
||||
- aacdec: don't return frames without data
|
||||
- id3v2: catch avio_read errors in check_tag
|
||||
- avi: Validate sample_size
|
||||
- aacsbr: break infinite loop in sbr_hf_calc_npatches
|
||||
- diracdec: avoid overflow of bytes*8 in decode_lowdelay
|
||||
- diracdec: prevent overflow in data_unit_size check
|
||||
- avformat/matroskadec: Use tracks[k]->stream instead of s->streams[k]
|
||||
- matroskadec: use uint64_t instead of int for index_scale
|
||||
- pngdec: don't use AV_PIX_FMT_MONOBLACK for apng
|
||||
- pngdec: return correct error code from decode_frame_common
|
||||
- nutdec: fix illegal count check in decode_main_header
|
||||
- nutdec: fix memleaks on error in nut_read_header
|
||||
- apedec: prevent out of array writes in decode_array_0000
|
||||
- apedec: set s->samples only when init_frame_decoder succeeded
|
||||
- swscale/ppc/swscale_altivec.c: POWER LE support in yuv2planeX_8() delete macro GET_VF() it was wrong
|
||||
- alac: reject rice_limit 0 if compression is used
|
||||
- alsdec: only adapt order for positive max_order
|
||||
- bink: check vst->index_entries before using it
|
||||
- mpeg4videodec: only allow a positive length
|
||||
- aacpsy: correct calculation of minath in psy_3gpp_init
|
||||
- alsdec: validate time diff index
|
||||
- alsdec: ensure channel reordering is reversible
|
||||
- ac3: validate end in ff_ac3_bit_alloc_calc_mask
|
||||
- aacpsy: avoid psy_band->threshold becoming NaN
|
||||
- aasc: return correct buffer size from aasc_decode_frame
|
||||
- matroskadec: export cover art correctly
|
||||
- mxfenc: don't try to write footer without header
|
||||
- mxfenc: fix memleaks in mxf_write_footer
|
||||
- rtpenc_mpegts: Set chain->rtp_ctx only after avformat_write_header succeeded
|
||||
- rtpenc_mpegts: Free the right ->pb in the error path in the init function
|
||||
|
||||
version 2.6.2:
|
||||
- avcodec/h264: Do not fail with randomly truncated VUIs
|
||||
- avcodec/h264_ps: Move truncation check from VUI to SPS
|
||||
|
||||
+3
-1
@@ -22,6 +22,7 @@
|
||||
#include "libavutil/time.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/opencl.h"
|
||||
#include "libavutil/avstring.h"
|
||||
#include "cmdutils.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -238,7 +239,8 @@ int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
|
||||
devices[count].platform_idx = i;
|
||||
devices[count].device_idx = j;
|
||||
devices[count].runtime = score;
|
||||
strcpy(devices[count].device_name, device_node->device_name);
|
||||
av_strlcpy(devices[count].device_name, device_node->device_name,
|
||||
sizeof(devices[count].device_name));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.6.2
|
||||
PROJECT_NUMBER = 2.6.3
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
@@ -351,7 +351,6 @@ void term_init(void)
|
||||
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
|
||||
}
|
||||
#endif
|
||||
avformat_network_deinit();
|
||||
|
||||
signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
|
||||
signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
|
||||
|
||||
+1
-1
@@ -2859,7 +2859,7 @@ const OptionDef options[] = {
|
||||
{ "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC |
|
||||
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(ts_scale) },
|
||||
"set the input ts scale", "scale" },
|
||||
{ "timestamp", HAS_ARG | OPT_PERFILE, { .func_arg = opt_recording_timestamp },
|
||||
{ "timestamp", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_recording_timestamp },
|
||||
"set the recording timestamp ('now' to set the current time)", "time" },
|
||||
{ "metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata) },
|
||||
"add metadata", "string=string" },
|
||||
|
||||
+7
-1
@@ -900,7 +900,7 @@ static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
|
||||
if (len == 15 + 255)
|
||||
len += get_bits(gb, 16);
|
||||
if (get_bits_left(gb) < len * 8 + 4) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
|
||||
av_log(avctx, AV_LOG_ERROR, overread_err);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
skip_bits_long(gb, 8 * len);
|
||||
@@ -3073,6 +3073,12 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
||||
AV_WL32(side, 2*AV_RL32(side));
|
||||
}
|
||||
|
||||
if (!ac->frame->data[0] && samples) {
|
||||
av_log(avctx, AV_LOG_ERROR, "no frame data found\n");
|
||||
err = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*got_frame_ptr = !!samples;
|
||||
if (samples) {
|
||||
ac->frame->nb_samples = samples;
|
||||
|
||||
+5
-2
@@ -313,7 +313,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
|
||||
ctx->bitres.size = 6144 - pctx->frame_bits;
|
||||
ctx->bitres.size -= ctx->bitres.size % 8;
|
||||
pctx->fill_level = ctx->bitres.size;
|
||||
minath = ath(3410, ATH_ADD);
|
||||
minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD);
|
||||
for (j = 0; j < 2; j++) {
|
||||
AacPsyCoeffs *coeffs = pctx->psy_coef[j];
|
||||
const uint8_t *band_sizes = ctx->bands[j];
|
||||
@@ -727,7 +727,10 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
|
||||
if (active_lines > 0.0f)
|
||||
band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction);
|
||||
pe += calc_pe_3gpp(band);
|
||||
band->norm_fac = band->active_lines / band->thr;
|
||||
if (band->thr > 0.0f)
|
||||
band->norm_fac = band->active_lines / band->thr;
|
||||
else
|
||||
band->norm_fac = 0.0f;
|
||||
norm_fac += band->norm_fac;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -514,7 +514,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr,
|
||||
/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46)
|
||||
static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
|
||||
{
|
||||
int i, k, sb = 0;
|
||||
int i, k, last_k = -1, last_msb = -1, sb = 0;
|
||||
int msb = sbr->k[0];
|
||||
int usb = sbr->kx[1];
|
||||
int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
|
||||
@@ -528,6 +528,12 @@ static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
|
||||
|
||||
do {
|
||||
int odd = 0;
|
||||
if (k == last_k && msb == last_msb) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "patch construction failed\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
last_k = k;
|
||||
last_msb = msb;
|
||||
for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) {
|
||||
sb = sbr->f_master[i];
|
||||
odd = (sb + sbr->k[0]) & 1;
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ static int aasc_decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
|
||||
/* report that the buffer was completely consumed */
|
||||
return buf_size;
|
||||
return avpkt->size;
|
||||
}
|
||||
|
||||
static av_cold int aasc_decode_end(AVCodecContext *avctx)
|
||||
|
||||
@@ -131,6 +131,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
||||
int band_start, band_end, begin, end1;
|
||||
int lowcomp, fastleak, slowleak;
|
||||
|
||||
if (end <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* excitation function */
|
||||
band_start = ff_ac3_bin_to_band_tab[start];
|
||||
band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
|
||||
|
||||
@@ -316,6 +316,11 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
|
||||
int lpc_quant[2];
|
||||
int rice_history_mult[2];
|
||||
|
||||
if (!alac->rice_limit) {
|
||||
avpriv_request_sample(alac->avctx, "Compression with rice limit 0");
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
decorr_shift = get_bits(&alac->gb, 8);
|
||||
decorr_left_weight = get_bits(&alac->gb, 8);
|
||||
|
||||
|
||||
+45
-7
@@ -357,11 +357,15 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
||||
|
||||
ctx->cs_switch = 1;
|
||||
|
||||
for (i = 0; i < avctx->channels; i++) {
|
||||
sconf->chan_pos[i] = -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < avctx->channels; i++) {
|
||||
int idx;
|
||||
|
||||
idx = get_bits(&gb, chan_pos_bits);
|
||||
if (idx >= avctx->channels) {
|
||||
if (idx >= avctx->channels || sconf->chan_pos[idx] != -1) {
|
||||
av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n");
|
||||
ctx->cs_switch = 0;
|
||||
break;
|
||||
@@ -678,7 +682,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
||||
|
||||
|
||||
if (!sconf->rlslms) {
|
||||
if (sconf->adapt_order) {
|
||||
if (sconf->adapt_order && sconf->max_order) {
|
||||
int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
|
||||
2, sconf->max_order + 1));
|
||||
*bd->opt_order = get_bits(gb, opt_order_length);
|
||||
@@ -1242,6 +1246,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
||||
ALSChannelData *ch = cd[c];
|
||||
unsigned int dep = 0;
|
||||
unsigned int channels = ctx->avctx->channels;
|
||||
unsigned int channel_size = ctx->sconf.frame_length + ctx->sconf.max_order;
|
||||
|
||||
if (reverted[c])
|
||||
return 0;
|
||||
@@ -1272,9 +1277,9 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
||||
bd->raw_samples = ctx->raw_samples[c] + offset;
|
||||
|
||||
for (dep = 0; !ch[dep].stop_flag; dep++) {
|
||||
unsigned int smp;
|
||||
unsigned int begin = 1;
|
||||
unsigned int end = bd->block_length - 1;
|
||||
ptrdiff_t smp;
|
||||
ptrdiff_t begin = 1;
|
||||
ptrdiff_t end = bd->block_length - 1;
|
||||
int64_t y;
|
||||
int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;
|
||||
|
||||
@@ -1286,11 +1291,28 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
||||
|
||||
if (ch[dep].time_diff_sign) {
|
||||
t = -t;
|
||||
if (begin < t) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "begin %td smaller than time diff index %d.\n", begin, t);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
begin -= t;
|
||||
} else {
|
||||
if (end < t) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "end %td smaller than time diff index %d.\n", end, t);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
end -= t;
|
||||
}
|
||||
|
||||
if (FFMIN(begin - 1, begin - 1 + t) < ctx->raw_buffer - master ||
|
||||
FFMAX(end + 1, end + 1 + t) > ctx->raw_buffer + channels * channel_size - master) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR,
|
||||
"sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
|
||||
master + FFMIN(begin - 1, begin - 1 + t), master + FFMAX(end + 1, end + 1 + t),
|
||||
ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (smp = begin; smp < end; smp++) {
|
||||
y = (1 << 6) +
|
||||
MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
|
||||
@@ -1303,6 +1325,16 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
||||
bd->raw_samples[smp] += y >> 7;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (begin - 1 < ctx->raw_buffer - master ||
|
||||
end + 1 > ctx->raw_buffer + channels * channel_size - master) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR,
|
||||
"sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
|
||||
master + begin - 1, master + end + 1,
|
||||
ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (smp = begin; smp < end; smp++) {
|
||||
y = (1 << 6) +
|
||||
MUL64(ch[dep].weighting[0], master[smp - 1]) +
|
||||
@@ -1666,6 +1698,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
avctx->sample_fmt = sconf->resolution > 1
|
||||
? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
|
||||
avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8;
|
||||
if (avctx->bits_per_raw_sample > 32) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Bits per raw sample %d larger than 32.\n",
|
||||
avctx->bits_per_raw_sample);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
// set maximum Rice parameter for progressive decoding based on resolution
|
||||
@@ -1728,9 +1766,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
|
||||
// allocate and assign channel data buffer for mcc mode
|
||||
if (sconf->mc_coding) {
|
||||
ctx->chan_data_buffer = av_malloc(sizeof(*ctx->chan_data_buffer) *
|
||||
ctx->chan_data_buffer = av_mallocz(sizeof(*ctx->chan_data_buffer) *
|
||||
num_buffers * num_buffers);
|
||||
ctx->chan_data = av_malloc(sizeof(*ctx->chan_data) *
|
||||
ctx->chan_data = av_mallocz(sizeof(*ctx->chan_data) *
|
||||
num_buffers);
|
||||
ctx->reverted_channels = av_malloc(sizeof(*ctx->reverted_channels) *
|
||||
num_buffers);
|
||||
|
||||
+3
-3
@@ -592,14 +592,14 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
|
||||
int ksummax, ksummin;
|
||||
|
||||
rice->ksum = 0;
|
||||
for (i = 0; i < 5; i++) {
|
||||
for (i = 0; i < FFMIN(blockstodecode, 5); i++) {
|
||||
out[i] = get_rice_ook(&ctx->gb, 10);
|
||||
rice->ksum += out[i];
|
||||
}
|
||||
rice->k = av_log2(rice->ksum / 10) + 1;
|
||||
if (rice->k >= 24)
|
||||
return;
|
||||
for (; i < 64; i++) {
|
||||
for (; i < FFMIN(blockstodecode, 64); i++) {
|
||||
out[i] = get_rice_ook(&ctx->gb, rice->k);
|
||||
rice->ksum += out[i];
|
||||
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
|
||||
@@ -1461,13 +1461,13 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
nblocks);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->samples = nblocks;
|
||||
|
||||
/* Initialize the frame decoder */
|
||||
if (init_frame_decoder(s) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->samples = nblocks;
|
||||
}
|
||||
|
||||
if (!s->data) {
|
||||
|
||||
@@ -599,8 +599,8 @@ void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
|
||||
const float *in, float *out)
|
||||
{
|
||||
int i, s, sb, t, pos_now, pos_next;
|
||||
DECLARE_ALIGNED(32, float, idct_in)[ATRAC3P_SUBBANDS];
|
||||
DECLARE_ALIGNED(32, float, idct_out)[ATRAC3P_SUBBANDS];
|
||||
LOCAL_ALIGNED(32, float, idct_in, [ATRAC3P_SUBBANDS]);
|
||||
LOCAL_ALIGNED(32, float, idct_out, [ATRAC3P_SUBBANDS]);
|
||||
|
||||
memset(out, 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out));
|
||||
|
||||
|
||||
+13
-5
@@ -563,6 +563,11 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
esc_code = get_ue_code(gb, esc_golomb_order);
|
||||
if (esc_code < 0 || esc_code > 32767) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "esc_code invalid\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
level = esc_code + (run > r->max_run ? 1 : r->level_add[run]);
|
||||
while (level > r->inc_limit)
|
||||
r++;
|
||||
@@ -1118,6 +1123,7 @@ static int decode_seq_header(AVSContext *h)
|
||||
{
|
||||
int frame_rate_code;
|
||||
int width, height;
|
||||
int ret;
|
||||
|
||||
h->profile = get_bits(&h->gb, 8);
|
||||
h->level = get_bits(&h->gb, 8);
|
||||
@@ -1134,9 +1140,6 @@ static int decode_seq_header(AVSContext *h)
|
||||
av_log(h->avctx, AV_LOG_ERROR, "Dimensions invalid\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
h->width = width;
|
||||
h->height = height;
|
||||
|
||||
skip_bits(&h->gb, 2); //chroma format
|
||||
skip_bits(&h->gb, 3); //sample_precision
|
||||
h->aspect_ratio = get_bits(&h->gb, 4);
|
||||
@@ -1145,11 +1148,16 @@ static int decode_seq_header(AVSContext *h)
|
||||
skip_bits1(&h->gb); //marker_bit
|
||||
skip_bits(&h->gb, 12); //bit_rate_upper
|
||||
h->low_delay = get_bits1(&h->gb);
|
||||
|
||||
ret = ff_set_dimensions(h->avctx, width, height);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
h->width = width;
|
||||
h->height = height;
|
||||
h->mb_width = (h->width + 15) >> 4;
|
||||
h->mb_height = (h->height + 15) >> 4;
|
||||
h->avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_code];
|
||||
h->avctx->width = h->width;
|
||||
h->avctx->height = h->height;
|
||||
if (!h->top_qp)
|
||||
return ff_cavs_init_top_lines(h);
|
||||
return 0;
|
||||
|
||||
+33
-5
@@ -226,6 +226,14 @@ static int dca_parse_audio_coding_header(DCAContext *s, int base_channel,
|
||||
}
|
||||
|
||||
nchans = get_bits(&s->gb, 3) + 1;
|
||||
if (xxch && nchans >= 3) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "nchans %d is too large\n", nchans);
|
||||
return AVERROR_INVALIDDATA;
|
||||
} else if (nchans + base_channel > DCA_PRIM_CHANNELS_MAX) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "channel sum %d + %d is too large\n", nchans, base_channel);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->total_channels = nchans + base_channel;
|
||||
s->prim_channels = s->total_channels;
|
||||
|
||||
@@ -426,6 +434,10 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
|
||||
|
||||
if (!base_channel) {
|
||||
s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1;
|
||||
if (block_index + s->subsubframes[s->current_subframe] > s->sample_blocks/8) {
|
||||
s->subsubframes[s->current_subframe] = 1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);
|
||||
}
|
||||
|
||||
@@ -1120,8 +1132,13 @@ int ff_dca_xbr_parse_frame(DCAContext *s)
|
||||
for(i = 0; i < num_chsets; i++) {
|
||||
n_xbr_ch[i] = get_bits(&s->gb, 3) + 1;
|
||||
k = get_bits(&s->gb, 2) + 5;
|
||||
for(j = 0; j < n_xbr_ch[i]; j++)
|
||||
for(j = 0; j < n_xbr_ch[i]; j++) {
|
||||
active_bands[i][j] = get_bits(&s->gb, k) + 1;
|
||||
if (active_bands[i][j] > DCA_SUBBANDS) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "too many active subbands (%d)\n", active_bands[i][j]);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* skip to the end of the header */
|
||||
@@ -1163,23 +1180,34 @@ int ff_dca_xbr_parse_frame(DCAContext *s)
|
||||
for(i = 0; i < n_xbr_ch[chset]; i++) {
|
||||
const uint32_t *scale_table;
|
||||
int nbits;
|
||||
int scale_table_size;
|
||||
|
||||
if (s->scalefactor_huffman[chan_base+i] == 6) {
|
||||
scale_table = ff_dca_scale_factor_quant7;
|
||||
scale_table_size = FF_ARRAY_ELEMS(ff_dca_scale_factor_quant7);
|
||||
} else {
|
||||
scale_table = ff_dca_scale_factor_quant6;
|
||||
scale_table_size = FF_ARRAY_ELEMS(ff_dca_scale_factor_quant6);
|
||||
}
|
||||
|
||||
nbits = anctemp[i];
|
||||
|
||||
for(j = 0; j < active_bands[chset][i]; j++) {
|
||||
if(abits_high[i][j] > 0) {
|
||||
scale_table_high[i][j][0] =
|
||||
scale_table[get_bits(&s->gb, nbits)];
|
||||
int index = get_bits(&s->gb, nbits);
|
||||
if (index >= scale_table_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "scale table index %d invalid\n", index);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
scale_table_high[i][j][0] = scale_table[index];
|
||||
|
||||
if(xbr_tmode && s->transition_mode[i][j]) {
|
||||
scale_table_high[i][j][1] =
|
||||
scale_table[get_bits(&s->gb, nbits)];
|
||||
int index = get_bits(&s->gb, nbits);
|
||||
if (index >= scale_table_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "scale table index %d invalid\n", index);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
scale_table_high[i][j][1] = scale_table[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-3
@@ -801,7 +801,10 @@ static int decode_lowdelay(DiracContext *s)
|
||||
slice_num++;
|
||||
|
||||
buf += bytes;
|
||||
bufsize -= bytes*8;
|
||||
if (bufsize/8 >= bytes)
|
||||
bufsize -= bytes*8;
|
||||
else
|
||||
bufsize = 0;
|
||||
}
|
||||
|
||||
avctx->execute(avctx, decode_lowdelay_slice, slices, NULL, slice_num,
|
||||
@@ -899,6 +902,14 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
|
||||
/*[DIRAC_STD] 11.2.4 motion_data_dimensions()
|
||||
Calculated in function dirac_unpack_block_motion_data */
|
||||
|
||||
if (s->plane[0].xblen % (1 << s->chroma_x_shift) != 0 ||
|
||||
s->plane[0].yblen % (1 << s->chroma_y_shift) != 0 ||
|
||||
!s->plane[0].xblen || !s->plane[0].yblen) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"invalid x/y block length (%d/%d) for x/y chroma shift (%d/%d)\n",
|
||||
s->plane[0].xblen, s->plane[0].yblen, s->chroma_x_shift, s->chroma_y_shift);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (!s->plane[0].xbsep || !s->plane[0].ybsep || s->plane[0].xbsep < s->plane[0].xblen/2 || s->plane[0].ybsep < s->plane[0].yblen/2) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Block separation too small\n");
|
||||
return -1;
|
||||
@@ -1742,6 +1753,12 @@ static int dirac_decode_picture_header(DiracContext *s)
|
||||
get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!s->ref_pics[i]) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Reference could not be allocated\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* retire the reference frames that are not used anymore */
|
||||
@@ -1937,8 +1954,8 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
break;
|
||||
|
||||
data_unit_size = AV_RB32(buf+buf_idx+5);
|
||||
if (buf_idx + data_unit_size > buf_size || !data_unit_size) {
|
||||
if(buf_idx + data_unit_size > buf_size)
|
||||
if (data_unit_size > buf_size - buf_idx || !data_unit_size) {
|
||||
if(data_unit_size > buf_size - buf_idx)
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Data unit with size %d is larger than input buffer, discarding\n",
|
||||
data_unit_size);
|
||||
|
||||
@@ -1197,8 +1197,12 @@ static int dvbsub_parse_region_segment(AVCodecContext *avctx,
|
||||
region->buf_size = region->width * region->height;
|
||||
|
||||
region->pbuf = av_malloc(region->buf_size);
|
||||
if (!region->pbuf)
|
||||
if (!region->pbuf) {
|
||||
region->buf_size =
|
||||
region->width =
|
||||
region->height = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
fill = 1;
|
||||
region->dirty = 0;
|
||||
@@ -1417,7 +1421,7 @@ static void save_display_set(DVBSubContext *ctx)
|
||||
|
||||
pbuf = av_malloc(width * height * 4);
|
||||
if (!pbuf)
|
||||
return AVERROR(ENOMEM);
|
||||
return;
|
||||
|
||||
for (display = ctx->display_list; display; display = display->next) {
|
||||
region = get_region(ctx, display->region_id);
|
||||
|
||||
@@ -546,6 +546,12 @@ static int read_extra_header(FFV1Context *f)
|
||||
f->num_h_slices = 1 + get_symbol(c, state, 0);
|
||||
f->num_v_slices = 1 + get_symbol(c, state, 0);
|
||||
|
||||
if (f->chroma_h_shift > 4U || f->chroma_v_shift > 4U) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n",
|
||||
f->chroma_h_shift, f->chroma_v_shift);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (f->num_h_slices > (unsigned)f->width || !f->num_h_slices ||
|
||||
f->num_v_slices > (unsigned)f->height || !f->num_v_slices
|
||||
) {
|
||||
@@ -651,6 +657,12 @@ static int read_header(FFV1Context *f)
|
||||
}
|
||||
}
|
||||
|
||||
if (chroma_h_shift > 4U || chroma_v_shift > 4U) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n",
|
||||
chroma_h_shift, chroma_v_shift);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
f->colorspace = colorspace;
|
||||
f->avctx->bits_per_raw_sample = bits_per_raw_sample;
|
||||
f->chroma_planes = chroma_planes;
|
||||
|
||||
+15
-2
@@ -694,11 +694,25 @@ static int hls_slice_header(HEVCContext *s)
|
||||
|
||||
sh->num_entry_point_offsets = 0;
|
||||
if (s->pps->tiles_enabled_flag || s->pps->entropy_coding_sync_enabled_flag) {
|
||||
sh->num_entry_point_offsets = get_ue_golomb_long(gb);
|
||||
unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
|
||||
// It would be possible to bound this tighter but this here is simpler
|
||||
if (num_entry_point_offsets > get_bits_left(gb)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
sh->num_entry_point_offsets = num_entry_point_offsets;
|
||||
if (sh->num_entry_point_offsets > 0) {
|
||||
int offset_len = get_ue_golomb_long(gb) + 1;
|
||||
int segments = offset_len >> 4;
|
||||
int rest = (offset_len & 15);
|
||||
|
||||
if (offset_len < 1 || offset_len > 32) {
|
||||
sh->num_entry_point_offsets = 0;
|
||||
av_log(s->avctx, AV_LOG_ERROR, "offset_len %d is invalid\n", offset_len);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
av_freep(&sh->entry_point_offset);
|
||||
av_freep(&sh->offset);
|
||||
av_freep(&sh->size);
|
||||
@@ -2983,7 +2997,6 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
|
||||
|
||||
/* parse the NAL units */
|
||||
for (i = 0; i < s->nb_nals; i++) {
|
||||
int ret;
|
||||
s->skipped_bytes = s->skipped_bytes_nal[i];
|
||||
s->skipped_bytes_pos = s->skipped_bytes_pos_nal[i];
|
||||
|
||||
|
||||
@@ -424,7 +424,8 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
||||
|
||||
vps->vps_max_layer_id = get_bits(gb, 6);
|
||||
vps->vps_num_layer_sets = get_ue_golomb_long(gb) + 1;
|
||||
if ((vps->vps_num_layer_sets - 1LL) * (vps->vps_max_layer_id + 1LL) > get_bits_left(gb)) {
|
||||
if (vps->vps_num_layer_sets < 1 || vps->vps_num_layer_sets > 1024 ||
|
||||
(vps->vps_num_layer_sets - 1LL) * (vps->vps_max_layer_id + 1LL) > get_bits_left(gb)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "too many layer_id_included_flags\n");
|
||||
goto err;
|
||||
}
|
||||
@@ -441,6 +442,11 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
||||
if (vps->vps_poc_proportional_to_timing_flag)
|
||||
vps->vps_num_ticks_poc_diff_one = get_ue_golomb_long(gb) + 1;
|
||||
vps->vps_num_hrd_parameters = get_ue_golomb_long(gb);
|
||||
if (vps->vps_num_hrd_parameters > (unsigned)vps->vps_num_layer_sets) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"vps_num_hrd_parameters %d is invalid\n", vps->vps_num_hrd_parameters);
|
||||
goto err;
|
||||
}
|
||||
for (i = 0; i < vps->vps_num_hrd_parameters; i++) {
|
||||
int common_inf_present = 1;
|
||||
|
||||
@@ -1316,14 +1322,14 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
|
||||
if (pps->tiles_enabled_flag) {
|
||||
pps->num_tile_columns = get_ue_golomb_long(gb) + 1;
|
||||
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
|
||||
if (pps->num_tile_columns == 0 ||
|
||||
if (pps->num_tile_columns <= 0 ||
|
||||
pps->num_tile_columns >= sps->width) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
|
||||
pps->num_tile_columns - 1);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto err;
|
||||
}
|
||||
if (pps->num_tile_rows == 0 ||
|
||||
if (pps->num_tile_rows <= 0 ||
|
||||
pps->num_tile_rows >= sps->height) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
|
||||
pps->num_tile_rows - 1);
|
||||
|
||||
@@ -126,6 +126,11 @@ static int active_parameter_sets(HEVCContext *s)
|
||||
get_bits(gb, 1); // num_sps_ids_minus1
|
||||
num_sps_ids_minus1 = get_ue_golomb_long(gb); // num_sps_ids_minus1
|
||||
|
||||
if (num_sps_ids_minus1 < 0 || num_sps_ids_minus1 > 15) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "num_sps_ids_minus1 %d invalid\n", num_sps_ids_minus1);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
active_seq_parameter_set_id = get_ue_golomb_long(gb);
|
||||
if (active_seq_parameter_set_id >= MAX_SPS_COUNT) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "active_parameter_set_id %d invalid\n", active_seq_parameter_set_id);
|
||||
|
||||
@@ -1559,7 +1559,7 @@ static int jp2_find_codestream(Jpeg2000DecoderContext *s)
|
||||
int cn = bytestream2_get_be16(&s->g);
|
||||
int av_unused typ = bytestream2_get_be16(&s->g);
|
||||
int asoc = bytestream2_get_be16(&s->g);
|
||||
if (cn < 4 || asoc < 4)
|
||||
if (cn < 4 && asoc < 4)
|
||||
s->cdef[cn] = asoc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,8 @@ static int get_stats(AVCodecContext *avctx, int eos)
|
||||
// libtheora generates a summary header at the end
|
||||
memcpy(h->stats, buf, bytes);
|
||||
avctx->stats_out = av_malloc(b64_size);
|
||||
if (!avctx->stats_out)
|
||||
return AVERROR(ENOMEM);
|
||||
av_base64_encode(avctx->stats_out, b64_size, h->stats, h->stats_offset);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -441,9 +441,10 @@ static av_cold int vpx_init(AVCodecContext *avctx,
|
||||
codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);
|
||||
if (ctx->arnr_type >= 0)
|
||||
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
|
||||
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
|
||||
if (avctx->codec_id == AV_CODEC_ID_VP8)
|
||||
if (avctx->codec_id == AV_CODEC_ID_VP8) {
|
||||
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
|
||||
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
|
||||
}
|
||||
#if FF_API_MPV_OPT
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
if (avctx->mb_threshold) {
|
||||
|
||||
@@ -182,7 +182,7 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
|
||||
s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n",
|
||||
index, s->qscale[index]);
|
||||
len -= 65;
|
||||
len -= 1 + 64 * (1+pr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/stereo3d.h"
|
||||
|
||||
@@ -1315,7 +1316,13 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
|
||||
}
|
||||
} // MPEG-2
|
||||
|
||||
ff_set_sar(s->avctx, s->avctx->sample_aspect_ratio);
|
||||
if (av_image_check_sar(s->width, s->height,
|
||||
avctx->sample_aspect_ratio) < 0) {
|
||||
av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
|
||||
avctx->sample_aspect_ratio.num,
|
||||
avctx->sample_aspect_ratio.den);
|
||||
avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
|
||||
}
|
||||
|
||||
if ((s1->mpeg_enc_ctx_allocated == 0) ||
|
||||
avctx->coded_width != s->width ||
|
||||
|
||||
@@ -102,7 +102,7 @@ enum AudioObjectType {
|
||||
AOT_USAC, ///< N Unified Speech and Audio Coding
|
||||
};
|
||||
|
||||
#define MAX_PCE_SIZE 304 ///<Maximum size of a PCE including the 3-bit ID_PCE
|
||||
#define MAX_PCE_SIZE 320 ///<Maximum size of a PCE including the 3-bit ID_PCE
|
||||
///<marker and the comment
|
||||
|
||||
int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb);
|
||||
|
||||
@@ -189,14 +189,14 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
|
||||
int x = 0, y = 0;
|
||||
|
||||
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
|
||||
if (length)
|
||||
if (length > 0)
|
||||
x = get_xbits(gb, length);
|
||||
|
||||
if (!(ctx->divx_version == 500 && ctx->divx_build == 413))
|
||||
skip_bits1(gb); /* marker bit */
|
||||
|
||||
length = get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
|
||||
if (length)
|
||||
if (length > 0)
|
||||
y = get_xbits(gb, length);
|
||||
|
||||
skip_bits1(gb); /* marker bit */
|
||||
|
||||
@@ -36,7 +36,7 @@ static int msrle_decode_pal4(AVCodecContext *avctx, AVPicture *pic,
|
||||
unsigned char rle_code;
|
||||
unsigned char extra_byte, odd_pixel;
|
||||
unsigned char stream_byte;
|
||||
unsigned int pixel_ptr = 0;
|
||||
int pixel_ptr = 0;
|
||||
int line = avctx->height - 1;
|
||||
int i;
|
||||
|
||||
|
||||
+4
-4
@@ -119,12 +119,12 @@ static int on2avc_decode_band_types(On2AVCContext *c, GetBitContext *gb)
|
||||
run_len = 1;
|
||||
do {
|
||||
run = get_bits(gb, bits_per_sect);
|
||||
if (run > num_bands - band - run_len) {
|
||||
av_log(c->avctx, AV_LOG_ERROR, "Invalid band type run\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
run_len += run;
|
||||
} while (run == esc_val);
|
||||
if (band + run_len > num_bands) {
|
||||
av_log(c->avctx, AV_LOG_ERROR, "Invalid band type run\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
for (i = band; i < band + run_len; i++) {
|
||||
c->band_type[i] = band_type;
|
||||
c->band_run_end[i] = band + run_len;
|
||||
|
||||
+12
-7
@@ -618,7 +618,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
||||
} else if ((s->bits_per_pixel == 1 || s->bits_per_pixel == 2 || s->bits_per_pixel == 4 || s->bits_per_pixel == 8) &&
|
||||
s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||
} else if (s->bit_depth == 1 && s->bits_per_pixel == 1) {
|
||||
} else if (s->bit_depth == 1 && s->bits_per_pixel == 1 && avctx->codec_id != AV_CODEC_ID_APNG) {
|
||||
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
|
||||
} else if (s->bit_depth == 8 &&
|
||||
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
@@ -968,7 +968,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
|
||||
AVDictionary *metadata = NULL;
|
||||
uint32_t tag, length;
|
||||
int decode_next_dat = 0;
|
||||
int ret = AVERROR_INVALIDDATA;
|
||||
int ret;
|
||||
AVFrame *ref;
|
||||
|
||||
for (;;) {
|
||||
@@ -984,12 +984,14 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
|
||||
if ( s->state & PNG_ALLIMAGE
|
||||
&& avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL)
|
||||
goto exit_loop;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
length = bytestream2_get_be32(&s->gb);
|
||||
if (length > 0x7fffffff || length > bytestream2_get_bytes_left(&s->gb)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "chunk too big\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
tag = bytestream2_get_le32(&s->gb);
|
||||
@@ -1001,11 +1003,11 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
|
||||
((tag >> 24) & 0xff), length);
|
||||
switch (tag) {
|
||||
case MKTAG('I', 'H', 'D', 'R'):
|
||||
if (decode_ihdr_chunk(avctx, s, length) < 0)
|
||||
if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0)
|
||||
goto fail;
|
||||
break;
|
||||
case MKTAG('p', 'H', 'Y', 's'):
|
||||
if (decode_phys_chunk(avctx, s) < 0)
|
||||
if ((ret = decode_phys_chunk(avctx, s)) < 0)
|
||||
goto fail;
|
||||
break;
|
||||
case MKTAG('f', 'c', 'T', 'L'):
|
||||
@@ -1018,15 +1020,17 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
|
||||
case MKTAG('f', 'd', 'A', 'T'):
|
||||
if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG)
|
||||
goto skip_tag;
|
||||
if (!decode_next_dat)
|
||||
if (!decode_next_dat) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
bytestream2_get_be32(&s->gb);
|
||||
length -= 4;
|
||||
/* fallthrough */
|
||||
case MKTAG('I', 'D', 'A', 'T'):
|
||||
if (CONFIG_APNG_DECODER && avctx->codec_id == AV_CODEC_ID_APNG && !decode_next_dat)
|
||||
goto skip_tag;
|
||||
if (decode_idat_chunk(avctx, s, length, p) < 0)
|
||||
if ((ret = decode_idat_chunk(avctx, s, length, p)) < 0)
|
||||
goto fail;
|
||||
break;
|
||||
case MKTAG('P', 'L', 'T', 'E'):
|
||||
@@ -1051,6 +1055,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
|
||||
if (!(s->state & PNG_ALLIMAGE))
|
||||
av_log(avctx, AV_LOG_ERROR, "IEND without all image\n");
|
||||
if (!(s->state & (PNG_ALLIMAGE|PNG_IDAT))) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
bytestream2_skip(&s->gb, 4); /* crc */
|
||||
@@ -1070,7 +1075,7 @@ exit_loop:
|
||||
/* handle p-frames only if a predecessor frame is available */
|
||||
ref = s->dispose_op == APNG_DISPOSE_OP_PREVIOUS ?
|
||||
s->previous_picture.f : s->last_picture.f;
|
||||
if (ref->data[0]) {
|
||||
if (ref->data[0] && s->last_picture.f->data[0]) {
|
||||
if ( !(avpkt->flags & AV_PKT_FLAG_KEY) && avctx->codec_tag != AV_RL32("MPNG")
|
||||
&& ref->width == p->width
|
||||
&& ref->height== p->height
|
||||
|
||||
@@ -183,6 +183,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
|
||||
|
||||
if (ctx->slice_count != slice_count || !ctx->slices) {
|
||||
av_freep(&ctx->slices);
|
||||
ctx->slice_count = 0;
|
||||
ctx->slices = av_mallocz_array(slice_count, sizeof(*ctx->slices));
|
||||
if (!ctx->slices)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -129,8 +129,7 @@ static int allocate_buffers(ShortenContext *s)
|
||||
av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->blocksize + s->nwrap >= UINT_MAX / sizeof(int32_t) ||
|
||||
s->blocksize + s->nwrap <= (unsigned)s->nwrap) {
|
||||
if (s->blocksize + (uint64_t)s->nwrap >= UINT_MAX / sizeof(int32_t)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"s->blocksize + s->nwrap too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -278,7 +277,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
|
||||
if (command == FN_QLPC) {
|
||||
/* read/validate prediction order */
|
||||
pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE);
|
||||
if (pred_order > s->nwrap) {
|
||||
if ((unsigned)pred_order > s->nwrap) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n",
|
||||
pred_order);
|
||||
return AVERROR(EINVAL);
|
||||
@@ -370,6 +369,11 @@ static int read_header(ShortenContext *s)
|
||||
s->nmean = get_uint(s, 0);
|
||||
|
||||
skip_bytes = get_uint(s, NSKIPSIZE);
|
||||
if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
for (i = 0; i < skip_bytes; i++)
|
||||
skip_bits(&s->gb, 8);
|
||||
}
|
||||
|
||||
@@ -155,6 +155,10 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
|
||||
if (!cur_frame) {
|
||||
av_frame_unref(mjpeg_data);
|
||||
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
|
||||
if (ret < 0) {
|
||||
s->mjpeg_data_size = 0;
|
||||
return ret;
|
||||
}
|
||||
} else if (!s->mjpeg_data_size)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
|
||||
+26
-5
@@ -497,12 +497,15 @@ static int predictor_calc_error(int *k, int *state, int order, int error)
|
||||
// copes better with quantization, and calculates the
|
||||
// actual whitened result as it goes.
|
||||
|
||||
static void modified_levinson_durbin(int *window, int window_entries,
|
||||
static int modified_levinson_durbin(int *window, int window_entries,
|
||||
int *out, int out_entries, int channels, int *tap_quant)
|
||||
{
|
||||
int i;
|
||||
int *state = av_calloc(window_entries, sizeof(*state));
|
||||
|
||||
if (!state)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
memcpy(state, window, 4* window_entries);
|
||||
|
||||
for (i = 0; i < out_entries; i++)
|
||||
@@ -567,6 +570,7 @@ static void modified_levinson_durbin(int *window, int window_entries,
|
||||
}
|
||||
|
||||
av_free(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int code_samplerate(int samplerate)
|
||||
@@ -627,6 +631,9 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
|
||||
|
||||
// generate taps
|
||||
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
|
||||
if (!s->tap_quant)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for (i = 0; i < s->num_taps; i++)
|
||||
s->tap_quant[i] = ff_sqrt(i+1);
|
||||
|
||||
@@ -656,7 +663,7 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx)
|
||||
|
||||
s->window_size = ((2*s->tail_size)+s->frame_size);
|
||||
s->window = av_calloc(s->window_size, sizeof(*s->window));
|
||||
if (!s->window)
|
||||
if (!s->window || !s->int_samples)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
avctx->extradata = av_mallocz(16);
|
||||
@@ -769,8 +776,11 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
s->tail[i] = s->int_samples[s->frame_size - s->tail_size + i];
|
||||
|
||||
// generate taps
|
||||
modified_levinson_durbin(s->window, s->window_size,
|
||||
ret = modified_levinson_durbin(s->window, s->window_size,
|
||||
s->predictor_k, s->num_taps, s->channels, s->tap_quant);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = intlist_write(&c, state, s->predictor_k, s->num_taps, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
@@ -873,13 +883,19 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
|
||||
|
||||
if (s->version >= 1)
|
||||
{
|
||||
int sample_rate_index;
|
||||
s->channels = get_bits(&gb, 2);
|
||||
s->samplerate = samplerate_table[get_bits(&gb, 4)];
|
||||
sample_rate_index = get_bits(&gb, 4);
|
||||
if (sample_rate_index >= FF_ARRAY_ELEMS(samplerate_table)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid sample_rate_index %d\n", sample_rate_index);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
s->samplerate = samplerate_table[sample_rate_index];
|
||||
av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n",
|
||||
s->channels, s->samplerate);
|
||||
}
|
||||
|
||||
if (s->channels > MAX_CHANNELS)
|
||||
if (s->channels > MAX_CHANNELS || s->channels < 1)
|
||||
{
|
||||
av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@@ -913,6 +929,9 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
|
||||
|
||||
// generate taps
|
||||
s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant));
|
||||
if (!s->tap_quant)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for (i = 0; i < s->num_taps; i++)
|
||||
s->tap_quant[i] = ff_sqrt(i+1);
|
||||
|
||||
@@ -932,6 +951,8 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples));
|
||||
if (!s->int_samples)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
return 0;
|
||||
|
||||
@@ -231,6 +231,12 @@ static int decode_format80(VqaContext *s, int src_size,
|
||||
unsigned char color;
|
||||
int i;
|
||||
|
||||
if (src_size < 0 || src_size > bytestream2_get_bytes_left(&s->gb)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Chunk size %d is out of range\n",
|
||||
src_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
start = bytestream2_tell(&s->gb);
|
||||
while (bytestream2_tell(&s->gb) - start < src_size) {
|
||||
opcode = bytestream2_get_byte(&s->gb);
|
||||
|
||||
@@ -472,6 +472,14 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb,
|
||||
s->decorr[i].samplesB[0] = L;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == AV_SAMPLE_FMT_S16P) {
|
||||
if (FFABS(L) + FFABS(R) > (1<<19)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "sample %d %d too large\n", L, R);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
pos = (pos + 1) & 7;
|
||||
if (s->joint)
|
||||
L += (R -= (L >> 1));
|
||||
|
||||
@@ -1622,7 +1622,9 @@ VP9_IDCT_IDCT_16x16_ADD_XMM avx
|
||||
PSIGNW m3, [pw_m1] ; m3=out1[w], m7=t10[w]
|
||||
SUMSUB_BA w, 2, 6, 1 ; m2=out14[w], m6=t11[w]
|
||||
|
||||
%if cpuflag(ssse3)
|
||||
; unfortunately, the code below overflows in some cases, e.g.
|
||||
; http://downloads.webmproject.org/test_data/libvpx/vp90-2-14-resize-fp-tiles-16-8.webm
|
||||
%if 0; cpuflag(ssse3)
|
||||
SUMSUB_BA w, 7, 6, 1
|
||||
pmulhrsw m7, [pw_11585x2] ; m7=out6[w]
|
||||
pmulhrsw m6, [pw_11585x2] ; m6=out9[w]
|
||||
@@ -1699,7 +1701,9 @@ VP9_IDCT_IDCT_16x16_ADD_XMM avx
|
||||
SUMSUB_BA w, 5, 7, 4
|
||||
PSIGNW m5, [pw_m1] ; m12=out15[w], m8=t3[w]
|
||||
|
||||
%if cpuflag(ssse3)
|
||||
; unfortunately, the code below overflows in some cases, e.g.
|
||||
; http://downloads.webmproject.org/test_data/libvpx/vp90-2-14-resize-fp-tiles-16-8-4-2-1.webm
|
||||
%if 0 ; cpuflag(ssse3)
|
||||
SUMSUB_BA w, 7, 6, 4
|
||||
pmulhrsw m7, [pw_m11585x2] ; m8=out7[w]
|
||||
pmulhrsw m6, [pw_11585x2] ; m1=out8[w]
|
||||
|
||||
+1
-1
@@ -286,7 +286,7 @@ static void list_formats(AVFormatContext *ctx, int type)
|
||||
} else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
|
||||
type & V4L_COMPFORMATS) {
|
||||
const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
|
||||
av_log(ctx, AV_LOG_INFO, "Compressedll : %9s : %20s :",
|
||||
av_log(ctx, AV_LOG_INFO, "Compressed: %9s : %20s :",
|
||||
desc ? desc->name : "Unsupported",
|
||||
vfd.description);
|
||||
} else {
|
||||
|
||||
+25
-4
@@ -149,13 +149,25 @@ static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt)
|
||||
xcb_get_image_cookie_t iq;
|
||||
xcb_get_image_reply_t *img;
|
||||
xcb_drawable_t drawable = c->screen->root;
|
||||
xcb_generic_error_t *e = NULL;
|
||||
uint8_t *data;
|
||||
int length, ret;
|
||||
|
||||
iq = xcb_get_image(c->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, drawable,
|
||||
c->x, c->y, c->width, c->height, ~0);
|
||||
|
||||
img = xcb_get_image_reply(c->conn, iq, NULL);
|
||||
img = xcb_get_image_reply(c->conn, iq, &e);
|
||||
|
||||
if (e) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Cannot get the image data "
|
||||
"event_error: response_type:%u error_code:%u "
|
||||
"sequence:%u resource_id:%u minor_code:%u major_code:%u.\n",
|
||||
e->response_type, e->error_code,
|
||||
e->sequence, e->resource_id, e->minor_code, e->major_code);
|
||||
return AVERROR(EACCES);
|
||||
}
|
||||
|
||||
if (!img)
|
||||
return AVERROR(EAGAIN);
|
||||
|
||||
@@ -409,7 +421,7 @@ static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
ret = xcbgrab_frame(s, pkt);
|
||||
|
||||
#if CONFIG_LIBXCB_XFIXES
|
||||
if (c->draw_mouse && p->same_screen)
|
||||
if (ret >= 0 && c->draw_mouse && p->same_screen)
|
||||
xcbgrab_draw_mouse(s, pkt, p, geo);
|
||||
#endif
|
||||
|
||||
@@ -520,8 +532,17 @@ static int create_stream(AVFormatContext *s)
|
||||
gc = xcb_get_geometry(c->conn, c->screen->root);
|
||||
geo = xcb_get_geometry_reply(c->conn, gc, NULL);
|
||||
|
||||
c->width = FFMIN(geo->width, c->width);
|
||||
c->height = FFMIN(geo->height, c->height);
|
||||
if (c->x + c->width >= geo->width ||
|
||||
c->y + c->height >= geo->height) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Capture area %dx%d at position %d.%d "
|
||||
"outside the screen size %dx%d\n",
|
||||
c->width, c->height,
|
||||
c->x, c->y,
|
||||
geo->width, geo->height);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
c->time_base = (AVRational){ st->avg_frame_rate.den,
|
||||
st->avg_frame_rate.num };
|
||||
c->time_frame = av_gettime();
|
||||
|
||||
@@ -32,6 +32,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
||||
AVFrame *frame;
|
||||
int frame_decoded, ret = 0;
|
||||
AVPacket pkt;
|
||||
AVDictionary *opt=NULL;
|
||||
|
||||
av_init_packet(&pkt);
|
||||
|
||||
@@ -57,7 +58,8 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
|
||||
av_dict_set(&opt, "thread_type", "slice", 0);
|
||||
if ((ret = avcodec_open2(codec_ctx, codec, &opt)) < 0) {
|
||||
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -97,6 +99,7 @@ end:
|
||||
avcodec_close(codec_ctx);
|
||||
avformat_close_input(&format_ctx);
|
||||
av_frame_free(&frame);
|
||||
av_dict_free(&opt);
|
||||
|
||||
if (ret < 0)
|
||||
av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename);
|
||||
|
||||
+25
-3
@@ -128,7 +128,7 @@ static inline int get_duration(AVIStream *ast, int len)
|
||||
{
|
||||
if (ast->sample_size)
|
||||
return len;
|
||||
else if (ast->dshow_block_align > 1)
|
||||
else if (ast->dshow_block_align)
|
||||
return (len + ast->dshow_block_align - 1) / ast->dshow_block_align;
|
||||
else
|
||||
return 1;
|
||||
@@ -450,6 +450,7 @@ static int calculate_bitrate(AVFormatContext *s)
|
||||
int64_t len = 0;
|
||||
AVStream *st = s->streams[i];
|
||||
int64_t duration;
|
||||
int64_t bitrate;
|
||||
|
||||
for (j = 0; j < st->nb_index_entries; j++)
|
||||
len += st->index_entries[j].size;
|
||||
@@ -457,7 +458,10 @@ static int calculate_bitrate(AVFormatContext *s)
|
||||
if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
|
||||
continue;
|
||||
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
|
||||
st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
|
||||
bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
|
||||
if (bitrate <= INT_MAX && bitrate > 0) {
|
||||
st->codec->bit_rate = bitrate;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -688,6 +692,23 @@ static int avi_read_header(AVFormatContext *s)
|
||||
default:
|
||||
av_log(s, AV_LOG_INFO, "unknown stream type %X\n", tag1);
|
||||
}
|
||||
|
||||
if (ast->sample_size < 0) {
|
||||
if (s->error_recognition & AV_EF_EXPLODE) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Invalid sample_size %d at stream %d\n",
|
||||
ast->sample_size,
|
||||
stream_index);
|
||||
goto fail;
|
||||
}
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"Invalid sample_size %d at stream %d "
|
||||
"setting it to 0\n",
|
||||
ast->sample_size,
|
||||
stream_index);
|
||||
ast->sample_size = 0;
|
||||
}
|
||||
|
||||
if (ast->sample_size == 0) {
|
||||
st->duration = st->nb_frames;
|
||||
if (st->duration > 0 && avi->io_fsize > 0 && avi->riff_end > avi->io_fsize) {
|
||||
@@ -845,7 +866,8 @@ static int avi_read_header(AVFormatContext *s)
|
||||
st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_AMV;
|
||||
ast->dshow_block_align = 0;
|
||||
}
|
||||
if (st->codec->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
|
||||
if (st->codec->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align <= 4 && ast->dshow_block_align ||
|
||||
st->codec->codec_id == AV_CODEC_ID_MP2 && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
|
||||
av_log(s, AV_LOG_DEBUG, "overriding invalid dshow_block_align of %d\n", ast->dshow_block_align);
|
||||
ast->dshow_block_align = 0;
|
||||
}
|
||||
|
||||
+4
-1
@@ -194,7 +194,10 @@ static int read_header(AVFormatContext *s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
avio_seek(pb, vst->index_entries[0].pos, SEEK_SET);
|
||||
if (vst->index_entries)
|
||||
avio_seek(pb, vst->index_entries[0].pos, SEEK_SET);
|
||||
else
|
||||
avio_skip(pb, 4);
|
||||
|
||||
bink->current_track = -1;
|
||||
return 0;
|
||||
|
||||
+16
-3
@@ -129,8 +129,12 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
|
||||
avio_skip(pb, size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avio_read(pb, preamble, ALAC_PREAMBLE);
|
||||
if (avio_read(pb, preamble, ALAC_PREAMBLE) != ALAC_PREAMBLE) {
|
||||
av_log(s, AV_LOG_ERROR, "failed to read preamble\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
av_freep(&st->codec->extradata);
|
||||
if (ff_alloc_extradata(st->codec, ALAC_HEADER))
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -144,17 +148,26 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
|
||||
av_freep(&st->codec->extradata);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avio_read(pb, st->codec->extradata, ALAC_HEADER);
|
||||
if (avio_read(pb, st->codec->extradata, ALAC_HEADER) != ALAC_HEADER) {
|
||||
av_log(s, AV_LOG_ERROR, "failed to read kuki header\n");
|
||||
av_freep(&st->codec->extradata);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avio_skip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
|
||||
} else {
|
||||
AV_WB32(st->codec->extradata, 36);
|
||||
memcpy(&st->codec->extradata[4], "alac", 4);
|
||||
AV_WB32(&st->codec->extradata[8], 0);
|
||||
memcpy(&st->codec->extradata[12], preamble, 12);
|
||||
avio_read(pb, &st->codec->extradata[24], ALAC_NEW_KUKI - 12);
|
||||
if (avio_read(pb, &st->codec->extradata[24], ALAC_NEW_KUKI - 12) != ALAC_NEW_KUKI - 12) {
|
||||
av_log(s, AV_LOG_ERROR, "failed to read new kuki header\n");
|
||||
av_freep(&st->codec->extradata);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avio_skip(pb, size - ALAC_NEW_KUKI);
|
||||
}
|
||||
} else {
|
||||
av_freep(&st->codec->extradata);
|
||||
if (ff_get_extradata(st->codec, pb, size) < 0)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ static int write_manifest(AVFormatContext *s, int final)
|
||||
}
|
||||
|
||||
if (c->has_video) {
|
||||
avio_printf(out, "\t\t<AdaptationSet id=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n");
|
||||
avio_printf(out, "\t\t<AdaptationSet contentType=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n");
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
AVStream *st = s->streams[i];
|
||||
OutputStream *os = &c->streams[i];
|
||||
@@ -509,7 +509,7 @@ static int write_manifest(AVFormatContext *s, int final)
|
||||
avio_printf(out, "\t\t</AdaptationSet>\n");
|
||||
}
|
||||
if (c->has_audio) {
|
||||
avio_printf(out, "\t\t<AdaptationSet id=\"audio\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n");
|
||||
avio_printf(out, "\t\t<AdaptationSet contentType=\"audio\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n");
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
AVStream *st = s->streams[i];
|
||||
OutputStream *os = &c->streams[i];
|
||||
|
||||
@@ -50,12 +50,14 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
|
||||
int last_block, int bitexact)
|
||||
{
|
||||
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
||||
unsigned int len;
|
||||
int64_t len;
|
||||
uint8_t *p, *p0;
|
||||
|
||||
ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
|
||||
|
||||
len = ff_vorbiscomment_length(*m, vendor);
|
||||
if (len >= ((1<<24) - 4))
|
||||
return AVERROR(EINVAL);
|
||||
p0 = av_malloc(len+4);
|
||||
if (!p0)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
+10
-2
@@ -189,7 +189,7 @@ static void skip_sub_layer_hrd_parameters(GetBitContext *gb,
|
||||
}
|
||||
}
|
||||
|
||||
static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
|
||||
static int skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
|
||||
unsigned int max_sub_layers_minus1)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -246,8 +246,11 @@ static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
|
||||
else
|
||||
low_delay_hrd_flag = get_bits1(gb);
|
||||
|
||||
if (!low_delay_hrd_flag)
|
||||
if (!low_delay_hrd_flag) {
|
||||
cpb_cnt_minus1 = get_ue_golomb_long(gb);
|
||||
if (cpb_cnt_minus1 > 31)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (nal_hrd_parameters_present_flag)
|
||||
skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
|
||||
@@ -257,6 +260,8 @@ static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
|
||||
skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
|
||||
sub_pic_hrd_params_present_flag);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void skip_timing_info(GetBitContext *gb)
|
||||
@@ -457,6 +462,9 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
|
||||
unsigned int num_negative_pics = get_ue_golomb_long(gb);
|
||||
unsigned int num_positive_pics = get_ue_golomb_long(gb);
|
||||
|
||||
if ((num_positive_pics + (uint64_t)num_negative_pics) * 2 > get_bits_left(gb))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
|
||||
|
||||
for (i = 0; i < num_negative_pics; i++) {
|
||||
|
||||
+1
-1
@@ -205,7 +205,7 @@ static int check_tag(AVIOContext *s, int offset, unsigned int len)
|
||||
|
||||
if (len > 4 ||
|
||||
avio_seek(s, offset, SEEK_SET) < 0 ||
|
||||
avio_read(s, tag, len) < len)
|
||||
avio_read(s, tag, len) < (int)len)
|
||||
return -1;
|
||||
else if (!AV_RB32(tag) || is_tag(tag, len))
|
||||
return 1;
|
||||
|
||||
@@ -341,7 +341,10 @@ int ff_img_read_header(AVFormatContext *s1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
|
||||
if (s1->flags & AVFMT_FLAG_CUSTOM_IO) {
|
||||
avio_seek(s1->pb, 0, SEEK_SET);
|
||||
} else
|
||||
ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
|
||||
}
|
||||
if (st->codec->codec_id == AV_CODEC_ID_NONE)
|
||||
st->codec->codec_id = ff_guess_image2_codec(s->path);
|
||||
|
||||
@@ -97,6 +97,8 @@ struct AVFormatInternal {
|
||||
AVRational offset_timebase;
|
||||
|
||||
int inject_global_side_data;
|
||||
|
||||
int avoid_negative_ts_use_pts;
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
@@ -99,12 +99,17 @@ const CodecTags ff_mkv_codec_tags[]={
|
||||
{"" , AV_CODEC_ID_NONE}
|
||||
};
|
||||
|
||||
const CodecMime ff_mkv_mime_tags[] = {
|
||||
{"text/plain" , AV_CODEC_ID_TEXT},
|
||||
const CodecMime ff_mkv_image_mime_tags[] = {
|
||||
{"image/gif" , AV_CODEC_ID_GIF},
|
||||
{"image/jpeg" , AV_CODEC_ID_MJPEG},
|
||||
{"image/png" , AV_CODEC_ID_PNG},
|
||||
{"image/tiff" , AV_CODEC_ID_TIFF},
|
||||
|
||||
{"" , AV_CODEC_ID_NONE}
|
||||
};
|
||||
|
||||
const CodecMime ff_mkv_mime_tags[] = {
|
||||
{"text/plain" , AV_CODEC_ID_TEXT},
|
||||
{"application/x-truetype-font", AV_CODEC_ID_TTF},
|
||||
{"application/x-font" , AV_CODEC_ID_TTF},
|
||||
{"application/vnd.ms-opentype", AV_CODEC_ID_OTF},
|
||||
|
||||
@@ -280,6 +280,7 @@ typedef struct CodecTags{
|
||||
|
||||
extern const CodecTags ff_mkv_codec_tags[];
|
||||
extern const CodecMime ff_mkv_mime_tags[];
|
||||
extern const CodecMime ff_mkv_image_mime_tags[];
|
||||
extern const AVMetadataConv ff_mkv_metadata_conv[];
|
||||
extern const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB];
|
||||
extern const char * const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_COUNT];
|
||||
|
||||
+38
-21
@@ -1274,15 +1274,13 @@ static int matroska_decode_buffer(uint8_t **buf, int *buf_size,
|
||||
newpktdata = av_realloc(pkt_data, pkt_size);
|
||||
if (!newpktdata) {
|
||||
inflateEnd(&zstream);
|
||||
result = AVERROR(ENOMEM);
|
||||
goto failed;
|
||||
}
|
||||
pkt_data = newpktdata;
|
||||
zstream.avail_out = pkt_size - zstream.total_out;
|
||||
zstream.next_out = pkt_data + zstream.total_out;
|
||||
if (pkt_data) {
|
||||
result = inflate(&zstream, Z_NO_FLUSH);
|
||||
} else
|
||||
result = Z_MEM_ERROR;
|
||||
result = inflate(&zstream, Z_NO_FLUSH);
|
||||
} while (result == Z_OK && pkt_size < 10000000);
|
||||
pkt_size = zstream.total_out;
|
||||
inflateEnd(&zstream);
|
||||
@@ -1309,15 +1307,13 @@ static int matroska_decode_buffer(uint8_t **buf, int *buf_size,
|
||||
newpktdata = av_realloc(pkt_data, pkt_size);
|
||||
if (!newpktdata) {
|
||||
BZ2_bzDecompressEnd(&bzstream);
|
||||
result = AVERROR(ENOMEM);
|
||||
goto failed;
|
||||
}
|
||||
pkt_data = newpktdata;
|
||||
bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
|
||||
bzstream.next_out = pkt_data + bzstream.total_out_lo32;
|
||||
if (pkt_data) {
|
||||
result = BZ2_bzDecompress(&bzstream);
|
||||
} else
|
||||
result = BZ_MEM_ERROR;
|
||||
result = BZ2_bzDecompress(&bzstream);
|
||||
} while (result == BZ_OK && pkt_size < 10000000);
|
||||
pkt_size = bzstream.total_out_lo32;
|
||||
BZ2_bzDecompressEnd(&bzstream);
|
||||
@@ -1496,7 +1492,7 @@ static void matroska_add_index_entries(MatroskaDemuxContext *matroska)
|
||||
{
|
||||
EbmlList *index_list;
|
||||
MatroskaIndex *index;
|
||||
int index_scale = 1;
|
||||
uint64_t index_scale = 1;
|
||||
int i, j;
|
||||
|
||||
if (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)
|
||||
@@ -2004,8 +2000,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
|
||||
snprintf(buf, sizeof(buf), "%s_%d",
|
||||
ff_matroska_video_stereo_plane[planes[j].type], i);
|
||||
for (k=0; k < matroska->tracks.nb_elem; k++)
|
||||
if (planes[j].uid == tracks[k].uid) {
|
||||
av_dict_set(&s->streams[k]->metadata,
|
||||
if (planes[j].uid == tracks[k].uid && tracks[k].stream) {
|
||||
av_dict_set(&tracks[k].stream->metadata,
|
||||
"stereo_mode", buf, 0);
|
||||
break;
|
||||
}
|
||||
@@ -2142,20 +2138,41 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
|
||||
av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
|
||||
st->codec->codec_id = AV_CODEC_ID_NONE;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
|
||||
if (ff_alloc_extradata(st->codec, attachments[j].bin.size))
|
||||
break;
|
||||
memcpy(st->codec->extradata, attachments[j].bin.data,
|
||||
attachments[j].bin.size);
|
||||
|
||||
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
|
||||
if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime,
|
||||
strlen(ff_mkv_mime_tags[i].str))) {
|
||||
st->codec->codec_id = ff_mkv_mime_tags[i].id;
|
||||
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
|
||||
if (!strncmp(ff_mkv_image_mime_tags[i].str, attachments[j].mime,
|
||||
strlen(ff_mkv_image_mime_tags[i].str))) {
|
||||
st->codec->codec_id = ff_mkv_image_mime_tags[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
attachments[j].stream = st;
|
||||
|
||||
if (st->codec->codec_id != AV_CODEC_ID_NONE) {
|
||||
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
|
||||
av_init_packet(&st->attached_pic);
|
||||
if ((res = av_new_packet(&st->attached_pic, attachments[j].bin.size)) < 0)
|
||||
return res;
|
||||
memcpy(st->attached_pic.data, attachments[j].bin.data, attachments[j].bin.size);
|
||||
st->attached_pic.stream_index = st->index;
|
||||
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
|
||||
} else {
|
||||
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
|
||||
if (ff_alloc_extradata(st->codec, attachments[j].bin.size))
|
||||
break;
|
||||
memcpy(st->codec->extradata, attachments[j].bin.data,
|
||||
attachments[j].bin.size);
|
||||
|
||||
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
|
||||
if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime,
|
||||
strlen(ff_mkv_mime_tags[i].str))) {
|
||||
st->codec->codec_id = ff_mkv_mime_tags[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
attachments[j].stream = st;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -545,12 +545,15 @@ static int put_flac_codecpriv(AVFormatContext *s,
|
||||
"Lavf" : LIBAVFORMAT_IDENT;
|
||||
AVDictionary *dict = NULL;
|
||||
uint8_t buf[32], *data, *p;
|
||||
int len;
|
||||
int64_t len;
|
||||
|
||||
snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
|
||||
av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
|
||||
|
||||
len = ff_vorbiscomment_length(dict, vendor);
|
||||
if (len >= ((1<<24) - 4))
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
data = av_malloc(len + 4);
|
||||
if (!data) {
|
||||
av_dict_free(&dict);
|
||||
@@ -940,6 +943,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
|
||||
// if there is no mkv-specific codec ID, use VFW mode
|
||||
put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC");
|
||||
mkv->tracks[i].write_dts = 1;
|
||||
s->internal->avoid_negative_ts_use_pts = 0;
|
||||
}
|
||||
|
||||
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0);
|
||||
@@ -1265,6 +1269,11 @@ static int mkv_write_attachments(AVFormatContext *s)
|
||||
mimetype = ff_mkv_mime_tags[i].str;
|
||||
break;
|
||||
}
|
||||
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
|
||||
if (ff_mkv_image_mime_tags[i].id == st->codec->codec_id) {
|
||||
mimetype = ff_mkv_image_mime_tags[i].str;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!mimetype) {
|
||||
av_log(s, AV_LOG_ERROR, "Attachment stream %d has no mimetype tag and "
|
||||
@@ -1311,8 +1320,10 @@ static int mkv_write_header(AVFormatContext *s)
|
||||
else
|
||||
mkv->mode = MODE_MATROSKAv2;
|
||||
|
||||
if (s->avoid_negative_ts < 0)
|
||||
if (s->avoid_negative_ts < 0) {
|
||||
s->avoid_negative_ts = 1;
|
||||
s->internal->avoid_negative_ts_use_pts = 1;
|
||||
}
|
||||
|
||||
if (mkv->mode != MODE_WEBM ||
|
||||
av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
|
||||
@@ -1995,6 +2006,12 @@ static const AVCodecTag additional_video_tags[] = {
|
||||
{ AV_CODEC_ID_NONE, 0xFFFFFFFF }
|
||||
};
|
||||
|
||||
static const AVCodecTag additional_subtitle_tags[] = {
|
||||
{ AV_CODEC_ID_DVB_SUBTITLE, 0xFFFFFFFF },
|
||||
{ AV_CODEC_ID_HDMV_PGS_SUBTITLE, 0xFFFFFFFF },
|
||||
{ AV_CODEC_ID_NONE, 0xFFFFFFFF }
|
||||
};
|
||||
|
||||
#define OFFSET(x) offsetof(MatroskaMuxContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption options[] = {
|
||||
@@ -2032,7 +2049,7 @@ AVOutputFormat ff_matroska_muxer = {
|
||||
AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
|
||||
.codec_tag = (const AVCodecTag* const []){
|
||||
ff_codec_bmp_tags, ff_codec_wav_tags,
|
||||
additional_audio_tags, additional_video_tags, 0
|
||||
additional_audio_tags, additional_video_tags, additional_subtitle_tags, 0
|
||||
},
|
||||
.subtitle_codec = AV_CODEC_ID_ASS,
|
||||
.query_codec = mkv_query_codec,
|
||||
|
||||
+11
-3
@@ -211,8 +211,10 @@ static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
|
||||
double longitude, latitude;
|
||||
const char *key = "location";
|
||||
|
||||
if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4)
|
||||
if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "loci too short\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
avio_skip(pb, 4); // version+flags
|
||||
langcode = avio_rb16(pb);
|
||||
@@ -220,13 +222,17 @@ static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
|
||||
len -= 6;
|
||||
|
||||
len -= avio_get_str(pb, len, buf, sizeof(buf)); // place name
|
||||
if (len < 1)
|
||||
if (len < 1) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "place name too long\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
avio_skip(pb, 1); // role
|
||||
len -= 1;
|
||||
|
||||
if (len < 14)
|
||||
if (len < 12) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "no space for coordinates left (%d)\n", len);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
longitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
|
||||
latitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
|
||||
|
||||
@@ -1209,6 +1215,8 @@ static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
uint64_t original_size;
|
||||
if (c->fc->nb_streams >= 1) {
|
||||
AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
|
||||
if (codec->codec_id == AV_CODEC_ID_H264)
|
||||
return 0;
|
||||
if (atom.size == 16) {
|
||||
original_size = codec->extradata_size;
|
||||
ret = mov_realloc_extradata(codec, atom);
|
||||
|
||||
+24
-12
@@ -554,10 +554,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (s->avoid_negative_ts > 0) {
|
||||
AVStream *st = s->streams[pkt->stream_index];
|
||||
int64_t offset = st->mux_ts_offset;
|
||||
int64_t ts = s->internal->avoid_negative_ts_use_pts ? pkt->pts : pkt->dts;
|
||||
|
||||
if (s->internal->offset == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE &&
|
||||
(pkt->dts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) {
|
||||
s->internal->offset = -pkt->dts;
|
||||
if (s->internal->offset == AV_NOPTS_VALUE && ts != AV_NOPTS_VALUE &&
|
||||
(ts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) {
|
||||
s->internal->offset = -ts;
|
||||
s->internal->offset_timebase = st->time_base;
|
||||
}
|
||||
|
||||
@@ -574,15 +575,26 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
if (pkt->pts != AV_NOPTS_VALUE)
|
||||
pkt->pts += offset;
|
||||
|
||||
av_assert2(pkt->dts == AV_NOPTS_VALUE || pkt->dts >= 0 || s->max_interleave_delta > 0);
|
||||
if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) {
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"Packets poorly interleaved, failed to avoid negative "
|
||||
"timestamp %s in stream %d.\n"
|
||||
"Try -max_interleave_delta 0 as a possible workaround.\n",
|
||||
av_ts2str(pkt->dts),
|
||||
pkt->stream_index
|
||||
);
|
||||
if (s->internal->avoid_negative_ts_use_pts) {
|
||||
if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < 0) {
|
||||
av_log(s, AV_LOG_WARNING, "failed to avoid negative "
|
||||
"pts %s in stream %d.\n"
|
||||
"Try -avoid_negative_ts 1 as a possible workaround.\n",
|
||||
av_ts2str(pkt->dts),
|
||||
pkt->stream_index
|
||||
);
|
||||
}
|
||||
} else {
|
||||
av_assert2(pkt->dts == AV_NOPTS_VALUE || pkt->dts >= 0 || s->max_interleave_delta > 0);
|
||||
if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) {
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"Packets poorly interleaved, failed to avoid negative "
|
||||
"timestamp %s in stream %d.\n"
|
||||
"Try -max_interleave_delta 0 as a possible workaround.\n",
|
||||
av_ts2str(pkt->dts),
|
||||
pkt->stream_index
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-7
@@ -2263,7 +2263,14 @@ static int mxf_write_footer(AVFormatContext *s)
|
||||
{
|
||||
MXFContext *mxf = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
int err;
|
||||
int err = 0;
|
||||
|
||||
if (!mxf->header_written ||
|
||||
(s->oformat == &ff_mxf_opatom_muxer && !mxf->body_partition_offset)) {
|
||||
/* reason could be invalid options/not supported codec/out of memory */
|
||||
err = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
mxf->duration = mxf->last_indexed_edit_unit + mxf->edit_units_count;
|
||||
|
||||
@@ -2271,10 +2278,10 @@ static int mxf_write_footer(AVFormatContext *s)
|
||||
mxf->footer_partition_offset = avio_tell(pb);
|
||||
if (mxf->edit_unit_byte_count && s->oformat != &ff_mxf_opatom_muxer) { // no need to repeat index
|
||||
if ((err = mxf_write_partition(s, 0, 0, footer_partition_key, 0)) < 0)
|
||||
return err;
|
||||
goto end;
|
||||
} else {
|
||||
if ((err = mxf_write_partition(s, 0, 2, footer_partition_key, 0)) < 0)
|
||||
return err;
|
||||
goto end;
|
||||
mxf_write_klv_fill(s);
|
||||
mxf_write_index_table_segment(s);
|
||||
}
|
||||
@@ -2287,21 +2294,22 @@ static int mxf_write_footer(AVFormatContext *s)
|
||||
/* rewrite body partition to update lengths */
|
||||
avio_seek(pb, mxf->body_partition_offset[0], SEEK_SET);
|
||||
if ((err = mxf_write_opatom_body_partition(s)) < 0)
|
||||
return err;
|
||||
goto end;
|
||||
}
|
||||
|
||||
avio_seek(pb, 0, SEEK_SET);
|
||||
if (mxf->edit_unit_byte_count && s->oformat != &ff_mxf_opatom_muxer) {
|
||||
if ((err = mxf_write_partition(s, 1, 2, header_closed_partition_key, 1)) < 0)
|
||||
return err;
|
||||
goto end;
|
||||
mxf_write_klv_fill(s);
|
||||
mxf_write_index_table_segment(s);
|
||||
} else {
|
||||
if ((err = mxf_write_partition(s, 0, 0, header_closed_partition_key, 1)) < 0)
|
||||
return err;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
ff_audio_interleave_close(s);
|
||||
|
||||
av_freep(&mxf->index_entries);
|
||||
@@ -2311,7 +2319,7 @@ static int mxf_write_footer(AVFormatContext *s)
|
||||
|
||||
mxf_free(s);
|
||||
|
||||
return 0;
|
||||
return err < 0 ? err : 0;
|
||||
}
|
||||
|
||||
static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
|
||||
|
||||
@@ -77,8 +77,10 @@ int ff_tls_init(void)
|
||||
if (!CRYPTO_get_locking_callback()) {
|
||||
int i;
|
||||
openssl_mutexes = av_malloc_array(sizeof(pthread_mutex_t), CRYPTO_num_locks());
|
||||
if (!openssl_mutexes)
|
||||
if (!openssl_mutexes) {
|
||||
avpriv_unlock_avformat();
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
for (i = 0; i < CRYPTO_num_locks(); i++)
|
||||
pthread_mutex_init(&openssl_mutexes[i], NULL);
|
||||
CRYPTO_set_locking_callback(openssl_lock);
|
||||
|
||||
+22
-7
@@ -294,7 +294,7 @@ static int decode_main_header(NUTContext *nut)
|
||||
while (tmp_fields-- > 8)
|
||||
ffio_read_varlen(bc);
|
||||
|
||||
if (count == 0 || i + count > 256) {
|
||||
if (count <= 0 || count > 256 - (i <= 'N') - i) {
|
||||
av_log(s, AV_LOG_ERROR, "illegal count %d at %d\n", count, i);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -505,6 +505,10 @@ static int decode_info_header(NUTContext *nut)
|
||||
nut->time_base[chapter_start %
|
||||
nut->time_base_count],
|
||||
start, start + chapter_len, NULL);
|
||||
if (!chapter) {
|
||||
av_log(s, AV_LOG_ERROR, "could not create chapter\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
metadata = &chapter->metadata;
|
||||
} else if (stream_id_plus1) {
|
||||
st = s->streams[stream_id_plus1 - 1];
|
||||
@@ -520,6 +524,8 @@ static int decode_info_header(NUTContext *nut)
|
||||
for (i = 0; i < count; i++) {
|
||||
get_str(bc, name, sizeof(name));
|
||||
value = get_s(bc);
|
||||
str_value[0] = 0;
|
||||
|
||||
if (value == -1) {
|
||||
type = "UTF-8";
|
||||
get_str(bc, str_value, sizeof(str_value));
|
||||
@@ -553,7 +559,8 @@ static int decode_info_header(NUTContext *nut)
|
||||
|
||||
if (stream_id_plus1 && !strcmp(name, "r_frame_rate")) {
|
||||
sscanf(str_value, "%d/%d", &st->r_frame_rate.num, &st->r_frame_rate.den);
|
||||
if (st->r_frame_rate.num >= 1000LL*st->r_frame_rate.den)
|
||||
if (st->r_frame_rate.num >= 1000LL*st->r_frame_rate.den ||
|
||||
st->r_frame_rate.num < 0 || st->r_frame_rate.num < 0)
|
||||
st->r_frame_rate.num = st->r_frame_rate.den = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -740,12 +747,14 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int nut_read_close(AVFormatContext *s);
|
||||
|
||||
static int nut_read_header(AVFormatContext *s)
|
||||
{
|
||||
NUTContext *nut = s->priv_data;
|
||||
AVIOContext *bc = s->pb;
|
||||
int64_t pos;
|
||||
int initialized_stream_count;
|
||||
int initialized_stream_count, ret = 0;
|
||||
|
||||
nut->avf = s;
|
||||
|
||||
@@ -755,7 +764,8 @@ static int nut_read_header(AVFormatContext *s)
|
||||
pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
|
||||
if (pos < 0 + 1) {
|
||||
av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto end;
|
||||
}
|
||||
} while (decode_main_header(nut) < 0);
|
||||
|
||||
@@ -765,7 +775,8 @@ static int nut_read_header(AVFormatContext *s)
|
||||
pos = find_startcode(bc, STREAM_STARTCODE, pos) + 1;
|
||||
if (pos < 0 + 1) {
|
||||
av_log(s, AV_LOG_ERROR, "Not all stream headers found.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto end;
|
||||
}
|
||||
if (decode_stream_header(nut) >= 0)
|
||||
initialized_stream_count++;
|
||||
@@ -779,7 +790,8 @@ static int nut_read_header(AVFormatContext *s)
|
||||
|
||||
if (startcode == 0) {
|
||||
av_log(s, AV_LOG_ERROR, "EOF before video frames\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto end;
|
||||
} else if (startcode == SYNCPOINT_STARTCODE) {
|
||||
nut->next_startcode = startcode;
|
||||
break;
|
||||
@@ -801,7 +813,10 @@ static int nut_read_header(AVFormatContext *s)
|
||||
|
||||
ff_metadata_conv_ctx(s, NULL, ff_nut_metadata_conv);
|
||||
|
||||
return 0;
|
||||
end:
|
||||
if (ret < 0)
|
||||
nut_read_close(s);
|
||||
return FFMIN(ret, 0);
|
||||
}
|
||||
|
||||
static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
|
||||
|
||||
@@ -282,16 +282,18 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
|
||||
static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact,
|
||||
int *header_len, AVDictionary **m, int framing_bit)
|
||||
{
|
||||
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
|
||||
int size;
|
||||
int64_t size;
|
||||
uint8_t *p, *p0;
|
||||
|
||||
ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
|
||||
|
||||
size = offset + ff_vorbiscomment_length(*m, vendor) + framing_bit;
|
||||
if (size > INT_MAX)
|
||||
return NULL;
|
||||
p = av_mallocz(size);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
@@ -88,7 +88,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
||||
return data->split_pkts > 0;
|
||||
}
|
||||
|
||||
if (len < 6) {
|
||||
if (len < 6 || len > INT_MAX/2) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Invalid %d byte packet\n", len);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
|
||||
} else if (buf[i + 1] == SOS) {
|
||||
/* SOS is last marker in the header */
|
||||
i += AV_RB16(&buf[i + 2]) + 2;
|
||||
if (i > size) {
|
||||
av_log(s1, AV_LOG_ERROR,
|
||||
"Insufficient data. Aborted!\n");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,17 +88,16 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
|
||||
st->time_base.num = 1;
|
||||
st->time_base.den = 90000;
|
||||
st->codec->codec_id = AV_CODEC_ID_MPEG2TS;
|
||||
chain->rtp_ctx = rtp_ctx;
|
||||
rtp_ctx->pb = s->pb;
|
||||
if ((ret = avformat_write_header(rtp_ctx, NULL)) < 0)
|
||||
goto fail;
|
||||
rtp_ctx = NULL;
|
||||
chain->rtp_ctx = rtp_ctx;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (mpegts_ctx) {
|
||||
ffio_free_dyn_buf(&chain->mpegts_ctx->pb);
|
||||
ffio_free_dyn_buf(&mpegts_ctx->pb);
|
||||
avformat_free_context(mpegts_ctx);
|
||||
}
|
||||
if (rtp_ctx)
|
||||
|
||||
@@ -109,7 +109,7 @@ int ff_text_peek_r8(FFTextReader *r)
|
||||
}
|
||||
|
||||
AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q,
|
||||
const uint8_t *event, int len, int merge)
|
||||
const uint8_t *event, size_t len, int merge)
|
||||
{
|
||||
AVPacket *subs, *sub;
|
||||
|
||||
@@ -303,7 +303,7 @@ int ff_smil_extract_next_text_chunk(FFTextReader *tr, AVBPrint *buf, char *c)
|
||||
const char *ff_smil_get_attr_ptr(const char *s, const char *attr)
|
||||
{
|
||||
int in_quotes = 0;
|
||||
const int len = strlen(attr);
|
||||
const size_t len = strlen(attr);
|
||||
|
||||
while (*s) {
|
||||
while (*s) {
|
||||
|
||||
@@ -116,7 +116,7 @@ typedef struct {
|
||||
* previous one instead of adding a new entry, 0 otherwise
|
||||
*/
|
||||
AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q,
|
||||
const uint8_t *event, int len, int merge);
|
||||
const uint8_t *event, size_t len, int merge);
|
||||
|
||||
/**
|
||||
* Set missing durations and sort subtitles by PTS, and then byte position.
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ int ff_url_join(char *str, int size, const char *proto,
|
||||
av_strlcatf(str, size, ":%d", port);
|
||||
if (fmt) {
|
||||
va_list vl;
|
||||
int len = strlen(str);
|
||||
size_t len = strlen(str);
|
||||
|
||||
va_start(vl, fmt);
|
||||
vsnprintf(str + len, size > len ? size - len : 0, fmt, vl);
|
||||
|
||||
@@ -418,6 +418,9 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
|
||||
if (options)
|
||||
av_dict_copy(&tmp, *options, 0);
|
||||
|
||||
if (s->pb) // must be before any goto fail
|
||||
s->flags |= AVFMT_FLAG_CUSTOM_IO;
|
||||
|
||||
if ((ret = av_opt_set_dict(s, &tmp)) < 0)
|
||||
goto fail;
|
||||
|
||||
@@ -4121,6 +4124,7 @@ int avformat_network_deinit(void)
|
||||
#if CONFIG_NETWORK
|
||||
ff_network_close();
|
||||
ff_tls_deinit();
|
||||
ff_network_inited_globally = 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,10 @@ int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m,
|
||||
AVDictionaryEntry *tag = NULL;
|
||||
bytestream_put_le32(p, count);
|
||||
while ((tag = av_dict_get(*m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
|
||||
unsigned int len1 = strlen(tag->key);
|
||||
unsigned int len2 = strlen(tag->value);
|
||||
int64_t len1 = strlen(tag->key);
|
||||
int64_t len2 = strlen(tag->value);
|
||||
if (len1+1+len2 > UINT32_MAX)
|
||||
return AVERROR(EINVAL);
|
||||
bytestream_put_le32(p, len1+1+len2);
|
||||
bytestream_put_buffer(p, tag->key, len1);
|
||||
bytestream_put_byte(p, '=');
|
||||
|
||||
@@ -100,7 +100,7 @@ size_t av_strlcat(char *dst, const char *src, size_t size)
|
||||
|
||||
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
|
||||
{
|
||||
int len = strlen(dst);
|
||||
size_t len = strlen(dst);
|
||||
va_list vl;
|
||||
|
||||
va_start(vl, fmt);
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
|
||||
if (flags & AV_DICT_DONT_STRDUP_VAL) {
|
||||
m->elems[m->count].value = (char*)(intptr_t)value;
|
||||
} else if (oldval && flags & AV_DICT_APPEND) {
|
||||
int len = strlen(oldval) + strlen(value) + 1;
|
||||
size_t len = strlen(oldval) + strlen(value) + 1;
|
||||
char *newval = av_mallocz(len);
|
||||
if (!newval)
|
||||
goto err_out;
|
||||
|
||||
@@ -219,6 +219,14 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
|
||||
if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
|
||||
avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
|
||||
|
||||
if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
|
||||
desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
|
||||
pointers[1] - pointers[0] > linesizes[0] * h) {
|
||||
/* zero-initialize the padding before the palette */
|
||||
memset(pointers[0] + linesizes[0] * h, 0,
|
||||
pointers[1] - pointers[0] - linesizes[0] * h);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -266,7 +266,7 @@ char *av_strdup(const char *s)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
if (s) {
|
||||
int len = strlen(s) + 1;
|
||||
size_t len = strlen(s) + 1;
|
||||
ptr = av_realloc(NULL, len);
|
||||
if (ptr)
|
||||
memcpy(ptr, s, len);
|
||||
|
||||
+10
-10
@@ -35,12 +35,12 @@
|
||||
#define PARAM AV_OPT_FLAG_AUDIO_PARAM
|
||||
|
||||
static const AVOption options[]={
|
||||
{"ich" , "set input channel count" , OFFSET( in.ch_count ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"in_channel_count" , "set input channel count" , OFFSET( in.ch_count ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"och" , "set output channel count" , OFFSET(out.ch_count ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"out_channel_count" , "set output channel count" , OFFSET(out.ch_count ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"uch" , "set used channel count" , OFFSET(used_ch_count ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"used_channel_count" , "set used channel count" , OFFSET(used_ch_count ), AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"ich" , "set input channel count" , OFFSET(user_in_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"in_channel_count" , "set input channel count" , OFFSET(user_in_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"och" , "set output channel count" , OFFSET(user_out_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"out_channel_count" , "set output channel count" , OFFSET(user_out_ch_count ), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"uch" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"used_channel_count" , "set used channel count" , OFFSET(user_used_ch_count), AV_OPT_TYPE_INT, {.i64=0 }, 0 , SWR_CH_MAX, PARAM},
|
||||
{"isr" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
|
||||
{"in_sample_rate" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
|
||||
{"osr" , "set output sample rate" , OFFSET(out_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM},
|
||||
@@ -51,10 +51,10 @@ static const AVOption options[]={
|
||||
{"out_sample_fmt" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"tsf" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"internal_sample_fmt" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM},
|
||||
{"icl" , "set input channel layout" , OFFSET( in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"in_channel_layout" , "set input channel layout" , OFFSET( in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"ocl" , "set output channel layout" , OFFSET(out_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"out_channel_layout" , "set output channel layout" , OFFSET(out_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"icl" , "set input channel layout" , OFFSET(user_in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"in_channel_layout" , "set input channel layout" , OFFSET(user_in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"ocl" , "set output channel layout" , OFFSET(user_out_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"out_channel_layout" , "set output channel layout" , OFFSET(user_out_ch_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"},
|
||||
{"clev" , "set center mix level" , OFFSET(clev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM},
|
||||
{"center_mix_level" , "set center mix level" , OFFSET(clev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM},
|
||||
{"slev" , "set surround mix level" , OFFSET(slev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM},
|
||||
|
||||
@@ -65,8 +65,8 @@ int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
|
||||
if (!s || s->in_convert) // s needs to be allocated but not initialized
|
||||
return AVERROR(EINVAL);
|
||||
memset(s->matrix, 0, sizeof(s->matrix));
|
||||
nb_in = av_get_channel_layout_nb_channels(s->in_ch_layout);
|
||||
nb_out = av_get_channel_layout_nb_channels(s->out_ch_layout);
|
||||
nb_in = av_get_channel_layout_nb_channels(s->user_in_ch_layout);
|
||||
nb_out = av_get_channel_layout_nb_channels(s->user_out_ch_layout);
|
||||
for (out = 0; out < nb_out; out++) {
|
||||
for (in = 0; in < nb_in; in++)
|
||||
s->matrix[out][in] = matrix[in];
|
||||
|
||||
@@ -314,6 +314,11 @@ int main(int argc, char **argv){
|
||||
fprintf(stderr, "Failed to init backw_ctx\n");
|
||||
return 1;
|
||||
}
|
||||
if (uint_rand(rand_seed) % 3 == 0)
|
||||
av_opt_set_int(forw_ctx, "ich", 0, 0);
|
||||
if (uint_rand(rand_seed) % 3 == 0)
|
||||
av_opt_set_int(forw_ctx, "och", 0, 0);
|
||||
|
||||
if(swr_init( forw_ctx) < 0)
|
||||
fprintf(stderr, "swr_init(->) failed\n");
|
||||
if(swr_init(backw_ctx) < 0)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "audioconvert.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/internal.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
@@ -86,10 +87,10 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
|
||||
if (av_opt_set_int(s, "tsf", AV_SAMPLE_FMT_NONE, 0) < 0)
|
||||
goto fail;
|
||||
|
||||
if (av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> in_ch_layout), 0) < 0)
|
||||
if (av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> user_in_ch_layout), 0) < 0)
|
||||
goto fail;
|
||||
|
||||
if (av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->out_ch_layout), 0) < 0)
|
||||
if (av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->user_out_ch_layout), 0) < 0)
|
||||
goto fail;
|
||||
|
||||
av_opt_set_int(s, "uch", 0, 0);
|
||||
@@ -152,6 +153,7 @@ av_cold void swr_close(SwrContext *s){
|
||||
|
||||
av_cold int swr_init(struct SwrContext *s){
|
||||
int ret;
|
||||
char l1[1024], l2[1024];
|
||||
|
||||
clear_context(s);
|
||||
|
||||
@@ -164,6 +166,13 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
s->out.ch_count = s-> user_out_ch_count;
|
||||
s-> in.ch_count = s-> user_in_ch_count;
|
||||
s->used_ch_count = s->user_used_ch_count;
|
||||
|
||||
s-> in_ch_layout = s-> user_in_ch_layout;
|
||||
s->out_ch_layout = s->user_out_ch_layout;
|
||||
|
||||
if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) {
|
||||
av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout);
|
||||
s->in_ch_layout = 0;
|
||||
@@ -270,10 +279,18 @@ av_cold int swr_init(struct SwrContext *s){
|
||||
return -1;
|
||||
}
|
||||
|
||||
av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
|
||||
av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
|
||||
if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
|
||||
av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
|
||||
av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
|
||||
char l1[1024], l2[1024];
|
||||
av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
|
||||
av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
|
||||
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
|
||||
"but there is not enough information to do it\n", l1, l2);
|
||||
return -1;
|
||||
@@ -647,8 +664,8 @@ int swr_is_initialized(struct SwrContext *s) {
|
||||
return !!s->in_buffer.ch_count;
|
||||
}
|
||||
|
||||
int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count,
|
||||
const uint8_t *in_arg [SWR_CH_MAX], int in_count){
|
||||
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count,
|
||||
const uint8_t *in_arg [SWR_CH_MAX], int in_count){
|
||||
AudioData * in= &s->in;
|
||||
AudioData *out= &s->out;
|
||||
|
||||
|
||||
@@ -112,6 +112,12 @@ struct SwrContext {
|
||||
int used_ch_count; ///< number of used input channels (mapped channel count if channel_map, otherwise in.ch_count)
|
||||
int engine;
|
||||
|
||||
int user_in_ch_count; ///< User set input channel count
|
||||
int user_out_ch_count; ///< User set output channel count
|
||||
int user_used_ch_count; ///< User set used channel count
|
||||
int64_t user_in_ch_layout; ///< User set input channel layout
|
||||
int64_t user_out_ch_layout; ///< User set output channel layout
|
||||
|
||||
struct DitherContext dither;
|
||||
|
||||
int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */
|
||||
|
||||
@@ -40,19 +40,11 @@
|
||||
ls = vec_perm(a, l2, c);\
|
||||
a = l2;\
|
||||
}
|
||||
#define GET_VF(a, b, c,d) {\
|
||||
a = vec_mergeh(c, d);\
|
||||
b = vec_mergel(c, d);\
|
||||
}
|
||||
#else
|
||||
#define GET_LS(a,b,c,s) {\
|
||||
ls = a;\
|
||||
a = vec_vsx_ld(((b) << 1) + 16, s);\
|
||||
}
|
||||
#define GET_VF(a, b, c, d) {\
|
||||
a = vec_mergel(d, c);\
|
||||
b = vec_mergeh(d, c);\
|
||||
}
|
||||
#endif
|
||||
|
||||
#define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do {\
|
||||
@@ -61,7 +53,8 @@
|
||||
vector signed int i1 = vec_mule(filter, ls);\
|
||||
vector signed int i2 = vec_mulo(filter, ls);\
|
||||
vector signed int vf1, vf2;\
|
||||
GET_VF(vf1, vf2, i1, i2);\
|
||||
vf1 = vec_mergeh(i1, i2);\
|
||||
vf2 = vec_mergel(i1, i2);\
|
||||
d1 = vec_add(d1, vf1);\
|
||||
d2 = vec_add(d2, vf2);\
|
||||
} while (0)
|
||||
|
||||
@@ -277,7 +277,7 @@ void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
|
||||
,"m"(retsave)
|
||||
#endif
|
||||
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
|
||||
#if !defined(PIC)
|
||||
#if ARCH_X86_64 || !defined(PIC)
|
||||
,"%"REG_b
|
||||
#endif
|
||||
);
|
||||
@@ -361,7 +361,7 @@ void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2,
|
||||
,"m"(retsave)
|
||||
#endif
|
||||
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
|
||||
#if !defined(PIC)
|
||||
#if ARCH_X86_64 || !defined(PIC)
|
||||
,"%"REG_b
|
||||
#endif
|
||||
);
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ compare(){
|
||||
}
|
||||
|
||||
do_tiny_psnr(){
|
||||
psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0)
|
||||
psnr=$(tests/tiny_psnr "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
|
||||
val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
|
||||
size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
|
||||
size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
|
||||
|
||||
+1
-2
@@ -83,8 +83,7 @@ clean(){
|
||||
|
||||
report(){
|
||||
date=$(date -u +%Y%m%d%H%M%S)
|
||||
echo "fate:0:${date}:${slot}:${version}:$1:$2:${comment}" >report
|
||||
# echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report
|
||||
echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report
|
||||
cat ${build}/config.fate >>report
|
||||
cat ${build}/tests/data/fate/*.rep >>report || for i in ${build}/tests/data/fate/*.rep ; do cat "$i" >>report ; done
|
||||
test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
|
||||
|
||||
+2
-2
@@ -153,7 +153,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* read from infile and put it in a buffer */
|
||||
{
|
||||
unsigned int count = 0;
|
||||
int64_t count = 0;
|
||||
struct line *line, *last_line, *first_line;
|
||||
char *p;
|
||||
last_line = first_line = av_malloc(sizeof(struct line));
|
||||
@@ -181,7 +181,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
p = graph_string;
|
||||
for (line = first_line; line->next; line = line->next) {
|
||||
unsigned int l = strlen(line->data);
|
||||
size_t l = strlen(line->data);
|
||||
memcpy(p, line->data, l);
|
||||
p += l;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user