From: Michael Niedermayer Date: Tue, 2 Sep 2014 19:57:46 +0000 (+0200) Subject: Merge commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67' X-Git-Tag: android-x86-6.0-r1~3287 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4c731233338d2bc6d9646808b7599224450932c6;p=android-x86%2Fexternal-ffmpeg.git Merge commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67' * commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67': asv: K&R formatting cosmetics Conflicts: libavcodec/asvdec.c libavcodec/asvenc.c Merged-by: Michael Niedermayer --- 4c731233338d2bc6d9646808b7599224450932c6 diff --cc libavcodec/asvdec.c index 23298757b7,9d1be5f391..18e2faacd3 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@@ -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 - diff --cc libavcodec/asvenc.c index 02cf2db991,98baaec0f0..bbf4494866 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@@ -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_ymb_height2; mb_y++){ - for(mb_x=0; mb_xmb_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); } @@@ -276,27 -269,36 +309,30 @@@ 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