[FFmpeg-devel,2/2] lavfi/showinfo: support regions of interest sidedata

Submitted by Jun Zhao on March 9, 2019, 8:33 a.m.

Details

Message ID 1552120413-10741-2-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao March 9, 2019, 8:33 a.m.
From: Jun Zhao <barryjzhao@tencent.com>

support regions of interest sidedata

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavfilter/vf_showinfo.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

Comments

Guo, Yejun March 9, 2019, 9:35 a.m.
> -----Original Message-----

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

> Of Jun Zhao

> Sent: Saturday, March 09, 2019 4:34 PM

> To: ffmpeg-devel@ffmpeg.org

> Cc: Jun Zhao <barryjzhao@tencent.com>

> Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/showinfo: support regions of

> interest sidedata

> 

> From: Jun Zhao <barryjzhao@tencent.com>

> 

> support regions of interest sidedata

> 

> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>

> ---

>  libavfilter/vf_showinfo.c |   23 +++++++++++++++++++++++

>  1 files changed, 23 insertions(+), 0 deletions(-)

> 

> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c

> index 9e84197..b51c1ae 100644

> --- a/libavfilter/vf_showinfo.c

> +++ b/libavfilter/vf_showinfo.c

> @@ -111,6 +111,26 @@ static void dump_stereo3d(AVFilterContext *ctx,

> AVFrameSideData *sd)

>          av_log(ctx, AV_LOG_INFO, " (inverted)");

>  }

> 

> +static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)

> +{

> +    AVRegionOfInterest *roi;

> +    int nb_rois;

> +

> +    if (sd->size < sizeof(*roi)) {

> +        av_log(ctx, AV_LOG_INFO, "invalid data");

> +        return;

> +    }


roi = (const AVRegionOfInterest *)sd->data;
if (roi->self_size == 0 || sd->size % roi->self_size != 0) {
    //report error and return.
}

> +

> +    roi = (AVRegionOfInterest *)sd->data;

> +    nb_rois = sd->size / sizeof(*roi);


nb_rois = sd->size / roi->self_size;

> +

> +    av_log(ctx, AV_LOG_INFO, "Regions Of Interest(RoI) informations: ");

> +    for (int index = 0; index < nb_rois; index++) {

> +        av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d %d)/(%d %d), qp

> offset: %d/%d",

> +               index, roi->left, roi->top, roi->right, roi->bottom, roi->qoffset.num,

> roi->qoffset.den);

> +    }

> +}

> +

>  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)

>  {

>      const char *color_range_str     = av_color_range_name(frame-

> >color_range);

> @@ -246,6 +266,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame

> *frame)

>          case AV_FRAME_DATA_AFD:

>              av_log(ctx, AV_LOG_INFO, "afd: value of %"PRIu8, sd->data[0]);

>              break;

> +        case AV_FRAME_DATA_REGIONS_OF_INTEREST:

> +            dump_roi(ctx, sd);

> +            break;

>          default:

>              av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d

> bytes)",

>                     sd->type, sd->size);

> --

> 1.7.1

> 

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Thomas Xu March 9, 2019, 3:44 p.m.
+    for (int index = 0; index < nb_rois; index++) {
+        av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d %d)/(%d %d), qp
offset: %d/%d",
+               index, roi->left, roi->top, roi->right, roi->bottom,
roi->qoffset.num, roi->qoffset.den);
+    }

pointer roi never ++, it always point to the first
AVRegionOfInterest structure.


On Sat, Mar 9, 2019 at 5:36 PM Guo, Yejun <yejun.guo@intel.com> wrote:

