aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2002-12-04 21:13:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-12-04 21:13:02 +0000
commit140cb66321f2d3271d4e1a9c80eee42e0500c4fa (patch)
tree46fac4ba73ad79302383b7c8b8ae25b3d665a2cb /ffmpeg.c
parent5b20b7328a6b0d0286b6d0f1975fbd417ae010eb (diff)
downloadffmpeg-140cb66321f2d3271d4e1a9c80eee42e0500c4fa.tar.gz
new PSNR code (now works with chroma, b frames, ...)
rename *_TYPE to FF_*_TYPE for the external API allow user specified pict_type Originally committed as revision 1308 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 109bbf95ad..04fc9c99fd 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -650,6 +650,11 @@ static void do_video_out(AVFormatContext *s,
av_free(buf1);
}
+static double psnr(double d){
+ if(d==0) return INFINITY;
+ return -10.0*log(d)/log(10);
+}
+
static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
int frame_size)
{
@@ -682,8 +687,8 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
if (enc->codec_type == CODEC_TYPE_VIDEO) {
frame_number = ost->frame_number;
fprintf(fvstats, "frame= %5d q= %2.1f ", frame_number, enc->coded_picture->quality);
- if (do_psnr)
- fprintf(fvstats, "PSNR= %6.2f ", enc->psnr_y);
+ if (enc->flags&CODEC_FLAG_PSNR)
+ fprintf(fvstats, "PSNR= %6.2f ", psnr(enc->coded_picture->error[0]/(enc->width*enc->height*255.0*255.0)));
fprintf(fvstats,"f_size= %6d ", frame_size);
/* compute pts value */
@@ -745,8 +750,8 @@ void print_report(AVFormatContext **output_files,
frame_number = ost->frame_number;
sprintf(buf + strlen(buf), "frame=%5d q=%2.1f ",
frame_number, enc->coded_picture ? enc->coded_picture->quality : 0);
- if (do_psnr)
- sprintf(buf + strlen(buf), "PSNR=%6.2f ", enc->psnr_y);
+ if (enc->flags&CODEC_FLAG_PSNR)
+ sprintf(buf + strlen(buf), "PSNR= %6.2f ", psnr(enc->coded_picture->error[0]/(enc->width*enc->height*255.0*255.0)));
vid = 1;
}
/* compute min output value */
@@ -2161,9 +2166,7 @@ void opt_output_file(const char *filename)
}
if (do_psnr)
- video_enc->get_psnr = 1;
- else
- video_enc->get_psnr = 0;
+ video_enc->flags|= CODEC_FLAG_PSNR;
video_enc->me_method = me_method;