}
}
- 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;
.decode = decode_frame,
.capabilities = CODEC_CAP_DR1,
};
-
+#endif
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]);
}
}
}
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;
.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
.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