]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_cavlc.c
nvenc: Allow different const qps for I, P and B frames
[ffmpeg] / libavcodec / h264_cavlc.c
index 4fa2de01844aed07f11845486220208b6cd5a171..c11e211bd894b39908a47f7766628f524d8a82b1 100644 (file)
@@ -32,7 +32,7 @@
 #include "h264dec.h"
 #include "h264_mvpred.h"
 #include "h264data.h"
-#include "golomb.h"
+#include "golomb_legacy.h"
 #include "mpegutils.h"
 
 #include <assert.h>
@@ -579,8 +579,10 @@ static int decode_residual(const H264Context *h, H264SliceContext *sl,
         for(i=1;i<total_coeff && zeros_left > 0;i++) { \
             if(zeros_left < 7) \
                 run_before= get_vlc2(gb, run_vlc[zeros_left - 1].table, RUN_VLC_BITS, 1); \
-            else \
+            else {\
                 run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); \
+                run_before = FFMIN(zeros_left, run_before);\
+            }\
             zeros_left -= run_before; \
             scantable -= 1 + run_before; \
             ((type*)block)[*scantable]= level[i]; \
@@ -594,8 +596,10 @@ static int decode_residual(const H264Context *h, H264SliceContext *sl,
         for(i=1;i<total_coeff && zeros_left > 0;i++) { \
             if(zeros_left < 7) \
                 run_before= get_vlc2(gb, run_vlc[zeros_left - 1].table, RUN_VLC_BITS, 1); \
-            else \
+            else {\
                 run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); \
+                run_before = FFMIN(zeros_left, run_before);\
+            }\
             zeros_left -= run_before; \
             scantable -= 1 + run_before; \
             ((type*)block)[*scantable]= ((int)(level[i] * qmul[*scantable] + 32))>>6; \