54 |
#include <xvid.h> |
#include <xvid.h> |
55 |
#include "debug.h" |
#include "debug.h" |
56 |
#include "codec.h" |
#include "codec.h" |
57 |
|
#include "status.h" |
58 |
|
|
59 |
|
|
60 |
static const int pmvfast_presets[7] = { |
static const int pmvfast_presets[7] = { |
244 |
|
|
245 |
LRESULT compress_frames_info(CODEC * codec, ICCOMPRESSFRAMES * icf) |
LRESULT compress_frames_info(CODEC * codec, ICCOMPRESSFRAMES * icf) |
246 |
{ |
{ |
247 |
//DPRINTF("%i %i", icf->lStartFrame, icf->lFrameCount); |
#if 0 |
248 |
|
DPRINTF("%i %i", icf->lStartFrame, icf->lFrameCount); |
249 |
|
#endif |
250 |
codec->fincr = icf->dwScale; |
codec->fincr = icf->dwScale; |
251 |
codec->fbase = icf->dwRate; |
codec->fbase = icf->dwRate; |
252 |
return ICERR_OK; |
return ICERR_OK; |
319 |
memset(&create, 0, sizeof(create)); |
memset(&create, 0, sizeof(create)); |
320 |
create.version = XVID_VERSION; |
create.version = XVID_VERSION; |
321 |
|
|
322 |
// zones |
/* zones */ |
323 |
create.zones = malloc(sizeof(xvid_enc_zone_t) * codec->config.num_zones); |
create.zones = malloc(sizeof(xvid_enc_zone_t) * codec->config.num_zones); |
324 |
create.num_zones = codec->config.num_zones; |
create.num_zones = codec->config.num_zones; |
325 |
for (i=0; i < create.num_zones; i++) { |
for (i=0; i < create.num_zones; i++) { |
334 |
create.zones[i].base = 100; |
create.zones[i].base = 100; |
335 |
} |
} |
336 |
|
|
337 |
// plugins |
/* plugins */ |
338 |
create.plugins = plugins; |
create.plugins = plugins; |
339 |
switch (codec->config.mode) |
switch (codec->config.mode) |
340 |
{ |
{ |
363 |
case RC_MODE_2PASS2 : |
case RC_MODE_2PASS2 : |
364 |
memset(&pass2, 0, sizeof(pass2)); |
memset(&pass2, 0, sizeof(pass2)); |
365 |
pass2.version = XVID_VERSION; |
pass2.version = XVID_VERSION; |
366 |
|
if (codec->config.use_2pass_bitrate) { |
367 |
pass2.bitrate = codec->config.bitrate * CONFIG_KBPS; |
pass2.bitrate = codec->config.bitrate * CONFIG_KBPS; |
368 |
|
}else{ |
369 |
|
pass2.bitrate = -codec->config.desired_size; /* kilobytes */ |
370 |
|
} |
371 |
pass2.filename = codec->config.stats; |
pass2.filename = codec->config.stats; |
372 |
|
|
373 |
pass2.keyframe_boost = codec->config.keyframe_boost; /* keyframe boost percentage: [0..100...]; */ |
pass2.keyframe_boost = codec->config.keyframe_boost; /* keyframe boost percentage: [0..100...]; */ |
456 |
codec->framenum = 0; |
codec->framenum = 0; |
457 |
codec->keyspacing = 0; |
codec->keyspacing = 0; |
458 |
|
|
459 |
|
if (codec->config.display_status) { |
460 |
|
status_destroy_always(&codec->status); |
461 |
|
status_create(&codec->status, codec->fincr, codec->fbase); |
462 |
|
} |
463 |
|
|
464 |
return ICERR_OK; |
return ICERR_OK; |
465 |
} |
} |
466 |
|
|
467 |
|
|
468 |
LRESULT compress_end(CODEC * codec) |
LRESULT compress_end(CODEC * codec) |
469 |
{ |
{ |
470 |
if (codec->ehandle != NULL) |
if (codec->ehandle != NULL) { |
|
{ |
|
471 |
xvid_encore(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); |
xvid_encore(codec->ehandle, XVID_ENC_DESTROY, NULL, NULL); |
472 |
codec->ehandle = NULL; |
codec->ehandle = NULL; |
473 |
} |
} |
474 |
|
|
475 |
|
if (codec->config.display_status) |
476 |
|
status_destroy(&codec->status); |
477 |
|
|
478 |
return ICERR_OK; |
return ICERR_OK; |
479 |
} |
} |
480 |
|
|
656 |
return ICERR_UNSUPPORTED; |
return ICERR_UNSUPPORTED; |
657 |
} |
} |
658 |
|
|
659 |
|
if (codec->config.display_status && stats.type>0) { |
660 |
|
status_update(&codec->status, stats.type, stats.length, stats.quant); |
661 |
|
} |
662 |
|
|
663 |
DPRINTF("{type=%i len=%i} length=%i", stats.type, stats.length, length); |
DPRINTF("{type=%i len=%i} length=%i", stats.type, stats.length, length); |
664 |
|
|
665 |
if (length == 0) /* no encoder output */ |
if (length == 0) /* no encoder output */ |
743 |
|
|
744 |
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
if (get_colorspace(inhdr) != XVID_CSP_NULL) { |
745 |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER)); |
746 |
// XXX: should we set outhdr->biSize ?? |
/* XXX: should we set outhdr->biSize ?? */ |
747 |
return ICERR_OK; |
return ICERR_OK; |
748 |
} |
} |
749 |
/* --- yv12 --- */ |
/* --- yv12 --- */ |