summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-02-09 00:15:31 +0000
committerCarl Hetherington <cth@carlh.net>2016-02-09 00:15:31 +0000
commit0b520c4aaca4acb9cdf6334858b462d1a657209d (patch)
tree9322f18ac5cdd1d47819d2364f7910fa905bea8d /src/lib/ffmpeg_decoder.cc
parent8ad8719583be8d778ce830044654fa2c7e22709e (diff)
Fix crash when a frame being deinterleaved has fewer audio channels
than its stream; I'm not sure why this happens but the file that triggered this commit was stereo AC3 and the crash happened when (embedded) subtitles were enabled and the file seek was seeked randomly. There were frame-sync errors from FFmpeg around the crash.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index c25efa463..c1448ad90 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -225,9 +225,13 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream, uint8_t
case AV_SAMPLE_FMT_FLTP:
{
float** p = reinterpret_cast<float**> (data);
- for (int i = 0; i < stream->channels(); ++i) {
+ /* Sometimes there aren't as many channels in the _frame as in the stream */
+ for (int i = 0; i < _frame->channels; ++i) {
memcpy (audio->data(i), p[i], frames * sizeof(float));
}
+ for (int i = _frame->channels; i < stream->channels(); ++i) {
+ audio->make_silent (i);
+ }
}
break;