mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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
This commit is contained in:
parent
aaa91aa00e
commit
905ef0d064
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
||||
|
47
libavcodec/vp56rac.c
Normal file
47
libavcodec/vp56rac.c
Normal file
@ -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);
|
||||
}
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user