brillcodec: dump decoded frames 76/34476/2
authorKitae Kim <kt920.kim@samsung.com>
Tue, 27 Jan 2015 03:03:15 +0000 (12:03 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 29 Jan 2015 06:57:25 +0000 (22:57 -0800)
Dump decoded frames to check if they are valid or not.

Change-Id: I904ef58148e468d7e2c1985614522935ff615f55
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
tizen/src/hw/pci/maru_brillcodec.c

index 0430274..6a513ed 100644 (file)
 /* define debug channel */
 DECLARE_DEBUG_CHANNEL(brillcodec);
 
-// device memory
-#define CODEC_META_DATA_SIZE    (256)
+#ifdef DUMP_DECODE_FRAME
+/* You can check whether decoded frames are valid or not via PYUV program  */
+FILE *dump_file = NULL;
+const char *dump_image = "dump_decode.raw";
+#endif
 
 // libav
 #define GEN_MASK(x) ((1 << (x)) - 1)
@@ -831,6 +834,13 @@ static void default_get_picture(void *dst, void *src, enum AVPixelFormat pix_fmt
     }
     avpicture_layout((AVPicture *)frame, pix_fmt,
             frame->width, frame->height, dst, pict_size);
+
+#ifdef DUMP_DECODE_FRAME
+    if (dump_file) {
+        LOG_TRACE("dump decoded frame. picture size %d\n", pict_size);
+        fwrite(dst, 1, pict_size, dump_file);
+    }
+#endif
 }
 
 // video decode data handler
@@ -1891,8 +1901,15 @@ static bool init(MaruBrillCodecState *s, int ctx_id, void *data_buf)
                            + sizeof(int);
 
             CONTEXT(s, ctx_id)->opened_context = true;
-            CONTEXT(s, ctx_id)->parser_ctx =
-                maru_brill_codec_parser_init(avctx);
+            CONTEXT(s, ctx_id)->parser_ctx = maru_brill_codec_parser_init(avctx);
+#ifdef DUMP_DECODE_FRAME
+            if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+                dump_file = fopen(dump_image, "wb");
+                if (!dump_file) {
+                    LOG_INFO("failed to open a file\n");
+                }
+            }
+#endif
         } else {
             LOG_SEVERE("failed to find codec. ctx_id: %d\n", ctx_id);
             ret = -1;
@@ -1951,6 +1968,15 @@ static bool deinit(MaruBrillCodecState *s, int ctx_id, void *data_buf)
     }
 
     LOG_INFO("close avcontext of %d\n", ctx_id);
+#ifdef DUMP_DECODE_FRAME
+    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+        if (dump_file) {
+            fclose(dump_file);
+            dump_file = NULL;
+        }
+    }
+#endif
+
     avcodec_close(avctx);
 
     if (CONTEXT(s, ctx_id)->is_hwaccel) {