New upstream version 3.2.1

This commit is contained in:
Andreas Cadhalpun 2016-11-26 23:41:26 +01:00
parent a518647af4
commit dbdc7a308b
73 changed files with 557 additions and 130 deletions

View File

@ -1,6 +1,86 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version 3.2.1:
- avcodec/aac_adtstoasc_bsf: validate and forward extradata if the stream is already ASC
- mss2: only use error correction for matching block counts
- softfloat: decrease MIN_EXP to cover full float range
- libopusdec: default to stereo for invalid number of channels
- flvdec: require need_context_update when changing codec id
- pgssubdec: only set w/h/linesize when allocating data
- sbgdec: prevent NULL pointer access
- rmdec: validate block alignment
- smacker: limit recursion depth of smacker_decode_bigtree
- mxfdec: fix NULL pointer dereference in mxf_read_packet_old
- ffmdec: validate codec parameters
- avformat/mpeg: Adjust vid probe threshold to correct mis-detection
- avcodec/ass_split: Change order of operations in ass_split_section()
- avcodec/rawdec: check for side data before checking its size
- avcodec/avpacket: fix leak on realloc in av_packet_add_side_data()
- avformat/apngenc: use the stream parameters extradata if available
- Revert "apngdec: use side data to pass extradata to the decoder"
- ffprobe: fix crash in case -of is specified with an empty string
- libavcodec/exr : fix channel size calculation for uint32 channel
- exr: fix out-of-bounds read
- libschroedingerdec: fix leaking of framewithpts
- libschroedingerdec: don't produce empty frames
- dds: limit 4 bpp handling to AV_PIX_FMT_PAL8
- mlz: limit next_code to data buffer size
- softfloat: handle -INT_MAX correctly
- filmstripdec: correctly check image dimensions
- pnmdec: make sure v is capped by maxval
- smvjpegdec: make sure cur_frame is not negative
- icodec: correctly check avio_read return value
- icodec: fix leaking pkt on error
- dvbsubdec: fix division by zero in compute_default_clut
- proresdec_lgpl: explicitly check coff[3] against slice_data_size
- escape124: reject codebook size 0
- mpegts: prevent division by zero
- matroskadec: fix NULL pointer dereference in webm_dash_manifest_read_header
- mpegaudio_parser: don't return AVERROR_PATCHWELCOME
- mxfdec: fix NULL pointer dereference
- lzf: update pointer p after realloc
- diracdec: check return code of get_buffer_with_edge
- diracdec: clear slice_params_num_buf on allocation failure
- diracdec: use correct buffer for slice_params_buf realloc
- ppc: pixblockdsp: do unaligned block accesses correctly again
- avformat: close parser if codec changed
- fate: add streamcopy test for apng
- apngdec: use side data to pass extradata to the decoder
- mov: immediately return from mov_fix_index without old index entries
- interplayacm: increase bitstream buffer size by AV_INPUT_BUFFER_PADDING_SIZE
- interplayacm: validate number of channels
- interplayacm: check for too large b
- doc: fix spelling errors
- configure: make sure LTO does not optimize out the test functions
- fate: add apng encoding/muxing test
- apng: use side data to pass extradata to muxer
- avcodec/mpeg4videodec: Workaround interlaced mpeg4 edge MC bug
- avcodec/mpegvideo: Fix edge emu buffer overlap with interlaced mpeg4
- avcodec/rv40: Test remaining space in loop of get_dimension()
- avcodec/ituh263dec: Avoid spending a long time in slice sync
- avcodec/movtextdec: Add error message for tsmb_size check
- avcodec/movtextdec: Fix tsmb_size check==0 check
- avcodec/movtextdec: Fix potential integer overflow
- ffmpeg: Fix bsf corrupting merged side data
- avcodec/sunrast: Fix input buffer pointer check
- avcodec/tscc: Check side data size before use
- avcodec/rscc: Fix constant
- avcodec/rawdec: Check side data size before use
- avcodec/rscc: Check side data size before use
- avcodec/msvideo1: Check side data size before use
- avcodec/qpeg: Check side data size before use
- avcodec/qtrle: Check side data size before use
- avcodec/msrle: Check side data size before use
- avcodec/kmvc: Check side data size before use
- avcodec/idcinvideo: Check side data size before use
- avcodec/cinepak: Check side data size before use
- avcodec/8bps: Check side data size before use
- avformat/flvdec: Fix regression losing streams
- avformat/hls: Add missing error check for avcodec_parameters_copy()
- avformat/hls: Fix probing mpegts audio streams that use probing
- avformat/hls: Factor copying stream info to a separate function
version 3.2:
- libopenmpt demuxer
- tee protocol

View File

@ -1 +1 @@
3.2
3.2.1

View File

@ -1 +1 @@
3.2
3.2.1

8
configure vendored
View File

@ -1146,10 +1146,16 @@ check_func_headers(){
for hdr in $headers; do
print_include $hdr
done
echo "#include <stdint.h>"
for func in $funcs; do
echo "long check_$func(void) { return (long) $func; }"
done
echo "int main(void) { return 0; }"
echo "int main(void) { int ret = 0;"
# LTO could optimize out the test functions without this
for func in $funcs; do
echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
done
echo "return ret; }"
} | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
}

View File

@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 3.2
PROJECT_NUMBER = 3.2.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -9665,7 +9665,7 @@ Scene change detection method. Scene change leads motion vectors to be in random
@item none
Disable scene change detection.
@item fdiff
Frame difference. Corresponding pixel values are compared and if it statisfies @var{scd_threshold} scene change is detected.
Frame difference. Corresponding pixel values are compared and if it satisfies @var{scd_threshold} scene change is detected.
@end table
Default method is @samp{fdiff}.

View File

@ -63,7 +63,7 @@ This ensures that file and data checksums are reproducible and match between
platforms. Its primary use is for regression testing.
@item shortest
Stop muxing at the end of the shortest stream.
It may be needed to increase max_interleave_delta to avoid flusing the longer
It may be needed to increase max_interleave_delta to avoid flushing the longer
streams before EOF.
@end table

View File

@ -789,6 +789,7 @@ static void output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
if (ost->nb_bitstream_filters) {
int idx;
av_packet_split_side_data(pkt);
ret = av_bsf_send_packet(ost->bsf_ctx[0], pkt);
if (ret < 0)
goto finish;

View File

@ -3311,6 +3311,12 @@ int main(int argc, char **argv)
goto end;
}
w_name = av_strtok(print_format, "=", &buf);
if (!w_name) {
av_log(NULL, AV_LOG_ERROR,
"No name specified for the output format\n");
ret = AVERROR(EINVAL);
goto end;
}
w_args = buf;
if (show_data_hash) {

View File

@ -532,7 +532,7 @@ static int decode_i_block(FourXContext *f, int16_t *block)
}
i += code >> 4;
if (i >= 64) {
av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i);
av_log(f->avctx, AV_LOG_ERROR, "run %d overflow\n", i);
return 0;
}

View File

