diff mbox

[FFmpeg-devel] lavf/dss: Support files with larger header

Message ID 201701111325.11089.cehoyos@ag.or.at
State Accepted
Commit f55da2200dbf98311969e0f345edbc82177d4836
Headers show

Commit Message

Carl Eugen Hoyos Jan. 11, 2017, 12:25 p.m. UTC
Hi!

Attached patch files ticket #6072 for me.

Please comment, Carl Eugen
From ab932a78315ad08fa67590b8d7cd97806c876f54 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Wed, 11 Jan 2017 13:23:13 +0100
Subject: [PATCH] lavf/dss: Support version 3 file / file with larger header.

Fixes ticket #6072.
---
 libavformat/dss.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Paul B Mahol Jan. 11, 2017, 1:08 p.m. UTC | #1
On 1/11/17, Carl Eugen Hoyos <cehoyos@ag.or.at> wrote:
> Hi!
>
> Attached patch files ticket #6072 for me.
>
> Please comment, Carl Eugen
>

ok
Carl Eugen Hoyos Jan. 12, 2017, 2:08 p.m. UTC | #2
2017-01-11 14:08 GMT+01:00 Paul B Mahol <onemda@gmail.com>:
> On 1/11/17, Carl Eugen Hoyos <cehoyos@ag.or.at> wrote:
>> Hi!
>>
>> Attached patch files ticket #6072 for me.
>>
>> Please comment, Carl Eugen
>>
>
> ok

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavformat/dss.c b/libavformat/dss.c
index 2f7f20d..cbf6e17 100644
--- a/libavformat/dss.c
+++ b/libavformat/dss.c
@@ -42,7 +42,6 @@ 
 #define DSS_COMMENT_SIZE              64
 
 #define DSS_BLOCK_SIZE                512
-#define DSS_HEADER_SIZE              (DSS_BLOCK_SIZE * 2)
 #define DSS_AUDIO_BLOCK_HEADER_SIZE   6
 #define DSS_FRAME_SIZE                42
 
@@ -56,11 +55,13 @@  typedef struct DSSDemuxContext {
     int8_t *dss_sp_buf;
 
     int packet_size;
+    int dss_header_size;
 } DSSDemuxContext;
 
 static int dss_probe(AVProbeData *p)
 {
-    if (AV_RL32(p->buf) != MKTAG(0x2, 'd', 's', 's'))
+    if (   AV_RL32(p->buf) != MKTAG(0x2, 'd', 's', 's')
+        && AV_RL32(p->buf) != MKTAG(0x3, 'd', 's', 's'))
         return 0;
 
     return AVPROBE_SCORE_MAX;
@@ -120,12 +121,15 @@  static int dss_read_header(AVFormatContext *s)
     DSSDemuxContext *ctx = s->priv_data;
     AVIOContext *pb = s->pb;
     AVStream *st;
-    int ret;
+    int ret, version;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
 
+    version = avio_r8(pb);
+    ctx->dss_header_size = version * DSS_BLOCK_SIZE;
+
     ret = dss_read_metadata_string(s, DSS_HEAD_OFFSET_AUTHOR,
                                    DSS_AUTHOR_SIZE, "author");
     if (ret)
@@ -164,7 +168,7 @@  static int dss_read_header(AVFormatContext *s)
 
     /* Jump over header */
 
-    if (avio_seek(pb, DSS_HEADER_SIZE, SEEK_SET) != DSS_HEADER_SIZE)
+    if (avio_seek(pb, ctx->dss_header_size, SEEK_SET) != ctx->dss_header_size)
         return AVERROR(EIO);
 
     ctx->counter = 0;
@@ -361,7 +365,7 @@  static int dss_read_seek(AVFormatContext *s, int stream_index,
     if (seekto < 0)
         seekto = 0;
 
-    seekto += DSS_HEADER_SIZE;
+    seekto += ctx->dss_header_size;
 
     ret = avio_seek(s->pb, seekto, SEEK_SET);
     if (ret < 0)