From: Sejun Park Date: Tue, 5 Dec 2017 07:23:43 +0000 (+0900) Subject: Added meta data of MMVideoBuffer for capturing video X-Git-Tag: submit/tizen_4.0/20171220.073105^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91d4a29c0629241d7d4e8d1e17edd6790526d8ba;p=platform%2Fadaptation%2Fnexell%2Fgst-plugins-video-dec.git Added meta data of MMVideoBuffer for capturing video Change-Id: Id963aa56b12cd39df093174158680f0808f73dd1 --- diff --git a/packaging/gst-plugins-video-dec.spec b/packaging/gst-plugins-video-dec.spec index 0026ee6..717cf71 100644 --- a/packaging/gst-plugins-video-dec.spec +++ b/packaging/gst-plugins-video-dec.spec @@ -1,6 +1,6 @@ Name: gst-plugins-video-dec Version: 1.0.3 -Release: 3 +Release: 4 License: LGPLv2+ Summary: nexell video decoder gstreamer plugin Group: Development/Libraries diff --git a/src/gstnxvideodec.c b/src/gstnxvideodec.c old mode 100644 new mode 100755 index fa52d08..bcbf693 --- a/src/gstnxvideodec.c +++ b/src/gstnxvideodec.c @@ -60,6 +60,7 @@ #include "config.h" #endif +#include #include #include #include @@ -71,6 +72,7 @@ // This SUPPORT_NO_MEMORY_COPY function is disabled now. // if the video decoder mmap is supported this function, it will be enabled. #define SUPPORT_NO_MEMORY_COPY 1 +//#define CODEC_DEC_OUTPUT_DUMP 1 GST_DEBUG_CATEGORY_STATIC (gst_nxvideodec_debug_category); #define GST_CAT_DEFAULT gst_nxvideodec_debug_category @@ -90,7 +92,7 @@ static GstFlowReturn gst_nxvideodec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame); static void nxvideodec_base_init (gpointer gclass); static void nxvideodec_buffer_finalize (gpointer pData); -static GstMemory *nxvideodec_mmvideobuf_copy (NX_V4L2DEC_OUT * pDecOut); +static GstMemory *nxvideodec_mmvideobuf_copy (GstNxVideoDec *pNxVideoDec, NX_V4L2DEC_OUT * pDecOut); #if SUPPORT_NO_MEMORY_COPY static void nxvideodec_get_offset_stride (gint width, gint height, @@ -143,6 +145,40 @@ GST_STATIC_PAD_TEMPLATE ("src", ); +#ifdef CODEC_DEC_OUTPUT_DUMP /* for decoder output dump */ +static void +decoder_output_dump(MMVideoBuffer *outbuf) +{ + char *temp = (char *)outbuf->data[0]; + int i = 0; + char filename[100]={0}; + FILE *fp = NULL; + int ret =0; + + GST_ERROR ("codec dec output dump start. w = %d, h = %d", outbuf->width[0], outbuf->height[0]); + + sprintf(filename, "/tmp/dec_output_dump_%d_%d.yuv", outbuf->width[0], outbuf->height[0]); + fp = fopen(filename, "ab"); + + for (i = 0; i < outbuf->height[0]; i++) { + ret = fwrite(temp, outbuf->width[0], 1, fp); + temp += outbuf->stride_width[0]; + } + + for (i = 0; i < outbuf->height[0]/2; i++) { + ret = fwrite(temp, outbuf->width[0]/2, 1, fp); + temp += outbuf->stride_width[0]/2; + } + + for (i = 0; i < outbuf->height[0]/2; i++) { + ret = fwrite(temp, outbuf->width[0]/2, 1, fp); + temp += outbuf->stride_width[0]/2; + } + + GST_ERROR ("codec dec output dumped!! ret = %d", ret); + fclose(fp); +} +#endif static void nxvideodec_base_init (gpointer gclass) @@ -714,7 +750,7 @@ gst_nxvideodec_handle_frame (GstVideoDecoder * pDecoder, goto HANDLE_ERROR; } - pMemMMVideoData = nxvideodec_mmvideobuf_copy (&decOut); + pMemMMVideoData = nxvideodec_mmvideobuf_copy (pNxVideoDec, &decOut); if (!pMemMMVideoData) { GST_ERROR ("failed to get zero copy data"); gst_video_codec_state_unref (pState); @@ -806,7 +842,7 @@ gst_nxvideodec_handle_frame (GstVideoDecoder * pDecoder, goto HANDLE_ERROR; } - pMemMMVideoData = nxvideodec_mmvideobuf_copy (&decOut); + pMemMMVideoData = nxvideodec_mmvideobuf_copy (pNxVideoDec, &decOut); if (!pMemMMVideoData) { GST_ERROR ("failed to get zero copy data"); gst_video_codec_frame_unref (pFrame); @@ -960,7 +996,7 @@ nxvideodec_buffer_finalize (gpointer pData) } static GstMemory * -nxvideodec_mmvideobuf_copy (NX_V4L2DEC_OUT * pDecOut) +nxvideodec_mmvideobuf_copy (GstNxVideoDec *pNxVideoDec, NX_V4L2DEC_OUT * pDecOut) { GstMemory *pMeta = NULL; MMVideoBuffer *pMMVideoBuf = NULL; @@ -986,8 +1022,15 @@ nxvideodec_mmvideobuf_copy (NX_V4L2DEC_OUT * pDecOut) pMMVideoBuf->stride_height[1] = GST_ROUND_UP_16 (pDecOut->hImg.height >> 1); pMMVideoBuf->stride_height[2] = pMMVideoBuf->stride_height[1]; pMMVideoBuf->size[0] = pDecOut->hImg.size[0]; + pMMVideoBuf->size[1] = pMMVideoBuf->size[1] = pMMVideoBuf->stride_width[1] * pMMVideoBuf->stride_height[1]; + pMMVideoBuf->size[2] = pMMVideoBuf->size[2] = pMMVideoBuf->stride_width[2] * pMMVideoBuf->stride_height[2]; pMMVideoBuf->data[0] = pDecOut->hImg.pBuffer[0]; + pMMVideoBuf->data[1] = pDecOut->hImg.pBuffer[0] + pMMVideoBuf->stride_width[0] * pMMVideoBuf->stride_height[0]; + pMMVideoBuf->data[2] = pMMVideoBuf->data[1] + pMMVideoBuf->stride_width[1] * pMMVideoBuf->stride_height[1]; pMMVideoBuf->handle_num = 1; + pMMVideoBuf->handle_size[0] = pMMVideoBuf->stride_width[0] * pMMVideoBuf->stride_height[0]; + pMMVideoBuf->handle_size[1] = pMMVideoBuf->stride_width[1] * pMMVideoBuf->stride_height[1]; + pMMVideoBuf->handle_size[2] = pMMVideoBuf->stride_width[2] * pMMVideoBuf->stride_height[2]; #ifdef TIZEN_FEATURE_ARTIK530 pMMVideoBuf->handle.bo[0] = pDecOut->hImg.bo[0]; if (!pMMVideoBuf->handle.bo[0]) @@ -1021,7 +1064,9 @@ nxvideodec_mmvideobuf_copy (NX_V4L2DEC_OUT * pDecOut) GST_ERROR ("bo[2] = null\n"); #endif } - +#ifdef CODEC_DEC_OUTPUT_DUMP /* for decoder output dump */ + decoder_output_dump (pMMVideoBuf); +#endif pMeta = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, pMMVideoBuf, sizeof (MMVideoBuffer), 0, sizeof (MMVideoBuffer), pMMVideoBuf, g_free);