Commit e73a6ebc authored by Antoine Cellerier's avatar Antoine Cellerier Committed by Jean-Paul Saman

Move davinci stuff to its own directory and split the different modules. Start...

Move davinci stuff to its own directory and split the different modules. Start implementing audio dec module (unfinished but most of the code should be in there).
Signed-off-by: Jean-Paul Saman's avatarJean-Paul Saman <jean-paul.saman@m2x.nl>
parent 96de7fa2
......@@ -5995,6 +5995,7 @@ AC_CONFIG_FILES([
modules/codec/Makefile
modules/codec/avcodec/Makefile
modules/codec/cmml/Makefile
modules/codec/davinci/Makefile
modules/codec/dmo/Makefile
modules/codec/shine/Makefile
modules/codec/subtitles/Makefile
......
SUBDIRS = cmml dmo avcodec shine subtitles spudec wmafixed xvmc
SUBDIRS = cmml dmo avcodec shine subtitles spudec wmafixed xvmc davinci
SOURCES_a52 = a52.c a52.h
SOURCES_dts = dts.c
SOURCES_flac = flac.c
......@@ -38,7 +38,6 @@ SOURCES_kate = kate.c
SOURCES_schroedinger = schroedinger.c
SOURCES_libass = libass.c
SOURCES_aes3 = aes3.c
SOURCES_davinci = davinci.c
libvlc_LTLIBRARIES += \
liba52_plugin.la \
......@@ -57,4 +56,3 @@ libvlc_LTLIBRARIES += \
libsvcdsub_plugin.la \
libinvmem_plugin.la \
$(NULL)
SOURCES_davinci = \
davinci.c \
davinci.h \
auddec.c \
viddec.c \
videnc.c \
$(NULL)
/*****************************************************************************
* auddec.c: audio decoder module using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
*
* 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
*****************************************************************************/
#include "davinci.h"
#include <ti/sdo/ce/audio/auddec.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static aout_buffer_t *DecodeAudioBlock( decoder_t *, block_t ** );
/*****************************************************************************
* Audio decoder
*****************************************************************************/
struct decoder_sys_t
{
Engine_Handle e;
AUDDEC_Handle d;
XDM_BufDesc in;
XDM_BufDesc out;
};
/*****************************************************************************
*
*****************************************************************************/
int OpenAudioDecoder( vlc_object_t *p_this )
{
#if 0
decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys;
Engine_Error err;
const char *psz_codec;
AUDDEC_Params params;
switch( p_dec->fmt_in.i_codec )
{
CASE_MP3
psz_codec = "mp3dec";
break;
CASE_AAC
psz_codec = "aacdec";
break;
default:
return VLC_EGENERIC;
}
/* Allocate our private structure */
p_dec->p_sys = (decoder_sys_t *)malloc( sizeof( decoder_sys_t ) );
if( !p_dec->p_sys )
return VLC_ENOMEM;
p_sys = p_dec->p_sys;
memset( p_sys, 0, sizeof( decoder_sys_t ) );
/* Initialize the codec engine */
CERuntime_init();
/* Create an engine handle */
p_sys->e = Engine_open( "decode", NULL /*&Engine_ATTRS*/, &err );
if( err != Engine_EOK )
{
msg_Err( p_dec, ppsz_engine_error[err] );
goto error;
}
PrintAvailableAlgorithms( p_this, "decode" );
/* Create audio decoder */
params.size = sizeof( params );
params.maxSampleRate = 48000; /* in Hz */
params.maxBitrate = 256000; /* in kbps */
params.maxNoOfCh = IAUDIO_SEVEN_ONE; /* 7.1 */
params.dataEndianness = XDM_BYTE; /* FIXME? */
p_sys->d = AUDDEC_create( p_sys->e, (String)psz_codec, &params );
if( !p_sys->d )
{
msg_Err( p_dec, "Failed to create audio decoder (%s)", psz_codec );
goto error;
}
/* Set output properties */
/* Set callbacks */
p_dec->pf_decode_audio = DecodeAudioBlock;
#ifdef DEBUG_DAVINCI
msg_Info( p_dec, "Wooooohooo!" );
#endif
return VLC_SUCCESS;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys );
#endif
return VLC_EGENERIC;
}
/*****************************************************************************
*
*****************************************************************************/
void CloseAudioDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
/* Close our codec handle */
AUDDEC_delete( p_sys->d );
/* Close our engine handle */
Engine_close( p_sys->e );
/* Exit the codec engine */
CERuntime_exit();
/* Free 'DaVinci compliant' buffers */
FreeBuffer( &p_sys->in );
FreeBuffer( &p_sys->out );
free( p_sys );
}
/*****************************************************************************
*
*****************************************************************************/
static aout_buffer_t *DecodeAudioBlock( decoder_t *p_dec, block_t **pp_block )
{
#if 0
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_block;
aout_buffer_t *p_out = NULL;
AUDDEC_InArgs in_args;
AUDDEC_OutArgs out_args;
AUDDEC_DynamicParams dparams;
AUDDEC_Status status;
int i;
if( !pp_block || !*pp_block ) return NULL;
p_block = *pp_block;
#ifdef DEBUG_DAVINCI
msg_Err( p_dec, "DecodeAudioBlock starts now!" );
#endif
memset( &in_args, 0, sizeof( in_args ) );
memset( &out_args, 0, sizeof( out_args ) );
/* Configure audio decoder */
dparams.size = sizeof( dparams );
memset( &status, 0, sizeof( status ) );
status.size = sizeof( status );
if( p_sys->in.numBufs == 0 || p_sys->out.numBufs == 0 )
{
if( AUDDEC_control( p_sys->d, XDM_GETBUFINFO, &dparams, &status )
!= VIDDEC_EOK )
{
msg_Err( p_dec, "Failed to get buffer info" );
goto error;
}
/* Allocate input buffer */
if( AllocateBuffer( p_dec, status.bufInfo.minNumInBufs,
status.bufInfo.minInBufSize, &p_sys->in )
!= VLC_SUCCESS )
{
msg_Err( p_dec, "Failed to allocate input buffer" );
goto error;
}
/* Allocate output buffer */
if( AllocateBuffer( p_dec, status.bufInfo.minNumOutBufs,
status.bufInfo.minOutBufSize, &p_sys->out )
!= VLC_SUCCESS )
{
msg_Err( p_dec, "Failed to allocate output buffer" );
goto error;
}
}
/* Setup input arguments */
in_args.size = sizeof( in_args );
in_args.numBytes = __MIN( p_block->i_buffer, p_sys->in.bufSizes[0] );
/* Setup input buffer */
#ifdef DEBUG_DAVINCI
if( p_block->i_buffer > p_sys->in.bufSizes[0] )
msg_Dbg( p_dec, "Woah! Not enough room to store the whole block" );
#endif
memcpy( p_sys->in.bufs[0], p_block->p_buffer, in_args.numBytes );
/* Setup output arguments */
out_args.size = sizeof( out_args );
/* Decode the audio */
i = AUDDEC_process( p_sys->d, &p_sys->in, &p_sys->out, &in_args, &out_args );
if( i != VIDDEC_EOK )
{
msg_Err( p_dec, "Audio decoding failed (Error code: %d, "
"Extended error: %x)", i, (int)out_args.extendedError );
PrintExtendedError( p_dec, out_args.extendedError );
goto error;
}
if( VIDDEC_control( p_sys->d, XDM_GETSTATUS, &dparams, &status ) != AUDDEC_EOK )
{
msg_Err( p_dec, "Failed to get decoder status" );
goto error;
}
p_block->p_buffer += out_args.bytesConsumed;
p_block->i_buffer -= out_args.bytesConsumed;
p_dec->fmt_out.audio.i_rate = status.sampleRate;
switch( status.numChannels )
{
case IAUDIO_MONO:
i = AOUT_VAR_MONO;
break;
case IAUDIO_STEREO:
i = AOUT_VAR_STEREO;
break;
case IAUDIO_THREE_ZERO:
i = 3; /* FIXME? */
break;
case IAUDIO_FIVE_ZERO:
i = AOUT_VAR_3F2R;
break;
case IAUDIO_FIVE_ONE:
i = AOUT_VAR_5_1;
break;
case IAUDIO_SEVEN_ONE:
i = AOUT_VAR_7_1;
break;
default:
msg_Warn( p_dec, "Unknown numChannels (%d)", status.numChannels );
i = status.numChannels;
break;
}
p_dec->fmt_out.audio.i_physical_channels =
p_dec->fmt_out.audio.i_original_channels =
p_dec->fmt_out.audio.i_channels = i;
p_dec->fmt_out.audio.i_bitspersample = status.outputBitsPerSample;
p_out = p_dec->pf_aout_buffer_new( p_dec, status.frameLen /
p_dec->fmt_out.audio.i_channels );
p_out->start_date =
p_out->end_date =
p_out->p_buffer =
return p_out;
error:
if( p_out && p_out->pf_release )
p_out->pf_release( p_out );
block_Release( p_block );
#endif
return NULL;
}
/*****************************************************************************
* davinci.c: decoder and encoder modules using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
*
* 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
*****************************************************************************/
#include "davinci.h"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
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_submodule();
set_description( _("DaVinci DSP audio decoder") );
set_capability( "decoder", 1337 );
set_callbacks( OpenAudioDecoder, CloseAudioDecoder );
add_submodule();
set_description( _("DaVinci DSP video encoder" ) );
set_capability( "encoder", 1337 );
set_callbacks( OpenVideoEncoder, CloseVideoEncoder );
vlc_module_end();
/*****************************************************************************
* Misc utils
*****************************************************************************/
#include <ti/sdo/ce/osal/Memory.h>
int __AllocateBuffer( vlc_object_t *p_this, XDAS_Int32 i_num,
XDAS_Int32 *pi_sizes, XDM_BufDesc *buf )
{
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 * ) );
if( !buf->bufs )
{
buf->numBufs = 0;
return VLC_ENOMEM;
}
buf->bufSizes = (XDAS_Int32 *)malloc( buf->numBufs * sizeof( XDAS_Int32 ) );
if( !buf->bufSizes )
{
free( buf->bufs );
buf->numBufs = 0;
return VLC_ENOMEM;
}
for( i = 0; i < i_num; i++ )
{
#ifdef DEBUG_DAVINCI
msg_Info( p_this, " %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] )
{
#ifdef DEBUG_DAVINCI
msg_Err( p_this, "Failed to allocate buffer" );
#endif
for( i--; i >= 0; i-- )
{
Memory_contigFree( buf->bufs[i], buf->bufSizes[i] );
free( buf->bufs );
free( buf->bufSizes );
buf->numBufs = 0;
return VLC_ENOMEM;
}
}
}
return VLC_SUCCESS;
}
void FreeBuffer( XDM_BufDesc *buf )
{
if( buf->numBufs != 0 )
{
int i;
for( i = 0; i < buf->numBufs; i++ )
Memory_contigFree( buf->bufs[i], buf->bufSizes[i] );
free( buf->bufs );
free( buf->bufSizes );
buf->numBufs = 0;
}
}
void __PrintExtendedError( vlc_object_t *p_this, XDAS_Int32 error )
{
if( XDM_ISAPPLIEDCONCEALMENT( error ) )
msg_Err( p_this, " Applied bit concealment" );
if( XDM_ISINSUFFICIENTDATA( error ) )
msg_Err( p_this, " Insufficient data" );
if( XDM_ISCORRUPTEDDATA( error ) )
msg_Err( p_this, " Corrupted data" );
if( XDM_ISCORRUPTEDHEADER( error ) )
msg_Err( p_this, " Corrupted header" );
if( XDM_ISUNSUPPORTEDINPUT( error ) )
msg_Err( p_this, " Unsupported input" );
if( XDM_ISUNSUPPORTEDPARAM( error ) )
msg_Err( p_this, " Unsupported param" );
if( XDM_ISFATALERROR( error ) )
msg_Err( p_this, " Fatal error" );
}
void __PrintAvailableAlgorithms( vlc_object_t *p_this, const char *psz_engine )
{
int i = 0;
Engine_AlgInfo info;
info.algInfoSize = sizeof( info );
msg_Dbg( p_this, "Available algorithms in engine `%s':", psz_engine );
while( Engine_getAlgInfo( (String)psz_engine, &info, i ) == Engine_EOK )
{
const char **psz_type = info.typeTab;
i++;
msg_Dbg( p_this, " %d: %s (%s)", i, info.name, info.isLocal?"local":"remote" );
if( *psz_type )
{
msg_Dbg( p_this, " Inheritance hierarchy:" );
for( ; !*psz_type; psz_type++ )
msg_Dbg( p_this, " %s", *psz_type );
}
}
}
/*****************************************************************************
* davinci.h: decoder and encoder modules using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
*
* 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.
*****************************************************************************/
#ifndef VLC_DAVINCI_H
#define VLC_DAVINCI_H
#include <vlc/vlc.h>
#include <vlc/decoder.h>
#include <gnu/targets/std.h>
#include <xdc/std.h>
#include <ti/xdais/xdas.h>
#include <ti/xdais/dm/xdm.h>
#include <ti/sdo/ce/CERuntime.h>
#include <ti/sdo/ce/Engine.h>
#define DEBUG_DAVINCI
int OpenVideoDecoder( vlc_object_t * );
void CloseVideoDecoder( vlc_object_t * );
int OpenAudioDecoder( vlc_object_t * );
void CloseAudioDecoder( vlc_object_t * );
int OpenVideoEncoder( vlc_object_t * );
void CloseVideoEncoder( vlc_object_t * );
int __AllocateBuffer( vlc_object_t *, XDAS_Int32, XDAS_Int32 *, XDM_BufDesc * );
#define AllocateBuffer( a, b, c, d ) __AllocateBuffer( VLC_OBJECT( a ), b, c, d )
void FreeBuffer( XDM_BufDesc * );
void __PrintExtendedError( vlc_object_t *, XDAS_Int32 );
#define PrintExtendedError( a, b ) __PrintExtendedError( VLC_OBJECT( a ), b )
void __PrintAvailableAlgorithms( vlc_object_t *, const char * );
#define PrintAvailableAlgorithms( a, b ) __PrintAvailableAlgorithms( VLC_OBJECT( a ), b )
/*****************************************************************************
* Common stuff
*****************************************************************************/
static const char *ppsz_engine_error[] = {
[Engine_EOK] = "Ok",
[Engine_EEXIST] = "Engine name doesn't exist",
[Engine_ENOMEM] = "Can't allocate engine memory",
[Engine_EDSPLOAD] = "Can't load the DSP",
[Engine_ENOCOMM] = "Can't create communication connection to DSP",
[Engine_ENOSERVER] = "Can't locate the server on the DSP",
[Engine_ECOMALLOC] = "Can't allocate communication buffer",
[Engine_ERUNTIME] = "Engine runtime failure",
[Engine_ECODECCREATE] = "Engine codec creation failed",
[Engine_ECODECSTART] = "Engine codec start failed",
[Engine_EINVAL] = "Bad parameter",
[Engine_EBADSERVER] = "Incompatible server specified",
[Engine_ENOTAVAIL] = "Service not available",
//[Engine_EWRONGSTATE] = "Call can't be made at this time",
//[Engine_EINUSE] = "Call can't be made at this time because a required resource is in use",
//[Engine_ENOTFOUND] = "Entity was not found",
};
/* FOURCC codes copied from libavcodec module */
#define CASE_MPEG1 \
case VLC_FOURCC('m','p','e','g'): \
case VLC_FOURCC('m','p','g','1'): \
case VLC_FOURCC('P','I','M','1'):
#define CASE_MPEG2 \
case VLC_FOURCC('m','p','g','v'): \
case VLC_FOURCC('m','p','2','v'): \
case VLC_FOURCC('M','P','E','G'): \
case VLC_FOURCC('m','p','g','2'): \
case VLC_FOURCC('h','d','v','1'): \
case VLC_FOURCC('h','d','v','2'): \
case VLC_FOURCC('h','d','v','3'): \
case VLC_FOURCC('h','d','v','5'): \
case VLC_FOURCC('m','x','5','n'): \
case VLC_FOURCC('m','x','5','p'): \
case VLC_FOURCC('m','x','4','n'): \
case VLC_FOURCC('m','x','4','p'): \
case VLC_FOURCC('m','x','3','n'): \
case VLC_FOURCC('m','x','3','p'): \
case VLC_FOURCC('x','d','v','2'): \
case VLC_FOURCC('A','V','m','p'): \
case VLC_FOURCC('V','C','R','2'): \
case VLC_FOURCC('M','M','E','S'): \
case VLC_FOURCC('m','m','e','s'):
#define CASE_MPEG4 \
case VLC_FOURCC('D','I','V','X'): \
case VLC_FOURCC('d','i','v','x'): \
case VLC_FOURCC('M','P','4','S'): \
case VLC_FOURCC('M','P','4','s'): \
case VLC_FOURCC('M','4','S','2'): \
case VLC_FOURCC('m','4','s','2'): \
case VLC_FOURCC('x','v','i','d'): \
case VLC_FOURCC('X','V','I','D'): \
case VLC_FOURCC('X','v','i','D'): \
case VLC_FOURCC('X','V','I','X'): \
case VLC_FOURCC('x','v','i','x'): \
case VLC_FOURCC('D','X','5','0'): \
case VLC_FOURCC('d','x','5','0'): \
case VLC_FOURCC('B','L','Z','0'): \
case VLC_FOURCC('B','X','G','M'): \
case VLC_FOURCC('m','p','4','v'): \
case VLC_FOURCC('M','P','4','V'): \
case VLC_FOURCC( 4 , 0 , 0 , 0 ): \
case VLC_FOURCC('m','4','c','c'): \
case VLC_FOURCC('M','4','C','C'): \
case VLC_FOURCC('F','M','P','4'): \
case VLC_FOURCC('f','m','p','4'): \
case VLC_FOURCC('3','I','V','2'): \
case VLC_FOURCC('3','i','v','2'): \
case VLC_FOURCC('U','M','P','4'): \
case VLC_FOURCC('W','V','1','F'): \
case VLC_FOURCC('S','E','D','G'): \
case VLC_FOURCC('R','M','P','4'): \
case VLC_FOURCC('H','D','X','4'): \
case VLC_FOURCC('h','d','x','4'): \
case VLC_FOURCC('S','M','P','4'): \
case VLC_FOURCC('f','v','f','w'): \
case VLC_FOURCC('F','V','F','W'):
#define CASE_H264 \
case VLC_FOURCC('a','v','c','1'): \
case VLC_FOURCC('A','V','C','1'): \
case VLC_FOURCC('h','2','6','4'): \
case VLC_FOURCC('H','2','6','4'): \
case VLC_FOURCC('x','2','6','4'): \
case VLC_FOURCC('X','2','6','4'): \
case VLC_FOURCC('V','S','S','H'): \
case VLC_FOURCC('V','S','S','W'): \
case VLC_FOURCC('v','s','s','h'): \
case VLC_FOURCC('D','A','V','C'): \
case VLC_FOURCC('d','a','v','c'):
#define CASE_VC1 \
case VLC_FOURCC('W','V','C','1'): \
case VLC_FOURCC('w','v','c','1'):
#define CASE_MP3 \
case VLC_FOURCC('m','p','3',' '): \
case VLC_FOURCC('.','m','p','3'): \
case VLC_FOURCC('M','P','3',' '): \
case VLC_FOURCC('L','A','M','E'):
#define CASE_AAC \
case VLC_FOURCC('m','p','4','a'):
#endif
This diff is collapsed.
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