Allow MP4 millisecond edit rounding in audio tail regression

This commit is contained in:
evgeny committed 2026-10-22 00:17:55 +02:00
1 parent 1d6596dc61
commit df2f90d1f5
1 file changed
+3 -1
+3 -1
View File
@@ -292,7 +292,9 @@ static void decode_audio(const char* path, int minimum_samples, int offset_ms) {
AVStream* stream = format->streams[index];
int64_t end_us = av_rescale_q(stream->start_time + stream->duration, stream->time_base, AV_TIME_BASE_Q);
int64_t expected_end_us = (int64_t)offset_ms * 1000 + av_rescale(minimum_samples, 1000000, stream->codecpar->sample_rate);
assert(llabs(end_us - expected_end_us) <= 150); // Проверяется хвост ресемплера, а не только padded AAC frames.
DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "test_video audio end_us=%lld expected_end_us=%lld", (long long)end_us, (long long)expected_end_us);
// MP4 movie_timescale=1000 округляет edit duration до 1мс; потерянный хвост этого resample превышает допуск.
assert(llabs(end_us - expected_end_us) <= 1000);
AVCodecContext* decoder = avcodec_alloc_context3(avcodec_find_decoder(stream->codecpar->codec_id)); assert(decoder);
assert(avcodec_parameters_to_context(decoder, stream->codecpar) >= 0 && avcodec_open2(decoder, decoder->codec, NULL) >= 0);
AVPacket* packet = av_packet_alloc(); AVFrame* frame = av_frame_alloc(); assert(packet && frame);