diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-02-16 11:50:35 +0100 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2018-02-28 08:32:26 -0500 |
commit | ea2df994f39da1388dd1cf7f937796ce0ecaa472 (patch) | |
tree | c92ddf4912f61dfb51aedc91eebc1211672ecc61 | |
parent | d1ffc97dddf5e0f9514af101be5e139da7346bd3 (diff) | |
download | gst-omx-ea2df994f39da1388dd1cf7f937796ce0ecaa472.tar.gz |
add support for NV12_10LE32 and NV16_10LE32 on zynqultrascaleplus
The encoder and decoder on zynqultrascaleplus support these new 10 bits
format.
https://bugzilla.gnome.org/show_bug.cgi?id=793694
-rw-r--r-- | omx/gstomxbufferpool.c | 2 | ||||
-rw-r--r-- | omx/gstomxh264enc.c | 25 | ||||
-rw-r--r-- | omx/gstomxh265enc.c | 27 | ||||
-rw-r--r-- | omx/gstomxvideo.c | 12 | ||||
-rw-r--r-- | omx/gstomxvideodec.c | 16 | ||||
-rw-r--r-- | omx/gstomxvideoenc.c | 34 |
6 files changed, 101 insertions, 15 deletions
diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c index 634527f..2d6923e 100644 --- a/omx/gstomxbufferpool.c +++ b/omx/gstomxbufferpool.c @@ -439,7 +439,9 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, offset[2] = offset[1] + (stride[1] * nslice / 2); break; case GST_VIDEO_FORMAT_NV12: + case GST_VIDEO_FORMAT_NV12_10LE32: case GST_VIDEO_FORMAT_NV16: + case GST_VIDEO_FORMAT_NV16_10LE32: stride[1] = nstride; offset[1] = offset[0] + stride[0] * nslice; break; diff --git a/omx/gstomxh264enc.c b/omx/gstomxh264enc.c index 0d3bf2d..e46593a 100644 --- a/omx/gstomxh264enc.c +++ b/omx/gstomxh264enc.c @@ -674,16 +674,29 @@ gst_omx_h264_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, } gst_caps_unref (peercaps); + } - if (profile != OMX_VIDEO_AVCProfileMax || level != OMX_VIDEO_AVCLevelMax) { - /* OMX provides 2 API to set the profile and level. We try using the - * generic on here and the H264 specific when calling - * update_param_avc() */ - if (!update_param_profile_level (self, profile, level)) - return FALSE; + /* Change default profile to high-10 if input is 10 bits */ + if (profile == OMX_VIDEO_AVCProfileMax) { + GstVideoFormat format; + + format = state->info.finfo->format; + if (format == GST_VIDEO_FORMAT_NV12_10LE32 || + format == GST_VIDEO_FORMAT_NV16_10LE32) { + GST_DEBUG_OBJECT (self, + "Set profile to high-10 as input is a 10 bits format"); + profile = OMX_VIDEO_AVCProfileHigh10; } } + if (profile != OMX_VIDEO_AVCProfileMax || level != OMX_VIDEO_AVCLevelMax) { + /* OMX provides 2 API to set the profile and level. We try using the + * generic one here and the H264 specific when calling + * update_param_avc() */ + if (!update_param_profile_level (self, profile, level)) + return FALSE; + } + if (!update_param_avc (self, profile, level)) return FALSE; diff --git a/omx/gstomxh265enc.c b/omx/gstomxh265enc.c index 6e807de..a016cab 100644 --- a/omx/gstomxh265enc.c +++ b/omx/gstomxh265enc.c @@ -492,17 +492,30 @@ gst_omx_h265_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, } gst_caps_unref (peercaps); + } - if (profile != OMX_VIDEO_HEVCProfileUnknown - || level != OMX_VIDEO_HEVCLevelUnknown) { - /* OMX provides 2 API to set the profile and level. We try using the - * generic on here and the H265 specific when calling - * update_param_hevc() */ - if (!update_param_profile_level (self, profile, level)) - return FALSE; + /* Change default profile to main-10 if input is 10 bits */ + if (profile == OMX_VIDEO_HEVCProfileUnknown) { + GstVideoFormat format; + + format = state->info.finfo->format; + if (format == GST_VIDEO_FORMAT_NV12_10LE32 || + format == GST_VIDEO_FORMAT_NV16_10LE32) { + GST_DEBUG_OBJECT (self, + "Set profile to main-10 as input is a 10 bits format"); + profile = OMX_VIDEO_HEVCProfileMain10; } } + if (profile != OMX_VIDEO_HEVCProfileUnknown + || level != OMX_VIDEO_HEVCLevelUnknown) { + /* OMX provides 2 API to set the profile and level. We try using the + * generic one here and the H265 specific when calling + * update_param_hevc() */ + if (!update_param_profile_level (self, profile, level)) + return FALSE; + } + if (!update_param_hevc (self, profile, level)) return FALSE; diff --git a/omx/gstomxvideo.c b/omx/gstomxvideo.c index c06a2f4..151b3b4 100644 --- a/omx/gstomxvideo.c +++ b/omx/gstomxvideo.c @@ -81,6 +81,18 @@ gst_omx_video_get_format_from_omx (OMX_COLOR_FORMATTYPE omx_colorformat) case OMX_COLOR_Format24bitBGR888: format = GST_VIDEO_FORMAT_BGR; break; +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS + /* Formats defined in extensions have their own enum so disable to -Wswitch warning */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" + case OMX_ALG_COLOR_FormatYUV420SemiPlanar10bitPacked: + format = GST_VIDEO_FORMAT_NV12_10LE32; + break; + case OMX_ALG_COLOR_FormatYUV422SemiPlanar10bitPacked: + format = GST_VIDEO_FORMAT_NV16_10LE32; + break; +#pragma GCC diagnostic pop +#endif default: format = GST_VIDEO_FORMAT_UNKNOWN; break; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 4a78c63..36fecc3 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -628,6 +628,22 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self, dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo); dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo); break; + case GST_VIDEO_FORMAT_NV12_10LE32: + /* Need ((width + 2) / 3) 32-bits words */ + dst_width[0] = (GST_VIDEO_INFO_WIDTH (vinfo) + 2) / 3 * 4; + dst_width[1] = dst_width[0]; + src_stride[1] = nstride; + src_size[1] = src_stride[1] * nslice / 2; + dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; + break; + case GST_VIDEO_FORMAT_NV16_10LE32: + /* Need ((width + 2) / 3) 32-bits words */ + dst_width[0] = (GST_VIDEO_INFO_WIDTH (vinfo) + 2) / 3 * 4; + dst_width[1] = dst_width[0]; + src_stride[1] = nstride; + src_size[1] = src_stride[1] * nslice; + dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo); + break; default: g_assert_not_reached (); break; diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 46591c1..0de273b 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1796,6 +1796,13 @@ gst_omx_video_enc_configure_input_buffer (GstOMXVideoEnc * self, switch (port_def.format.video.eColorFormat) { case OMX_COLOR_FormatYUV420Planar: case OMX_COLOR_FormatYUV420PackedPlanar: +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS + /* Formats defined in extensions have their own enum so disable to -Wswitch warning */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" + case OMX_ALG_COLOR_FormatYUV420SemiPlanar10bitPacked: +#pragma GCC diagnostic pop +#endif port_def.nBufferSize = (port_def.format.video.nStride * port_def.format.video.nFrameHeight) + 2 * ((port_def.format.video.nStride / 2) * @@ -1810,6 +1817,19 @@ gst_omx_video_enc_configure_input_buffer (GstOMXVideoEnc * self, ((port_def.format.video.nFrameHeight + 1) / 2)); break; +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS + /* Formats defined in extensions have their own enum so disable to -Wswitch warning */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" + case OMX_ALG_COLOR_FormatYUV422SemiPlanar10bitPacked: +#pragma GCC diagnostic pop +#endif + port_def.nBufferSize = + (port_def.format.video.nStride * port_def.format.video.nFrameHeight) + + 2 * (port_def.format.video.nStride * + ((port_def.format.video.nFrameHeight + 1) / 2)); + break; + default: GST_ERROR_OBJECT (self, "Unsupported port format %x", port_def.format.video.eColorFormat); @@ -2248,7 +2268,7 @@ gst_omx_video_enc_flush (GstVideoEncoder * encoder) static gboolean gst_omx_video_enc_nv12_manual_copy (GstOMXVideoEnc * self, GstBuffer * inbuf, - GstOMXBuffer * outbuf) + GstOMXBuffer * outbuf, gboolean variant_10) { GstVideoInfo *info = &self->input_state->info; OMX_PARAM_PORTDEFINITIONTYPE *port_def = &self->enc_in_port->port_def; @@ -2284,6 +2304,10 @@ gst_omx_video_enc_nv12_manual_copy (GstOMXVideoEnc * self, GstBuffer * inbuf, height = GST_VIDEO_FRAME_COMP_HEIGHT (&frame, i); width = GST_VIDEO_FRAME_COMP_WIDTH (&frame, i) * (i == 0 ? 1 : 2); + if (variant_10) + /* Need ((width + 2) / 3) 32-bits words */ + width = (width + 2) / 3 * 4; + if (dest + dest_stride * height > outbuf->omx_buf->pBuffer + outbuf->omx_buf->nAllocLen) { gst_video_frame_unmap (&frame); @@ -2453,7 +2477,11 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf, break; } case GST_VIDEO_FORMAT_NV12: - ret = gst_omx_video_enc_nv12_manual_copy (self, inbuf, outbuf); + ret = gst_omx_video_enc_nv12_manual_copy (self, inbuf, outbuf, FALSE); + break; + case GST_VIDEO_FORMAT_NV12_10LE32: + case GST_VIDEO_FORMAT_NV16_10LE32: + ret = gst_omx_video_enc_nv12_manual_copy (self, inbuf, outbuf, TRUE); break; default: GST_ERROR_OBJECT (self, "Unsupported format"); @@ -2899,6 +2927,8 @@ filter_supported_formats (GList * negotiation_map) switch (nmap->format) { case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_NV12: + case GST_VIDEO_FORMAT_NV12_10LE32: + case GST_VIDEO_FORMAT_NV16_10LE32: //case GST_VIDEO_FORMAT_ABGR: //case GST_VIDEO_FORMAT_ARGB: cur = g_list_next (cur); |