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