Mercurial > libavcodec.hg
changeset 2010:ad1a92c2db48 libavcodec
width height %64 != 0 fix
print average RD score at the end
precalculated codebook vector mean tables
author | michael |
---|---|
date | Sat, 08 May 2004 11:54:55 +0000 |
parents | b13a25ac9f0c |
children | 8c7e7c332b86 |
files | svq1.c svq1_cb.h |
diffstat | 2 files changed, 75 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/svq1.c Fri May 07 21:34:33 2004 +0000 +++ b/svq1.c Sat May 08 11:54:55 2004 +0000 @@ -85,6 +85,7 @@ unsigned char *c_plane; + int64_t rd_total; } SVQ1Context; /* motion vector (prediction) */ @@ -1340,7 +1341,7 @@ int8_t *vector; for(i=0; i<16; i++){ - int sum=0; + int sum= svq1_intra_codebook_sum[level][stage*16 + i]; int sqr=0; int diff, mean, score; @@ -1348,7 +1349,6 @@ for(j=0; j<size; j++){ int v= vector[j]; - sum += v; sqr += (v - block[stage][j])*(v - block[stage][j]); } diff= block_sum[stage] - sum; @@ -1463,6 +1463,8 @@ for (x = 0; x < block_width; x++) { uint8_t reorder_buffer[6][7*32]; + uint8_t *src= plane + y * 16 * stride + x * 16; + uint8_t buf[stride*16]; #ifdef DEBUG_SVQ1 av_log(s->avctx, AV_LOG_INFO, "* level 5 vector @ %d, %d:\n", x * 16, y * 16); @@ -1474,7 +1476,11 @@ for(i=0; i<6; i++){ init_put_bits(&s->reorder_pb[i], reorder_buffer[i], 7*32); } - encode_block(s, &plane[left_edge], stride, 5, 256, (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT)); + if(x*16 + 16 > width || y*16 + 16 > height){ + ff_emulated_edge_mc(buf, src, stride, 16, 16, 16*x, 16*y, width, height); + src= buf; + } + s->rd_total += encode_block(s, src, stride, 5, 256, (s->picture.quality*s->picture.quality) >> (2*FF_LAMBDA_SHIFT)); for(i=5; i>=0; i--){ int count= put_bits_count(&s->reorder_pb[i]); @@ -1676,6 +1682,8 @@ { SVQ1Context * const s = avctx->priv_data; + av_log(avctx, AV_LOG_DEBUG, "RD: %f\n", s->rd_total/(double)(avctx->width*avctx->height*avctx->frame_number)); + av_free(s->c_plane); return 0;
--- a/svq1_cb.h Fri May 07 21:34:33 2004 +0000 +++ b/svq1_cb.h Sat May 08 11:54:55 2004 +0000 @@ -769,6 +769,38 @@ svq1_inter_codebook_8x4, svq1_inter_codebook_8x8 }; +static const int8_t const svq1_inter_codebook_sum[4][16*6] = { + { + -1, 1, -2, 0, 1, -1, -1, -1, -2, -1, 1, -1, -1, 0, -1, -1, + 0, -1, -1, -1, -1, 0, -1, 0, 0, 0, -3, 1, -1, 0, 1, -1, + 1, -1, 2, 2, 1, 1, 2, 0, 0, 0, -1, 1, 1, 0, 0, 0, + 1, -1, 0, 1, -1, 1, 1, 0, 1, 0, -1, 1, 1, 0, 0, 0, + -2, 0, 0, -2, 0, 0, -2, 0, -2, -1, -2, -1, 0, 0, -1, 0, + 1, 0, 1, -1, 2, 2, 1, 2, 2, 1, 0, 1, 1, 0, 1, 1, + },{ + -2, 1, -1, -1, 1, 0, 1, -1, -1, -1, 1, -1, 0, -1, 0, -1, + 0, 0, 0, -2, 0, 1, 0, -1, -1, 0, 2, -3, 1, -2, 3, -1, + 2, 0, 2, 1, 1, -1, 1, 1, 0, 0, 1, 1, 2, -2, 1, 0, + -2, -1, 2, -2, -2, 0, -3, 0, -1, 0, -1, 0, -1, 0, -2, -3, + 1, -2, -2, -1, 1, -1, -1, 1, -1, 1, 1, 0, -2, 0, 1, 1, + 1, 1, 2, 1, 0, 0, -1, 0, 0, 1, 0, 1, -1, 1, 0, 2, + },{ + 0, 0, 0, -3, 1, 1, 1, -3, 0, -1, 0, -3, 1, -3, 0, -2, + 1, 2, -1, -3, 0, -3, 1, -1, 0, -1, 0, 0, 1, 2, 1, 1, + -1, 2, -3, 3, 1, 0, -5, 1, 0, -1, -3, 1, 0, 2, 0, -3, + 4, 2, 0, -2, 1, -2, 3, -2, 1, 1, 0, -1, 2, 5, 3, 1, + -1, 0, 2, -3, -2, 0, 0, -2, 2, -3, -1, -1, 2, 1, 0, -2, + 3, -1, 1, -1, 2, 4, 0, 1, 0, 1, 0, -1, -3, -2, -1, 0, + },{ + 0, 2, -1, -1, 2, -4, -2, 3, 0, -1, -5, 1, 0, 1, 0, 6, + -2, 2, 0, 1, 1, -1, -1, -2, 1, -2, -1, 0, 2, -2, -2, -1, + -4, 2, -1, -3, -1, -2, 2, -1, 2, -1, 2, 0, 3, -3, -3, 0, + -3, 0, 0, -2, 4, -4, 0, -1, 4, 0, -2, -2, 3, -2, 0, 4, + 5, 0, 1, 0, -3, 3, 3, 2, 0, 0, 1, 2, -5, -2, -3, 0, + -3, 2, -2, 2, -2, 4, 7, -3, 4, 2, 3, 2, -1, 0, -3, 1, + } +}; + /* 6x16-entry codebook for intra-coded 4x2 vectors */ static const int8_t svq1_intra_codebook_4x2[768] = { 12, 13, 13, 11, -7,-10,-15,-17,-16,-15,-12,-10, 11, 15, 15, 12, @@ -1510,3 +1542,35 @@ svq1_intra_codebook_4x2, svq1_intra_codebook_4x4, svq1_intra_codebook_8x4, svq1_intra_codebook_8x8 }; + +static const int8_t const svq1_intra_codebook_sum[4][16*6] = { + { + 0, 0, 0, -1, -1, -1, -1, -2, 0, -1, -1, 0, -1, 0, 1, 0, + 1, 0, -1, 1, 0, 0, -1, 1, -1, 0, 0, 0, -1, 1, 0, 0, + -1, 0, 0, 1, -1, 1, 0, -1, -1, 0, 1, 1, 0, 0, -1, 1, + 0, 1, 0, 0, 1, -1, 0, 0, 0, -1, 1, 0, 1, 0, -2, 1, + 0, -1, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, -1, 0, 0, 0, + 0, 1, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, -1, 1, 1, -1, + },{ + -1, -2, 0, -1, 1, 0, -1, 0, -1, -4, -1, -2, -1, -2, 1, -2, + 0, 0, 4, -2, -1, 1, 1, 0, 2, 1, 1, 0, 2, 0, 0, 0, + 1, 1, 0, -1, -1, -1, 1, 0, -1, -3, -3, 1, -1, 1, -2, -1, + 1, -1, 0, 1, 2, 1, -1, -1, 1, 1, 1, 2, 1, 0, 1, -2, + -2, 0, -1, -2, -2, 0, -1, -1, -1, 0, 1, 0, -1, -1, 0, -1, + 0, 2, 1, 2, 2, 1, -1, 1, 0, 2, 0, -1, 1, 0, 0, 0, + },{ + -2, 0, -1, -1, 1, 1, -2, 0, -2, 0, 1, -2, -2, 1, -1, -1, + 3, -2, 0, -3, -4, -3, 2, 1, 0, 3, -2, 2, 3, 2, 2, -1, + -3, 1, 0, 1, 0, 0, 0, 1, -2, 1, -2, -2, -1, -2, -2, 2, + 0, -4, 0, 2, -1, 0, 2, 2, 2, 1, 0, -1, -1, 1, -3, 2, + 2, 1, 0, 3, 1, -1, 1, 3, 1, 0, 1, 1, 2, -1, 1, -1, + -2, -1, 0, -1, 1, -1, 1, -2, -2, -1, -1, -3, 1, -4, -3, 1, + },{ + -2, 0, -2, 3, -1, -1, 0, 2, 2, -1, -3, 2, 1, 0, -2, -1, + -3, -2, -2, 1, 2, -3, 0, 1, -5, -2, -3, 0, -2, -1, 2, 0, + -1, -1, 0, -2, 1, 3, -7, -2, -2, -1, 2, -1, 0, 3, 1, 3, + 1, 0, 0, 1, 2, 3, 1, 2, 0, -2, -2, 1, 1, 2, 2, 3, + 4, 1, -1, 2, -2, 4, 0, 0, 0, 4, 2, 0, -2, -2, 2, -4, + -1, 5, -2, -2, -3, 2, -3, -1, 3, -3, 0, 4, 3, 0, 1, -2, + } +};