|
|
|
@ -1123,7 +1123,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, |
|
|
|
|
if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE) { |
|
|
|
|
st->start_time = pktl_it->pkt.pts; |
|
|
|
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) |
|
|
|
|
st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base)); |
|
|
|
|
st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->internal->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1136,7 +1136,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, |
|
|
|
|
st->start_time = pts; |
|
|
|
|
} |
|
|
|
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) |
|
|
|
|
st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base)); |
|
|
|
|
st->start_time = av_sat_add64(st->start_time, av_rescale_q(st->internal->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1639,25 +1639,25 @@ FF_ENABLE_DEPRECATION_WARNINGS |
|
|
|
|
if (ret >= 0) { |
|
|
|
|
AVStream *st = s->streams[pkt->stream_index]; |
|
|
|
|
int discard_padding = 0; |
|
|
|
|
if (st->first_discard_sample && pkt->pts != AV_NOPTS_VALUE) { |
|
|
|
|
if (st->internal->first_discard_sample && pkt->pts != AV_NOPTS_VALUE) { |
|
|
|
|
int64_t pts = pkt->pts - (is_relative(pkt->pts) ? RELATIVE_TS_BASE : 0); |
|
|
|
|
int64_t sample = ts_to_samples(st, pts); |
|
|
|
|
int duration = ts_to_samples(st, pkt->duration); |
|
|
|
|
int64_t end_sample = sample + duration; |
|
|
|
|
if (duration > 0 && end_sample >= st->first_discard_sample && |
|
|
|
|
sample < st->last_discard_sample) |
|
|
|
|
discard_padding = FFMIN(end_sample - st->first_discard_sample, duration); |
|
|
|
|
if (duration > 0 && end_sample >= st->internal->first_discard_sample && |
|
|
|
|
sample < st->internal->last_discard_sample) |
|
|
|
|
discard_padding = FFMIN(end_sample - st->internal->first_discard_sample, duration); |
|
|
|
|
} |
|
|
|
|
if (st->start_skip_samples && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE)) |
|
|
|
|
st->skip_samples = st->start_skip_samples; |
|
|
|
|
if (st->skip_samples || discard_padding) { |
|
|
|
|
if (st->internal->start_skip_samples && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE)) |
|
|
|
|
st->internal->skip_samples = st->internal->start_skip_samples; |
|
|
|
|
if (st->internal->skip_samples || discard_padding) { |
|
|
|
|
uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); |
|
|
|
|
if (p) { |
|
|
|
|
AV_WL32(p, st->skip_samples); |
|
|
|
|
AV_WL32(p, st->internal->skip_samples); |
|
|
|
|
AV_WL32(p + 4, discard_padding); |
|
|
|
|
av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d / discard %d\n", st->skip_samples, discard_padding); |
|
|
|
|
av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d / discard %d\n", st->internal->skip_samples, discard_padding); |
|
|
|
|
} |
|
|
|
|
st->skip_samples = 0; |
|
|
|
|
st->internal->skip_samples = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (st->internal->inject_global_side_data) { |
|
|
|
@ -1891,7 +1891,7 @@ void ff_read_frame_flush(AVFormatContext *s) |
|
|
|
|
if (s->internal->inject_global_side_data) |
|
|
|
|
st->internal->inject_global_side_data = 1; |
|
|
|
|
|
|
|
|
|
st->skip_samples = 0; |
|
|
|
|
st->internal->skip_samples = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|