@ -122,12 +122,15 @@ static int decode_frame(AVCodecContext *avctx, void *data,
}
if (avctx->bits_per_coded_sample <= 8) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt,
AV_PKT_DATA_PALETTE,
NULL);
if (pal) {
&size);
if (pal && size == AVPALETTE_SIZE) {
frame->palette_has_changed = 1;
memcpy(c->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
memcpy (frame->data[1], c->pal, AVPALETTE_SIZE);

View File

@ -136,8 +136,16 @@ fail:
static int aac_adtstoasc_init(AVBSFContext *ctx)
{
av_freep(&ctx->par_out->extradata);
ctx->par_out->extradata_size = 0;
/* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */
if (ctx->par_in->extradata) {
MPEG4AudioConfig mp4ac;
int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata,
ctx->par_in->extradata_size * 8, 1);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Error parsing AudioSpecificConfig extradata!\n");
return ret;
}
}
return 0;
}

View File

@ -275,7 +275,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf)
}
if (section->format_header && !order) {
len = strlen(section->format_header);
if (buf[len] == ':' && !strncmp(buf, section->format_header, len)) {
if (!strncmp(buf, section->format_header, len) && buf[len] == ':') {
buf += len + 1;
while (!is_eol(*buf)) {
buf = skip_space(buf);

View File

@ -2878,6 +2878,7 @@ typedef struct AVCodecContext {
#define FF_BUG_DC_CLIP 4096
#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
#define FF_BUG_TRUNCATED 16384
#define FF_BUG_IEDGE 32768
/**
* strictly follow the standard (MPEG-4, ...).

View File

@ -295,16 +295,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
uint8_t *data, size_t size)
{
AVPacketSideData *tmp;
int elems = pkt->side_data_elems;
if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
return AVERROR(ERANGE);
pkt->side_data = av_realloc(pkt->side_data,
(elems + 1) * sizeof(*pkt->side_data));
if (!pkt->side_data)
tmp = av_realloc(pkt->side_data, (elems + 1) * sizeof(*tmp));
if (!tmp)
return AVERROR(ENOMEM);
pkt->side_data = tmp;
pkt->side_data[elems].data = data;
pkt->side_data[elems].size = size;
pkt->side_data[elems].type = type;

View File

@ -443,10 +443,13 @@ static int cinepak_decode_frame(AVCodecContext *avctx,
return ret;
if (s->palette_video) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (pal) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
}

View File

@ -680,7 +680,7 @@ static int dds_decode(AVCodecContext *avctx, void *data,
/* Use the decompress function on the texture, one block per thread. */
ctx->tex_data = gbc->buffer;
avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count);
} else if (!ctx->paletted && ctx->bpp == 4) {
} else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == AV_PIX_FMT_PAL8) {
uint8_t *dst = frame->data[0];
int x, y, i;

View File

@ -907,9 +907,10 @@ static int decode_lowdelay(DiracContext *s)
int slice_num = 0;
if (s->slice_params_num_buf != (s->num_x * s->num_y)) {
s->slice_params_buf = av_realloc_f(s->thread_buf, s->num_x * s->num_y, sizeof(DiracSlice));
s->slice_params_buf = av_realloc_f(s->slice_params_buf, s->num_x * s->num_y, sizeof(DiracSlice));
if (!s->slice_params_buf) {
av_log(s->avctx, AV_LOG_ERROR, "slice params buffer allocation failure\n");
s->slice_params_num_buf = 0;
return AVERROR(ENOMEM);
}
s->slice_params_num_buf = s->num_x * s->num_y;
@ -1974,7 +1975,9 @@ static int dirac_decode_picture_header(DiracContext *s)
for (j = 0; j < MAX_FRAMES; j++)
if (!s->all_frames[j].avframe->data[0]) {
s->ref_pics[i] = &s->all_frames[j];
get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
ret = get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
if (ret < 0)
return ret;
break;
}

View File

@ -810,7 +810,7 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
list_inv[ i ] = bestv;
}
count = i - 1;
count = FFMAX(i - 1, 1);
for (i--; i>=0; i--) {
int v = i*255/count;
AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));

View File

@ -249,6 +249,10 @@ static int escape124_decode_frame(AVCodecContext *avctx,
// This codebook can be cut off at places other than
// powers of 2, leaving some of the entries undefined.
cb_size = get_bits_long(&gb, 20);
if (!cb_size) {
av_log(avctx, AV_LOG_ERROR, "Invalid codebook size 0.\n");
return AVERROR_INVALIDDATA;
}
cb_depth = av_log2(cb_size - 1) + 1;
} else {
cb_depth = get_bits(&gb, 4);

View File

@ -1428,8 +1428,7 @@ static int decode_header(EXRContext *s)
return AVERROR_PATCHWELCOME;
}
if (s->channel_offsets[channel_index] == -1){/* channel have not been previously assign */
if (channel_index >= 0) {
if (channel_index >= 0 && s->channel_offsets[channel_index] == -1) { /* channel has not been previously assigned */
if (s->pixel_type != EXR_UNKNOWN &&
s->pixel_type != current_pixel_type) {
av_log(s->avctx, AV_LOG_ERROR,
@ -1438,7 +1437,6 @@ static int decode_header(EXRContext *s)
}
s->pixel_type = current_pixel_type;
s->channel_offsets[channel_index] = s->current_channel_offset;
}
}
s->channels = av_realloc(s->channels,
@ -1450,7 +1448,11 @@ static int decode_header(EXRContext *s)
channel->xsub = xsub;
channel->ysub = ysub;
s->current_channel_offset += 1 << current_pixel_type;
if (current_pixel_type == EXR_HALF) {
s->current_channel_offset += 2;
} else {/* Float or UINT32 */
s->current_channel_offset += 4;
}
}
/* Check if all channels are set with an offset or if the channels

View File

@ -214,7 +214,8 @@ static int idcin_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
IdcinContext *s = avctx->priv_data;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
AVFrame *frame = data;
int ret;
@ -227,9 +228,11 @@ static int idcin_decode_frame(AVCodecContext *avctx,
if (idcin_decode_vlcs(s, frame))
return AVERROR_INVALIDDATA;
if (pal) {
if (pal && pal_size == AVPALETTE_SIZE) {
frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
}
/* make the palette available on the way out */
memcpy(frame->data[1], s->pal, AVPALETTE_SIZE);

View File

@ -62,6 +62,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (avctx->extradata_size < 14)
return AVERROR_INVALIDDATA;
if (avctx->channels <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", avctx->channels);
return AVERROR_INVALIDDATA;
}
s->level = AV_RL16(avctx->extradata + 12) & 0xf;
s->rows = AV_RL16(avctx->extradata + 12) >> 4;
s->cols = 1 << s->level;
@ -72,7 +77,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->block = av_calloc(s->block_len, sizeof(int));
s->wrapbuf = av_calloc(s->wrapbuf_len, sizeof(int));
s->ampbuf = av_calloc(0x10000, sizeof(int));
s->bitstream = av_calloc(s->max_framesize, sizeof(*s->bitstream));
s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*s->bitstream) + 1, sizeof(*s->bitstream));
if (!s->block || !s->wrapbuf || !s->ampbuf || !s->bitstream)
return AVERROR(ENOMEM);
@ -326,6 +331,10 @@ static int t15(InterplayACMContext *s, unsigned ind, unsigned col)
for (i = 0; i < s->rows; i++) {
/* b = (x1) + (x2 * 3) + (x3 * 9) */
b = get_bits(gb, 5);
if (b > 26) {
av_log(NULL, AV_LOG_ERROR, "Too large b = %d > 26\n", b);
return AVERROR_INVALIDDATA;
}
n1 = (mul_3x3[b] & 0x0F) - 1;
n2 = ((mul_3x3[b] >> 4) & 0x0F) - 1;
@ -351,6 +360,10 @@ static int t27(InterplayACMContext *s, unsigned ind, unsigned col)
for (i = 0; i < s->rows; i++) {
/* b = (x1) + (x2 * 5) + (x3 * 25) */
b = get_bits(gb, 7);
if (b > 124) {
av_log(NULL, AV_LOG_ERROR, "Too large b = %d > 124\n", b);
return AVERROR_INVALIDDATA;
}
n1 = (mul_3x5[b] & 0x0F) - 2;
n2 = ((mul_3x5[b] >> 4) & 0x0F) - 2;
@ -375,6 +388,10 @@ static int t37(InterplayACMContext *s, unsigned ind, unsigned col)
for (i = 0; i < s->rows; i++) {
/* b = (x1) + (x2 * 11) */
b = get_bits(gb, 7);
if (b > 120) {
av_log(NULL, AV_LOG_ERROR, "Too large b = %d > 120\n", b);
return AVERROR_INVALIDDATA;
}
n1 = (mul_2x11[b] & 0x0F) - 5;
n2 = ((mul_2x11[b] >> 4) & 0x0F) - 5;

View File

@ -167,6 +167,7 @@ static int h263_decode_gob_header(MpegEncContext *s)
/* We have a GBSC probably with GSTUFF */
skip_bits(&s->gb, 16); /* Drop the zeros */
left= get_bits_left(&s->gb);
left = FFMIN(left, 32);
//MN: we must check the bits left or we might end in an infinite loop (or segfault)
for(;left>13; left--){
if(get_bits1(&s->gb)) break; /* Seek the '1' bit */

View File

@ -268,7 +268,8 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
int i, ret;
int header;
int blocksize;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
bytestream2_init(&ctx->g, avpkt->data, avpkt->size);
@ -303,9 +304,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
}
}
if (pal) {
if (pal && pal_size == AVPALETTE_SIZE) {
frame->palette_has_changed = 1;
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
}
if (ctx->setpal) {

View File

@ -47,6 +47,13 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled;
uint8_t mapping_arr[8] = { 0, 1 }, *mapping;
avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2;
if (avc->channels <= 0) {
av_log(avc, AV_LOG_WARNING,
"Invalid number of channels %d, defaulting to stereo\n", avc->channels);
avc->channels = 2;
}
avc->sample_rate = 48000;
avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ?
AV_SAMPLE_FMT_FLT : AV_SAMPLE_FMT_S16;

View File

@ -218,6 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx,
int outer = 1;
SchroParseUnitContext parse_ctx;
LibSchroFrameContext *framewithpts = NULL;
int ret;
*got_frame = 0;
@ -307,11 +308,10 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx,
/* Grab next frame to be returned from the top of the queue. */
framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue);
if (framewithpts && framewithpts->frame) {
int ret;
if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) {
if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0)
return ret;
goto end;
memcpy(avframe->data[0],
framewithpts->frame->components[0].data,
@ -337,15 +337,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
avframe->linesize[2] = framewithpts->frame->components[2].stride;
*got_frame = 1;
/* Now free the frame resources. */
libschroedinger_decode_frame_free(framewithpts->frame);
av_free(framewithpts);
} else {
data = NULL;
*got_frame = 0;
}
return buf_size;
ret = buf_size;
end:
/* Now free the frame resources. */
if (framewithpts && framewithpts->frame)
libschroedinger_decode_frame_free(framewithpts->frame);
av_freep(&framewithpts);
return ret;
}

View File

@ -53,6 +53,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
ret = av_reallocp(buf, *size);
if (ret < 0)
return ret;
p = *buf + len;
}
bytestream2_get_buffer(gb, p, s);
@ -75,6 +76,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
ret = av_reallocp(buf, *size);
if (ret < 0)
return ret;
p = *buf + len;
}
av_memcpy_backptr(p, off, l);

View File

@ -166,6 +166,10 @@ int ff_mlz_decompression(MLZ* mlz, GetBitContext* gb, int size, unsigned char *b
}
output_chars += ret;
set_new_entry_dict(dict, mlz->next_code, last_string_code, char_code);
if (mlz->next_code >= TABLE_SIZE - 1) {
av_log(mlz->context, AV_LOG_ERROR, "Too many MLZ codes\n");
return output_chars;
}
mlz->next_code++;
} else {
int ret = decode_string(mlz, &buff[output_chars], string_code, &char_code, size - output_chars);
@ -177,6 +181,10 @@ int ff_mlz_decompression(MLZ* mlz, GetBitContext* gb, int size, unsigned char *b
if (output_chars <= size && !mlz->freeze_flag) {
if (last_string_code != -1) {
set_new_entry_dict(dict, mlz->next_code, last_string_code, char_code);
if (mlz->next_code >= TABLE_SIZE - 1) {
av_log(mlz->context, AV_LOG_ERROR, "Too many MLZ codes\n");
return output_chars;
}
mlz->next_code++;
}
} else {

View File

@ -471,10 +471,6 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
tsmb_type = AV_RB32(tsmb);
tsmb += 4;
if (tsmb_size == 0) {
return AVERROR_INVALIDDATA;
}
if (tsmb_size == 1) {
if (m->tracksize + 16 > avpkt->size)
break;
@ -485,7 +481,12 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
m->size_var = 8;
//size_var is equal to 8 or 16 depending on the size of box
if (m->tracksize + tsmb_size > avpkt->size)
if (tsmb_size == 0) {
av_log(avctx, AV_LOG_ERROR, "tsmb_size is 0\n");
return AVERROR_INVALIDDATA;
}
if (tsmb_size > avpkt->size - m->tracksize)
break;
for (size_t i = 0; i < box_count; i++) {

View File

@ -2195,6 +2195,13 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
if (ctx->lavc_build <= 4712U)
s->workaround_bugs |= FF_BUG_DC_CLIP;
if ((ctx->lavc_build&0xFF) >= 100) {
if (ctx->lavc_build > 3621476 && ctx->lavc_build < 3752552 &&
(ctx->lavc_build < 3752037 || ctx->lavc_build > 3752191) // 3.2.1+
)
s->workaround_bugs |= FF_BUG_IEDGE;
}
if (ctx->divx_version >= 0)
s->workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE;
if (ctx->divx_version == 501 && ctx->divx_build == 20020416)

View File

@ -98,7 +98,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
} else if (codec_id == AV_CODEC_ID_MP3ADU) {
avpriv_report_missing_feature(avctx,
"MP3ADU full parser");
return AVERROR_PATCHWELCOME;
return 0; /* parsers must not return error codes */
}
break;

View File

@ -76,7 +76,7 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
// at uvlinesize. It supports only YUV420 so 24x24 is enough
// linesize * interlaced * MBsize
// we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines
FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 68,
FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 70,
fail);
FF_ALLOCZ_ARRAY_OR_GOTO(avctx, me->scratchpad, alloc_size, 4 * 16 * 2,

View File

@ -2116,7 +2116,9 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
uint8_t *vbuf =ubuf + 9 * s->uvlinesize;
uint8_t *vbuf =ubuf + 10 * s->uvlinesize;
if (s->workaround_bugs & FF_BUG_IEDGE)
vbuf -= s->uvlinesize;
s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
uvlinesize >> field_based, uvlinesize >> field_based,
9, 9 + field_based,

View File

@ -2276,7 +2276,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
(mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width;
if((mb_x * 16 + 16 > s->width || mb_y * 16 + 16 > s->height) && s->codec_id != AV_CODEC_ID_AMV){
uint8_t *ebuf = s->sc.edge_emu_buffer + 36 * wrap_y;
uint8_t *ebuf = s->sc.edge_emu_buffer + 38 * wrap_y;
int cw = (s->width + s->chroma_x_shift) >> s->chroma_x_shift;
int ch = (s->height + s->chroma_y_shift) >> s->chroma_y_shift;
s->vdsp.emulated_edge_mc(ebuf, ptr_y,

View File

@ -326,7 +326,9 @@ void mpeg_motion_internal(MpegEncContext *s,
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
uint8_t *vbuf = ubuf + 9 * s->uvlinesize;
uint8_t *vbuf = ubuf + 10 * s->uvlinesize;
if (s->workaround_bugs & FF_BUG_IEDGE)
vbuf -= s->uvlinesize;
uvsrc_y = (unsigned)uvsrc_y << field_based;
s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
@ -549,7 +551,9 @@ static inline void qpel_motion(MpegEncContext *s,
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
uint8_t *vbuf = ubuf + 9 * s->uvlinesize;
uint8_t *vbuf = ubuf + 10 * s->uvlinesize;
if (s->workaround_bugs & FF_BUG_IEDGE)
vbuf -= s->uvlinesize;
s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,

View File

@ -99,11 +99,14 @@ static int msrle_decode_frame(AVCodecContext *avctx,
return ret;
if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal) {
if (pal && size == AVPALETTE_SIZE) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
/* make the palette available */
memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);

View File

@ -422,7 +422,13 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
ff_vc1_decode_blocks(v);
ff_er_frame_end(&s->er);
if (v->end_mb_x == s->mb_width && s->end_mb_y == s->mb_height) {
ff_er_frame_end(&s->er);
} else {
av_log(v->s.avctx, AV_LOG_WARNING,
"disabling error correction due to block count mismatch %dx%d != %dx%d\n",
v->end_mb_x, s->end_mb_y, s->mb_width, s->mb_height);
}
ff_mpv_frame_end(s);

View File

@ -305,11 +305,14 @@ static int msvideo1_decode_frame(AVCodecContext *avctx,
return ret;
if (s->mode_8bit) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal) {
if (pal && size == AVPALETTE_SIZE) {
memcpy(s->pal, pal, AVPALETTE_SIZE);
s->frame->palette_has_changed = 1;
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
}

View File

@ -163,6 +163,7 @@ static const AVOption avcodec_options[] = {
{"dc_clip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"},
{"ms", "work around various bugs in Microsoft's broken decoders", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"},
{"trunc", "truncated frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"},
{"iedge", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_IEDGE }, INT_MIN, INT_MAX, V|D, "bug"},
{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
{"very", "strictly conform to a older more strict version of the spec or reference software", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
{"strict", "strictly conform to all the things in the spec no matter what the consequences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},

View File

@ -556,12 +556,13 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
sub->rects[i]->x = ctx->presentation.objects[i].x;
sub->rects[i]->y = ctx->presentation.objects[i].y;
sub->rects[i]->w = object->w;
sub->rects[i]->h = object->h;
sub->rects[i]->linesize[0] = object->w;
if (object->rle) {
sub->rects[i]->w = object->w;
sub->rects[i]->h = object->h;
sub->rects[i]->linesize[0] = object->w;
if (object->rle_remaining_len) {
av_log(avctx, AV_LOG_ERROR, "RLE data length %u is %u bytes shorter than expected\n",
object->rle_data_len, object->rle_remaining_len);

View File

@ -68,6 +68,9 @@ typedef struct PNGEncContext {
// APNG
uint32_t palette_checksum; // Used to ensure a single unique palette
uint32_t sequence_number;
int extra_data_updated;
uint8_t *extra_data;
int extra_data_size;
AVFrame *prev_frame;
AVFrame *last_frame;
@ -870,15 +873,15 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
if (!pict)
return AVERROR(EINVAL);
s->bytestream = avctx->extradata = av_malloc(FF_MIN_BUFFER_SIZE);
if (!avctx->extradata)
s->bytestream = s->extra_data = av_malloc(FF_MIN_BUFFER_SIZE);
if (!s->extra_data)
return AVERROR(ENOMEM);
ret = encode_headers(avctx, pict);
if (ret < 0)
return ret;
avctx->extradata_size = s->bytestream - avctx->extradata;
s->extra_data_size = s->bytestream - s->extra_data;
s->last_frame_packet = av_malloc(max_packet_size);
if (!s->last_frame_packet)
@ -917,6 +920,13 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
if (s->last_frame) {
uint8_t* last_fctl_chunk_start = pkt->data;
uint8_t buf[26];
if (!s->extra_data_updated) {
uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, s->extra_data_size);
if (!side_data)
return AVERROR(ENOMEM);
memcpy(side_data, s->extra_data, s->extra_data_size);
s->extra_data_updated = 1;
}
AV_WB32(buf + 0, s->last_frame_fctl.sequence_number);
AV_WB32(buf + 4, s->last_frame_fctl.width);
@ -1093,6 +1103,8 @@ static av_cold int png_enc_close(AVCodecContext *avctx)
av_frame_free(&s->last_frame);
av_frame_free(&s->prev_frame);
av_freep(&s->last_frame_packet);
av_freep(&s->extra_data);
s->extra_data_size = 0;
return 0;
}

View File

@ -43,7 +43,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
int buf_size = avpkt->size;
PNMContext * const s = avctx->priv_data;
AVFrame * const p = data;
int i, j, n, linesize, h, upgrade = 0, is_mono = 0;
int i, j, k, n, linesize, h, upgrade = 0, is_mono = 0;
unsigned char *ptr;
int components, sample_len, ret;
@ -143,10 +143,14 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
v = (*s->bytestream++)&1;
} else {
/* read a sequence of digits */
do {
for (k = 0; k < 5 && c <= 9; k += 1) {
v = 10*v + c;
c = (*s->bytestream++) - '0';
} while (c <= 9);
}
if (v > s->maxval) {
av_log(avctx, AV_LOG_ERROR, "value %d larger than maxval %d\n", v, s->maxval);
return AVERROR_INVALIDDATA;
}
}
if (sample_len == 16) {
((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval;

View File

@ -67,10 +67,10 @@ static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels,
ptrdiff_t line_size)
{
int i;
vec_u8 perm = vec_lvsl(0, pixels);
const vec_u8 zero = (const vec_u8)vec_splat_u8(0);
for (i = 0; i < 8; i++) {
vec_u8 perm = vec_lvsl(0, pixels);
/* Read potentially unaligned pixels.
* We're reading 16 pixels, and actually only want 8,
* but we simply ignore the extras. */
@ -157,8 +157,7 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
const uint8_t *s2, int stride)
{
int i;
vec_u8 perm1 = vec_lvsl(0, s1);
vec_u8 perm2 = vec_lvsl(0, s2);
vec_u8 perm;
const vec_u8 zero = (const vec_u8)vec_splat_u8(0);
vec_s16 shorts1, shorts2;
@ -166,17 +165,19 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
/* Read potentially unaligned pixels.
* We're reading 16 pixels, and actually only want 8,
* but we simply ignore the extras. */
perm = vec_lvsl(0, s1);
vec_u8 pixl = vec_ld(0, s1);
vec_u8 pixr = vec_ld(15, s1);
vec_u8 bytes = vec_perm(pixl, pixr, perm1);
vec_u8 bytes = vec_perm(pixl, pixr, perm);
// Convert the bytes into shorts.
shorts1 = (vec_s16)vec_mergeh(zero, bytes);
// Do the same for the second block of pixels.
perm = vec_lvsl(0, s2);
pixl = vec_ld(0, s2);
pixr = vec_ld(15, s2);
bytes = vec_perm(pixl, pixr, perm2);
bytes = vec_perm(pixl, pixr, perm);
// Convert the bytes into shorts.
shorts2 = (vec_s16)vec_mergeh(zero, bytes);
@ -197,17 +198,19 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
/* Read potentially unaligned pixels.
* We're reading 16 pixels, and actually only want 8,
* but we simply ignore the extras. */
perm = vec_lvsl(0, s1);
pixl = vec_ld(0, s1);
pixr = vec_ld(15, s1);
bytes = vec_perm(pixl, pixr, perm1);
bytes = vec_perm(pixl, pixr, perm);
// Convert the bytes into shorts.
shorts1 = (vec_s16)vec_mergeh(zero, bytes);
// Do the same for the second block of pixels.
perm = vec_lvsl(0, s2);
pixl = vec_ld(0, s2);
pixr = vec_ld(15, s2);
bytes = vec_perm(pixl, pixr, perm2);
bytes = vec_perm(pixl, pixr, perm);
// Convert the bytes into shorts.
shorts2 = (vec_s16)vec_mergeh(zero, bytes);

View File

@ -625,7 +625,7 @@ static int decode_slice(AVCodecContext *avctx, void *tdata)
/* if V or alpha component size is negative that means that previous
component sizes are too large */
if (v_data_size < 0 || a_data_size < 0 || hdr_size < 6) {
if (v_data_size < 0 || a_data_size < 0 || hdr_size < 6 || coff[3] > slice_data_size) {
av_log(avctx, AV_LOG_ERROR, "invalid data size\n");
return AVERROR_INVALIDDATA;
}

View File

@ -260,7 +260,8 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const ref = a->ref;
uint8_t* outdata;
int delta, ret;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
if (avpkt->size < 0x86) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
@ -287,9 +288,11 @@ static int decode_frame(AVCodecContext *avctx,
}
/* make the palette available on the way out */
if (pal) {
if (pal && pal_size == AVPALETTE_SIZE) {
p->palette_has_changed = 1;
memcpy(a->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
}
memcpy(p->data[1], a->pal, AVPALETTE_SIZE);

View File

@ -506,11 +506,14 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
}
if(has_palette) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal) {
if (pal && size == AVPALETTE_SIZE) {
s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
/* make the palette available on the way out */

View File

@ -364,9 +364,16 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
int pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
NULL);
&pal_size);
int ret;
if (pal && pal_size != AVPALETTE_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
pal = NULL;
}
if (!context->palette)
context->palette = av_buffer_alloc(AVPALETTE_SIZE);
if (!context->palette) {

View File

@ -310,12 +310,15 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
frame->pict_type = AV_PICTURE_TYPE_P;
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt,
AV_PKT_DATA_PALETTE,
NULL);
if (pal) {
&size);
if (pal && size == AVPALETTE_SIZE) {
frame->palette_has_changed = 1;
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE);
}

View File

@ -109,6 +109,8 @@ static int get_dimension(GetBitContext *gb, const int *dim)
val = dim[get_bits1(gb) - val];
if(!val){
do{
if (get_bits_left(gb) < 8)
return AVERROR_INVALIDDATA;
t = get_bits(gb, 8);
val += t << 2;
}while(t == 0xFF);

View File

@ -129,8 +129,12 @@ static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t pref
/**
* Decode header tree
*/
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx, int length)
{
if(length > 500) { // Larger length can cause segmentation faults due to too deep recursion.
av_log(NULL, AV_LOG_ERROR, "length too long\n");
return AVERROR_INVALIDDATA;
}
if (hc->current + 1 >= hc->length) {
av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
return AVERROR_INVALIDDATA;
@ -159,12 +163,12 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx
int r = 0, r_new, t;
t = hc->current++;
r = smacker_decode_bigtree(gb, hc, ctx);
r = smacker_decode_bigtree(gb, hc, ctx, length + 1);
if(r < 0)
return r;
hc->values[t] = SMK_NODE | r;
r++;
r_new = smacker_decode_bigtree(gb, hc, ctx);
r_new = smacker_decode_bigtree(gb, hc, ctx, length + 1);
if (r_new < 0)
return r_new;
return r + r_new;
@ -275,7 +279,7 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
goto error;
}
if (smacker_decode_bigtree(gb, &huff, &ctx) < 0)
if (smacker_decode_bigtree(gb, &huff, &ctx, 0) < 0)
err = -1;
skip_bits1(gb);
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;

View File

@ -152,6 +152,10 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
cur_frame = avpkt->pts % s->frames_per_jpeg;
/* cur_frame is later used to calculate the buffer offset, so it mustn't be negative */
if (cur_frame < 0)
cur_frame += s->frames_per_jpeg;
/* Are we at the start of a block? */
if (!cur_frame) {
av_frame_unref(mjpeg_data);

View File

@ -168,7 +168,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
}
} else {
for (y = 0; y < h; y++) {
if (buf_end - buf < len)
if (buf_end - buf < alen)
break;
memcpy(ptr, buf, len);
ptr += stride;

View File

@ -98,11 +98,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
/* make the palette available on the way out */
if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal) {
if (pal && size == AVPALETTE_SIZE) {
frame->palette_has_changed = 1;
memcpy(c->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
memcpy(frame->data[1], c->pal, AVPALETTE_SIZE);
}

View File

@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 64
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

View File

@ -44,6 +44,9 @@ typedef struct APNGMuxContext {
AVRational prev_delay;
int framerate_warned;
uint8_t *extra_data;
int extra_data_size;
} APNGMuxContext;
static uint8_t *apng_find_chunk(uint32_t tag, uint8_t *buf, size_t length)
@ -78,6 +81,7 @@ static void apng_write_chunk(AVIOContext *io_context, uint32_t tag,
static int apng_write_header(AVFormatContext *format_context)
{
APNGMuxContext *apng = format_context->priv_data;
AVCodecParameters *par = format_context->streams[0]->codecpar;
if (format_context->nb_streams != 1 ||
format_context->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
@ -98,18 +102,38 @@ static int apng_write_header(AVFormatContext *format_context)
avio_wb64(format_context->pb, PNGSIG);
// Remaining headers are written when they are copied from the encoder
if (par->extradata_size) {
apng->extra_data = av_mallocz(par->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!apng->extra_data)
return AVERROR(ENOMEM);
apng->extra_data_size = par->extradata_size;
memcpy(apng->extra_data, par->extradata, par->extradata_size);
}
return 0;
}
static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
{
APNGMuxContext *apng = format_context->priv_data;
AVIOContext *io_context = format_context->pb;
AVStream *codec_stream = format_context->streams[0];
AVCodecParameters *codec_par = codec_stream->codecpar;
uint8_t *side_data = NULL;
int side_data_size = 0;
av_assert0(apng->prev_packet);
side_data = av_packet_get_side_data(apng->prev_packet, AV_PKT_DATA_NEW_EXTRADATA, &side_data_size);
if (side_data_size) {
av_freep(&apng->extra_data);
apng->extra_data = av_mallocz(side_data_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!apng->extra_data)
return AVERROR(ENOMEM);
apng->extra_data_size = side_data_size;
memcpy(apng->extra_data, side_data, apng->extra_data_size);
}
if (apng->frame_number == 0 && !packet) {
uint8_t *existing_acTL_chunk;
uint8_t *existing_fcTL_chunk;
@ -117,13 +141,13 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
av_log(format_context, AV_LOG_INFO, "Only a single frame so saving as a normal PNG.\n");
// Write normal PNG headers without acTL chunk
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_par->extradata, codec_par->extradata_size);
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), apng->extra_data, apng->extra_data_size);
if (existing_acTL_chunk) {
uint8_t *chunk_after_acTL = existing_acTL_chunk + AV_RB32(existing_acTL_chunk) + 12;
avio_write(io_context, codec_par->extradata, existing_acTL_chunk - codec_par->extradata);
avio_write(io_context, chunk_after_acTL, codec_par->extradata + codec_par->extradata_size - chunk_after_acTL);
avio_write(io_context, apng->extra_data, existing_acTL_chunk - apng->extra_data);
avio_write(io_context, chunk_after_acTL, apng->extra_data + apng->extra_data_size - chunk_after_acTL);
} else {
avio_write(io_context, codec_par->extradata, codec_par->extradata_size);
avio_write(io_context, apng->extra_data, apng->extra_data_size);
}
// Write frame data without fcTL chunk
@ -142,9 +166,9 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
uint8_t *existing_acTL_chunk;
// Write normal PNG headers
avio_write(io_context, codec_par->extradata, codec_par->extradata_size);
avio_write(io_context, apng->extra_data, apng->extra_data_size);
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_par->extradata, codec_par->extradata_size);
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), apng->extra_data, apng->extra_data_size);
if (!existing_acTL_chunk) {
uint8_t buf[8];
// Write animation control header
@ -195,11 +219,13 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
av_packet_unref(apng->prev_packet);
if (packet)
av_copy_packet(apng->prev_packet, packet);
return 0;
}
static int apng_write_packet(AVFormatContext *format_context, AVPacket *packet)
{
APNGMuxContext *apng = format_context->priv_data;
int ret;
if (!apng->prev_packet) {
apng->prev_packet = av_malloc(sizeof(*apng->prev_packet));
@ -208,7 +234,9 @@ static int apng_write_packet(AVFormatContext *format_context, AVPacket *packet)
av_copy_packet(apng->prev_packet, packet);
} else {
flush_packet(format_context, packet);
ret = flush_packet(format_context, packet);
if (ret < 0)
return ret;
}
return 0;
@ -219,10 +247,13 @@ static int apng_write_trailer(AVFormatContext *format_context)
APNGMuxContext *apng = format_context->priv_data;
AVIOContext *io_context = format_context->pb;
uint8_t buf[8];
int ret;
if (apng->prev_packet) {
flush_packet(format_context, NULL);
ret = flush_packet(format_context, NULL);
av_freep(&apng->prev_packet);
if (ret < 0)
return ret;
}
apng_write_chunk(io_context, MKBETAG('I', 'E', 'N', 'D'), NULL, 0);
@ -235,6 +266,9 @@ static int apng_write_trailer(AVFormatContext *format_context)
apng_write_chunk(io_context, MKBETAG('a', 'c', 'T', 'L'), buf, 8);
}
av_freep(&apng->extra_data);
apng->extra_data = 0;
return 0;
}

View File

@ -21,6 +21,7 @@
#include <stdint.h>
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
@ -28,6 +29,7 @@
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/pixdesc.h"
#include "libavcodec/internal.h"
#include "avformat.h"
#include "internal.h"
#include "ffm.h"
@ -277,6 +279,14 @@ static int ffm_append_recommended_configuration(AVStream *st, char **conf)
return 0;
}
#define VALIDATE_PARAMETER(parameter, name, check) { \
if (check) { \
av_log(codec, AV_LOG_ERROR, "Invalid " name " %d\n", codec->parameter); \
ret = AVERROR_INVALIDDATA; \
goto fail; \
} \
}
static int ffm2_read_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
@ -342,6 +352,7 @@ static int ffm2_read_header(AVFormatContext *s)
if (!codec_desc) {
av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codec->codec_id);
codec->codec_id = AV_CODEC_ID_NONE;
ret = AVERROR_INVALIDDATA;
goto fail;
}
codec->codec_type = avio_r8(pb);
@ -350,14 +361,25 @@ static int ffm2_read_header(AVFormatContext *s)
codec_desc->type, codec->codec_type);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
ret = AVERROR_INVALIDDATA;
goto fail;
}
codec->bit_rate = avio_rb32(pb);
if (codec->bit_rate < 0) {
av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", codec->bit_rate);
ret = AVERROR_INVALIDDATA;
goto fail;
}
codec->flags = avio_rb32(pb);
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
int size = avio_rb32(pb);
if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size);
ret = AVERROR_INVALIDDATA;
goto fail;
}
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);
@ -380,6 +402,9 @@ static int ffm2_read_header(AVFormatContext *s)
}
codec->width = avio_rb16(pb);
codec->height = avio_rb16(pb);
ret = av_image_check_size(codec->width, codec->height, 0, s);
if (ret < 0)
goto fail;
codec->gop_size = avio_rb16(pb);
codec->pix_fmt = avio_rb32(pb);
if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
@ -432,8 +457,11 @@ static int ffm2_read_header(AVFormatContext *s)
goto fail;
}
codec->sample_rate = avio_rb32(pb);
VALIDATE_PARAMETER(sample_rate, "sample rate", codec->sample_rate < 0)
codec->channels = avio_rl16(pb);
VALIDATE_PARAMETER(channels, "number of channels", codec->channels < 0)
codec->frame_size = avio_rl16(pb);
VALIDATE_PARAMETER(frame_size, "frame size", codec->frame_size < 0)
break;
case MKBETAG('C', 'P', 'R', 'V'):
if (f_cprv++) {
@ -513,7 +541,7 @@ static int ffm_read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
AVCodecContext *codec;
const AVCodecDescriptor *codec_desc;
int i, nb_streams;
int i, nb_streams, ret;
uint32_t tag;
/* header */
@ -565,6 +593,10 @@ static int ffm_read_header(AVFormatContext *s)
goto fail;
}
codec->bit_rate = avio_rb32(pb);
if (codec->bit_rate < 0) {
av_log(codec, AV_LOG_WARNING, "Invalid bit rate %"PRId64"\n", codec->bit_rate);
goto fail;
}
codec->flags = avio_rb32(pb);
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
@ -580,6 +612,8 @@ static int ffm_read_header(AVFormatContext *s)
}
codec->width = avio_rb16(pb);
codec->height = avio_rb16(pb);
if (av_image_check_size(codec->width, codec->height, 0, s) < 0)
goto fail;
codec->gop_size = avio_rb16(pb);
codec->pix_fmt = avio_rb32(pb);
if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
@ -628,14 +662,21 @@ static int ffm_read_header(AVFormatContext *s)
break;
case AVMEDIA_TYPE_AUDIO:
codec->sample_rate = avio_rb32(pb);
VALIDATE_PARAMETER(sample_rate, "sample rate", codec->sample_rate < 0)
codec->channels = avio_rl16(pb);
VALIDATE_PARAMETER(channels, "number of channels", codec->channels < 0)
codec->frame_size = avio_rl16(pb);
VALIDATE_PARAMETER(frame_size, "frame size", codec->frame_size < 0)
break;
default:
goto fail;
}
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
int size = avio_rb32(pb);
if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size);
goto fail;
}
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);

View File

@ -25,6 +25,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avformat.h"
#include "internal.h"
@ -68,10 +69,8 @@ static int read_header(AVFormatContext *s)
st->codecpar->height = avio_rb16(pb);
film->leading = avio_rb16(pb);
if (st->codecpar->width * 4LL * st->codecpar->height >= INT_MAX) {
av_log(s, AV_LOG_ERROR, "dimensions too large\n");
return AVERROR_PATCHWELCOME;
}
if (av_image_check_size(st->codecpar->width, st->codecpar->height, 0, s) < 0)
return AVERROR_INVALIDDATA;
avpriv_set_pts_info(st, 64, 1, avio_rb16(pb));

View File

@ -66,6 +66,7 @@ typedef struct FLVContext {
int keyframe_count;
int64_t *keyframe_times;
int64_t *keyframe_filepositions;
int missing_streams;
} FLVContext;
static int probe(AVProbeData *p, int live)
@ -137,6 +138,11 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
&& s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
&& s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE))
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
if (codec_type == AVMEDIA_TYPE_AUDIO)
flv->missing_streams &= ~FLV_HEADER_FLAG_HASAUDIO;
if (codec_type == AVMEDIA_TYPE_VIDEO)
flv->missing_streams &= ~FLV_HEADER_FLAG_HASVIDEO;
avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
flv->last_keyframe_stream_index = s->nb_streams - 1;
@ -283,7 +289,9 @@ static int flv_same_video_codec(AVCodecParameters *vpar, int flags)
static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
int flv_codecid, int read)
{
int ret = 0;
AVCodecParameters *par = vstream->codecpar;
enum AVCodecID old_codec_id = vstream->codecpar->codec_id;
switch (flv_codecid) {
case FLV_CODECID_H263:
par->codec_id = AV_CODEC_ID_FLV1;
@ -311,20 +319,28 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
else
avio_skip(s->pb, 1);
}
return 1; // 1 byte body size adjustment for flv_read_packet()
ret = 1; // 1 byte body size adjustment for flv_read_packet()
break;
case FLV_CODECID_H264:
par->codec_id = AV_CODEC_ID_H264;
vstream->need_parsing = AVSTREAM_PARSE_HEADERS;
return 3; // not 4, reading packet type will consume one byte
ret = 3; // not 4, reading packet type will consume one byte
break;
case FLV_CODECID_MPEG4:
par->codec_id = AV_CODEC_ID_MPEG4;
return 3;
ret = 3;
break;
default:
avpriv_request_sample(s, "Video codec (%x)", flv_codecid);
par->codec_tag = flv_codecid;
}
return 0;
if (!vstream->internal->need_context_update && par->codec_id != old_codec_id) {
avpriv_request_sample(s, "Changing the codec id midstream");
return AVERROR_PATCHWELCOME;
}
return ret;
}
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
@ -539,7 +555,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
} else if (flv->trust_metadata) {
if (!strcmp(key, "videocodecid") && vpar) {
flv_set_video_codec(s, vstream, num_val, 0);
int ret = flv_set_video_codec(s, vstream, num_val, 0);
if (ret < 0)
return ret;
} else if (!strcmp(key, "audiocodecid") && apar) {
int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
flv_set_audio_codec(s, astream, apar, id);
@ -674,11 +692,14 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
static int flv_read_header(AVFormatContext *s)
{
int flags;
FLVContext *flv = s->priv_data;
int offset;
avio_skip(s->pb, 4);
avio_r8(s->pb); // flags
flags = avio_r8(s->pb);
flv->missing_streams = flags & (FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO);
s->ctx_flags |= AVFMTCTX_NOHEADER;
@ -1087,7 +1108,10 @@ retry_duration:
avcodec_parameters_free(&par);
}
} else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
int ret = flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
if (ret < 0)
return ret;
size -= ret;
} else if (stream_type == FLV_STREAM_TYPE_DATA) {
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
}
@ -1216,6 +1240,7 @@ static int flv_read_seek(AVFormatContext *s, int stream_index,
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "flv_metadata", "Allocate streams according to the onMetaData array", OFFSET(trust_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
{ "missing_streams", "", OFFSET(missing_streams), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0xFF, VD | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
{ NULL }
};

View File

@ -1528,9 +1528,29 @@ static void add_stream_to_programs(AVFormatContext *s, struct playlist *pls, AVS
av_dict_set_int(&stream->metadata, "variant_bitrate", bandwidth, 0);
}
static int set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist)
{
int err;
err = avcodec_parameters_copy(st->codecpar, ist->codecpar);
if (err < 0)
return err;
if (pls->is_id3_timestamped) /* custom timestamps via id3 */
avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
else
avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
st->internal->need_context_update = 1;
return 0;
}
/* add new subdemuxer streams to our context, if any */
static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *pls)
{
int err;
while (pls->n_main_streams < pls->ctx->nb_streams) {
int ist_idx = pls->n_main_streams;
AVStream *st = avformat_new_stream(s, NULL);
@ -1540,17 +1560,13 @@ static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *p
return AVERROR(ENOMEM);
st->id = pls->index;
avcodec_parameters_copy(st->codecpar, ist->codecpar);
if (pls->is_id3_timestamped) /* custom timestamps via id3 */
avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
else
avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
dynarray_add(&pls->main_streams, &pls->n_main_streams, st);
add_stream_to_programs(s, pls, st);
err = set_stream_info_from_input_stream(st, pls, ist);
if (err < 0)
return err;
}
return 0;
@ -1946,6 +1962,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
/* If we got a packet, return it */
if (minplaylist >= 0) {
struct playlist *pls = c->playlists[minplaylist];
AVStream *ist;
AVStream *st;
ret = update_streams_from_subdemuxer(s, pls);
if (ret < 0) {
@ -1968,15 +1986,28 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_BUG;
}
ist = pls->ctx->streams[pls->pkt.stream_index];
st = pls->main_streams[pls->pkt.stream_index];
*pkt = pls->pkt;
pkt->stream_index = pls->main_streams[pls->pkt.stream_index]->index;
pkt->stream_index = st->index;
reset_packet(&c->playlists[minplaylist]->pkt);
if (pkt->dts != AV_NOPTS_VALUE)
c->cur_timestamp = av_rescale_q(pkt->dts,
pls->ctx->streams[pls->pkt.stream_index]->time_base,
ist->time_base,
AV_TIME_BASE_Q);
/* There may be more situations where this would be useful, but this at least
* handles newly probed codecs properly (i.e. request_probe by mpegts). */
if (ist->codecpar->codec_id != st->codecpar->codec_id) {
ret = set_stream_info_from_input_stream(st, pls, ist);
if (ret < 0) {
av_packet_unref(pkt);
return ret;
}
}
return 0;
}
return AVERROR_EOF;

View File

@ -109,6 +109,10 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 5);
ico->images[i].size = avio_rl32(pb);
if (ico->images[i].size <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size);
return AVERROR_INVALIDDATA;
}
ico->images[i].offset = avio_rl32(pb);
if (avio_seek(pb, ico->images[i].offset, SEEK_SET) < 0)
@ -174,8 +178,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
bytestream_put_le16(&buf, 0);
bytestream_put_le32(&buf, 0);
if ((ret = avio_read(pb, buf, image->size)) < 0)
return ret;
if ((ret = avio_read(pb, buf, image->size)) != image->size) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_INVALIDDATA;
}
st->codecpar->bits_per_coded_sample = AV_RL16(buf + 14);

View File

@ -3772,6 +3772,11 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Failed to read file headers\n");
return -1;
}
if (!s->nb_streams) {
matroska_read_close(s);
av_log(s, AV_LOG_ERROR, "No streams found\n");
return AVERROR_INVALIDDATA;
}
if (!matroska->is_live) {
buf = av_asprintf("%g", matroska->duration);

View File

@ -2961,7 +2961,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
int first_non_zero_audio_edit = -1;
int packet_skip_samples = 0;
if (!msc->elst_data || msc->elst_count <= 0) {
if (!msc->elst_data || msc->elst_count <= 0 || nb_old <= 0) {
return;
}
// Clean AVStream from traces of old index

View File

@ -112,7 +112,7 @@ static int mpegps_probe(AVProbeData *p)
: AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg
if ((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys &&
!pspack && p->buf_size > 2048 && vid + audio > invalid) /* PES stream */
return (audio > 12 || vid > 3 + 2 * invalid) ? AVPROBE_SCORE_EXTENSION + 2
return (audio > 12 || vid > 6 + 2 * invalid) ? AVPROBE_SCORE_EXTENSION + 2
: AVPROBE_SCORE_EXTENSION / 2;
// 02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1

View File

@ -2681,8 +2681,17 @@ static int mpegts_read_header(AVFormatContext *s)
packet_count[nb_pcrs] = nb_packets;
pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
nb_pcrs++;
if (nb_pcrs >= 2)
break;
if (nb_pcrs >= 2) {
if (pcrs[1] - pcrs[0] > 0) {
/* the difference needs to be positive to make sense for bitrate computation */
break;
} else {
av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= %"PRId64"\n", pcrs[0], pcrs[1]);
pcrs[0] = pcrs[1];
packet_count[0] = packet_count[1];
nb_pcrs--;
}
}
} else {
finished_reading_packet(s, ts->raw_packet_size);
}

View File

@ -391,7 +391,7 @@ static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
for (i = 0; i < s->nb_streams; i++) {
MXFTrack *track = s->streams[i]->priv_data;
/* SMPTE 379M 7.3 */
if (!memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
if (track && !memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
return i;
}
/* return 0 if only one stream, for OP Atom files with 0 as track number */
@ -3135,7 +3135,7 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) {
pkt->dts = mxf->current_edit_unit + t->first_dts;
pkt->pts = t->ptses[mxf->current_edit_unit];
} else if (track->intra_only) {
} else if (track && track->intra_only) {
/* intra-only -> PTS = EditUnit.
* let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */
pkt->pts = mxf->current_edit_unit;

View File

@ -934,6 +934,10 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
ast->sub_packet_cnt = 0;
rm->audio_stream_num = st->index;
if (st->codecpar->block_align <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid block alignment %d\n", st->codecpar->block_align);
return AVERROR_INVALIDDATA;
}
rm->audio_pkt_cnt = h * w / st->codecpar->block_align;
} else if ((ast->deint_id == DEINT_ID_VBRF) ||
(ast->deint_id == DEINT_ID_VBRS)) {

View File

@ -927,7 +927,7 @@ static void expand_timestamps(void *log, struct sbg_script *s)
}
}
if (s->start_ts == AV_NOPTS_VALUE)
s->start_ts = s->opt_start_at_first ? s->tseq[0].ts.t : now;
s->start_ts = (s->opt_start_at_first && s->tseq) ? s->tseq[0].ts.t : now;
s->end_ts = s->opt_duration ? s->start_ts + s->opt_duration :
AV_NOPTS_VALUE; /* may be overridden later by -E option */
cur_ts = now;

View File

@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s)
if (!st->internal->need_context_update)
continue;
/* close parser, because it depends on the codec */
if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
av_parser_close(st->parser);
st->parser = NULL;
}
/* update internal codec context, for the parser */
ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
if (ret < 0)
@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
st->info->found_decoder = 0;
}
/* close parser, because it depends on the codec */
if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
av_parser_close(st->parser);
st->parser = NULL;
}
ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
if (ret < 0)
return ret;
@ -3349,6 +3361,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
int64_t max_subtitle_analyze_duration;
int64_t probesize = ic->probesize;
int eof_reached = 0;
int64_t *missing_streams = av_opt_ptr(ic->iformat->priv_class, ic->priv_data, "missing_streams");
flush_codecs = probesize > 0;
@ -3502,6 +3515,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
break;
}
analyzed_all_streams = 0;
if (!missing_streams || !*missing_streams)
if (i == ic->nb_streams) {
analyzed_all_streams = 1;
/* NOTE: If the format has no header, then we need to read some

View File

@ -27,7 +27,7 @@
#include "avassert.h"
#include "softfloat_tables.h"
#define MIN_EXP -126
#define MIN_EXP -149
#define MAX_EXP 126
#define ONE_BITS 29
@ -175,7 +175,7 @@ static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
*/
static inline av_const SoftFloat av_int2sf(int v, int frac_bits){
int exp_offset = 0;
if(v == INT_MIN){
if(v <= INT_MIN + 1){
exp_offset = 1;
v>>=1;
}

View File

@ -1,5 +1,6 @@
FATE_LAVF-$(call ENCDEC, PCM_S16BE, AIFF) += aiff
FATE_LAVF-$(call ENCDEC, PCM_ALAW, PCM_ALAW) += alaw
FATE_LAVF-$(call ENCDEC, APNG, APNG) += apng
FATE_LAVF-$(call ENCDEC2, MSMPEG4V3, MP2, ASF) += asf
FATE_LAVF-$(call ENCDEC, PCM_S16BE_PLANAR, AST) += ast
FATE_LAVF-$(call ENCDEC, PCM_S16BE, AU) += au

View File

@ -212,6 +212,18 @@ do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -q
do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24
fi
if [ -n "$do_apng" ] ; then
file=${outfile}lavf.apng
do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -pix_fmt rgb24
do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24
file_copy=${outfile}lavf.copy.apng
do_avconv $file_copy $DEC_OPTS -i $file $ENC_OPTS -c copy
do_avconv_crc $file_copy $DEC_OPTS -i $target_path/$file_copy
file=${outfile}lavf.png
do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -pix_fmt rgb24 -frames:v 1 -f apng
do_avconv_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24
fi
if [ -n "$do_yuv4mpeg" ] ; then
file=${outfile}lavf.y4m
do_avconv $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -qscale 10

9
tests/ref/lavf/apng Normal file
View File

@ -0,0 +1,9 @@
a4c46fad7716ad094eb3c78b74ca0244 *./tests/data/lavf/lavf.apng
6209864 ./tests/data/lavf/lavf.apng
./tests/data/lavf/lavf.apng CRC=0x87b3c15f
a4c46fad7716ad094eb3c78b74ca0244 *./tests/data/lavf/lavf.copy.apng
6209864 ./tests/data/lavf/lavf.copy.apng
./tests/data/lavf/lavf.copy.apng CRC=0x87b3c15f
c5900fdd1b2fc30b985793f5226fd0c4 *./tests/data/lavf/lavf.png
248854 ./tests/data/lavf/lavf.png
./tests/data/lavf/lavf.png CRC=0xd8c7b7a1