[FFmpeg-devel] [PATCH] lavf/bink: fix latest header and add all existing revisions

bananaman255 at gmail.com bananaman255 at gmail.com
Fri Aug 18 20:45:16 EEST 2017


From: bnnm <bananaman255 at gmail.com>

KB2 'i' found in Life is Strange (Xbox 360), rest verified against binkconv.exe

Signed-off-by: bnnm <bananaman255 at gmail.com>
---
 libavformat/bink.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavformat/bink.c b/libavformat/bink.c
index 20dba677db..8a05082fcd 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -65,10 +65,12 @@ static int probe(AVProbeData *p)
     int smush = AV_RN32(p->buf) == AV_RN32("SMUS");
 
     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')) ||
+        if (((b[0] == 'B' && b[1] == 'I' && b[2] == 'K' && /* Bink 1 */
+             (b[3] == 'b' || b[3] == 'f' || b[3] == 'g' || b[3] == 'h' || b[3] == 'i' ||
+              b[3] == 'k')) ||
              (b[0] == 'K' && b[1] == 'B' && b[2] == '2' && /* Bink 2 */
-             (b[3] == 'a' || b[3] == 'd' || b[3] == 'f' || b[3] == 'g'))) &&
+             (b[3] == 'a' || b[3] == 'd' || b[3] == 'f' || b[3] == 'g' || b[3] == 'h' ||
+              b[3] == 'i' || b[3] == 'j' || b[3] == 'k'))) &&
             AV_RL32(b+8) > 0 &&  // num_frames
             AV_RL32(b+20) > 0 && AV_RL32(b+20) <= BINK_MAX_WIDTH &&
             AV_RL32(b+24) > 0 && AV_RL32(b+24) <= BINK_MAX_HEIGHT &&
@@ -159,7 +161,14 @@ static int read_header(AVFormatContext *s)
     }
 
     if (bink->num_audio_tracks) {
-        avio_skip(pb, 4 * bink->num_audio_tracks);
+        uint32_t signature = (vst->codecpar->codec_tag & 0xFFFFFF);
+        uint8_t revision = ((vst->codecpar->codec_tag >> 24) % 0xFF);
+
+        if ((signature == AV_RL32("BIK") && (revision == 0x6b)) || /* k */
+            (signature == AV_RL32("KB2") && (revision == 0x69 || revision == 0x6a || revision == 0x6b))) /* i,j,k */
+            avio_skip(pb, 4); /* unknown new field */
+
+        avio_skip(pb, 4 * bink->num_audio_tracks); /* max decoded size */
 
         for (i = 0; i < bink->num_audio_tracks; i++) {
             ast = avformat_new_stream(s, NULL);
-- 
2.11.0.windows.3



More information about the ffmpeg-devel mailing list