Merge commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67'
* commit 'f61e47dd68582529bcf6d42d861c70a320cd1b67': asv: K&R formatting cosmetics Conflicts: libavcodec/asvdec.c libavcodec/asvenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
4c73123333
@ -80,7 +80,8 @@ const uint8_t ff_asv2_level_tab[63][2] = {
|
|||||||
{ 0x22, 10 }, { 0x32, 10 }, { 0x2A, 10 }, { 0x3A, 10 }, { 0x26, 10 }, { 0x36, 10 }, { 0x2E, 10 }, { 0x3E, 10 },
|
{ 0x22, 10 }, { 0x32, 10 }, { 0x2A, 10 }, { 0x3A, 10 }, { 0x26, 10 }, { 0x36, 10 }, { 0x2E, 10 }, { 0x3E, 10 },
|
||||||
};
|
};
|
||||||
|
|
||||||
av_cold void ff_asv_common_init(AVCodecContext *avctx) {
|
av_cold void ff_asv_common_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
ASV1Context *const a = avctx->priv_data;
|
ASV1Context *const a = avctx->priv_data;
|
||||||
|
|
||||||
ff_bswapdsp_init(&a->bbdsp);
|
ff_bswapdsp_init(&a->bbdsp);
|
||||||
|
@ -201,8 +201,7 @@ static inline void idct_put(ASV1Context *a, AVFrame *frame, int mb_x, int mb_y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_frame(AVCodecContext *avctx,
|
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
void *data, int *got_frame,
|
|
||||||
AVPacket *avpkt)
|
AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
ASV1Context *const a = avctx->priv_data;
|
ASV1Context *const a = avctx->priv_data;
|
||||||
@ -221,10 +220,10 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
if (!a->bitstream_buffer)
|
if (!a->bitstream_buffer)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (avctx->codec_id == AV_CODEC_ID_ASV1)
|
if (avctx->codec_id == AV_CODEC_ID_ASV1) {
|
||||||
a->bbdsp.bswap_buf((uint32_t *) a->bitstream_buffer,
|
a->bbdsp.bswap_buf((uint32_t *) a->bitstream_buffer,
|
||||||
(const uint32_t *) buf, buf_size / 4);
|
(const uint32_t *) buf, buf_size / 4);
|
||||||
else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < buf_size; i++)
|
for (i = 0; i < buf_size; i++)
|
||||||
a->bitstream_buffer[i] = ff_reverse[buf[i]];
|
a->bitstream_buffer[i] = ff_reverse[buf[i]];
|
||||||
@ -296,7 +295,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
for (i = 0; i < 64; i++) {
|
for (i = 0; i < 64; i++) {
|
||||||
int index = ff_asv_scantab[i];
|
int index = ff_asv_scantab[i];
|
||||||
|
|
||||||
a->intra_matrix[i] = 64 * scale * ff_mpeg1_default_intra_matrix[index] / a->inv_qscale;
|
a->intra_matrix[i] = 64 * scale * ff_mpeg1_default_intra_matrix[index] /
|
||||||
|
a->inv_qscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -339,4 +339,3 @@ AVCodec ff_asv2_decoder = {
|
|||||||
.capabilities = CODEC_CAP_DR1,
|
.capabilities = CODEC_CAP_DR1,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -33,31 +33,37 @@
|
|||||||
#include "mathops.h"
|
#include "mathops.h"
|
||||||
#include "mpeg12data.h"
|
#include "mpeg12data.h"
|
||||||
|
|
||||||
static inline void asv2_put_bits(PutBitContext *pb, int n, int v){
|
static inline void asv2_put_bits(PutBitContext *pb, int n, int v)
|
||||||
|
{
|
||||||
put_bits(pb, n, ff_reverse[v << (8 - n)]);
|
put_bits(pb, n, ff_reverse[v << (8 - n)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void asv1_put_level(PutBitContext *pb, int level){
|
static inline void asv1_put_level(PutBitContext *pb, int level)
|
||||||
|
{
|
||||||
unsigned int index = level + 3;
|
unsigned int index = level + 3;
|
||||||
|
|
||||||
if(index <= 6) put_bits(pb, ff_asv_level_tab[index][1], ff_asv_level_tab[index][0]);
|
if (index <= 6) {
|
||||||
else{
|
put_bits(pb, ff_asv_level_tab[index][1], ff_asv_level_tab[index][0]);
|
||||||
|
} else {
|
||||||
put_bits(pb, ff_asv_level_tab[3][1], ff_asv_level_tab[3][0]);
|
put_bits(pb, ff_asv_level_tab[3][1], ff_asv_level_tab[3][0]);
|
||||||
put_sbits(pb, 8, level);
|
put_sbits(pb, 8, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void asv2_put_level(PutBitContext *pb, int level){
|
static inline void asv2_put_level(PutBitContext *pb, int level)
|
||||||
|
{
|
||||||
unsigned int index = level + 31;
|
unsigned int index = level + 31;
|
||||||
|
|
||||||
if(index <= 62) put_bits(pb, ff_asv2_level_tab[index][1], ff_asv2_level_tab[index][0]);
|
if (index <= 62) {
|
||||||
else{
|
put_bits(pb, ff_asv2_level_tab[index][1], ff_asv2_level_tab[index][0]);
|
||||||
|
} else {
|
||||||
put_bits(pb, ff_asv2_level_tab[31][1], ff_asv2_level_tab[31][0]);
|
put_bits(pb, ff_asv2_level_tab[31][1], ff_asv2_level_tab[31][0]);
|
||||||
asv2_put_bits(pb, 8, level & 0xFF);
|
asv2_put_bits(pb, 8, level & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void asv1_encode_block(ASV1Context *a, int16_t block[64]){
|
static inline void asv1_encode_block(ASV1Context *a, int16_t block[64])
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
int nc_count = 0;
|
int nc_count = 0;
|
||||||
|
|
||||||
@ -68,10 +74,18 @@ static inline void asv1_encode_block(ASV1Context *a, int16_t block[64]){
|
|||||||
const int index = ff_asv_scantab[4 * i];
|
const int index = ff_asv_scantab[4 * i];
|
||||||
int ccp = 0;
|
int ccp = 0;
|
||||||
|
|
||||||
if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8;
|
if ((block[index + 0] = (block[index + 0] *
|
||||||
if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4;
|
a->q_intra_matrix[index + 0] + (1 << 15)) >> 16))
|
||||||
if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2;
|
ccp |= 8;
|
||||||
if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1;
|
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;
|
||||||
|
|
||||||
if (ccp) {
|
if (ccp) {
|
||||||
for (; nc_count; nc_count--)
|
for (; nc_count; nc_count--)
|
||||||
@ -79,10 +93,14 @@ static inline void asv1_encode_block(ASV1Context *a, int16_t block[64]){
|
|||||||
|
|
||||||
put_bits(&a->pb, ff_asv_ccp_tab[ccp][1], ff_asv_ccp_tab[ccp][0]);
|
put_bits(&a->pb, ff_asv_ccp_tab[ccp][1], ff_asv_ccp_tab[ccp][0]);
|
||||||
|
|
||||||
if(ccp&8) asv1_put_level(&a->pb, block[index + 0]);
|
if (ccp & 8)
|
||||||
if(ccp&4) asv1_put_level(&a->pb, block[index + 8]);
|
asv1_put_level(&a->pb, block[index + 0]);
|
||||||
if(ccp&2) asv1_put_level(&a->pb, block[index + 1]);
|
if (ccp & 4)
|
||||||
if(ccp&1) asv1_put_level(&a->pb, block[index + 9]);
|
asv1_put_level(&a->pb, block[index + 8]);
|
||||||
|
if (ccp & 2)
|
||||||
|
asv1_put_level(&a->pb, block[index + 1]);
|
||||||
|
if (ccp & 1)
|
||||||
|
asv1_put_level(&a->pb, block[index + 9]);
|
||||||
} else {
|
} else {
|
||||||
nc_count++;
|
nc_count++;
|
||||||
}
|
}
|
||||||
@ -90,13 +108,13 @@ static inline void asv1_encode_block(ASV1Context *a, int16_t block[64]){
|
|||||||
put_bits(&a->pb, ff_asv_ccp_tab[16][1], ff_asv_ccp_tab[16][0]);
|
put_bits(&a->pb, ff_asv_ccp_tab[16][1], ff_asv_ccp_tab[16][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void asv2_encode_block(ASV1Context *a, int16_t block[64]){
|
static inline void asv2_encode_block(ASV1Context *a, int16_t block[64])
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (count = 63; count > 3; count--) {
|
for (count = 63; count > 3; count--) {
|
||||||
const int index = ff_asv_scantab[count];
|
const int index = ff_asv_scantab[count];
|
||||||
|
|
||||||
if ((block[index] * a->q_intra_matrix[index] + (1 << 15)) >> 16)
|
if ((block[index] * a->q_intra_matrix[index] + (1 << 15)) >> 16)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -111,27 +129,42 @@ static inline void asv2_encode_block(ASV1Context *a, int16_t block[64]){
|
|||||||
const int index = ff_asv_scantab[4 * i];
|
const int index = ff_asv_scantab[4 * i];
|
||||||
int ccp = 0;
|
int ccp = 0;
|
||||||
|
|
||||||
if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8;
|
if ((block[index + 0] = (block[index + 0] *
|
||||||
if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4;
|
a->q_intra_matrix[index + 0] + (1 << 15)) >> 16))
|
||||||
if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2;
|
ccp |= 8;
|
||||||
if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1;
|
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);
|
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]);
|
if (i)
|
||||||
else put_bits(&a->pb, ff_asv_dc_ccp_tab[ccp][1], ff_asv_dc_ccp_tab[ccp][0]);
|
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) {
|
||||||
if(ccp&8) asv2_put_level(&a->pb, block[index + 0]);
|
if (ccp & 8)
|
||||||
if(ccp&4) asv2_put_level(&a->pb, block[index + 8]);
|
asv2_put_level(&a->pb, block[index + 0]);
|
||||||
if(ccp&2) asv2_put_level(&a->pb, block[index + 1]);
|
if (ccp & 4)
|
||||||
if(ccp&1) asv2_put_level(&a->pb, block[index + 9]);
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_MB_SIZE (30 * 16 * 16 * 3 / 2 / 8)
|
#define MAX_MB_SIZE (30 * 16 * 16 * 3 / 2 / 8)
|
||||||
|
|
||||||
static inline int encode_mb(ASV1Context *a, int16_t block[6][64]){
|
static inline int encode_mb(ASV1Context *a, int16_t block[6][64])
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (a->pb.buf_end - a->pb.buf - (put_bits_count(&a->pb) >> 3) < MAX_MB_SIZE) {
|
if (a->pb.buf_end - a->pb.buf - (put_bits_count(&a->pb) >> 3) < MAX_MB_SIZE) {
|
||||||
@ -260,10 +293,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
size = put_bits_count(&a->pb) / 32;
|
size = put_bits_count(&a->pb) / 32;
|
||||||
|
|
||||||
if(avctx->codec_id == AV_CODEC_ID_ASV1)
|
if (avctx->codec_id == AV_CODEC_ID_ASV1) {
|
||||||
a->bbdsp.bswap_buf((uint32_t *) pkt->data,
|
a->bbdsp.bswap_buf((uint32_t *) pkt->data,
|
||||||
(uint32_t *) pkt->data, size);
|
(uint32_t *) pkt->data, size);
|
||||||
else{
|
} else {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 4 * size; i++)
|
for (i = 0; i < 4 * size; i++)
|
||||||
pkt->data[i] = ff_reverse[pkt->data[i]];
|
pkt->data[i] = ff_reverse[pkt->data[i]];
|
||||||
@ -276,7 +309,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int encode_init(AVCodecContext *avctx){
|
static av_cold int encode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
ASV1Context *const a = avctx->priv_data;
|
ASV1Context *const a = avctx->priv_data;
|
||||||
int i;
|
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;
|
||||||
@ -285,9 +319,11 @@ static av_cold int encode_init(AVCodecContext *avctx){
|
|||||||
ff_fdctdsp_init(&a->fdsp, avctx);
|
ff_fdctdsp_init(&a->fdsp, avctx);
|
||||||
ff_pixblockdsp_init(&a->pdsp, avctx);
|
ff_pixblockdsp_init(&a->pdsp, avctx);
|
||||||
|
|
||||||
if(avctx->global_quality <= 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
|
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 = av_mallocz(8);
|
||||||
avctx->extradata_size = 8;
|
avctx->extradata_size = 8;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user