3 |
* XviD Bit Rate Controller Library |
* XviD Bit Rate Controller Library |
4 |
* - VBR 2 pass bitrate controler implementation - |
* - VBR 2 pass bitrate controler implementation - |
5 |
* |
* |
6 |
* Copyright (C) 2002 Edouard Gomez <ed.gomez@wanadoo.fr> |
* Copyright (C) 2002-2003 Edouard Gomez <ed.gomez@free.fr> |
7 |
* |
* |
8 |
* The curve treatment algorithm is the one implemented by Foxer <email?> and |
* The curve treatment algorithm is the one implemented by Foxer <email?> and |
9 |
* Dirk Knop <dknop@gwdg.de> for the XviD vfw dynamic library. |
* Dirk Knop <dknop@gwdg.de> for the XviD vfw dynamic library. |
22 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
* |
* |
25 |
* $Id: plugin_2pass1.c,v 1.1.2.1 2003-03-23 04:03:01 suxen_drol Exp $ |
* $Id: plugin_2pass1.c,v 1.1.2.5 2003-06-09 13:55:07 edgomez Exp $ |
26 |
* |
* |
27 |
*****************************************************************************/ |
*****************************************************************************/ |
28 |
|
|
36 |
typedef struct |
typedef struct |
37 |
{ |
{ |
38 |
FILE * stat_file; |
FILE * stat_file; |
39 |
|
|
40 |
|
double fq_error; |
41 |
} rc_2pass1_t; |
} rc_2pass1_t; |
42 |
|
|
43 |
|
|
65 |
/* |
/* |
66 |
* The File Header |
* The File Header |
67 |
*/ |
*/ |
68 |
/* fprintf(rc->stat_file, "# XviD 2pass stat file\n"); |
#if 0 |
69 |
|
fprintf(rc->stat_file, "# XviD 2pass stat file\n"); |
70 |
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, "version %i.%i.%i\n",XVID_MAJOR(XVID_VERSION), XVID_MINOR(XVID_VERSION), XVID_PATCH(XVID_VERSION)); |
71 |
fprintf(rc->stat_file, "start\n"); |
fprintf(rc->stat_file, "start\n"); |
72 |
fprintf(rc->stat_file, "type quantizer length kblocks mblocks ublocks\n"); */ |
fprintf(rc->stat_file, "type quantizer length kblocks mblocks ublocks\n"); |
73 |
|
#endif |
74 |
|
|
75 |
|
rc->fq_error = 0; |
76 |
|
|
77 |
*handle = rc; |
*handle = rc; |
78 |
return(0); |
return(0); |
81 |
|
|
82 |
static int rc_2pass1_destroy(rc_2pass1_t * rc, xvid_plg_destroy_t * destroy) |
static int rc_2pass1_destroy(rc_2pass1_t * rc, xvid_plg_destroy_t * destroy) |
83 |
{ |
{ |
|
//fprintf(rc->stat_file, "stop\n"); |
|
84 |
fclose(rc->stat_file); |
fclose(rc->stat_file); |
85 |
|
|
86 |
free(rc); |
free(rc); |
90 |
|
|
91 |
static int rc_2pass1_before(rc_2pass1_t * rc, xvid_plg_data_t * data) |
static int rc_2pass1_before(rc_2pass1_t * rc, xvid_plg_data_t * data) |
92 |
{ |
{ |
93 |
|
if (data->quant <= 0) { |
94 |
|
if (data->zone && data->zone->mode == XVID_ZONE_QUANT) { |
95 |
|
rc->fq_error += (double)data->zone->increment / (double)data->zone->base; |
96 |
|
data->quant = (int)rc->fq_error; |
97 |
|
rc->fq_error -= data->quant; |
98 |
|
|
99 |
|
}else { |
100 |
data->quant = 2; |
data->quant = 2; |
101 |
data->type = XVID_TYPE_AUTO; |
} |
102 |
|
} |
103 |
return 0; |
return 0; |
104 |
} |
} |
105 |
|
|
131 |
fprintf(rc->stat_file, "%c %d %d %d %d %d\n", |
fprintf(rc->stat_file, "%c %d %d %d %d %d\n", |
132 |
type, |
type, |
133 |
data->quant, |
data->quant, |
|
data->length, |
|
134 |
data->kblks, |
data->kblks, |
135 |
data->mblks, |
data->mblks, |
136 |
data->ublks); |
data->ublks, |
137 |
|
data->length); |
138 |
|
|
139 |
return(0); |
return(0); |
140 |
} |
} |