[FFmpeg-devel] lavc/v210dec: Skip Canopus C210 extradata

Submitted by Carl Eugen Hoyos on May 10, 2018, 8:50 p.m.

Details

Message ID CAB0OVGo4LW_YFdqDgdoqrsOgYzpjbYu=S7_MCDHJsf2LNE55kA@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos May 10, 2018, 8:50 p.m.
Hi!

Peter Bubestinger provided a C210 file where every frame starts with
64 bytes of extradata (24 byte "INFO", 16 byte "RDRT", rest "FIEL").
Piotr confirmed that the Canopus decoder accepts files without the
extradata but consumes it if present.
Attached patch fixes the file in question visually.

Please comment, Carl Eugen

Comments

Carl Eugen Hoyos May 17, 2018, 10:20 a.m.
2018-05-10 22:50 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Peter Bubestinger provided a C210 file where every frame starts with
> 64 bytes of extradata (24 byte "INFO", 16 byte "RDRT", rest "FIEL").
> Piotr confirmed that the Canopus decoder accepts files without the
> extradata but consumes it if present.
> Attached patch fixes the file in question visually.

Patch applied, Carl Eugen
Peter B. May 18, 2018, 1:22 p.m.
On 17/05/18 12:20, Carl Eugen Hoyos wrote:
> 2018-05-10 22:50 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:
>
>> Peter Bubestinger provided a C210 file where every frame starts with
>> 64 bytes of extradata (24 byte "INFO", 16 byte "RDRT", rest "FIEL").
>> Piotr confirmed that the Canopus decoder accepts files without the
>> extradata but consumes it if present.
>> Attached patch fixes the file in question visually.
> Patch applied, Carl Eugen

I've just tested with recent git (=including your path) and it seems to
work properly.
Also transcoded to FFV1 and compared framemd5: matches.


Thank you very much!
Pb

Patch hide | download patch | download mbox

From 42b101a00cc1d78ee6a5207ac09546b67adf7fe5 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 10 May 2018 22:45:07 +0200
Subject: [PATCH] lavc/v210dec: Skip Canopus C210 extradata.

Unbreaks files with unknown extradata.
---
 libavcodec/v210dec.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 99199dd..ddc5dbe 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -27,6 +27,7 @@ 
 #include "libavutil/bswap.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
+#include "libavutil/intreadwrite.h"
 
 #define READ_PIXELS(a, b, c)         \
     do {                             \
@@ -92,6 +93,11 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             return AVERROR_INVALIDDATA;
         }
     }
+    if (   avctx->codec_tag == MKTAG('C', '2', '1', '0')
+        && avpkt->size > 64
+        && AV_RN32(psrc) == AV_RN32("INFO")
+        && avpkt->size - 64 >= stride * avctx->height)
+        psrc += 64;
 
     aligned_input = !((uintptr_t)psrc & 0xf) && !(stride & 0xf);
     if (aligned_input != s->aligned_input) {
-- 
1.7.10.4