mirror of https://github.com/mpv-player/mpv
#ifdef'ed divx4 2pass code - idea by Diego
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6674 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
66d8a40c4b
commit
6e7e73bc90
|
@ -20,10 +20,12 @@
|
||||||
#include "mp_image.h"
|
#include "mp_image.h"
|
||||||
#include "vf.h"
|
#include "vf.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_DIVX4ENCORE
|
||||||
#include "divx4_vbr.h"
|
#include "divx4_vbr.h"
|
||||||
|
extern char* passtmpfile;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int pass;
|
extern int pass;
|
||||||
extern char* passtmpfile;
|
|
||||||
|
|
||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
|
|
||||||
|
@ -185,10 +187,14 @@ static int config(struct vf_instance_s* vf,
|
||||||
|
|
||||||
|
|
||||||
/* lavc internal 2pass bitrate control */
|
/* lavc internal 2pass bitrate control */
|
||||||
if(lavc_param_vpass==1)
|
#ifdef HAVE_DIVX4ENCORE
|
||||||
lavc_venc_context.flags|= CODEC_FLAG_PASS1;
|
switch(lavc_param_vpass){
|
||||||
else if(lavc_param_vpass==2)
|
#else
|
||||||
lavc_venc_context.flags|= CODEC_FLAG_PASS2;
|
switch(lavc_param_vpass?lavc_param_vpass:pass){
|
||||||
|
#endif
|
||||||
|
case 1: lavc_venc_context.flags|= CODEC_FLAG_PASS1; break;
|
||||||
|
case 2: lavc_venc_context.flags|= CODEC_FLAG_PASS2; break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ME_ZERO
|
#ifdef ME_ZERO
|
||||||
// workaround Juanjo's stupid incompatible change:
|
// workaround Juanjo's stupid incompatible change:
|
||||||
|
@ -205,6 +211,7 @@ static int config(struct vf_instance_s* vf,
|
||||||
lavc_venc_context.quality = lavc_param_vqscale;
|
lavc_venc_context.quality = lavc_param_vqscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DIVX4ENCORE
|
||||||
switch(pass){
|
switch(pass){
|
||||||
case 1:
|
case 1:
|
||||||
if (VbrControl_init_2pass_vbr_analysis(passtmpfile, 5) == -1){
|
if (VbrControl_init_2pass_vbr_analysis(passtmpfile, 5) == -1){
|
||||||
|
@ -224,6 +231,7 @@ static int config(struct vf_instance_s* vf,
|
||||||
lavc_venc_context.flags|=CODEC_FLAG_QSCALE|CODEC_FLAG_TYPE; // VBR
|
lavc_venc_context.flags|=CODEC_FLAG_QSCALE|CODEC_FLAG_TYPE; // VBR
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) {
|
if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) {
|
||||||
mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
|
mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
|
||||||
|
@ -264,6 +272,7 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||||
lavc_venc_picture.linesize[1]=mpi->stride[1];
|
lavc_venc_picture.linesize[1]=mpi->stride[1];
|
||||||
lavc_venc_picture.linesize[2]=mpi->stride[2];
|
lavc_venc_picture.linesize[2]=mpi->stride[2];
|
||||||
|
|
||||||
|
#ifdef HAVE_DIVX4ENCORE
|
||||||
if(pass==2){ // handle 2-pass:
|
if(pass==2){ // handle 2-pass:
|
||||||
lavc_venc_context.flags|=CODEC_FLAG_QSCALE; // enable VBR
|
lavc_venc_context.flags|=CODEC_FLAG_QSCALE; // enable VBR
|
||||||
lavc_venc_context.quality=VbrControl_get_quant();
|
lavc_venc_context.quality=VbrControl_get_quant();
|
||||||
|
@ -274,17 +283,19 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||||
VbrControl_update_2pass_vbr_encoding(lavc_venc_context.mv_bits,
|
VbrControl_update_2pass_vbr_encoding(lavc_venc_context.mv_bits,
|
||||||
lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits,
|
lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits,
|
||||||
8*out_size);
|
8*out_size);
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
out_size = avcodec_encode_video(&lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
|
out_size = avcodec_encode_video(&lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
|
||||||
&lavc_venc_picture);
|
&lavc_venc_picture);
|
||||||
|
#ifdef HAVE_DIVX4ENCORE
|
||||||
if(pass==1){
|
if(pass==1){
|
||||||
VbrControl_update_2pass_vbr_analysis(lavc_venc_context.key_frame,
|
VbrControl_update_2pass_vbr_analysis(lavc_venc_context.key_frame,
|
||||||
lavc_venc_context.mv_bits,
|
lavc_venc_context.mv_bits,
|
||||||
lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits,
|
lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits,
|
||||||
8*out_size, lavc_venc_context.quality);
|
8*out_size, lavc_venc_context.quality);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
mencoder_write_chunk(mux_v,out_size,lavc_venc_context.key_frame?0x10:0);
|
mencoder_write_chunk(mux_v,out_size,lavc_venc_context.key_frame?0x10:0);
|
||||||
|
@ -369,7 +380,7 @@ static int vf_open(vf_instance_t *vf, char* args){
|
||||||
vf_info_t ve_info_lavc = {
|
vf_info_t ve_info_lavc = {
|
||||||
"libavcodec encoder",
|
"libavcodec encoder",
|
||||||
"lavc",
|
"lavc",
|
||||||
"A'rpi and Alex",
|
"A'rpi, Alex, Michael",
|
||||||
"for internal use by mencoder",
|
"for internal use by mencoder",
|
||||||
vf_open
|
vf_open
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue