40 #define VP6_MAX_HUFF_SIZE 12
48 int parse_filter_info = 0;
54 int separated_coeff = buf[0] & 1;
60 sub_version = buf[1] >> 3;
63 s->filter_header = buf[1] & 0x06;
68 if (separated_coeff || !s->filter_header) {
69 coeff_offset =
AV_RB16(buf+2) - 2;
83 if (!s->macroblocks ||
84 16*cols != s->avctx->coded_width ||
85 16*rows != s->avctx->coded_height) {
86 if (s->avctx->extradata_size == 0 &&
87 FFALIGN(s->avctx->width, 16) == 16 * cols &&
88 FFALIGN(s->avctx->height, 16) == 16 * rows) {
92 s->avctx->coded_width = 16 * cols;
93 s->avctx->coded_height = 16 * rows;
96 if (s->avctx->extradata_size == 1) {
97 s->avctx->width -= s->avctx->extradata[0] >> 4;
98 s->avctx->height -= s->avctx->extradata[0] & 0x0F;
107 parse_filter_info = s->filter_header;
110 s->sub_version = sub_version;
113 if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height)
116 if (separated_coeff || !s->filter_header) {
117 coeff_offset =
AV_RB16(buf+1) - 2;
124 if (s->filter_header) {
126 if (s->deblock_filtering)
128 if (s->sub_version > 7)
133 if (parse_filter_info) {
136 s->sample_variance_threshold =
vp56_rac_gets(c, 5) << vrt_shift;
143 if (s->sub_version > 7)
146 s->filter_selection = 16;
154 buf_size -= coeff_offset;
160 if (s->use_huffman) {
178 s->modelp->coeff_index_to_pos[0] = 0;
180 for (pos=1; pos<64; pos++)
181 if (s->modelp->coeff_reorder[pos] == i)
182 s->modelp->coeff_index_to_pos[idx++] = pos;
209 for (comp=0; comp<2; comp++) {
216 for (comp=0; comp<2; comp++)
217 for (node=0; node<7; node++)
221 for (comp=0; comp<2; comp++)
222 for (node=0; node<8; node++)
230 const Node *
a = va, *
b = vb;
231 return (a->
count - b->count)*16 + (b->sym - a->
sym);
242 for (i=0; i<size-1; i++) {
243 a = tmp[i].
count * coeff_model[i] >> 8;
244 b = tmp[i].
count * (255 - coeff_model[i]) >> 8;
245 nodes[map[2*i ]].
count = a + !
a;
246 nodes[map[2*i+1]].
count = b + !
b;
261 int node, cg, ctx, pos;
265 memset(def_prob, 0x80,
sizeof(def_prob));
267 for (pt=0; pt<2; pt++)
268 for (node=0; node<11; node++)
277 for (pos=1; pos<64; pos++)
283 for (cg=0; cg<2; cg++)
284 for (node=0; node<14; node++)
288 for (ct=0; ct<3; ct++)
289 for (pt=0; pt<2; pt++)
290 for (cg=0; cg<6; cg++)
291 for (node=0; node<11; node++)
299 if (s->use_huffman) {
300 for (pt=0; pt<2; pt++) {
307 for (ct=0; ct<3; ct++)
308 for (cg = 0; cg < 6; cg++)
311 &s->ract_vlc[pt][ct][cg]))
314 memset(s->nb_null, 0,
sizeof(s->nb_null));
317 for (pt=0; pt<2; pt++)
318 for (ctx=0; ctx<3; ctx++)
319 for (node=0; node<5; node++)
332 if (s->vector_candidate_pos < 2)
333 *vect = s->vector_candidate[0];
335 for (comp=0; comp<2; comp++) {
339 static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4};
340 for (i=0; i<
sizeof(prob_order); i++) {
341 int j = prob_order[i];
374 val = 6+val +
get_bits(&s->gb, 2+val);
384 int coeff, sign, coeff_idx;
388 for (b=0; b<6; b++) {
391 vlc_coeff = &s->dccv_vlc[
pt];
393 for (coeff_idx = 0;;) {
395 if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) {
396 s->nb_null[coeff_idx][
pt]--;
405 int pt = (coeff_idx >= 6);
412 }
else if (coeff == 11) {
419 coeff2 +=
get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11);
420 ct = 1 + (coeff2 > 1);
422 coeff2 = (coeff2 ^ -sign) + sign;
424 coeff2 *= s->dequant_ac;
426 s->block_coeff[
b][permute[idx]] = coeff2;
433 vlc_coeff = &s->ract_vlc[
pt][ct][cg];
443 uint8_t *model1, *model2, *model3;
444 int coeff, sign, coeff_idx;
445 int b, i, cg, idx, ctx;
448 for (b=0; b<6; b++) {
455 + s->above_blocks[s->above_block_idx[
b]].not_null_dc;
481 coeff = (coeff ^ -sign) + sign;
483 coeff *= s->dequant_ac;
485 s->block_coeff[
b][permute[idx]] =
coeff;
497 for (run=9, i=0; i<6; i++)
509 s->above_blocks[s->above_block_idx[
b]].not_null_dc = !!s->block_coeff[
b][0];
515 int sum = 0, square_sum = 0;
518 for (y=0; y<8; y+=2) {
519 for (x=0; x<8; x+=2) {
521 square_sum += src[x]*src[x];
525 return (16*square_sum - sum*sum) >> 8;
529 int delta,
const int16_t *weights)
533 for (y=0; y<8; y++) {
534 for (x=0; x<8; x++) {
535 dst[x] = av_clip_uint8(( src[x-delta ] * weights[0]
536 + src[x ] * weights[1]
537 + src[x+delta ] * weights[2]
538 + src[x+2*delta] * weights[3] + 64) >> 7);
546 int stride,
int h_weight,
int v_weight)
548 uint8_t *tmp = s->edge_emu_buffer+16;
549 s->h264chroma.put_h264_chroma_pixels_tab[0](tmp,
src,
stride, 9, h_weight, 0);
550 s->h264chroma.put_h264_chroma_pixels_tab[0](dst, tmp,
stride, 8, 0, v_weight);
554 int offset1,
int offset2,
int stride,
558 int x8 = mv.
x &
mask;
559 int y8 = mv.
y &
mask;
564 filter4 = s->filter_mode;
566 if (s->max_vector_length &&
567 (
FFABS(mv.
x) > s->max_vector_length ||
568 FFABS(mv.
y) > s->max_vector_length)) {
570 }
else if (s->sample_variance_threshold
572 < s->sample_variance_threshold)) {
578 if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) {
590 s->vp56dsp.vp6_filter_diag4(dst, src+offset1+((mv.
x^mv.
y)>>31), stride,
596 s->h264chroma.put_h264_chroma_pixels_tab[0](dst, src + offset1,
stride, 8, x8, y8);
617 s->alpha_context =
av_mallocz(
sizeof(VP56Context));
619 s->flip == -1, s->has_alpha);
628 s->deblock_filtering = 0;
647 if (s->alpha_context) {
660 for (pt=0; pt<2; pt++) {
663 for (ct=0; ct<3; ct++)
664 for (cg=0; cg<6; cg++)
674 .priv_data_size =
sizeof(VP56Context),
687 .priv_data_size =
sizeof(VP56Context),
700 .priv_data_size =
sizeof(VP56Context),