fftools/ffprobe: keep decoder buffers unflushed for show_streams()

When a decoder buffer is flushed, parts of the private context is reset,
which may affect show_streams().

Example:
ffprobe -of flat fate-suite/ac3/mp3ac325-4864-small.ts \
    -analyze_frames -show_entries stream=ltrt_cmixlev
Before: ltrt_cmixlev="0.000000"
After:  ltrt_cmixlev="0.707107"

Currently, it seems that only ac3 downmix info is concerned.
(ac3 downmix options are exported since 376bb8481a).

Fix regression since 045a8b15b1.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
This commit is contained in:
Nicolas Gaullier
2026-01-27 17:29:11 +01:00
committed by James Almer
parent 8a0ae6b344
commit b66c314c4b

View File

@@ -1700,8 +1700,6 @@ static int read_interval_packets(AVTextFormatContext *tfc, InputFile *ifile,
pkt->stream_index = i;
if (do_read_frames) {
while (process_frame(tfc, ifile, frame, pkt, &(int){1}) > 0);
if (ifile->streams[i].dec_ctx)
avcodec_flush_buffers(ifile->streams[i].dec_ctx);
}
}
@@ -1715,6 +1713,18 @@ end:
return ret;
}
static void flush_buffers(InputFile *ifile)
{
int i;
if (!do_read_frames)
return;
for (i = 0; i < ifile->nb_streams; i++) {
if (ifile->streams[i].dec_ctx)
avcodec_flush_buffers(ifile->streams[i].dec_ctx);
}
}
static int read_packets(AVTextFormatContext *tfc, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
@@ -1726,6 +1736,10 @@ static int read_packets(AVTextFormatContext *tfc, InputFile *ifile)
ret = read_interval_packets(tfc, ifile, &interval, &cur_ts);
} else {
for (i = 0; i < read_intervals_nb; i++) {
/* flushing buffers can reset parts of the private context which may be
* read by show_streams(), so only flush between each read_interval */
if (i)
flush_buffers(ifile);
ret = read_interval_packets(tfc, ifile, &read_intervals[i], &cur_ts);
if (ret < 0)
break;