avformat/mov: export initial padding
Some muxers, like Matroska, use it to write priming samples. fate-segment-adts-to-mkv no longer uses the ref file from fate-segment-adts-to-mkv-header-all as it's demuxed through the hls demuxer and this commit exposed a bug where initial padding is not being propagated. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -241,7 +241,6 @@ typedef struct MOVStreamContext {
|
||||
uint32_t tmcd_flags; ///< tmcd track flags
|
||||
uint8_t tmcd_nb_frames; ///< tmcd number of frames per tick / second
|
||||
int64_t track_end; ///< used for dts generation in fragmented movie files
|
||||
int start_pad; ///< amount of samples to skip due to enc-dec delay
|
||||
unsigned int rap_group_count;
|
||||
MOVSbgp *rap_group;
|
||||
unsigned int sync_group_count;
|
||||
|
||||
+9
-12
@@ -4459,7 +4459,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
|
||||
}
|
||||
found_non_empty_edit = 1;
|
||||
|
||||
// If we encounter a non-negative edit list reset the skip_samples/start_pad fields and set them
|
||||
// If we encounter a non-negative edit list reset the skip_samples/initial_padding fields and set them
|
||||
// according to the edit list below.
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
if (first_non_zero_audio_edit < 0) {
|
||||
@@ -4469,7 +4469,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
|
||||
}
|
||||
|
||||
if (first_non_zero_audio_edit > 0)
|
||||
sti->skip_samples = msc->start_pad = 0;
|
||||
sti->skip_samples = st->codecpar->initial_padding = 0;
|
||||
}
|
||||
|
||||
// While reordering frame index according to edit list we must handle properly
|
||||
@@ -4663,7 +4663,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
|
||||
|
||||
// Update av stream length, if it ends up shorter than the track's media duration
|
||||
st->duration = FFMIN(st->duration, edit_list_dts_entry_end - start_dts);
|
||||
msc->start_pad = sti->skip_samples;
|
||||
st->codecpar->initial_padding = sti->skip_samples;
|
||||
|
||||
// Free the old index and the old CTTS structures
|
||||
av_free(e_old);
|
||||
@@ -4881,7 +4881,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
|
||||
|
||||
if (!multiple_edits && !mov->advanced_editlist &&
|
||||
st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)
|
||||
sc->start_pad = av_rescale_q(start_time, st->time_base,
|
||||
st->codecpar->initial_padding = av_rescale_q(start_time, st->time_base,
|
||||
(AVRational){1, st->codecpar->sample_rate});
|
||||
}
|
||||
|
||||
@@ -5518,12 +5518,10 @@ static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
int i;
|
||||
int ret = 0;
|
||||
AVStream *st;
|
||||
MOVStreamContext *sc;
|
||||
|
||||
if (c->fc->nb_streams < 1)
|
||||
return 0;
|
||||
st = c->fc->streams[c->fc->nb_streams-1];
|
||||
sc = st->priv_data;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
uint8_t **p;
|
||||
@@ -5572,8 +5570,8 @@ static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
int priming, remainder, samples;
|
||||
if(sscanf(val, "%*X %X %X %X", &priming, &remainder, &samples) == 3){
|
||||
if(priming>0 && priming<16384)
|
||||
sc->start_pad = priming = av_rescale_q(priming, st->time_base,
|
||||
(AVRational){ 1, st->codecpar->sample_rate });
|
||||
st->codecpar->initial_padding = priming = av_rescale_q(priming, st->time_base,
|
||||
(AVRational){ 1, st->codecpar->sample_rate });
|
||||
if (remainder > 0) {
|
||||
int64_t duration = av_rescale_q(st->duration, st->time_base,
|
||||
(AVRational){ 1, st->codecpar->sample_rate });
|
||||
@@ -11322,7 +11320,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
st->codecpar->codec_id == AV_CODEC_ID_AAC) {
|
||||
sti->skip_samples = sc->start_pad;
|
||||
sti->skip_samples = st->codecpar->initial_padding;
|
||||
}
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0)
|
||||
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
|
||||
@@ -12026,7 +12024,6 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp,
|
||||
|
||||
static int64_t mov_get_skip_samples(AVStream *st, int sample)
|
||||
{
|
||||
MOVStreamContext *sc = st->priv_data;
|
||||
FFStream *const sti = ffstream(st);
|
||||
int64_t first_ts = sti->index_entries[0].timestamp;
|
||||
int64_t ts = sti->index_entries[sample].timestamp;
|
||||
@@ -12035,10 +12032,10 @@ static int64_t mov_get_skip_samples(AVStream *st, int sample)
|
||||
if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
|
||||
return 0;
|
||||
|
||||
/* compute skip samples according to stream start_pad, seek ts and first ts */
|
||||
/* compute skip samples according to stream initial_padding, seek ts and first ts */
|
||||
off = av_rescale_q(ts - first_ts, st->time_base,
|
||||
(AVRational){1, st->codecpar->sample_rate});
|
||||
return FFMAX(sc->start_pad - off, 0);
|
||||
return FFMAX(st->codecpar->initial_padding - off, 0);
|
||||
}
|
||||
|
||||
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
|
||||
|
||||
@@ -40,7 +40,6 @@ FATE_SEGMENT-$(call FRAMECRC, MOV HLS MATROSKA, H264, H264_PARSER H264_MP4TOANNE
|
||||
FATE_SEGMENT += fate-segment-adts-to-mkv
|
||||
fate-segment-adts-to-mkv: tests/data/adts-to-mkv.m3u8
|
||||
fate-segment-adts-to-mkv: CMD = framecrc -flags +bitexact -i $(TARGET_PATH)/tests/data/adts-to-mkv.m3u8 -c copy
|
||||
fate-segment-adts-to-mkv: REF = $(SRC_PATH)/tests/ref/fate/segment-adts-to-mkv-header-all
|
||||
FATE_SEGMENT-$(call FRAMECRC, AAC HLS MATROSKA, AAC, AAC_ADTSTOASC_BSF MATROSKA_MUXER SEGMENT_MUXER) += fate-segment-adts-to-mkv
|
||||
|
||||
FATE_SEGMENT_ALLPARTS = $(FATE_SEGMENT_PARTS)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#extradata 0: 2, 0x0030001c
|
||||
#tb 0: 1/1000
|
||||
#media_type 0: audio
|
||||
#codec_id 0: aac
|
||||
#sample_rate 0: 16000
|
||||
#channel_layout_name 0: mono
|
||||
0, 0, 0, 64, 4, 0x02f70117, S=1, Skip Samples, 10, 0x02c80048
|
||||
0, 64, 64, 64, 163, 0xd5f85007
|
||||
0, 128, 128, 64, 127, 0x66484065
|
||||
0, 192, 192, 64, 94, 0x55222bd6
|
||||
0, 256, 256, 64, 314, 0x3c7e923a
|
||||
0, 320, 320, 64, 207, 0x1efc5d1b
|
||||
0, 384, 384, 64, 119, 0xb2a13601
|
||||
0, 448, 448, 64, 184, 0xcafc6091
|
||||
0, 512, 512, 64, 132, 0xddd33c0b
|
||||
0, 576, 576, 64, 152, 0x83935031
|
||||
0, 640, 640, 64, 227, 0x32a86bc4
|
||||
0, 704, 704, 64, 122, 0xd04e3571
|
||||
0, 768, 768, 64, 163, 0x57d44d16
|
||||
0, 832, 832, 64, 147, 0x226043d7
|
||||
0, 896, 896, 64, 119, 0x8ad931ed
|
||||
0, 960, 960, 64, 153, 0xbb6e432f
|
||||
0, 1024, 1024, 64, 185, 0xa01f4ff3
|
||||
0, 1088, 1088, 64, 126, 0x85503ce6
|
||||
0, 1152, 1152, 64, 246, 0x652c7b59
|
||||
0, 1216, 1216, 64, 162, 0xc9f04da0
|
||||
0, 1280, 1280, 64, 135, 0x71fa3be0
|
||||
0, 1344, 1344, 64, 246, 0x7a6f7788
|
||||
0, 1408, 1408, 64, 262, 0xd3097781
|
||||
0, 1472, 1472, 64, 60, 0x09a118f5
|
||||
0, 1536, 1536, 64, 255, 0xbab5793c
|
||||
0, 1600, 1600, 64, 153, 0x6b6a44fb
|
||||
0, 1664, 1664, 64, 160, 0x550e4530
|
||||
0, 1728, 1728, 64, 215, 0x7fe66144
|
||||
0, 1792, 1792, 64, 144, 0xcd723f7d
|
||||
0, 1856, 1856, 64, 187, 0x2a0b5c1b
|
||||
0, 1920, 1920, 64, 177, 0xb8c355d5
|
||||
0, 1984, 1984, 64, 156, 0x867d4f3a
|
||||
0, 2048, 2048, 64, 201, 0x62745ff9
|
||||
0, 2112, 2112, 64, 137, 0x90c639e0, S=1, Skip Samples, 10, 0x048a00c2
|
||||
@@ -4,18 +4,18 @@
|
||||
#codec_id 0: aac
|
||||
#sample_rate 0: 16000
|
||||
#channel_layout_name 0: mono
|
||||
0, 0, 0, 64, 4, 0x02f70117
|
||||
0, 64, 64, 64, 163, 0xd5f85007
|
||||
0, 128, 128, 64, 127, 0x66484065
|
||||
0, 192, 192, 64, 94, 0x55222bd6
|
||||
0, 256, 256, 64, 314, 0x3c7e923a
|
||||
0, 320, 320, 64, 207, 0x1efc5d1b
|
||||
0, 384, 384, 64, 119, 0xb2a13601
|
||||
0, 448, 448, 64, 184, 0xcafc6091
|
||||
0, 512, 512, 64, 132, 0xddd33c0b
|
||||
0, 576, 576, 64, 152, 0x83935031
|
||||
0, 640, 640, 64, 227, 0x32a86bc4
|
||||
0, 704, 704, 64, 122, 0xd04e3571
|
||||
0, 768, 768, 64, 163, 0x57d44d16
|
||||
0, 832, 832, 64, 147, 0x226043d7
|
||||
0, 896, 896, 64, 119, 0x8ad931ed
|
||||
0, -132, -132, 64, 4, 0x02f70117, S=1, Skip Samples, 10, 0x02c80048
|
||||
0, -68, -68, 64, 163, 0xd5f85007
|
||||
0, -4, -4, 64, 127, 0x66484065
|
||||
0, 60, 60, 64, 94, 0x55222bd6
|
||||
0, 124, 124, 64, 314, 0x3c7e923a
|
||||
0, 188, 188, 64, 207, 0x1efc5d1b
|
||||
0, 252, 252, 64, 119, 0xb2a13601
|
||||
0, 316, 316, 64, 184, 0xcafc6091
|
||||
0, 380, 380, 64, 132, 0xddd33c0b
|
||||
0, 444, 444, 64, 152, 0x83935031
|
||||
0, 508, 508, 64, 227, 0x32a86bc4
|
||||
0, 572, 572, 64, 122, 0xd04e3571
|
||||
0, 636, 636, 64, 163, 0x57d44d16
|
||||
0, 700, 700, 64, 147, 0x226043d7
|
||||
0, 764, 764, 64, 119, 0x8ad931ed
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
#codec_id 0: aac
|
||||
#sample_rate 0: 16000
|
||||
#channel_layout_name 0: mono
|
||||
0, 0, 0, 64, 153, 0xbb6e432f
|
||||
0, 64, 64, 64, 185, 0xa01f4ff3
|
||||
0, 128, 128, 64, 126, 0x85503ce6
|
||||
0, 192, 192, 64, 246, 0x652c7b59
|
||||
0, 256, 256, 64, 162, 0xc9f04da0
|
||||
0, 320, 320, 64, 135, 0x71fa3be0
|
||||
0, 384, 384, 64, 246, 0x7a6f7788
|
||||
0, 448, 448, 64, 262, 0xd3097781
|
||||
0, 512, 512, 64, 60, 0x09a118f5
|
||||
0, 576, 576, 64, 255, 0xbab5793c
|
||||
0, 640, 640, 64, 153, 0x6b6a44fb
|
||||
0, 704, 704, 64, 160, 0x550e4530
|
||||
0, 768, 768, 64, 215, 0x7fe66144
|
||||
0, 832, 832, 64, 144, 0xcd723f7d
|
||||
0, 896, 896, 64, 187, 0x2a0b5c1b
|
||||
0, 960, 960, 64, 177, 0xb8c355d5
|
||||
0, -132, -132, 64, 153, 0xbb6e432f, S=1, Skip Samples, 10, 0x02c80048
|
||||
0, -68, -68, 64, 185, 0xa01f4ff3
|
||||
0, -4, -4, 64, 126, 0x85503ce6
|
||||
0, 60, 60, 64, 246, 0x652c7b59
|
||||
0, 124, 124, 64, 162, 0xc9f04da0
|
||||
0, 188, 188, 64, 135, 0x71fa3be0
|
||||
0, 252, 252, 64, 246, 0x7a6f7788
|
||||
0, 316, 316, 64, 262, 0xd3097781
|
||||
0, 380, 380, 64, 60, 0x09a118f5
|
||||
0, 444, 444, 64, 255, 0xbab5793c
|
||||
0, 508, 508, 64, 153, 0x6b6a44fb
|
||||
0, 572, 572, 64, 160, 0x550e4530
|
||||
0, 636, 636, 64, 215, 0x7fe66144
|
||||
0, 700, 700, 64, 144, 0xcd723f7d
|
||||
0, 764, 764, 64, 187, 0x2a0b5c1b
|
||||
0, 828, 828, 64, 177, 0xb8c355d5
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#codec_id 0: aac
|
||||
#sample_rate 0: 16000
|
||||
#channel_layout_name 0: mono
|
||||
0, 0, 0, 64, 156, 0x867d4f3a
|
||||
0, 64, 64, 64, 201, 0x62745ff9
|
||||
0, 128, 128, 64, 137, 0x90c639e0, S=1, Skip Samples, 10, 0x048a00c2
|
||||
0, -132, -132, 64, 156, 0x867d4f3a, S=1, Skip Samples, 10, 0x02c80048
|
||||
0, -68, -68, 64, 201, 0x62745ff9
|
||||
0, -4, -4, 64, 137, 0x90c639e0, S=1, Skip Samples, 10, 0x048a00c2
|
||||
|
||||
@@ -4,37 +4,37 @@
|
||||
#codec_id 0: aac
|
||||
#sample_rate 0: 16000
|
||||
#channel_layout_name 0: mono
|
||||
0, 0, 0, 64, 4, 0x02f70117
|
||||
0, 64, 64, 64, 163, 0xd5f85007
|
||||
0, 128, 128, 64, 127, 0x66484065
|
||||
0, 192, 192, 64, 94, 0x55222bd6
|
||||
0, 256, 256, 64, 314, 0x3c7e923a
|
||||
0, 320, 320, 64, 207, 0x1efc5d1b
|
||||
0, 384, 384, 64, 119, 0xb2a13601
|
||||
0, 448, 448, 64, 184, 0xcafc6091
|
||||
0, 512, 512, 64, 132, 0xddd33c0b
|
||||
0, 576, 576, 64, 152, 0x83935031
|
||||
0, 640, 640, 64, 227, 0x32a86bc4
|
||||
0, 704, 704, 64, 122, 0xd04e3571
|
||||
0, 768, 768, 64, 163, 0x57d44d16
|
||||
0, 832, 832, 64, 147, 0x226043d7
|
||||
0, 896, 896, 64, 119, 0x8ad931ed
|
||||
0, 960, 960, 64, 153, 0xbb6e432f
|
||||
0, 1024, 1024, 64, 185, 0xa01f4ff3
|
||||
0, 1088, 1088, 64, 126, 0x85503ce6
|
||||
0, 1152, 1152, 64, 246, 0x652c7b59
|
||||
0, 1216, 1216, 64, 162, 0xc9f04da0
|
||||
0, 1280, 1280, 64, 135, 0x71fa3be0
|
||||
0, 1344, 1344, 64, 246, 0x7a6f7788
|
||||
0, 1408, 1408, 64, 262, 0xd3097781
|
||||
0, 1472, 1472, 64, 60, 0x09a118f5
|
||||
0, 1536, 1536, 64, 255, 0xbab5793c
|
||||
0, 1600, 1600, 64, 153, 0x6b6a44fb
|
||||
0, 1664, 1664, 64, 160, 0x550e4530
|
||||
0, 1728, 1728, 64, 215, 0x7fe66144
|
||||
0, 1792, 1792, 64, 144, 0xcd723f7d
|
||||
0, 1856, 1856, 64, 187, 0x2a0b5c1b
|
||||
0, 1920, 1920, 64, 177, 0xb8c355d5
|
||||
0, 1984, 1984, 64, 156, 0x867d4f3a
|
||||
0, 2048, 2048, 64, 201, 0x62745ff9
|
||||
0, 2112, 2112, 64, 137, 0x90c639e0, S=1, Skip Samples, 10, 0x048a00c2
|
||||
0, -132, -132, 64, 4, 0x02f70117, S=1, Skip Samples, 10, 0x02c80048
|
||||
0, -68, -68, 64, 163, 0xd5f85007
|
||||
0, -4, -4, 64, 127, 0x66484065
|
||||
0, 60, 60, 64, 94, 0x55222bd6
|
||||
0, 124, 124, 64, 314, 0x3c7e923a
|
||||
0, 188, 188, 64, 207, 0x1efc5d1b
|
||||
0, 252, 252, 64, 119, 0xb2a13601
|
||||
0, 316, 316, 64, 184, 0xcafc6091
|
||||
0, 380, 380, 64, 132, 0xddd33c0b
|
||||
0, 444, 444, 64, 152, 0x83935031
|
||||
0, 508, 508, 64, 227, 0x32a86bc4
|
||||
0, 572, 572, 64, 122, 0xd04e3571
|
||||
0, 636, 636, 64, 163, 0x57d44d16
|
||||
0, 700, 700, 64, 147, 0x226043d7
|
||||
0, 764, 764, 64, 119, 0x8ad931ed
|
||||
0, 828, 828, 64, 153, 0xbb6e432f
|
||||
0, 892, 892, 64, 185, 0xa01f4ff3
|
||||
0, 956, 956, 64, 126, 0x85503ce6
|
||||
0, 1020, 1020, 64, 246, 0x652c7b59
|
||||
0, 1084, 1084, 64, 162, 0xc9f04da0
|
||||
0, 1148, 1148, 64, 135, 0x71fa3be0
|
||||
0, 1212, 1212, 64, 246, 0x7a6f7788
|
||||
0, 1276, 1276, 64, 262, 0xd3097781
|
||||
0, 1340, 1340, 64, 60, 0x09a118f5
|
||||
0, 1404, 1404, 64, 255, 0xbab5793c
|
||||
0, 1468, 1468, 64, 153, 0x6b6a44fb
|
||||
0, 1532, 1532, 64, 160, 0x550e4530
|
||||
0, 1596, 1596, 64, 215, 0x7fe66144
|
||||
0, 1660, 1660, 64, 144, 0xcd723f7d
|
||||
0, 1724, 1724, 64, 187, 0x2a0b5c1b
|
||||
0, 1788, 1788, 64, 177, 0xb8c355d5
|
||||
0, 1852, 1852, 64, 156, 0x867d4f3a
|
||||
0, 1916, 1916, 64, 201, 0x62745ff9
|
||||
0, 1980, 1980, 64, 137, 0x90c639e0, S=1, Skip Samples, 10, 0x048a00c2
|
||||
|
||||
Reference in New Issue
Block a user