Merge commit '69f6f03cd16a09e4e848b4e82bae4993bc361cd0'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 17 Apr 2013 14:04:38 +0000 (16:04 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 17 Apr 2013 14:04:38 +0000 (16:04 +0200)
* commit '69f6f03cd16a09e4e848b4e82bae4993bc361cd0':
  rv10: cosmetics, reformat
  qdm2: check that the FFT size is a power of 2

Conflicts:
libavcodec/rv10.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/qdm2.c
libavcodec/rv10.c

Simple merge
@@@ -304,39 -303,18 +303,22 @@@ static int rv20_decode_picture_header(R
      int seq, mb_pos, i;
      int rpr_bits;
  
- #if 0
-     GetBitContext gb= s->gb;
-     for(i=0; i<64; i++){
-         av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb));
-         if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
-     }
-     av_log(s->avctx, AV_LOG_DEBUG, "\n");
- #endif
- #if 0
-     av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4);
-     for(i=0; i<s->avctx->extradata_size; i++){
-         av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]);
-         if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
-     }
-     av_log(s->avctx, AV_LOG_DEBUG, "\n");
- #endif
-     i= get_bits(&s->gb, 2);
-     switch(i){
-     case 0: s->pict_type= AV_PICTURE_TYPE_I; break;
-     case 1: s->pict_type= AV_PICTURE_TYPE_I; break; //hmm ...
-     case 2: s->pict_type= AV_PICTURE_TYPE_P; break;
-     case 3: s->pict_type= AV_PICTURE_TYPE_B; break;
+     i = get_bits(&s->gb, 2);
 -    switch (i) {
++    switch(i) {
+     case 0: s->pict_type = AV_PICTURE_TYPE_I; break;
+     case 1: s->pict_type = AV_PICTURE_TYPE_I; break; //hmm ...
+     case 2: s->pict_type = AV_PICTURE_TYPE_P; break;
+     case 3: s->pict_type = AV_PICTURE_TYPE_B; break;
      default:
          av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
          return -1;
      }
  
-     if(s->low_delay && s->pict_type==AV_PICTURE_TYPE_B){
++    if (s->low_delay && s->pict_type == AV_PICTURE_TYPE_B) {
 +        av_log(s->avctx, AV_LOG_ERROR, "low delay B\n");
 +        return -1;
 +    }
-     if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){
+     if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B) {
          av_log(s->avctx, AV_LOG_ERROR, "early B pix\n");
          return -1;
      }
          return -1;
      }
  
-     if(RV_GET_MINOR_VER(rv->sub_id) >= 2)
+     if (RV_GET_MINOR_VER(rv->sub_id) >= 2)
 -        s->loop_filter = get_bits1(&s->gb);
 +        s->loop_filter = get_bits1(&s->gb) && !s->avctx->lowres;
  
-     if(RV_GET_MINOR_VER(rv->sub_id) <= 1)
+     if (RV_GET_MINOR_VER(rv->sub_id) <= 1)
          seq = get_bits(&s->gb, 8) << 7;
      else
          seq = get_bits(&s->gb, 13) << 2;
  
          f = get_bits(&s->gb, rpr_bits);
  
-         if(f){
-             new_w= 4*((uint8_t*)s->avctx->extradata)[6+2*f];
-             new_h= 4*((uint8_t*)s->avctx->extradata)[7+2*f];
-         }else{
-             new_w= s->orig_width ;
-             new_h= s->orig_height;
+         if (f) {
+             new_w = 4 * ((uint8_t*)s->avctx->extradata)[6 + 2 * f];
+             new_h = 4 * ((uint8_t*)s->avctx->extradata)[7 + 2 * f];
+         } else {
+             new_w = s->orig_width ;
+             new_h = s->orig_height;
          }
-         if(new_w != s->width || new_h != s->height){
+         if (new_w != s->width || new_h != s->height) {
 +            AVRational old_aspect = s->avctx->sample_aspect_ratio;
-             av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
+             av_log(s->avctx, AV_LOG_DEBUG,
+                    "attempting to change resolution to %dx%d\n", new_w, new_h);
              if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
                  return -1;
              ff_MPV_common_end(s);
                  return -1;
          }
  
-         if(s->avctx->debug & FF_DEBUG_PICT_INFO){
+         if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
              av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits);
          }
 -    } else if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
 +    }
 +    if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
          return AVERROR_INVALIDDATA;
  
      mb_pos = ff_h263_decode_mba(s);
  
