Skip to content

Commit a3b54e8

Browse files
committed
ffmdec: evil compat hacks to keep it working when using the deprecated st->codec
FATE changes to accomodate a few changed codec properties
1 parent 66afc9e commit a3b54e8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

libavformat/ffmdec.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static int ffm2_read_header(AVFormatContext *s)
283283
AVIOContext *pb = s->pb;
284284
AVCodecContext *codec;
285285
const AVCodecDescriptor *codec_desc;
286-
int ret;
286+
int ret, i;
287287
int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
288288
AVCodec *enc;
289289
char *buffer;
@@ -356,8 +356,12 @@ static int ffm2_read_header(AVFormatContext *s)
356356
codec->flags2 = avio_rb32(pb);
357357
codec->debug = avio_rb32(pb);
358358
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
359-
if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0)
359+
int size = avio_rb32(pb);
360+
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
361+
if (!codec->extradata)
360362
return AVERROR(ENOMEM);
363+
codec->extradata_size = size;
364+
avio_read(pb, codec->extradata, size);
361365
}
362366
break;
363367
case MKBETAG('S', 'T', 'V', 'I'):
@@ -476,6 +480,9 @@ static int ffm2_read_header(AVFormatContext *s)
476480
avio_seek(pb, next, SEEK_SET);
477481
}
478482

483+
for (i = 0; i < s->nb_streams; i++)
484+
avcodec_parameters_from_context(s->streams[i]->codecpar, s->streams[i]->codec);
485+
479486
/* get until end of block reached */
480487
while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)
481488
avio_r8(pb);
@@ -617,9 +624,15 @@ static int ffm_read_header(AVFormatContext *s)
617624
goto fail;
618625
}
619626
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
620-
if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0)
627+
int size = avio_rb32(pb);
628+
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
629+
if (!codec->extradata)
621630
return AVERROR(ENOMEM);
631+
codec->extradata_size = size;
632+
avio_read(pb, codec->extradata, size);
622633
}
634+
635+
avcodec_parameters_from_context(st->codecpar, codec);
623636
}
624637

625638
/* get until end of block reached */

tests/ref/lavf/ffm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
e63c16b5f0ad5015304fc4009fdb33ca *./tests/data/lavf/lavf.ffm
1+
79674a5219d00e1d2221a29157b35eb4 *./tests/data/lavf/lavf.ffm
22
376832 ./tests/data/lavf/lavf.ffm
33
./tests/data/lavf/lavf.ffm CRC=0x000e23ae

0 commit comments

Comments
 (0)