[Mplayer-cvslog] CVS: main/libmpcodecs ve_xvid4.c,1.4,1.5
Ivan Kalvachev CVS
syncmail at mplayerhq.hu
Thu Feb 5 00:18:27 CET 2004
CVS change done by Ivan Kalvachev CVS
Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv23845
Modified Files:
ve_xvid4.c
Log Message:
psnr and debug option added
Index: ve_xvid4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_xvid4.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ve_xvid4.c 2 Feb 2004 19:51:39 -0000 1.4
+++ ve_xvid4.c 4 Feb 2004 23:18:25 -0000 1.5
@@ -31,6 +31,7 @@
#include <errno.h>
#include <math.h>
#include <limits.h>
+#include <time.h>
#include "../config.h"
#include "../mp_msg.h"
@@ -165,6 +166,8 @@
static int xvidenc_max_key_interval = 0; /* Let xvidcore set a 10s interval by default */
static int xvidenc_frame_drop_ratio = 0;
static int xvidenc_greyscale = 0;
+static int xvidenc_debug = 0;
+static int xvidenc_psnr = 0;
static int xvidenc_max_bframes = 2;
static int xvidenc_bquant_ratio = 150;
@@ -226,7 +229,9 @@
{"max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
{"greyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"turbo", &xvidenc_turbo, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+ {"debug", &xvidenc_debug, CONF_TYPE_INT , 0 ,0,-1,NULL},
{"stats", &xvidenc_stats, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+ {"psnr", &xvidenc_psnr , CONF_TYPE_FLAG, 0, 0, 1, NULL},
/* section [quantizer] */
@@ -298,10 +303,13 @@
int min_sse_y;
int min_sse_u;
int min_sse_v;
+ int min_framenum;
int max_sse_y;
int max_sse_u;
int max_sse_v;
+ int max_framenum;
+ int pixels;
int d_width, d_height;
} xvid_mplayer_module_t;
@@ -387,36 +395,34 @@
/* Display stats */
if(mod->frames) {
- int pixels;
-
mod->sse_y /= mod->frames;
mod->sse_u /= mod->frames;
mod->sse_v /= mod->frames;
- pixels = mod->create.width*mod->create.height;
-
#define SSE2PSNR(sse, nbpixels) \
((!(sse)) ? 99.99f : 48.131f - 10*(double)log10((double)(sse)/(double)((nbpixels))))
mp_msg(MSGT_MENCODER, MSGL_INFO,
"The value 99.99dB is a special value and represents "
"the upper range limit\n");
mp_msg(MSGT_MENCODER, MSGL_INFO,
- "xvid: Min PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB\n",
- SSE2PSNR(mod->max_sse_y, pixels),
- SSE2PSNR(mod->max_sse_u, pixels/4),
- SSE2PSNR(mod->max_sse_v, pixels/4));
+ "xvid: Min PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB, in frame %d\n",
+ SSE2PSNR(mod->max_sse_y, mod->pixels),
+ SSE2PSNR(mod->max_sse_u, mod->pixels/4),
+ SSE2PSNR(mod->max_sse_v, mod->pixels/4),
+ mod->max_framenum);
mp_msg(MSGT_MENCODER, MSGL_INFO,
- "xvid: Average PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB\n",
- SSE2PSNR(mod->sse_y, pixels),
- SSE2PSNR(mod->sse_u, pixels/4),
- SSE2PSNR(mod->sse_v, pixels/4));
+ "xvid: Average PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB, for %d frames\n",
+ SSE2PSNR(mod->sse_y, mod->pixels),
+ SSE2PSNR(mod->sse_u, mod->pixels/4),
+ SSE2PSNR(mod->sse_v, mod->pixels/4),
+ mod->frames);
mp_msg(MSGT_MENCODER, MSGL_INFO,
- "xvid: Max PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB\n",
- SSE2PSNR(mod->min_sse_y, pixels),
- SSE2PSNR(mod->min_sse_u, pixels/4),
- SSE2PSNR(mod->min_sse_v, pixels/4));
+ "xvid: Max PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB, in frame %d\n",
+ SSE2PSNR(mod->min_sse_y, mod->pixels),
+ SSE2PSNR(mod->min_sse_u, mod->pixels/4),
+ SSE2PSNR(mod->min_sse_v, mod->pixels/4),
+ mod->min_framenum);
}
-#undef SSE2PSNR
/* ToDo: free matrices, and some string settings (quant method, matrix
* filenames...) */
@@ -495,7 +501,6 @@
/* Did xvidcore returned stats about an encoded frame ? (asynchronous) */
if(xvidenc_stats && stats.type > 0) {
- mod->frames++;
mod->sse_y += stats.sse_y;
mod->sse_u += stats.sse_u;
mod->sse_v += stats.sse_v;
@@ -504,14 +509,46 @@
mod->min_sse_y = stats.sse_y;
mod->min_sse_u = stats.sse_u;
mod->min_sse_v = stats.sse_v;
+ mod->min_framenum = mod->frames;
}
if(mod->max_sse_y < stats.sse_y) {
mod->max_sse_y = stats.sse_y;
mod->max_sse_u = stats.sse_u;
mod->max_sse_v = stats.sse_v;
+ mod->max_framenum = mod->frames;
+ }
+ if (xvidenc_psnr) {
+ static FILE *fvstats = NULL;
+ char filename[20];
+
+ if (!fvstats) {
+ time_t today2;
+ struct tm *today;
+ today2 = time (NULL);
+ today = localtime (&today2);
+ sprintf (filename, "psnr_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec);
+ fvstats = fopen (filename,"w");
+ if (!fvstats) {
+ perror ("fopen");
+ xvidenc_psnr = 0; // disable block
+ }
+ }
+ fprintf (fvstats, "%6d, %2d, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n",
+ mod->frames,
+ stats.quant,
+ stats.length,
+ SSE2PSNR (stats.sse_y, mod->pixels),
+ SSE2PSNR (stats.sse_u, mod->pixels / 4),
+ SSE2PSNR (stats.sse_v, mod->pixels / 4),
+ SSE2PSNR (stats.sse_y + stats.sse_u + stats.sse_v,(double)mod->pixels * 1.5),
+ stats.type==1?'I':stats.type==2?'P':stats.type==3?'B':stats.type?'S':'?'
+ );
}
+ mod->frames++;
+
}
+#undef SSE2PSNR
/* xvidcore outputed bitstream -- mux it */
muxer_write_chunk(mod->mux,
@@ -590,6 +627,7 @@
/* Initialize the xvid_gbl_init structure */
memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init_t));
xvid_gbl_init.version = XVID_VERSION;
+ xvid_gbl_init.debug = xvidenc_debug;
/* Initialize the xvidcore library */
if (xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL) < 0) {
@@ -645,6 +683,9 @@
if(xvidenc_closed_gop)
create->global |= XVID_GLOBAL_CLOSED_GOP;
+ if(xvidenc_psnr)
+ xvidenc_stats = 1;
+
if(xvidenc_stats)
create->global |= XVID_GLOBAL_EXTRASTATS_ENABLE;
@@ -858,6 +899,9 @@
create->width = mod->mux->bih->biWidth;
create->height = mod->mux->bih->biHeight;
+ /* Pixels are needed for PSNR calculations */
+ mod->pixels = create->width * create->height;
+
/* FPS */
create->fincr = mod->mux->h.dwScale;
create->fbase = mod->mux->h.dwRate;
More information about the MPlayer-cvslog
mailing list