[FFmpeg-devel] [PATCH 3/4] huffyuvdec: remove superfluous check

Christophe Gisquet christophe.gisquet at gmail.com
Wed Jun 4 22:48:58 CEST 2014


An invalid entry already has the property of having a negative number
of bits, so remove the check on the reserved value, and rearrange the
code as a consequence.

346800 decicycles in 422, 262079 runs, 65 skips
168197 decicycles in gray, 262077 runs, 67 skips
Overall time: 7.878s

319076 decicycles in 422, 262096 runs, 48 skips
159875 decicycles in gray, 262057 runs, 87 skips
Overall time: 7.394s
---
 libavcodec/huffyuvdec.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 01c01ce..dc803cd 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -586,13 +586,13 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
 
 
 #define GET_VLC_DUAL(dst0, dst1, name, gb, dtable, table1, table2,  \
-                     bits, max_depth, rsvd )                        \
+                     bits, max_depth)                               \
     do {                                                            \
         unsigned int index = SHOW_UBITS(name, gb, bits);            \
-        int          code  = dtable[index][0];                      \
-        int          n     = dtable[index][1];                      \
+        int          code, n = dtable[index][1];                    \
                                                                     \
-        if (code != rsvd && n>0) {                                  \
+        if (n>0) {                                                  \
+            code = dtable[index][0];                                \
             dst0 = code>>8;                                         \
             dst1 = code;                                            \
             LAST_SKIP_BITS(name, gb, n);                            \
@@ -609,8 +609,7 @@ static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
 #define READ_2PIX(dst0, dst1, plane1)\
     UPDATE_CACHE(re, &s->gb); \
     GET_VLC_DUAL(dst0, dst1, re, &s->gb, s->vlc[4+plane1].table, \
-                 s->vlc[0].table, s->vlc[plane1].table, \
-                 VLC_BITS, 3, 0xffff)
+                 s->vlc[0].table, s->vlc[plane1].table, VLC_BITS, 3)
 
 static void decode_422_bitstream(HYuvContext *s, int count)
 {
@@ -640,8 +639,7 @@ static void decode_422_bitstream(HYuvContext *s, int count)
 #define READ_2PIX_PLANE(dst0, dst1, plane) \
     UPDATE_CACHE(re, &s->gb); \
     GET_VLC_DUAL(dst0, dst1, re, &s->gb, s->vlc[4+plane].table, \
-                 s->vlc[plane].table, s->vlc[plane].table, \
-                 VLC_BITS, 3, 0xffff)
+                 s->vlc[plane].table, s->vlc[plane].table, VLC_BITS, 3)
 
 #define READ_2PIX_PLANE14(dst0, dst1, plane){\
     int16_t code = get_vlc2(&s->gb, s->vlc[4+plane].table, VLC_BITS, 1);\
-- 
1.8.0.msysgit.0



More information about the ffmpeg-devel mailing list