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
This commit is contained in:
Guillaume Desmottes 2018-02-16 11:50:35 +01:00 committed by Nicolas Dufresne
parent d1ffc97ddd
commit ea2df994f3
6 changed files with 101 additions and 15 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);