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

Video decoder using DaVinci chip.

parent c91faf2e
...@@ -4508,6 +4508,18 @@ AC_ARG_ENABLE(davinciresizer, ...@@ -4508,6 +4508,18 @@ AC_ARG_ENABLE(davinciresizer,
VLC_ADD_PLUGINS([davinci_resizer]) VLC_ADD_PLUGINS([davinci_resizer])
fi fi
dnl
dnl Linux DaVinci codec module
dnl
AC_ARG_ENABLE(davinci,
[ --enable-davinc Linux davinci codec support (default disabled on Linux)])
if test "${enable_davinci}" = "yes"
then
VLC_ADD_PLUGINS([davinci])
VLC_ADD_CFLAGS([davinci],[-I${PRJROOT}/ticel/codec/include])
VLC_ADD_LDFLAGS([davinci],[${PRJROOT}/ticel/codec/libs/decode_x470MV.o470MV ${PRJROOT}/ticel/codec/libs/bioslog.a ${PRJROOT}/ticel/codec/libs/video.a ${PRJROOT}/ticel/codec/libs/audio.a ${PRJROOT}/ticel/codec/libs/speech.a ${PRJROOT}/ticel/codec/libs/ce.a ${PRJROOT}/ticel/codec/libs/osal_dsplink_linux.a ${PRJROOT}/ticel/codec/libs/cmem.a ${PRJROOT}/ticel/codec/libs/dsplink.lib ${PRJROOT}/ticel/codec/libs/node.a ${PRJROOT}/ticel/codec/libs/TraceUtil.a ${PRJROOT}/ticel/codec/libs/alg.a ${PRJROOT}/ticel/codec/libs/gt.a])
fi
dnl dnl
dnl Linux MGA module dnl Linux MGA module
dnl dnl
......
...@@ -38,6 +38,7 @@ SOURCES_kate = kate.c ...@@ -38,6 +38,7 @@ SOURCES_kate = kate.c
SOURCES_schroedinger = schroedinger.c SOURCES_schroedinger = schroedinger.c
SOURCES_libass = libass.c SOURCES_libass = libass.c
SOURCES_aes3 = aes3.c SOURCES_aes3 = aes3.c
SOURCES_davinci = davinci.c
libvlc_LTLIBRARIES += \ libvlc_LTLIBRARIES += \
liba52_plugin.la \ liba52_plugin.la \
...@@ -56,3 +57,4 @@ libvlc_LTLIBRARIES += \ ...@@ -56,3 +57,4 @@ libvlc_LTLIBRARIES += \
libsvcdsub_plugin.la \ libsvcdsub_plugin.la \
libinvmem_plugin.la \ libinvmem_plugin.la \
$(NULL) $(NULL)
/*****************************************************************************
* davinci.c: 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 <vlc/vlc.h>
#include <vlc/decoder.h>
#include <gnu/targets/std.h>
#include <xdc/std.h>
#include <ti/sdo/ce/video/viddec.h>
#include <ti/sdo/ce/CERuntime.h>
/*****************************************************************************
*
*****************************************************************************/
struct decoder_sys_t
{
Engine_Handle e;
VIDDEC_Handle d;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int OpenVideoDecoder ( vlc_object_t * );
static void CloseVideoDecoder ( vlc_object_t * );
static picture_t *DecodeVideoBlock ( decoder_t *, block_t ** );
/*****************************************************************************
* 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 );
vlc_module_end();
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",
};
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
static int OpenVideoDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
Engine_Error err;
//IVIDEO_Format //i_format;
const char *psz_codec;
VIDDEC_Params params;
switch( p_dec->fmt_in.i_codec )
{
/* FOURCC codes copied from libavcodec module */
case VLC_FOURCC('m','p','g','v'):
case VLC_FOURCC('m','p','e','g'):
case VLC_FOURCC('m','p','g','1'):
case VLC_FOURCC('P','I','M','1'):
//i_format = IVIDEO_MPEG1;
psz_codec = "mpegdec"; /* FIXME */
break;
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'):
//i_format = IVIDEO_MPEG2SP;
//i_format = IVIDEO_MPEG2MP;
//i_format = IVIDEO_MPEG2HP;
psz_codec = "mpeg2dec";
break;
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'):
//i_format = IVIDEO_MPEG4SP;
//i_format = IVIDEO_MPEG4ASP;
psz_codec = "mpeg4dec";
break;
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'):
//i_format = IVIDEO_H264BP;
//i_format = IVIDEO_H264MP;
//i_format = IVIDEO_H264HP;
psz_codec = "h264dec";
break;
case VLC_FOURCC('W','V','C','1'):
case VLC_FOURCC('w','v','c','1'):
//i_format = IVIDEO_VC1SP;
//i_format = IVIDEO_VC1MP;
//i_format = IVIDEO_VC1AP;
psz_codec = "vc1dec"; /* FIXME */
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_EGENERIC;
}
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;
}
/* Create video decoder */
params.size = sizeof( VIDDEC_Params );
params.maxHeight = p_dec->fmt_in.video.i_height;
params.maxWidth = p_dec->fmt_in.video.i_width;
params.maxFrameRate = 30 * 1000; /* in frames per 1000 seconds */
params.maxBitRate = 10 * 1000 * 1000; /* in bits per second */
params.dataEndianness = XDM_LE_32;
params.forceChromaFormat = XDM_YUV_420P;
/* Or do we want to output directly to XDM_YUV422ILE as that's what the
* frame buffer likes? */
p_sys->d = VIDDEC_create( p_sys->e, (String)psz_codec, &params );
if( !p_sys->d )
{
msg_Err( p_dec, "Failed to create video decoder (%s)", psz_codec );
goto error;
}
/* Set output properties */
p_dec->fmt_out.i_cat = VIDEO_ES;
p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0');
p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width;
p_dec->fmt_out.video.i_height = p_dec->fmt_in.video.i_height;
p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect;
/* Set callbacks */
p_dec->pf_decode_video = DecodeVideoBlock;
return VLC_SUCCESS;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys );
return VLC_EGENERIC;
}
/*****************************************************************************
* CloseDecoder: png decoder destruction
*****************************************************************************/
static void CloseVideoDecoder( 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 */
VIDDEC_delete( p_sys->d );
/* Close our engine handle */
Engine_close( p_sys->e );
/* Exit the codec engine */
/* FIXME: not available in ticel it seems CERuntime_exit(); */
free( p_sys );
}
/****************************************************************************
* DecodeBlock: the whole thing
****************************************************************************/
static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_block;
picture_t *p_pic = NULL;
XDM_BufDesc in;
XDM_BufDesc out;
VIDDEC_InArgs in_args;
VIDDEC_OutArgs out_args;
int i;
if( !pp_block || !*pp_block ) return NULL;
memset( &in, 0, sizeof( in ) );
memset( &out, 0, sizeof( out ) );
memset( &in_args, 0, sizeof( in_args ) );
memset( &out_args, 0, sizeof( out_args ) );
p_block = *pp_block;
/* Setup input buffer */
in.numBufs = 1;
in.bufs = (XDAS_Int8 **)malloc( in.numBufs * sizeof( XDAS_Int8 * ) );
in.bufSizes = (XDAS_Int32 *)malloc( in.numBufs * sizeof( XDAS_Int32 ) );
in.bufs[0] = p_block->p_buffer;
in.bufSizes[0] = p_block->i_buffer;
/* Setup input arguments */
in_args.size = sizeof( in_args );
in_args.numBytes = p_block->i_buffer;
in_args.inputID = 0; /* FIXME */
/* Get a new picture */
p_pic = p_dec->pf_vout_buffer_new( p_dec );
if( !p_pic ) goto error;
/* Setup output buffer */
/* XXX: Not sure about this one */
out.numBufs = p_pic->i_planes;
out.bufs = (XDAS_Int8 **)malloc( out.numBufs * sizeof( XDAS_Int8 * ) );
out.bufSizes = (XDAS_Int32 *)malloc( out.numBufs * sizeof( XDAS_Int32 ) );
for( i = 0; i < p_pic->i_planes; i++ )
{
out.bufs[i] = p_pic->p[i].p_pixels;
out.bufSizes[i] = p_pic->p[i].i_lines * p_pic->p[i].i_pitch;
}
/* Setup output arguemnts */
out_args.size = sizeof( out_args );
/* Decode the video */
if( VIDDEC_process( p_sys->d, &in, &out, &in_args, &out_args )
== VIDDEC_EFAIL )
{
msg_Err( p_dec, "Video decoding failed" );
goto error;
}
/* Copy stuff to picture here */
p_pic->date = p_block->i_pts > 0 ? p_block->i_pts : p_block->i_dts;
error:
if( p_pic && p_pic->pf_release ) p_pic->pf_release( p_pic );
free( in.bufs );
free( in.bufSizes );
free( out.bufs );
free( out.bufSizes );
block_Release( p_block );
return p_pic;
}
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