LCOV - code coverage report
Current view: top level - libavcodec - msmpeg4dec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 411 478 86.0 %
Date: 2018-05-20 11:54:08 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /*
       2             :  * MSMPEG4 backend for encoder and decoder
       3             :  * Copyright (c) 2001 Fabrice Bellard
       4             :  * Copyright (c) 2002-2013 Michael Niedermayer <michaelni@gmx.at>
       5             :  *
       6             :  * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
       7             :  *
       8             :  * This file is part of FFmpeg.
       9             :  *
      10             :  * FFmpeg is free software; you can redistribute it and/or
      11             :  * modify it under the terms of the GNU Lesser General Public
      12             :  * License as published by the Free Software Foundation; either
      13             :  * version 2.1 of the License, or (at your option) any later version.
      14             :  *
      15             :  * FFmpeg is distributed in the hope that it will be useful,
      16             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :  * Lesser General Public License for more details.
      19             :  *
      20             :  * You should have received a copy of the GNU Lesser General Public
      21             :  * License along with FFmpeg; if not, write to the Free Software
      22             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      23             :  */
      24             : 
      25             : #include "avcodec.h"
      26             : #include "internal.h"
      27             : #include "mpegutils.h"
      28             : #include "mpegvideo.h"
      29             : #include "msmpeg4.h"
      30             : #include "libavutil/imgutils.h"
      31             : #include "h263.h"
      32             : #include "mpeg4video.h"
      33             : #include "msmpeg4data.h"
      34             : #include "vc1data.h"
      35             : #include "wmv2.h"
      36             : 
      37             : #define DC_VLC_BITS 9
      38             : #define V2_INTRA_CBPC_VLC_BITS 3
      39             : #define V2_MB_TYPE_VLC_BITS 7
      40             : #define MV_VLC_BITS 9
      41             : #define V2_MV_VLC_BITS 9
      42             : #define TEX_VLC_BITS 9
      43             : 
      44             : #define DEFAULT_INTER_INDEX 3
      45             : 
      46        5490 : static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
      47             :                                     int32_t **dc_val_ptr)
      48             : {
      49             :     int i;
      50             : 
      51        5490 :     if (n < 4) {
      52        3660 :         i= 0;
      53             :     } else {
      54        1830 :         i= n-3;
      55             :     }
      56             : 
      57        5490 :     *dc_val_ptr= &s->last_dc[i];
      58        5490 :     return s->last_dc[i];
      59             : }
      60             : 
      61             : /****************************************/
      62             : /* decoding stuff */
      63             : 
      64             : VLC ff_mb_non_intra_vlc[4];
      65             : static VLC v2_dc_lum_vlc;
      66             : static VLC v2_dc_chroma_vlc;
      67             : static VLC v2_intra_cbpc_vlc;
      68             : static VLC v2_mb_type_vlc;
      69             : static VLC v2_mv_vlc;
      70             : VLC ff_inter_intra_vlc;
      71             : 
      72             : /* This is identical to H.263 except that its range is multiplied by 2. */
      73      132268 : static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
      74             : {
      75             :     int code, val, sign, shift;
      76             : 
      77      132268 :     code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2);
      78             :     ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
      79      132268 :     if (code < 0)
      80           0 :         return 0xffff;
      81             : 
      82      132268 :     if (code == 0)
      83       68571 :         return pred;
      84       63697 :     sign = get_bits1(&s->gb);
      85       63697 :     shift = f_code - 1;
      86       63697 :     val = code;
      87       63697 :     if (shift) {
      88           0 :         val = (val - 1) << shift;
      89           0 :         val |= get_bits(&s->gb, shift);
      90           0 :         val++;
      91             :     }
      92       63697 :     if (sign)
      93       26289 :         val = -val;
      94             : 
      95       63697 :     val += pred;
      96       63697 :     if (val <= -64)
      97         138 :         val += 64;
      98       63559 :     else if (val >= 64)
      99          13 :         val -= 64;
     100             : 
     101       63697 :     return val;
     102             : }
     103             : 
     104       76350 : static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
     105             : {
     106             :     int cbp, code, i;
     107       76350 :     uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
     108             : 
     109       76350 :     if (s->pict_type == AV_PICTURE_TYPE_P) {
     110       70035 :         if (s->use_skip_mb_code) {
     111       70035 :             if (get_bits1(&s->gb)) {
     112             :                 /* skip mb */
     113        1159 :                 s->mb_intra = 0;
     114        8113 :                 for(i=0;i<6;i++)
     115        6954 :                     s->block_last_index[i] = -1;
     116        1159 :                 s->mv_dir = MV_DIR_FORWARD;
     117        1159 :                 s->mv_type = MV_TYPE_16X16;
     118        1159 :                 s->mv[0][0][0] = 0;
     119        1159 :                 s->mv[0][0][1] = 0;
     120        1159 :                 s->mb_skipped = 1;
     121        1159 :                 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
     122        1159 :                 return 0;
     123             :             }
     124             :         }
     125             : 
     126       68876 :         if(s->msmpeg4_version==2)
     127       53160 :             code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
     128             :         else
     129       15716 :             code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
     130       68876 :         if(code<0 || code>7){
     131           0 :             av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
     132           0 :             return -1;
     133             :         }
     134             : 
     135       68876 :         s->mb_intra = code >>2;
     136             : 
     137       68876 :         cbp = code & 0x3;
     138             :     } else {
     139        6315 :         s->mb_intra = 1;
     140        6315 :         if(s->msmpeg4_version==2)
     141        5985 :             cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
     142             :         else
     143         330 :             cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
     144        6315 :         if(cbp<0 || cbp>3){
     145           0 :             av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
     146           0 :             return -1;
     147             :         }
     148             :     }
     149             : 
     150       75191 :     if (!s->mb_intra) {
     151             :         int mx, my, cbpy;
     152             : 
     153       66134 :         cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
     154       66134 :         if(cbpy<0){
     155           0 :             av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
     156           0 :             return -1;
     157             :         }
     158             : 
     159       66134 :         cbp|= cbpy<<2;
     160       66134 :         if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
     161             : 
     162       66134 :         ff_h263_pred_motion(s, 0, 0, &mx, &my);
     163       66134 :         mx= msmpeg4v2_decode_motion(s, mx, 1);
     164       66134 :         my= msmpeg4v2_decode_motion(s, my, 1);
     165             : 
     166       66134 :         s->mv_dir = MV_DIR_FORWARD;
     167       66134 :         s->mv_type = MV_TYPE_16X16;
     168       66134 :         s->mv[0][0][0] = mx;
     169       66134 :         s->mv[0][0][1] = my;
     170       66134 :         *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
     171             :     } else {
     172             :         int v;
     173        9057 :         if(s->msmpeg4_version==2){
     174        8142 :             s->ac_pred = get_bits1(&s->gb);
     175        8142 :             v = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
     176        8142 :             if (v < 0) {
     177           0 :                 av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
     178           0 :                 return -1;
     179             :             }
     180        8142 :             cbp|= v<<2;
     181             :         } else{
     182         915 :             s->ac_pred = 0;
     183         915 :             v = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
     184         915 :             if (v < 0) {
     185           0 :                 av_log(s->avctx, AV_LOG_ERROR, "cbpy vlc invalid\n");
     186           0 :                 return -1;
     187             :             }
     188         915 :             cbp|= v<<2;
     189         915 :             if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
     190             :         }
     191        9057 :         *mb_type_ptr = MB_TYPE_INTRA;
     192             :     }
     193             : 
     194       75191 :     s->bdsp.clear_blocks(s->block[0]);
     195      526337 :     for (i = 0; i < 6; i++) {
     196      451146 :         if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
     197             :         {
     198           0 :              av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
     199           0 :              return -1;
     200             :         }
     201             :     }
     202       75191 :     return 0;
     203             : }
     204             : 
     205      129600 : static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
     206             : {
     207             :     int cbp, code, i;
     208             :     uint8_t *coded_val;
     209      129600 :     uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
     210             : 
     211      129600 :     if (get_bits_left(&s->gb) <= 0)
     212           0 :         return AVERROR_INVALIDDATA;
     213             : 
     214      129600 :     if (s->pict_type == AV_PICTURE_TYPE_P) {
     215      116442 :         if (s->use_skip_mb_code) {
     216      116442 :             if (get_bits1(&s->gb)) {
     217             :                 /* skip mb */
     218        1554 :                 s->mb_intra = 0;
     219       10878 :                 for(i=0;i<6;i++)
     220        9324 :                     s->block_last_index[i] = -1;
     221        1554 :                 s->mv_dir = MV_DIR_FORWARD;
     222        1554 :                 s->mv_type = MV_TYPE_16X16;
     223        1554 :                 s->mv[0][0][0] = 0;
     224        1554 :                 s->mv[0][0][1] = 0;
     225        1554 :                 s->mb_skipped = 1;
     226        1554 :                 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
     227             : 
     228        1554 :                 return 0;
     229             :             }
     230             :         }
     231             : 
     232      114888 :         code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
     233      114888 :         if (code < 0)
     234           0 :             return -1;
     235             :         //s->mb_intra = (code & 0x40) ? 0 : 1;
     236      114888 :         s->mb_intra = (~code & 0x40) >> 6;
     237             : 
     238      114888 :         cbp = code & 0x3f;
     239             :     } else {
     240       13158 :         s->mb_intra = 1;
     241       13158 :         code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
     242       13158 :         if (code < 0)
     243           0 :             return -1;
     244             :         /* predict coded block pattern */
     245       13158 :         cbp = 0;
     246       92106 :         for(i=0;i<6;i++) {
     247       78948 :             int val = ((code >> (5 - i)) & 1);
     248       78948 :             if (i < 4) {
     249       52632 :                 int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
     250       52632 :                 val = val ^ pred;
     251       52632 :                 *coded_val = val;
     252             :             }
     253       78948 :             cbp |= val << (5 - i);
     254             :         }
     255             :     }
     256             : 
     257      128046 :     if (!s->mb_intra) {
     258             :         int mx, my;
     259      109652 :         if(s->per_mb_rl_table && cbp){
     260           0 :             s->rl_table_index = decode012(&s->gb);
     261           0 :             s->rl_chroma_table_index = s->rl_table_index;
     262             :         }
     263      109652 :         ff_h263_pred_motion(s, 0, 0, &mx, &my);
     264      109652 :         if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
     265           0 :             return -1;
     266      109652 :         s->mv_dir = MV_DIR_FORWARD;
     267      109652 :         s->mv_type = MV_TYPE_16X16;
     268      109652 :         s->mv[0][0][0] = mx;
     269      109652 :         s->mv[0][0][1] = my;
     270      109652 :         *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
     271             :     } else {
     272             :         ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
     273             :                 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
     274             :                 show_bits(&s->gb, 24));
     275       18394 :         s->ac_pred = get_bits1(&s->gb);
     276       18394 :         *mb_type_ptr = MB_TYPE_INTRA;
     277       18394 :         if(s->inter_intra_pred){
     278           0 :             s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
     279             :             ff_dlog(s, "%d%d %d %d/",
     280             :                     s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
     281             :         }
     282       18394 :         if(s->per_mb_rl_table && cbp){
     283           0 :             s->rl_table_index = decode012(&s->gb);
     284           0 :             s->rl_chroma_table_index = s->rl_table_index;
     285             :         }
     286             :     }
     287             : 
     288      128046 :     s->bdsp.clear_blocks(s->block[0]);
     289      896322 :     for (i = 0; i < 6; i++) {
     290      768276 :         if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
     291             :         {
     292           0 :             av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
     293           0 :             return -1;
     294             :         }
     295             :     }
     296             : 
     297      128046 :     return 0;
     298             : }
     299             : 
     300             : /* init all vlc decoding tables */
     301          81 : av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
     302             : {
     303          81 :     MpegEncContext *s = avctx->priv_data;
     304             :     static volatile int done = 0;
     305             :     int i, ret;
     306             :     MVTable *mv;
     307             : 
     308          81 :     if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
     309           0 :         return ret;
     310             : 
     311          81 :     if (ff_h263_decode_init(avctx) < 0)
     312           0 :         return -1;
     313             : 
     314          81 :     ff_msmpeg4_common_init(s);
     315             : 
     316          81 :     if (!done) {
     317         287 :         for(i=0;i<NB_RL_TABLES;i++) {
     318         246 :             ff_rl_init(&ff_rl_table[i], ff_static_rl_table_store[i]);
     319             :         }
     320          41 :         INIT_VLC_RL(ff_rl_table[0], 642);
     321          41 :         INIT_VLC_RL(ff_rl_table[1], 1104);
     322          41 :         INIT_VLC_RL(ff_rl_table[2], 554);
     323          41 :         INIT_VLC_RL(ff_rl_table[3], 940);
     324          41 :         INIT_VLC_RL(ff_rl_table[4], 962);
     325          41 :         INIT_VLC_RL(ff_rl_table[5], 554);
     326             : 
     327          41 :         mv = &ff_mv_tables[0];
     328          41 :         INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
     329             :                     mv->table_mv_bits, 1, 1,
     330             :                     mv->table_mv_code, 2, 2, 3714);
     331          41 :         mv = &ff_mv_tables[1];
     332          41 :         INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
     333             :                     mv->table_mv_bits, 1, 1,
     334             :                     mv->table_mv_code, 2, 2, 2694);
     335             : 
     336          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
     337             :                  &ff_table0_dc_lum[0][1], 8, 4,
     338             :                  &ff_table0_dc_lum[0][0], 8, 4, 1158);
     339          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
     340             :                  &ff_table0_dc_chroma[0][1], 8, 4,
     341             :                  &ff_table0_dc_chroma[0][0], 8, 4, 1118);
     342          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
     343             :                  &ff_table1_dc_lum[0][1], 8, 4,
     344             :                  &ff_table1_dc_lum[0][0], 8, 4, 1476);
     345          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
     346             :                  &ff_table1_dc_chroma[0][1], 8, 4,
     347             :                  &ff_table1_dc_chroma[0][0], 8, 4, 1216);
     348             : 
     349          41 :         INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
     350             :                  &ff_v2_dc_lum_table[0][1], 8, 4,
     351             :                  &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
     352          41 :         INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
     353             :                  &ff_v2_dc_chroma_table[0][1], 8, 4,
     354             :                  &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
     355             : 
     356          41 :         INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
     357             :                  &ff_v2_intra_cbpc[0][1], 2, 1,
     358             :                  &ff_v2_intra_cbpc[0][0], 2, 1, 8);
     359          41 :         INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
     360             :                  &ff_v2_mb_type[0][1], 2, 1,
     361             :                  &ff_v2_mb_type[0][0], 2, 1, 128);
     362          41 :         INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
     363             :                  &ff_mvtab[0][1], 2, 1,
     364             :                  &ff_mvtab[0][0], 2, 1, 538);
     365             : 
     366          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
     367             :                      &ff_wmv2_inter_table[0][0][1], 8, 4,
     368             :                      &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
     369          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
     370             :                      &ff_wmv2_inter_table[1][0][1], 8, 4,
     371             :                      &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
     372          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
     373             :                      &ff_wmv2_inter_table[2][0][1], 8, 4,
     374             :                      &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
     375          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
     376             :                      &ff_wmv2_inter_table[3][0][1], 8, 4,
     377             :                      &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
     378             : 
     379          41 :         INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
     380             :                  &ff_msmp4_mb_i_table[0][1], 4, 2,
     381             :                  &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
     382             : 
     383          41 :         INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
     384             :                  &ff_table_inter_intra[0][1], 2, 1,
     385             :                  &ff_table_inter_intra[0][0], 2, 1, 8);
     386          41 :         done = 1;
     387             :     }
     388             : 
     389          81 :     switch(s->msmpeg4_version){
     390          11 :     case 1:
     391             :     case 2:
     392          11 :         s->decode_mb= msmpeg4v12_decode_mb;
     393          11 :         break;
     394          22 :     case 3:
     395             :     case 4:
     396          22 :         s->decode_mb= msmpeg4v34_decode_mb;
     397          22 :         break;
     398          12 :     case 5:
     399             :         if (CONFIG_WMV2_DECODER)
     400          12 :             s->decode_mb= ff_wmv2_decode_mb;
     401             :     case 6:
     402             :         //FIXME + TODO VC1 decode mb
     403          48 :         break;
     404             :     }
     405             : 
     406          81 :     s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
     407             : 
     408          81 :     return 0;
     409             : }
     410             : 
     411         675 : int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
     412             : {
     413             :     int code;
     414             : 
     415         675 :     if(s->msmpeg4_version==1){
     416          50 :         int start_code = get_bits_long(&s->gb, 32);
     417          50 :         if(start_code!=0x00000100){
     418           0 :             av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
     419           0 :             return -1;
     420             :         }
     421             : 
     422          50 :         skip_bits(&s->gb, 5); // frame number */
     423             :     }
     424             : 
     425         675 :     s->pict_type = get_bits(&s->gb, 2) + 1;
     426        1286 :     if (s->pict_type != AV_PICTURE_TYPE_I &&
     427         611 :         s->pict_type != AV_PICTURE_TYPE_P){
     428           0 :         av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
     429           0 :         return -1;
     430             :     }
     431         675 :     s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
     432         675 :     if(s->qscale==0){
     433           0 :         av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
     434           0 :         return -1;
     435             :     }
     436             : 
     437         675 :     if (s->pict_type == AV_PICTURE_TYPE_I) {
     438          64 :         code = get_bits(&s->gb, 5);
     439          64 :         if(s->msmpeg4_version==1){
     440           1 :             if(code==0 || code>s->mb_height){
     441           0 :                 av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
     442           0 :                 return -1;
     443             :             }
     444             : 
     445           1 :             s->slice_height = code;
     446             :         }else{
     447             :             /* 0x17: one slice, 0x18: two slices, ... */
     448          63 :             if (code < 0x17){
     449           0 :                 av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
     450           0 :                 return -1;
     451             :             }
     452             : 
     453          63 :             s->slice_height = s->mb_height / (code - 0x16);
     454             :         }
     455             : 
     456          64 :         switch(s->msmpeg4_version){
     457          21 :         case 1:
     458             :         case 2:
     459          21 :             s->rl_chroma_table_index = 2;
     460          21 :             s->rl_table_index = 2;
     461             : 
     462          21 :             s->dc_table_index = 0; //not used
     463          21 :             break;
     464          23 :         case 3:
     465          23 :             s->rl_chroma_table_index = decode012(&s->gb);
     466          23 :             s->rl_table_index = decode012(&s->gb);
     467             : 
     468          23 :             s->dc_table_index = get_bits1(&s->gb);
     469          23 :             break;
     470          20 :         case 4:
     471          20 :             ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
     472             : 
     473          20 :             if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
     474           0 :             else                           s->per_mb_rl_table= 0;
     475             : 
     476          20 :             if(!s->per_mb_rl_table){
     477          20 :                 s->rl_chroma_table_index = decode012(&s->gb);
     478          20 :                 s->rl_table_index = decode012(&s->gb);
     479             :             }
     480             : 
     481          20 :             s->dc_table_index = get_bits1(&s->gb);
     482          20 :             s->inter_intra_pred= 0;
     483          20 :             break;
     484             :         }
     485          64 :         s->no_rounding = 1;
     486          64 :         if(s->avctx->debug&FF_DEBUG_PICT_INFO)
     487           0 :             av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d   \n",
     488             :                 s->qscale,
     489             :                 s->rl_chroma_table_index,
     490             :                 s->rl_table_index,
     491             :                 s->dc_table_index,
     492             :                 s->per_mb_rl_table,
     493             :                 s->slice_height);
     494             :     } else {
     495         611 :         switch(s->msmpeg4_version){
     496         229 :         case 1:
     497             :         case 2:
     498         229 :             if(s->msmpeg4_version==1)
     499          49 :                 s->use_skip_mb_code = 1;
     500             :             else
     501         180 :                 s->use_skip_mb_code = get_bits1(&s->gb);
     502         229 :             s->rl_table_index = 2;
     503         229 :             s->rl_chroma_table_index = s->rl_table_index;
     504         229 :             s->dc_table_index = 0; //not used
     505         229 :             s->mv_table_index = 0;
     506         229 :             break;
     507         202 :         case 3:
     508         202 :             s->use_skip_mb_code = get_bits1(&s->gb);
     509         202 :             s->rl_table_index = decode012(&s->gb);
     510         202 :             s->rl_chroma_table_index = s->rl_table_index;
     511             : 
     512         202 :             s->dc_table_index = get_bits1(&s->gb);
     513             : 
     514         202 :             s->mv_table_index = get_bits1(&s->gb);
     515         202 :             break;
     516         180 :         case 4:
     517         180 :             s->use_skip_mb_code = get_bits1(&s->gb);
     518             : 
     519         180 :             if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
     520           0 :             else                           s->per_mb_rl_table= 0;
     521             : 
     522         180 :             if(!s->per_mb_rl_table){
     523         180 :                 s->rl_table_index = decode012(&s->gb);
     524         180 :                 s->rl_chroma_table_index = s->rl_table_index;
     525             :             }
     526             : 
     527         180 :             s->dc_table_index = get_bits1(&s->gb);
     528             : 
     529         180 :             s->mv_table_index = get_bits1(&s->gb);
     530         180 :             s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
     531         180 :             break;
     532             :         }
     533             : 
     534         611 :         if(s->avctx->debug&FF_DEBUG_PICT_INFO)
     535           0 :             av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d   \n",
     536             :                 s->use_skip_mb_code,
     537             :                 s->rl_table_index,
     538             :                 s->rl_chroma_table_index,
     539             :                 s->dc_table_index,
     540             :                 s->mv_table_index,
     541             :                 s->per_mb_rl_table,
     542             :                 s->qscale);
     543             : 
     544         611 :         if(s->flipflop_rounding){
     545         382 :             s->no_rounding ^= 1;
     546             :         }else{
     547         229 :             s->no_rounding = 0;
     548             :         }
     549             :     }
     550             :     ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
     551             :             s->inter_intra_pred, s->width, s->height);
     552             : 
     553         675 :     s->esc3_level_length= 0;
     554         675 :     s->esc3_run_length= 0;
     555             : 
     556         675 :     return 0;
     557             : }
     558             : 
     559          64 : int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
     560             : {
     561          64 :     int left= buf_size*8 - get_bits_count(&s->gb);
     562          64 :     int length= s->msmpeg4_version>=3 ? 17 : 16;
     563             :     /* the alt_bitstream reader could read over the end so we need to check it */
     564          64 :     if(left>=length && left<length+8)
     565             :     {
     566          63 :         skip_bits(&s->gb, 5); /* fps */
     567          63 :         s->bit_rate= get_bits(&s->gb, 11)*1024;
     568         126 :         if(s->msmpeg4_version>=3)
     569          43 :             s->flipflop_rounding= get_bits1(&s->gb);
     570             :         else
     571          20 :             s->flipflop_rounding= 0;
     572             :     }
     573           1 :     else if(left<length+8)
     574             :     {
     575           1 :         s->flipflop_rounding= 0;
     576           1 :         if(s->msmpeg4_version != 2)
     577           1 :             av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
     578             :     }
     579             :     else
     580             :     {
     581           0 :         av_log(s->avctx, AV_LOG_ERROR, "I-frame too long, ignoring ext header\n");
     582             :     }
     583             : 
     584          64 :     return 0;
     585             : }
     586             : 
     587      230712 : static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
     588             : {
     589             :     int level, pred;
     590             : 
     591      230712 :     if(s->msmpeg4_version<=2){
     592       54342 :         if (n < 4) {
     593       36228 :             level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
     594             :         } else {
     595       18114 :             level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
     596             :         }
     597       54342 :         if (level < 0) {
     598           0 :             av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
     599           0 :             *dir_ptr = 0;
     600           0 :             return -1;
     601             :         }
     602       54342 :         level-=256;
     603             :     }else{  //FIXME optimize use unified tables & index
     604      176370 :         if (n < 4) {
     605      117580 :             level = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     606             :         } else {
     607       58790 :             level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     608             :         }
     609      176370 :         if (level < 0){
     610           0 :             av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
     611           0 :             *dir_ptr = 0;
     612           0 :             return -1;
     613             :         }
     614             : 
     615      176370 :         if (level == DC_MAX) {
     616          48 :             level = get_bits(&s->gb, 8);
     617          48 :             if (get_bits1(&s->gb))
     618           6 :                 level = -level;
     619      176322 :         } else if (level != 0) {
     620      153813 :             if (get_bits1(&s->gb))
     621       74512 :                 level = -level;
     622             :         }
     623             :     }
     624             : 
     625      230712 :     if(s->msmpeg4_version==1){
     626             :         int32_t *dc_val;
     627        5490 :         pred = msmpeg4v1_pred_dc(s, n, &dc_val);
     628        5490 :         level += pred;
     629             : 
     630             :         /* update predictor */
     631        5490 :         *dc_val= level;
     632             :     }else{
     633             :         int16_t *dc_val;
     634      225222 :         pred   = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
     635      225222 :         level += pred;
     636             : 
     637             :         /* update predictor */
     638      225222 :         if (n < 4) {
     639      150148 :             *dc_val = level * s->y_dc_scale;
     640             :         } else {
     641       75074 :             *dc_val = level * s->c_dc_scale;
     642             :         }
     643             :     }
     644             : 
     645      230712 :     return level;
     646             : }
     647             : 
     648     1472610 : int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
     649             :                               int n, int coded, const uint8_t *scan_table)
     650             : {
     651             :     int level, i, last, run, run_diff;
     652     1472610 :     int av_uninit(dc_pred_dir);
     653             :     RLTable *rl;
     654             :     RL_VLC_ELEM *rl_vlc;
     655             :     int qmul, qadd;
     656             : 
     657     1472610 :     if (s->mb_intra) {
     658      230712 :         qmul=1;
     659      230712 :         qadd=0;
     660             : 
     661             :         /* DC coef */
     662      230712 :         level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
     663             : 
     664      230712 :         if (level < 0){
     665           0 :             av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
     666           0 :             if(s->inter_intra_pred) level=0;
     667             :         }
     668      230712 :         if (n < 4) {
     669      153808 :             rl = &ff_rl_table[s->rl_table_index];
     670      153808 :             if(level > 256*s->y_dc_scale){
     671           0 :                 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
     672           0 :                 if(!s->inter_intra_pred) return -1;
     673             :             }
     674             :         } else {
     675       76904 :             rl = &ff_rl_table[3 + s->rl_chroma_table_index];
     676       76904 :             if(level > 256*s->c_dc_scale){
     677           0 :                 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
     678           0 :                 if(!s->inter_intra_pred) return -1;
     679             :             }
     680             :         }
     681      230712 :         block[0] = level;
     682             : 
     683      230712 :         run_diff = s->msmpeg4_version >= 4;
     684      230712 :         i = 0;
     685      230712 :         if (!coded) {
     686       42456 :             goto not_coded;
     687             :         }
     688      188256 :         if (s->ac_pred) {
     689        3224 :             if (dc_pred_dir == 0)
     690        1928 :                 scan_table = s->intra_v_scantable.permutated; /* left */
     691             :             else
     692        1296 :                 scan_table = s->intra_h_scantable.permutated; /* top */
     693             :         } else {
     694      185032 :             scan_table = s->intra_scantable.permutated;
     695             :         }
     696      188256 :         rl_vlc= rl->rl_vlc[0];
     697             :     } else {
     698     1241898 :         qmul = s->qscale << 1;
     699     1241898 :         qadd = (s->qscale - 1) | 1;
     700     1241898 :         i = -1;
     701     1241898 :         rl = &ff_rl_table[3 + s->rl_table_index];
     702             : 
     703     1241898 :         if(s->msmpeg4_version==2)
     704      306018 :             run_diff = 0;
     705             :         else
     706      935880 :             run_diff = 1;
     707             : 
     708     1241898 :         if (!coded) {
     709      633723 :             s->block_last_index[n] = i;
     710      633723 :             return 0;
     711             :         }
     712      608175 :         if(!scan_table)
     713      420993 :             scan_table = s->inter_scantable.permutated;
     714      608175 :         rl_vlc= rl->rl_vlc[s->qscale];
     715             :     }
     716             :   {
     717      796431 :     OPEN_READER(re, &s->gb);
     718             :     for(;;) {
     719     9175903 :         UPDATE_CACHE(re, &s->gb);
     720     4986167 :         GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
     721     4986167 :         if (level==0) {
     722             :             int cache;
     723      162066 :             cache= GET_CACHE(re, &s->gb);
     724             :             /* escape */
     725      162066 :             if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
     726      192784 :                 if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
     727             :                     /* third escape */
     728       41550 :                     if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
     729       41550 :                     UPDATE_CACHE(re, &s->gb);
     730       41550 :                     if(s->msmpeg4_version<=3){
     731       34734 :                         last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
     732       34734 :                         run=   SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
     733       34734 :                         level= SHOW_SBITS(re, &s->gb, 8);
     734       34734 :                         SKIP_COUNTER(re, &s->gb, 1+6+8);
     735             :                     }else{
     736             :                         int sign;
     737        6816 :                         last=  SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
     738        6816 :                         if(!s->esc3_level_length){
     739             :                             int ll;
     740             :                             ff_dlog(s->avctx, "ESC-3 %X at %d %d\n",
     741             :                                     show_bits(&s->gb, 24), s->mb_x, s->mb_y);
     742         384 :                             if(s->qscale<8){
     743          78 :                                 ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
     744          78 :                                 if(ll==0){
     745           0 :                                     ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
     746             :                                 }
     747             :                             }else{
     748         306 :                                 ll=2;
     749        2320 :                                 while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
     750        1708 :                                     ll++;
     751        1708 :                                     SKIP_BITS(re, &s->gb, 1);
     752             :                                 }
     753         306 :                                 if(ll<8) SKIP_BITS(re, &s->gb, 1);
     754             :                             }
     755             : 
     756         384 :                             s->esc3_level_length= ll;
     757         384 :                             s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
     758         384 :                             UPDATE_CACHE(re, &s->gb);
     759             :                         }
     760        6816 :                         run=   SHOW_UBITS(re, &s->gb, s->esc3_run_length);
     761        6816 :                         SKIP_BITS(re, &s->gb, s->esc3_run_length);
     762             : 
     763        6816 :                         sign=  SHOW_UBITS(re, &s->gb, 1);
     764        6816 :                         SKIP_BITS(re, &s->gb, 1);
     765             : 
     766        6816 :                         level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
     767        6816 :                         SKIP_BITS(re, &s->gb, s->esc3_level_length);
     768        6816 :                         if(sign) level= -level;
     769             :                     }
     770             : 
     771             :                     //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
     772       41550 :                     if (level>0) level= level * qmul + qadd;
     773       20607 :                     else         level= level * qmul - qadd;
     774       41550 :                     i+= run + 1;
     775       41550 :                     if(last) i+=192;
     776             :                 } else {
     777             :                     /* second escape */
     778       54842 :                     SKIP_BITS(re, &s->gb, 2);
     779       54842 :                     GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
     780       54842 :                     i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
     781       54842 :                     level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
     782       54842 :                     LAST_SKIP_BITS(re, &s->gb, 1);
     783             :                 }
     784             :             } else {
     785             :                 /* first escape */
     786       65674 :                 SKIP_BITS(re, &s->gb, 1);
     787       65674 :                 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
     788       65674 :                 i+= run;
     789       65674 :                 level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
     790       65674 :                 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
     791       65674 :                 LAST_SKIP_BITS(re, &s->gb, 1);
     792             :             }
     793             :         } else {
     794     4824101 :             i+= run;
     795     4824101 :             level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
     796     4824101 :             LAST_SKIP_BITS(re, &s->gb, 1);
     797             :         }
     798     4986167 :         if (i > 62){
     799      796431 :             i-= 192;
     800      796431 :             if(i&(~63)){
     801           0 :                 const int left= get_bits_left(&s->gb);
     802           0 :                 if (((i + 192 == 64 && level / qmul == -1) ||
     803           0 :                      !(s->avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))) &&
     804             :                     left >= 0) {
     805           0 :                     av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
     806           0 :                     i = 63;
     807           0 :                     break;
     808             :                 }else{
     809           0 :                     av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
     810           0 :                     return -1;
     811             :                 }
     812             :             }
     813             : 
     814      796431 :             block[scan_table[i]] = level;
     815      796431 :             break;
     816             :         }
     817             : 
     818     4189736 :         block[scan_table[i]] = level;
     819             :     }
     820      796431 :     CLOSE_READER(re, &s->gb);
     821             :   }
     822      838887 :  not_coded:
     823      838887 :     if (s->mb_intra) {
     824      230712 :         ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
     825      230712 :         if (s->ac_pred) {
     826        4194 :             i = 63; /* XXX: not optimal */
     827             :         }
     828             :     }
     829      838887 :     if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
     830      838887 :     s->block_last_index[n] = i;
     831             : 
     832      838887 :     return 0;
     833             : }
     834             : 
     835      228076 : int ff_msmpeg4_decode_motion(MpegEncContext * s,
     836             :                                  int *mx_ptr, int *my_ptr)
     837             : {
     838             :     MVTable *mv;
     839             :     int code, mx, my;
     840             : 
     841      228076 :     mv = &ff_mv_tables[s->mv_table_index];
     842             : 
     843      228076 :     code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
     844      228076 :     if (code < 0){
     845           0 :         av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
     846           0 :         return -1;
     847             :     }
     848      228076 :     if (code == mv->n) {
     849        1856 :         mx = get_bits(&s->gb, 6);
     850        1856 :         my = get_bits(&s->gb, 6);
     851             :     } else {
     852      226220 :         mx = mv->table_mvx[code];
     853      226220 :         my = mv->table_mvy[code];
     854             :     }
     855             : 
     856      228076 :     mx += *mx_ptr - 32;
     857      228076 :     my += *my_ptr - 32;
     858             :     /* WARNING : they do not do exactly modulo encoding */
     859      228076 :     if (mx <= -64)
     860          22 :         mx += 64;
     861      228054 :     else if (mx >= 64)
     862          10 :         mx -= 64;
     863             : 
     864      228076 :     if (my <= -64)
     865           6 :         my += 64;
     866      228070 :     else if (my >= 64)
     867           4 :         my -= 64;
     868      228076 :     *mx_ptr = mx;
     869      228076 :     *my_ptr = my;
     870      228076 :     return 0;
     871             : }
     872             : 
     873             : AVCodec ff_msmpeg4v1_decoder = {
     874             :     .name           = "msmpeg4v1",
     875             :     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
     876             :     .type           = AVMEDIA_TYPE_VIDEO,
     877             :     .id             = AV_CODEC_ID_MSMPEG4V1,
     878             :     .priv_data_size = sizeof(MpegEncContext),
     879             :     .init           = ff_msmpeg4_decode_init,
     880             :     .close          = ff_h263_decode_end,
     881             :     .decode         = ff_h263_decode_frame,
     882             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     883             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     884             :     .max_lowres     = 3,
     885             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     886             :         AV_PIX_FMT_YUV420P,
     887             :         AV_PIX_FMT_NONE
     888             :     },
     889             : };
     890             : 
     891             : AVCodec ff_msmpeg4v2_decoder = {
     892             :     .name           = "msmpeg4v2",
     893             :     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
     894             :     .type           = AVMEDIA_TYPE_VIDEO,
     895             :     .id             = AV_CODEC_ID_MSMPEG4V2,
     896             :     .priv_data_size = sizeof(MpegEncContext),
     897             :     .init           = ff_msmpeg4_decode_init,
     898             :     .close          = ff_h263_decode_end,
     899             :     .decode         = ff_h263_decode_frame,
     900             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     901             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     902             :     .max_lowres     = 3,
     903             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     904             :         AV_PIX_FMT_YUV420P,
     905             :         AV_PIX_FMT_NONE
     906             :     },
     907             : };
     908             : 
     909             : AVCodec ff_msmpeg4v3_decoder = {
     910             :     .name           = "msmpeg4",
     911             :     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
     912             :     .type           = AVMEDIA_TYPE_VIDEO,
     913             :     .id             = AV_CODEC_ID_MSMPEG4V3,
     914             :     .priv_data_size = sizeof(MpegEncContext),
     915             :     .init           = ff_msmpeg4_decode_init,
     916             :     .close          = ff_h263_decode_end,
     917             :     .decode         = ff_h263_decode_frame,
     918             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     919             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     920             :     .max_lowres     = 3,
     921             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     922             :         AV_PIX_FMT_YUV420P,
     923             :         AV_PIX_FMT_NONE
     924             :     },
     925             : };
     926             : 
     927             : AVCodec ff_wmv1_decoder = {
     928             :     .name           = "wmv1",
     929             :     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
     930             :     .type           = AVMEDIA_TYPE_VIDEO,
     931             :     .id             = AV_CODEC_ID_WMV1,
     932             :     .priv_data_size = sizeof(MpegEncContext),
     933             :     .init           = ff_msmpeg4_decode_init,
     934             :     .close          = ff_h263_decode_end,
     935             :     .decode         = ff_h263_decode_frame,
     936             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     937             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     938             :     .max_lowres     = 3,
     939             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     940             :         AV_PIX_FMT_YUV420P,
     941             :         AV_PIX_FMT_NONE
     942             :     },
     943             : };

Generated by: LCOV version 1.13