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

Submitted by Guo, Yejun on Dec. 12, 2018, 4:27 p.m.

Details

Message ID 1544632071-23069-1-git-send-email-yejun.guo@intel.com
State Superseded
Headers show

Commit Message

Guo, Yejun Dec. 12, 2018, 4:27 p.m.
This patchset contains two patches.
- the first patch finished the code and ask for upstreaming.
- the second patch (this patch) is just a quick example and
  not ask for upstreaming.

to verify it, 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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index f741419..6776ad9 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -437,6 +437,16 @@  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;
+    in->rois_buf = av_buffer_alloc(sizeof(AVFrameROI) * nb_rois);
+    AVFrameROI* rois = (AVFrameROI*)in->rois_buf->data;
+    rois[0].top = 0;
+    rois[0].left = 0;
+    rois[0].bottom = in->height;
+    rois[0].right = in->width/2;
+    rois[0].quality = AV_RQ_BEST;
+
     if (!scale->sws)
         return ff_filter_frame(outlink, in);