File 0001-opusenc-psy-disable-stereo-searches.patch of Package A_tw-ffmpeg-3

41
 
1
From f141b353e60f1081185927a1e74a9ab46cae8bef Mon Sep 17 00:00:00 2001
2
From: Rostislav Pehlivanov <atomnuker@gmail.com>
3
Date: Thu, 4 Jan 2018 02:52:40 +0000
4
Subject: [PATCH] opusenc_psy: disable stereo searches for mono streams
5
6
Fixes a crash which happened when someone tried to encode mono.
7
8
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
9
---
10
 libavcodec/opusenc_psy.c | 7 +++++++
11
 1 file changed, 7 insertions(+)
12
13
diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c
14
index 50890c65d6..b712603344 100644
15
--- a/libavcodec/opusenc_psy.c
16
+++ b/libavcodec/opusenc_psy.c
17
@@ -383,6 +383,10 @@ static void celt_search_for_dual_stereo(OpusPsyContext *s, CeltFrame *f)
18
 {
19
     float td1, td2;
20
     f->dual_stereo = 0;
21
+
22
+    if (s->avctx->channels < 2)
23
+        return;
24
+
25
     bands_dist(s, f, &td1);
26
     f->dual_stereo = 1;
27
     bands_dist(s, f, &td2);
28
@@ -396,6 +400,9 @@ static void celt_search_for_intensity(OpusPsyContext *s, CeltFrame *f)
29
     int i, best_band = CELT_MAX_BANDS - 1;
30
     float dist, best_dist = FLT_MAX;
31
 
32
+    if (s->avctx->channels < 2)
33
+        return;
34
+
35
     /* TODO: fix, make some heuristic up here using the lambda value */
36
     float end_band = 0;
37
 
38
-- 
39
2.11.0
40
41