Mercurial > libavcodec.hg
annotate vp6.c @ 4925:ff4cd98bc90c libavcodec
simplify
| author | lorenm |
|---|---|
| date | Sun, 06 May 2007 09:17:50 +0000 |
| parents | 58f751086434 |
| children | 470601203f44 |
| rev | line source |
|---|---|
| 3695 | 1 /** |
| 2 * @file vp6.c | |
| 3 * VP6 compatible video decoder | |
| 4 * | |
| 5 * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> | |
| 6 * | |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
7 * This file is part of FFmpeg. |
|
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
8 * |
|
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
9 * FFmpeg is free software; you can redistribute it and/or |
| 3695 | 10 * modify it under the terms of the GNU Lesser General Public |
| 11 * License as published by the Free Software Foundation; either | |
| 12 * version 2.1 of the License, or (at your option) any later version. | |
| 13 * | |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
14 * FFmpeg is distributed in the hope that it will be useful, |
| 3695 | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 * Lesser General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU Lesser General Public | |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
20 * License along with FFmpeg; if not, write to the Free Software |
| 3695 | 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 4063 | 22 * |
| 23 * | |
| 24 * The VP6F decoder accept an optional 1 byte extradata. It is composed of: | |
| 25 * - upper 4bits: difference between encoded width and visible width | |
| 26 * - lower 4bits: difference between encoded height and visible height | |
| 3695 | 27 */ |
| 28 | |
| 29 #include <stdlib.h> | |
| 30 | |
| 31 #include "avcodec.h" | |
| 32 #include "dsputil.h" | |
| 33 #include "bitstream.h" | |
| 34 #include "mpegvideo.h" | |
| 35 | |
| 36 #include "vp56.h" | |
| 37 #include "vp56data.h" | |
| 38 #include "vp6data.h" | |
| 39 | |
| 40 | |
| 41 static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size, | |
| 42 int *golden_frame) | |
| 43 { | |
| 44 vp56_range_coder_t *c = &s->c; | |
| 4308 | 45 int parse_filter_info = 0; |
| 4348 | 46 int coeff_offset = 0; |
| 4308 | 47 int vrt_shift = 0; |
| 48 int sub_version; | |
| 3695 | 49 int rows, cols; |
| 50 int res = 1; | |
| 4348 | 51 int separated_coeff = buf[0] & 1; |
| 3695 | 52 |
| 4595 | 53 s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80); |
| 3695 | 54 vp56_init_dequant(s, (buf[0] >> 1) & 0x3F); |
| 55 | |
| 4595 | 56 if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
| 4308 | 57 sub_version = buf[1] >> 3; |
| 58 if (sub_version > 8) | |
| 59 return 0; | |
| 4348 | 60 s->filter_header = buf[1] & 0x06; |
| 3695 | 61 if (buf[1] & 1) { |
| 62 av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n"); | |
| 63 return 0; | |
| 64 } | |
| 4348 | 65 if (separated_coeff || !s->filter_header) { |
| 4364 | 66 coeff_offset = AV_RB16(buf+2) - 2; |
| 4348 | 67 buf += 2; |
| 68 buf_size -= 2; | |
| 69 } | |
| 3695 | 70 |
| 71 rows = buf[2]; /* number of stored macroblock rows */ | |
| 72 cols = buf[3]; /* number of stored macroblock cols */ | |
| 73 /* buf[4] is number of displayed macroblock rows */ | |
| 74 /* buf[5] is number of displayed macroblock cols */ | |
| 75 | |
| 76 if (16*cols != s->avctx->coded_width || | |
| 77 16*rows != s->avctx->coded_height) { | |
| 78 avcodec_set_dimensions(s->avctx, 16*cols, 16*rows); | |
|
4062
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
79 if (s->avctx->extradata_size == 1) { |
|
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
80 s->avctx->width -= s->avctx->extradata[0] >> 4; |
|
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
81 s->avctx->height -= s->avctx->extradata[0] & 0x0F; |
|
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
82 } |
| 3695 | 83 res = 2; |
| 84 } | |
| 85 | |
| 86 vp56_init_range_decoder(c, buf+6, buf_size-6); | |
| 87 vp56_rac_gets(c, 2); | |
| 88 | |
| 4348 | 89 parse_filter_info = s->filter_header; |
| 4308 | 90 if (sub_version < 8) |
| 91 vrt_shift = 5; | |
| 92 s->sub_version = sub_version; | |
| 3695 | 93 } else { |
| 4308 | 94 if (!s->sub_version) |
| 95 return 0; | |
| 96 | |
| 4348 | 97 if (separated_coeff || !s->filter_header) { |
| 4364 | 98 coeff_offset = AV_RB16(buf+1) - 2; |
| 4348 | 99 buf += 2; |
| 100 buf_size -= 2; | |
| 101 } | |
| 3695 | 102 vp56_init_range_decoder(c, buf+1, buf_size-1); |
| 103 | |
| 104 *golden_frame = vp56_rac_get(c); | |
| 4348 | 105 if (s->filter_header) { |
| 4349 | 106 s->deblock_filtering = vp56_rac_get(c); |
| 107 if (s->deblock_filtering) | |
| 108 vp56_rac_get(c); | |
| 109 if (s->sub_version > 7) | |
| 110 parse_filter_info = vp56_rac_get(c); | |
| 4348 | 111 } |
| 3695 | 112 } |
| 113 | |
| 114 if (parse_filter_info) { | |
| 115 if (vp56_rac_get(c)) { | |
| 116 s->filter_mode = 2; | |
| 4308 | 117 s->sample_variance_threshold = vp56_rac_gets(c, 5) << vrt_shift; |
| 3695 | 118 s->max_vector_length = 2 << vp56_rac_gets(c, 3); |
| 119 } else if (vp56_rac_get(c)) { | |
| 120 s->filter_mode = 1; | |
| 121 } else { | |
| 122 s->filter_mode = 0; | |
| 123 } | |
| 4308 | 124 if (s->sub_version > 7) |
| 125 s->filter_selection = vp56_rac_gets(c, 4); | |
| 126 else | |
| 127 s->filter_selection = 16; | |
| 3695 | 128 } |
| 129 | |
| 130 vp56_rac_get(c); | |
| 4348 | 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 | |
| 3695 | 140 return res; |
| 141 } | |
| 142 | |
| 143 static void vp6_coeff_order_table_init(vp56_context_t *s) | |
| 144 { | |
| 145 int i, pos, idx = 1; | |
| 146 | |
| 147 s->coeff_index_to_pos[0] = 0; | |
| 148 for (i=0; i<16; i++) | |
| 149 for (pos=1; pos<64; pos++) | |
| 150 if (s->coeff_reorder[pos] == i) | |
| 151 s->coeff_index_to_pos[idx++] = pos; | |
| 152 } | |
| 153 | |
| 154 static void vp6_default_models_init(vp56_context_t *s) | |
| 155 { | |
| 156 s->vector_model_dct[0] = 0xA2; | |
| 157 s->vector_model_dct[1] = 0xA4; | |
| 158 s->vector_model_sig[0] = 0x80; | |
| 159 s->vector_model_sig[1] = 0x80; | |
| 160 | |
| 161 memcpy(s->mb_types_stats, vp56_def_mb_types_stats, sizeof(s->mb_types_stats)); | |
| 162 memcpy(s->vector_model_fdv, vp6_def_fdv_vector_model, sizeof(s->vector_model_fdv)); | |
| 163 memcpy(s->vector_model_pdv, vp6_def_pdv_vector_model, sizeof(s->vector_model_pdv)); | |
| 164 memcpy(s->coeff_model_runv, vp6_def_runv_coeff_model, sizeof(s->coeff_model_runv)); | |
| 165 memcpy(s->coeff_reorder, vp6_def_coeff_reorder, sizeof(s->coeff_reorder)); | |
| 166 | |
| 167 vp6_coeff_order_table_init(s); | |
| 168 } | |
| 169 | |
| 170 static void vp6_parse_vector_models(vp56_context_t *s) | |
| 171 { | |
| 172 vp56_range_coder_t *c = &s->c; | |
| 173 int comp, node; | |
| 174 | |
| 175 for (comp=0; comp<2; comp++) { | |
| 176 if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][0])) | |
| 177 s->vector_model_dct[comp] = vp56_rac_gets_nn(c, 7); | |
| 178 if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][1])) | |
| 179 s->vector_model_sig[comp] = vp56_rac_gets_nn(c, 7); | |
| 180 } | |
| 181 | |
| 182 for (comp=0; comp<2; comp++) | |
| 183 for (node=0; node<7; node++) | |
| 184 if (vp56_rac_get_prob(c, vp6_pdv_pct[comp][node])) | |
| 185 s->vector_model_pdv[comp][node] = vp56_rac_gets_nn(c, 7); | |
| 186 | |
| 187 for (comp=0; comp<2; comp++) | |
| 188 for (node=0; node<8; node++) | |
| 189 if (vp56_rac_get_prob(c, vp6_fdv_pct[comp][node])) | |
| 190 s->vector_model_fdv[comp][node] = vp56_rac_gets_nn(c, 7); | |
| 191 } | |
| 192 | |
| 193 static void vp6_parse_coeff_models(vp56_context_t *s) | |
| 194 { | |
| 195 vp56_range_coder_t *c = &s->c; | |
| 196 int def_prob[11]; | |
| 197 int node, cg, ctx, pos; | |
| 198 int ct; /* code type */ | |
| 199 int pt; /* plane type (0 for Y, 1 for U or V) */ | |
| 200 | |
| 201 memset(def_prob, 0x80, sizeof(def_prob)); | |
| 202 | |
| 203 for (pt=0; pt<2; pt++) | |
| 204 for (node=0; node<11; node++) | |
| 205 if (vp56_rac_get_prob(c, vp6_dccv_pct[pt][node])) { | |
| 206 def_prob[node] = vp56_rac_gets_nn(c, 7); | |
| 207 s->coeff_model_dccv[pt][node] = def_prob[node]; | |
| 4595 | 208 } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
| 3695 | 209 s->coeff_model_dccv[pt][node] = def_prob[node]; |
| 210 } | |
| 211 | |
| 212 if (vp56_rac_get(c)) { | |
| 213 for (pos=1; pos<64; pos++) | |
| 214 if (vp56_rac_get_prob(c, vp6_coeff_reorder_pct[pos])) | |
| 215 s->coeff_reorder[pos] = vp56_rac_gets(c, 4); | |
| 216 vp6_coeff_order_table_init(s); | |
| 217 } | |
| 218 | |
| 219 for (cg=0; cg<2; cg++) | |
| 220 for (node=0; node<14; node++) | |
| 221 if (vp56_rac_get_prob(c, vp6_runv_pct[cg][node])) | |
| 222 s->coeff_model_runv[cg][node] = vp56_rac_gets_nn(c, 7); | |
| 223 | |
| 224 for (ct=0; ct<3; ct++) | |
| 225 for (pt=0; pt<2; pt++) | |
| 226 for (cg=0; cg<6; cg++) | |
| 227 for (node=0; node<11; node++) | |
| 228 if (vp56_rac_get_prob(c, vp6_ract_pct[ct][pt][cg][node])) { | |
| 229 def_prob[node] = vp56_rac_gets_nn(c, 7); | |
| 230 s->coeff_model_ract[pt][ct][cg][node] = def_prob[node]; | |
| 4595 | 231 } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
| 3695 | 232 s->coeff_model_ract[pt][ct][cg][node] = def_prob[node]; |
| 233 } | |
| 234 | |
| 235 /* coeff_model_dcct is a linear combination of coeff_model_dccv */ | |
| 236 for (pt=0; pt<2; pt++) | |
| 237 for (ctx=0; ctx<3; ctx++) | |
| 238 for (node=0; node<5; node++) | |
| 4594 | 239 s->coeff_model_dcct[pt][ctx][node] = av_clip(((s->coeff_model_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255); |
| 3695 | 240 } |
| 241 | |
| 3697 | 242 static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect) |
| 3695 | 243 { |
| 244 vp56_range_coder_t *c = &s->c; | |
| 245 int comp; | |
| 246 | |
| 3697 | 247 *vect = (vp56_mv_t) {0,0}; |
| 3695 | 248 if (s->vector_candidate_pos < 2) |
| 3697 | 249 *vect = s->vector_candidate[0]; |
| 3695 | 250 |
| 251 for (comp=0; comp<2; comp++) { | |
| 252 int i, delta = 0; | |
| 253 | |
| 254 if (vp56_rac_get_prob(c, s->vector_model_dct[comp])) { | |
| 255 static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4}; | |
| 256 for (i=0; i<sizeof(prob_order); i++) { | |
| 257 int j = prob_order[i]; | |
| 258 delta |= vp56_rac_get_prob(c, s->vector_model_fdv[comp][j])<<j; | |
| 259 } | |
| 260 if (delta & 0xF0) | |
| 261 delta |= vp56_rac_get_prob(c, s->vector_model_fdv[comp][3])<<3; | |
| 262 else | |
| 263 delta |= 8; | |
| 264 } else { | |
| 265 delta = vp56_rac_get_tree(c, vp56_pva_tree, | |
| 266 s->vector_model_pdv[comp]); | |
| 267 } | |
| 268 | |
| 269 if (delta && vp56_rac_get_prob(c, s->vector_model_sig[comp])) | |
| 270 delta = -delta; | |
| 271 | |
| 272 if (!comp) | |
| 3697 | 273 vect->x += delta; |
| 3695 | 274 else |
| 3697 | 275 vect->y += delta; |
| 3695 | 276 } |
| 277 } | |
| 278 | |
| 279 static void vp6_parse_coeff(vp56_context_t *s) | |
| 280 { | |
| 4348 | 281 vp56_range_coder_t *c = s->ccp; |
| 3695 | 282 uint8_t *permute = s->scantable.permutated; |
| 283 uint8_t *model, *model2, *model3; | |
| 284 int coeff, sign, coeff_idx; | |
| 285 int b, i, cg, idx, ctx; | |
| 286 int pt = 0; /* plane type (0 for Y, 1 for U or V) */ | |
| 287 | |
| 288 for (b=0; b<6; b++) { | |
| 289 int ct = 1; /* code type */ | |
| 290 int run = 1; | |
| 291 | |
| 292 if (b > 3) pt = 1; | |
| 293 | |
| 294 ctx = s->left_block[vp56_b6to4[b]].not_null_dc | |
| 295 + s->above_blocks[s->above_block_idx[b]].not_null_dc; | |
| 296 model = s->coeff_model_dccv[pt]; | |
| 297 model2 = s->coeff_model_dcct[pt][ctx]; | |
| 298 | |
| 299 for (coeff_idx=0; coeff_idx<64; ) { | |
| 300 if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) { | |
| 301 /* parse a coeff */ | |
| 302 if (vp56_rac_get_prob(c, model2[2])) { | |
| 303 if (vp56_rac_get_prob(c, model2[3])) { | |
| 304 idx = vp56_rac_get_tree(c, vp56_pc_tree, model); | |
| 305 coeff = vp56_coeff_bias[idx]; | |
| 306 for (i=vp56_coeff_bit_length[idx]; i>=0; i--) | |
| 307 coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i; | |
| 308 } else { | |
| 309 if (vp56_rac_get_prob(c, model2[4])) | |
| 310 coeff = 3 + vp56_rac_get_prob(c, model[5]); | |
| 311 else | |
| 312 coeff = 2; | |
| 313 } | |
| 314 ct = 2; | |
| 315 } else { | |
| 316 ct = 1; | |
| 317 coeff = 1; | |
| 318 } | |
| 319 sign = vp56_rac_get(c); | |
| 320 coeff = (coeff ^ -sign) + sign; | |
| 321 if (coeff_idx) | |
| 322 coeff *= s->dequant_ac; | |
| 323 idx = s->coeff_index_to_pos[coeff_idx]; | |
| 324 s->block_coeff[b][permute[idx]] = coeff; | |
| 325 run = 1; | |
| 326 } else { | |
| 327 /* parse a run */ | |
| 328 ct = 0; | |
| 4925 | 329 if (coeff_idx > 0) { |
| 3695 | 330 if (!vp56_rac_get_prob(c, model2[1])) |
| 331 break; | |
| 332 | |
| 333 model3 = s->coeff_model_runv[coeff_idx >= 6]; | |
| 334 run = vp56_rac_get_tree(c, vp6_pcr_tree, model3); | |
| 335 if (!run) | |
| 336 for (run=9, i=0; i<6; i++) | |
| 337 run += vp56_rac_get_prob(c, model3[i+8]) << i; | |
| 338 } | |
| 339 } | |
| 340 | |
| 341 cg = vp6_coeff_groups[coeff_idx+=run]; | |
| 342 model = model2 = s->coeff_model_ract[pt][ct][cg]; | |
| 343 } | |
| 4925 | 344 |
| 345 s->left_block[vp56_b6to4[b]].not_null_dc = | |
| 346 s->above_blocks[s->above_block_idx[b]].not_null_dc = !!s->block_coeff[b][0]; | |
| 3695 | 347 } |
| 348 } | |
| 349 | |
| 350 static int vp6_adjust(int v, int t) | |
| 351 { | |
| 352 int V = v, s = v >> 31; | |
| 353 V ^= s; | |
| 354 V -= s; | |
| 355 if (V-t-1 >= (unsigned)(t-1)) | |
| 356 return v; | |
| 357 V = 2*t - V; | |
| 358 V += s; | |
| 359 V ^= s; | |
| 360 return V; | |
| 361 } | |
| 362 | |
| 363 static int vp6_block_variance(uint8_t *src, int stride) | |
| 364 { | |
| 365 int sum = 0, square_sum = 0; | |
| 366 int y, x; | |
| 367 | |
| 368 for (y=0; y<8; y+=2) { | |
| 369 for (x=0; x<8; x+=2) { | |
| 370 sum += src[x]; | |
| 371 square_sum += src[x]*src[x]; | |
| 372 } | |
| 373 src += 2*stride; | |
| 374 } | |
| 4306 | 375 return (16*square_sum - sum*sum) >> 8; |
| 3695 | 376 } |
| 377 | |
| 378 static void vp6_filter_hv4(uint8_t *dst, uint8_t *src, int stride, | |
| 379 int delta, const int16_t *weights) | |
| 380 { | |
| 381 int x, y; | |
| 382 | |
| 383 for (y=0; y<8; y++) { | |
| 384 for (x=0; x<8; x++) { | |
| 4594 | 385 dst[x] = av_clip_uint8(( src[x-delta ] * weights[0] |
| 3695 | 386 + src[x ] * weights[1] |
| 387 + src[x+delta ] * weights[2] | |
| 388 + src[x+2*delta] * weights[3] + 64) >> 7); | |
| 389 } | |
| 390 src += stride; | |
| 391 dst += stride; | |
| 392 } | |
| 393 } | |
| 394 | |
| 395 static void vp6_filter_diag2(vp56_context_t *s, uint8_t *dst, uint8_t *src, | |
| 396 int stride, int h_weight, int v_weight) | |
| 397 { | |
| 398 uint8_t *tmp = s->edge_emu_buffer+16; | |
| 4921 | 399 s->dsp.put_h264_chroma_pixels_tab[0](tmp, src, stride, 9, h_weight, 0); |
| 400 s->dsp.put_h264_chroma_pixels_tab[0](dst, tmp, stride, 8, 0, v_weight); | |
| 3695 | 401 } |
| 402 | |
| 403 static void vp6_filter_diag4(uint8_t *dst, uint8_t *src, int stride, | |
| 404 const int16_t *h_weights,const int16_t *v_weights) | |
| 405 { | |
| 406 int x, y; | |
| 407 int tmp[8*11]; | |
| 408 int *t = tmp; | |
| 409 | |
| 410 src -= stride; | |
| 411 | |
| 412 for (y=0; y<11; y++) { | |
| 413 for (x=0; x<8; x++) { | |
| 4594 | 414 t[x] = av_clip_uint8(( src[x-1] * h_weights[0] |
| 3695 | 415 + src[x ] * h_weights[1] |
| 416 + src[x+1] * h_weights[2] | |
| 417 + src[x+2] * h_weights[3] + 64) >> 7); | |
| 418 } | |
| 419 src += stride; | |
| 420 t += 8; | |
| 421 } | |
| 422 | |
| 423 t = tmp + 8; | |
| 424 for (y=0; y<8; y++) { | |
| 425 for (x=0; x<8; x++) { | |
| 4594 | 426 dst[x] = av_clip_uint8(( t[x-8 ] * v_weights[0] |
| 3695 | 427 + t[x ] * v_weights[1] |
| 428 + t[x+8 ] * v_weights[2] | |
| 429 + t[x+16] * v_weights[3] + 64) >> 7); | |
| 430 } | |
| 431 dst += stride; | |
| 432 t += 8; | |
| 433 } | |
| 434 } | |
| 435 | |
| 436 static void vp6_filter(vp56_context_t *s, uint8_t *dst, uint8_t *src, | |
| 437 int offset1, int offset2, int stride, | |
| 438 vp56_mv_t mv, int mask, int select, int luma) | |
| 439 { | |
| 440 int filter4 = 0; | |
| 441 int x8 = mv.x & mask; | |
| 442 int y8 = mv.y & mask; | |
| 443 | |
| 444 if (luma) { | |
| 445 x8 *= 2; | |
| 446 y8 *= 2; | |
| 447 filter4 = s->filter_mode; | |
| 448 if (filter4 == 2) { | |
| 449 if (s->max_vector_length && | |
| 4001 | 450 (FFABS(mv.x) > s->max_vector_length || |
| 451 FFABS(mv.y) > s->max_vector_length)) { | |
| 3695 | 452 filter4 = 0; |
| 4308 | 453 } else if (s->sample_variance_threshold |
| 454 && (vp6_block_variance(src+offset1, stride) | |
| 3695 | 455 < s->sample_variance_threshold)) { |
| 456 filter4 = 0; | |
| 457 } | |
| 458 } | |
| 459 } | |
| 460 | |
| 461 if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) { | |
| 462 offset1 = offset2; | |
| 463 } | |
| 464 | |
| 465 if (filter4) { | |
| 466 if (!y8) { /* left or right combine */ | |
| 467 vp6_filter_hv4(dst, src+offset1, stride, 1, | |
| 468 vp6_block_copy_filter[select][x8]); | |
| 469 } else if (!x8) { /* above or below combine */ | |
| 470 vp6_filter_hv4(dst, src+offset1, stride, stride, | |
| 471 vp6_block_copy_filter[select][y8]); | |
| 4922 | 472 } else { |
| 473 vp6_filter_diag4(dst, src+offset1 + ((mv.x^mv.y)>>31), stride, | |
| 3695 | 474 vp6_block_copy_filter[select][x8], |
| 475 vp6_block_copy_filter[select][y8]); | |
| 476 } | |
| 477 } else { | |
| 4921 | 478 if (!x8 || !y8) { |
| 479 s->dsp.put_h264_chroma_pixels_tab[0](dst, src+offset1, stride, 8, x8, y8); | |
| 4922 | 480 } else { |
| 481 vp6_filter_diag2(s, dst, src+offset1 + ((mv.x^mv.y)>>31), stride, x8, y8); | |
| 3695 | 482 } |
| 483 } | |
| 484 } | |
| 485 | |
| 486 static int vp6_decode_init(AVCodecContext *avctx) | |
| 487 { | |
| 488 vp56_context_t *s = avctx->priv_data; | |
| 489 | |
| 490 vp56_init(s, avctx, avctx->codec->id == CODEC_ID_VP6); | |
| 491 s->vp56_coord_div = vp6_coord_div; | |
| 492 s->parse_vector_adjustment = vp6_parse_vector_adjustment; | |
| 493 s->adjust = vp6_adjust; | |
| 494 s->filter = vp6_filter; | |
| 495 s->parse_coeff = vp6_parse_coeff; | |
| 496 s->default_models_init = vp6_default_models_init; | |
| 497 s->parse_vector_models = vp6_parse_vector_models; | |
| 498 s->parse_coeff_models = vp6_parse_coeff_models; | |
| 499 s->parse_header = vp6_parse_header; | |
| 500 | |
| 501 return 0; | |
| 502 } | |
| 503 | |
| 504 AVCodec vp6_decoder = { | |
| 505 "vp6", | |
| 506 CODEC_TYPE_VIDEO, | |
| 507 CODEC_ID_VP6, | |
| 508 sizeof(vp56_context_t), | |
| 509 vp6_decode_init, | |
| 510 NULL, | |
| 511 vp56_free, | |
| 512 vp56_decode_frame, | |
| 4910 | 513 CODEC_CAP_DR1, |
| 3695 | 514 }; |
| 515 | |
| 516 /* flash version, not flipped upside-down */ | |
| 517 AVCodec vp6f_decoder = { | |
| 518 "vp6f", | |
| 519 CODEC_TYPE_VIDEO, | |
| 520 CODEC_ID_VP6F, | |
| 521 sizeof(vp56_context_t), | |
| 522 vp6_decode_init, | |
| 523 NULL, | |
| 524 vp56_free, | |
| 525 vp56_decode_frame, | |
| 4910 | 526 CODEC_CAP_DR1, |
| 3695 | 527 }; |