>
>
> > -----Original Message-----
> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf
> > Of Jun Zhao
> > Sent: Saturday, March 09, 2019 4:34 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Jun Zhao <barryjzhao@tencent.com>
> > Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/showinfo: support regions of
> > interest sidedata
> >
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > support regions of interest sidedata
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavfilter/vf_showinfo.c |   23 +++++++++++++++++++++++
> >  1 files changed, 23 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 9e84197..b51c1ae 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -111,6 +111,26 @@ static void dump_stereo3d(AVFilterContext *ctx,
> > AVFrameSideData *sd)
> >          av_log(ctx, AV_LOG_INFO, " (inverted)");
> >  }
> >
> > +static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)
> > +{
> > +    AVRegionOfInterest *roi;
> > +    int nb_rois;
> > +
> > +    if (sd->size < sizeof(*roi)) {
> > +        av_log(ctx, AV_LOG_INFO, "invalid data");
> > +        return;
> > +    }
>
> roi = (const AVRegionOfInterest *)sd->data;
> if (roi->self_size == 0 || sd->size % roi->self_size != 0) {
>     //report error and return.
> }
>
> > +
> > +    roi = (AVRegionOfInterest *)sd->data;
> > +    nb_rois = sd->size / sizeof(*roi);
>
> nb_rois = sd->size / roi->self_size;
>
> > +
> > +    av_log(ctx, AV_LOG_INFO, "Regions Of Interest(RoI) informations: ");
> > +    for (int index = 0; index < nb_rois; index++) {
> > +        av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d %d)/(%d %d), qp
> > offset: %d/%d",
> > +               index, roi->left, roi->top, roi->right, roi->bottom,
> roi->qoffset.num,
> > roi->qoffset.den);
> > +    }
> > +}
> > +
> >  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> >  {
> >      const char *color_range_str     = av_color_range_name(frame-
> > >color_range);
> > @@ -246,6 +266,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> > *frame)
> >          case AV_FRAME_DATA_AFD:
> >              av_log(ctx, AV_LOG_INFO, "afd: value of %"PRIu8,
> sd->data[0]);
> >              break;
> > +        case AV_FRAME_DATA_REGIONS_OF_INTEREST:
> > +            dump_roi(ctx, sd);
> > +            break;
> >          default:
> >              av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d
> > bytes)",
> >                     sd->type, sd->size);
> > --
> > 1.7.1
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
mypopy@gmail.com April 3, 2019, 1:42 a.m.
On Sat, Mar 9, 2019 at 11:44 PM Thomas Xu <oddstone@gmail.com> wrote:
>
> +    for (int index = 0; index < nb_rois; index++) {
> +        av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d %d)/(%d %d), qp
> offset: %d/%d",
> +               index, roi->left, roi->top, roi->right, roi->bottom,
> roi->qoffset.num, roi->qoffset.den);
> +    }
>
> pointer roi never ++, it always point to the first
> AVRegionOfInterest structure.

Thanks the catch, this issue have been solved in local repository,
will update other version after some dependencies merge,

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 9e84197..b51c1ae 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -111,6 +111,26 @@  static void dump_stereo3d(AVFilterContext *ctx, AVFrameSideData *sd)
         av_log(ctx, AV_LOG_INFO, " (inverted)");
 }
 
+static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+    AVRegionOfInterest *roi;
+    int nb_rois;
+
+    if (sd->size < sizeof(*roi)) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
+
+    roi = (AVRegionOfInterest *)sd->data;
+    nb_rois = sd->size / sizeof(*roi);
+
+    av_log(ctx, AV_LOG_INFO, "Regions Of Interest(RoI) informations: ");
+    for (int index = 0; index < nb_rois; index++) {
+        av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d %d)/(%d %d), qp offset: %d/%d",
+               index, roi->left, roi->top, roi->right, roi->bottom, roi->qoffset.num, roi->qoffset.den);
+    }
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
     const char *color_range_str     = av_color_range_name(frame->color_range);
@@ -246,6 +266,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         case AV_FRAME_DATA_AFD:
             av_log(ctx, AV_LOG_INFO, "afd: value of %"PRIu8, sd->data[0]);
             break;
+        case AV_FRAME_DATA_REGIONS_OF_INTEREST:
+            dump_roi(ctx, sd);
+            break;
         default:
             av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
                    sd->type, sd->size);