aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2011-03-20 18:30:29 +0100
committerRonald S. Bultje <rsbultje@gmail.com>2011-03-22 18:26:46 -0400
commitee26abf2a4884bb56959bac8215758195776c553 (patch)
tree6f6ca8bf2c5dff22050f2307d0dc50941eab9d99
parenta6d2227bc8a269c243bbcf3c3a22e94912755bb8 (diff)
downloadffmpeg-ee26abf2a4884bb56959bac8215758195776c553.tar.gz
Fix an infinite loop when RoQ encoded generated a frame with a size greater than the maximum valid size.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
-rw-r--r--libavcodec/roqvideoenc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index f4b5de0adf..052dcef3de 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -898,9 +898,20 @@ static void roq_encode_video(RoqContext *enc)
for (i=0; i<enc->width*enc->height/64; i++)
gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
- /* Quake 3 can't handle chunks bigger than 65536 bytes */
- if (tempData->mainChunkSize/8 > 65536) {
- enc->lambda *= .8;
+ /* Quake 3 can't handle chunks bigger than 65535 bytes */
+ if (tempData->mainChunkSize/8 > 65535) {
+ av_log(enc->avctx, AV_LOG_ERROR,
+ "Warning, generated a frame too big (%d > 65535), "
+ "try using a smaller qscale value.\n",
+ tempData->mainChunkSize/8);
+ enc->lambda *= 1.5;
+ tempData->mainChunkSize = 0;
+ memset(tempData->used_option, 0, sizeof(tempData->used_option));
+ memset(tempData->codebooks.usedCB4, 0,
+ sizeof(tempData->codebooks.usedCB4));
+ memset(tempData->codebooks.usedCB2, 0,
+ sizeof(tempData->codebooks.usedCB2));
+
goto retry_encode;
}