[FFmpeg-cvslog] r24701 - in trunk/libavcodec: Makefile vp5.c vp56.h vp56rac.c vp6.c vp8.c

darkshikari subversion
Thu Aug 5 01:04:05 CEST 2010


Author: darkshikari
Date: Thu Aug  5 01:04:05 2010
New Revision: 24701

Log:
VP5/6/8: eliminate CABAC dependency
Create a custom table for VP5/6/8's renorm to avoid depending on H.264's.
Saves one instruction in the arithmetic decoder as well.

Added:
   trunk/libavcodec/vp56rac.c
Modified:
   trunk/libavcodec/Makefile
   trunk/libavcodec/vp5.c
   trunk/libavcodec/vp56.h
   trunk/libavcodec/vp6.c
   trunk/libavcodec/vp8.c

Modified: trunk/libavcodec/Makefile
==============================================================================
--- trunk/libavcodec/Makefile	Thu Aug  5 00:34:43 2010	(r24700)
+++ trunk/libavcodec/Makefile	Thu Aug  5 01:04:05 2010	(r24701)
@@ -376,10 +376,10 @@ OBJS-$(CONFIG_VORBIS_ENCODER)          +
                                           vorbis_data.o
 OBJS-$(CONFIG_VP3_DECODER)             += vp3.o vp3dsp.o
 OBJS-$(CONFIG_VP5_DECODER)             += vp5.o vp56.o vp56data.o vp56dsp.o \
-                                          vp3dsp.o cabac.o
+                                          vp3dsp.o vp56rac.o
 OBJS-$(CONFIG_VP6_DECODER)             += vp6.o vp56.o vp56data.o vp56dsp.o \
-                                          vp3dsp.o vp6dsp.o huffman.o cabac.o
-OBJS-$(CONFIG_VP8_DECODER)             += vp8.o vp8dsp.o cabac.o
+                                          vp3dsp.o vp6dsp.o huffman.o vp56rac.o
+OBJS-$(CONFIG_VP8_DECODER)             += vp8.o vp8dsp.o vp56rac.o
 OBJS-$(CONFIG_VQA_DECODER)             += vqavideo.o
 OBJS-$(CONFIG_WAVPACK_DECODER)         += wavpack.o
 OBJS-$(CONFIG_WMAPRO_DECODER)          += wmaprodec.o wma.o

Modified: trunk/libavcodec/vp5.c
==============================================================================
--- trunk/libavcodec/vp5.c	Thu Aug  5 00:34:43 2010	(r24700)
+++ trunk/libavcodec/vp5.c	Thu Aug  5 01:04:05 2010	(r24701)
@@ -39,7 +39,7 @@ static int vp5_parse_header(VP56Context 
     VP56RangeCoder *c = &s->c;
     int rows, cols;
 
-    vp56_init_range_decoder(&s->c, buf, buf_size);
+    ff_vp56_init_range_decoder(&s->c, buf, buf_size);
     s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c);
     vp56_rac_get(c);
     ff_vp56_init_dequant(s, vp56_rac_gets(c, 6));

Modified: trunk/libavcodec/vp56.h
==============================================================================
--- trunk/libavcodec/vp56.h	Thu Aug  5 00:34:43 2010	(r24700)
+++ trunk/libavcodec/vp56.h	Thu Aug  5 01:04:05 2010	(r24701)
@@ -181,19 +181,12 @@ int ff_vp56_decode_frame(AVCodecContext 
  * vp56 specific range coder implementation
  */
 
-static inline void vp56_init_range_decoder(VP56RangeCoder *c,
-                                           const uint8_t *buf, int buf_size)
-{
-    c->high = 255;
-    c->bits = -8;
-    c->buffer = buf;
-    c->end = buf + buf_size;
-    c->code_word = bytestream_get_be16(&c->buffer);
-}
+extern const uint8_t ff_vp56_norm_shift[256];
+void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size);
 
 static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
 {
-    int shift = ff_h264_norm_shift[c->high] - 1;
+    int shift = ff_vp56_norm_shift[c->high];
     int bits = c->bits;
     unsigned int code_word = c->code_word;
 

Added: trunk/libavcodec/vp56rac.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/libavcodec/vp56rac.c	Thu Aug  5 01:04:05 2010	(r24701)
@@ -0,0 +1,47 @@
+/*
+ * VP5/6/8 decoder
+ * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "vp56.h"
+
+const uint8_t ff_vp56_norm_shift[256]= {
+ 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,
+ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+};
+
+void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
+{
+    c->high = 255;
+    c->bits = -8;
+    c->buffer = buf;
+    c->end = buf + buf_size;
+    c->code_word = bytestream_get_be16(&c->buffer);
+}

Modified: trunk/libavcodec/vp6.c
==============================================================================
--- trunk/libavcodec/vp6.c	Thu Aug  5 00:34:43 2010	(r24700)
+++ trunk/libavcodec/vp6.c	Thu Aug  5 01:04:05 2010	(r24701)
@@ -87,7 +87,7 @@ static int vp6_parse_header(VP56Context 
             res = 2;
         }
 
-        vp56_init_range_decoder(c, buf+6, buf_size-6);
+        ff_vp56_init_range_decoder(c, buf+6, buf_size-6);
         vp56_rac_gets(c, 2);
 
         parse_filter_info = s->filter_header;
@@ -103,7 +103,7 @@ static int vp6_parse_header(VP56Context 
             buf += 2;
             buf_size -= 2;
         }
-        vp56_init_range_decoder(c, buf+1, buf_size-1);
+        ff_vp56_init_range_decoder(c, buf+1, buf_size-1);
 
         *golden_frame = vp56_rac_get(c);
         if (s->filter_header) {
@@ -143,7 +143,7 @@ static int vp6_parse_header(VP56Context 
             s->parse_coeff = vp6_parse_coeff_huffman;
             init_get_bits(&s->gb, buf, buf_size<<3);
         } else {
-            vp56_init_range_decoder(&s->cc, buf, buf_size);
+            ff_vp56_init_range_decoder(&s->cc, buf, buf_size);
             s->ccp = &s->cc;
         }
     } else {

Modified: trunk/libavcodec/vp8.c
==============================================================================
--- trunk/libavcodec/vp8.c	Thu Aug  5 00:34:43 2010	(r24700)
+++ trunk/libavcodec/vp8.c	Thu Aug  5 01:04:05 2010	(r24701)
@@ -305,11 +305,11 @@ static int setup_partitions(VP8Context *
         if (buf_size - size < 0)
             return -1;
 
-        vp56_init_range_decoder(&s->coeff_partition[i], buf, size);
+        ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, size);
         buf      += size;
         buf_size -= size;
     }
-    vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size);
+    ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size);
 
     return 0;
 }
@@ -445,7 +445,7 @@ static int decode_frame_header(VP8Contex
             return ret;
     }
 
-    vp56_init_range_decoder(c, buf, header_size);
+    ff_vp56_init_range_decoder(c, buf, header_size);
     buf      += header_size;
     buf_size -= header_size;
 



More information about the ffmpeg-cvslog mailing list