#include "config.h"
#endif
+#include <stdio.h>
#include <string.h>
#include <gst/gst.h>
#include <gst/video/video.h>
// 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
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,
);
+#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)
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);
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);
}
static GstMemory *
-nxvideodec_mmvideobuf_copy (NX_V4L2DEC_OUT * pDecOut)
+nxvideodec_mmvideobuf_copy (GstNxVideoDec *pNxVideoDec, NX_V4L2DEC_OUT * pDecOut)
{
GstMemory *pMeta = NULL;
MMVideoBuffer *pMMVideoBuf = NULL;
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])
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);