[FFmpeg-devel] [PATCH] libavformat/dnxhddec added support for raw 444 and dnxhr formats

Mark Reid mindmark at gmail.com
Mon Feb 8 02:31:41 CET 2016


---
 libavcodec/dnxhd_parser.c | 19 ++++++++++++++++---
 libavformat/dnxhddec.c    | 14 +++++++++++---
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dnxhd_parser.c b/libavcodec/dnxhd_parser.c
index fffb98f..83bfda8 100644
--- a/libavcodec/dnxhd_parser.c
+++ b/libavcodec/dnxhd_parser.c
@@ -26,7 +26,10 @@
 
 #include "parser.h"
 
-#define DNXHD_HEADER_PREFIX 0x000002800100
+#define DNXHD_HEADER_PREFIX    0x000002800100
+#define DNXHD_HEADER_PREFIX444 0x000002800200
+#define DNXHD_HEADER_PREFIXHR1 0x000002800300
+#define DNXHD_HEADER_PREFIXHR2 0x0000038C0300
 
 typedef struct {
     ParseContext pc;
@@ -34,6 +37,16 @@ typedef struct {
     int cur_field; /* first field is 0, second is 1 */
 } DNXHDParserContext;
 
+static int dnxhd_is_prefix(uint64_t prefix)
+{
+  if (prefix == DNXHD_HEADER_PREFIX    ||
+      prefix == DNXHD_HEADER_PREFIX444 ||
+      prefix == DNXHD_HEADER_PREFIXHR1 ||
+      prefix == DNXHD_HEADER_PREFIXHR2)
+      return 1;
+  return 0;
+}
+
 static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
                                 const uint8_t *buf, int buf_size)
 {
@@ -47,7 +60,7 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
     if (!pic_found) {
         for (i = 0; i < buf_size; i++) {
             state = (state << 8) | buf[i];
-            if ((state & 0xffffffffff00LL) == DNXHD_HEADER_PREFIX) {
+            if (dnxhd_is_prefix(state & 0xffffffffff00LL)) {
                 i++;
                 pic_found = 1;
                 interlaced = (state&2)>>1; /* byte following the 5-byte header prefix */
@@ -62,7 +75,7 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
             return 0;
         for (; i < buf_size; i++) {
             state = (state << 8) | buf[i];
-            if ((state & 0xffffffffff00LL) == DNXHD_HEADER_PREFIX) {
+            if (dnxhd_is_prefix(state & 0xffffffffff00LL)) {
                 if (!interlaced || dctx->cur_field) {
                     pc->frame_start_found = 0;
                     pc->state64 = -1;
diff --git a/libavformat/dnxhddec.c b/libavformat/dnxhddec.c
index 37e52d5..d26667d 100644
--- a/libavformat/dnxhddec.c
+++ b/libavformat/dnxhddec.c
@@ -26,18 +26,26 @@
 
 static int dnxhd_probe(AVProbeData *p)
 {
-    static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
+    static const uint8_t header_prefix[]    = { 0x00, 0x00, 0x02, 0x80, 0x01 };
+    static const uint8_t header_prefix444[] = { 0x00, 0x00, 0x02, 0x80, 0x02 };
+    static const uint8_t header_prefixhr1[] = { 0x00, 0x00, 0x02, 0x80, 0x03 };
+    static const uint8_t header_prefixhr2[] = { 0x00, 0x00, 0x03, 0x8C, 0x03 };
+
     int w, h, compression_id;
     if (p->buf_size < 0x2c)
         return 0;
-    if (memcmp(p->buf, header, 5))
+    if (memcmp(p->buf, header_prefix,    5) &&
+        memcmp(p->buf, header_prefix444, 5) &&
+        memcmp(p->buf, header_prefixhr1, 5) &&
+        memcmp(p->buf, header_prefixhr2, 5))
         return 0;
     h = AV_RB16(p->buf + 0x18);
     w = AV_RB16(p->buf + 0x1a);
     if (!w || !h)
         return 0;
     compression_id = AV_RB32(p->buf + 0x28);
-    if (compression_id < 1235 || compression_id > 1260)
+    if ((compression_id < 1235 || compression_id > 1260) &&
+        (compression_id < 1270 || compression_id > 1274))
         return 0;
     return AVPROBE_SCORE_MAX;
 }
-- 
2.4.1



More information about the ffmpeg-devel mailing list