avcodec/aacenc: Avoid 0 lambda
Fixes: Ticket8003
Fixes: CVE-2020-20453
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a7a7f32c8a
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
* TODOs:
|
* TODOs:
|
||||||
* add sane pulse detection
|
* add sane pulse detection
|
||||||
***********************************/
|
***********************************/
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#include "libavutil/libm.h"
|
#include "libavutil/libm.h"
|
||||||
#include "libavutil/thread.h"
|
#include "libavutil/thread.h"
|
||||||
@@ -855,7 +856,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
/* Not so fast though */
|
/* Not so fast though */
|
||||||
ratio = sqrtf(ratio);
|
ratio = sqrtf(ratio);
|
||||||
}
|
}
|
||||||
s->lambda = FFMIN(s->lambda * ratio, 65536.f);
|
s->lambda = av_clipf(s->lambda * ratio, FLT_MIN, 65536.f);
|
||||||
|
|
||||||
/* Keep iterating if we must reduce and lambda is in the sky */
|
/* Keep iterating if we must reduce and lambda is in the sky */
|
||||||
if (ratio > 0.9f && ratio < 1.1f) {
|
if (ratio > 0.9f && ratio < 1.1f) {
|
||||||
|
Reference in New Issue
Block a user