Fixed align issue when using s/w codec 17/85017/2 accepted/tizen/common/20160831.162043 accepted/tizen/ivi/20160901.065253 accepted/tizen/mobile/20160901.065031 accepted/tizen/tv/20160901.065130 accepted/tizen/wearable/20160901.065208 submit/tizen/20160831.052250
authorSejun Park <sejun79.park@samsung.com>
Tue, 23 Aug 2016 08:59:41 +0000 (17:59 +0900)
committerSejun Park <sejun79.park@samsung.com>
Tue, 23 Aug 2016 09:05:19 +0000 (18:05 +0900)
Change-Id: I051be3f7f783bef6d1ade8fb1fa865228fe1bd64

src/media_codec_port_gst.c

index d2bad4b..5e38462 100755 (executable)
@@ -33,7 +33,6 @@
 #include <linux/ion.h>
 #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();