Commit 4510c72e authored by Rafaël Carré's avatar Rafaël Carré Committed by Jean-Paul Saman

davinci decoder : clean up debug messages

Autodetect codec to use based on the fourcc - remove useless options
Hardcode the engine to use: "decode" for decoder, "encode" for encoder
Signed-off-by: Jean-Paul Saman's avatarJean-Paul Saman <jean-paul.saman@m2x.nl>
parent ac4b4c89
......@@ -168,10 +168,6 @@ int OpenAudioDecoder( vlc_object_t *p_this )
p_dec->fmt_out.audio.i_format = AOUT_FMT_S16_NE;
p_dec->fmt_out.audio.i_bitspersample = 16;
#ifdef DEBUG_DAVINCI
msg_Info( p_dec, "Wooooohooo!" );
#endif
free( psz_codec );
free( psz_engine );
return VLC_SUCCESS;
......@@ -226,10 +222,6 @@ static aout_buffer_t *DecodeAudioBlock( decoder_t *p_dec, block_t **pp_block )
if( !pp_block || !*pp_block ) return NULL;
p_block = *pp_block;
#ifdef DEBUG_DAVINCI
msg_Err( p_dec, "DecodeAudioBlock starts now!" );
#endif
if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
{
block_Release( p_block );
......@@ -306,12 +298,7 @@ static aout_buffer_t *DecodeAudioBlock( decoder_t *p_dec, block_t **pp_block )
/* Setup input buffer */
int i_used = in_args.numBytes - p_sys->i_buffer;
#ifdef DEBUG_DAVINCI
if( p_sys->i_buffer + p_block->i_buffer > p_sys->in.bufSizes[0] )
msg_Dbg( p_dec, "Woah! Not enough room to store the whole block" );
msg_Dbg( p_dec, "Sending %d bytes", (int)in_args.numBytes );
msg_Dbg( p_dec, "Used %d bytes from new block", i_used );
#endif
assert( p_sys->i_buffer + p_block->i_buffer <= p_sys->in.bufSizes[0] );
if( i_used > 0 )
{
......@@ -328,9 +315,7 @@ static aout_buffer_t *DecodeAudioBlock( decoder_t *p_dec, block_t **pp_block )
if( in_args.numBytes < p_sys->in.bufSizes[0] )
{
#ifdef DEBUG_DAVINCI
msg_Err( p_dec, "Waiting for more data" );
#endif
msg_Dbg( p_dec, "Waiting for more data" );
block_Release( p_block );
p_sys->i_buffer = in_args.numBytes;
return NULL;
......@@ -352,7 +337,7 @@ static aout_buffer_t *DecodeAudioBlock( decoder_t *p_dec, block_t **pp_block )
}
else
{
msg_Warn( p_dec, "Rejecting frame" );
msg_Err( p_dec, "Rejecting frame" );
b_reject = VLC_TRUE;
}
}
......@@ -459,14 +444,9 @@ static aout_buffer_t *DecodeAudioBlock( decoder_t *p_dec, block_t **pp_block )
*pp_block = NULL;
}*/
#ifdef DEBUG_DAVINCI
msg_Info( p_dec, "Audio samples incoming ... get ready!" );
#endif
return p_out;
error:
msg_Err( p_dec, "suxxors" );
if( p_out && p_out->pf_release )
p_out->pf_release( p_out );
block_Release( p_block );
......
......@@ -29,57 +29,16 @@
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define VIDDEC_ENGINE_TEXT N_( "Video decoder engine" )
#define VIDDEC_ENGINE_LONGTEXT N_( \
"Name of the decoder engine used to decode video" )
#define VIDDEC_CODEC_TEXT N_( "Video decoder name" )
#define VIDDEC_CODEC_LONGTEXT N_( \
"Force usage of a specific video decoder in engine. " \
"Leave empty to autodetect." )
#define VIDDEC_FOURCC_TEXT N_( "Match against FOURCC" )
#define VIDDEC_FOURCC_LONGTEXT N_( \
"Use davinci video decoder module for this FOURCC. Option should be " \
"set when viddec-codec is used." )
#define VIDDEC_CHROMA_TEXT N_( "Decoder output chroma" )
#define VIDDEC_CHROMA_LONGTEXT N_( \
"Force video decoder to output in specific chroma" )
#define AUDDEC_ENGINE_TEXT N_( "Audio decoder engine" )
#define AUDDEC_ENGINE_LONGTEXT N_( \
"Name of the decoder engine used to decode audio" )
#define AUDDEC_CODEC_TEXT N_( "Audio decoder name" )
#define AUDDEC_CODEC_LONGTEXT N_( \
"Force usage of a specific audio decoder in engine. " \
"Leave empty to autodetect." )
#define AUDDEC_FOURCC_TEXT N_( "Match against FOURCC" )
#define AUDDEC_FOURCC_LONGTEXT N_( \
"Use davinci audio decoder module for this FOURCC. Option should be " \
"set when auddec-codec is used." )
#define VIDENC_ENGINE_TEXT N_( "Video encoder engine" )
#define VIDENC_ENGINE_LONGTEXT N_( \
"Name of the encoder engine used to encode video" )
#define VIDENC_CODEC_TEXT N_( "Video encoder name" )
#define VIDENC_CODEC_LONGTEXT N_( \
"Force usage of a specific video encoder in engine. " \
"Leave empty to autodetect." )
#define VIDENC_FOURCC_TEXT N_( "Match against FOURCC" )
#define VIDENC_FOURCC_LONGTEXT N_( \
"Use davinci video encoder module for this FOURCC. Option should be " \
"set when videnc-codec is used." )
vlc_module_begin();
set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_VCODEC );
set_description( _("DaVinci DSP video decoder") );
set_capability( "decoder", 1337 );
set_callbacks( OpenVideoDecoder, CloseVideoDecoder );
add_string( "davinci-viddec-engine", "decode", NULL,
VIDDEC_ENGINE_TEXT, VIDDEC_ENGINE_LONGTEXT, VLC_TRUE );
add_string( "davinci-viddec-codec", "", NULL,
VIDDEC_CODEC_TEXT, VIDDEC_CODEC_LONGTEXT, VLC_TRUE );
add_string( "davinci-viddec-fourcc", "", NULL,
VIDDEC_FOURCC_TEXT, VIDDEC_FOURCC_LONGTEXT, VLC_TRUE );
add_string( "davinci-viddec-chroma", "", NULL,
VIDDEC_CHROMA_TEXT, VIDDEC_CHROMA_LONGTEXT, VLC_TRUE );
......@@ -87,23 +46,11 @@ vlc_module_begin();
set_description( _("DaVinci DSP audio decoder") );
set_capability( "decoder", 1337 );
set_callbacks( OpenAudioDecoder, CloseAudioDecoder );
add_string( "davinci-auddec-engine", "decode", NULL,
AUDDEC_ENGINE_TEXT, AUDDEC_ENGINE_LONGTEXT, VLC_TRUE );
add_string( "davinci-auddec-codec", "", NULL,
AUDDEC_CODEC_TEXT, AUDDEC_CODEC_LONGTEXT, VLC_TRUE );
add_string( "davinci-auddec-fourcc", "", NULL,
AUDDEC_FOURCC_TEXT, AUDDEC_FOURCC_LONGTEXT, VLC_TRUE );
add_submodule();
set_description( _("DaVinci DSP video encoder" ) );
set_capability( "encoder", 1337 );
set_callbacks( OpenVideoEncoder, CloseVideoEncoder );
add_string( "davinci-videnc-engine", "encode", NULL,
VIDENC_ENGINE_TEXT, VIDENC_ENGINE_LONGTEXT, VLC_TRUE );
add_string( "davinci-videnc-codec", "", NULL,
VIDENC_CODEC_TEXT, VIDENC_CODEC_LONGTEXT, VLC_TRUE );
add_string( "davinci-videnc-fourcc", "", NULL,
VIDENC_FOURCC_TEXT, VIDENC_FOURCC_LONGTEXT, VLC_TRUE );
vlc_module_end();
......@@ -117,9 +64,6 @@ int __AllocateBuffer( vlc_object_t *p_this, XDAS_Int32 i_num,
{
int i;
#ifdef DEBUG_DAVINCI
msg_Info( p_this, "Allocating buffers:" );
#endif
buf->numBufs = i_num;
buf->bufs = (XDAS_Int8 **)malloc( buf->numBufs * sizeof( XDAS_Int8 * ) );
......@@ -139,9 +83,6 @@ int __AllocateBuffer( vlc_object_t *p_this, XDAS_Int32 i_num,
for( i = 0; i < i_num; i++ )
{
#ifdef DEBUG_DAVINCI
msg_Info( p_this, "\t%d: size %d Bytes", i, (int)pi_sizes[i] );
#endif
buf->bufSizes[i] = pi_sizes[i];
buf->bufs[i] = Memory_contigAlloc( pi_sizes[i], Memory_DEFAULTALIGNMENT );
if( !buf->bufs[i] )
......
......@@ -54,53 +54,30 @@ int OpenVideoDecoder( vlc_object_t *p_this )
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
Engine_Error err;
char *psz_codec = NULL;
char *psz_engine = NULL;
char *psz_chroma = NULL;
char *psz_codec = NULL;
vlc_fourcc_t i_chroma = VLC_FOURCC('U','Y','V','Y');
VIDDEC_Params params;
psz_codec = config_GetPsz( p_this, "davinci-viddec-codec" );
if( psz_codec && !*psz_codec )
{
free( psz_codec );
psz_codec = NULL;
}
if( psz_codec )
switch( p_dec->fmt_in.i_codec )
{
char *psz_fourcc = config_GetPsz( p_this, "davinci-viddec-fourcc" );
if( strlen( psz_fourcc ) != 4 || p_dec->fmt_in.i_codec !=
VLC_FOURCC(psz_fourcc[0],psz_fourcc[1],psz_fourcc[2],psz_fourcc[3]))
{
free( psz_codec );
free( psz_fourcc );
return VLC_EGENERIC;
}
free( psz_fourcc );
msg_Dbg( p_this, "Forcing use of video decoder `%s'", psz_codec );
}
else
{
switch( p_dec->fmt_in.i_codec )
{
#if 0
CASE_MPEG1
psz_codec = strdup( "mpegdec" ); /* FIXME */
break;
CASE_MPEG1
psz_codec = strdup( "mpegdec" ); /* FIXME */
break;
#endif
CASE_MPEG2
psz_codec = strdup( "mpeg2dec" );
break;
CASE_MPEG2
psz_codec = strdup( "mpeg2dec" );
break;
CASE_MPEG4
psz_codec = strdup( "mpeg4dec" );
break;
CASE_MPEG4
psz_codec = strdup( "mpeg4dec" );
break;
CASE_H264
psz_codec = strdup( "h264dec" );
break;
CASE_H264
psz_codec = strdup( "h264dec" );
break;
#if 0
CASE_VC1
......@@ -108,9 +85,8 @@ int OpenVideoDecoder( vlc_object_t *p_this )
break;
#endif
default:
return VLC_EGENERIC;
}
default:
return VLC_EGENERIC;
}
/* Allocate our private structure */
......@@ -124,16 +100,16 @@ int OpenVideoDecoder( vlc_object_t *p_this )
CERuntime_init();
/* Create an engine handle */
psz_engine = config_GetPsz( p_dec, "davinci-viddec-engine" );
p_sys->e = Engine_open( psz_engine, NULL /*&Engine_ATTRS*/, &err );
#define ti_engine "decode"
p_sys->e = Engine_open( ti_engine, NULL /*&Engine_ATTRS*/, &err );
if( err != Engine_EOK )
{
msg_Err( p_dec, "Error while opening engine `%s': %s",
psz_engine, ppsz_engine_error[err] );
ti_engine, ppsz_engine_error[err] );
goto error;
}
PrintAvailableAlgorithms( p_this, psz_engine );
PrintAvailableAlgorithms( p_this, ti_engine );
/* Get user supplied chroma setting */
psz_chroma = config_GetPsz( p_dec, "davinci-viddec-chroma" );
......@@ -179,14 +155,12 @@ int OpenVideoDecoder( vlc_object_t *p_this )
p_dec->pf_decode_video = DecodeVideoBlock;
free( psz_codec );
free( psz_engine );
return VLC_SUCCESS;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys );
free( psz_codec );
free( psz_engine );
return VLC_EGENERIC;
}
......
......@@ -54,61 +54,37 @@ int OpenVideoEncoder( vlc_object_t *p_this )
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
char *psz_codec = NULL;
char *psz_engine = NULL;
Engine_Error err;
VIDENC_Params params;
psz_codec = config_GetPsz( p_this, "davinci-videnc-codec" );
if( psz_codec && !*psz_codec )
switch( p_enc->fmt_out.i_codec )
{
free( psz_codec );
psz_codec = NULL;
}
if( psz_codec )
{
char *psz_fourcc = config_GetPsz( p_this, "davinci-videnc-fourcc" );
if( strlen( psz_fourcc ) != 4 || p_enc->fmt_out.i_codec !=
VLC_FOURCC(psz_fourcc[0],psz_fourcc[1],psz_fourcc[2],psz_fourcc[3]))
{
free( psz_codec );
free( psz_fourcc );
return VLC_EGENERIC;
}
free( psz_fourcc );
msg_Dbg( p_this, "Forcing use of video encoder `%s'", psz_codec );
}
else
{
switch( p_enc->fmt_out.i_codec )
{
#if 0
CASE_MPEG1
psz_codec = strdup( "mpegenc" ); /* FIXME */
break;
CASE_MPEG1
psz_codec = strdup( "mpegenc" ); /* FIXME */
break;
CASE_MPEG2
psz_codec = strdup( "mpeg2enc" ); /* FIXME */
break;
CASE_MPEG2
psz_codec = strdup( "mpeg2enc" ); /* FIXME */
break;
#endif
CASE_MPEG4
psz_codec = strdup( "mpeg4enc" );
break;
CASE_MPEG4
psz_codec = strdup( "mpeg4enc" );
break;
CASE_H264
psz_codec = strdup( "h264enc" );
break;
CASE_H264
psz_codec = strdup( "h264enc" );
break;
#if 0
CASE_VC1
psz_codec = strdup( "vc1enc" ); /* FIXME */
break;
CASE_VC1
psz_codec = strdup( "vc1enc" ); /* FIXME */
break;
#endif
default:
return VLC_EGENERIC;
}
default:
return VLC_EGENERIC;
}
/* Allocate our private structure */
......@@ -122,16 +98,16 @@ int OpenVideoEncoder( vlc_object_t *p_this )
CERuntime_init();
/* Create an engine handle */
psz_engine = config_GetPsz( p_enc, "davinci-videnc-engine" );
p_sys->e = Engine_open( psz_engine, NULL /*&Engine_ATTRS*/, &err );
#define ti_engine "encode"
p_sys->e = Engine_open( ti_engine, NULL /*&Engine_ATTRS*/, &err );
if( err != Engine_EOK )
{
msg_Err( p_enc, "Error while opening engine `%s': %s",
psz_engine, ppsz_engine_error[err] );
ti_engine, ppsz_engine_error[err] );
goto error;
}
PrintAvailableAlgorithms( p_this, psz_engine );
PrintAvailableAlgorithms( p_this, ti_engine );
/* Configure encoder */
params.size = sizeof( params );
......@@ -145,18 +121,23 @@ int OpenVideoEncoder( vlc_object_t *p_this )
25000; /* Frames per 1000 seconds */
params.maxBitRate = p_enc->fmt_out.i_bitrate
+ p_enc->i_tolerance; /* Bits per second. FIXME? */
params.maxBitRate *= 10;
params.dataEndianness = XDM_BYTE;
params.maxInterFrameInterval = p_enc->i_iframes; /* FIXME? */
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",
(int)params.maxHeight, (int)params.maxWidth,
((float)params.maxFrameRate)/1000.,
((int)params.maxBitRate) / (8*1024),
(int)params.maxInterFrameInterval
);
if( params.inputChromaFormat == XDM_CHROMA_NA )
{
msg_Err( p_enc, "Unsupported input chroma (%4.4s). Forcing I420. This error message is ok if you're in the 'encoder probe' part of transcode. It isn't ok if you still get it on the 2nd module init.",
msg_Warn( p_enc, "Unsupported input chroma (%4.4s), forcing I420.",
(const char *)&p_enc->fmt_in.i_codec );
params.inputChromaFormat = VlcChromaToXdm( VLC_FOURCC('I','4','2','0' ) );
/* goto error; */
}
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) */
/* Create encoder handle */
p_sys->c = VIDENC_create( p_sys->e, (String)psz_codec, &params );
if( !p_sys->c )
......@@ -168,18 +149,13 @@ int OpenVideoEncoder( vlc_object_t *p_this )
/* Initialize random stuff */
p_enc->pf_encode_video = EncodeVideo;
/* Holy bananas! We made it! */
msg_Info( p_enc, "Woohoooooooo!" );
free( psz_codec );
free( psz_engine );
return VLC_SUCCESS;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys );
free( psz_codec );
free( psz_engine );
return VLC_EGENERIC;
}
......@@ -301,7 +277,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
}
/* Print some info */
msg_Info( p_enc, "Bytes generated: %d", (int)out_args.bytesGenerated );
msg_Dbg( p_enc, "Bytes generated: %d", (int)out_args.bytesGenerated );
/* Put everything in the block */
if( out_args.bytesGenerated <= 0 )
......
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