mirror of https://github.com/mpv-player/mpv
Updating XviD :
- deleted "hinted_me" and "hint_file", the whole idea is bogus. - commented-out "lumi_mask", it's too buggy. - better defaults for "bquant_ratio" / "bquant_offset" - fixed a typo : "extrastatl" -> "extrastat" git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9805 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a039bd2d53
commit
8f2869dd1f
|
@ -3416,14 +3416,6 @@ use MPEG quantizers instead of H.263 (default=off)
|
||||||
.IPs mod_quant
|
.IPs mod_quant
|
||||||
decide whether to use MPEG or H.263 quantizers on a frame-by-frame basis.
|
decide whether to use MPEG or H.263 quantizers on a frame-by-frame basis.
|
||||||
(default=off, 2pass mode only)
|
(default=off, 2pass mode only)
|
||||||
.IPs lumi_mask
|
|
||||||
use a lumimasking algorithm (default=off, seems buggy)
|
|
||||||
.IPs hintedme
|
|
||||||
save Motion Estimation vectors to a file during the first pass and reuse this
|
|
||||||
file during the second (default=off, 2pass mode only, seems buggy)
|
|
||||||
.IPs hintfile
|
|
||||||
specify the temporary file to be used by the 'hintedme' option
|
|
||||||
(default= \./xvid_hint_me.dat, 2pass mode only)
|
|
||||||
.IPs debug
|
.IPs debug
|
||||||
save per-frame statistics in xvid.dbg (default=off)
|
save per-frame statistics in xvid.dbg (default=off)
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -78,19 +78,17 @@ static int xvidenc_min_key_interval = -1;
|
||||||
static int xvidenc_max_key_interval = -1;
|
static int xvidenc_max_key_interval = -1;
|
||||||
static int xvidenc_mpeg_quant = 0;
|
static int xvidenc_mpeg_quant = 0;
|
||||||
static int xvidenc_mod_quant = 0;
|
static int xvidenc_mod_quant = 0;
|
||||||
static int xvidenc_lumi_mask = 0;
|
|
||||||
static int xvidenc_keyframe_boost = -1;
|
static int xvidenc_keyframe_boost = -1;
|
||||||
static int xvidenc_kfthreshold = -1;
|
static int xvidenc_kfthreshold = -1;
|
||||||
static int xvidenc_kfreduction = -1;
|
static int xvidenc_kfreduction = -1;
|
||||||
static int xvidenc_fixed_quant = 0;
|
static int xvidenc_fixed_quant = 0;
|
||||||
static int xvidenc_debug = 0;
|
static int xvidenc_debug = 0;
|
||||||
static int xvidenc_hintedme = 0;
|
|
||||||
static char* xvidenc_hintfile = "xvid_hint_me.dat";
|
|
||||||
#ifdef XVID_API_UNSTABLE
|
#ifdef XVID_API_UNSTABLE
|
||||||
|
static int xvidenc_lumi_mask = 0;
|
||||||
static int xvidenc_qpel = 0;
|
static int xvidenc_qpel = 0;
|
||||||
static int xvidenc_max_bframes = 0;
|
static int xvidenc_max_bframes = 0;
|
||||||
static int xvidenc_bquant_ratio = 125;
|
static int xvidenc_bquant_ratio = 150;
|
||||||
static int xvidenc_bquant_offset = 60;
|
static int xvidenc_bquant_offset = 100;
|
||||||
static int xvidenc_gmc = 0;
|
static int xvidenc_gmc = 0;
|
||||||
static int xvidenc_me_colour = 0;
|
static int xvidenc_me_colour = 0;
|
||||||
static int xvidenc_reduced = 0;
|
static int xvidenc_reduced = 0;
|
||||||
|
@ -114,16 +112,14 @@ struct config xvidencopts_conf[] = {
|
||||||
{ "max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, 0, 0, 0, NULL},
|
{ "max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, 0, 0, 0, NULL},
|
||||||
{ "mpeg_quant", &xvidenc_mpeg_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
{ "mpeg_quant", &xvidenc_mpeg_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{ "mod_quant", &xvidenc_mod_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
{ "mod_quant", &xvidenc_mod_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{ "lumi_mask", &xvidenc_lumi_mask, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
||||||
{ "keyframe_boost", &xvidenc_keyframe_boost, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL}, /* for XVID_MODE_2PASS_2 */
|
{ "keyframe_boost", &xvidenc_keyframe_boost, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL}, /* for XVID_MODE_2PASS_2 */
|
||||||
{ "kfthreshold", &xvidenc_kfthreshold, CONF_TYPE_INT, 0, 0, 0, NULL}, /* for XVID_MODE_2PASS_2 */
|
{ "kfthreshold", &xvidenc_kfthreshold, CONF_TYPE_INT, 0, 0, 0, NULL}, /* for XVID_MODE_2PASS_2 */
|
||||||
{ "kfreduction", &xvidenc_kfreduction, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, /* for XVID_MODE_2PASS_2 */
|
{ "kfreduction", &xvidenc_kfreduction, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, /* for XVID_MODE_2PASS_2 */
|
||||||
{ "fixed_quant", &xvidenc_fixed_quant, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, /* for XVID_MODE_FIXED_QUANT */
|
{ "fixed_quant", &xvidenc_fixed_quant, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, /* for XVID_MODE_FIXED_QUANT */
|
||||||
{ "debug", &xvidenc_debug, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
{ "debug", &xvidenc_debug, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{ "hintedme", &xvidenc_hintedme, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
||||||
{ "hintfile", &xvidenc_hintfile, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
|
||||||
#ifdef XVID_API_UNSTABLE
|
#ifdef XVID_API_UNSTABLE
|
||||||
{ "extrastatl", &xvidenc_xstat, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
//{ "lumi_mask", &xvidenc_lumi_mask, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
|
{ "extrastat", &xvidenc_xstat, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{ "qpel", &xvidenc_qpel, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
{ "qpel", &xvidenc_qpel, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{ "max_bframes", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
|
{ "max_bframes", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
|
||||||
{ "bquant_ratio", &xvidenc_bquant_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL},
|
{ "bquant_ratio", &xvidenc_bquant_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL},
|
||||||
|
@ -143,8 +139,6 @@ struct vf_priv_s {
|
||||||
XVID_ENC_FRAME enc_frame;
|
XVID_ENC_FRAME enc_frame;
|
||||||
void* enc_handle;
|
void* enc_handle;
|
||||||
vbr_control_t vbr_state;
|
vbr_control_t vbr_state;
|
||||||
FILE *hintfile;
|
|
||||||
void *hintstream;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -296,24 +290,6 @@ config(struct vf_instance_s* vf,
|
||||||
fp->enc_frame.quant_intra_matrix = 0;
|
fp->enc_frame.quant_intra_matrix = 0;
|
||||||
fp->enc_frame.quant_inter_matrix = 0;
|
fp->enc_frame.quant_inter_matrix = 0;
|
||||||
|
|
||||||
// hinted ME
|
|
||||||
fp->hintstream = NULL;
|
|
||||||
fp->hintfile = NULL;
|
|
||||||
if (xvidenc_hintedme && (xvidenc_pass == 1 || xvidenc_pass == 2)) {
|
|
||||||
fp->hintstream = malloc( 100000 ); // this is what the vfw code in XViD CVS allocates
|
|
||||||
if (fp->hintstream == NULL)
|
|
||||||
mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: cannot allocate memory for hinted ME\n");
|
|
||||||
else {
|
|
||||||
fp->hintfile = fopen(xvidenc_hintfile, xvidenc_pass == 1 ? "w" : "r");
|
|
||||||
if (fp->hintfile == NULL) {
|
|
||||||
mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: %s: %s\n", strerror(errno), xvidenc_hintfile);
|
|
||||||
free(fp->hintstream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fp->hintstream == NULL || fp->hintfile == NULL)
|
|
||||||
xvidenc_hintedme = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize VBR engine
|
// initialize VBR engine
|
||||||
// =====================
|
// =====================
|
||||||
vbrSetDefaults(&fp->vbr_state);
|
vbrSetDefaults(&fp->vbr_state);
|
||||||
|
@ -364,10 +340,6 @@ uninit(struct vf_instance_s* vf)
|
||||||
{
|
{
|
||||||
struct vf_priv_s *fp = vf->priv;
|
struct vf_priv_s *fp = vf->priv;
|
||||||
|
|
||||||
if (fp->hintfile)
|
|
||||||
fclose(fp->hintfile);
|
|
||||||
if (fp->hintstream)
|
|
||||||
free(fp->hintstream);
|
|
||||||
vbrFinish(&fp->vbr_state);
|
vbrFinish(&fp->vbr_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +386,6 @@ put_image(struct vf_instance_s* vf, mp_image_t *mpi)
|
||||||
fp->enc_frame.bquant = (xvidenc_fixed_quant * xvidenc_bquant_ratio + xvidenc_bquant_offset) / 100;
|
fp->enc_frame.bquant = (xvidenc_fixed_quant * xvidenc_bquant_ratio + xvidenc_bquant_offset) / 100;
|
||||||
} else
|
} else
|
||||||
// use the internal VBR engine since the external one isn't bframe aware
|
// use the internal VBR engine since the external one isn't bframe aware
|
||||||
// fp->enc_frame.quant = fp->enc_frame.intra = fp->enc_frame.bquant = -1;
|
|
||||||
fp->enc_frame.quant =0;
|
fp->enc_frame.quant =0;
|
||||||
fp->enc_frame.intra =-1;
|
fp->enc_frame.intra =-1;
|
||||||
fp->enc_frame.bquant = 0;
|
fp->enc_frame.bquant = 0;
|
||||||
|
@ -433,32 +404,6 @@ put_image(struct vf_instance_s* vf, mp_image_t *mpi)
|
||||||
fp->enc_frame.general &= (fp->enc_frame.quant < 4) ? ~XVID_H263QUANT : ~XVID_MPEGQUANT;
|
fp->enc_frame.general &= (fp->enc_frame.quant < 4) ? ~XVID_H263QUANT : ~XVID_MPEGQUANT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hinted ME, 1st part
|
|
||||||
if (xvidenc_hintedme && xvidenc_pass == 1) {
|
|
||||||
fp->enc_frame.hint.hintstream = fp->hintstream;
|
|
||||||
fp->enc_frame.hint.rawhints = 0;
|
|
||||||
fp->enc_frame.general |= XVID_HINTEDME_GET;
|
|
||||||
}
|
|
||||||
else if (xvidenc_hintedme && xvidenc_pass == 2) {
|
|
||||||
size_t read;
|
|
||||||
int blocksize;
|
|
||||||
fp->enc_frame.general &= ~XVID_HINTEDME_SET;
|
|
||||||
read = fread(&blocksize, sizeof(blocksize), 1, fp->hintfile);
|
|
||||||
if (read == 1) {
|
|
||||||
read = fread(fp->hintstream, (size_t)blocksize, 1, fp->hintfile);
|
|
||||||
if (read == 1) {
|
|
||||||
fp->enc_frame.hint.hintstream = fp->hintstream;
|
|
||||||
fp->enc_frame.hint.hintlength = 0;
|
|
||||||
fp->enc_frame.hint.rawhints = 0;
|
|
||||||
fp->enc_frame.general |= XVID_HINTEDME_SET;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
perror("xvid: hint file read block failure");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
perror("xvid: hint file read failure");
|
|
||||||
}
|
|
||||||
|
|
||||||
// encode frame
|
// encode frame
|
||||||
switch (xvid_encore(fp->enc_handle, XVID_ENC_ENCODE, &fp->enc_frame, &enc_stats)) {
|
switch (xvid_encore(fp->enc_handle, XVID_ENC_ENCODE, &fp->enc_frame, &enc_stats)) {
|
||||||
case XVID_ERR_OK:
|
case XVID_ERR_OK:
|
||||||
|
@ -481,17 +426,6 @@ put_image(struct vf_instance_s* vf, mp_image_t *mpi)
|
||||||
vbrUpdate(&fp->vbr_state, enc_stats.quant, fp->enc_frame.intra,
|
vbrUpdate(&fp->vbr_state, enc_stats.quant, fp->enc_frame.intra,
|
||||||
enc_stats.hlength, fp->enc_frame.length, enc_stats.kblks, enc_stats.mblks, enc_stats.ublks);
|
enc_stats.hlength, fp->enc_frame.length, enc_stats.kblks, enc_stats.mblks, enc_stats.ublks);
|
||||||
|
|
||||||
// hinted ME, 2nd part
|
|
||||||
if (fp->enc_frame.general & XVID_HINTEDME_GET) {
|
|
||||||
size_t wrote = fwrite(&fp->enc_frame.hint.hintlength, sizeof(fp->enc_frame.hint.hintlength), 1, fp->hintfile);
|
|
||||||
if (wrote == 1) {
|
|
||||||
wrote = fwrite(fp->enc_frame.hint.hintstream, fp->enc_frame.hint.hintlength, 1, fp->hintfile);
|
|
||||||
if (wrote != 1)
|
|
||||||
perror("xvid: hint write block failure");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
perror("xvid: hint write failure");
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue