brillcodec: disable parser APIs because of seeking issue.
authorKitae Kim <kt920.kim@samsung.com>
Wed, 21 Jan 2015 01:42:50 +0000 (10:42 +0900)
committerSooyoung Ha <yoosah.ha@samsung.com>
Thu, 26 Feb 2015 15:12:23 +0000 (00:12 +0900)
when seeking video, decoder returns invalid position of video stream.
However, decoding video does work successfully without parser APIs.

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

index 76347cf63887464bad914bc99c0d7b889f17c15d..36d36faa107a33561562d8b719584ef0afadbfb9 100644 (file)
@@ -131,7 +131,9 @@ static CodecFuncEntry codec_func_handler[] = {
     codec_flush_buffers,
 };
 
+#if 0
 static AVCodecParserContext *maru_brill_codec_parser_init(AVCodecContext *avctx);
+#endif
 
 static void maru_brill_codec_push_readqueue(MaruBrillCodecState *s, CodecParam *ioparam);
 static void maru_brill_codec_push_writequeue(MaruBrillCodecState *s, void* opaque,
@@ -933,8 +935,8 @@ static int parse_and_decode_video(AVCodecContext *avctx, AVFrame *picture,
 {
     uint8_t *parser_outbuf = NULL;
     int parser_outbuf_size = 0;
-    uint8_t *parser_buf = packet->data;
-    int parser_buf_size = packet->size;
+    uint8_t *parser_inbuf = packet->data;
+    int parser_inbuf_size = packet->size;
     int ret = 0, len = -1;
     int64_t pts = 0, dts = 0, pos = 0;
 
@@ -943,23 +945,25 @@ static int parse_and_decode_video(AVCodecContext *avctx, AVFrame *picture,
 
     do {
         if (pctx) {
+            TRACE("before parsing parser_inbuf_size %d pts %lld\n", parser_inbuf_size, pctx->pts);
+
             ret = av_parser_parse2(pctx, avctx, &parser_outbuf,
-                    &parser_outbuf_size, parser_buf, parser_buf_size,
+                    &parser_outbuf_size, parser_inbuf, parser_inbuf_size,
                     pts, dts, pos);
 
-            if (ret) {
-                parser_buf_size -= ret;
-                parser_buf += ret;
+            if (ret > 0) {
+                parser_inbuf_size -= ret;
+                parser_inbuf += ret;
             }
 
-            TRACE("after parsing ret: %d parser_outbuf_size %d parser_buf_size %d pts %lld\n",
-                ret, parser_outbuf_size, parser_buf_size, pctx->pts);
+            TRACE("after parsing ret: %d parser_outbuf_size %d parser_inbuf_size %d pts %lld\n",
+                ret, parser_outbuf_size, parser_inbuf_size, pctx->pts);
 
             /* if there is no output, we must break and wait for more data.
              * also the timestamp in the context is not updated.
              */
             if (parser_outbuf_size == 0) {
-                if (parser_buf_size > 0) {
+                if (parser_inbuf_size > 0) {
                     TRACE("parsing data have been left\n");
                     continue;
                 } else {
@@ -974,32 +978,34 @@ static int parse_and_decode_video(AVCodecContext *avctx, AVFrame *picture,
             TRACE("not using parser %s\n", avctx->codec->name);
         }
 
+        TRACE("before decode_video inbuf %p inbuf_size %d\n", packet->data, packet->size);
         len = avcodec_decode_video2(avctx, picture, got_picture, packet);
+
         TRACE("decode_video. len %d, got_picture %d\n", len, *got_picture);
 
         if (!pctx) {
             if (len == 0 && (*got_picture) == 0) {
-                INFO("decoding video 1! didn't return any data! ctx_id %d len %d\n", ctx_id, len);
+                INFO("decoding video w/o parser didn't return any data! ctx_id %d len %d\n", ctx_id, len);
                 break;
             } else if (len < 0) {
-                ERR("decoding video error! ctx_id %d len %d\n", ctx_id, len);
+                ERR("decoding video w/o parser. ctx_id %d len %d\n", ctx_id, len);
                 break;
             }
-            parser_buf_size -= len;
-            parser_buf += len;
+            parser_inbuf_size -= len;
+            parser_inbuf += len;
         } else {
             if (len == 0) {
-                INFO("decoding video 2! didn't return any data! ctx_id %d len %d\n", ctx_id, len);
+                INFO("decoding video w/ parser didn't return any data! ctx_id %d len %d\n", ctx_id, len);
                 *got_picture = 0;
                 break;
             } else if (len < 0) {
-                ERR("decoding video error! trying next ctx_id %d len %d\n", ctx_id, len);
+                ERR("decoding video w/ parser. ctx_id %d len %d\n", ctx_id, len);
                 break;
             }
         }
 
-        TRACE("decoding video. parser_buf_size %d\n", parser_buf_size);
-    } while (parser_buf_size > 0);
+        TRACE("decoding video. parser_buf_size %d\n", parser_inbuf_size);
+    } while (parser_inbuf_size > 0);
 
     return len;
 }
@@ -1082,7 +1088,7 @@ static bool codec_init(MaruBrillCodecState *s, int ctx_id, void *data_buf)
                 + sizeof(avctx->extradata_size) + avctx->extradata_size) + 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);
     } else {
         ERR("failed to find codec. ctx_id: %d\n", ctx_id);
         ret = -1;
@@ -1191,6 +1197,7 @@ static bool codec_flush_buffers(MaruBrillCodecState *s, int ctx_id, void *data_b
         ret = false;
     } else {
         TRACE("flush %d context of buffers.\n", ctx_id);
+
         AVCodecParserContext *pctx = NULL;
         uint8_t *poutbuf = NULL;
         int poutbuf_size = 0;
@@ -1205,7 +1212,7 @@ static bool codec_flush_buffers(MaruBrillCodecState *s, int ctx_id, void *data_b
         if (pctx) {
             res = av_parser_parse2(pctx, avctx, &poutbuf, &poutbuf_size,
                     p_inbuf, p_inbuf_size, -1, -1, -1);
-            TRACE("before flush buffers, using parser. res: %d\n", res);
+            TRACE("after flush buffers, using parser. res: %d\n", res);
         }
 
         avcodec_flush_buffers(avctx);
@@ -1742,6 +1749,7 @@ static bool codec_encode_audio(MaruBrillCodecState *s, int ctx_id, void *data_bu
     return true;
 }
 
+#if 0
 static AVCodecParserContext *maru_brill_codec_parser_init(AVCodecContext *avctx)
 {
     AVCodecParserContext *parser = NULL;
@@ -1768,3 +1776,4 @@ static AVCodecParserContext *maru_brill_codec_parser_init(AVCodecContext *avctx)
 
     return parser;
 }
+#endif