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) {
87 if (s->avctx->extradata_size == 1) {
88 s->avctx->width -= s->avctx->extradata[0] >> 4;
89 s->avctx->height -= s->avctx->extradata[0] & 0x0F;
97 parse_filter_info = s->filter_header;
100 s->sub_version = sub_version;
103 if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height)
106 if (separated_coeff || !s->filter_header) {
107 coeff_offset =
AV_RB16(buf+1) - 2;
114 if (s->filter_header) {
116 if (s->deblock_filtering)
118 if (s->sub_version > 7)
123 if (parse_filter_info) {
126 s->sample_variance_threshold =
vp56_rac_gets(c, 5) << vrt_shift;
133 if (s->sub_version > 7)
136 s->filter_selection = 16;
144 buf_size -= coeff_offset;
150 if (s->use_huffman) {
168 s->modelp->coeff_index_to_pos[0] = 0;
170 for (pos=1; pos<64; pos++)
171 if (s->modelp->coeff_reorder[pos] == i)
172 s->modelp->coeff_index_to_pos[idx++] = pos;
199 for (comp=0; comp<2; comp++) {
206 for (comp=0; comp<2; comp++)
207 for (node=0; node<7; node++)
211 for (comp=0; comp<2; comp++)
212 for (node=0; node<8; node++)
220 const Node *
a = va, *
b = vb;
221 return (a->
count - b->count)*16 + (b->sym - a->
sym);
232 for (i=0; i<size-1; i++) {
233 a = tmp[i].
count * coeff_model[i] >> 8;
234 b = tmp[i].
count * (255 - coeff_model[i]) >> 8;
235 nodes[map[2*i ]].
count = a + !
a;
236 nodes[map[2*i+1]].
count = b + !
b;
250 int node, cg, ctx, pos;
254 memset(def_prob, 0x80,
sizeof(def_prob));
256 for (pt=0; pt<2; pt++)
257 for (node=0; node<11; node++)
266 for (pos=1; pos<64; pos++)
272 for (cg=0; cg<2; cg++)
273 for (node=0; node<14; node++)
277 for (ct=0; ct<3; ct++)
278 for (pt=0; pt<2; pt++)
279 for (cg=0; cg<6; cg++)
280 for (node=0; node<11; node++)
288 if (s->use_huffman) {
289 for (pt=0; pt<2; pt++) {
296 for (ct=0; ct<3; ct++)
297 for (cg = 0; cg < 6; cg++)
300 &s->ract_vlc[pt][ct][cg]))
303 memset(s->nb_null, 0,
sizeof(s->nb_null));
306 for (pt=0; pt<2; pt++)
307 for (ctx=0; ctx<3; ctx++)
308 for (node=0; node<5; node++)
321 if (s->vector_candidate_pos < 2)
322 *vect = s->vector_candidate[0];
324 for (comp=0; comp<2; comp++) {
328 static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4};
329 for (i=0; i<
sizeof(prob_order); i++) {
330 int j = prob_order[i];
363 val = 6+val +
get_bits(&s->gb, 2+val);
373 int coeff, sign, coeff_idx;
377 for (b=0; b<6; b++) {
380 vlc_coeff = &s->dccv_vlc[
pt];
382 for (coeff_idx = 0;;) {
384 if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) {
385 s->nb_null[coeff_idx][
pt]--;
394 int pt = (coeff_idx >= 6);
395 run +=
get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3);
401 }
else if (coeff == 11) {
408 coeff2 +=
get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11);
409 ct = 1 + (coeff2 > 1);
411 coeff2 = (coeff2 ^ -sign) + sign;
413 coeff2 *= s->dequant_ac;
415 s->block_coeff[
b][permute[idx]] = coeff2;
422 vlc_coeff = &s->ract_vlc[
pt][ct][cg];
432 uint8_t *model1, *model2, *model3;
433 int coeff, sign, coeff_idx;
434 int b, i, cg, idx, ctx;
437 for (b=0; b<6; b++) {
444 + s->above_blocks[s->above_block_idx[
b]].not_null_dc;
470 coeff = (coeff ^ -sign) + sign;
472 coeff *= s->dequant_ac;
474 s->block_coeff[
b][permute[idx]] =
coeff;
486 for (run=9, i=0; i<6; i++)
498 s->above_blocks[s->above_block_idx[
b]].not_null_dc = !!s->block_coeff[
b][0];
504 int sum = 0, square_sum = 0;
507 for (y=0; y<8; y+=2) {
508 for (x=0; x<8; x+=2) {
510 square_sum += src[x]*src[x];
514 return (16*square_sum - sum*sum) >> 8;
518 int delta,
const int16_t *weights)
522 for (y=0; y<8; y++) {
523 for (x=0; x<8; x++) {
524 dst[x] = av_clip_uint8(( src[x-delta ] * weights[0]
525 + src[x ] * weights[1]
526 + src[x+delta ] * weights[2]
527 + src[x+2*delta] * weights[3] + 64) >> 7);
535 int stride,
int h_weight,
int v_weight)
537 uint8_t *tmp = s->edge_emu_buffer+16;
538 s->h264chroma.put_h264_chroma_pixels_tab[0](tmp, src,
stride, 9, h_weight, 0);
539 s->h264chroma.put_h264_chroma_pixels_tab[0](
dst, tmp,
stride, 8, 0, v_weight);
543 int offset1,
int offset2,
int stride,
547 int x8 = mv.
x &
mask;
548 int y8 = mv.
y &
mask;
553 filter4 = s->filter_mode;
555 if (s->max_vector_length &&
556 (
FFABS(mv.
x) > s->max_vector_length ||
557 FFABS(mv.
y) > s->max_vector_length)) {
559 }
else if (s->sample_variance_threshold
561 < s->sample_variance_threshold)) {
567 if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) {
579 s->vp56dsp.vp6_filter_diag4(dst, src+offset1+((mv.
x^mv.
y)>>31), stride,
585 s->h264chroma.put_h264_chroma_pixels_tab[0](
dst, src + offset1,
stride, 8, x8, y8);
605 s->alpha_context =
av_mallocz(
sizeof(VP56Context));
607 s->flip == -1, s->has_alpha);
609 for (i = 0; i < 6; ++i)
610 s->alpha_context->framep[i] = s->framep[i];
618 s->deblock_filtering = 0;
637 if (s->alpha_context) {
650 for (pt=0; pt<2; pt++) {
653 for (ct=0; ct<3; ct++)
654 for (cg=0; cg<6; cg++)
663 .priv_data_size =
sizeof(VP56Context),
676 .priv_data_size =
sizeof(VP56Context),
689 .priv_data_size =
sizeof(VP56Context),