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); offset[2] = offset[1] + (stride[1] * nslice / 2);
break; break;
case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV12_10LE32:
case GST_VIDEO_FORMAT_NV16: case GST_VIDEO_FORMAT_NV16:
case GST_VIDEO_FORMAT_NV16_10LE32:
stride[1] = nstride; stride[1] = nstride;
offset[1] = offset[0] + stride[0] * nslice; offset[1] = offset[0] + stride[0] * nslice;
break; break;

View file

@ -674,16 +674,29 @@ gst_omx_h264_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
} }
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
}
if (profile != OMX_VIDEO_AVCProfileMax || level != OMX_VIDEO_AVCLevelMax) { /* Change default profile to high-10 if input is 10 bits */
/* OMX provides 2 API to set the profile and level. We try using the if (profile == OMX_VIDEO_AVCProfileMax) {
* generic on here and the H264 specific when calling GstVideoFormat format;
* update_param_avc() */
if (!update_param_profile_level (self, profile, level)) format = state->info.finfo->format;
return FALSE; 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)) if (!update_param_avc (self, profile, level))
return FALSE; return FALSE;

View file

@ -492,17 +492,30 @@ gst_omx_h265_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
} }
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
}
if (profile != OMX_VIDEO_HEVCProfileUnknown /* Change default profile to main-10 if input is 10 bits */
|| level != OMX_VIDEO_HEVCLevelUnknown) { if (profile == OMX_VIDEO_HEVCProfileUnknown) {
/* OMX provides 2 API to set the profile and level. We try using the GstVideoFormat format;
* generic on here and the H265 specific when calling
* update_param_hevc() */ format = state->info.finfo->format;
if (!update_param_profile_level (self, profile, level)) if (format == GST_VIDEO_FORMAT_NV12_10LE32 ||
return FALSE; 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)) if (!update_param_hevc (self, profile, level))
return FALSE; return FALSE;

View file

@ -81,6 +81,18 @@ gst_omx_video_get_format_from_omx (OMX_COLOR_FORMATTYPE omx_colorformat)
case OMX_COLOR_Format24bitBGR888: case OMX_COLOR_Format24bitBGR888:
format = GST_VIDEO_FORMAT_BGR; format = GST_VIDEO_FORMAT_BGR;
break; 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: default:
format = GST_VIDEO_FORMAT_UNKNOWN; format = GST_VIDEO_FORMAT_UNKNOWN;
break; break;

View file

@ -628,6 +628,22 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo); dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo);
dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo); dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo);
break; 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: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;

View file

@ -1796,6 +1796,13 @@ gst_omx_video_enc_configure_input_buffer (GstOMXVideoEnc * self,
switch (port_def.format.video.eColorFormat) { switch (port_def.format.video.eColorFormat) {
case OMX_COLOR_FormatYUV420Planar: case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420PackedPlanar: 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.nBufferSize =
(port_def.format.video.nStride * port_def.format.video.nFrameHeight) + (port_def.format.video.nStride * port_def.format.video.nFrameHeight) +
2 * ((port_def.format.video.nStride / 2) * 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)); ((port_def.format.video.nFrameHeight + 1) / 2));
break; 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: default:
GST_ERROR_OBJECT (self, "Unsupported port format %x", GST_ERROR_OBJECT (self, "Unsupported port format %x",
port_def.format.video.eColorFormat); port_def.format.video.eColorFormat);
@ -2248,7 +2268,7 @@ gst_omx_video_enc_flush (GstVideoEncoder * encoder)
static gboolean static gboolean
gst_omx_video_enc_nv12_manual_copy (GstOMXVideoEnc * self, GstBuffer * inbuf, gst_omx_video_enc_nv12_manual_copy (GstOMXVideoEnc * self, GstBuffer * inbuf,
GstOMXBuffer * outbuf) GstOMXBuffer * outbuf, gboolean variant_10)
{ {
GstVideoInfo *info = &self->input_state->info; GstVideoInfo *info = &self->input_state->info;
OMX_PARAM_PORTDEFINITIONTYPE *port_def = &self->enc_in_port->port_def; 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); height = GST_VIDEO_FRAME_COMP_HEIGHT (&frame, i);
width = GST_VIDEO_FRAME_COMP_WIDTH (&frame, i) * (i == 0 ? 1 : 2); 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 > if (dest + dest_stride * height >
outbuf->omx_buf->pBuffer + outbuf->omx_buf->nAllocLen) { outbuf->omx_buf->pBuffer + outbuf->omx_buf->nAllocLen) {
gst_video_frame_unmap (&frame); gst_video_frame_unmap (&frame);
@ -2453,7 +2477,11 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
break; break;
} }
case GST_VIDEO_FORMAT_NV12: 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; break;
default: default:
GST_ERROR_OBJECT (self, "Unsupported format"); GST_ERROR_OBJECT (self, "Unsupported format");
@ -2899,6 +2927,8 @@ filter_supported_formats (GList * negotiation_map)
switch (nmap->format) { switch (nmap->format) {
case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_NV12: 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_ABGR:
//case GST_VIDEO_FORMAT_ARGB: //case GST_VIDEO_FORMAT_ARGB:
cur = g_list_next (cur); cur = g_list_next (cur);