41 #define VP6_MAX_HUFF_SIZE 12
50 int parse_filter_info = 0;
56 int separated_coeff = buf[0] & 1;
62 sub_version = buf[1] >> 3;
71 coeff_offset =
AV_RB16(buf+2) - 2;
108 coeff_offset =
AV_RB16(buf+1) - 2;
124 if (parse_filter_info) {
145 buf_size -= coeff_offset;
171 for (pos=1; pos<64; pos++)
200 for (comp=0; comp<2; comp++) {
207 for (comp=0; comp<2; comp++)
208 for (node=0; node<7; node++)
212 for (comp=0; comp<2; comp++)
213 for (node=0; node<8; node++)
221 const Node *
a = va, *
b = vb;
222 return (a->
count - b->count)*16 + (b->sym - a->
sym);
226 const uint8_t *map,
unsigned size,
VLC *vlc)
233 for (i=0; i<size-1; i++) {
234 a = tmp[i].
count * coeff_model[i] >> 8;
235 b = tmp[i].
count * (255 - coeff_model[i]) >> 8;
236 nodes[map[2*i ]].
count = a + !
a;
237 nodes[map[2*i+1]].
count = b + !
b;
251 int node, cg, ctx, pos;
255 memset(def_prob, 0x80,
sizeof(def_prob));
257 for (pt=0; pt<2; pt++)
258 for (node=0; node<11; node++)
267 for (pos=1; pos<64; pos++)
273 for (cg=0; cg<2; cg++)
274 for (node=0; node<14; node++)
278 for (ct=0; ct<3; ct++)
279 for (pt=0; pt<2; pt++)
280 for (cg=0; cg<6; cg++)
281 for (node=0; node<11; node++)
290 for (pt=0; pt<2; pt++) {
297 for (ct=0; ct<3; ct++)
298 for (cg = 0; cg < 6; cg++)
307 for (pt=0; pt<2; pt++)
308 for (ctx=0; ctx<3; ctx++)
309 for (node=0; node<5; node++)
325 for (comp=0; comp<2; comp++) {
329 static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4};
330 for (i=0; i<
sizeof(prob_order); i++) {
331 int j = prob_order[i];
374 int coeff, sign, coeff_idx;
378 for (b=0; b<6; b++) {
383 for (coeff_idx = 0;;) {
385 if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) {
395 int pt = (coeff_idx >= 6);
402 }
else if (coeff == 11) {
409 coeff2 +=
get_bits(&s->
gb, coeff <= 9 ? coeff - 4 : 11);
410 ct = 1 + (coeff2 > 1);
412 coeff2 = (coeff2 ^ -sign) + sign;
433 uint8_t *model1, *model2, *model3;
434 int coeff, sign, coeff_idx;
435 int b, i, cg, idx, ctx;
438 for (b=0; b<6; b++) {
471 coeff = (coeff ^ -sign) + sign;
487 for (run=9, i=0; i<6; i++)
505 int sum = 0, square_sum = 0;
508 for (y=0; y<8; y+=2) {
509 for (x=0; x<8; x+=2) {
511 square_sum += src[x]*src[x];
515 return (16*square_sum - sum*sum) >> 8;
519 int delta,
const int16_t *weights)
523 for (y=0; y<8; y++) {
524 for (x=0; x<8; x++) {
525 dst[x] = av_clip_uint8(( src[x-delta ] * weights[0]
526 + src[x ] * weights[1]
527 + src[x+delta ] * weights[2]
528 + src[x+2*delta] * weights[3] + 64) >> 7);
536 int stride,
int h_weight,
int v_weight)
544 int offset1,
int offset2,
int stride,
548 int x8 = mv.
x &
mask;
549 int y8 = mv.
y &
mask;
568 if ((y8 && (offset2-offset1)*s->
flip<0) || (!y8 && offset1 > offset2)) {
617 for (pt=0; pt<2; pt++) {
620 for (ct=0; ct<3; ct++)
621 for (cg=0; cg<6; cg++)
av_cold int ff_vp56_free(AVCodecContext *avctx)
static void vp6_coeff_order_table_init(VP56Context *s)
uint8_t coeff_ract[2][3][6][11]
static const uint8_t vp6_ract_pct[3][2][6][11]
static av_cold int vp6_decode_init(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_HUFFMAN_FLAG_HNODE_FIRST
static const uint8_t vp6_runv_pct[2][14]
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[], const uint8_t *map, unsigned size, VLC *vlc)
uint8_t coeff_index_to_pos[64]
VP5 and VP6 compatible video decoder (common features)
int coded_width
Bitstream width / height, may be different from width/height if lowres enabled.
const uint8_t vp56_coeff_bias[]
static const int16_t vp6_block_copy_filter[17][8][4]
const VP56Tree vp56_pva_tree[]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const uint8_t vp6_def_fdv_vector_model[2][8]
uint8_t coeff_dccv[2][11]
uint8_t mb_types_stats[3][10][2]
VP56ParseCoeffModels parse_coeff_models
VP56mv vector_candidate[2]
const uint8_t vp56_coeff_bit_length[]
const VP56Tree vp56_pc_tree[]
const uint8_t vp56_coeff_parse_table[6][11]
static const uint8_t vp6_huff_coeff_map[]
int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, Node *nodes, HuffCmp cmp, int flags)
nodes size must be 2*nb_codes first nb_codes nodes.count must be set
struct vp56_context VP56Context
static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src, int offset1, int offset2, int stride, VP56mv mv, int mask, int select, int luma)
static const uint8_t vp6_def_runv_coeff_model[2][14]
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static const uint8_t vp6_def_coeff_reorder[]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int vp6_parse_coeff_models(VP56Context *s)
#define VP6_MAX_HUFF_SIZE
void(* vp6_filter_diag4)(uint8_t *dst, uint8_t *src, int stride, const int16_t *h_weights, const int16_t *v_weights)
VP56ParseCoeff parse_coeff
bitstream reader API header.
static const uint8_t vp6_dccv_pct[2][11]
static av_always_inline int vp56_rac_get_tree(VP56RangeCoder *c, const VP56Tree *tree, const uint8_t *probs)
uint8_t coeff_reorder[64]
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
VP56ParseVectorAdjustment parse_vector_adjustment
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_left(GetBitContext *gb)
static const uint16_t mask[17]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline int vp56_rac_get(VP56RangeCoder *c)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
void ff_vp56_init_dequant(VP56Context *s, int quantizer)
DCTELEM block_coeff[6][64]
VP56Macroblock * macroblocks
VP56ParseVectorModels parse_vector_models
h264_chroma_mc_func put_h264_chroma_pixels_tab[3]
h264 Chroma MC
static int vp6_huff_cmp(const void *va, const void *vb)
const uint8_t * vp56_coord_div
static void vp6_parse_vector_models(VP56Context *s)
const uint8_t vp56_def_mb_types_stats[3][10][2]
VP5 and VP6 compatible video decoder (common data)
static av_unused int vp56_rac_gets_nn(VP56RangeCoder *c, int bits)
static void vp6_filter_diag2(VP56Context *s, uint8_t *dst, uint8_t *src, int stride, int h_weight, int v_weight)
VP6 compatible video decoder.
static void vp6_default_models_init(VP56Context *s)
static const uint8_t vp6_huff_run_map[]
int width
picture width / height.
static void vp6_parse_coeff_huffman(VP56Context *s)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int sample_variance_threshold
VP56DefaultModelsInit default_models_init
#define vp56_rac_get_prob
static const VP56Tree vp6_pcr_tree[]
static void vp6_filter_hv4(uint8_t *dst, uint8_t *src, int stride, int delta, const int16_t *weights)
uint8_t coeff_runv[2][14]
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
static const int8_t mv[256][2]
static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, int *golden_frame)
static const uint8_t vp6_coeff_reorder_pct[]
main external API structure.
static void vp6_parse_coeff(VP56Context *s)
static void close(AVCodecParserContext *s)
static const uint8_t vp6_fdv_pct[2][8]
static const uint8_t vp6_coord_div[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned vp6_get_nb_null(VP56Context *s)
Read number of consecutive blocks with null DC or AC.
static const uint8_t vp6_sig_dct_pct[2][2]
uint8_t coeff_dcct[2][36][5]
static unsigned int get_bits1(GetBitContext *s)
static av_cold int vp6_decode_free(AVCodecContext *avctx)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
huffman tree builder and VLC generator
VP56ParseHeader parse_header
void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
av_cold void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
static const int vp6_dccv_lc[3][5][2]
uint8_t * edge_emu_buffer
static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
static const uint8_t vp6_coeff_groups[]
static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits)
static const uint8_t vp6_def_pdv_vector_model[2][7]
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static void permute(DCTELEM dst[64], const DCTELEM src[64], int perm)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
unsigned int nb_null[2][2]
const uint8_t vp56_b6to4[]
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
Log a generic warning message about a missing feature.
void ff_free_vlc(VLC *vlc)
static const uint8_t vp6_pdv_pct[2][7]
static int vp6_block_variance(uint8_t *src, int stride)