30 |
#include "../xvid.h" |
#include "../xvid.h" |
31 |
#include "../image/image.h" |
#include "../image/image.h" |
32 |
|
|
33 |
#define DEFAULT_INITIAL_QUANTIZER 5 |
#define DEFAULT_INITIAL_QUANTIZER 8 |
34 |
|
|
35 |
#define DEFAULT_BITRATE 900000 /* 900kbps */ |
#define DEFAULT_BITRATE 900000 /* 900kbps */ |
36 |
#define DEFAULT_DELAY_FACTOR 16 |
#define DEFAULT_DELAY_FACTOR 16 |
153 |
data->quant = (int)rc->fq_error; |
data->quant = (int)rc->fq_error; |
154 |
rc->fq_error -= data->quant; |
rc->fq_error -= data->quant; |
155 |
}else { |
}else { |
156 |
data->quant = rc->rtn_quant; |
int q = rc->rtn_quant; |
157 |
|
/* limit to min/max range |
158 |
|
we don't know frame type of the next frame, so we just use |
159 |
|
P-VOP's range... */ |
160 |
|
if (q > data->max_quant[XVID_TYPE_PVOP-1]) |
161 |
|
q = data->max_quant[XVID_TYPE_PVOP-1]; |
162 |
|
else if (q < data->min_quant[XVID_TYPE_PVOP-1]) |
163 |
|
q = data->min_quant[XVID_TYPE_PVOP-1]; |
164 |
|
|
165 |
|
data->quant = q; |
166 |
} |
} |
167 |
} |
} |
168 |
return 0; |
return 0; |
182 |
double base_quality; |
double base_quality; |
183 |
double target_quality; |
double target_quality; |
184 |
|
|
|
|
|
185 |
/* Update internal values */ |
/* Update internal values */ |
186 |
rc->time += (double) data->fincr / data->fbase; |
rc->time += (double) data->fincr / data->fbase; |
187 |
rc->total_size += data->length; |
rc->total_size += data->length; |
188 |
|
|
189 |
|
if(data->type == XVID_TYPE_BVOP) |
190 |
|
return (0); |
191 |
|
|
192 |
|
rc->rtn_quant = data->quant; |
193 |
|
|
194 |
/* Compute the deviation from expected total size */ |
/* Compute the deviation from expected total size */ |
195 |
deviation = (int64_t) |
deviation = |
196 |
((double) rc->total_size - (double) rc->bytes_per_sec * rc->time); |
rc->total_size - rc->bytes_per_sec * rc->time; |
197 |
|
|
198 |
|
|
199 |
if (data->quant >= 2) { |
if (data->quant >= 2) { |
254 |
else if (rtn_quant < data->quant - 1) |
else if (rtn_quant < data->quant - 1) |
255 |
rtn_quant = data->quant - 1; |
rtn_quant = data->quant - 1; |
256 |
|
|
|
/* limit to min/max range */ |
|
|
if (rtn_quant > data->max_quant[data->type-1]) |
|
|
rtn_quant = data->max_quant[data->type-1]; |
|
|
else if (rtn_quant < data->min_quant[data->type-1]) |
|
|
rtn_quant = data->min_quant[data->type-1]; |
|
|
|
|
257 |
rc->rtn_quant = rtn_quant; |
rc->rtn_quant = rtn_quant; |
258 |
|
|
259 |
return (0); |
return (0); |
269 |
{ |
{ |
270 |
switch (opt) { |
switch (opt) { |
271 |
case XVID_PLG_INFO: |
case XVID_PLG_INFO: |
272 |
|
case XVID_PLG_FRAME : |
273 |
return 0; |
return 0; |
274 |
|
|
275 |
case XVID_PLG_CREATE: |
case XVID_PLG_CREATE: |