Commit 15e440e9 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Paul Saman

davinci: add encoder settings.

Signed-off-by: Jean-Paul Saman's avatarJean-Paul Saman <jean-paul.saman@m2x.nl>
parent 6e476135
......@@ -29,34 +29,79 @@
/*****************************************************************************
* Module descriptor
*****************************************************************************/
/*
* Decoder
*/
#define VIDDEC_CHROMA_TEXT N_( "Decoder output chroma" )
#define VIDDEC_CHROMA_LONGTEXT N_( \
"Force video decoder to output in specific chroma" )
#define VIDDEC_FULLSCREEN_TEXT N_( "Resize video to fullscreen" )
/*
* Encoder
*/
#define ENC_KEYINT_TEXT N_( "Ratio of key frames" )
#define ENC_KEYINT_LONGTEXT N_( "Number of frames " \
"that will be coded for one key frame." )
#define ENC_INTERLACE_TEXT N_( "Interlaced encoding" )
#define ENC_INTERLACE_LONGTEXT N_( "Enable dedicated " \
"algorithms for interlaced frames." )
#define ENC_RC_TEXT N_( "Rate control Preset method (default: 0)" )
#define ENC_RC_LONGTEXT N_( "Rate control Preset method " \
"ranges from 1..5 (1=cbr, 2=storage, 3=twopass, 4=none, 5=userdefined)")
#define ENC_VT_TEXT N_( "Bitrate tolerance" )
#define ENC_VT_LONGTEXT N_( "Bitrate tolerance in kbit/s." )
#define ENC_QUALITY_TEXT N_("Encoder quality setting (default: 0)" )
#define ENC_QUALITY_LONGTEXT N_( "Encoder qualtiy setting preset. " \
"ranges from 0..3 (0=encoders default, 1=high quality, 2=speed, 3=user defined" )
vlc_module_begin();
/* video decoder */
set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_VCODEC );
set_description( _("DaVinci DSP video decoder") );
set_capability( "decoder", 1337 );
set_callbacks( OpenVideoDecoder, CloseVideoDecoder );
#ifdef DAVINCI_HACK
add_bool( "davinci-viddec-fullscreen", VLC_TRUE, NULL,
add_bool( DEC_CFG_PREFIX "fullscreen", VLC_TRUE, NULL,
VIDDEC_FULLSCREEN_TEXT, VIDDEC_FULLSCREEN_TEXT, VLC_FALSE );
#endif
add_string( "davinci-viddec-chroma", "", NULL,
add_string( DEC_CFG_PREFIX "chroma", "", NULL,
VIDDEC_CHROMA_TEXT, VIDDEC_CHROMA_LONGTEXT, VLC_TRUE );
/* audio decoder */
add_submodule();
set_description( _("DaVinci DSP audio decoder") );
set_capability( "decoder", 0 );
set_callbacks( OpenAudioDecoder, CloseAudioDecoder );
/* video encoder */
add_submodule();
set_description( _("DaVinci DSP video encoder" ) );
set_capability( "encoder", 1337 );
set_callbacks( OpenVideoEncoder, CloseVideoEncoder );
add_integer( ENC_CFG_PREFIX "keyint", 0, NULL, ENC_KEYINT_TEXT,
ENC_KEYINT_LONGTEXT, VLC_FALSE );
add_bool( ENC_CFG_PREFIX "interlace", VLC_FALSE, NULL, ENC_INTERLACE_TEXT,
ENC_INTERLACE_LONGTEXT, VLC_TRUE );
add_integer( ENC_CFG_PREFIX "rc", 1, NULL, ENC_RC_TEXT,
ENC_RC_LONGTEXT, VLC_TRUE );
change_integer_range( 0, 5 );
add_integer( ENC_CFG_PREFIX "tolerance", 0, NULL, ENC_VT_TEXT,
ENC_VT_LONGTEXT, VLC_TRUE );
add_integer( ENC_CFG_PREFIX "quality", 0, NULL, ENC_QUALITY_TEXT,
ENC_QUALITY_LONGTEXT, VLC_TRUE );
change_integer_range( 0, 3 );
vlc_module_end();
......
......@@ -39,6 +39,9 @@
#define DAVINCI_HACK /* directly resize and output the decoded video */
#define TI_ENGINE "encodedecode"
#define ENC_CFG_PREFIX "davinci-videnc-"
#define DEC_CFG_PREFIX "davinci-viddec-"
int OpenVideoDecoder( vlc_object_t * );
void CloseVideoDecoder( vlc_object_t * );
......
......@@ -147,6 +147,11 @@ int OpenVideoEncoder( vlc_object_t *p_this )
p_sys = p_enc->p_sys;
memset( p_sys, 0, sizeof( encoder_sys_t ) );
/* FIXME: number of frames between 2 keyframes */
p_enc->i_iframes = var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "keyint" );
p_enc->i_tolerance = var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "tolerance" );
p_enc->i_tolerance *= 1024; /* bits per second */
/* Initialize the codec engine */
CERuntime_init();
......@@ -163,21 +168,40 @@ int OpenVideoEncoder( vlc_object_t *p_this )
/* Configure encoder */
params.size = sizeof( params );
params.encodingPreset = 0; /* Use default */
params.rateControlPreset = 0; /* Use default */
switch( var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "quality" ) )
{
case 1: params.encodingPreset = XDM_HIGH_QUALITY; break;
case 2: params.encodingPreset = XDM_HIGH_SPEED; break;
case 3: params.encodingPreset = XDM_USER_DEFINED; break;
default:
params.encodingPreset = XDM_DEFAULT;
break;
}
switch( var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "rc" ) )
{
case 1: params.rateControlPreset = IVIDEO_LOW_DELAY; break;
case 2: params.rateControlPreset = IVIDEO_STORAGE; break;
case 3: params.rateControlPreset = IVIDEO_TWOPASS; break;
case 4: params.rateControlPreset = IVIDEO_NONE; break;
case 5: params.rateControlPreset = IVIDEO_USER_DEFINED; break;
default:
params.rateControlPreset = IVIDEO_RATECONTROLPRESET_DEFAULT;
break;
}
params.maxHeight = p_enc->fmt_in.video.i_height;
params.maxWidth = p_enc->fmt_in.video.i_width;
params.maxFrameRate = p_enc->fmt_out.video.i_frame_rate_base ?
p_enc->fmt_out.video.i_frame_rate * 1000 /
p_enc->fmt_out.video.i_frame_rate_base :
25000; /* Frames per 1000 seconds */
50000; /* Frames per 1000 seconds */
params.maxBitRate = p_enc->fmt_out.i_bitrate
+ p_enc->i_tolerance; /* Bits per second. FIXME? */
params.maxBitRate *= 10;
+ p_enc->i_tolerance;
//params.maxBitRate *= 10;
params.dataEndianness = XDM_BYTE;
params.maxInterFrameInterval = p_enc->i_iframes; /* FIXME? */
params.maxInterFrameInterval = 0; //p_enc->i_iframes;
params.inputChromaFormat = VlcChromaToXdm( p_enc->fmt_in.i_codec );
msg_Dbg( p_enc, "%dx%d at %.3f fps (max bitrate %d kBps, I-Frame interval %d)\n",
msg_Info( p_enc, "max %dx%d at %.3f fps (max bitrate %d kBps, I-Frame interval %d)\n",
(int)params.maxWidth, (int)params.maxHeight,
((float)params.maxFrameRate)/1000.,
((int)params.maxBitRate) / (8*1024),
......@@ -189,7 +213,15 @@ int OpenVideoEncoder( vlc_object_t *p_this )
(const char *)&p_enc->fmt_in.i_codec );
params.inputChromaFormat = VlcChromaToXdm( VLC_FOURCC('I','4','2','0' ) );
}
params.inputContentType = IVIDEO_PROGRESSIVE; /* FIXME: we don't know if it's progressive or interlaced until we get the first picture (p_pic->b_progressive) */
/* FIXME: we don't know if it's progressive or interlaced
* until we get the first picture (p_pic->b_progressive).
* Thus let a knowledgeable user override this setting. */
if( var_CreateGetBool( p_enc, ENC_CFG_PREFIX "interlace" ) == VLC_TRUE )
params.inputContentType = IVIDEO_INTERLACED;
else
params.inputContentType = IVIDEO_PROGRESSIVE;
/* Create encoder handle */
p_sys->c = VIDENC_create( p_sys->e, (String)psz_codec, &params );
if( !p_sys->c )
......@@ -262,7 +294,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
dparams.refFrameRate = p_enc->fmt_out.video.i_frame_rate_base ?
p_enc->fmt_out.video.i_frame_rate * 1000 /
p_enc->fmt_out.video.i_frame_rate_base :
30; /* Frames per 1000 seconds */
25000; /* Frames per 1000 seconds */
dparams.targetFrameRate = dparams.refFrameRate; /* input fps = output fps */
dparams.targetBitRate = p_enc->fmt_out.i_bitrate;
dparams.intraFrameInterval = p_enc->i_iframes;
......@@ -281,6 +313,11 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
(int)dparams.intraFrameInterval );
goto error;
}
msg_Info( p_enc, "using %dx%d at %.3f fps (bitrate %d kBps, I-Frame interval %d)\n",
(int)dparams.inputWidth, (int)dparams.inputHeight,
((float)dparams.targetFrameRate)/1000.,
((int)dparams.targetBitRate) / (8*1024),
(int)dparams.intraFrameInterval );
/* Configure buffers */
if( VIDENC_control( p_sys->c, XDM_GETBUFINFO, &dparams, &status )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment