Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: auto insert enhancement filters when available
Date: Tue, 19 Mar 2024 16:01:17 +0100
Message-ID: <AS8P250MB07446045CCD06BB1EF5CA6518F2C2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240319140636.4323-3-jamrial@gmail.com>

James Almer:
> Signed-off-by: James Almer <jamrial@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.

> +#endif
> +
>      // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
>      if ((ifp->opts.flags & IFILTER_FLAG_AUTOROTATE) &&
>          !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
> @@ -1883,6 +1896,10 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
>          memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix));
>      ifp->displaymatrix_present = !!sd;
>  
> +#if CONFIG_LCEVC_FILTER
> +    ifp->enhancement_present = !!(av_frame_get_side_data(frame, AV_FRAME_DATA_LCEVC));
> +#endif
> +
>      return 0;
>  }
>  
> @@ -2584,7 +2601,8 @@ enum ReinitReason {
>      VIDEO_CHANGED   = (1 << 0),
>      AUDIO_CHANGED   = (1 << 1),
>      MATRIX_CHANGED  = (1 << 2),
> -    HWACCEL_CHANGED = (1 << 3)
> +    HWACCEL_CHANGED = (1 << 3),
> +    ENHANCEMENT_CHANGED = (1 << 4),
>  };
>  
>  static const char *unknown_if_null(const char *str)
> @@ -2625,6 +2643,12 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
>      } else if (ifp->displaymatrix_present)
>          need_reinit |= MATRIX_CHANGED;
>  
> +#if CONFIG_LCEVC_FILTER
> +    if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_LCEVC))
> +        if (!ifp->enhancement_present)
> +            need_reinit |= ENHANCEMENT_CHANGED;
> +#endif
> +
>      if (!(ifp->opts.flags & IFILTER_FLAG_REINIT) && fgt->graph)
>          need_reinit = 0;
>  
> @@ -2681,6 +2705,8 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
>                  av_bprintf(&reason, "display matrix changed, ");
>              if (need_reinit & HWACCEL_CHANGED)
>                  av_bprintf(&reason, "hwaccel changed, ");
> +            if (need_reinit & ENHANCEMENT_CHANGED)
> +                av_bprintf(&reason, "enhancement data found, ");
>              if (reason.len > 1)
>                  reason.str[reason.len - 2] = '\0'; // remove last comma
>              av_log(fg, AV_LOG_INFO, "Reconfiguring filter graph%s%s\n", reason.len ? " because " : "", reason.str);
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 4b3f9789ba..b87782806e 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -1738,6 +1738,9 @@ const OptionDef options[] = {
>      { "autorotate",                 OPT_TYPE_BOOL,   OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
>          { .off = OFFSET(autorotate) },
>          "automatically insert correct rotate filters" },
> +    { "autoenhance",                OPT_TYPE_BOOL,   OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
> +        { .off = OFFSET(autoenhance) },
> +        "automatically insert enhancement filters (LCEVC)" },
>      { "autoscale",                  OPT_TYPE_BOOL,   OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
>          { .off = OFFSET(autoscale) },
>          "automatically insert a scale filter at the end of the filter graph" },

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  reply	other threads:[~2024-03-19 15:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 14:06 [FFmpeg-devel] [PATCH 1/3] libavcodec/h2645_sei: export raw LCEVC metadata James Almer
2024-03-19 14:06 ` [FFmpeg-devel] [PATCH 2/3] avfilter: add an LCEVC decoding filter James Almer
2024-03-19 14:56   ` Andreas Rheinhardt
2024-03-19 15:05     ` James Almer
2024-03-19 15:20       ` Kieran Kunhya
2024-03-19 15:28         ` James Almer
2024-03-19 17:21           ` Kieran Kunhya
     [not found]             ` <BB9E2F8E-6821-43B7-9021-C264A8AFCE35@cosmin.at>
2024-03-19 19:07               ` Cosmin Stejerean via ffmpeg-devel
2024-03-19 15:00   ` Stefano Sabatini
2024-03-19 14:06 ` [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: auto insert enhancement filters when available James Almer
2024-03-19 15:01   ` Andreas Rheinhardt [this message]
2024-03-19 15:08     ` James Almer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB07446045CCD06BB1EF5CA6518F2C2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git