comparison vp6.c @ 4348:d3dcf62d52c5 libavcodec

add support for another variant of vp6 with block coeffs coded separatly from other parts of the frame
author aurel
date Sun, 14 Jan 2007 18:17:15 +0000
parents 74b476185cd1
children 541b65620b5f
comparison
equal deleted inserted replaced
4347:a188a94e1b61 4348:d3dcf62d52c5
41 static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size, 41 static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
42 int *golden_frame) 42 int *golden_frame)
43 { 43 {
44 vp56_range_coder_t *c = &s->c; 44 vp56_range_coder_t *c = &s->c;
45 int parse_filter_info = 0; 45 int parse_filter_info = 0;
46 int coeff_offset = 0;
46 int vrt_shift = 0; 47 int vrt_shift = 0;
47 int sub_version; 48 int sub_version;
48 int rows, cols; 49 int rows, cols;
49 int res = 1; 50 int res = 1;
50 51 int separated_coeff = buf[0] & 1;
51 if (buf[0] & 1)
52 return 0;
53 52
54 s->frames[VP56_FRAME_CURRENT].key_frame = !(buf[0] & 0x80); 53 s->frames[VP56_FRAME_CURRENT].key_frame = !(buf[0] & 0x80);
55 vp56_init_dequant(s, (buf[0] >> 1) & 0x3F); 54 vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
56 55
57 if (s->frames[VP56_FRAME_CURRENT].key_frame) { 56 if (s->frames[VP56_FRAME_CURRENT].key_frame) {
58 sub_version = buf[1] >> 3; 57 sub_version = buf[1] >> 3;
59 if (sub_version > 8) 58 if (sub_version > 8)
60 return 0; 59 return 0;
61 if ((buf[1] & 0x06) != 0x06) 60 s->filter_header = buf[1] & 0x06;
62 return 0;
63 if (buf[1] & 1) { 61 if (buf[1] & 1) {
64 av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n"); 62 av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n");
65 return 0; 63 return 0;
64 }
65 if (separated_coeff || !s->filter_header) {
66 coeff_offset = BE_16(buf+2) - 2;
67 buf += 2;
68 buf_size -= 2;
66 } 69 }
67 70
68 rows = buf[2]; /* number of stored macroblock rows */ 71 rows = buf[2]; /* number of stored macroblock rows */
69 cols = buf[3]; /* number of stored macroblock cols */ 72 cols = buf[3]; /* number of stored macroblock cols */
70 /* buf[4] is number of displayed macroblock rows */ 73 /* buf[4] is number of displayed macroblock rows */
81 } 84 }
82 85
83 vp56_init_range_decoder(c, buf+6, buf_size-6); 86 vp56_init_range_decoder(c, buf+6, buf_size-6);
84 vp56_rac_gets(c, 2); 87 vp56_rac_gets(c, 2);
85 88
86 parse_filter_info = 1; 89 parse_filter_info = s->filter_header;
87 if (sub_version < 8) 90 if (sub_version < 8)
88 vrt_shift = 5; 91 vrt_shift = 5;
89 s->sub_version = sub_version; 92 s->sub_version = sub_version;
90 } else { 93 } else {
91 if (!s->sub_version) 94 if (!s->sub_version)
92 return 0; 95 return 0;
93 96
97 if (separated_coeff || !s->filter_header) {
98 coeff_offset = BE_16(buf+1) - 2;
99 buf += 2;
100 buf_size -= 2;
101 }
94 vp56_init_range_decoder(c, buf+1, buf_size-1); 102 vp56_init_range_decoder(c, buf+1, buf_size-1);
95 103
96 *golden_frame = vp56_rac_get(c); 104 *golden_frame = vp56_rac_get(c);
105 if (s->filter_header) {
97 s->deblock_filtering = vp56_rac_get(c); 106 s->deblock_filtering = vp56_rac_get(c);
98 if (s->deblock_filtering) 107 if (s->deblock_filtering)
99 vp56_rac_get(c); 108 vp56_rac_get(c);
100 if (s->sub_version > 7) 109 if (s->sub_version > 7)
101 parse_filter_info = vp56_rac_get(c); 110 parse_filter_info = vp56_rac_get(c);
111 }
102 } 112 }
103 113
104 if (parse_filter_info) { 114 if (parse_filter_info) {
105 if (vp56_rac_get(c)) { 115 if (vp56_rac_get(c)) {
106 s->filter_mode = 2; 116 s->filter_mode = 2;
116 else 126 else
117 s->filter_selection = 16; 127 s->filter_selection = 16;
118 } 128 }
119 129
120 vp56_rac_get(c); 130 vp56_rac_get(c);
131
132 if (coeff_offset) {
133 vp56_init_range_decoder(&s->cc, buf+coeff_offset,
134 buf_size-coeff_offset);
135 s->ccp = &s->cc;
136 } else {
137 s->ccp = &s->c;
138 }
139
121 return res; 140 return res;
122 } 141 }
123 142
124 static void vp6_coeff_order_table_init(vp56_context_t *s) 143 static void vp6_coeff_order_table_init(vp56_context_t *s)
125 { 144 {
257 } 276 }
258 } 277 }
259 278
260 static void vp6_parse_coeff(vp56_context_t *s) 279 static void vp6_parse_coeff(vp56_context_t *s)
261 { 280 {
262 vp56_range_coder_t *c = &s->c; 281 vp56_range_coder_t *c = s->ccp;
263 uint8_t *permute = s->scantable.permutated; 282 uint8_t *permute = s->scantable.permutated;
264 uint8_t *model, *model2, *model3; 283 uint8_t *model, *model2, *model3;
265 int coeff, sign, coeff_idx; 284 int coeff, sign, coeff_idx;
266 int b, i, cg, idx, ctx; 285 int b, i, cg, idx, ctx;
267 int pt = 0; /* plane type (0 for Y, 1 for U or V) */ 286 int pt = 0; /* plane type (0 for Y, 1 for U or V) */