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.2 2003-04-08 14:01:09 suxen_drol Exp $ |
* $Id: plugin_2pass1.c,v 1.1.2.3 2003-05-12 12:33:16 suxen_drol 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 |
|
|
62 |
if((rc->stat_file = fopen(param->filename, "w+")) == NULL) |
if((rc->stat_file = fopen(param->filename, "w+")) == NULL) |
63 |
return(XVID_ERR_FAIL); |
return(XVID_ERR_FAIL); |
64 |
|
|
65 |
|
{ |
66 |
|
int i; |
67 |
|
printf("---\n"); |
68 |
|
for (i=0;i<create->num_zones;i++) { |
69 |
|
printf("[%i] %i\n", create->zones[i].frame, create->zones[i].increment); |
70 |
|
} |
71 |
|
printf("---\n"); |
72 |
|
} |
73 |
|
|
74 |
/* |
/* |
75 |
* The File Header |
* The File Header |
76 |
*/ |
*/ |
79 |
fprintf(rc->stat_file, "start\n"); |
fprintf(rc->stat_file, "start\n"); |
80 |
fprintf(rc->stat_file, "type quantizer length kblocks mblocks ublocks\n"); */ |
fprintf(rc->stat_file, "type quantizer length kblocks mblocks ublocks\n"); */ |
81 |
|
|
82 |
|
rc->fq_error = 0; |
83 |
|
|
84 |
*handle = rc; |
*handle = rc; |
85 |
return(0); |
return(0); |
86 |
} |
} |
88 |
|
|
89 |
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) |
90 |
{ |
{ |
|
//fprintf(rc->stat_file, "stop\n"); |
|
91 |
fclose(rc->stat_file); |
fclose(rc->stat_file); |
92 |
|
|
93 |
free(rc); |
free(rc); |
97 |
|
|
98 |
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) |
99 |
{ |
{ |
100 |
|
if (data->quant <= 0) { |
101 |
|
if (data->zone && data->zone->mode == XVID_ZONE_QUANT) { |
102 |
|
rc->fq_error += (double)data->zone->increment / (double)data->zone->base; |
103 |
|
data->quant = (int)rc->fq_error; |
104 |
|
rc->fq_error -= data->quant; |
105 |
|
|
106 |
|
}else { |
107 |
data->quant = 2; |
data->quant = 2; |
108 |
data->type = XVID_TYPE_AUTO; |
} |
109 |
|
} |
110 |
return 0; |
return 0; |
111 |
} |
} |
112 |
|
|