diff mbox series

[FFmpeg-devel,21/31] fftools/ffmpeg_dec: pass top_field_first through DecoderOpts

Message ID 20240124081702.4759-21-anton@khirnov.net
State Accepted
Commit 9ba4bc87e6c02a7dfe710534c536d17684cc6c02
Headers show
Series [FFmpeg-devel,01/31] fftools/ffmpeg_dec: split Decoder into a private and public part | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Jan. 24, 2024, 8:16 a.m. UTC
Do not read it from InputStream directly.

This is a step towards decoupling Decoder and InputStream.
---
 fftools/ffmpeg.h       | 3 +++
 fftools/ffmpeg_dec.c   | 2 +-
 fftools/ffmpeg_demux.c | 6 +++++-
 3 files changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 5d6a538aa0..9add5cac85 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -287,6 +287,9 @@  enum DecoderFlags {
     // decoder should override timestamps by fixed framerate
     // from DecoderOpts.framerate
     DECODER_FLAG_FRAMERATE_FORCED = (1 << 2),
+#if FFMPEG_OPT_TOP
+    DECODER_FLAG_TOP_FIELD_FIRST  = (1 << 3),
+#endif
 };
 
 typedef struct DecoderOpts {
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 4a2ea83f97..e34b23b40c 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -318,7 +318,7 @@  static int video_frame_process(InputStream *ist, AVFrame *frame)
     DecoderPriv *dp = dp_from_dec(ist->decoder);
 
 #if FFMPEG_OPT_TOP
-    if(ist->top_field_first>=0) {
+    if (dp->flags & DECODER_FLAG_TOP_FIELD_FIRST) {
         av_log(dp, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n");
         frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
     }
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 4cced4a7f8..3c3be214c5 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -905,7 +905,11 @@  static int ist_use(InputStream *ist, int decoding_needed)
             return ret;
 
         ds->dec_opts.flags = (!!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION) |
-                             (!!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS) * DECODER_FLAG_TS_UNRELIABLE);
+                             (!!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS) * DECODER_FLAG_TS_UNRELIABLE)
+#if FFMPEG_OPT_TOP
+                             | ((ist->top_field_first >= 0) * DECODER_FLAG_TOP_FIELD_FIRST)
+#endif
+                             ;
 
         if (ist->framerate.num) {
             ds->dec_opts.flags     |= DECODER_FLAG_FRAMERATE_FORCED;