[FFmpeg-devel] [PATCH]lavf/bink: Support SMUSH files

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Apr 6 23:18:20 CEST 2016


Hi!

Attached patch fixes ticket #5410 for me.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/bink.c b/libavformat/bink.c
index 332edbb..4600af0 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -55,12 +55,15 @@ typedef struct BinkDemuxContext {
     int64_t audio_pts[BINK_MAX_AUDIO_TRACKS];
 
     uint32_t remain_packet_size;
+    int skip_smush;
 } BinkDemuxContext;
 
 static int probe(AVProbeData *p)
 {
     const uint8_t *b = p->buf;
+    int i = 0;
 
+    do {
     if (((b[0] == 'B' && b[1] == 'I' && b[2] == 'K' &&
          (b[3] == 'b' || b[3] == 'f' || b[3] == 'g' || b[3] == 'h' || b[3] == 'i')) ||
          (b[0] == 'K' && b[1] == 'B' && b[2] == '2' && /* Bink 2 */
@@ -70,6 +73,8 @@ static int probe(AVProbeData *p)
         AV_RL32(b+24) > 0 && AV_RL32(b+24) <= BINK_MAX_HEIGHT &&
         AV_RL32(b+28) > 0 && AV_RL32(b+32) > 0)  // fps num,den
         return AVPROBE_SCORE_MAX;
+        b += 512;
+    } while (b < p->buf + p->buf_size - 32 && i++ < 1);
     return 0;
 }
 
@@ -90,6 +95,11 @@ static int read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     vst->codec->codec_tag = avio_rl32(pb);
+    if (vst->codec->codec_tag == AV_RL32("SMUS")) {
+        bink->skip_smush = 512;
+        avio_skip(pb, bink->skip_smush - 4);
+        vst->codec->codec_tag = avio_rl32(pb);
+    }
 
     bink->file_size = avio_rl32(pb) + 8;
     vst->duration   = avio_rl32(pb);
@@ -195,7 +205,7 @@ static int read_header(AVFormatContext *s)
     }
 
     if (vst->index_entries)
-        avio_seek(pb, vst->index_entries[0].pos, SEEK_SET);
+        avio_seek(pb, vst->index_entries[0].pos + bink->skip_smush, SEEK_SET);
     else
         avio_skip(pb, 4);
 
@@ -279,7 +289,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
         return -1;
 
     /* seek to the first frame */
-    if (avio_seek(s->pb, vst->index_entries[0].pos, SEEK_SET) < 0)
+    if (avio_seek(s->pb, vst->index_entries[0].pos + bink->skip_smush, SEEK_SET) < 0)
         return -1;
 
     bink->video_pts = 0;


More information about the ffmpeg-devel mailing list