1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avformat/mov: export the correct initial extratada from samples with multiple stsd

The first sample in the stsc box may not refer to the first stsd entry.
This is the case in h264/thezerotheorem-cut.mp4, and as such the
fate-h264_redundant_pps-side_data test is updated accordingly.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-07-27 16:14:12 -03:00
parent a4a3b3bf54
commit eefa6de7d5
2 changed files with 18 additions and 4 deletions

View File

@ -10580,6 +10580,20 @@ static int mov_read_header(AVFormatContext *s)
MOVStreamContext *sc = st->priv_data; MOVStreamContext *sc = st->priv_data;
uint32_t dvdsub_clut[FF_DVDCLUT_CLUT_LEN] = {0}; uint32_t dvdsub_clut[FF_DVDCLUT_CLUT_LEN] = {0};
fix_timescale(mov, sc); fix_timescale(mov, sc);
/* Set the primary extradata based on the first Sample. */
if (sc->stsc_count && sc->extradata_size && !sc->iamf) {
sc->last_stsd_index = sc->stsc_data[0].id - 1;
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = sc->extradata_size[sc->last_stsd_index];
if (sc->extradata_size[sc->last_stsd_index]) {
st->codecpar->extradata = av_mallocz(sc->extradata_size[sc->last_stsd_index] + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
memcpy(st->codecpar->extradata, sc->extradata[sc->last_stsd_index], sc->extradata_size[sc->last_stsd_index]);
}
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codecpar->codec_id == AV_CODEC_ID_AAC) { st->codecpar->codec_id == AV_CODEC_ID_AAC) {
sti->skip_samples = sc->start_pad; sti->skip_samples = sc->start_pad;

View File

@ -1,12 +1,12 @@
a35cca13c3f91d1a279bf576b8264d05 *tests/data/fate/h264_redundant_pps-side_data.nut 92fe70291f72acf94ba56b426bbaccb0 *tests/data/fate/h264_redundant_pps-side_data.nut
596153 tests/data/fate/h264_redundant_pps-side_data.nut 596100 tests/data/fate/h264_redundant_pps-side_data.nut
#extradata 0: 34, 0x851f08e4 #extradata 0: 34, 0x850408e3
#tb 0: 1/48000 #tb 0: 1/48000
#media_type 0: video #media_type 0: video
#codec_id 0: h264 #codec_id 0: h264
#dimensions 0: 1920x1080 #dimensions 0: 1920x1080
#sar 0: 0/1 #sar 0: 0/1
0, -2002, 0, 2002, 247959, 0xdb721881, S=1, New Extradata, 34, 0x850408e3 0, -2002, 0, 2002, 247959, 0xdb721881
0, 0, 4004, 2002, 43356, 0xa366eb79, F=0x0 0, 0, 4004, 2002, 43356, 0xa366eb79, F=0x0
0, 2002, 2002, 2002, 11423, 0x9c0a86fa, F=0x0 0, 2002, 2002, 2002, 11423, 0x9c0a86fa, F=0x0
0, 4004, 8008, 2002, 50801, 0xfbfe860d, F=0x0 0, 4004, 8008, 2002, 50801, 0xfbfe860d, F=0x0