20 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: plugin_single.c,v 1.1.2.2 2003-05-17 13:36:38 suxen_drol Exp $ |
* $Id: plugin_single.c,v 1.1.2.7 2003-11-28 14:20:13 syskin Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
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 |
173 |
double base_quality; |
double base_quality; |
174 |
double target_quality; |
double target_quality; |
175 |
|
|
|
|
|
176 |
/* Update internal values */ |
/* Update internal values */ |
177 |
rc->time += (double) data->fincr / data->fbase; |
rc->time += (double) data->fincr / data->fbase; |
178 |
rc->total_size += data->length; |
rc->total_size += data->length; |
179 |
|
|
180 |
|
if(data->type == XVID_TYPE_BVOP) |
181 |
|
return (0); |
182 |
|
|
183 |
|
rc->rtn_quant = data->quant; |
184 |
|
|
185 |
/* Compute the deviation from expected total size */ |
/* Compute the deviation from expected total size */ |
186 |
deviation = (int64_t) |
deviation = |
187 |
((double) rc->total_size - (double) rc->bytes_per_sec * rc->time); |
rc->total_size - rc->bytes_per_sec * rc->time; |
188 |
|
|
189 |
|
|
190 |
if (data->quant >= 2) { |
if (data->quant >= 2) { |
245 |
else if (rtn_quant < data->quant - 1) |
else if (rtn_quant < data->quant - 1) |
246 |
rtn_quant = data->quant - 1; |
rtn_quant = data->quant - 1; |
247 |
|
|
248 |
/* limit to min/max range */ |
/* limit to min/max range |
249 |
if (rtn_quant > data->max_quant[data->type-1]) |
we don't know frame type of the next frame, so we just use |
250 |
rtn_quant = data->max_quant[data->type-1]; |
P-VOP's range... */ |
251 |
else if (rtn_quant < data->min_quant[data->type-1]) |
if (rtn_quant > data->max_quant[XVID_TYPE_PVOP-1]) |
252 |
rtn_quant = data->min_quant[data->type-1]; |
rtn_quant = data->max_quant[XVID_TYPE_PVOP-1]; |
253 |
|
else if (rtn_quant < data->min_quant[XVID_TYPE_PVOP-1]) |
254 |
|
rtn_quant = data->min_quant[XVID_TYPE_PVOP-1]; |
255 |
|
|
256 |
rc->rtn_quant = rtn_quant; |
rc->rtn_quant = rtn_quant; |
257 |
|
|
268 |
{ |
{ |
269 |
switch (opt) { |
switch (opt) { |
270 |
case XVID_PLG_INFO: |
case XVID_PLG_INFO: |
271 |
|
case XVID_PLG_FRAME : |
272 |
return 0; |
return 0; |
273 |
|
|
274 |
case XVID_PLG_CREATE: |
case XVID_PLG_CREATE: |