Is there a way to crop in VAAPI?

Nicolas Dufresne nicolas at ndufresne.ca
Wed Aug 7 01:31:28 UTC 2019


Le mardi 06 août 2019 à 14:31 +0800, Yan Wang a écrit :
> 
> On 8/5/2019 9:29 PM, Nicolas Dufresne-5 [via GStreamer-devel] wrote:
> > 
> > Le lun. 5 août 2019 02 h 55, Yan Wang <[hidden email]> a écrit :
> > > 
> > > On 8/3/2019 9:25 PM, Nicolas Dufresne-5 [via GStreamer-devel] wrote:
> > > > Le vendredi 02 août 2019 à 20:45 -0500, kmliu a écrit :
> > > > 
> > > > > I need to decode H.264 video via VAAPI and then extract the decoded frames to 
> > > > > main memory. Since I intend to crop the frames anyway, I'd like to crop them 
> > > > > while they're still in graphics memory, to reduce memory bandwidth 
> > > > > consumption. So conceptually, I want to do this: 
> > > > > 
> > > > > gst-launch-1.0 rtspsrc location=rtsp_uri ! rtph264depay ! vaapih264dec ! 
> > > > > videocrop left=x right=x top=x bottom=x ! filesink location=video.yuv 
> > > > > 
> > > > > But I think this will end up copying the whole frames to main memory before 
> > > > > cropping it there. It would be nice if vaapipostproc supports cropping?
> > > > 
> > > > Another (simplier) option is to use gltransformation, but apparently 
> > > > not all distro ship this plugin. 
> > > 
> > > May I add the crop option for vaapih264dec? 
> > > 
> > > It may be more direct.
> > > 
> > > 
> > 
> > Sounds wrong to me, and I doubt you'll find an API to support that. If there is one element in VAAPI that may have an API for this it would be vaapipostproc.
> 
> Yes. I know vaapipostproc can do this. 
> 
> IMHO, this could be done in decode context too if VAConfigAttribDecProcessing can support it.
> 
> https://github.com/intel/libva/blob/master/va/va.h#L520
> 
> Currently It can do scaling (1/8 ~ 8x at most, CSC). Cropping can be the special case of scaling.
> 
> If vaapih264dec provides the interface, it can reduce the overhead and power because it is fixed function. And no need vaapipostproc context.
> 
> But it may make vaapih264dec more complex and cannot support multiply pipelines of decoding. So it is just one possible option.

If you know how it works, just give it a try. You can find similar code
in -good/sys/gstv4l2videodec.c, but only for the CSC bit. Scaling is
more complex though, because of the pixel aspect ratio handling. It's
this a proper scaler or just multiple of 2 ?

> 
> Thanks.
> 
> Yan Wang
> 
> > 
> > > Thanks.
> > > 
> > > Yan Wang
> > > 
> > > 
> > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > -- 
> > > > > Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> > > > > _______________________________________________ 
> > > > > gstreamer-devel mailing list 
> > > > > [hidden email] 
> > > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > > > 
> > > > _______________________________________________ 
> > > > gstreamer-devel mailing list 
> > > > [hidden email] 
> > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel 
> > > > 
> > > > If you reply to this email, your message will be added to the discussion below:
> > > > http://gstreamer-devel.966125.n4.nabble.com/Is-there-a-way-to-crop-in-VAAPI-tp4691566p4691569.html
> > > > To start a new topic under GStreamer-devel, email [hidden email] 
> > > > To unsubscribe from GStreamer-devel, click here.
> > > > NAML
> > > 
> > > _______________________________________________
> > > gstreamer-devel mailing list
> > > [hidden email]
> > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > 
> > _______________________________________________ 
> > gstreamer-devel mailing list 
> > [hidden email] 
> > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel 
> > 
> > If you reply to this email, your message will be added to the discussion below:
> > http://gstreamer-devel.966125.n4.nabble.com/Is-there-a-way-to-crop-in-VAAPI-tp4691566p4691583.html
> > To start a new topic under GStreamer-devel, email ml+s966125n966125h86 at n4.nabble.com 
> > To unsubscribe from GStreamer-devel, click here.
> > NAML
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list