Fixes ticket #3645.
Carl Eugen Hoyos authored on 2014/05/30 14:26:18... | ... |
@@ -51,7 +51,7 @@ static uint32_t codec_flags(enum AVCodecID codec_id) { |
51 | 51 |
} |
52 | 52 |
} |
53 | 53 |
|
54 |
-static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels) { |
|
54 |
+static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int block_align) { |
|
55 | 55 |
switch (codec_id) { |
56 | 56 |
case AV_CODEC_ID_PCM_S8: |
57 | 57 |
case AV_CODEC_ID_PCM_S16LE: |
... | ... |
@@ -91,9 +91,9 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels) { |
91 | 91 |
case AV_CODEC_ID_ALAC: |
92 | 92 |
return 4096; |
93 | 93 |
case AV_CODEC_ID_ADPCM_IMA_WAV: |
94 |
- return (1024 - 4 * channels) * 8 / (4 * channels) + 1; |
|
94 |
+ return (block_align - 4 * channels) * 8 / (4 * channels) + 1; |
|
95 | 95 |
case AV_CODEC_ID_ADPCM_MS: |
96 |
- return (1024 - 7 * channels) * 2 / channels + 2; |
|
96 |
+ return (block_align - 7 * channels) * 2 / channels + 2; |
|
97 | 97 |
default: |
98 | 98 |
return 0; |
99 | 99 |
} |
... | ... |
@@ -146,7 +146,7 @@ static int caf_write_header(AVFormatContext *s) |
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
if (enc->codec_id != AV_CODEC_ID_MP3 || frame_size != 576) |
149 |
- frame_size = samples_per_packet(enc->codec_id, enc->channels); |
|
149 |
+ frame_size = samples_per_packet(enc->codec_id, enc->channels, enc->block_align); |
|
150 | 150 |
|
151 | 151 |
ffio_wfourcc(pb, "caff"); //< mFileType |
152 | 152 |
avio_wb16(pb, 1); //< mFileVersion |
... | ... |
@@ -259,7 +259,7 @@ static int caf_write_trailer(AVFormatContext *s) |
259 | 259 |
ffio_wfourcc(pb, "pakt"); |
260 | 260 |
avio_wb64(pb, caf->size_entries_used + 24); |
261 | 261 |
avio_wb64(pb, caf->packets); ///< mNumberPackets |
262 |
- avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels)); ///< mNumberValidFrames |
|
262 |
+ avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels, enc->block_align)); ///< mNumberValidFrames |
|
263 | 263 |
avio_wb32(pb, 0); ///< mPrimingFrames |
264 | 264 |
avio_wb32(pb, 0); ///< mRemainderFrames |
265 | 265 |
avio_write(pb, caf->pkt_sizes, caf->size_entries_used); |