--- plugin_2pass1.c 2003/10/01 23:23:01 1.1.2.7 +++ plugin_2pass1.c 2003/12/18 17:43:32 1.1.2.11 @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: plugin_2pass1.c,v 1.1.2.7 2003/10/01 23:23:01 edgomez Exp $ + * $Id: plugin_2pass1.c,v 1.1.2.11 2003/12/18 17:43:32 edgomez Exp $ * *****************************************************************************/ @@ -60,18 +60,17 @@ rc->stat_file = NULL; /* Open the 1st pass file */ - if((rc->stat_file = fopen(param->filename, "w+")) == NULL) + if((rc->stat_file = fopen(param->filename, "w+b")) == NULL) return(XVID_ERR_FAIL); /* * The File Header */ -#if 0 - fprintf(rc->stat_file, "# XviD 2pass stat file\n"); - fprintf(rc->stat_file, "version %i.%i.%i\n",XVID_MAJOR(XVID_VERSION), XVID_MINOR(XVID_VERSION), XVID_PATCH(XVID_VERSION)); - fprintf(rc->stat_file, "start\n"); - fprintf(rc->stat_file, "type quantizer length kblocks mblocks ublocks\n"); -#endif + fprintf(rc->stat_file, "# XviD 2pass stat file (core version %d.%d.%d)\n", + XVID_VERSION_MAJOR(XVID_VERSION), + XVID_VERSION_MINOR(XVID_VERSION), + XVID_VERSION_PATCH(XVID_VERSION)); + fprintf(rc->stat_file, "# Please do not modify this file\n\n"); rc->fq_error = 0; @@ -83,7 +82,6 @@ static int rc_2pass1_destroy(rc_2pass1_t * rc, xvid_plg_destroy_t * destroy) { fclose(rc->stat_file); - free(rc); return(0); } @@ -91,26 +89,26 @@ static int rc_2pass1_before(rc_2pass1_t * rc, xvid_plg_data_t * data) { - if (data->quant <= 0) { - if (data->zone && data->zone->mode == XVID_ZONE_QUANT) { - rc->fq_error += (double)data->zone->increment / (double)data->zone->base; - data->quant = (int)rc->fq_error; - rc->fq_error -= data->quant; - - }else { - data->quant = 2; - } - } - return 0; + if (data->quant <= 0) { + if (data->zone && data->zone->mode == XVID_ZONE_QUANT) { + rc->fq_error += (double)data->zone->increment / (double)data->zone->base; + data->quant = (int)rc->fq_error; + rc->fq_error -= data->quant; + } else { + data->quant = 2; + } + } + return(0); } static int rc_2pass1_after(rc_2pass1_t * rc, xvid_plg_data_t * data) { char type; + xvid_enc_stats_t *stats = &data->stats; /* Frame type in ascii I/P/B */ - switch(data->type) { + switch(stats->type) { case XVID_TYPE_IVOP: type = 'i'; break; @@ -129,13 +127,14 @@ /* write the resulting statistics */ - fprintf(rc->stat_file, "%c %d %d %d %d %d\n", - type, - data->quant, - data->kblks, - data->mblks, - data->ublks, - data->length); + fprintf(rc->stat_file, "%c %d %d %d %d %d %d\n", + type, + stats->quant, + stats->kblks, + stats->mblks, + stats->ublks, + stats->length, + stats->hlength); return(0); } @@ -147,6 +146,7 @@ switch(opt) { case XVID_PLG_INFO : + case XVID_PLG_FRAME : return 0; case XVID_PLG_CREATE :