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

Submitted by Jun Zhao on July 13, 2019, 5:44 a.m.

Details

Message ID 1562996645-8212-2-git-send-email-mypopydev@gmail.com
State Accepted
Commit 7eec3d22fc5f8f93a14a58836c5ac9f7b243e992
Headers show

Commit Message

Jun Zhao July 13, 2019, 5:44 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 |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

Comments

Guo, Yejun July 13, 2019, 6:27 a.m.
> -----Original Message-----

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

> Jun Zhao

> Sent: Saturday, July 13, 2019 1:44 PM

> To: ffmpeg-devel@ffmpeg.org

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

> Subject: [FFmpeg-devel] [PATCH V1 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 |   25 +++++++++++++++++++++++++

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

> 

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

> index e41c330..f6f8f49 100644

> --- a/libavfilter/vf_showinfo.c

> +++ b/libavfilter/vf_showinfo.c

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

> AVFrameSideData *sd)

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

>  }

> 

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

> +{

> +    int nb_rois;

> +    const AVRegionOfInterest *roi;

> +    uint32_t roi_size;

> +

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

> +    roi_size = roi->self_size;

> +    if (!roi_size || sd->size % roi_size != 0) {

> +        av_log(ctx, AV_LOG_ERROR, "Invalid

> AVRegionOfInterest.self_size.\n");

> +        return;

> +    }

> +    nb_rois = sd->size / roi_size;

> +

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

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

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

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

> qp offset: %d/%d.\n",

> +               i, 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 +268,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);


looks good to me, thanks.

> --

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

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index e41c330..f6f8f49 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -111,6 +111,28 @@  static void dump_stereo3d(AVFilterContext *ctx, AVFrameSideData *sd)
         av_log(ctx, AV_LOG_INFO, " (inverted)");
 }
 
+static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+    int nb_rois;
+    const AVRegionOfInterest *roi;
+    uint32_t roi_size;
+
+    roi = (const AVRegionOfInterest *)sd->data;
+    roi_size = roi->self_size;
+    if (!roi_size || sd->size % roi_size != 0) {
+        av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n");
+        return;
+    }
+    nb_rois = sd->size / roi_size;
+
+    av_log(ctx, AV_LOG_INFO, "Regions Of Interest(RoI) information: ");
+    for (int i = 0; i < nb_rois; i++) {
+        roi = (const AVRegionOfInterest *)(sd->data + roi_size * i);
+        av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d, %d)/(%d, %d), qp offset: %d/%d.\n",
+               i, 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 +268,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);