diff options
author | Jason Garrett-Glaser <darkshikari@gmail.com> | 2010-08-04 23:04:05 +0000 |
---|---|---|
committer | Jason Garrett-Glaser <darkshikari@gmail.com> | 2010-08-04 23:04:05 +0000 |
commit | 905ef0d064d8fb6a349b071c686c4a7fa5a99e07 (patch) | |
tree | 3ae8bf7599a298afaaa2b80cf196e8b4cf9d5033 | |
parent | aaa91aa00edddb097cce7fa769db6643de37df11 (diff) | |
download | ffmpeg-905ef0d064d8fb6a349b071c686c4a7fa5a99e07.tar.gz |
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.
Originally committed as revision 24701 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/Makefile | 6 | ||||
-rw-r--r-- | libavcodec/vp5.c | 2 | ||||
-rw-r--r-- | libavcodec/vp56.h | 13 | ||||
-rw-r--r-- | libavcodec/vp56rac.c | 47 | ||||
-rw-r--r-- | libavcodec/vp6.c | 6 | ||||
-rw-r--r-- | libavcodec/vp8.c | 6 |
6 files changed, 60 insertions, 20 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 2492e57e59..d4bdad5a89 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -376,10 +376,10 @@ OBJS-$(CONFIG_VORBIS_ENCODER) += vorbis_enc.o vorbis.o \ 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 diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 489bcac828..7b3a487f1b 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -39,7 +39,7 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, 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)); diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 7ea7d77817..50a39f75bc 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -181,19 +181,12 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, * 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; diff --git a/libavcodec/vp56rac.c b/libavcodec/vp56rac.c new file mode 100644 index 0000000000..752a42bc6b --- /dev/null +++ b/libavcodec/vp56rac.c @@ -0,0 +1,47 @@ +/* + * VP5/6/8 decoder + * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@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); +} diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 9708fbe85c..cc74cf48ea 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -87,7 +87,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, 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 *s, const uint8_t *buf, int buf_size, 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, const uint8_t *buf, int buf_size, 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 { diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 66e8c9d554..329e6053f8 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -305,11 +305,11 @@ static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size) 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(VP8Context *s, const uint8_t *buf, int buf_size) 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; |