avcodec/h264_cavlc: Set valid qscale value in ff_h264_decode_mb_cavlc()
authorXiaohan Wang <xhwang@chromium.org>
Sat, 3 Feb 2018 09:43:35 +0000 (01:43 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 14 Feb 2018 00:06:37 +0000 (01:06 +0100)
When ff_h264_decode_mb_cavlc() failed due to wrong sl->qscale values,
e.g. dquant out of range, set the qscale to be a valid value before
returning -1 and exiting the function. The qscale value can be used
later e.g. in loop filter.

BUG=806122

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/h264_cavlc.c

index 187b1c6..5e6a203 100644 (file)
@@ -1111,6 +1111,7 @@ decode_intra_mb:
             else                sl->qscale -= max_qp+1;
             if (((unsigned)sl->qscale) > max_qp){
                 av_log(h->avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, sl->mb_x, sl->mb_y);
             else                sl->qscale -= max_qp+1;
             if (((unsigned)sl->qscale) > max_qp){
                 av_log(h->avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, sl->mb_x, sl->mb_y);
+                sl->qscale = max_qp;
                 return -1;
             }
         }
                 return -1;
             }
         }