On 3/19/2024 12:01 PM, Andreas Rheinhardt wrote:
James Almer:
Signed-off-by: James Almer <jamr...@gmail.com>
---
  fftools/ffmpeg.h        |  3 +++
  fftools/ffmpeg_demux.c  |  4 ++++
  fftools/ffmpeg_filter.c | 28 +++++++++++++++++++++++++++-
  fftools/ffmpeg_opt.c    |  3 +++
  4 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7454089c2d..8d54affc0a 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -155,6 +155,7 @@ typedef struct OptionsContext {
      SpecifierOptList hwaccel_devices;
      SpecifierOptList hwaccel_output_formats;
      SpecifierOptList autorotate;
+    SpecifierOptList autoenhance;
/* output options */
      StreamMap *stream_maps;
@@ -239,6 +240,7 @@ enum IFilterFlags {
      IFILTER_FLAG_AUTOROTATE     = (1 << 0),
      IFILTER_FLAG_REINIT         = (1 << 1),
      IFILTER_FLAG_CFR            = (1 << 2),
+    IFILTER_FLAG_AUTOENHANCE    = (1 << 3),
  };
typedef struct InputFilterOptions {
@@ -369,6 +371,7 @@ typedef struct InputStream {
  #endif
int autorotate;
+    int                   autoenhance;
int fix_sub_duration; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 47312c9fe1..0b4ab3d7ec 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1056,6 +1056,7 @@ int ist_filter_add(InputStream *ist, InputFilter 
*ifilter, int is_simple,
          return AVERROR(ENOMEM);
opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ist->autorotate) |
+                   IFILTER_FLAG_AUTOENHANCE * !!(ist->autoenhance) |
                     IFILTER_FLAG_REINIT     * !!(ds->reinit_filters);
return ds->sch_idx_dec;
@@ -1238,6 +1239,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st)
      ist->autorotate = 1;
      MATCH_PER_STREAM_OPT(autorotate, i, ist->autorotate, ic, st);
+ ist->autoenhance = 1;
+    MATCH_PER_STREAM_OPT(autoenhance, i, ist->autoenhance, ic, st);
+
      MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
      if (codec_tag) {
          uint32_t tag = strtol(codec_tag, &next, 0);
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 3d88482d07..c4d900d95b 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -18,6 +18,8 @@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
   */
+#include "config_components.h"
+
  #include <stdint.h>
#include "ffmpeg.h"
@@ -145,6 +147,8 @@ typedef struct InputFilterPriv {
      int                 displaymatrix_present;
      int32_t             displaymatrix[9];
+ int enhancement_present;
+
      // fallback parameters to use when no input is ever sent
      struct {
          AVRational          time_base;
@@ -1567,6 +1571,15 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
      desc = av_pix_fmt_desc_get(ifp->format);
      av_assert0(desc);
+#if CONFIG_LCEVC_FILTER
+    if ((ifp->opts.flags & IFILTER_FLAG_AUTOENHANCE) &&
+        !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+        ret = insert_filter(&last_filter, &pad_idx, "lcevc", NULL);
+        if (ret < 0)
+            return ret;
+    }

If I see this correctly, this will add this filter automatically for all
videos when this filter is present, although it will be unneeded in the
vast majority of cases. I am against this.

Yeah, good catch. Missed a ifp->enhancement_present check here.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to