Skip to content

Instantly share code, notes, and snippets.

@rcombs

rcombs/stdin Secret

Created June 20, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcombs/36af640e5f1d2603b0c6 to your computer and use it in GitHub Desktop.
Save rcombs/36af640e5f1d2603b0c6 to your computer and use it in GitHub Desktop.
commit 7f8987e0d9d15b9f2a6966018769e661725b87a5
Author: Rodger Combs <rodger.combs@gmail.com>
Date: Sat Jun 20 12:19:29 2015 -0500
lavf/brstm: if the file lies about the last block's size, correct it
diff --git a/libavformat/brstm.c b/libavformat/brstm.c
index 3533f5a..de54500 100644
--- a/libavformat/brstm.c
+++ b/libavformat/brstm.c
@@ -362,6 +362,15 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
size = b->last_block_used_bytes;
samples = b->last_block_samples;
skip = b->last_block_size - b->last_block_used_bytes;
+
+ if (samples < size * 14 / 8) {
+ uint32_t adjusted_size = samples / 14 * 8;
+ if (samples % 14)
+ adjusted_size += (samples % 14 + 1) / 2 + 1;
+
+ skip += size - adjusted_size;
+ size = adjusted_size;
+ }
} else if (b->current_block < b->block_count) {
size = b->block_size;
samples = b->samples_per_block;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment