msdk: Set 16 bit alignment for width

According to MediaSDK specification,
Width must be a multiple of 16 and Height must be a multiple
of 16 for progressive frame sequence and a multiple of 32 otherwise.

This patch sets a 16 bit alignment for width and 32 bit alignment
for height as default.

https://bugzilla.gnome.org/show_bug.cgi?id=796566
This commit is contained in:
Sreerenj Balachandran 2018-07-02 16:50:46 -08:00
parent d63a1b4e3f
commit 84c33be0c0
3 changed files with 11 additions and 11 deletions

View file

@ -318,7 +318,7 @@ gst_msdkdec_init_decoder (GstMsdkDec * thiz)
* dealing with different allocators */
/* Fixme: msdk sometimes only requires 16 bit rounding, optimization possible */
thiz->param.mfx.FrameInfo.Width =
GST_ROUND_UP_32 (thiz->param.mfx.FrameInfo.Width);
GST_ROUND_UP_16 (thiz->param.mfx.FrameInfo.Width);
thiz->param.mfx.FrameInfo.Height =
GST_ROUND_UP_32 (thiz->param.mfx.FrameInfo.Height);
/* Set framerate only if provided.
@ -521,7 +521,7 @@ gst_msdkdec_set_src_caps (GstMsdkDec * thiz, gboolean need_allocation)
if (need_allocation) {
/* Find allocation width and height */
width =
GST_ROUND_UP_32 (thiz->param.mfx.FrameInfo.Width ? thiz->param.mfx.
GST_ROUND_UP_16 (thiz->param.mfx.FrameInfo.Width ? thiz->param.mfx.
FrameInfo.Width : GST_VIDEO_INFO_WIDTH (&output_state->info));
height =
GST_ROUND_UP_32 (thiz->param.mfx.FrameInfo.Height ? thiz->param.mfx.
@ -1055,7 +1055,7 @@ gst_msdkdec_create_buffer_pool (GstMsdkDec * thiz, GstVideoInfo * info,
if (!pool)
goto error_no_pool;
if (G_UNLIKELY (!IS_ALIGNED (GST_VIDEO_INFO_WIDTH (info), 32)
if (G_UNLIKELY (!IS_ALIGNED (GST_VIDEO_INFO_WIDTH (info), 16)
|| !IS_ALIGNED (GST_VIDEO_INFO_HEIGHT (info), 32))) {
gst_msdk_set_video_alignment (info, &align);
gst_video_info_align (info, &align);

View file

@ -262,7 +262,7 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz)
thiz->vpp_param.IOPattern =
MFX_IOPATTERN_IN_SYSTEM_MEMORY | MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
thiz->vpp_param.vpp.In.Width = GST_ROUND_UP_32 (info->width);
thiz->vpp_param.vpp.In.Width = GST_ROUND_UP_16 (info->width);
thiz->vpp_param.vpp.In.Height = GST_ROUND_UP_32 (info->height);
thiz->vpp_param.vpp.In.CropW = info->width;
thiz->vpp_param.vpp.In.CropH = info->height;
@ -370,7 +370,7 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz)
thiz->param.mfx.NumRefFrame = thiz->ref_frames;
thiz->param.mfx.EncodedOrder = 0; /* Take input frames in display order */
thiz->param.mfx.FrameInfo.Width = GST_ROUND_UP_32 (info->width);
thiz->param.mfx.FrameInfo.Width = GST_ROUND_UP_16 (info->width);
thiz->param.mfx.FrameInfo.Height = GST_ROUND_UP_32 (info->height);
thiz->param.mfx.FrameInfo.CropW = info->width;
thiz->param.mfx.FrameInfo.CropH = info->height;

View file

@ -37,7 +37,7 @@ GST_DEBUG_CATEGORY_EXTERN (gst_msdk_debug);
#define GST_CAT_DEFAULT gst_msdk_debug
#define INVALID_INDEX ((guint) -1)
#define GST_MSDK_ALIGNMENT_PADDING(num) (32 - ((num) & 31))
#define GST_MSDK_ALIGNMENT_PADDING(num,padding) ((padding) - ((num) & ((padding) - 1)))
struct map
{
@ -215,12 +215,12 @@ gst_msdk_set_video_alignment (GstVideoInfo * info,
gst_video_alignment_reset (alignment);
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++)
alignment->stride_align[i] = 31; /* 32-byte alignment */
alignment->stride_align[i] = 15; /* 16-byte alignment */
if (width & 31)
alignment->padding_right = GST_MSDK_ALIGNMENT_PADDING (width);
if (width & 15)
alignment->padding_right = GST_MSDK_ALIGNMENT_PADDING (width, 16);
if (height & 31)
alignment->padding_bottom = GST_MSDK_ALIGNMENT_PADDING (height);
alignment->padding_bottom = GST_MSDK_ALIGNMENT_PADDING (height, 32);
}
static const struct map *
@ -257,7 +257,7 @@ gst_msdk_set_mfx_frame_info_from_video_info (mfxFrameInfo * mfx_info,
{
g_return_if_fail (info && mfx_info);
mfx_info->Width = GST_ROUND_UP_32 (GST_VIDEO_INFO_WIDTH (info));
mfx_info->Width = GST_ROUND_UP_16 (GST_VIDEO_INFO_WIDTH (info));
mfx_info->Height = GST_ROUND_UP_32 (GST_VIDEO_INFO_HEIGHT (info));
mfx_info->CropW = GST_VIDEO_INFO_WIDTH (info);
mfx_info->CropH = GST_VIDEO_INFO_HEIGHT (info);