-     seq |= s->time &~0x7FFF;
-     if(seq - s->time >  0x4000) seq -= 0x8000;
-     if(seq - s->time < -0x4000) seq += 0x8000;
-     if(seq != s->time){
-         if(s->pict_type!=AV_PICTURE_TYPE_B){
-             s->time= seq;
-             s->pp_time= s->time - s->last_non_b_time;
-             s->last_non_b_time= s->time;
-         }else{
-             s->time= seq;
-             s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
+     seq |= s->time & ~0x7FFF;
+     if (seq - s->time >  0x4000)
+         seq -= 0x8000;
+     if (seq - s->time < -0x4000)
+         seq += 0x8000;
+     if (seq != s->time) {
+         if (s->pict_type != AV_PICTURE_TYPE_B) {
+             s->time            = seq;
+             s->pp_time         = s->time - s->last_non_b_time;
+             s->last_non_b_time = s->time;
+         } else {
+             s->time    = seq;
+             s->pb_time = s->pp_time - (s->last_non_b_time - s->time);
 -            if (s->pp_time <= s->pb_time ||
 -                s->pp_time <= s->pp_time - s->pb_time || s->pp_time <= 0) {
 -                av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible "
 -                       "from seeking? skipping current b frame\n");
 -                return FRAME_SKIPPED;
 -            }
 -            ff_mpeg4_init_direct_mv(s);
          }
      }
-     if (s->pict_type==AV_PICTURE_TYPE_B) {
-         if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
-             av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n");
++    if (s->pict_type == AV_PICTURE_TYPE_B) {
++        if (s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0) {
++            av_log(s->avctx, AV_LOG_DEBUG,
++                   "messed up order, possible from seeking? skipping current b frame\n");
 +#define ERROR_SKIP_FRAME -123
 +            return ERROR_SKIP_FRAME;
 +        }
 +        ff_mpeg4_init_direct_mv(s);
 +    }
  
-     s->no_rounding= get_bits1(&s->gb);
+     s->no_rounding = get_bits1(&s->gb);
  
-     if(RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
+     if (RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
          skip_bits(&s->gb, 5); // binary decoder reads 3+2 bits here but they don't seem to be used
  
-     s->f_code = 1;
+     s->f_code          = 1;
      s->unrestricted_mv = 1;
-     s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I;
- //    s->alt_inter_vlc=1;
- //    s->obmc=1;
- //    s->umvplus=1;
-     s->modified_quant=1;
-     if(!s->avctx->lowres)
-         s->loop_filter=1;
-     if(s->avctx->debug & FF_DEBUG_PICT_INFO){
-             av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
-                    seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);
+     s->h263_aic        = s->pict_type == AV_PICTURE_TYPE_I;
+     s->modified_quant  = 1;
 -    s->loop_filter     = 1;
++    if (!s->avctx->lowres)
++        s->loop_filter = 1;
+     if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
+         av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
+                seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);
      }
  
 -    assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
 +    av_assert0(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
  
      return s->mb_width*s->mb_height - mb_pos;
  }
@@@ -465,15 -432,16 +449,15 @@@ static av_cold int rv10_decode_init(AVC
  
      ff_MPV_decode_defaults(s);
  
-     s->avctx= avctx;
+     s->avctx      = avctx;
      s->out_format = FMT_H263;
-     s->codec_id= avctx->codec_id;
+     s->codec_id   = avctx->codec_id;
 -    avctx->flags |= CODEC_FLAG_EMU_EDGE;
  
-     s->orig_width = s->width  = avctx->coded_width;
-     s->orig_height= s->height = avctx->coded_height;
+     s->orig_width  = s->width  = avctx->coded_width;
+     s->orig_height = s->height = avctx->coded_height;
  
-     s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
-     rv->sub_id = AV_RB32((uint8_t*)avctx->extradata + 4);
+     s->h263_long_vectors = ((uint8_t*)avctx->extradata)[3] & 1;
+     rv->sub_id           = AV_RB32((uint8_t*)avctx->extradata + 4);
  
      major_ver = RV_GET_MAJOR_VER(rv->sub_id);
      minor_ver = RV_GET_MINOR_VER(rv->sub_id);
          return AVERROR_PATCHWELCOME;
      }
  
-     if(avctx->debug & FF_DEBUG_PICT_INFO){
-         av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id, ((uint32_t*)avctx->extradata)[0]);
+     if (avctx->debug & FF_DEBUG_PICT_INFO) {
+         av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id,
 -               avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
++               ((uint32_t*)avctx->extradata)[0]);
      }
  
      avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@@@ -746,14 -713,15 +734,16 @@@ static int rv10_decode_frame(AVCodecCon
          } else if (s->last_picture_ptr != NULL) {
              if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
                  return ret;
 -            ff_print_debug_info(s, s->last_picture_ptr);
 +            ff_print_debug_info(s, s->last_picture_ptr, pict);
 +            ff_mpv_export_qp_table(s, pict,s->last_picture_ptr, FF_QSCALE_TYPE_MPEG1);
          }
  
-         if(s->last_picture_ptr || s->low_delay){
+         if (s->last_picture_ptr || s->low_delay) {
              *got_frame = 1;
          }
-         s->current_picture_ptr= NULL; // so we can detect if frame_end was not called (find some nicer solution...)
+         // so we can detect if frame_end was not called (find some nicer solution...)
+         s->current_picture_ptr = NULL;
      }
  
      return avpkt->size;