[FFmpeg-devel] libavcodec/libx264 and libx265: add a flag to output ROI warnings only once.

Submitted by Guo, Yejun on Sept. 2, 2019, 4:37 a.m.

Details

Message ID 1567399056-8185-1-git-send-email-yejun.guo@intel.com
State New
Headers show

Commit Message

Guo, Yejun Sept. 2, 2019, 4:37 a.m.
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
---
 libavcodec/libx264.c | 14 ++++++++++++--
 libavcodec/libx265.c |  9 ++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

Comments

Guo, Yejun Sept. 11, 2019, 12:54 a.m.
> -----Original Message-----
> From: Guo, Yejun
> Sent: Monday, September 02, 2019 12:38 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun <yejun.guo@intel.com>
> Subject: [PATCH] libavcodec/libx264 and libx265: add a flag to output ROI
> warnings only once.
> 
> Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
> ---
>  libavcodec/libx264.c | 14 ++++++++++++--
>  libavcodec/libx265.c |  9 ++++++++-
>  2 files changed, 20 insertions(+), 3 deletions(-)

this patch ask for review, thanks.

> 
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 86e3530..62316e6 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -99,6 +99,10 @@ typedef struct X264Context {
> 
>      int nb_reordered_opaque, next_reordered_opaque;
>      int64_t *reordered_opaque;
> +
> +    // If the encoder does not support ROI then warn the first time we
> +    // encounter a frame with ROI side data.
> +    int roi_warned;
>  } X264Context;
> 
>  static void X264_log(void *p, int level, const char *fmt, va_list args)
> @@ -356,7 +360,10 @@ static int X264_frame(AVCodecContext *ctx,
> AVPacket *pkt, const AVFrame *frame,
>          sd = av_frame_get_side_data(frame,
> AV_FRAME_DATA_REGIONS_OF_INTEREST);
>          if (sd) {
>              if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
> -                av_log(ctx, AV_LOG_WARNING, "Adaptive quantization
> must be enabled to use ROI encoding, skipping ROI.\n");
> +                if (!x4->roi_warned) {
> +                    x4->roi_warned = 1;
> +                    av_log(ctx, AV_LOG_WARNING, "Adaptive
> quantization must be enabled to use ROI encoding, skipping ROI.\n");
> +                }
>              } else {
>                  if (frame->interlaced_frame == 0) {
>                      int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
> @@ -410,7 +417,10 @@ static int X264_frame(AVCodecContext *ctx,
> AVPacket *pkt, const AVFrame *frame,
>                      x4->pic.prop.quant_offsets = qoffsets;
>                      x4->pic.prop.quant_offsets_free = av_free;
>                  } else {
> -                    av_log(ctx, AV_LOG_WARNING, "interlaced_frame
> not supported for ROI encoding yet, skipping ROI.\n");
> +                    if (!x4->roi_warned) {
> +                        x4->roi_warned = 1;
> +                        av_log(ctx, AV_LOG_WARNING,
> "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
> +                    }
>                  }
>              }
>          }
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index 665b780..15fc4e7 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -47,6 +47,10 @@ typedef struct libx265Context {
>      char *tune;
>      char *profile;
>      char *x265_opts;
> +
> +    // If the encoder does not support ROI then warn the first time we
> +    // encounter a frame with ROI side data.
> +    int roi_warned;
>  } libx265Context;
> 
>  static int is_keyframe(NalUnitType naltype)
> @@ -310,7 +314,10 @@ static av_cold int
> libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
>      AVFrameSideData *sd = av_frame_get_side_data(frame,
> AV_FRAME_DATA_REGIONS_OF_INTEREST);
>      if (sd) {
>          if (ctx->params->rc.aqMode == X265_AQ_NONE) {
> -            av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must
> be enabled to use ROI encoding, skipping ROI.\n");
> +            if (!ctx->roi_warned) {
> +                ctx->roi_warned = 1;
> +                av_log(ctx, AV_LOG_WARNING, "Adaptive quantization
> must be enabled to use ROI encoding, skipping ROI.\n");
> +            }
>          } else {
>              /* 8x8 block when qg-size is 8, 16*16 block otherwise. */
>              int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;
> --
> 2.7.4
Guo, Yejun Sept. 18, 2019, 2:50 p.m.
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of

> Guo, Yejun

> Sent: Wednesday, September 11, 2019 8:55 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/libx264 and libx265: add a flag

> to output ROI warnings only once.

> 

> 

> 

> > -----Original Message-----

> > From: Guo, Yejun

> > Sent: Monday, September 02, 2019 12:38 PM

> > To: ffmpeg-devel@ffmpeg.org

> > Cc: Guo, Yejun <yejun.guo@intel.com>

> > Subject: [PATCH] libavcodec/libx264 and libx265: add a flag to output ROI

> > warnings only once.

> >

> > Signed-off-by: Guo, Yejun <yejun.guo@intel.com>

> > ---

> >  libavcodec/libx264.c | 14 ++++++++++++--

> >  libavcodec/libx265.c |  9 ++++++++-

> >  2 files changed, 20 insertions(+), 3 deletions(-)

> 

> this patch ask for review, thanks.


ping for review, thanks.

> 

> >

> > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c

> > index 86e3530..62316e6 100644

> > --- a/libavcodec/libx264.c

> > +++ b/libavcodec/libx264.c

> > @@ -99,6 +99,10 @@ typedef struct X264Context {

> >

> >      int nb_reordered_opaque, next_reordered_opaque;

> >      int64_t *reordered_opaque;

> > +

> > +    // If the encoder does not support ROI then warn the first time we

> > +    // encounter a frame with ROI side data.

> > +    int roi_warned;

> >  } X264Context;

> >

> >  static void X264_log(void *p, int level, const char *fmt, va_list args)

> > @@ -356,7 +360,10 @@ static int X264_frame(AVCodecContext *ctx,

> > AVPacket *pkt, const AVFrame *frame,

> >          sd = av_frame_get_side_data(frame,

> > AV_FRAME_DATA_REGIONS_OF_INTEREST);

> >          if (sd) {

> >              if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {

> > -                av_log(ctx, AV_LOG_WARNING, "Adaptive quantization

> > must be enabled to use ROI encoding, skipping ROI.\n");

> > +                if (!x4->roi_warned) {

> > +                    x4->roi_warned = 1;

> > +                    av_log(ctx, AV_LOG_WARNING, "Adaptive

> > quantization must be enabled to use ROI encoding, skipping ROI.\n");

> > +                }

> >              } else {

> >                  if (frame->interlaced_frame == 0) {

> >                      int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;

> > @@ -410,7 +417,10 @@ static int X264_frame(AVCodecContext *ctx,

> > AVPacket *pkt, const AVFrame *frame,

> >                      x4->pic.prop.quant_offsets = qoffsets;

> >                      x4->pic.prop.quant_offsets_free = av_free;

> >                  } else {

> > -                    av_log(ctx, AV_LOG_WARNING, "interlaced_frame

> > not supported for ROI encoding yet, skipping ROI.\n");

> > +                    if (!x4->roi_warned) {

> > +                        x4->roi_warned = 1;

> > +                        av_log(ctx, AV_LOG_WARNING,

> > "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");

> > +                    }

> >                  }

> >              }

> >          }

> > diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c

> > index 665b780..15fc4e7 100644

> > --- a/libavcodec/libx265.c

> > +++ b/libavcodec/libx265.c

> > @@ -47,6 +47,10 @@ typedef struct libx265Context {

> >      char *tune;

> >      char *profile;

> >      char *x265_opts;

> > +

> > +    // If the encoder does not support ROI then warn the first time we

> > +    // encounter a frame with ROI side data.

> > +    int roi_warned;

> >  } libx265Context;

> >

> >  static int is_keyframe(NalUnitType naltype)

> > @@ -310,7 +314,10 @@ static av_cold int

> > libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr

> >      AVFrameSideData *sd = av_frame_get_side_data(frame,

> > AV_FRAME_DATA_REGIONS_OF_INTEREST);

> >      if (sd) {

> >          if (ctx->params->rc.aqMode == X265_AQ_NONE) {

> > -            av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must

> > be enabled to use ROI encoding, skipping ROI.\n");

> > +            if (!ctx->roi_warned) {

> > +                ctx->roi_warned = 1;

> > +                av_log(ctx, AV_LOG_WARNING, "Adaptive quantization

> > must be enabled to use ROI encoding, skipping ROI.\n");

> > +            }

> >          } else {

> >              /* 8x8 block when qg-size is 8, 16*16 block otherwise. */

> >              int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;

> > --

> > 2.7.4

> 

> _______________________________________________

> 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".

Patch hide | download patch | download mbox

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 86e3530..62316e6 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -99,6 +99,10 @@  typedef struct X264Context {
 
     int nb_reordered_opaque, next_reordered_opaque;
     int64_t *reordered_opaque;
+
+    // If the encoder does not support ROI then warn the first time we
+    // encounter a frame with ROI side data.
+    int roi_warned;
 } X264Context;
 
 static void X264_log(void *p, int level, const char *fmt, va_list args)
@@ -356,7 +360,10 @@  static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
         sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST);
         if (sd) {
             if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
-                av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+                if (!x4->roi_warned) {
+                    x4->roi_warned = 1;
+                    av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+                }
             } else {
                 if (frame->interlaced_frame == 0) {
                     int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
@@ -410,7 +417,10 @@  static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
                     x4->pic.prop.quant_offsets = qoffsets;
                     x4->pic.prop.quant_offsets_free = av_free;
                 } else {
-                    av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
+                    if (!x4->roi_warned) {
+                        x4->roi_warned = 1;
+                        av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
+                    }
                 }
             }
         }
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 665b780..15fc4e7 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -47,6 +47,10 @@  typedef struct libx265Context {
     char *tune;
     char *profile;
     char *x265_opts;
+
+    // If the encoder does not support ROI then warn the first time we
+    // encounter a frame with ROI side data.
+    int roi_warned;
 } libx265Context;
 
 static int is_keyframe(NalUnitType naltype)
@@ -310,7 +314,10 @@  static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
     AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST);
     if (sd) {
         if (ctx->params->rc.aqMode == X265_AQ_NONE) {
-            av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+            if (!ctx->roi_warned) {
+                ctx->roi_warned = 1;
+                av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+            }
         } else {
             /* 8x8 block when qg-size is 8, 16*16 block otherwise. */
             int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;