Commit c7b11ee697 for ffmpeg
commit c7b11ee69728871a809cd4950e5bd4e4361ea256
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Mon Nov 23 18:52:38 2026 -0800
fate/h264: check the signalled reorder limit after a flush
Replay the active SPS with caller depths zero and one, then verify
the first output packet and drained pictures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Assisted-by: Fairy
diff --git a/tests/api/api-h264-flush-test.c b/tests/api/api-h264-flush-test.c
index e9045f9f34..188373c291 100644
--- a/tests/api/api-h264-flush-test.c
+++ b/tests/api/api-h264-flush-test.c
@@ -113,13 +113,24 @@ static void decode(AVCodecContext *ctx, const char *path,
avformat_close_input(&fmt);
}
-static AVCodecContext *open_decoder(int threads)
+static AVCodecContext *open_decoder(int threads, int video_delay)
{
const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_H264);
AVCodecContext *ctx = avcodec_alloc_context3(codec);
if (!ctx)
exit(1);
+ if (video_delay) {
+ AVCodecParameters *par = avcodec_parameters_alloc();
+
+ if (!par)
+ exit(1);
+ par->codec_type = AVMEDIA_TYPE_VIDEO;
+ par->codec_id = AV_CODEC_ID_H264;
+ par->video_delay = video_delay;
+ check(avcodec_parameters_to_context(ctx, par));
+ avcodec_parameters_free(&par);
+ }
ctx->thread_count = threads;
ctx->thread_type = FF_THREAD_FRAME;
check(avcodec_open2(ctx, codec, NULL));
@@ -135,12 +146,12 @@ int main(int argc, char **argv)
AVCodecContext *ctx;
int threads;
- if (argc != 5)
+ if (argc != 6)
return 1;
av_log_set_level(AV_LOG_ERROR);
threads = atoi(argv[1]);
- ctx = open_decoder(threads);
+ ctx = open_decoder(threads, 0);
/* BA1 should output immediately after the flush. The following SPS
* needs the learned reorder depth to output every picture. */
@@ -151,19 +162,30 @@ int main(int argc, char **argv)
/* A one-packet BA1 prefix switches back to CAMACI3 on the next worker.
* Count both inputs because the prefix picture may still be queued. */
- ctx = open_decoder(threads);
+ ctx = open_decoder(threads, 0);
decode(ctx, argv[2], NULL, 0, 0);
avcodec_flush_buffers(ctx);
decode(ctx, argv[3], argv[2], 1, REPORT_FRAMES);
avcodec_free_context(&ctx);
/* Seek back to the active SPS before the prefix learns its depth. */
- ctx = open_decoder(threads);
+ ctx = open_decoder(threads, 0);
decode(ctx, argv[2], NULL, 0, 0);
avcodec_flush_buffers(ctx);
decode(ctx, argv[4], NULL, 8, 0);
avcodec_flush_buffers(ctx);
decode(ctx, argv[4], NULL, 0, REPORT_FRAMES);
avcodec_free_context(&ctx);
+
+ /* Replay MR7 after a flush while its zero-reorder SPS is still active,
+ * with and without one frame of delay supplied by the caller. */
+ for (int video_delay = 0; video_delay <= 1; video_delay++) {
+ ctx = open_decoder(threads, video_delay);
+ decode(ctx, argv[4], NULL, 20, 0);
+ decode(ctx, argv[5], NULL, 1, 0);
+ avcodec_flush_buffers(ctx);
+ decode(ctx, argv[5], NULL, 0, REPORT_TIMING | REPORT_FRAMES);
+ avcodec_free_context(&ctx);
+ }
return 0;
}
diff --git a/tests/fate/api.mak b/tests/fate/api.mak
index 0ad93e749a..ea9cb55d1f 100644
--- a/tests/fate/api.mak
+++ b/tests/fate/api.mak
@@ -52,7 +52,8 @@ fate-api-h264-flush: $(APITESTSDIR)/api-h264-flush-test$(EXESUF)
fate-api-h264-flush: CMD = run $(APITESTSDIR)/api-h264-flush-test$(EXESUF) $(if $(HAVE_THREADS),4,1) \
$(TARGET_SAMPLES)/h264-conformance/CAMACI3_Sony_C.jsv \
$(TARGET_SAMPLES)/h264-conformance/BA1_Sony_D.jsv \
- $(TARGET_SAMPLES)/h264/reference-b-reorder.h264
+ $(TARGET_SAMPLES)/h264/reference-b-reorder.h264 \
+ $(TARGET_SAMPLES)/h264-conformance/MR7_BT_B.h264
FATE_API_SAMPLES_LIBAVFORMAT-$(call DEMDEC, H264, H264) += fate-api-h264-slice
fate-api-h264-slice: $(APITESTSDIR)/api-h264-slice-test$(EXESUF)
diff --git a/tests/ref/fate/api-h264-flush b/tests/ref/fate/api-h264-flush
index 892434c4c7..c34d4b507b 100644
--- a/tests/ref/fate/api-h264-flush
+++ b/tests/ref/fate/api-h264-flush
@@ -2,3 +2,7 @@ first output after 1 packet(s) plus thread delay
38 frames, checksum cda5b62d
18 frames, checksum 298dea73
21 frames, checksum b2004ca5
+first output after 1 packet(s) plus thread delay
+60 frames, checksum 9c9e6b54
+first output after 2 packet(s) plus thread delay
+60 frames, checksum 9c9e6b54