From: Xavier Claessens Date: Wed, 15 May 2019 14:16:33 +0000 (-0400) Subject: amc: crop values are not mandatory in format X-Git-Tag: 1.19.3~507^2~2955 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06fc7880bbc88f8feae587fa109bceae8a9e2457;p=platform%2Fupstream%2Fgstreamer.git amc: crop values are not mandatory in format Android documentation has example code how to compute width and height when crop values are present. https://developer.android.com/reference/android/media/MediaCodec#accessing-raw-video-bytebuffers-on-older-devices --- diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c index 35d2b99..c8e79c2 100644 --- a/sys/androidmedia/gstamcvideodec.c +++ b/sys/androidmedia/gstamcvideodec.c @@ -766,13 +766,14 @@ gst_amc_video_dec_set_src_caps (GstAmcVideoDec * self, GstAmcFormat * format) return FALSE; } - if (!gst_amc_format_get_int (format, "crop-left", &crop_left, &err) || - !gst_amc_format_get_int (format, "crop-right", &crop_right, &err) || - !gst_amc_format_get_int (format, "crop-top", &crop_top, &err) || - !gst_amc_format_get_int (format, "crop-bottom", &crop_bottom, &err)) { - GST_ERROR_OBJECT (self, "Failed to get crop rectangle: %s", err->message); - g_clear_error (&err); - return FALSE; + if (gst_amc_format_get_int (format, "crop-left", &crop_left, NULL) && + gst_amc_format_get_int (format, "crop-right", &crop_right, NULL)) { + width = crop_right + 1 - crop_left; + } + + if (gst_amc_format_get_int (format, "crop-top", &crop_top, NULL) && + gst_amc_format_get_int (format, "crop-bottom", &crop_bottom, NULL)) { + height = crop_bottom + 1 - crop_top; } if (width == 0 || height == 0) { @@ -780,16 +781,6 @@ gst_amc_video_dec_set_src_caps (GstAmcVideoDec * self, GstAmcFormat * format) return FALSE; } - if (crop_bottom) - height = height - (height - crop_bottom - 1); - if (crop_top) - height = height - crop_top; - - if (crop_right) - width = width - (width - crop_right - 1); - if (crop_left) - width = width - crop_left; - mime = caps_to_mime (self->input_state->caps); if (!mime) { GST_ERROR_OBJECT (self, "Failed to convert caps to mime");