From 6835c2b4e62b2fbfd6e580104b67d1c0350a4cbc Mon Sep 17 00:00:00 2001 From: Sejun Park Date: Tue, 23 Aug 2016 17:59:41 +0900 Subject: [PATCH] Fixed align issue when using s/w codec Change-Id: I051be3f7f783bef6d1ade8fb1fa865228fe1bd64 --- src/media_codec_port_gst.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/media_codec_port_gst.c b/src/media_codec_port_gst.c index d2bad4b..5e38462 100755 --- a/src/media_codec_port_gst.c +++ b/src/media_codec_port_gst.c @@ -33,7 +33,6 @@ #include #endif -#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) /* * Internal Implementation */ @@ -370,13 +369,10 @@ int __mc_fill_vdec_packet_with_output_buffer(mc_gst_core_t *core, void *data, in if (!core->is_hw) { width = dec_info->width; height = dec_info->height; - stride_width = ALIGN(width, 4); - stride_height = ALIGN(height, 4); + stride_width = GST_ROUND_UP_4(width); + stride_height = GST_ROUND_UP_2(height); buf_size = stride_width * stride_height * 3 / 2; - if (buf_size > size) - return MC_ERROR; - memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s)); bo[0] = tbm_bo_alloc(core->bufmgr, buf_size, TBM_BO_WC); @@ -399,8 +395,8 @@ int __mc_fill_vdec_packet_with_output_buffer(mc_gst_core_t *core, void *data, in tsurf_info.planes[i].offset = 0; tsurf_info.size = tsurf_info.planes[i].size; } else { - tsurf_info.planes[i].stride = stride_width>>1; - tsurf_info.planes[i].size = (stride_width>>1) * (stride_height>>1); + tsurf_info.planes[i].stride = GST_ROUND_UP_4(GST_ROUND_UP_2(width)/2); + tsurf_info.planes[i].size = GST_ROUND_UP_4(GST_ROUND_UP_2(width)/2) * (GST_ROUND_UP_2(height)/2); tsurf_info.planes[i].offset = (tsurf_info.planes[i-1].offset + tsurf_info.planes[i - 1].size); tsurf_info.size += tsurf_info.planes[i].size; } @@ -2022,6 +2018,9 @@ void __mc_gst_buffer_add(GstElement *element, GstBuffer *buffer, GstPad *pad, gp ((mc_fill_buffer_cb) core->user_cb[_MEDIACODEC_EVENT_TYPE_FILLBUFFER]) (out_pkt, core->user_data[_MEDIACODEC_EVENT_TYPE_FILLBUFFER]); } + } else { + gst_buffer_unref(buffer); + LOGE("Failed to dequeue output packet"); } MEDIACODEC_FLEAVE(); -- 2.7.4