mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 13:21:13 +00:00
Adaptive quantization support for "-lavcopts psnr" and "-lavdopts vstats".
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9866 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
dae951d466
commit
a19559f911
@ -550,6 +550,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
||||
static int frame_number=0;
|
||||
static double all_frametime=0.0;
|
||||
AVFrame *pic= avctx->coded_frame;
|
||||
double quality=0.0;
|
||||
|
||||
if(!fvstats) {
|
||||
time_t today2;
|
||||
@ -567,10 +568,24 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
||||
}
|
||||
}
|
||||
|
||||
// average MB quantizer
|
||||
{
|
||||
int x, y;
|
||||
int w = (avctx->width+15) >> 4;
|
||||
int h = (avctx->height+15) >> 4;
|
||||
int8_t *q = pic->qscale_table;
|
||||
for( y = 0; y < h; y++ ) {
|
||||
for( x = 0; x < w; x++ )
|
||||
quality += (double)*(q+x);
|
||||
q += pic->qstride;
|
||||
}
|
||||
quality /= w * h;
|
||||
}
|
||||
|
||||
all_len+=len;
|
||||
all_frametime+=sh->frametime;
|
||||
fprintf(fvstats, "frame= %5d q= %2.2f f_size= %6d s_size= %8.0fkB ",
|
||||
++frame_number, pic->quality, len, (double)all_len/1024);
|
||||
++frame_number, quality, len, (double)all_len/1024);
|
||||
fprintf(fvstats, "time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
|
||||
all_frametime, (double)(len*8)/sh->frametime/1000.0,
|
||||
(double)(all_len*8)/all_frametime/1000.0);
|
||||
@ -587,11 +602,14 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
||||
case FF_B_TYPE:
|
||||
fprintf(fvstats, "type= B\n");
|
||||
break;
|
||||
default:
|
||||
fprintf(fvstats, "type= ? (%d)\n", pic->pict_type);
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->qp_stat[(int)(pic->quality+0.5)]++;
|
||||
ctx->qp_sum += pic->quality;
|
||||
ctx->inv_qp_sum += 1.0/pic->quality;
|
||||
ctx->qp_stat[(int)(quality+0.5)]++;
|
||||
ctx->qp_sum += quality;
|
||||
ctx->inv_qp_sum += 1.0/(double)quality;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -528,6 +528,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||
static double all_frametime=0.0;
|
||||
AVFrame *pic= lavc_venc_context->coded_frame;
|
||||
double f= lavc_venc_context->width*lavc_venc_context->height*255.0*255.0;
|
||||
double quality=0.0;
|
||||
|
||||
if(!fvstats) {
|
||||
time_t today2;
|
||||
@ -543,10 +544,24 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||
/*exit(1);*/
|
||||
}
|
||||
}
|
||||
|
||||
// average MB quantizer
|
||||
{
|
||||
int x, y;
|
||||
int w = (lavc_venc_context->width+15) >> 4;
|
||||
int h = (lavc_venc_context->height+15) >> 4;
|
||||
int8_t *q = lavc_venc_context->coded_frame->qscale_table;
|
||||
for( y = 0; y < h; y++ ) {
|
||||
for( x = 0; x < w; x++ )
|
||||
quality += (double)*(q+x);
|
||||
q += lavc_venc_context->coded_frame->qstride;
|
||||
}
|
||||
quality /= w * h;
|
||||
}
|
||||
|
||||
fprintf(fvstats, "%6d, %2.2f, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n",
|
||||
lavc_venc_context->coded_frame->coded_picture_number,
|
||||
lavc_venc_context->coded_frame->quality,
|
||||
quality,
|
||||
out_size,
|
||||
psnr(lavc_venc_context->coded_frame->error[0]/f),
|
||||
psnr(lavc_venc_context->coded_frame->error[1]*4/f),
|
||||
|
Loading…
Reference in New Issue
Block a user