diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2018-01-04 05:52:40 +0300 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2018-01-04 05:52:40 +0300 |
commit | f141b353e60f1081185927a1e74a9ab46cae8bef (patch) | |
tree | aa2d90c55bdea10b52b43f3030d4d0fa37f8f3dc /libavcodec/opusenc_psy.c | |
parent | c29038f3041a4080342b2e333c1967d136749c0f (diff) |
opusenc_psy: disable stereo searches for mono streams
Fixes a crash which happened when someone tried to encode mono.
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/opusenc_psy.c')
-rw-r--r-- | libavcodec/opusenc_psy.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c index 50890c65d6..b712603344 100644 --- a/libavcodec/opusenc_psy.c +++ b/libavcodec/opusenc_psy.c @@ -383,6 +383,10 @@ static void celt_search_for_dual_stereo(OpusPsyContext *s, CeltFrame *f) { float td1, td2; f->dual_stereo = 0; + + if (s->avctx->channels < 2) + return; + bands_dist(s, f, &td1); f->dual_stereo = 1; bands_dist(s, f, &td2); @@ -396,6 +400,9 @@ static void celt_search_for_intensity(OpusPsyContext *s, CeltFrame *f) int i, best_band = CELT_MAX_BANDS - 1; float dist, best_dist = FLT_MAX; + if (s->avctx->channels < 2) + return; + /* TODO: fix, make some heuristic up here using the lambda value */ float end_band = 0; |