[FFmpeg-devel] [PATCH v2 2/2] libavcodec/dnxhd_parser: add parser and probe support raw 444 and dnxhr formats
Mark Reid
mindmark at gmail.com
Fri Feb 12 05:41:16 CET 2016
---
libavcodec/dnxhd_parser.c | 11 +++++++----
libavformat/dnxhddec.c | 7 ++++---
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/libavcodec/dnxhd_parser.c b/libavcodec/dnxhd_parser.c
index fffb98f..96f6eff 100644
--- a/libavcodec/dnxhd_parser.c
+++ b/libavcodec/dnxhd_parser.c
@@ -25,8 +25,8 @@
*/
#include "parser.h"
-
-#define DNXHD_HEADER_PREFIX 0x000002800100
+#include "dnxhddata.h"
+#include "libavutil/bswap.h"
typedef struct {
ParseContext pc;
@@ -39,6 +39,7 @@ static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
{
ParseContext *pc = &dctx->pc;
uint64_t state = pc->state64;
+ uint64_t header_prefix;
int pic_found = pc->frame_start_found;
int i = 0;
int interlaced = dctx->interlaced;
@@ -47,7 +48,8 @@ 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) {
+ header_prefix = av_bswap64(state & 0xffffffffff00LL) >> 16;
+ if (avpriv_dnxhd_parse_prefix((uint8_t*)&header_prefix) != DNXHD_HEADER_UNKNOWN) {
i++;
pic_found = 1;
interlaced = (state&2)>>1; /* byte following the 5-byte header prefix */
@@ -62,7 +64,8 @@ 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) {
+ header_prefix = av_bswap64(state & 0xffffffffff00LL) >> 16;
+ if (avpriv_dnxhd_parse_prefix((uint8_t*)&header_prefix) != DNXHD_HEADER_UNKNOWN) {
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..adcbaf5 100644
--- a/libavformat/dnxhddec.c
+++ b/libavformat/dnxhddec.c
@@ -23,21 +23,22 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "rawdec.h"
+#include "libavcodec/dnxhddata.h"
static int dnxhd_probe(AVProbeData *p)
{
- static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
int w, h, compression_id;
if (p->buf_size < 0x2c)
return 0;
- if (memcmp(p->buf, header, 5))
+ if (avpriv_dnxhd_parse_prefix(p->buf) == DNXHD_HEADER_UNKNOWN)
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