[FFmpeg-devel,V3,3/3] add an example to show how to fill the ROI info

Submitted by Guo, Yejun on Dec. 27, 2018, 11:06 a.m.

Details

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

Commit Message

Guo, Yejun Dec. 27, 2018, 11:06 a.m.
This patch is just a quick example to show how to fill the ROI info,
it does not ask for upstreaming, just for your reference.

to verify the ROI feature with this example, the command line looks like:
./ffmpeg -i .../path_to_1920x1080_video_file -vf scale=1920:1080 -c:v libx264 -b:v 2000k -y tmp.264

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
---
 libavfilter/vf_scale.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Derek Buitenhuis Dec. 27, 2018, 4:46 p.m.
On 27/12/2018 11:06, Guo, Yejun wrote:
> This patch is just a quick example to show how to fill the ROI info,
> it does not ask for upstreaming, just for your reference.
> 
> to verify the ROI feature with this example, the command line looks like:
> ./ffmpeg -i .../path_to_1920x1080_video_file -vf scale=1920:1080 -c:v libx264 -b:v 2000k -y tmp.264
> 
> Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
> ---
>  libavfilter/vf_scale.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

I understand the patch is an example for the benefit of the
people reading the list, but obviously can't be pushed.

Is it useful to add an example to any of the existing *example*.c files
we ship with the source?

- Derek
Guo, Yejun Dec. 28, 2018, 2:11 a.m.
> -----Original Message-----

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

> Of Derek Buitenhuis

> Sent: Friday, December 28, 2018 12:47 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH V3 3/3] add an example to show how to

> fill the ROI info

> 

> On 27/12/2018 11:06, Guo, Yejun wrote:

> > This patch is just a quick example to show how to fill the ROI info,

> > it does not ask for upstreaming, just for your reference.

> >

> > to verify the ROI feature with this example, the command line looks like:

> > ./ffmpeg -i .../path_to_1920x1080_video_file -vf scale=1920:1080 -c:v

> > libx264 -b:v 2000k -y tmp.264

> >

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

> > ---

> >  libavfilter/vf_scale.c | 14 ++++++++++++++

> >  1 file changed, 14 insertions(+)

> 

> I understand the patch is an example for the benefit of the people reading

> the list, but obviously can't be pushed.


yes, this patch is not ask for upstreaming/pushing.

> 

> Is it useful to add an example to any of the existing *example*.c files we ship

> with the source?


good point, I'll add into doc/examples/encode_video.c. 
Just to make things step by step, I'll send this in another patch (separated with the two basic patches), maybe tomorrow or next week.

> 

> - Derek

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index f741419..561391c 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -437,6 +437,20 @@  static int filter_frame(AVFilterLink *link, AVFrame *in)
             return ret;
     }
 
+    // just to show how a filter fills the ROI info
+    size_t nb_rois = 1;
+    AVFrameSideData *sd = av_frame_new_side_data(in, AV_FRAME_DATA_ROIS, nb_rois * sizeof(AVROI));
+    if (!sd) {
+        av_frame_free(&in);
+        return AVERROR(ENOMEM);
+    }
+    AVROI* rois = (AVROI*)sd->data;
+    rois[0].top = 0;
+    rois[0].left = 0;
+    rois[0].bottom = in->height;
+    rois[0].right = in->width/2;
+    rois[0].qoffset = -15;
+
     if (!scale->sws)
         return ff_filter_frame(outlink, in);