diff mbox series

[FFmpeg-devel,2/2] qsvdec_av1: add an option to disable film grain

Message ID 20201126053001.4164257-2-haihao.xiang@intel.com
State New
Headers show
Series [FFmpeg-devel,1/2] qsvdec: factor common options out | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Xiang, Haihao Nov. 26, 2020, 5:30 a.m. UTC
User may use '-disable_film_grain 1' to disable film grain.
---
 libavcodec/qsvdec.c       |  5 +++++
 libavcodec/qsvdec.h       |  2 ++
 libavcodec/qsvdec_other.c | 13 ++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

Comments

Guangxin Xu Nov. 26, 2020, 10:19 a.m. UTC | #1
Hi Haihao,
Hold on a moment, Let me send another related refact patch set. :)

On Thu, Nov 26, 2020 at 1:30 PM Haihao Xiang <haihao.xiang@intel.com> wrote:

> User may use '-disable_film_grain 1' to disable film grain.
> ---
>  libavcodec/qsvdec.c       |  5 +++++
>  libavcodec/qsvdec.h       |  2 ++
>  libavcodec/qsvdec_other.c | 13 ++++++++++++-
>  3 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index c666aaeb52..f34487bdbb 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -290,6 +290,11 @@ static int qsv_decode_header(AVCodecContext *avctx,
> QSVContext *q, AVPacket *avp
>          return ff_qsv_print_error(avctx, ret,
>                  "Error decoding stream header");
>
> +#if CONFIG_AV1_QSV_DECODER
> +    if (avctx->codec_id == AV_CODEC_ID_AV1)
> +        param->mfx.FilmGrain = q->disable_film_grain ? 0 :
> param->mfx.FilmGrain;
> +#endif
> +
>      return 0;
>  }
>
> diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
> index 10e8cf7f91..b5914834d9 100644
> --- a/libavcodec/qsvdec.h
> +++ b/libavcodec/qsvdec.h
> @@ -85,6 +85,8 @@ typedef struct QSVContext {
>
>      mfxExtBuffer **ext_buffers;
>      int         nb_ext_buffers;
> +
> +    int disable_film_grain;
>  } QSVContext;
>
>  extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[];
> diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> index 65cefff2ab..ac1e2ea84a 100644
> --- a/libavcodec/qsvdec_other.c
> +++ b/libavcodec/qsvdec_other.c
> @@ -325,10 +325,21 @@ AVCodec ff_vp9_qsv_decoder = {
>  #endif
>
>  #if CONFIG_AV1_QSV_DECODER
> +static const AVOption av1_options[] = {
> +    QSVDEC_COMMON_OPTIONS,
> +
> +    { "disable_film_grain",
> +      "Disable the film grain synthesis",
> +      OFFSET(qsv.disable_film_grain), AV_OPT_TYPE_BOOL,
> +      { .i64 = 0}, 0, 1, VD},
> +
> +    { NULL },
> +};
> +
>  static const AVClass av1_qsv_class = {
>      .class_name = "av1_qsv",
>      .item_name  = av_default_item_name,
> -    .option     = options,
> +    .option     = av1_options,
>      .version    = LIBAVUTIL_VERSION_INT,
>  };
>
> --
> 2.25.1
>
> _______________________________________________
> 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".
James Almer Nov. 26, 2020, 1:17 p.m. UTC | #2
On 11/26/2020 2:30 AM, Haihao Xiang wrote:
> User may use '-disable_film_grain 1' to disable film grain.

A side data type was recently pushed that lets the user choose to export 
film grain parameters as frame side data instead of having the decoder 
apply them. Can you implement it here? Does QSV give you such values in 
order to export them?

> ---
>   libavcodec/qsvdec.c       |  5 +++++
>   libavcodec/qsvdec.h       |  2 ++
>   libavcodec/qsvdec_other.c | 13 ++++++++++++-
>   3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index c666aaeb52..f34487bdbb 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -290,6 +290,11 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, AVPacket *avp
>           return ff_qsv_print_error(avctx, ret,
>                   "Error decoding stream header");
>   
> +#if CONFIG_AV1_QSV_DECODER
> +    if (avctx->codec_id == AV_CODEC_ID_AV1)
> +        param->mfx.FilmGrain = q->disable_film_grain ? 0 : param->mfx.FilmGrain;
> +#endif
> +
>       return 0;
>   }
>   
> diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
> index 10e8cf7f91..b5914834d9 100644
> --- a/libavcodec/qsvdec.h
> +++ b/libavcodec/qsvdec.h
> @@ -85,6 +85,8 @@ typedef struct QSVContext {
>   
>       mfxExtBuffer **ext_buffers;
>       int         nb_ext_buffers;
> +
> +    int disable_film_grain;
>   } QSVContext;
>   
>   extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[];
> diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> index 65cefff2ab..ac1e2ea84a 100644
> --- a/libavcodec/qsvdec_other.c
> +++ b/libavcodec/qsvdec_other.c
> @@ -325,10 +325,21 @@ AVCodec ff_vp9_qsv_decoder = {
>   #endif
>   
>   #if CONFIG_AV1_QSV_DECODER
> +static const AVOption av1_options[] = {
> +    QSVDEC_COMMON_OPTIONS,
> +
> +    { "disable_film_grain",
> +      "Disable the film grain synthesis",
> +      OFFSET(qsv.disable_film_grain), AV_OPT_TYPE_BOOL,
> +      { .i64 = 0}, 0, 1, VD},
> +
> +    { NULL },
> +};
> +
>   static const AVClass av1_qsv_class = {
>       .class_name = "av1_qsv",
>       .item_name  = av_default_item_name,
> -    .option     = options,
> +    .option     = av1_options,
>       .version    = LIBAVUTIL_VERSION_INT,
>   };
>   
>
Xiang, Haihao Nov. 27, 2020, 12:47 a.m. UTC | #3
On Thu, 2020-11-26 at 10:17 -0300, James Almer wrote:
> On 11/26/2020 2:30 AM, Haihao Xiang wrote:
> > User may use '-disable_film_grain 1' to disable film grain.
> 
> A side data type was recently pushed that lets the user choose to export 
> film grain parameters as frame side data instead of having the decoder 
> apply them. Can you implement it here? Does QSV give you such values in 
> order to export them?

Thanks for the comment, I will check QSV to make sure whether we can get such
values from QSV. 

Regards
Haihao

> 
> > ---
> >   libavcodec/qsvdec.c       |  5 +++++
> >   libavcodec/qsvdec.h       |  2 ++
> >   libavcodec/qsvdec_other.c | 13 ++++++++++++-
> >   3 files changed, 19 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index c666aaeb52..f34487bdbb 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -290,6 +290,11 @@ static int qsv_decode_header(AVCodecContext *avctx,
> > QSVContext *q, AVPacket *avp
> >           return ff_qsv_print_error(avctx, ret,
> >                   "Error decoding stream header");
> >   
> > +#if CONFIG_AV1_QSV_DECODER
> > +    if (avctx->codec_id == AV_CODEC_ID_AV1)
> > +        param->mfx.FilmGrain = q->disable_film_grain ? 0 : param-
> > >mfx.FilmGrain;
> > +#endif
> > +
> >       return 0;
> >   }
> >   
> > diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
> > index 10e8cf7f91..b5914834d9 100644
> > --- a/libavcodec/qsvdec.h
> > +++ b/libavcodec/qsvdec.h
> > @@ -85,6 +85,8 @@ typedef struct QSVContext {
> >   
> >       mfxExtBuffer **ext_buffers;
> >       int         nb_ext_buffers;
> > +
> > +    int disable_film_grain;
> >   } QSVContext;
> >   
> >   extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[];
> > diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> > index 65cefff2ab..ac1e2ea84a 100644
> > --- a/libavcodec/qsvdec_other.c
> > +++ b/libavcodec/qsvdec_other.c
> > @@ -325,10 +325,21 @@ AVCodec ff_vp9_qsv_decoder = {
> >   #endif
> >   
> >   #if CONFIG_AV1_QSV_DECODER
> > +static const AVOption av1_options[] = {
> > +    QSVDEC_COMMON_OPTIONS,
> > +
> > +    { "disable_film_grain",
> > +      "Disable the film grain synthesis",
> > +      OFFSET(qsv.disable_film_grain), AV_OPT_TYPE_BOOL,
> > +      { .i64 = 0}, 0, 1, VD},
> > +
> > +    { NULL },
> > +};
> > +
> >   static const AVClass av1_qsv_class = {
> >       .class_name = "av1_qsv",
> >       .item_name  = av_default_item_name,
> > -    .option     = options,
> > +    .option     = av1_options,
> >       .version    = LIBAVUTIL_VERSION_INT,
> >   };
> >   
> > 
> 
> _______________________________________________
> 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".
Xiang, Haihao Nov. 27, 2020, 3:10 a.m. UTC | #4
Sure, I will update my patch against your patchset.

Thanks
Haihao


Hi Haihao,
Hold on a moment, Let me send another related refact patch set. :)

On Thu, Nov 26, 2020 at 1:30 PM Haihao Xiang <haihao.xiang@intel.com<mailto:haihao.xiang@intel.com>> wrote:
User may use '-disable_film_grain 1' to disable film grain.
---
 libavcodec/qsvdec.c       |  5 +++++
 libavcodec/qsvdec.h       |  2 ++
 libavcodec/qsvdec_other.c | 13 ++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index c666aaeb52..f34487bdbb 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -290,6 +290,11 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, AVPacket *avp
         return ff_qsv_print_error(avctx, ret,
                 "Error decoding stream header");

+#if CONFIG_AV1_QSV_DECODER
+    if (avctx->codec_id == AV_CODEC_ID_AV1)
+        param->mfx.FilmGrain = q->disable_film_grain ? 0 : param->mfx.FilmGrain;
+#endif
+
     return 0;
 }

diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index 10e8cf7f91..b5914834d9 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -85,6 +85,8 @@ typedef struct QSVContext {

     mfxExtBuffer **ext_buffers;
     int         nb_ext_buffers;
+
+    int disable_film_grain;
 } QSVContext;

 extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[];
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 65cefff2ab..ac1e2ea84a 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -325,10 +325,21 @@ AVCodec ff_vp9_qsv_decoder = {
 #endif

 #if CONFIG_AV1_QSV_DECODER
+static const AVOption av1_options[] = {
+    QSVDEC_COMMON_OPTIONS,
+
+    { "disable_film_grain",
+      "Disable the film grain synthesis",
+      OFFSET(qsv.disable_film_grain), AV_OPT_TYPE_BOOL,
+      { .i64 = 0}, 0, 1, VD},
+
+    { NULL },
+};
+
 static const AVClass av1_qsv_class = {
     .class_name = "av1_qsv",
     .item_name  = av_default_item_name,
-    .option     = options,
+    .option     = av1_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
diff mbox series

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index c666aaeb52..f34487bdbb 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -290,6 +290,11 @@  static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, AVPacket *avp
         return ff_qsv_print_error(avctx, ret,
                 "Error decoding stream header");
 
+#if CONFIG_AV1_QSV_DECODER
+    if (avctx->codec_id == AV_CODEC_ID_AV1)
+        param->mfx.FilmGrain = q->disable_film_grain ? 0 : param->mfx.FilmGrain;
+#endif
+
     return 0;
 }
 
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index 10e8cf7f91..b5914834d9 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -85,6 +85,8 @@  typedef struct QSVContext {
 
     mfxExtBuffer **ext_buffers;
     int         nb_ext_buffers;
+
+    int disable_film_grain;
 } QSVContext;
 
 extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[];
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 65cefff2ab..ac1e2ea84a 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -325,10 +325,21 @@  AVCodec ff_vp9_qsv_decoder = {
 #endif
 
 #if CONFIG_AV1_QSV_DECODER
+static const AVOption av1_options[] = {
+    QSVDEC_COMMON_OPTIONS,
+
+    { "disable_film_grain",
+      "Disable the film grain synthesis",
+      OFFSET(qsv.disable_film_grain), AV_OPT_TYPE_BOOL,
+      { .i64 = 0}, 0, 1, VD},
+
+    { NULL },
+};
+
 static const AVClass av1_qsv_class = {
     .class_name = "av1_qsv",
     .item_name  = av_default_item_name,
-    .option     = options,
+    .option     = av1_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };