[SCM] libav/experimental: dnxhd parser

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:31:37 UTC 2013


The following commit has been merged in the experimental branch:
commit da396bf84e53ee5bd46c69df6511cd5cbfb73e7a
Author: Baptiste Coudurier <baptiste.coudurier at gmail.com>
Date:   Fri Oct 24 01:38:30 2008 +0000

    dnxhd parser
    
    Originally committed as revision 15673 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a2195e8..e942e3e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -345,6 +345,7 @@ OBJS-$(CONFIG_AC3_PARSER)              += ac3_parser.o ac3tab.o aac_ac3_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
 OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o
 OBJS-$(CONFIG_DIRAC_PARSER)            += dirac_parser.o
+OBJS-$(CONFIG_DNXHD_PARSER)            += dnxhd_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsub_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsub_parser.o
 OBJS-$(CONFIG_H261_PARSER)             += h261_parser.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 1475a7b..074054d 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -304,6 +304,7 @@ void avcodec_register_all(void)
     REGISTER_PARSER  (CAVSVIDEO, cavsvideo);
     REGISTER_PARSER  (DCA, dca);
     REGISTER_PARSER  (DIRAC, dirac);
+    REGISTER_PARSER  (DNXHD, dnxhd);
     REGISTER_PARSER  (DVBSUB, dvbsub);
     REGISTER_PARSER  (DVDSUB, dvdsub);
     REGISTER_PARSER  (H261, h261);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index dfd7264..3be9402 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -30,7 +30,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR  0
+#define LIBAVCODEC_VERSION_MINOR  1
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/dirac_parser.c b/libavcodec/dnxhd_parser.c
similarity index 51%
copy from libavcodec/dirac_parser.c
copy to libavcodec/dnxhd_parser.c
index 199354a..b527913 100644
--- a/libavcodec/dirac_parser.c
+++ b/libavcodec/dnxhd_parser.c
@@ -1,7 +1,6 @@
 /*
- * Dirac parser
- *
- * Copyright (c) 2007 Marco Gerards <marco at gnu.org>
+ * DNxHD/VC-3 parser
+ * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier at free.fr>
  *
  * This file is part of FFmpeg.
  *
@@ -21,41 +20,51 @@
  */
 
 /**
- * @file dirac_parser.c
- * Dirac Parser
- * @author Marco Gerards <marco at gnu.org>
+ * @file dnxhd_parser.c
+ * DNxHD/VC-3 parser
  */
 
 #include "parser.h"
 
-#define DIRAC_PARSE_INFO_PREFIX 0x42424344
+#define DNXHD_HEADER_PREFIX 0x0000028001
 
-/**
- * Finds the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame or -1
- */
-static int find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
+static int dnxhd_find_frame_end(ParseContext *pc,
+                                const uint8_t *buf, int buf_size)
 {
-    uint32_t state = pc->state;
-    int i;
+    uint64_t state = pc->state64;
+    int pic_found = pc->frame_start_found;
+    int i = 0;
 
-    for (i = 0; i < buf_size; i++) {
-        state = (state << 8) | buf[i];
-        if (state == DIRAC_PARSE_INFO_PREFIX) {
-            pc->frame_start_found ^= 1;
-            if (!pc->frame_start_found) {
-                pc->state = -1;
-                return i - 3;
+    if (!pic_found) {
+        for (i = 0; i < buf_size; i++) {
+            state = (state<<8) | buf[i];
+            if ((state & 0xffffffffffLL) == DNXHD_HEADER_PREFIX) {
+                i++;
+                pic_found = 1;
+                break;
             }
         }
     }
 
-    pc->state = state;
-
+    if (pic_found) {
+        if (!buf_size) /* EOF considered as end of frame */
+            return 0;
+        for (; i < buf_size; i++) {
+            state = (state<<8) | buf[i];
+            if ((state & 0xffffffffffLL) == DNXHD_HEADER_PREFIX) {
+                pc->frame_start_found = 0;
+                pc->state64 = -1;
+                return i-4;
+            }
+        }
+    }
+    pc->frame_start_found = pic_found;
+    pc->state64 = state;
     return END_NOT_FOUND;
 }
 
-static int dirac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
+static int dnxhd_parse(AVCodecParserContext *s,
+                       AVCodecContext *avctx,
                        const uint8_t **poutbuf, int *poutbuf_size,
                        const uint8_t *buf, int buf_size)
 {
@@ -64,25 +73,23 @@ static int dirac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
 
     if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
         next = buf_size;
-    }else{
-        next = find_frame_end(pc, buf, buf_size);
-
+    } else {
+        next = dnxhd_find_frame_end(pc, buf, buf_size);
         if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
             *poutbuf = NULL;
             *poutbuf_size = 0;
             return buf_size;
         }
     }
-
     *poutbuf = buf;
     *poutbuf_size = buf_size;
     return next;
 }
 
-AVCodecParser dirac_parser = {
-    { CODEC_ID_DIRAC },
+AVCodecParser dnxhd_parser = {
+    { CODEC_ID_DNXHD },
     sizeof(ParseContext),
     NULL,
-    dirac_parse,
+    dnxhd_parse,
     ff_parse_close,
 };

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list