mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-29 10:52:20 +00:00
noise preserving sum of squares comparission function
Originally committed as revision 3204 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
2b647ac8c9
commit
e6a2ac3474
@ -915,8 +915,8 @@ typedef struct AVCodecContext {
|
||||
void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
|
||||
|
||||
/**
|
||||
* is 1 if the decoded stream contains b frames, 0 otherwise.
|
||||
* - encoding: unused
|
||||
* if 1 the stream has a 1 frame delay during decoding.
|
||||
* - encoding: set by lavc
|
||||
* - decoding: set by lavc
|
||||
*/
|
||||
int has_b_frames;
|
||||
@ -1251,6 +1251,7 @@ typedef struct AVCodecContext {
|
||||
#define FF_CMP_ZERO 7
|
||||
#define FF_CMP_VSAD 8
|
||||
#define FF_CMP_VSSE 9
|
||||
#define FF_CMP_NSSE 10
|
||||
#define FF_CMP_CHROMA 256
|
||||
|
||||
/**
|
||||
|
@ -2587,6 +2587,54 @@ static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
|
||||
return s;
|
||||
}
|
||||
|
||||
static int nsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
|
||||
int score1=0;
|
||||
int score2=0;
|
||||
int x,y;
|
||||
|
||||
for(y=0; y<h; y++){
|
||||
for(x=0; x<16; x++){
|
||||
score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
|
||||
}
|
||||
if(y+1<h){
|
||||
for(x=0; x<15; x++){
|
||||
score2+= ABS( s1[x ] - s1[x +stride]
|
||||
- s1[x+1] + s1[x+1+stride])
|
||||
-ABS( s2[x ] - s2[x +stride]
|
||||
- s2[x+1] + s2[x+1+stride]);
|
||||
}
|
||||
}
|
||||
s1+= stride;
|
||||
s2+= stride;
|
||||
}
|
||||
|
||||
return score1 + ABS(score2)*8;
|
||||
}
|
||||
|
||||
static int nsse8_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
|
||||
int score1=0;
|
||||
int score2=0;
|
||||
int x,y;
|
||||
|
||||
for(y=0; y<h; y++){
|
||||
for(x=0; x<8; x++){
|
||||
score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
|
||||
}
|
||||
if(y+1<h){
|
||||
for(x=0; x<7; x++){
|
||||
score2+= ABS( s1[x ] - s1[x +stride]
|
||||
- s1[x+1] + s1[x+1+stride])
|
||||
-ABS( s2[x ] - s2[x +stride]
|
||||
- s2[x+1] + s2[x+1+stride]);
|
||||
}
|
||||
}
|
||||
s1+= stride;
|
||||
s2+= stride;
|
||||
}
|
||||
|
||||
return score1 + ABS(score2)*8;
|
||||
}
|
||||
|
||||
static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
|
||||
int i;
|
||||
unsigned int sum=0;
|
||||
@ -2680,6 +2728,9 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
|
||||
case FF_CMP_ZERO:
|
||||
cmp[i]= zero_cmp;
|
||||
break;
|
||||
case FF_CMP_NSSE:
|
||||
cmp[i]= c->nsse[i];
|
||||
break;
|
||||
default:
|
||||
av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
|
||||
}
|
||||
@ -3313,6 +3364,8 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
|
||||
c->vsad[4]= vsad_intra16_c;
|
||||
c->vsse[0]= vsse16_c;
|
||||
c->vsse[4]= vsse_intra16_c;
|
||||
c->nsse[0]= nsse16_c;
|
||||
c->nsse[1]= nsse8_c;
|
||||
|
||||
c->add_bytes= add_bytes_c;
|
||||
c->diff_bytes= diff_bytes_c;
|
||||
|
@ -162,6 +162,7 @@ typedef struct DSPContext {
|
||||
me_cmp_func rd[5];
|
||||
me_cmp_func vsad[5];
|
||||
me_cmp_func vsse[5];
|
||||
me_cmp_func nsse[5];
|
||||
|
||||
me_cmp_func me_pre_cmp[5];
|
||||
me_cmp_func me_cmp[5];
|
||||
|
@ -223,6 +223,7 @@ static inline int get_penalty_factor(MpegEncContext *s, int type){
|
||||
switch(type&0xFF){
|
||||
default:
|
||||
case FF_CMP_SAD:
|
||||
case FF_CMP_NSSE:
|
||||
return s->lambda>>FF_LAMBDA_SHIFT;
|
||||
case FF_CMP_DCT:
|
||||
return (3*s->lambda)>>(FF_LAMBDA_SHIFT+1);
|
||||
|
@ -3916,9 +3916,15 @@ static int sse_mb(MpegEncContext *s){
|
||||
if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
|
||||
|
||||
if(w==16 && h==16)
|
||||
if(s->avctx->mb_cmp == FF_CMP_NSSE){
|
||||
return s->dsp.nsse[0](NULL, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
|
||||
+s->dsp.nsse[1](NULL, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
|
||||
+s->dsp.nsse[1](NULL, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
|
||||
}else{
|
||||
return s->dsp.sse[0](NULL, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
|
||||
+s->dsp.sse[1](NULL, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
|
||||
+s->dsp.sse[1](NULL, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
|
||||
}
|
||||
else
|
||||
return sse(s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
|
||||
+sse(s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
|
||||
|
Loading…
Reference in New Issue
Block a user