]> git.sesse.net Git - nageru/commitdiff
Fix a crash bug when avcodec_fill_audio_frame() decided we needed more alignment.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Nov 2015 01:06:49 +0000 (02:06 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Nov 2015 01:06:49 +0000 (02:06 +0100)
bmusb
h264encode.cpp

diff --git a/bmusb b/bmusb
index 6a027cb2d982c385859150ad1558a1e205817844..ec10aedf720f2356035255999827beb4158aa4a2 160000 (submodule)
--- a/bmusb
+++ b/bmusb
@@ -1 +1 @@
-Subproject commit 6a027cb2d982c385859150ad1558a1e205817844
+Subproject commit ec10aedf720f2356035255999827beb4158aa4a2
index a359726b4a874484305e0d6b32adc8ef7c249887..0946eb02b06126f0fcfc6c5a197e4d933daef814 100644 (file)
@@ -1709,7 +1709,11 @@ void H264Encoder::save_codeddata(storage_task task)
         frame->channel_layout = AV_CH_LAYOUT_STEREO;
 
         unique_ptr<int32_t[]> int_samples(new int32_t[audio.size()]);
-        avcodec_fill_audio_frame(frame, 2, AV_SAMPLE_FMT_S32, (const uint8_t*)int_samples.get(), audio.size() * sizeof(int32_t), 0);
+        int ret = avcodec_fill_audio_frame(frame, 2, AV_SAMPLE_FMT_S32, (const uint8_t*)int_samples.get(), audio.size() * sizeof(int32_t), 1);
+        if (ret < 0) {
+            fprintf(stderr, "avcodec_fill_audio_frame() failed with %d\n", ret);
+            exit(1);
+        }
         for (int i = 0; i < frame->nb_samples * 2; ++i) {
             if (audio[i] >= 1.0f) {
                 int_samples[i] = 2147483647;