OSDN Git Service

Merge commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 2 Sep 2014 19:57:46 +0000 (21:57 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 2 Sep 2014 19:57:46 +0000 (21:57 +0200)
* commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67':
  asv: K&R formatting cosmetics

Conflicts:
libavcodec/asvdec.c
libavcodec/asvenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/asv.c
libavcodec/asv.h
libavcodec/asvdec.c
libavcodec/asvenc.c

Simple merge
Simple merge
@@@ -201,18 -202,19 +201,17 @@@ static inline void idct_put(ASV1Contex
      }
  }
  
- static int decode_frame(AVCodecContext *avctx,
-                         void *data, int *got_frame,
+ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                          AVPacket *avpkt)
  {
-     ASV1Context * const a = avctx->priv_data;
-     const uint8_t *buf    = avpkt->data;
-     int buf_size          = avpkt->size;
-     AVFrame * const p     = data;
+     ASV1Context *const a = avctx->priv_data;
+     const uint8_t *buf = avpkt->data;
+     int buf_size       = avpkt->size;
+     AVFrame *const p = data;
      int mb_x, mb_y, ret;
  
 -    if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
          return ret;
 -    }
      p->pict_type = AV_PICTURE_TYPE_I;
      p->key_frame = 1;
  
@@@ -338,5 -340,3 +338,4 @@@ AVCodec ff_asv2_decoder = 
      .decode         = decode_frame,
      .capabilities   = CODEC_CAP_DR1,
  };
 +#endif
@@@ -104,27 -121,41 +122,41 @@@ static inline void asv2_encode_block(AS
      count >>= 2;
  
      asv2_put_bits(&a->pb, 4, count);
-     asv2_put_bits(&a->pb, 8, (block[0] + 32)>>6);
-     block[0]= 0;
-     for(i=0; i<=count; i++){
-         const int index = ff_asv_scantab[4*i];
-         int ccp=0;
-         if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8;
-         if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4;
-         if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2;
-         if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1;
-         av_assert2(i || ccp<8);
-         if(i) put_bits(&a->pb, ff_asv_ac_ccp_tab[ccp][1], ff_asv_ac_ccp_tab[ccp][0]);
-         else  put_bits(&a->pb, ff_asv_dc_ccp_tab[ccp][1], ff_asv_dc_ccp_tab[ccp][0]);
-         if(ccp){
-             if(ccp&8) asv2_put_level(&a->pb, block[index + 0]);
-             if(ccp&4) asv2_put_level(&a->pb, block[index + 8]);
-             if(ccp&2) asv2_put_level(&a->pb, block[index + 1]);
-             if(ccp&1) asv2_put_level(&a->pb, block[index + 9]);
+     asv2_put_bits(&a->pb, 8, (block[0] + 32) >> 6);
+     block[0] = 0;
+     for (i = 0; i <= count; i++) {
+         const int index = ff_asv_scantab[4 * i];
+         int ccp         = 0;
+         if ((block[index + 0] = (block[index + 0] *
+                                  a->q_intra_matrix[index + 0] + (1 << 15)) >> 16))
+             ccp |= 8;
+         if ((block[index + 8] = (block[index + 8] *
+                                  a->q_intra_matrix[index + 8] + (1 << 15)) >> 16))
+             ccp |= 4;
+         if ((block[index + 1] = (block[index + 1] *
+                                  a->q_intra_matrix[index + 1] + (1 << 15)) >> 16))
+             ccp |= 2;
+         if ((block[index + 9] = (block[index + 9] *
+                                  a->q_intra_matrix[index + 9] + (1 << 15)) >> 16))
+             ccp |= 1;
 -        assert(i || ccp < 8);
++        av_assert2(i || ccp < 8);
+         if (i)
+             put_bits(&a->pb, ff_asv_ac_ccp_tab[ccp][1], ff_asv_ac_ccp_tab[ccp][0]);
+         else
+             put_bits(&a->pb, ff_asv_dc_ccp_tab[ccp][1], ff_asv_dc_ccp_tab[ccp][0]);
+         if (ccp) {
+             if (ccp & 8)
+                 asv2_put_level(&a->pb, block[index + 0]);
+             if (ccp & 4)
+                 asv2_put_level(&a->pb, block[index + 8]);
+             if (ccp & 2)
+                 asv2_put_level(&a->pb, block[index + 1]);
+             if (ccp & 1)
+                 asv2_put_level(&a->pb, block[index + 9]);
          }
      }
  }
@@@ -224,14 -221,10 +257,14 @@@ static int encode_frame(AVCodecContext 
          return ret;
      }
  
-     if ((ret = ff_alloc_packet2(avctx, pkt, a->mb_height*a->mb_width*MAX_MB_SIZE +
-                                   FF_MIN_BUFFER_SIZE)) < 0)
++    if ((ret = ff_alloc_packet2(avctx, pkt, a->mb_height * a->mb_width * MAX_MB_SIZE +
++                                FF_MIN_BUFFER_SIZE)) < 0)
 +        return ret;
 +
      init_put_bits(&a->pb, pkt->data, pkt->size);
  
-     for(mb_y=0; mb_y<a->mb_height2; mb_y++){
-         for(mb_x=0; mb_x<a->mb_width2; mb_x++){
+     for (mb_y = 0; mb_y < a->mb_height2; mb_y++) {
+         for (mb_x = 0; mb_x < a->mb_width2; mb_x++) {
              dct_get(a, pict, mb_x, mb_y);
              encode_mb(a, a->block);
          }
      return 0;
  }
  
- static av_cold int encode_init(AVCodecContext *avctx){
-     ASV1Context * const a = avctx->priv_data;
+ static av_cold int encode_init(AVCodecContext *avctx)
+ {
+     ASV1Context *const a = avctx->priv_data;
      int i;
-     const int scale= avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
+     const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
  
 -    avctx->coded_frame = av_frame_alloc();
 -    if (!avctx->coded_frame)
 -        return AVERROR(ENOMEM);
 -    avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
 -    avctx->coded_frame->key_frame = 1;
 -
      ff_asv_common_init(avctx);
      ff_fdctdsp_init(&a->fdsp, avctx);
      ff_pixblockdsp_init(&a->pdsp, avctx);
  
-     if(avctx->global_quality <= 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
 -    if (avctx->global_quality == 0)
++    if (avctx->global_quality <= 0)
+         avctx->global_quality = 4 * FF_QUALITY_SCALE;
  
-     a->inv_qscale= (32*scale*FF_QUALITY_SCALE +  avctx->global_quality/2) / avctx->global_quality;
+     a->inv_qscale = (32 * scale * FF_QUALITY_SCALE +
+                      avctx->global_quality / 2) / avctx->global_quality;
  
-     avctx->extradata= av_mallocz(8);
-     avctx->extradata_size=8;
-     ((uint32_t*)avctx->extradata)[0]= av_le2ne32(a->inv_qscale);
-     ((uint32_t*)avctx->extradata)[1]= av_le2ne32(AV_RL32("ASUS"));
+     avctx->extradata                   = av_mallocz(8);
+     avctx->extradata_size              = 8;
+     ((uint32_t *) avctx->extradata)[0] = av_le2ne32(a->inv_qscale);
+     ((uint32_t *) avctx->extradata)[1] = av_le2ne32(AV_RL32("ASUS"));
  
-     for(i=0; i<64; i++){
-         int q= 32*scale*ff_mpeg1_default_intra_matrix[i];
-         a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q;
+     for (i = 0; i < 64; i++) {
+         int q = 32 * scale * ff_mpeg1_default_intra_matrix[i];
+         a->q_intra_matrix[i] = ((a->inv_qscale << 16) + q / 2) / q;
      }
  
      return 0;
@@@ -311,8 -320,9 +347,8 @@@ AVCodec ff_asv1_encoder = 
      .priv_data_size = sizeof(ASV1Context),
      .init           = encode_init,
      .encode2        = encode_frame,
-     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
-                                                     AV_PIX_FMT_NONE },
 -    .close          = asv_encode_close,
+     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
+                                                      AV_PIX_FMT_NONE },
  };
  #endif
  
@@@ -325,7 -335,8 +361,7 @@@ AVCodec ff_asv2_encoder = 
      .priv_data_size = sizeof(ASV1Context),
      .init           = encode_init,
      .encode2        = encode_frame,
-     .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
-                                                     AV_PIX_FMT_NONE },
 -    .close          = asv_encode_close,
+     .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
+                                                      AV_PIX_FMT_NONE },
  };
  #endif