LCOV - code coverage report
Current view: top level - libavcodec - msmpeg4dec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 410 476 86.1 %
Date: 2017-12-18 20:14:19 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 (s->pict_type == AV_PICTURE_TYPE_P) {
     212      116442 :         if (s->use_skip_mb_code) {
     213      116442 :             if (get_bits1(&s->gb)) {
     214             :                 /* skip mb */
     215        1554 :                 s->mb_intra = 0;
     216       10878 :                 for(i=0;i<6;i++)
     217        9324 :                     s->block_last_index[i] = -1;
     218        1554 :                 s->mv_dir = MV_DIR_FORWARD;
     219        1554 :                 s->mv_type = MV_TYPE_16X16;
     220        1554 :                 s->mv[0][0][0] = 0;
     221        1554 :                 s->mv[0][0][1] = 0;
     222        1554 :                 s->mb_skipped = 1;
     223        1554 :                 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
     224             : 
     225        1554 :                 return 0;
     226             :             }
     227             :         }
     228             : 
     229      114888 :         code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
     230      114888 :         if (code < 0)
     231           0 :             return -1;
     232             :         //s->mb_intra = (code & 0x40) ? 0 : 1;
     233      114888 :         s->mb_intra = (~code & 0x40) >> 6;
     234             : 
     235      114888 :         cbp = code & 0x3f;
     236             :     } else {
     237       13158 :         s->mb_intra = 1;
     238       13158 :         code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
     239       13158 :         if (code < 0)
     240           0 :             return -1;
     241             :         /* predict coded block pattern */
     242       13158 :         cbp = 0;
     243       92106 :         for(i=0;i<6;i++) {
     244       78948 :             int val = ((code >> (5 - i)) & 1);
     245       78948 :             if (i < 4) {
     246       52632 :                 int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
     247       52632 :                 val = val ^ pred;
     248       52632 :                 *coded_val = val;
     249             :             }
     250       78948 :             cbp |= val << (5 - i);
     251             :         }
     252             :     }
     253             : 
     254      128046 :     if (!s->mb_intra) {
     255             :         int mx, my;
     256      109652 :         if(s->per_mb_rl_table && cbp){
     257           0 :             s->rl_table_index = decode012(&s->gb);
     258           0 :             s->rl_chroma_table_index = s->rl_table_index;
     259             :         }
     260      109652 :         ff_h263_pred_motion(s, 0, 0, &mx, &my);
     261      109652 :         if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
     262           0 :             return -1;
     263      109652 :         s->mv_dir = MV_DIR_FORWARD;
     264      109652 :         s->mv_type = MV_TYPE_16X16;
     265      109652 :         s->mv[0][0][0] = mx;
     266      109652 :         s->mv[0][0][1] = my;
     267      109652 :         *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
     268             :     } else {
     269             :         ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
     270             :                 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
     271             :                 show_bits(&s->gb, 24));
     272       18394 :         s->ac_pred = get_bits1(&s->gb);
     273       18394 :         *mb_type_ptr = MB_TYPE_INTRA;
     274       18394 :         if(s->inter_intra_pred){
     275           0 :             s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
     276             :             ff_dlog(s, "%d%d %d %d/",
     277             :                     s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
     278             :         }
     279       18394 :         if(s->per_mb_rl_table && cbp){
     280           0 :             s->rl_table_index = decode012(&s->gb);
     281           0 :             s->rl_chroma_table_index = s->rl_table_index;
     282             :         }
     283             :     }
     284             : 
     285      128046 :     s->bdsp.clear_blocks(s->block[0]);
     286      896322 :     for (i = 0; i < 6; i++) {
     287      768276 :         if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
     288             :         {
     289           0 :             av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
     290           0 :             return -1;
     291             :         }
     292             :     }
     293             : 
     294      128046 :     return 0;
     295             : }
     296             : 
     297             : /* init all vlc decoding tables */
     298          81 : av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
     299             : {
     300          81 :     MpegEncContext *s = avctx->priv_data;
     301             :     static volatile int done = 0;
     302             :     int i, ret;
     303             :     MVTable *mv;
     304             : 
     305          81 :     if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
     306           0 :         return ret;
     307             : 
     308          81 :     if (ff_h263_decode_init(avctx) < 0)
     309           0 :         return -1;
     310             : 
     311          81 :     ff_msmpeg4_common_init(s);
     312             : 
     313          81 :     if (!done) {
     314         287 :         for(i=0;i<NB_RL_TABLES;i++) {
     315         246 :             ff_rl_init(&ff_rl_table[i], ff_static_rl_table_store[i]);
     316             :         }
     317          41 :         INIT_VLC_RL(ff_rl_table[0], 642);
     318          41 :         INIT_VLC_RL(ff_rl_table[1], 1104);
     319          41 :         INIT_VLC_RL(ff_rl_table[2], 554);
     320          41 :         INIT_VLC_RL(ff_rl_table[3], 940);
     321          41 :         INIT_VLC_RL(ff_rl_table[4], 962);
     322          41 :         INIT_VLC_RL(ff_rl_table[5], 554);
     323             : 
     324          41 :         mv = &ff_mv_tables[0];
     325          41 :         INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
     326             :                     mv->table_mv_bits, 1, 1,
     327             :                     mv->table_mv_code, 2, 2, 3714);
     328          41 :         mv = &ff_mv_tables[1];
     329          41 :         INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
     330             :                     mv->table_mv_bits, 1, 1,
     331             :                     mv->table_mv_code, 2, 2, 2694);
     332             : 
     333          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
     334             :                  &ff_table0_dc_lum[0][1], 8, 4,
     335             :                  &ff_table0_dc_lum[0][0], 8, 4, 1158);
     336          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
     337             :                  &ff_table0_dc_chroma[0][1], 8, 4,
     338             :                  &ff_table0_dc_chroma[0][0], 8, 4, 1118);
     339          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
     340             :                  &ff_table1_dc_lum[0][1], 8, 4,
     341             :                  &ff_table1_dc_lum[0][0], 8, 4, 1476);
     342          41 :         INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
     343             :                  &ff_table1_dc_chroma[0][1], 8, 4,
     344             :                  &ff_table1_dc_chroma[0][0], 8, 4, 1216);
     345             : 
     346          41 :         INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
     347             :                  &ff_v2_dc_lum_table[0][1], 8, 4,
     348             :                  &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
     349          41 :         INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
     350             :                  &ff_v2_dc_chroma_table[0][1], 8, 4,
     351             :                  &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
     352             : 
     353          41 :         INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
     354             :                  &ff_v2_intra_cbpc[0][1], 2, 1,
     355             :                  &ff_v2_intra_cbpc[0][0], 2, 1, 8);
     356          41 :         INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
     357             :                  &ff_v2_mb_type[0][1], 2, 1,
     358             :                  &ff_v2_mb_type[0][0], 2, 1, 128);
     359          41 :         INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
     360             :                  &ff_mvtab[0][1], 2, 1,
     361             :                  &ff_mvtab[0][0], 2, 1, 538);
     362             : 
     363          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
     364             :                      &ff_wmv2_inter_table[0][0][1], 8, 4,
     365             :                      &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
     366          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
     367             :                      &ff_wmv2_inter_table[1][0][1], 8, 4,
     368             :                      &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
     369          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
     370             :                      &ff_wmv2_inter_table[2][0][1], 8, 4,
     371             :                      &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
     372          41 :         INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
     373             :                      &ff_wmv2_inter_table[3][0][1], 8, 4,
     374             :                      &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
     375             : 
     376          41 :         INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
     377             :                  &ff_msmp4_mb_i_table[0][1], 4, 2,
     378             :                  &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
     379             : 
     380          41 :         INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
     381             :                  &ff_table_inter_intra[0][1], 2, 1,
     382             :                  &ff_table_inter_intra[0][0], 2, 1, 8);
     383          41 :         done = 1;
     384             :     }
     385             : 
     386          81 :     switch(s->msmpeg4_version){
     387          11 :     case 1:
     388             :     case 2:
     389          11 :         s->decode_mb= msmpeg4v12_decode_mb;
     390          11 :         break;
     391          22 :     case 3:
     392             :     case 4:
     393          22 :         s->decode_mb= msmpeg4v34_decode_mb;
     394          22 :         break;
     395          12 :     case 5:
     396             :         if (CONFIG_WMV2_DECODER)
     397          12 :             s->decode_mb= ff_wmv2_decode_mb;
     398             :     case 6:
     399             :         //FIXME + TODO VC1 decode mb
     400          48 :         break;
     401             :     }
     402             : 
     403          81 :     s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
     404             : 
     405          81 :     return 0;
     406             : }
     407             : 
     408         675 : int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
     409             : {
     410             :     int code;
     411             : 
     412         675 :     if(s->msmpeg4_version==1){
     413          50 :         int start_code = get_bits_long(&s->gb, 32);
     414          50 :         if(start_code!=0x00000100){
     415           0 :             av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
     416           0 :             return -1;
     417             :         }
     418             : 
     419          50 :         skip_bits(&s->gb, 5); // frame number */
     420             :     }
     421             : 
     422         675 :     s->pict_type = get_bits(&s->gb, 2) + 1;
     423        1286 :     if (s->pict_type != AV_PICTURE_TYPE_I &&
     424         611 :         s->pict_type != AV_PICTURE_TYPE_P){
     425           0 :         av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
     426           0 :         return -1;
     427             :     }
     428         675 :     s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
     429         675 :     if(s->qscale==0){
     430           0 :         av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
     431           0 :         return -1;
     432             :     }
     433             : 
     434         675 :     if (s->pict_type == AV_PICTURE_TYPE_I) {
     435          64 :         code = get_bits(&s->gb, 5);
     436          64 :         if(s->msmpeg4_version==1){
     437           1 :             if(code==0 || code>s->mb_height){
     438           0 :                 av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
     439           0 :                 return -1;
     440             :             }
     441             : 
     442           1 :             s->slice_height = code;
     443             :         }else{
     444             :             /* 0x17: one slice, 0x18: two slices, ... */
     445          63 :             if (code < 0x17){
     446           0 :                 av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
     447           0 :                 return -1;
     448             :             }
     449             : 
     450          63 :             s->slice_height = s->mb_height / (code - 0x16);
     451             :         }
     452             : 
     453          64 :         switch(s->msmpeg4_version){
     454          21 :         case 1:
     455             :         case 2:
     456          21 :             s->rl_chroma_table_index = 2;
     457          21 :             s->rl_table_index = 2;
     458             : 
     459          21 :             s->dc_table_index = 0; //not used
     460          21 :             break;
     461          23 :         case 3:
     462          23 :             s->rl_chroma_table_index = decode012(&s->gb);
     463          23 :             s->rl_table_index = decode012(&s->gb);
     464             : 
     465          23 :             s->dc_table_index = get_bits1(&s->gb);
     466          23 :             break;
     467          20 :         case 4:
     468          20 :             ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
     469             : 
     470          20 :             if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
     471           0 :             else                           s->per_mb_rl_table= 0;
     472             : 
     473          20 :             if(!s->per_mb_rl_table){
     474          20 :                 s->rl_chroma_table_index = decode012(&s->gb);
     475          20 :                 s->rl_table_index = decode012(&s->gb);
     476             :             }
     477             : 
     478          20 :             s->dc_table_index = get_bits1(&s->gb);
     479          20 :             s->inter_intra_pred= 0;
     480          20 :             break;
     481             :         }
     482          64 :         s->no_rounding = 1;
     483          64 :         if(s->avctx->debug&FF_DEBUG_PICT_INFO)
     484           0 :             av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d   \n",
     485             :                 s->qscale,
     486             :                 s->rl_chroma_table_index,
     487             :                 s->rl_table_index,
     488             :                 s->dc_table_index,
     489             :                 s->per_mb_rl_table,
     490             :                 s->slice_height);
     491             :     } else {
     492         611 :         switch(s->msmpeg4_version){
     493         229 :         case 1:
     494             :         case 2:
     495         229 :             if(s->msmpeg4_version==1)
     496          49 :                 s->use_skip_mb_code = 1;
     497             :             else
     498         180 :                 s->use_skip_mb_code = get_bits1(&s->gb);
     499         229 :             s->rl_table_index = 2;
     500         229 :             s->rl_chroma_table_index = s->rl_table_index;
     501         229 :             s->dc_table_index = 0; //not used
     502         229 :             s->mv_table_index = 0;
     503         229 :             break;
     504         202 :         case 3:
     505         202 :             s->use_skip_mb_code = get_bits1(&s->gb);
     506         202 :             s->rl_table_index = decode012(&s->gb);
     507         202 :             s->rl_chroma_table_index = s->rl_table_index;
     508             : 
     509         202 :             s->dc_table_index = get_bits1(&s->gb);
     510             : 
     511         202 :             s->mv_table_index = get_bits1(&s->gb);
     512         202 :             break;
     513         180 :         case 4:
     514         180 :             s->use_skip_mb_code = get_bits1(&s->gb);
     515             : 
     516         180 :             if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
     517           0 :             else                           s->per_mb_rl_table= 0;
     518             : 
     519         180 :             if(!s->per_mb_rl_table){
     520         180 :                 s->rl_table_index = decode012(&s->gb);
     521         180 :                 s->rl_chroma_table_index = s->rl_table_index;
     522             :             }
     523             : 
     524         180 :             s->dc_table_index = get_bits1(&s->gb);
     525             : 
     526         180 :             s->mv_table_index = get_bits1(&s->gb);
     527         180 :             s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
     528         180 :             break;
     529             :         }
     530             : 
     531         611 :         if(s->avctx->debug&FF_DEBUG_PICT_INFO)
     532           0 :             av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d   \n",
     533             :                 s->use_skip_mb_code,
     534             :                 s->rl_table_index,
     535             :                 s->rl_chroma_table_index,
     536             :                 s->dc_table_index,
     537             :                 s->mv_table_index,
     538             :                 s->per_mb_rl_table,
     539             :                 s->qscale);
     540             : 
     541         611 :         if(s->flipflop_rounding){
     542         382 :             s->no_rounding ^= 1;
     543             :         }else{
     544         229 :             s->no_rounding = 0;
     545             :         }
     546             :     }
     547             :     ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
     548             :             s->inter_intra_pred, s->width, s->height);
     549             : 
     550         675 :     s->esc3_level_length= 0;
     551         675 :     s->esc3_run_length= 0;
     552             : 
     553         675 :     return 0;
     554             : }
     555             : 
     556          64 : int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
     557             : {
     558          64 :     int left= buf_size*8 - get_bits_count(&s->gb);
     559          64 :     int length= s->msmpeg4_version>=3 ? 17 : 16;
     560             :     /* the alt_bitstream reader could read over the end so we need to check it */
     561          64 :     if(left>=length && left<length+8)
     562             :     {
     563          63 :         skip_bits(&s->gb, 5); /* fps */
     564          63 :         s->bit_rate= get_bits(&s->gb, 11)*1024;
     565         126 :         if(s->msmpeg4_version>=3)
     566          43 :             s->flipflop_rounding= get_bits1(&s->gb);
     567             :         else
     568          20 :             s->flipflop_rounding= 0;
     569             :     }
     570           1 :     else if(left<length+8)
     571             :     {
     572           1 :         s->flipflop_rounding= 0;
     573           1 :         if(s->msmpeg4_version != 2)
     574           1 :             av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
     575             :     }
     576             :     else
     577             :     {
     578           0 :         av_log(s->avctx, AV_LOG_ERROR, "I-frame too long, ignoring ext header\n");
     579             :     }
     580             : 
     581          64 :     return 0;
     582             : }
     583             : 
     584      230712 : static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
     585             : {
     586             :     int level, pred;
     587             : 
     588      230712 :     if(s->msmpeg4_version<=2){
     589       54342 :         if (n < 4) {
     590       36228 :             level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
     591             :         } else {
     592       18114 :             level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
     593             :         }
     594       54342 :         if (level < 0) {
     595           0 :             av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
     596           0 :             *dir_ptr = 0;
     597           0 :             return -1;
     598             :         }
     599       54342 :         level-=256;
     600             :     }else{  //FIXME optimize use unified tables & index
     601      176370 :         if (n < 4) {
     602      117580 :             level = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     603             :         } else {
     604       58790 :             level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
     605             :         }
     606      176370 :         if (level < 0){
     607           0 :             av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
     608           0 :             *dir_ptr = 0;
     609           0 :             return -1;
     610             :         }
     611             : 
     612      176370 :         if (level == DC_MAX) {
     613          48 :             level = get_bits(&s->gb, 8);
     614          48 :             if (get_bits1(&s->gb))
     615           6 :                 level = -level;
     616      176322 :         } else if (level != 0) {
     617      153813 :             if (get_bits1(&s->gb))
     618       74512 :                 level = -level;
     619             :         }
     620             :     }
     621             : 
     622      230712 :     if(s->msmpeg4_version==1){
     623             :         int32_t *dc_val;
     624        5490 :         pred = msmpeg4v1_pred_dc(s, n, &dc_val);
     625        5490 :         level += pred;
     626             : 
     627             :         /* update predictor */
     628        5490 :         *dc_val= level;
     629             :     }else{
     630             :         int16_t *dc_val;
     631      225222 :         pred   = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
     632      225222 :         level += pred;
     633             : 
     634             :         /* update predictor */
     635      225222 :         if (n < 4) {
     636      150148 :             *dc_val = level * s->y_dc_scale;
     637             :         } else {
     638       75074 :             *dc_val = level * s->c_dc_scale;
     639             :         }
     640             :     }
     641             : 
     642      230712 :     return level;
     643             : }
     644             : 
     645     1472610 : int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
     646             :                               int n, int coded, const uint8_t *scan_table)
     647             : {
     648             :     int level, i, last, run, run_diff;
     649     1472610 :     int av_uninit(dc_pred_dir);
     650             :     RLTable *rl;
     651             :     RL_VLC_ELEM *rl_vlc;
     652             :     int qmul, qadd;
     653             : 
     654     1472610 :     if (s->mb_intra) {
     655      230712 :         qmul=1;
     656      230712 :         qadd=0;
     657             : 
     658             :         /* DC coef */
     659      230712 :         level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
     660             : 
     661      230712 :         if (level < 0){
     662           0 :             av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
     663           0 :             if(s->inter_intra_pred) level=0;
     664             :         }
     665      230712 :         if (n < 4) {
     666      153808 :             rl = &ff_rl_table[s->rl_table_index];
     667      153808 :             if(level > 256*s->y_dc_scale){
     668           0 :                 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
     669           0 :                 if(!s->inter_intra_pred) return -1;
     670             :             }
     671             :         } else {
     672       76904 :             rl = &ff_rl_table[3 + s->rl_chroma_table_index];
     673       76904 :             if(level > 256*s->c_dc_scale){
     674           0 :                 av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
     675           0 :                 if(!s->inter_intra_pred) return -1;
     676             :             }
     677             :         }
     678      230712 :         block[0] = level;
     679             : 
     680      230712 :         run_diff = s->msmpeg4_version >= 4;
     681      230712 :         i = 0;
     682      230712 :         if (!coded) {
     683       42456 :             goto not_coded;
     684             :         }
     685      188256 :         if (s->ac_pred) {
     686        3224 :             if (dc_pred_dir == 0)
     687        1928 :                 scan_table = s->intra_v_scantable.permutated; /* left */
     688             :             else
     689        1296 :                 scan_table = s->intra_h_scantable.permutated; /* top */
     690             :         } else {
     691      185032 :             scan_table = s->intra_scantable.permutated;
     692             :         }
     693      188256 :         rl_vlc= rl->rl_vlc[0];
     694             :     } else {
     695     1241898 :         qmul = s->qscale << 1;
     696     1241898 :         qadd = (s->qscale - 1) | 1;
     697     1241898 :         i = -1;
     698     1241898 :         rl = &ff_rl_table[3 + s->rl_table_index];
     699             : 
     700     1241898 :         if(s->msmpeg4_version==2)
     701      306018 :             run_diff = 0;
     702             :         else
     703      935880 :             run_diff = 1;
     704             : 
     705     1241898 :         if (!coded) {
     706      633723 :             s->block_last_index[n] = i;
     707      633723 :             return 0;
     708             :         }
     709      608175 :         if(!scan_table)
     710      420993 :             scan_table = s->inter_scantable.permutated;
     711      608175 :         rl_vlc= rl->rl_vlc[s->qscale];
     712             :     }
     713             :   {
     714      796431 :     OPEN_READER(re, &s->gb);
     715             :     for(;;) {
     716     9175903 :         UPDATE_CACHE(re, &s->gb);
     717     4986167 :         GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
     718     4986167 :         if (level==0) {
     719             :             int cache;
     720      162066 :             cache= GET_CACHE(re, &s->gb);
     721             :             /* escape */
     722      162066 :             if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
     723      192784 :                 if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
     724             :                     /* third escape */
     725       41550 :                     if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
     726       41550 :                     UPDATE_CACHE(re, &s->gb);
     727       41550 :                     if(s->msmpeg4_version<=3){
     728       34734 :                         last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
     729       34734 :                         run=   SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
     730       34734 :                         level= SHOW_SBITS(re, &s->gb, 8);
     731       34734 :                         SKIP_COUNTER(re, &s->gb, 1+6+8);
     732             :                     }else{
     733             :                         int sign;
     734        6816 :                         last=  SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
     735        6816 :                         if(!s->esc3_level_length){
     736             :                             int ll;
     737             :                             ff_dlog(s->avctx, "ESC-3 %X at %d %d\n",
     738             :                                     show_bits(&s->gb, 24), s->mb_x, s->mb_y);
     739         384 :                             if(s->qscale<8){
     740          78 :                                 ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
     741          78 :                                 if(ll==0){
     742           0 :                                     ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
     743             :                                 }
     744             :                             }else{
     745         306 :                                 ll=2;
     746        2320 :                                 while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
     747        1708 :                                     ll++;
     748        1708 :                                     SKIP_BITS(re, &s->gb, 1);
     749             :                                 }
     750         306 :                                 if(ll<8) SKIP_BITS(re, &s->gb, 1);
     751             :                             }
     752             : 
     753         384 :                             s->esc3_level_length= ll;
     754         384 :                             s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
     755         384 :                             UPDATE_CACHE(re, &s->gb);
     756             :                         }
     757        6816 :                         run=   SHOW_UBITS(re, &s->gb, s->esc3_run_length);
     758        6816 :                         SKIP_BITS(re, &s->gb, s->esc3_run_length);
     759             : 
     760        6816 :                         sign=  SHOW_UBITS(re, &s->gb, 1);
     761        6816 :                         SKIP_BITS(re, &s->gb, 1);
     762             : 
     763        6816 :                         level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
     764        6816 :                         SKIP_BITS(re, &s->gb, s->esc3_level_length);
     765        6816 :                         if(sign) level= -level;
     766             :                     }
     767             : 
     768             :                     //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
     769       41550 :                     if (level>0) level= level * qmul + qadd;
     770       20607 :                     else         level= level * qmul - qadd;
     771       41550 :                     i+= run + 1;
     772       41550 :                     if(last) i+=192;
     773             :                 } else {
     774             :                     /* second escape */
     775       54842 :                     SKIP_BITS(re, &s->gb, 2);
     776       54842 :                     GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
     777       54842 :                     i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
     778       54842 :                     level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
     779       54842 :                     LAST_SKIP_BITS(re, &s->gb, 1);
     780             :                 }
     781             :             } else {
     782             :                 /* first escape */
     783       65674 :                 SKIP_BITS(re, &s->gb, 1);
     784       65674 :                 GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
     785       65674 :                 i+= run;
     786       65674 :                 level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
     787       65674 :                 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
     788       65674 :                 LAST_SKIP_BITS(re, &s->gb, 1);
     789             :             }
     790             :         } else {
     791     4824101 :             i+= run;
     792     4824101 :             level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
     793     4824101 :             LAST_SKIP_BITS(re, &s->gb, 1);
     794             :         }
     795     4986167 :         if (i > 62){
     796      796431 :             i-= 192;
     797      796431 :             if(i&(~63)){
     798           0 :                 const int left= get_bits_left(&s->gb);
     799           0 :                 if (((i + 192 == 64 && level / qmul == -1) ||
     800           0 :                      !(s->avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))) &&
     801             :                     left >= 0) {
     802           0 :                     av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
     803           0 :                     i = 63;
     804           0 :                     break;
     805             :                 }else{
     806           0 :                     av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
     807           0 :                     return -1;
     808             :                 }
     809             :             }
     810             : 
     811      796431 :             block[scan_table[i]] = level;
     812      796431 :             break;
     813             :         }
     814             : 
     815     4189736 :         block[scan_table[i]] = level;
     816             :     }
     817      796431 :     CLOSE_READER(re, &s->gb);
     818             :   }
     819      838887 :  not_coded:
     820      838887 :     if (s->mb_intra) {
     821      230712 :         ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
     822      230712 :         if (s->ac_pred) {
     823        4194 :             i = 63; /* XXX: not optimal */
     824             :         }
     825             :     }
     826      838887 :     if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
     827      838887 :     s->block_last_index[n] = i;
     828             : 
     829      838887 :     return 0;
     830             : }
     831             : 
     832      228076 : int ff_msmpeg4_decode_motion(MpegEncContext * s,
     833             :                                  int *mx_ptr, int *my_ptr)
     834             : {
     835             :     MVTable *mv;
     836             :     int code, mx, my;
     837             : 
     838      228076 :     mv = &ff_mv_tables[s->mv_table_index];
     839             : 
     840      228076 :     code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
     841      228076 :     if (code < 0){
     842           0 :         av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
     843           0 :         return -1;
     844             :     }
     845      228076 :     if (code == mv->n) {
     846        1856 :         mx = get_bits(&s->gb, 6);
     847        1856 :         my = get_bits(&s->gb, 6);
     848             :     } else {
     849      226220 :         mx = mv->table_mvx[code];
     850      226220 :         my = mv->table_mvy[code];
     851             :     }
     852             : 
     853      228076 :     mx += *mx_ptr - 32;
     854      228076 :     my += *my_ptr - 32;
     855             :     /* WARNING : they do not do exactly modulo encoding */
     856      228076 :     if (mx <= -64)
     857          22 :         mx += 64;
     858      228054 :     else if (mx >= 64)
     859          10 :         mx -= 64;
     860             : 
     861      228076 :     if (my <= -64)
     862           6 :         my += 64;
     863      228070 :     else if (my >= 64)
     864           4 :         my -= 64;
     865      228076 :     *mx_ptr = mx;
     866      228076 :     *my_ptr = my;
     867      228076 :     return 0;
     868             : }
     869             : 
     870             : AVCodec ff_msmpeg4v1_decoder = {
     871             :     .name           = "msmpeg4v1",
     872             :     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
     873             :     .type           = AVMEDIA_TYPE_VIDEO,
     874             :     .id             = AV_CODEC_ID_MSMPEG4V1,
     875             :     .priv_data_size = sizeof(MpegEncContext),
     876             :     .init           = ff_msmpeg4_decode_init,
     877             :     .close          = ff_h263_decode_end,
     878             :     .decode         = ff_h263_decode_frame,
     879             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     880             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     881             :     .max_lowres     = 3,
     882             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     883             :         AV_PIX_FMT_YUV420P,
     884             :         AV_PIX_FMT_NONE
     885             :     },
     886             : };
     887             : 
     888             : AVCodec ff_msmpeg4v2_decoder = {
     889             :     .name           = "msmpeg4v2",
     890             :     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
     891             :     .type           = AVMEDIA_TYPE_VIDEO,
     892             :     .id             = AV_CODEC_ID_MSMPEG4V2,
     893             :     .priv_data_size = sizeof(MpegEncContext),
     894             :     .init           = ff_msmpeg4_decode_init,
     895             :     .close          = ff_h263_decode_end,
     896             :     .decode         = ff_h263_decode_frame,
     897             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     898             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     899             :     .max_lowres     = 3,
     900             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     901             :         AV_PIX_FMT_YUV420P,
     902             :         AV_PIX_FMT_NONE
     903             :     },
     904             : };
     905             : 
     906             : AVCodec ff_msmpeg4v3_decoder = {
     907             :     .name           = "msmpeg4",
     908             :     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
     909             :     .type           = AVMEDIA_TYPE_VIDEO,
     910             :     .id             = AV_CODEC_ID_MSMPEG4V3,
     911             :     .priv_data_size = sizeof(MpegEncContext),
     912             :     .init           = ff_msmpeg4_decode_init,
     913             :     .close          = ff_h263_decode_end,
     914             :     .decode         = ff_h263_decode_frame,
     915             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     916             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     917             :     .max_lowres     = 3,
     918             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     919             :         AV_PIX_FMT_YUV420P,
     920             :         AV_PIX_FMT_NONE
     921             :     },
     922             : };
     923             : 
     924             : AVCodec ff_wmv1_decoder = {
     925             :     .name           = "wmv1",
     926             :     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
     927             :     .type           = AVMEDIA_TYPE_VIDEO,
     928             :     .id             = AV_CODEC_ID_WMV1,
     929             :     .priv_data_size = sizeof(MpegEncContext),
     930             :     .init           = ff_msmpeg4_decode_init,
     931             :     .close          = ff_h263_decode_end,
     932             :     .decode         = ff_h263_decode_frame,
     933             :     .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
     934             :     .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
     935             :     .max_lowres     = 3,
     936             :     .pix_fmts       = (const enum AVPixelFormat[]) {
     937             :         AV_PIX_FMT_YUV420P,
     938             :         AV_PIX_FMT_NONE
     939             :     },
     940             : };

Generated by: LCOV version 1.13