v4l2videoenc: Setup crop rectangle if needed

Hantro H1 and Rockchip VEPU2 drivers will pad the width/height to a
multiple of 16. In order to obtain the right JPEG size, the image needs
to be cropped using the S_SELECTION API. This support is added as best
effort since older drivers may emulate this by looking at the capture
queue width/height.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2329>
This commit is contained in:
Nicolas Dufresne 2022-04-28 09:19:57 -04:00 committed by GStreamer Marge Bot
parent 13fbcde1e7
commit 522f19e013
2 changed files with 6 additions and 2 deletions

View file

@ -3194,7 +3194,6 @@ gst_v4l2_object_reset_compose_region (GstV4l2Object * obj)
struct v4l2_selection sel = { 0 };
GST_V4L2_CHECK_OPEN (obj);
GST_V4L2_CHECK_NOT_ACTIVE (obj);
sel.type = obj->type;
sel.target = V4L2_SEL_TGT_COMPOSE_DEFAULT;
@ -4357,7 +4356,6 @@ gst_v4l2_object_set_crop (GstV4l2Object * obj, struct v4l2_rect * crop_rect)
struct v4l2_crop crop = { 0 };
GST_V4L2_CHECK_OPEN (obj);
GST_V4L2_CHECK_NOT_ACTIVE (obj);
sel.type = obj->type;
sel.target = V4L2_SEL_TGT_CROP;

View file

@ -342,6 +342,9 @@ gst_v4l2_video_enc_set_format (GstVideoEncoder * encoder,
return FALSE;
}
/* best effort */
gst_v4l2_object_setup_padding (self->v4l2output);
self->input_state = gst_video_codec_state_ref (state);
GST_DEBUG_OBJECT (self, "output caps: %" GST_PTR_FORMAT, state->caps);
@ -876,6 +879,9 @@ gst_v4l2_video_enc_decide_allocation (GstVideoEncoder *
}
gst_caps_unref (caps);
/* best effort */
gst_v4l2_object_setup_padding (self->v4l2capture);
if (gst_v4l2_object_decide_allocation (self->v4l2capture, query)) {
GstVideoEncoderClass *enc_class = GST_VIDEO_ENCODER_CLASS (parent_class);
ret = enc_class->decide_allocation (encoder, query);