Commit a8c5af18 authored by Jean-Paul Saman's avatar Jean-Paul Saman

davinci: separate XDM 0.9 and XDM 1.0 code

- encoder.c: separate XDM 0.9 and XDM 1.0 code into separate files
- fourcc.c : indicate which XDM API to use for this codec
parent a688d669
...@@ -6,20 +6,27 @@ SOURCES_davinci = \ ...@@ -6,20 +6,27 @@ SOURCES_davinci = \
fourcc.c \ fourcc.c \
$(NULL) $(NULL)
# Davinci speed hack # Davinci resizer/scaling hack
# resizer.c \ # resizer.c \
# reziser.h # reziser.h
if ENABLE_SOUT if ENABLE_SOUT
SOURCES_davinci += encoder.c SOURCES_davinci += encoder.c audio_encoder.c video_encoder.c audio1_encoder.c
# video1_encoder.c
endif endif
EXTRA_libdavinci_plugin_la_SOURCES = \ EXTRA_libdavinci_plugin_la_SOURCES = \
encoder.c \ encoder.c \
audio_encoder.c \
video_encoder.c \
audio1_encoder.c \
$(NULL) $(NULL)
# video1_encoder.c
libvlc_LTLIBRARIES += \ libvlc_LTLIBRARIES += \
$(LTLIBdavinci) $(LTLIBdavinci)
EXTRA_LTLIBRARIES += \ EXTRA_LTLIBRARIES += \
libdavinci_plugin.la libdavinci_plugin.la
\ No newline at end of file
...@@ -87,11 +87,11 @@ int OpenAudioDecoder( vlc_object_t *p_this ) ...@@ -87,11 +87,11 @@ int OpenAudioDecoder( vlc_object_t *p_this )
decoder_sys_t *p_sys; decoder_sys_t *p_sys;
Engine_Error err; Engine_Error err;
AUDDEC_Params params; AUDDEC_Params params;
int i_cat; int i_cat, i_xdm;
const char *psz_codec; const char *psz_codec;
const char *psz_namecodec; const char *psz_namecodec;
if( !GetDavinciDecoder( p_dec->fmt_in.i_codec, &i_cat, if( !GetDavinciDecoder( p_dec->fmt_in.i_codec, &i_cat, &i_xdm,
&psz_codec, &psz_namecodec ) ) &psz_codec, &psz_namecodec ) )
{ {
msg_Dbg( p_dec, "Unsupported codec : %4.4s",(char*)&p_dec->fmt_in.i_codec ); msg_Dbg( p_dec, "Unsupported codec : %4.4s",(char*)&p_dec->fmt_in.i_codec );
......
/*****************************************************************************
* encoder.c: video encoder module using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2010 M2X BV
* $Id$
*
* Authors: Jean-Paul Saman <jean-paul.saman at m2x dot nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_vout.h>
#include <vlc_aout.h>
#include <vlc_sout.h>
#include <vlc_codec.h>
#include "davinci.h"
/* XDM 1.0 */
#include <ti/sdo/ce/audio1/audenc1.h>
#include <assert.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
/* XDM 1.0 */
static block_t *EncodeAudio1( encoder_t *, aout_buffer_t * );
static inline IAUDIO_ChannelMode davinci_get_audio_channels( int i_channels );
/*****************************************************************************
* Encoder
*****************************************************************************/
struct xdm_sys_t
{
/* XDM 1.0 */
AUDENC1_Handle handle;
AUDENC1_Params params;
AUDENC1_DynamicParams dparams;
XDM1_BufDesc in;
XDM1_BufDesc out;
};
/*****************************************************************************
*
*****************************************************************************/
int OpenEncoderAudio1( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm;
p_sys->xdm = (xdm_sys_t *) calloc( 1, sizeof( xdm_sys_t ) );
if( !p_sys->xdm )
return VLC_ENOMEM;
xdm = p_sys->xdm;
xdm->params.size = sizeof( xdm->params );
p_enc->i_tolerance = var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "tolerance" );
p_enc->i_tolerance *= 1024; /* bits per second */
xdm->params.encMode = var_CreateGetBool( p_enc, ENC_CFG_PREFIX "cbr" ) ? IAUDIO_CBR : IAUDIO_VBR;
xdm->params.bitRate = p_enc->fmt_out.i_bitrate;
if( xdm->params.encMode == IAUDIO_VBR )
xdm->params.maxBitRate = p_enc->fmt_out.i_bitrate + p_enc->i_tolerance;
else
xdm->params.maxBitRate = p_enc->fmt_out.i_bitrate;
xdm->params.sampleRate = p_enc->fmt_out.audio.i_rate;
xdm->params.channelMode = davinci_get_audio_channels( p_enc->fmt_out.audio.i_channels );
if( xdm->params.channelMode == IAUDIO_11_0 )
xdm->params.dualMonoMode = IAUDIO_DUALMONO_LR;
xdm->params.dataEndianness = XDM_LE_16;
xdm->params.inputFormat = IAUDIO_INTERLEAVED; // IAUDIO_BLOCK
xdm->params.inputBitsPerSample = p_enc->fmt_out.audio.i_bitspersample;
xdm->params.crcFlag = XDAS_FALSE;
xdm->params.ancFlag = XDAS_FALSE;
xdm->params.lfeFlag = XDAS_FALSE;
msg_Info( p_enc, "audio %d channels, %d Hz (max bitrate %d kBps)\n",
(int)p_enc->fmt_out.audio.i_channels,
(int)xdm->params.sampleRate,
((int)xdm->params.maxBitRate) >> 13 /* / (8*1024)*/);
/* Create encoder handle */
xdm->handle = AUDENC1_create( p_sys->engine, (String)p_sys->psz_codec, &xdm->params );
if( !xdm->handle )
{
goto error;
}
p_sys->pf_encode_audio = EncodeAudio1;
return VLC_SUCCESS;
error:
free( p_sys->xdm );
p_sys->xdm = NULL;
return VLC_EGENERIC;
}
void CloseEncoderAudio1( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm = p_sys->xdm;
/* Delete audio encoder */
if( p_enc->fmt_out.i_cat == AUDIO_ES )
AUDENC1_delete( xdm->handle );
/* Free 'DaVinci compliant' buffers */
davinci_FreeBuffer1( &xdm->in );
davinci_FreeBuffer1( &xdm->out );
free( xdm );
xdm = NULL;
}
/*****************************************************************************
* Audio Encoder: XDM 1.0 API
*****************************************************************************/
static inline IAUDIO_ChannelMode davinci_get_audio_channels( int i_channels )
{
IAUDIO_ChannelMode i_mode = IAUDIO_2_0;
switch( i_channels )
{
case 1: i_mode = IAUDIO_1_0; /* Single channel. */
break;
case 2: i_mode = IAUDIO_2_0; /* Two channel. */
break;
case 3: i_mode = IAUDIO_3_0; /* Three channel. */
break;
case 4: i_mode = IAUDIO_3_1; /* Four channel. */
break;
case 5: i_mode = IAUDIO_3_2; /* Five channel. */
break;
case 6: i_mode = IAUDIO_2_3; /* 5.1 channel. */
break;
case 7: i_mode = IAUDIO_3_4; /* 7.1 channel. */
break;
default: i_mode = IAUDIO_2_0; /**< Two channel. */
break;
}
return i_mode;
}
static inline int davinci_InitAudio1Buffers( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm = p_sys->xdm;
int i_ret = VLC_SUCCESS;
AUDENC1_Status status;
xdm->dparams.size = sizeof( xdm->dparams );
memset( &status, 0, sizeof( status ) );
status.size = sizeof( status );
/* Configue the encoder */
xdm->dparams.bitRate = p_enc->fmt_out.i_bitrate;
xdm->dparams.sampleRate = p_enc->fmt_out.audio.i_rate;
xdm->dparams.channelMode = davinci_get_audio_channels( p_enc->fmt_out.audio.i_channels );
if( xdm->dparams.channelMode == IAUDIO_11_0 )
xdm->dparams.dualMonoMode = IAUDIO_DUALMONO_LR;
xdm->dparams.lfeFlag = XDAS_FALSE; /* FIXME: What to fill in here?
* Number of LFE (Low Frequency Effects) channels in the stream. */
xdm->dparams.inputBitsPerSample = p_enc->fmt_out.audio.i_bitspersample;
//(p_enc->fmt_in.i_codec == AOUT_FMT_S16_NE) ? 16: 32;
msg_Info( p_enc, "using %d channels at %d Hz samplerate (bitrate %d kBps, "
"%d bits per sample)\n",
p_enc->fmt_out.audio.i_channels,
(int)xdm->dparams.sampleRate,
((int)xdm->dparams.bitRate) >> 13 /* / (8*1024)*/,
(int)xdm->dparams.inputBitsPerSample );
if( AUDENC1_control( xdm->handle, XDM_SETPARAMS, &xdm->dparams, &status )
!= AUDENC1_EOK )
{
msg_Err( p_enc, "Failed to set encoder parameters" );
return VLC_EGENERIC;
}
/* Configure buffers */
if( AUDENC1_control( xdm->handle, XDM_GETBUFINFO, &xdm->dparams, &status )
!= AUDENC1_EOK )
{
msg_Err( p_enc, "Failed to get buffer info" );
return VLC_EGENERIC;
}
/* Allocate input buffer(s) */
if( (i_ret = davinci_AllocateBuffer1( status.bufInfo.minNumInBufs,
status.bufInfo.minInBufSize, &xdm->in ))
!= VLC_SUCCESS )
{
msg_Err( p_enc, "Failed to allocate input buffers" );
return i_ret;
}
/* Allocate output buffer */
if( (i_ret = davinci_AllocateBuffer1( status.bufInfo.minNumOutBufs,
status.bufInfo.minOutBufSize, &xdm->out ))
!= VLC_SUCCESS )
{
msg_Err( p_enc, "Failed to allocate output buffers" );
return i_ret;
}
return i_ret;
}
static block_t *EncodeAudio1( encoder_t *p_enc, aout_buffer_t *p_buffer )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm = p_sys->xdm;
AUDENC1_InArgs in_args;
AUDENC1_OutArgs out_args;
block_t *p_block;
int i_ret;
if( xdm->in.numBufs == 0 || xdm->out.numBufs == 0 )
{
if( davinci_InitAudio1Buffers( p_enc ) != VLC_SUCCESS )
return NULL;
}
/* Configure input */
memset( &in_args, 0, sizeof( in_args ) );
in_args.size = sizeof( in_args );
/* NOTE: assume interleaved channels */
memcpy( xdm->in.descs[0].buf, p_buffer->p_buffer, p_buffer->i_nb_bytes );
/* Configure output */
memset( &out_args, 0, sizeof( out_args ) );
out_args.size = sizeof( out_args );
/* Encode the audio */
if( (i_ret = AUDENC1_process( xdm->handle, &xdm->in, &xdm->out,
&in_args, &out_args )) != AUDENC1_EOK )
{
msg_Err( p_enc, "Audio encoding failed (%d): %s", i_ret,
davinci_GetExtendedError( out_args.extendedError ) );
return NULL;
}
/* Print some info */
//msg_Dbg( p_enc, "Bytes generated: %d", (int)out_args.bytesGenerated );
/* Put everything in the block */
if( out_args.bytesGenerated <= 0 )
return NULL;
p_block = block_New( p_enc, out_args.bytesGenerated );
if( !p_block )
return NULL;
memcpy( p_block->p_buffer, xdm->out.descs[0].buf, out_args.bytesGenerated );
/* NOTE: assumption */
p_block->i_dts = p_block->i_pts = p_buffer->start_date;
/* Shamelessly copied from ffmpeg/encoder.c */
p_block->i_length = (mtime_t)1000000 *
(mtime_t)p_enc->fmt_out.audio.i_frame_length /
(mtime_t)p_enc->fmt_out.audio.i_rate;
return p_block;
}
/*****************************************************************************
* encoder.c: video encoder module using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008-2010 M2X BV
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
* Rafaël Carré <rcarre@m2x.nl>
* Jean-Paul Saman <jean-paul.saman at m2x dot nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_vout.h>
#include <vlc_aout.h>
#include <vlc_sout.h>
#include <vlc_codec.h>
#include "davinci.h"
/* XDM 0.9 */
#include <ti/sdo/ce/audio/audenc.h>
#include <assert.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
/* XDM 0.9 */
static block_t *EncodeAudio( encoder_t *, aout_buffer_t * );
/*****************************************************************************
* Encoder
*****************************************************************************/
struct xdm_sys_t
{
/* XDM 0.9 */
AUDENC_Handle handle;
AUDENC_Params params;
AUDENC_DynamicParams dparams;
XDM_BufDesc in;
XDM_BufDesc out;
};
/*****************************************************************************
*
*****************************************************************************/
int OpenEncoderAudio( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm;
xdm = (xdm_sys_t *) calloc( 1, sizeof( xdm_sys_t ) );
if( !xdm )
return VLC_ENOMEM;
xdm = p_sys->xdm;
xdm->params.size = sizeof( xdm->params );
switch( var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "quality" ) )
{
case 1: xdm->params.encodingPreset = XDM_HIGH_QUALITY; break;
case 2: xdm->params.encodingPreset = XDM_HIGH_SPEED; break;
case 3: xdm->params.encodingPreset = XDM_USER_DEFINED; break;
default:
xdm->params.encodingPreset = XDM_DEFAULT;
break;
}
xdm->params.maxBitrate = p_enc->fmt_out.i_bitrate;
xdm->params.maxSampleRate = p_enc->fmt_out.audio.i_rate;
xdm->params.maxNoOfCh = p_enc->fmt_out.audio.i_channels;
xdm->params.dataEndianness = XDM_BYTE;
msg_Info( p_enc, "audio %d channels, %d Hz (max bitrate %d kBps)\n",
(int)xdm->params.maxNoOfCh,
(int)xdm->params.maxSampleRate,
((int)xdm->params.maxBitrate) >> 13 /* / (8*1024)*/);
/* Create encoder handle */
xdm->handle = AUDENC_create( p_sys->engine, (String)p_sys->psz_codec, &xdm->params );
if( !xdm->handle )
goto error;
p_sys->pf_encode_audio = EncodeAudio;
return VLC_SUCCESS;
error:
free( p_sys->xdm );
p_sys->xdm = NULL;
return VLC_EGENERIC;
}
void CloseEncoderAudio( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm = p_sys->xdm;
/* Delete audio encoder */
if( p_enc->fmt_out.i_cat == AUDIO_ES )
AUDENC_delete( xdm->handle );
/* Free 'DaVinci compliant' buffers */
davinci_FreeBuffer( &xdm->in );
davinci_FreeBuffer( &xdm->out );
free( xdm );
xdm = NULL;
}
/*****************************************************************************
* Audio Encoder: XDM 0.9
*****************************************************************************/
static inline int davinci_InitAudioBuffers( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm = p_sys->xdm;
int i_ret = VLC_SUCCESS;
AUDENC_Status status;
xdm->dparams.size = sizeof( xdm->dparams );
memset( &status, 0, sizeof( status ) );
status.size = sizeof( status );
/* Configue the encoder */
/* NOTE: assuming channels are interleaved */
xdm->dparams.inputFormat = IAUDIO_INTERLEAVED; // IAUDIO_BLOCK;
xdm->dparams.bitRate = p_enc->fmt_out.i_bitrate;
xdm->dparams.sampleRate = p_enc->fmt_out.audio.i_rate;
switch( p_enc->fmt_out.audio.i_channels )
{
case 1: xdm->dparams.numChannels = IAUDIO_MONO; /* Single channel. */
break;
case 2: xdm->dparams.numChannels = IAUDIO_STEREO; /* Two channel. */
break;
case 3: xdm->dparams.numChannels = IAUDIO_THREE_ZERO; /* Three channel. */
break;
case 5: xdm->dparams.numChannels = IAUDIO_FIVE_ZERO; /* Five channel. */
break;
case 6: xdm->dparams.numChannels = IAUDIO_FIVE_ONE; /* 5.1 channel. */
break;
case 7: xdm->dparams.numChannels = IAUDIO_SEVEN_ONE; /* 7.1 channel. */
break;
default:
msg_Warn( p_enc, "assuming stereo audio channels" );
xdm->dparams.numChannels = IAUDIO_STEREO; /**< Two channel. */
break;
}
xdm->dparams.numLFEChannels = 0; /* FIXME: What to fill in here?
* Number of LFE (Low Frequency Effects) channels in the stream. */
xdm->dparams.inputBitsPerSample = p_enc->fmt_out.audio.i_bitspersample;
//p_enc->fmt_in.i_codec == AOUT_FMT_S16_NE) ? 16: 32;
msg_Info( p_enc, "using %d channels at %d Hz samplerate (bitrate %d kBps, "
"%d bits per sample)\n",
p_enc->fmt_out.audio.i_channels,
(int)xdm->dparams.sampleRate,
((int)xdm->dparams.bitRate) >> 13 /* / (8*1024)*/,
(int)xdm->dparams.inputBitsPerSample );
if( AUDENC_control( xdm->handle, XDM_SETPARAMS, &xdm->dparams, &status )
!= AUDENC_EOK )
{
msg_Err( p_enc, "Failed to set encoder parameters." );
return VLC_EGENERIC;
}
/* Configure buffers */
if( AUDENC_control( xdm->handle, XDM_GETBUFINFO, &xdm->dparams, &status )
!= AUDENC_EOK )
{
msg_Err( p_enc, "Failed to get buffer info" );
return VLC_EGENERIC;
}
/* Allocate input buffer(s) */
if( (i_ret = davinci_AllocateBuffer( status.bufInfo.minNumInBufs,
status.bufInfo.minInBufSize, &xdm->in ))
!= VLC_SUCCESS )
{
msg_Err( p_enc, "Failed to allocate input buffers" );
return i_ret;
}
/* Allocate output buffer */
if( (i_ret = davinci_AllocateBuffer( status.bufInfo.minNumOutBufs,
status.bufInfo.minOutBufSize, &xdm->out ))
!= VLC_SUCCESS )
{
msg_Err( p_enc, "Failed to allocate output buffers" );
return i_ret;
}
return i_ret;
}
static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_buffer )
{
encoder_sys_t *p_sys = p_enc->p_sys;
xdm_sys_t *xdm = p_sys->xdm;
AUDENC_InArgs in_args;
AUDENC_OutArgs out_args;
block_t *p_block;
int i_ret;
if( xdm->in.numBufs == 0 || xdm->out.numBufs == 0 )
{
if( davinci_InitAudioBuffers( p_enc ) != VLC_SUCCESS )
return NULL;
}
/* Configure input */
memset( &in_args, 0, sizeof( in_args ) );
in_args.size = sizeof( in_args );
/* NOTE: assume interleaved channels */
memcpy( xdm->in.bufs[0], p_buffer->p_buffer, p_buffer->i_nb_bytes );
/* Configure output */
memset( &out_args, 0, sizeof( out_args ) );
out_args.size = sizeof( out_args );
/* Encode the audio */
if( (i_ret = AUDENC_process( xdm->handle, &xdm->in, &xdm->out,
&in_args, &out_args )) != AUDENC_EOK )
{
msg_Err( p_enc, "Audio encoding failed (%d): %s", i_ret,
davinci_GetExtendedError( out_args.extendedError ) );
return NULL;
}
/* Print some info */
//msg_Dbg( p_enc, "Bytes generated: %d", (int)out_args.bytesGenerated );
/* Put everything in the block */
if( out_args.bytesGenerated <= 0 )
return NULL;
p_block = block_New( p_enc, out_args.bytesGenerated );
if( !p_block )
return NULL;
memcpy( p_block->p_buffer, xdm->out.bufs[0], out_args.bytesGenerated );
/* NOTE: assumption */
p_block->i_dts = p_block->i_pts = p_buffer->start_date;
/* Shamelessly copied from ffmpeg/encoder.c */
p_block->i_length = (mtime_t)1000000 *
(mtime_t)p_enc->fmt_out.audio.i_frame_length /
(mtime_t)p_enc->fmt_out.audio.i_rate;
return p_block;
}
/***************************************************************************** /*****************************************************************************
* davinci.c: decoder and encoder modules using the DaVinci DSP. * davinci.c: decoder and encoder modules using the DaVinci DSP.
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2009 M2X BV * Copyright (C) 2008-2010 M2X BV
* $Id$ * $Id$
* *
* Authors: Antoine Cellerier <dionoea at videolan dot org> * Authors: Antoine Cellerier <dionoea at videolan dot org>
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_codec.h> #include <vlc_codec.h>
#include <assert.h>
#include "davinci.h" #include "davinci.h"
/***************************************************************************** /*****************************************************************************
...@@ -79,6 +81,11 @@ ...@@ -79,6 +81,11 @@
#define ENC_QUALITY_LONGTEXT N_( "Encoder qualtiy setting preset. " \ #define ENC_QUALITY_LONGTEXT N_( "Encoder qualtiy setting preset. " \
"ranges from 0..3 (0=encoders default, 1=high quality, 2=speed, 3=user defined" ) "ranges from 0..3 (0=encoders default, 1=high quality, 2=speed, 3=user defined" )
#define ENC_CBR_TEXT N_("Constant bitrate encoding (default: true)" )
#define ENC_CBR_LONGTEXT N_( "Use constant bitrate encoding. If disabled, " \
"then variable bitrate encoding is used resulting in higher bandwidth savings." )
/* */
#define MODULE_DESCRIPTION N_( "Various audio and video decoders/encoders" \ #define MODULE_DESCRIPTION N_( "Various audio and video decoders/encoders" \
"delivered by TI Davinci library. This includes MPEG4, H264, VC-1, "\ "delivered by TI Davinci library. This includes MPEG4, H264, VC-1, "\
"MPEG1, MPEG2, AAC and MP3 codecs") "MPEG1, MPEG2, AAC and MP3 codecs")
...@@ -116,12 +123,16 @@ vlc_module_begin() ...@@ -116,12 +123,16 @@ vlc_module_begin()
set_section( N_("Encoding") , NULL ) set_section( N_("Encoding") , NULL )
set_callbacks( OpenEncoder, CloseEncoder ) set_callbacks( OpenEncoder, CloseEncoder )
/* encoder settings */ /* encoder settings - XDM 0.9 only */
add_integer( ENC_CFG_PREFIX "quality", 0, NULL, ENC_QUALITY_TEXT, add_integer( ENC_CFG_PREFIX "quality", 0, NULL, ENC_QUALITY_TEXT,
ENC_QUALITY_LONGTEXT, true ) ENC_QUALITY_LONGTEXT, true )
change_integer_range( 0, 3 ) change_integer_range( 0, 3 )
/* video encoder settings */ /* encoder settings - XDM 1.0 only */
add_bool( ENC_CFG_PREFIX "cbr", true, NULL, ENC_CBR_TEXT,
ENC_CBR_LONGTEXT, true )
/* video encoder settings - XDM all versions */
add_integer( ENC_CFG_PREFIX "keyint", 0, NULL, ENC_KEYINT_TEXT, add_integer( ENC_CFG_PREFIX "keyint", 0, NULL, ENC_KEYINT_TEXT,
ENC_KEYINT_LONGTEXT, false ) ENC_KEYINT_LONGTEXT, false )
add_bool( ENC_CFG_PREFIX "interlace", false, NULL, ENC_INTERLACE_TEXT, add_bool( ENC_CFG_PREFIX "interlace", false, NULL, ENC_INTERLACE_TEXT,
...@@ -150,6 +161,7 @@ vlc_module_end() ...@@ -150,6 +161,7 @@ vlc_module_end()
*****************************************************************************/ *****************************************************************************/
#include <ti/sdo/ce/osal/Memory.h> #include <ti/sdo/ce/osal/Memory.h>
/* XDM 0.9 */
int davinci_AllocateBuffer( XDAS_Int32 i_num, XDAS_Int32 *pi_sizes, int davinci_AllocateBuffer( XDAS_Int32 i_num, XDAS_Int32 *pi_sizes,
XDM_BufDesc *buf ) XDM_BufDesc *buf )
{ {
...@@ -203,6 +215,44 @@ void davinci_FreeBuffer( XDM_BufDesc *buf ) ...@@ -203,6 +215,44 @@ void davinci_FreeBuffer( XDM_BufDesc *buf )
} }
} }
/* XDM 1.0 */
int davinci_AllocateBuffer1( XDAS_Int32 i_num, XDAS_Int32 *pi_sizes,
XDM1_BufDesc *buf )
{
int i;
assert(i_num < XDM_MAX_IO_BUFFERS);
buf->numBufs = i_num;
for( i = 0; i < i_num; i++ )
{
buf->descs[i].bufSize = pi_sizes[i];
buf->descs[i].buf = Memory_contigAlloc( pi_sizes[i], Memory_DEFAULTALIGNMENT );
if( !buf->descs[i].buf )
{
goto error;
}
}
return VLC_SUCCESS;
error:
for( i--; i >= 0; i-- )
Memory_contigFree( buf->descs[i].buf, buf->descs[i].bufSize );
return VLC_ENOMEM;
}
void davinci_FreeBuffer1( XDM1_BufDesc *buf )
{
if( buf->numBufs != 0 )
{
int i;
for( i = 0; i < buf->numBufs; i++ )
Memory_contigFree( buf->descs[i].buf, buf->descs[i].bufSize );
buf->numBufs = 0;
}
}
/***************************************************************************** /*****************************************************************************
* Misc utils * Misc utils
*****************************************************************************/ *****************************************************************************/
...@@ -264,3 +314,4 @@ void davinci_PrintAvailableAlgorithms( vlc_object_t *p_this, const char *psz_eng ...@@ -264,3 +314,4 @@ void davinci_PrintAvailableAlgorithms( vlc_object_t *p_this, const char *psz_eng
} }
} }
} }
/***************************************************************************** /*****************************************************************************
* davinci.h: decoder and encoder modules using the DaVinci DSP. * davinci.h: decoder and encoder modules using the DaVinci DSP.
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2009 M2X BV * Copyright (C) 2008-2010 M2X BV
* $Id$ * $Id$
* *
* Authors: Antoine Cellerier <dionoea at videolan dot org> * Authors: Antoine Cellerier <dionoea at videolan dot org>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define VLC_DAVINCI_H #define VLC_DAVINCI_H
#define XDM_INCLUDE_DOT9_SUPPORT /* Support old 0.9 API */ #define XDM_INCLUDE_DOT9_SUPPORT /* Support old 0.9 API */
#include <gnu/targets/std.h> #include <gnu/targets/std.h>
#include <xdc/std.h> #include <xdc/std.h>
#include <ti/xdais/xdas.h> #include <ti/xdais/xdas.h>
...@@ -38,28 +39,86 @@ ...@@ -38,28 +39,86 @@
#define ENC_CFG_PREFIX "sout-davinci-" #define ENC_CFG_PREFIX "sout-davinci-"
#define DEC_CFG_PREFIX "davinci-" #define DEC_CFG_PREFIX "davinci-"
/* Wrapper for XDM version specific data */
typedef struct xdm_sys_t xdm_sys_t;
/* decoder */
int OpenVideoDecoder( vlc_object_t * ); int OpenVideoDecoder( vlc_object_t * );
void CloseVideoDecoder( vlc_object_t * ); void CloseVideoDecoder( vlc_object_t * );
int OpenAudioDecoder( vlc_object_t * ); int OpenAudioDecoder( vlc_object_t * );
void CloseAudioDecoder( vlc_object_t * ); void CloseAudioDecoder( vlc_object_t * );
/* encoder */
struct encoder_sys_t
{
char *psz_ti_engine;
const char *psz_codec;
Engine_Handle engine;
xdm_sys_t *xdm;
block_t *(*pf_encode_video)( encoder_t *, picture_t * );
block_t *(*pf_encode_audio)( encoder_t *, aout_buffer_t * );
/* stats */
#ifdef DEBUG_FPS
mtime_t i_pts_start;
mtime_t i_pts_end;
int i_fps;
#endif
int i_pics;
};
int OpenEncoder( vlc_object_t * ); int OpenEncoder( vlc_object_t * );
void CloseEncoder( vlc_object_t * ); void CloseEncoder( vlc_object_t * );
int OpenEncoderAudio( encoder_t * );
void CloseEncoderAudio( encoder_t * );
int OpenEncoderAudio1( encoder_t * );
void CloseEncoderAudio1( encoder_t * );
int OpenEncoderVideo( encoder_t * );
void CloseEncoderVideo( encoder_t * );
//int OpenEncoderVideo1( encoder_t * );
//void CloseEncoderVideo1( encoder_t * );
/***************************************************************************** /*****************************************************************************
* Common stuff * Common stuff
*****************************************************************************/ *****************************************************************************/
extern const char *ppsz_engine_error[]; extern const char *ppsz_engine_error[];
int davinci_AllocateBuffer( XDAS_Int32, XDAS_Int32 *, XDM_BufDesc * ); #ifdef DEBUG_FPS
void davinci_FreeBuffer( XDM_BufDesc * ); void calculate_fps( encoder_t *p_enc );
#endif
const char *davinci_GetExtendedError( XDAS_Int32 ); const char *davinci_GetExtendedError( XDAS_Int32 );
void davinci_PrintAvailableAlgorithms( vlc_object_t *, const char * ); void davinci_PrintAvailableAlgorithms( vlc_object_t *, const char * );
bool GetDavinciDecoder( vlc_fourcc_t, int *, const char **, const char ** ); /* Davinci FourCC */
bool GetDavinciEncoder( vlc_fourcc_t, int *, const char **, const char ** ); enum davinci_xdm_version_e
{
DAVINCI_XDM0_9 = 0x09,
DAVINCI_XDM1_0 = 0x0A,
DAVINCI_XDM1_1 = 0x0C,
};
bool GetDavinciDecoder( vlc_fourcc_t, int *, int *, const char **, const char ** );
bool GetDavinciEncoder( vlc_fourcc_t, int *, int *, const char **, const char ** );
bool GetVlcFourcc( const char *, int *, vlc_fourcc_t *, const char ** ); bool GetVlcFourcc( const char *, int *, vlc_fourcc_t *, const char ** );
XDAS_Int32 VlcChromaToXdm( vlc_fourcc_t ); XDAS_Int32 VlcChromaToXdm( vlc_fourcc_t );
/* XDM 0.9 */
int davinci_AllocateBuffer( XDAS_Int32, XDAS_Int32 *, XDM_BufDesc * );
void davinci_FreeBuffer( XDM_BufDesc * );
/* XDM 1.0 */
int davinci_AllocateBuffer1( XDAS_Int32, XDAS_Int32 *, XDM1_BufDesc * );
void davinci_FreeBuffer1( XDM1_BufDesc * );
#endif #endif
This diff is collapsed.
This diff is collapsed.
...@@ -67,14 +67,14 @@ int OpenVideoDecoder( vlc_object_t *p_this ) ...@@ -67,14 +67,14 @@ int OpenVideoDecoder( vlc_object_t *p_this )
decoder_t *p_dec = (decoder_t*)p_this; decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys; decoder_sys_t *p_sys;
Engine_Error err; Engine_Error err;
int i_cat; int i_cat, i_xdm;
char *psz_chroma = NULL; char *psz_chroma = NULL;
const char *psz_codec = NULL; const char *psz_codec = NULL;
const char *psz_namecodec = NULL; const char *psz_namecodec = NULL;
vlc_fourcc_t i_chroma = VLC_FOURCC('U','Y','V','Y'); vlc_fourcc_t i_chroma = VLC_FOURCC('U','Y','V','Y');
VIDDEC_Params params; VIDDEC_Params params;
if( !GetDavinciDecoder( p_dec->fmt_in.i_codec, &i_cat, if( !GetDavinciDecoder( p_dec->fmt_in.i_codec, &i_cat, &i_xdm,
&psz_codec, &psz_namecodec ) ) &psz_codec, &psz_namecodec ) )
return VLC_EGENERIC; return VLC_EGENERIC;
......
This diff is collapsed.
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