00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00030 #include "avcodec.h"
00031 #include "dsputil.h"
00032 #include "mpegvideo.h"
00033 #include "msmpeg4.h"
00034 #include "libavutil/x86/asm.h"
00035 #include "h263.h"
00036 #include "mpeg4video.h"
00037 #include "msmpeg4data.h"
00038 #include "vc1data.h"
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #define DC_VLC_BITS 9
00050 #define V2_INTRA_CBPC_VLC_BITS 3
00051 #define V2_MB_TYPE_VLC_BITS 7
00052 #define MV_VLC_BITS 9
00053 #define V2_MV_VLC_BITS 9
00054 #define TEX_VLC_BITS 9
00055
00056 #define DEFAULT_INTER_INDEX 3
00057
00058
00059
00060 static av_cold void init_h263_dc_for_msmpeg4(void)
00061 {
00062 int level, uni_code, uni_len;
00063
00064 for(level=-256; level<256; level++){
00065 int size, v, l;
00066
00067 size = 0;
00068 v = abs(level);
00069 while (v) {
00070 v >>= 1;
00071 size++;
00072 }
00073
00074 if (level < 0)
00075 l= (-level) ^ ((1 << size) - 1);
00076 else
00077 l= level;
00078
00079
00080 uni_code= ff_mpeg4_DCtab_lum[size][0];
00081 uni_len = ff_mpeg4_DCtab_lum[size][1];
00082 uni_code ^= (1<<uni_len)-1;
00083
00084 if (size > 0) {
00085 uni_code<<=size; uni_code|=l;
00086 uni_len+=size;
00087 if (size > 8){
00088 uni_code<<=1; uni_code|=1;
00089 uni_len++;
00090 }
00091 }
00092 ff_v2_dc_lum_table[level + 256][0] = uni_code;
00093 ff_v2_dc_lum_table[level + 256][1] = uni_len;
00094
00095
00096 uni_code= ff_mpeg4_DCtab_chrom[size][0];
00097 uni_len = ff_mpeg4_DCtab_chrom[size][1];
00098 uni_code ^= (1<<uni_len)-1;
00099
00100 if (size > 0) {
00101 uni_code<<=size; uni_code|=l;
00102 uni_len+=size;
00103 if (size > 8){
00104 uni_code<<=1; uni_code|=1;
00105 uni_len++;
00106 }
00107 }
00108 ff_v2_dc_chroma_table[level + 256][0] = uni_code;
00109 ff_v2_dc_chroma_table[level + 256][1] = uni_len;
00110
00111 }
00112 }
00113
00114 av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
00115 {
00116 static int initialized=0;
00117
00118 switch(s->msmpeg4_version){
00119 case 1:
00120 case 2:
00121 s->y_dc_scale_table=
00122 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00123 break;
00124 case 3:
00125 if(s->workaround_bugs){
00126 s->y_dc_scale_table= ff_old_ff_y_dc_scale_table;
00127 s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
00128 } else{
00129 s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table;
00130 s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
00131 }
00132 break;
00133 case 4:
00134 case 5:
00135 s->y_dc_scale_table= ff_wmv1_y_dc_scale_table;
00136 s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
00137 break;
00138 #if CONFIG_VC1_DECODER
00139 case 6:
00140 s->y_dc_scale_table= ff_wmv3_dc_scale_table;
00141 s->c_dc_scale_table= ff_wmv3_dc_scale_table;
00142 break;
00143 #endif
00144
00145 }
00146
00147
00148 if(s->msmpeg4_version>=4){
00149 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_wmv1_scantable[1]);
00150 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_wmv1_scantable[2]);
00151 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_wmv1_scantable[3]);
00152 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_wmv1_scantable[0]);
00153 }
00154
00155
00156 if(!initialized){
00157 initialized=1;
00158
00159 init_h263_dc_for_msmpeg4();
00160 }
00161 }
00162
00163
00164 int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr)
00165 {
00166 int xy, wrap, pred, a, b, c;
00167
00168 xy = s->block_index[n];
00169 wrap = s->b8_stride;
00170
00171
00172
00173
00174 a = s->coded_block[xy - 1 ];
00175 b = s->coded_block[xy - 1 - wrap];
00176 c = s->coded_block[xy - wrap];
00177
00178 if (b == c) {
00179 pred = a;
00180 } else {
00181 pred = c;
00182 }
00183
00184
00185 *coded_block_ptr = &s->coded_block[xy];
00186
00187 return pred;
00188 }
00189
00190 static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
00191 int32_t **dc_val_ptr)
00192 {
00193 int i;
00194
00195 if (n < 4) {
00196 i= 0;
00197 } else {
00198 i= n-3;
00199 }
00200
00201 *dc_val_ptr= &s->last_dc[i];
00202 return s->last_dc[i];
00203 }
00204
00205 static int get_dc(uint8_t *src, int stride, int scale)
00206 {
00207 int y;
00208 int sum=0;
00209 for(y=0; y<8; y++){
00210 int x;
00211 for(x=0; x<8; x++){
00212 sum+=src[x + y*stride];
00213 }
00214 }
00215 return FASTDIV((sum + (scale>>1)), scale);
00216 }
00217
00218
00219 int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
00220 int16_t **dc_val_ptr, int *dir_ptr)
00221 {
00222 int a, b, c, wrap, pred, scale;
00223 int16_t *dc_val;
00224
00225
00226 if (n < 4) {
00227 scale = s->y_dc_scale;
00228 } else {
00229 scale = s->c_dc_scale;
00230 }
00231
00232 wrap = s->block_wrap[n];
00233 dc_val= s->dc_val[0] + s->block_index[n];
00234
00235
00236
00237
00238 a = dc_val[ - 1];
00239 b = dc_val[ - 1 - wrap];
00240 c = dc_val[ - wrap];
00241
00242 if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){
00243 b=c=1024;
00244 }
00245
00246
00247
00248
00249
00250 #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
00251 __asm__ volatile(
00252 "movl %3, %%eax \n\t"
00253 "shrl $1, %%eax \n\t"
00254 "addl %%eax, %2 \n\t"
00255 "addl %%eax, %1 \n\t"
00256 "addl %0, %%eax \n\t"
00257 "mull %4 \n\t"
00258 "movl %%edx, %0 \n\t"
00259 "movl %1, %%eax \n\t"
00260 "mull %4 \n\t"
00261 "movl %%edx, %1 \n\t"
00262 "movl %2, %%eax \n\t"
00263 "mull %4 \n\t"
00264 "movl %%edx, %2 \n\t"
00265 : "+b" (a), "+c" (b), "+D" (c)
00266 : "g" (scale), "S" (ff_inverse[scale])
00267 : "%eax", "%edx"
00268 );
00269 #else
00270
00271
00272
00273
00274 if (scale == 8) {
00275 a = (a + (8 >> 1)) / 8;
00276 b = (b + (8 >> 1)) / 8;
00277 c = (c + (8 >> 1)) / 8;
00278 } else {
00279 a = FASTDIV((a + (scale >> 1)), scale);
00280 b = FASTDIV((b + (scale >> 1)), scale);
00281 c = FASTDIV((c + (scale >> 1)), scale);
00282 }
00283 #endif
00284
00285
00286 if(s->msmpeg4_version>3){
00287 if(s->inter_intra_pred){
00288 uint8_t *dest;
00289 int wrap;
00290
00291 if(n==1){
00292 pred=a;
00293 *dir_ptr = 0;
00294 }else if(n==2){
00295 pred=c;
00296 *dir_ptr = 1;
00297 }else if(n==3){
00298 if (abs(a - b) < abs(b - c)) {
00299 pred = c;
00300 *dir_ptr = 1;
00301 } else {
00302 pred = a;
00303 *dir_ptr = 0;
00304 }
00305 }else{
00306 if(n<4){
00307 wrap= s->linesize;
00308 dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;
00309 }else{
00310 wrap= s->uvlinesize;
00311 dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
00312 }
00313 if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
00314 else a= get_dc(dest-8, wrap, scale*8);
00315 if(s->mb_y==0) c= (1024 + (scale>>1))/scale;
00316 else c= get_dc(dest-8*wrap, wrap, scale*8);
00317
00318 if (s->h263_aic_dir==0) {
00319 pred= a;
00320 *dir_ptr = 0;
00321 }else if (s->h263_aic_dir==1) {
00322 if(n==0){
00323 pred= c;
00324 *dir_ptr = 1;
00325 }else{
00326 pred= a;
00327 *dir_ptr = 0;
00328 }
00329 }else if (s->h263_aic_dir==2) {
00330 if(n==0){
00331 pred= a;
00332 *dir_ptr = 0;
00333 }else{
00334 pred= c;
00335 *dir_ptr = 1;
00336 }
00337 } else {
00338 pred= c;
00339 *dir_ptr = 1;
00340 }
00341 }
00342 }else{
00343 if (abs(a - b) < abs(b - c)) {
00344 pred = c;
00345 *dir_ptr = 1;
00346 } else {
00347 pred = a;
00348 *dir_ptr = 0;
00349 }
00350 }
00351 }else{
00352 if (abs(a - b) <= abs(b - c)) {
00353 pred = c;
00354 *dir_ptr = 1;
00355 } else {
00356 pred = a;
00357 *dir_ptr = 0;
00358 }
00359 }
00360
00361
00362 *dc_val_ptr = &dc_val[0];
00363 return pred;
00364 }
00365
00366
00367
00368
00369 VLC ff_mb_non_intra_vlc[4];
00370 static VLC v2_dc_lum_vlc;
00371 static VLC v2_dc_chroma_vlc;
00372 static VLC v2_intra_cbpc_vlc;
00373 static VLC v2_mb_type_vlc;
00374 static VLC v2_mv_vlc;
00375 VLC ff_inter_intra_vlc;
00376
00377
00378 static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
00379 {
00380 int code, val, sign, shift;
00381
00382 code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2);
00383
00384 if (code < 0)
00385 return 0xffff;
00386
00387 if (code == 0)
00388 return pred;
00389 sign = get_bits1(&s->gb);
00390 shift = f_code - 1;
00391 val = code;
00392 if (shift) {
00393 val = (val - 1) << shift;
00394 val |= get_bits(&s->gb, shift);
00395 val++;
00396 }
00397 if (sign)
00398 val = -val;
00399
00400 val += pred;
00401 if (val <= -64)
00402 val += 64;
00403 else if (val >= 64)
00404 val -= 64;
00405
00406 return val;
00407 }
00408
00409 static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
00410 {
00411 int cbp, code, i;
00412 uint32_t * const mb_type_ptr = &s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride];
00413
00414 if (s->pict_type == AV_PICTURE_TYPE_P) {
00415 if (s->use_skip_mb_code) {
00416 if (get_bits1(&s->gb)) {
00417
00418 s->mb_intra = 0;
00419 for(i=0;i<6;i++)
00420 s->block_last_index[i] = -1;
00421 s->mv_dir = MV_DIR_FORWARD;
00422 s->mv_type = MV_TYPE_16X16;
00423 s->mv[0][0][0] = 0;
00424 s->mv[0][0][1] = 0;
00425 s->mb_skipped = 1;
00426 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
00427 return 0;
00428 }
00429 }
00430
00431 if(s->msmpeg4_version==2)
00432 code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
00433 else
00434 code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
00435 if(code<0 || code>7){
00436 av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
00437 return -1;
00438 }
00439
00440 s->mb_intra = code >>2;
00441
00442 cbp = code & 0x3;
00443 } else {
00444 s->mb_intra = 1;
00445 if(s->msmpeg4_version==2)
00446 cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
00447 else
00448 cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
00449 if(cbp<0 || cbp>3){
00450 av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
00451 return -1;
00452 }
00453 }
00454
00455 if (!s->mb_intra) {
00456 int mx, my, cbpy;
00457
00458 cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
00459 if(cbpy<0){
00460 av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
00461 return -1;
00462 }
00463
00464 cbp|= cbpy<<2;
00465 if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
00466
00467 ff_h263_pred_motion(s, 0, 0, &mx, &my);
00468 mx= msmpeg4v2_decode_motion(s, mx, 1);
00469 my= msmpeg4v2_decode_motion(s, my, 1);
00470
00471 s->mv_dir = MV_DIR_FORWARD;
00472 s->mv_type = MV_TYPE_16X16;
00473 s->mv[0][0][0] = mx;
00474 s->mv[0][0][1] = my;
00475 *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
00476 } else {
00477 if(s->msmpeg4_version==2){
00478 s->ac_pred = get_bits1(&s->gb);
00479 cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2;
00480 } else{
00481 s->ac_pred = 0;
00482 cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2;
00483 if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
00484 }
00485 *mb_type_ptr = MB_TYPE_INTRA;
00486 }
00487
00488 s->dsp.clear_blocks(s->block[0]);
00489 for (i = 0; i < 6; i++) {
00490 if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
00491 {
00492 av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
00493 return -1;
00494 }
00495 }
00496 return 0;
00497 }
00498
00499 static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
00500 {
00501 int cbp, code, i;
00502 uint8_t *coded_val;
00503 uint32_t * const mb_type_ptr = &s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride];
00504
00505 if (s->pict_type == AV_PICTURE_TYPE_P) {
00506 if (s->use_skip_mb_code) {
00507 if (get_bits1(&s->gb)) {
00508
00509 s->mb_intra = 0;
00510 for(i=0;i<6;i++)
00511 s->block_last_index[i] = -1;
00512 s->mv_dir = MV_DIR_FORWARD;
00513 s->mv_type = MV_TYPE_16X16;
00514 s->mv[0][0][0] = 0;
00515 s->mv[0][0][1] = 0;
00516 s->mb_skipped = 1;
00517 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
00518
00519 return 0;
00520 }
00521 }
00522
00523 code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
00524 if (code < 0)
00525 return -1;
00526
00527 s->mb_intra = (~code & 0x40) >> 6;
00528
00529 cbp = code & 0x3f;
00530 } else {
00531 s->mb_intra = 1;
00532 code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
00533 if (code < 0)
00534 return -1;
00535
00536 cbp = 0;
00537 for(i=0;i<6;i++) {
00538 int val = ((code >> (5 - i)) & 1);
00539 if (i < 4) {
00540 int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
00541 val = val ^ pred;
00542 *coded_val = val;
00543 }
00544 cbp |= val << (5 - i);
00545 }
00546 }
00547
00548 if (!s->mb_intra) {
00549 int mx, my;
00550
00551 if(s->per_mb_rl_table && cbp){
00552 s->rl_table_index = decode012(&s->gb);
00553 s->rl_chroma_table_index = s->rl_table_index;
00554 }
00555 ff_h263_pred_motion(s, 0, 0, &mx, &my);
00556 if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
00557 return -1;
00558 s->mv_dir = MV_DIR_FORWARD;
00559 s->mv_type = MV_TYPE_16X16;
00560 s->mv[0][0][0] = mx;
00561 s->mv[0][0][1] = my;
00562 *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
00563 } else {
00564
00565 s->ac_pred = get_bits1(&s->gb);
00566 *mb_type_ptr = MB_TYPE_INTRA;
00567 if(s->inter_intra_pred){
00568 s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
00569
00570 }
00571 if(s->per_mb_rl_table && cbp){
00572 s->rl_table_index = decode012(&s->gb);
00573 s->rl_chroma_table_index = s->rl_table_index;
00574 }
00575 }
00576
00577 s->dsp.clear_blocks(s->block[0]);
00578 for (i = 0; i < 6; i++) {
00579 if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
00580 {
00581 av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
00582 return -1;
00583 }
00584 }
00585
00586 return 0;
00587 }
00588
00589
00590 av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
00591 {
00592 MpegEncContext *s = avctx->priv_data;
00593 static int done = 0;
00594 int i;
00595 MVTable *mv;
00596
00597 if (ff_h263_decode_init(avctx) < 0)
00598 return -1;
00599
00600 ff_msmpeg4_common_init(s);
00601
00602 if (!done) {
00603 done = 1;
00604
00605 for(i=0;i<NB_RL_TABLES;i++) {
00606 ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
00607 }
00608 INIT_VLC_RL(ff_rl_table[0], 642);
00609 INIT_VLC_RL(ff_rl_table[1], 1104);
00610 INIT_VLC_RL(ff_rl_table[2], 554);
00611 INIT_VLC_RL(ff_rl_table[3], 940);
00612 INIT_VLC_RL(ff_rl_table[4], 962);
00613 INIT_VLC_RL(ff_rl_table[5], 554);
00614
00615 mv = &ff_mv_tables[0];
00616 INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
00617 mv->table_mv_bits, 1, 1,
00618 mv->table_mv_code, 2, 2, 3714);
00619 mv = &ff_mv_tables[1];
00620 INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
00621 mv->table_mv_bits, 1, 1,
00622 mv->table_mv_code, 2, 2, 2694);
00623
00624 INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
00625 &ff_table0_dc_lum[0][1], 8, 4,
00626 &ff_table0_dc_lum[0][0], 8, 4, 1158);
00627 INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
00628 &ff_table0_dc_chroma[0][1], 8, 4,
00629 &ff_table0_dc_chroma[0][0], 8, 4, 1118);
00630 INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
00631 &ff_table1_dc_lum[0][1], 8, 4,
00632 &ff_table1_dc_lum[0][0], 8, 4, 1476);
00633 INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
00634 &ff_table1_dc_chroma[0][1], 8, 4,
00635 &ff_table1_dc_chroma[0][0], 8, 4, 1216);
00636
00637 INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
00638 &ff_v2_dc_lum_table[0][1], 8, 4,
00639 &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
00640 INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
00641 &ff_v2_dc_chroma_table[0][1], 8, 4,
00642 &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
00643
00644 INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
00645 &ff_v2_intra_cbpc[0][1], 2, 1,
00646 &ff_v2_intra_cbpc[0][0], 2, 1, 8);
00647 INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
00648 &ff_v2_mb_type[0][1], 2, 1,
00649 &ff_v2_mb_type[0][0], 2, 1, 128);
00650 INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
00651 &ff_mvtab[0][1], 2, 1,
00652 &ff_mvtab[0][0], 2, 1, 538);
00653
00654 INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
00655 &ff_wmv2_inter_table[0][0][1], 8, 4,
00656 &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
00657 INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
00658 &ff_wmv2_inter_table[1][0][1], 8, 4,
00659 &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
00660 INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
00661 &ff_wmv2_inter_table[2][0][1], 8, 4,
00662 &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
00663 INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
00664 &ff_wmv2_inter_table[3][0][1], 8, 4,
00665 &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
00666
00667 INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
00668 &ff_msmp4_mb_i_table[0][1], 4, 2,
00669 &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
00670
00671 INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
00672 &ff_table_inter_intra[0][1], 2, 1,
00673 &ff_table_inter_intra[0][0], 2, 1, 8);
00674 }
00675
00676 switch(s->msmpeg4_version){
00677 case 1:
00678 case 2:
00679 s->decode_mb= msmpeg4v12_decode_mb;
00680 break;
00681 case 3:
00682 case 4:
00683 s->decode_mb= msmpeg4v34_decode_mb;
00684 break;
00685 case 5:
00686 if (CONFIG_WMV2_DECODER)
00687 s->decode_mb= ff_wmv2_decode_mb;
00688 case 6:
00689
00690 break;
00691 }
00692
00693 s->slice_height= s->mb_height;
00694
00695 return 0;
00696 }
00697
00698 int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
00699 {
00700 int code;
00701
00702 if(s->msmpeg4_version==1){
00703 int start_code = get_bits_long(&s->gb, 32);
00704 if(start_code!=0x00000100){
00705 av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
00706 return -1;
00707 }
00708
00709 skip_bits(&s->gb, 5);
00710 }
00711
00712 s->pict_type = get_bits(&s->gb, 2) + 1;
00713 if (s->pict_type != AV_PICTURE_TYPE_I &&
00714 s->pict_type != AV_PICTURE_TYPE_P){
00715 av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
00716 return -1;
00717 }
00718 #if 0
00719 {
00720 static int had_i=0;
00721 if(s->pict_type == AV_PICTURE_TYPE_I) had_i=1;
00722 if(!had_i) return -1;
00723 }
00724 #endif
00725 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00726 if(s->qscale==0){
00727 av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
00728 return -1;
00729 }
00730
00731 if (s->pict_type == AV_PICTURE_TYPE_I) {
00732 code = get_bits(&s->gb, 5);
00733 if(s->msmpeg4_version==1){
00734 if(code==0 || code>s->mb_height){
00735 av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
00736 return -1;
00737 }
00738
00739 s->slice_height = code;
00740 }else{
00741
00742 if (code < 0x17){
00743 av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
00744 return -1;
00745 }
00746
00747 s->slice_height = s->mb_height / (code - 0x16);
00748 }
00749
00750 switch(s->msmpeg4_version){
00751 case 1:
00752 case 2:
00753 s->rl_chroma_table_index = 2;
00754 s->rl_table_index = 2;
00755
00756 s->dc_table_index = 0;
00757 break;
00758 case 3:
00759 s->rl_chroma_table_index = decode012(&s->gb);
00760 s->rl_table_index = decode012(&s->gb);
00761
00762 s->dc_table_index = get_bits1(&s->gb);
00763 break;
00764 case 4:
00765 ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
00766
00767 if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
00768 else s->per_mb_rl_table= 0;
00769
00770 if(!s->per_mb_rl_table){
00771 s->rl_chroma_table_index = decode012(&s->gb);
00772 s->rl_table_index = decode012(&s->gb);
00773 }
00774
00775 s->dc_table_index = get_bits1(&s->gb);
00776 s->inter_intra_pred= 0;
00777 break;
00778 }
00779 s->no_rounding = 1;
00780 if(s->avctx->debug&FF_DEBUG_PICT_INFO)
00781 av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
00782 s->qscale,
00783 s->rl_chroma_table_index,
00784 s->rl_table_index,
00785 s->dc_table_index,
00786 s->per_mb_rl_table,
00787 s->slice_height);
00788 } else {
00789 switch(s->msmpeg4_version){
00790 case 1:
00791 case 2:
00792 if(s->msmpeg4_version==1)
00793 s->use_skip_mb_code = 1;
00794 else
00795 s->use_skip_mb_code = get_bits1(&s->gb);
00796 s->rl_table_index = 2;
00797 s->rl_chroma_table_index = s->rl_table_index;
00798 s->dc_table_index = 0;
00799 s->mv_table_index = 0;
00800 break;
00801 case 3:
00802 s->use_skip_mb_code = get_bits1(&s->gb);
00803 s->rl_table_index = decode012(&s->gb);
00804 s->rl_chroma_table_index = s->rl_table_index;
00805
00806 s->dc_table_index = get_bits1(&s->gb);
00807
00808 s->mv_table_index = get_bits1(&s->gb);
00809 break;
00810 case 4:
00811 s->use_skip_mb_code = get_bits1(&s->gb);
00812
00813 if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
00814 else s->per_mb_rl_table= 0;
00815
00816 if(!s->per_mb_rl_table){
00817 s->rl_table_index = decode012(&s->gb);
00818 s->rl_chroma_table_index = s->rl_table_index;
00819 }
00820
00821 s->dc_table_index = get_bits1(&s->gb);
00822
00823 s->mv_table_index = get_bits1(&s->gb);
00824 s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
00825 break;
00826 }
00827
00828 if(s->avctx->debug&FF_DEBUG_PICT_INFO)
00829 av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
00830 s->use_skip_mb_code,
00831 s->rl_table_index,
00832 s->rl_chroma_table_index,
00833 s->dc_table_index,
00834 s->mv_table_index,
00835 s->per_mb_rl_table,
00836 s->qscale);
00837
00838 if(s->flipflop_rounding){
00839 s->no_rounding ^= 1;
00840 }else{
00841 s->no_rounding = 0;
00842 }
00843 }
00844
00845
00846 s->esc3_level_length= 0;
00847 s->esc3_run_length= 0;
00848
00849 return 0;
00850 }
00851
00852 int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
00853 {
00854 int left= buf_size*8 - get_bits_count(&s->gb);
00855 int length= s->msmpeg4_version>=3 ? 17 : 16;
00856
00857 if(left>=length && left<length+8)
00858 {
00859 skip_bits(&s->gb, 5);
00860 s->bit_rate= get_bits(&s->gb, 11)*1024;
00861 if(s->msmpeg4_version>=3)
00862 s->flipflop_rounding= get_bits1(&s->gb);
00863 else
00864 s->flipflop_rounding= 0;
00865
00866
00867 }
00868 else if(left<length+8)
00869 {
00870 s->flipflop_rounding= 0;
00871 if(s->msmpeg4_version != 2)
00872 av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
00873 }
00874 else
00875 {
00876 av_log(s->avctx, AV_LOG_ERROR, "I frame too long, ignoring ext header\n");
00877 }
00878
00879 return 0;
00880 }
00881
00882 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
00883 {
00884 int level, pred;
00885
00886 if(s->msmpeg4_version<=2){
00887 if (n < 4) {
00888 level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
00889 } else {
00890 level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
00891 }
00892 if (level < 0)
00893 return -1;
00894 level-=256;
00895 }else{
00896 if (n < 4) {
00897 level = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
00898 } else {
00899 level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
00900 }
00901 if (level < 0){
00902 av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
00903 return -1;
00904 }
00905
00906 if (level == DC_MAX) {
00907 level = get_bits(&s->gb, 8);
00908 if (get_bits1(&s->gb))
00909 level = -level;
00910 } else if (level != 0) {
00911 if (get_bits1(&s->gb))
00912 level = -level;
00913 }
00914 }
00915
00916 if(s->msmpeg4_version==1){
00917 int32_t *dc_val;
00918 pred = msmpeg4v1_pred_dc(s, n, &dc_val);
00919 level += pred;
00920
00921
00922 *dc_val= level;
00923 }else{
00924 int16_t *dc_val;
00925 pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
00926 level += pred;
00927
00928
00929 if (n < 4) {
00930 *dc_val = level * s->y_dc_scale;
00931 } else {
00932 *dc_val = level * s->c_dc_scale;
00933 }
00934 }
00935
00936 return level;
00937 }
00938
00939
00940 int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
00941 int n, int coded, const uint8_t *scan_table)
00942 {
00943 int level, i, last, run, run_diff;
00944 int av_uninit(dc_pred_dir);
00945 RLTable *rl;
00946 RL_VLC_ELEM *rl_vlc;
00947 int qmul, qadd;
00948
00949 if (s->mb_intra) {
00950 qmul=1;
00951 qadd=0;
00952
00953
00954 level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
00955
00956 if (level < 0){
00957 av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
00958 if(s->inter_intra_pred) level=0;
00959 else return -1;
00960 }
00961 if (n < 4) {
00962 rl = &ff_rl_table[s->rl_table_index];
00963 if(level > 256*s->y_dc_scale){
00964 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
00965 if(!s->inter_intra_pred) return -1;
00966 }
00967 } else {
00968 rl = &ff_rl_table[3 + s->rl_chroma_table_index];
00969 if(level > 256*s->c_dc_scale){
00970 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
00971 if(!s->inter_intra_pred) return -1;
00972 }
00973 }
00974 block[0] = level;
00975
00976 run_diff = s->msmpeg4_version >= 4;
00977 i = 0;
00978 if (!coded) {
00979 goto not_coded;
00980 }
00981 if (s->ac_pred) {
00982 if (dc_pred_dir == 0)
00983 scan_table = s->intra_v_scantable.permutated;
00984 else
00985 scan_table = s->intra_h_scantable.permutated;
00986 } else {
00987 scan_table = s->intra_scantable.permutated;
00988 }
00989 rl_vlc= rl->rl_vlc[0];
00990 } else {
00991 qmul = s->qscale << 1;
00992 qadd = (s->qscale - 1) | 1;
00993 i = -1;
00994 rl = &ff_rl_table[3 + s->rl_table_index];
00995
00996 if(s->msmpeg4_version==2)
00997 run_diff = 0;
00998 else
00999 run_diff = 1;
01000
01001 if (!coded) {
01002 s->block_last_index[n] = i;
01003 return 0;
01004 }
01005 if(!scan_table)
01006 scan_table = s->inter_scantable.permutated;
01007 rl_vlc= rl->rl_vlc[s->qscale];
01008 }
01009 {
01010 OPEN_READER(re, &s->gb);
01011 for(;;) {
01012 UPDATE_CACHE(re, &s->gb);
01013 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
01014 if (level==0) {
01015 int cache;
01016 cache= GET_CACHE(re, &s->gb);
01017
01018 if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
01019 if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
01020
01021 if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
01022 UPDATE_CACHE(re, &s->gb);
01023 if(s->msmpeg4_version<=3){
01024 last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
01025 run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
01026 level= SHOW_SBITS(re, &s->gb, 8);
01027 SKIP_COUNTER(re, &s->gb, 1+6+8);
01028 }else{
01029 int sign;
01030 last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
01031 if(!s->esc3_level_length){
01032 int ll;
01033
01034 if(s->qscale<8){
01035 ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
01036 if(ll==0){
01037 ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
01038 }
01039 }else{
01040 ll=2;
01041 while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
01042 ll++;
01043 SKIP_BITS(re, &s->gb, 1);
01044 }
01045 if(ll<8) SKIP_BITS(re, &s->gb, 1);
01046 }
01047
01048 s->esc3_level_length= ll;
01049 s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
01050
01051 UPDATE_CACHE(re, &s->gb);
01052 }
01053 run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
01054 SKIP_BITS(re, &s->gb, s->esc3_run_length);
01055
01056 sign= SHOW_UBITS(re, &s->gb, 1);
01057 SKIP_BITS(re, &s->gb, 1);
01058
01059 level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
01060 SKIP_BITS(re, &s->gb, s->esc3_level_length);
01061 if(sign) level= -level;
01062 }
01063
01064 #if 0 // waste of time / this will detect very few errors
01065 {
01066 const int abs_level= FFABS(level);
01067 const int run1= run - rl->max_run[last][abs_level] - run_diff;
01068 if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
01069 if(abs_level <= rl->max_level[last][run]){
01070 av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
01071 return DECODING_AC_LOST;
01072 }
01073 if(abs_level <= rl->max_level[last][run]*2){
01074 av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
01075 return DECODING_AC_LOST;
01076 }
01077 if(run1>=0 && abs_level <= rl->max_level[last][run1]){
01078 av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
01079 return DECODING_AC_LOST;
01080 }
01081 }
01082 }
01083 #endif
01084
01085 if (level>0) level= level * qmul + qadd;
01086 else level= level * qmul - qadd;
01087 #if 0 // waste of time too :(
01088 if(level>2048 || level<-2048){
01089 av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc\n");
01090 return DECODING_AC_LOST;
01091 }
01092 #endif
01093 i+= run + 1;
01094 if(last) i+=192;
01095 #ifdef ERROR_DETAILS
01096 if(run==66)
01097 av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level);
01098 else if((i>62 && i<192) || i>192+63)
01099 av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
01100 #endif
01101 } else {
01102
01103 SKIP_BITS(re, &s->gb, 2);
01104 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
01105 i+= run + rl->max_run[run>>7][level/qmul] + run_diff;
01106 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
01107 LAST_SKIP_BITS(re, &s->gb, 1);
01108 #ifdef ERROR_DETAILS
01109 if(run==66)
01110 av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level);
01111 else if((i>62 && i<192) || i>192+63)
01112 av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
01113 #endif
01114 }
01115 } else {
01116
01117 SKIP_BITS(re, &s->gb, 1);
01118 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
01119 i+= run;
01120 level = level + rl->max_level[run>>7][(run-1)&63] * qmul;
01121 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
01122 LAST_SKIP_BITS(re, &s->gb, 1);
01123 #ifdef ERROR_DETAILS
01124 if(run==66)
01125 av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level);
01126 else if((i>62 && i<192) || i>192+63)
01127 av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
01128 #endif
01129 }
01130 } else {
01131 i+= run;
01132 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
01133 LAST_SKIP_BITS(re, &s->gb, 1);
01134 #ifdef ERROR_DETAILS
01135 if(run==66)
01136 av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level);
01137 else if((i>62 && i<192) || i>192+63)
01138 av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level);
01139 #endif
01140 }
01141 if (i > 62){
01142 i-= 192;
01143 if(i&(~63)){
01144 const int left= get_bits_left(&s->gb);
01145 if(((i+192 == 64 && level/qmul==-1) || !(s->err_recognition&(AV_EF_BITSTREAM|AV_EF_COMPLIANT))) && left>=0){
01146 av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
01147 break;
01148 }else{
01149 av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
01150 return -1;
01151 }
01152 }
01153
01154 block[scan_table[i]] = level;
01155 break;
01156 }
01157
01158 block[scan_table[i]] = level;
01159 }
01160 CLOSE_READER(re, &s->gb);
01161 }
01162 not_coded:
01163 if (s->mb_intra) {
01164 ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
01165 if (s->ac_pred) {
01166 i = 63;
01167 }
01168 }
01169 if(s->msmpeg4_version>=4 && i>0) i=63;
01170 s->block_last_index[n] = i;
01171
01172 return 0;
01173 }
01174
01175 int ff_msmpeg4_decode_motion(MpegEncContext * s,
01176 int *mx_ptr, int *my_ptr)
01177 {
01178 MVTable *mv;
01179 int code, mx, my;
01180
01181 mv = &ff_mv_tables[s->mv_table_index];
01182
01183 code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
01184 if (code < 0){
01185 av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
01186 return -1;
01187 }
01188 if (code == mv->n) {
01189
01190 mx = get_bits(&s->gb, 6);
01191 my = get_bits(&s->gb, 6);
01192 } else {
01193 mx = mv->table_mvx[code];
01194 my = mv->table_mvy[code];
01195 }
01196
01197 mx += *mx_ptr - 32;
01198 my += *my_ptr - 32;
01199
01200 if (mx <= -64)
01201 mx += 64;
01202 else if (mx >= 64)
01203 mx -= 64;
01204
01205 if (my <= -64)
01206 my += 64;
01207 else if (my >= 64)
01208 my -= 64;
01209 *mx_ptr = mx;
01210 *my_ptr = my;
01211 return 0;
01212 }
01213
01214 AVCodec ff_msmpeg4v1_decoder = {
01215 .name = "msmpeg4v1",
01216 .type = AVMEDIA_TYPE_VIDEO,
01217 .id = AV_CODEC_ID_MSMPEG4V1,
01218 .priv_data_size = sizeof(MpegEncContext),
01219 .init = ff_msmpeg4_decode_init,
01220 .close = ff_h263_decode_end,
01221 .decode = ff_h263_decode_frame,
01222 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
01223 .max_lowres = 3,
01224 .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
01225 .pix_fmts = ff_pixfmt_list_420,
01226 };
01227
01228 AVCodec ff_msmpeg4v2_decoder = {
01229 .name = "msmpeg4v2",
01230 .type = AVMEDIA_TYPE_VIDEO,
01231 .id = AV_CODEC_ID_MSMPEG4V2,
01232 .priv_data_size = sizeof(MpegEncContext),
01233 .init = ff_msmpeg4_decode_init,
01234 .close = ff_h263_decode_end,
01235 .decode = ff_h263_decode_frame,
01236 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
01237 .max_lowres = 3,
01238 .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
01239 .pix_fmts = ff_pixfmt_list_420,
01240 };
01241
01242 AVCodec ff_msmpeg4v3_decoder = {
01243 .name = "msmpeg4",
01244 .type = AVMEDIA_TYPE_VIDEO,
01245 .id = AV_CODEC_ID_MSMPEG4V3,
01246 .priv_data_size = sizeof(MpegEncContext),
01247 .init = ff_msmpeg4_decode_init,
01248 .close = ff_h263_decode_end,
01249 .decode = ff_h263_decode_frame,
01250 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
01251 .max_lowres = 3,
01252 .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
01253 .pix_fmts = ff_pixfmt_list_420,
01254 };
01255
01256 AVCodec ff_wmv1_decoder = {
01257 .name = "wmv1",
01258 .type = AVMEDIA_TYPE_VIDEO,
01259 .id = AV_CODEC_ID_WMV1,
01260 .priv_data_size = sizeof(MpegEncContext),
01261 .init = ff_msmpeg4_decode_init,
01262 .close = ff_h263_decode_end,
01263 .decode = ff_h263_decode_frame,
01264 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
01265 .max_lowres = 3,
01266 .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
01267 .pix_fmts = ff_pixfmt_list_420,
01268 };