aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vp3.c
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2005-05-17 23:39:23 +0000
committerMike Melanson <mike@multimedia.cx>2005-05-17 23:39:23 +0000
commit0ad72bdd5cb493df78c660b9859a8b890018926a (patch)
tree4d51672a0f7acee0ede85c9376847075dd42f092 /libavcodec/vp3.c
parent4935b1b9eba5ee1f9bf7f85e388ce7001f50ab6b (diff)
downloadffmpeg-0ad72bdd5cb493df78c660b9859a8b890018926a.tar.gz
use VLCs for in place of get_fragment_run_length(), get_mode_code(), and
get_motion_vector_vlc() Originally committed as revision 4266 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/vp3.c')
-rw-r--r--libavcodec/vp3.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 75877860c0..ad72965e4c 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -15,17 +15,17 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * VP3 Video Decoder by Mike Melanson (melanson@pcisys.net)
- * For more information about the VP3 coding process, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * Theora decoder by Alex Beregszaszi
- *
*/
/**
* @file vp3.c
* On2 VP3 Video Decoder
+ *
+ * VP3 Video Decoder by Mike Melanson (mike at multimedia.cx)
+ * For more information about the VP3 coding process, visit:
+ * http://multimedia.cx/
+ *
+ * Theora decoder by Alex Beregszaszi
*/
#include <stdio.h>
@@ -271,6 +271,11 @@ typedef struct Vp3DecodeContext {
VLC ac_vlc_3[16];
VLC ac_vlc_4[16];
+ VLC superblock_run_length_vlc;
+ VLC fragment_run_length_vlc;
+ VLC mode_code_vlc;
+ VLC motion_vector_vlc;
+
/* these arrays need to be on 16-byte boundaries since SSE2 operations
* index into them */
int16_t __align16 intra_y_dequant[64];
@@ -1274,7 +1279,12 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
* that cares about the fragment coding runs */
if (current_run == 0) {
bit ^= 1;
+#if 1
+ current_run = get_vlc2(gb,
+ s->fragment_run_length_vlc.table, 5, 2) + 1;
+#else
current_run = get_fragment_run_length(gb);
+#endif
}
if (bit) {
@@ -1404,7 +1414,14 @@ static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
if (scheme == 7)
coding_mode = get_bits(gb, 3);
else
+{
+#if 1
+ coding_mode = ModeAlphabet[scheme]
+ [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];
+#else
coding_mode = ModeAlphabet[scheme][get_mode_code(gb)];
+#endif
+}
s->macroblock_coding[current_macroblock] = coding_mode;
for (k = 0; k < 6; k++) {
@@ -1491,8 +1508,13 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
case MODE_GOLDEN_MV:
/* all 6 fragments use the same motion vector */
if (coding_mode == 0) {
+#if 1
+ motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+#else
motion_x[0] = get_motion_vector_vlc(gb);
motion_y[0] = get_motion_vector_vlc(gb);
+#endif
} else {
motion_x[0] = get_motion_vector_fixed(gb);
motion_y[0] = get_motion_vector_fixed(gb);
@@ -1518,8 +1540,13 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
motion_x[4] = motion_y[4] = 0;
for (k = 0; k < 4; k++) {
if (coding_mode == 0) {
+#if 1
+ motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+ motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
+#else
motion_x[k] = get_motion_vector_vlc(gb);
motion_y[k] = get_motion_vector_vlc(gb);
+#endif
} else {
motion_x[k] = get_motion_vector_fixed(gb);
motion_y[k] = get_motion_vector_fixed(gb);
@@ -2496,13 +2523,8 @@ static int vp3_decode_init(AVCodecContext *avctx)
s->version = 1;
s->avctx = avctx;
-#if 0
- s->width = avctx->width;
- s->height = avctx->height;
-#else
s->width = (avctx->width + 15) & 0xFFFFFFF0;
s->height = (avctx->height + 15) & 0xFFFFFFF0;
-#endif
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 0;
if(avctx->idct_algo==FF_IDCT_AUTO)
@@ -2608,6 +2630,18 @@ static int vp3_decode_init(AVCodecContext *avctx)
&ac_bias_3[i][0][0], 4, 2, 0);
}
+ init_vlc(&s->fragment_run_length_vlc, 5, 31,
+ &fragment_run_length_vlc_table[0][1], 4, 2,
+ &fragment_run_length_vlc_table[0][0], 4, 2, 0);
+
+ init_vlc(&s->mode_code_vlc, 3, 8,
+ &mode_code_vlc_table[0][1], 2, 1,
+ &mode_code_vlc_table[0][0], 2, 1, 0);
+
+ init_vlc(&s->motion_vector_vlc, 6, 63,
+ &motion_vector_vlc_table[0][1], 2, 1,
+ &motion_vector_vlc_table[0][0], 2, 1, 0);
+
/* work out the block mapping tables */
s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));