]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'f2f145f3032bc8808708a4bd694fbce5f1b8b63c'
authorClément Bœsch <u@pkh.me>
Sun, 19 Mar 2017 15:06:49 +0000 (16:06 +0100)
committerClément Bœsch <u@pkh.me>
Sun, 19 Mar 2017 15:06:49 +0000 (16:06 +0100)
* commit 'f2f145f3032bc8808708a4bd694fbce5f1b8b63c':
  msmpeg4: Drop disabled debug cruft

Merged-by: Clément Bœsch <u@pkh.me>
1  2 
libavcodec/msmpeg4dec.c
libavcodec/msmpeg4enc.c

diff --combined libavcodec/msmpeg4dec.c
index b45e7517fc04cce2efe5397de6c9a044dc84b336,a2d0ad4294cac8284409deea35852783ecf80397..cf43027a0089331acac2b0c30ce6ac375b18b779
@@@ -1,24 -1,24 +1,24 @@@
  /*
   * MSMPEG4 backend for encoder and decoder
   * Copyright (c) 2001 Fabrice Bellard
 - * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
 + * Copyright (c) 2002-2013 Michael Niedermayer <michaelni@gmx.at>
   *
   * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
 - * License along with Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -27,7 -27,6 +27,7 @@@
  #include "mpegutils.h"
  #include "mpegvideo.h"
  #include "msmpeg4.h"
 +#include "libavutil/imgutils.h"
  #include "h263.h"
  #include "mpeg4video.h"
  #include "msmpeg4data.h"
@@@ -104,7 -103,6 +104,7 @@@ static int msmpeg4v2_decode_motion(Mpeg
  static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
  {
      int cbp, code, i;
 +    uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];
  
      if (s->pict_type == AV_PICTURE_TYPE_P) {
          if (s->use_skip_mb_code) {
                  s->mv[0][0][0] = 0;
                  s->mv[0][0][1] = 0;
                  s->mb_skipped = 1;
 +                *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
                  return 0;
              }
          }
          s->mv_type = MV_TYPE_16X16;
          s->mv[0][0][0] = mx;
          s->mv[0][0][1] = my;
 +        *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
      } else {
          if(s->msmpeg4_version==2){
              s->ac_pred = get_bits1(&s->gb);
              cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
              if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
          }
 +        *mb_type_ptr = MB_TYPE_INTRA;
      }
  
      s->bdsp.clear_blocks(s->block[0]);
@@@ -287,19 -282,18 +287,19 @@@ static int msmpeg4v34_decode_mb(MpegEnc
  av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
  {
      MpegEncContext *s = avctx->priv_data;
 -    static int done = 0;
 -    int i;
 +    static volatile int done = 0;
 +    int i, ret;
      MVTable *mv;
  
 +    if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
 +        return ret;
 +
      if (ff_h263_decode_init(avctx) < 0)
          return -1;
  
      ff_msmpeg4_common_init(s);
  
      if (!done) {
 -        done = 1;
 -
          for(i=0;i<NB_RL_TABLES;i++) {
              ff_rl_init(&ff_rl_table[i], ff_static_rl_table_store[i]);
          }
          INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
                   &ff_table_inter_intra[0][1], 2, 1,
                   &ff_table_inter_intra[0][0], 2, 1, 8);
 +        done = 1;
      }
  
      switch(s->msmpeg4_version){
@@@ -414,13 -407,6 +414,6 @@@ int ff_msmpeg4_decode_picture_header(Mp
          av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
          return -1;
      }
- #if 0
- {
-     static int had_i=0;
-     if(s->pict_type == AV_PICTURE_TYPE_I) had_i=1;
-     if(!had_i) return -1;
- }
- #endif
      s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
      if(s->qscale==0){
          av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
              s->no_rounding = 0;
          }
      }
 -    ff_dlog(s->avctx, "%d %d %d %d %d\n", s->pict_type, s->bit_rate,
 +    ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
              s->inter_intra_pred, s->width, s->height);
  
      s->esc3_level_length= 0;
@@@ -587,11 -573,8 +580,11 @@@ static int msmpeg4_decode_dc(MpegEncCon
          } else {
              level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
          }
 -        if (level < 0)
 +        if (level < 0) {
 +            av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
 +            *dir_ptr = 0;
              return -1;
 +        }
          level-=256;
      }else{  //FIXME optimize use unified tables & index
          if (n < 4) {
          }
          if (level < 0){
              av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
 +            *dir_ptr = 0;
              return -1;
          }
  
@@@ -657,6 -639,7 +650,6 @@@ int ff_msmpeg4_decode_block(MpegEncCont
          if (level < 0){
              av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
              if(s->inter_intra_pred) level=0;
 -            else                    return -1;
          }
          if (n < 4) {
              rl = &ff_rl_table[s->rl_table_index];
              if(i&(~63)){
                  const int left= get_bits_left(&s->gb);
                  if (((i + 192 == 64 && level / qmul == -1) ||
 -                     !(s->avctx->err_recognition & AV_EF_BITSTREAM)) &&
 +                     !(s->avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))) &&
                      left >= 0) {
                      av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
 +                    i = 63;
                      break;
                  }else{
                      av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
@@@ -873,8 -855,6 +866,8 @@@ AVCodec ff_msmpeg4v1_decoder = 
      .close          = ff_h263_decode_end,
      .decode         = ff_h263_decode_frame,
      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
 +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 +    .max_lowres     = 3,
      .pix_fmts       = (const enum AVPixelFormat[]) {
          AV_PIX_FMT_YUV420P,
          AV_PIX_FMT_NONE
@@@ -891,8 -871,6 +884,8 @@@ AVCodec ff_msmpeg4v2_decoder = 
      .close          = ff_h263_decode_end,
      .decode         = ff_h263_decode_frame,
      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
 +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 +    .max_lowres     = 3,
      .pix_fmts       = (const enum AVPixelFormat[]) {
          AV_PIX_FMT_YUV420P,
          AV_PIX_FMT_NONE
@@@ -909,8 -887,6 +902,8 @@@ AVCodec ff_msmpeg4v3_decoder = 
      .close          = ff_h263_decode_end,
      .decode         = ff_h263_decode_frame,
      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
 +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 +    .max_lowres     = 3,
      .pix_fmts       = (const enum AVPixelFormat[]) {
          AV_PIX_FMT_YUV420P,
          AV_PIX_FMT_NONE
@@@ -927,8 -903,6 +920,8 @@@ AVCodec ff_wmv1_decoder = 
      .close          = ff_h263_decode_end,
      .decode         = ff_h263_decode_frame,
      .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
 +    .caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 +    .max_lowres     = 3,
      .pix_fmts       = (const enum AVPixelFormat[]) {
          AV_PIX_FMT_YUV420P,
          AV_PIX_FMT_NONE
diff --combined libavcodec/msmpeg4enc.c
index 07241e891301a66ffdda2afa6d443cc565d8cc5e,6d353e5c0a8ce16f0f91b656322f136b088a699b..144468b24f16df8650be3dd91207ab26067e16a6
@@@ -5,20 -5,20 +5,20 @@@
   *
   * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni@gmx.at>
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
 - * License along with Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -34,6 -34,7 +34,6 @@@
  #include "libavutil/avutil.h"
  #include "libavutil/mem.h"
  #include "mpegvideo.h"
 -#include "msmpeg4.h"
  #include "h263.h"
  #include "internal.h"
  #include "mpeg4video.h"
@@@ -159,8 -160,8 +159,8 @@@ av_cold int ff_msmpeg4_encode_init(Mpeg
  static void find_best_tables(MpegEncContext * s)
  {
      int i;
 -    int best       =-1, best_size       =9999999;
 -    int chroma_best=-1, best_chroma_size=9999999;
 +    int best        = 0, best_size        = INT_MAX;
 +    int chroma_best = 0, best_chroma_size = INT_MAX;
  
      for(i=0; i<3; i++){
          int level;
@@@ -240,7 -241,7 +240,7 @@@ void ff_msmpeg4_encode_picture_header(M
      s->per_mb_rl_table = 0;
      if(s->msmpeg4_version==4)
          s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
 -    ff_dlog(s, "%d %d %d %d %d\n", s->pict_type, s->bit_rate,
 +    ff_dlog(s, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
              s->inter_intra_pred, s->width, s->height);
  
      if (s->pict_type == AV_PICTURE_TYPE_I) {
  
  void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
  {
 -        put_bits(&s->pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
 +        unsigned fps = s->avctx->time_base.den / s->avctx->time_base.num / FFMAX(s->avctx->ticks_per_frame, 1);
 +        put_bits(&s->pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
  
          put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
  
          if(s->msmpeg4_version>=3)
              put_bits(&s->pb, 1, s->flipflop_rounding);
          else
 -            assert(s->flipflop_rounding==0);
 +            av_assert0(s->flipflop_rounding==0);
  }
  
  void ff_msmpeg4_encode_motion(MpegEncContext * s,
  
      mx += 32;
      my += 32;
- #if 0
-     if ((unsigned)mx >= 64 ||
-         (unsigned)my >= 64)
-         av_log(s->avctx, AV_LOG_ERROR, "error mx=%d my=%d\n", mx, my);
- #endif
      mv = &ff_mv_tables[s->mv_table_index];
  
      code = mv->table_mv_index[(mx << 6) | my];
@@@ -504,7 -499,7 +499,7 @@@ void ff_msmpeg4_encode_mb(MpegEncContex
  static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
  {
      int sign, code;
 -    int pred, extquant;
 +    int pred, av_uninit(extquant);
      int extrabits = 0;
  
      int16_t *dc_val;