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

Rewrite davinci codec

parent 5e3df08c
......@@ -4501,11 +4501,11 @@ AC_ARG_ENABLE(fb,
dnl
dnl Linux DaVinci resizer and chroma conversion module
dnl
AC_ARG_ENABLE(davinciresizer,
[ --enable-davinciresizer Linux davinci resizer and chroma conversion support (default disabled on Linux)])
if test "${enable_davinciresizer}" = "yes"
AC_ARG_ENABLE(davinci-resizer,
[ --enable-davinci-resizer Linux davinci resizer and chroma conversion support (default disabled on Linux)])
if test "${enable_davinci_resizer}" = "yes"
then
VLC_ADD_PLUGINS([davinci_resizer])
VLC_ADD_PLUGIN([davinci_resizer])
VLC_ADD_CFLAGS([davinci_resizer],[-I${KNL_INSTALL_DIR}/include])
fi
......@@ -4513,17 +4513,16 @@ dnl
dnl Linux DaVinci codec module
dnl
AC_ARG_ENABLE(davinci,
[ --enable-davinci Linux davinci codec support (default disabled on
Linux)])
[ --enable-davinci Linux davinci codec support (default disabled on Linux)])
if test "${enable_davinci}" = "yes"
then
if ! which ticel-config >/dev/null 2>&1; then
echo "ticel-config not found, required for davinci !"
exit 1
fi
VLC_ADD_PLUGINS([davinci])
VLC_ADD_PLUGIN([davinci])
VLC_ADD_CFLAGS([davinci],[`ticel-config --cflags`])
VLC_ADD_LDFLAGS([davinci],[`ticel-config --libs`])
VLC_ADD_LIBS([davinci],[`ticel-config --libs`])
fi
dnl
......
This diff is collapsed.
SOURCES_davinci = \
davinci.c \
davinci.h \
auddec.c \
viddec.c \
videnc.c \
resizer.c \
reziser.h \
audio.c \
video.c \
fourcc.c \
$(NULL)
# Davinci speed hack
# resizer.c \
# reziser.h
if ENABLE_SOUT
SOURCES_davinci += encoder.c
endif
EXTRA_libdavinci_plugin_la_SOURCES = \
encoder.c \
$(NULL)
/*****************************************************************************
* davinci.c: decoder and encoder modules using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 M2X BV
* Copyright (C) 2008-2009 M2X BV
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
......@@ -24,6 +24,14 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include "davinci.h"
/*****************************************************************************
......@@ -31,14 +39,21 @@
*****************************************************************************/
/*
* Decoder
* Davinci common
*/
#define VIDDEC_CHROMA_TEXT N_( "Decoder output chroma" )
#define VIDDEC_CHROMA_LONGTEXT N_( \
"Force video decoder to output in specific chroma" )
#define DAVINCI_ENGINE_TEXT N_( "DSP firmware library" )
#define DAVINCI_ENGINE_LONGTEXT N_( \
"Specifiy which DSP firmware library to use. By default " \
"a combined encoder/decoder library \"encodedecode\" is used." )
/*
* Decoder
*/
#define VIDDEC_FULLSCREEN_TEXT N_( "Resize video to fullscreen" )
#define DAVINCI_FOURCC_TEXT N_( "Decoder output fourcc/chroma" )
#define DAVINCI_FOURCC_LONGTEXT N_( \
"Force audio/video decoder to output in specific fourcc/chroma" )
/*
* Encoder
......@@ -63,47 +78,65 @@
#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( DEC_CFG_PREFIX "fullscreen", VLC_TRUE, NULL,
VIDDEC_FULLSCREEN_TEXT, VIDDEC_FULLSCREEN_TEXT, VLC_FALSE );
#endif
add_string( DEC_CFG_PREFIX "chroma", "", NULL,
VIDDEC_CHROMA_TEXT, VIDDEC_CHROMA_LONGTEXT, VLC_TRUE );
#define MODULE_DESCRIPTION N_( "Various audio and video decoders/encoders" \
"delivered by TI Davinci library. This includes MPEG4, H264, VC-1, "\
"MPEG1, MPEG2, AAC and MP3 codecs")
vlc_module_begin()
/* audio/video decoder */
set_shortname( "Davinci" )
add_shortcut( "davinci" )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_SCODEC )
set_description( N_("DaVinci DSP audio/video decoder") )
set_help( MODULE_DESCRIPTION )
set_capability( "decoder", 1337 )
set_section( N_("Decoding") , NULL )
set_callbacks( OpenVideoDecoder, CloseVideoDecoder )
add_string( DEC_CFG_PREFIX "engine", "encodedecode", NULL,
DAVINCI_ENGINE_TEXT, DAVINCI_ENGINE_LONGTEXT, true )
add_string( DEC_CFG_PREFIX "fourcc", "", NULL,
DAVINCI_FOURCC_TEXT, DAVINCI_FOURCC_LONGTEXT, true )
/* audio decoder */
add_submodule();
add_submodule()
add_shortcut( "davinci" )
set_description( _("DaVinci DSP audio decoder") );
set_capability( "decoder", 0 );
set_callbacks( OpenAudioDecoder, CloseAudioDecoder );
#ifdef ENABLE_SOUT
/* video encoder */
add_submodule();
set_description( _("DaVinci DSP video encoder" ) );
set_capability( "encoder", 1337 );
set_callbacks( OpenVideoEncoder, CloseVideoEncoder );
add_submodule()
add_shortcut( "davinci" )
set_description( N_("DaVinci DSP video encoder" ) )
set_capability( "encoder", 1337 )
set_section( N_("Encoding") , NULL )
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 );
ENC_KEYINT_LONGTEXT, false )
add_bool( ENC_CFG_PREFIX "interlace", false, NULL, ENC_INTERLACE_TEXT,
ENC_INTERLACE_LONGTEXT, true )
add_integer( ENC_CFG_PREFIX "rc", 1, NULL, ENC_RC_TEXT,
ENC_RC_LONGTEXT, VLC_TRUE );
change_integer_range( 0, 5 );
ENC_RC_LONGTEXT, true )
change_integer_range( 0, 5 )
add_integer( ENC_CFG_PREFIX "tolerance", 0, NULL, ENC_VT_TEXT,
ENC_VT_LONGTEXT, VLC_TRUE );
ENC_VT_LONGTEXT, 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();
ENC_QUALITY_LONGTEXT, true )
change_integer_range( 0, 3 )
#endif
#if 0
/* video filter submodule */
add_submodule ()
set_capability( "video filter2", 0 )
set_callbacks( OpenResizer, CloseResizer )
set_description( N_("Davinci resizer video filter") )
add_shortcut( "davinci-resizer" )
#endif
vlc_module_end()
/*****************************************************************************
* Memory utils
......@@ -225,40 +258,3 @@ void __PrintAvailableAlgorithms( vlc_object_t *p_this, const char *psz_engine )
}
}
}
XDAS_Int32 VlcChromaToXdm( vlc_fourcc_t i_chroma )
{
switch( i_chroma )
{
case VLC_FOURCC('I','4','2','0'):
return XDM_YUV_420P;
case VLC_FOURCC('I','4','1','1'):
return XDM_YUV_411P;
case VLC_FOURCC('I','4','2','2'):
return XDM_YUV_422P;
case VLC_FOURCC('I','4','4','4'):
return XDM_YUV_444P;
case VLC_FOURCC('Y','U','Y','V'):
return XDM_YUV_422IBE; /* FIXME ? */
case VLC_FOURCC('U','Y','V','Y'):
return XDM_YUV_422ILE; /* FIXME ? */
case VLC_FOURCC('G','R','E','Y'):
return XDM_GRAY;
#if 0
/* FIXME: not sure about this one */
case VLC_FOURCC('R','V','2','4'):
case VLC_FOURCC('R','V','3','2'):
return XDM_RGB;
#endif
default:
return XDM_CHROMA_NA;
}
}
/*****************************************************************************
* davinci.h: decoder and encoder modules using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 M2X BV
* Copyright (C) 2008-2009 M2X BV
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
* 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
......@@ -24,9 +25,6 @@
#ifndef VLC_DAVINCI_H
#define VLC_DAVINCI_H
#include <vlc/vlc.h>
#include <vlc/decoder.h>
#define XDM_INCLUDE_DOT9_SUPPORT /* Support old 0.9 API */
#include <gnu/targets/std.h>
#include <xdc/std.h>
......@@ -35,12 +33,10 @@
#include <ti/sdo/ce/CERuntime.h>
#include <ti/sdo/ce/Engine.h>
#define DEBUG_DAVINCI
#define DAVINCI_HACK /* directly resize and output the decoded video */
#define TI_ENGINE "encodedecode"
#undef DEBUG_DAVINCI
#define ENC_CFG_PREFIX "davinci-videnc-"
#define DEC_CFG_PREFIX "davinci-viddec-"
#define ENC_CFG_PREFIX "sout-davinci-"
#define DEC_CFG_PREFIX "davinci-"
int OpenVideoDecoder( vlc_object_t * );
void CloseVideoDecoder( vlc_object_t * );
......@@ -57,132 +53,15 @@ void FreeBuffer( XDM_BufDesc * );
const char *davinci_GetExtendedError( XDAS_Int32 );
void __PrintAvailableAlgorithms( vlc_object_t *, const char * );
#define PrintAvailableAlgorithms( a, b ) __PrintAvailableAlgorithms( VLC_OBJECT( a ), b )
XDAS_Int32 VlcChromaToXdm( vlc_fourcc_t );
/*****************************************************************************
* Common stuff
*****************************************************************************/
extern const char *ppsz_engine_error[];
/* 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'): \
/* MSMPEG4 v1 (Not sure that we should include these) */ \
case VLC_FOURCC('D','I','V','1'): \
case VLC_FOURCC('d','i','v','1'): \
case VLC_FOURCC('M','P','G','4'): \
case VLC_FOURCC('m','p','g','4'): \
/* MSMPEG4 v2 (Not sure that we should include these) */ \
case VLC_FOURCC('D','I','V','2'): \
case VLC_FOURCC('d','i','v','2'): \
case VLC_FOURCC('M','P','4','2'): \
case VLC_FOURCC('m','p','4','2'): \
/* MSMPEG4 v3 (Not sure that we should include these) */ \
case VLC_FOURCC('M','P','G','3'): \
case VLC_FOURCC('m','p','g','3'): \
case VLC_FOURCC('d','i','v','3'): \
case VLC_FOURCC('M','P','4','3'): \
case VLC_FOURCC('m','p','4','3'): \
case VLC_FOURCC('D','I','V','3'): \
case VLC_FOURCC('D','I','V','4'): \
case VLC_FOURCC('d','i','v','4'): \
case VLC_FOURCC('D','I','V','5'): \
case VLC_FOURCC('d','i','v','5'): \
case VLC_FOURCC('D','I','V','6'): \
case VLC_FOURCC('d','i','v','6'): \
case VLC_FOURCC('C','O','L','1'): \
case VLC_FOURCC('c','o','l','1'): \
case VLC_FOURCC('C','O','L','0'): \
case VLC_FOURCC('c','o','l','0'): \
case VLC_FOURCC('A','P','4','1'): \
case VLC_FOURCC('3','I','V','D'): \
case VLC_FOURCC('3','i','v','d'): \
case VLC_FOURCC('3','V','I','D'): \
case VLC_FOURCC('3','v','i','d'):
#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','g','a'): \
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'):
bool GetDavinciDecoder( vlc_fourcc_t, int *, const char **, const char ** );
bool GetDavinciEncoder( vlc_fourcc_t, int *, const char **, const char ** );
bool GetVlcFourcc( const char *, int *, vlc_fourcc_t *, const char ** );
XDAS_Int32 VlcChromaToXdm( vlc_fourcc_t );
#endif
/*****************************************************************************
* videnc.c: video encoder module using the DaVinci DSP.
* encoder.c: video encoder module using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 M2X BV
* Copyright (C) 2008-2009 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
......@@ -25,11 +26,22 @@
/*****************************************************************************
* 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"
#include <assert.h>
#include <ti/sdo/ce/video/videnc.h>
#include <assert.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -40,6 +52,8 @@ static block_t *EncodeVideo( encoder_t *, picture_t * );
*****************************************************************************/
struct encoder_sys_t
{
char *psz_ti_engine;
Engine_Handle e;
VIDENC_Handle c;
......@@ -50,102 +64,36 @@ struct encoder_sys_t
/*****************************************************************************
*
*****************************************************************************/
static void picfree( picture_t *p_pic )
{
if( p_pic->i_type == MEMORY_PICTURE )
free( p_pic->p_data_orig );
free( p_pic );
}
static picture_t * NewEncoderBuffer( encoder_t *p_enc, decoder_t *p_dec )
{
p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
picture_t *p_pic = malloc(sizeof(picture_t));
if( !p_pic ) return NULL;
if( !p_enc->p_sys->in.numBufs )
{
vout_AllocatePicture( p_dec, p_pic,
p_dec->fmt_out.video.i_chroma,
p_dec->fmt_out.video.i_width,
p_dec->fmt_out.video.i_height,
p_dec->fmt_out.video.i_aspect );
if( !p_pic->i_planes )
{
free( p_pic );
return NULL;
}
p_pic->i_type = MEMORY_PICTURE;
}
else
{
p_pic->i_planes = 1;
vout_InitPicture( p_dec, p_pic,
p_dec->fmt_out.video.i_chroma,
p_dec->fmt_out.video.i_width,
p_dec->fmt_out.video.i_height,
p_dec->fmt_out.video.i_aspect );
p_pic->p_data = p_enc->p_sys->in.bufs[0];
p_pic->p_data_orig = NULL;
p_pic->p[0].p_pixels = p_pic->p_data;
p_pic->i_type = DIRECT_PICTURE;
}
p_pic->pf_release = picfree;
p_pic->i_status = RESERVED_PICTURE;
p_pic->p_sys = NULL;
return p_pic;
}
int OpenVideoEncoder( vlc_object_t *p_this )
{
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
char *psz_codec = NULL;
Engine_Error err;
VIDENC_Params params;
int i_cat;
const char *psz_codec;
const char *psz_namecodec;
switch( p_enc->fmt_out.i_codec )
if( !GetDavinciEncoder( p_enc->fmt_out.i_codec, &i_cat,
&psz_codec, &psz_namecodec ) )
{
#if 0
CASE_MPEG1
psz_codec = strdup( "mpegenc" ); /* FIXME */
break;
CASE_MPEG2
psz_codec = strdup( "mpeg2enc" ); /* FIXME */
break;
#endif
CASE_MPEG4
psz_codec = strdup( "mpeg4enc" );
break;
CASE_H264
psz_codec = strdup( "h264enc" );
break;
#if 0
CASE_VC1
psz_codec = strdup( "vc1enc" ); /* FIXME */
break;
#endif
default:
return VLC_EGENERIC;
msg_Dbg( p_enc, "Unsupported codec : %4.4s",(char*)&p_enc->fmt_in.i_codec );
return VLC_EGENERIC;
}
/* Allocate our private structure */
p_enc->p_sys = (encoder_sys_t *)malloc( sizeof( encoder_sys_t ) );
p_enc->p_sys = (encoder_sys_t *)calloc( 1, sizeof( encoder_sys_t ) );
if( !p_enc->p_sys )
return VLC_ENOMEM;
p_sys = p_enc->p_sys;
memset( p_sys, 0, sizeof( encoder_sys_t ) );
p_sys->psz_ti_engine = var_CreateGetString( p_enc, DEC_CFG_PREFIX "engine" );
if( !p_sys->psz_ti_engine )
{
free( p_sys );
return VLC_ENOMEM;
}
/* FIXME: number of frames between 2 keyframes */
p_enc->i_iframes = var_CreateGetInteger( p_enc, ENC_CFG_PREFIX "keyint" );
......@@ -156,15 +104,15 @@ int OpenVideoEncoder( vlc_object_t *p_this )
CERuntime_init();
/* Create an engine handle */
p_sys->e = Engine_open( TI_ENGINE, NULL /*&Engine_ATTRS*/, &err );
p_sys->e = Engine_open( p_sys->psz_ti_engine, NULL /*&Engine_ATTRS*/, &err );
if( err != Engine_EOK )
{
msg_Err( p_enc, "Error while opening engine `%s': %s",
TI_ENGINE, ppsz_engine_error[err] );
p_sys->psz_ti_engine, ppsz_engine_error[err] );
goto error;
}
PrintAvailableAlgorithms( p_this, TI_ENGINE );
PrintAvailableAlgorithms( p_this, p_sys->psz_ti_engine );
/* Configure encoder */
params.size = sizeof( params );
......@@ -214,10 +162,10 @@ int OpenVideoEncoder( vlc_object_t *p_this )
params.inputChromaFormat = VlcChromaToXdm( VLC_FOURCC('I','4','2','0' ) );
}
/* FIXME: we don't know if it's progressive or interlaced
/* NOTE: 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 )
if( var_CreateGetBool( p_enc, ENC_CFG_PREFIX "interlace" ) )
params.inputContentType = IVIDEO_INTERLACED;
else
params.inputContentType = IVIDEO_PROGRESSIVE;
......@@ -226,22 +174,21 @@ int OpenVideoEncoder( vlc_object_t *p_this )
p_sys->c = VIDENC_create( p_sys->e, (String)psz_codec, &params );
if( !p_sys->c )
{
msg_Err( p_enc, "Failed to create video encoder (%s)", psz_codec );
msg_Err( p_enc, "Failed to create video encoder (%s) for %s",
psz_codec, psz_namecodec );
goto error;
}
/* Initialize random stuff */
p_enc->pf_encode_video = EncodeVideo;
p_enc->pf_enc_buffer_new = NewEncoderBuffer;
free( psz_codec );
return VLC_SUCCESS;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys );
free( psz_codec );
return VLC_EGENERIC;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys->psz_ti_engine );
free( p_sys );
return VLC_EGENERIC;
}
/*****************************************************************************
......@@ -265,12 +212,30 @@ void CloseVideoEncoder( vlc_object_t *p_this )
FreeBuffer( &p_sys->in );
FreeBuffer( &p_sys->out );
free( p_sys->psz_ti_engine );
free( p_sys );
}
/*****************************************************************************
*
*****************************************************************************/
static inline void davinci_CopyPictureToXDM( decoder_t *p_dec, XDM_BufDesc *p_buf, picture_t *p_pic )
{
/* Copy input picture */
assert( p_pic->i_planes == p_buf->numBufs );
assert( p_pic->i_planes == 1 );
for( int i = 0; i < p_pic->i_planes; i++ )
{
if( p_pic->i_type == MEMORY_PICTURE )
{
plane_t *p = p_pic->p + i;
memcpy( p_buf->bufs[i], p->p_pixels, p->i_pitch * p->i_visible_lines );
}
/* if it's our direct buffer, we have nothing to do */
}
}
static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
{
encoder_sys_t *p_sys = p_enc->p_sys;
......@@ -346,6 +311,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
}
}
#if 1
/* Copy input picture */
assert( p_pic->i_planes == p_sys->in.numBufs );
assert( p_pic->i_planes == 1 );
......@@ -359,7 +325,9 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
}
/* if it's our direct buffer, we have nothing to do */
}
#else
davinci_CopyPictureToXDM( p_dec, p_sys->in, p_pic );
#endif
/* Configure input */
in_args.size = sizeof( in_args );
......@@ -412,12 +380,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
p_block->i_dts = p_block->i_pts = p_pic->date;
/* Shamelessly copied from ffmpeg/encoder.c */
p_block->i_length = I64C(1000000) *
p_block->i_length = INT64_C(1000000) *
p_enc->fmt_in.video.i_frame_rate_base /
p_enc->fmt_in.video.i_frame_rate;
return p_block;
error:
return NULL;
error:
return NULL;
}
/*****************************************************************************
* viddec.c: video decoder module using the DaVinci DSP.
* fb.c: video decoder module using the DaVinci DSP.
*****************************************************************************
* Copyright (C) 2008 M2X BV
* Copyright (C) 2008-2009 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
......@@ -25,11 +26,21 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_codec.h>
#include <vlc_vout.h>
#include <vlc_codecs.h>
#include "davinci.h"
#include <assert.h>
#include <ti/sdo/ce/video/viddec.h>
#define DAVINCI_HACK /* directly resize and output the decoded video */
#ifdef DAVINCI_HACK
#include "resizer.h"
#endif
......@@ -45,6 +56,7 @@ static picture_t *DecodeVideoBlockInner( decoder_t *, block_t **, int );
*****************************************************************************/
struct decoder_sys_t
{
char *psz_ti_engine;
Engine_Handle e;
VIDDEC_Handle d;
......@@ -60,7 +72,7 @@ struct decoder_sys_t
/* resizer */
davinci_resizer_t rsz;
vlc_bool_t b_resize;
bool b_resize;
vlc_mutex_t cb_lock;
#endif
};
......@@ -95,17 +107,13 @@ int OpenVideoDecoder( vlc_object_t *p_this )
switch( p_dec->fmt_in.i_codec )
{
/* enable the following if you bought the codecs from TI */
#if 0
CASE_VC1
psz_codec = strdup( "vc1dec" );
break;
#endif
#if 0
psz_codec = strdup( "vc1dec" );
break;
CASE_MPEG1
psz_codec = strdup( "mpegdec" );
break;
#endif
CASE_MPEG2
psz_codec = strdup( "mpeg2dec" );
......@@ -124,31 +132,38 @@ int OpenVideoDecoder( vlc_object_t *p_this )
}
/* Allocate our private structure */
p_dec->p_sys = (decoder_sys_t *)malloc( sizeof( decoder_sys_t ) );
p_dec->p_sys = (decoder_sys_t *)calloc( 1, sizeof( decoder_sys_t ) );
if( !p_dec->p_sys )
{
free( psz_codec );
return VLC_ENOMEM;
}
p_sys = p_dec->p_sys;
memset( p_sys, 0, sizeof( decoder_sys_t ) );
p_sys->psz_ti_engine = var_CreateGetString( DEC_CFG_PREFIX "engine" );
if( !p_sys->psz_ti_engine )
{
free( psz_codec );
free( p_sys );
return VLC_ENOMEM;
}
/* Initialize the codec engine */
CERuntime_init();
/* Create an engine handle */
p_sys->e = Engine_open( TI_ENGINE, NULL /*&Engine_ATTRS*/, &err );
p_sys->e = Engine_open( p_sys->psz_ti_engine, NULL /*&Engine_ATTRS*/, &err );
if( err != Engine_EOK )
{
msg_Err( p_dec, "Error while opening engine `%s': %s",
TI_ENGINE, ppsz_engine_error[err] );
p_sys->psz_ti_engine, ppsz_engine_error[err] );
goto error;
}
PrintAvailableAlgorithms( p_this, TI_ENGINE );
PrintAvailableAlgorithms( p_this, p_sys->psz_ti_engine );
/* Get user supplied chroma setting */
psz_chroma = config_GetPsz( p_dec, "davinci-viddec-chroma" );
psz_chroma = config_GetPsz( p_dec, DEC_CFG_PREFIX "chroma" );
if( psz_chroma && strlen( psz_chroma ) == 4 )
{
i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
......@@ -204,8 +219,8 @@ int OpenVideoDecoder( vlc_object_t *p_this )
goto error;
}
p_sys->b_resize = var_CreateGetBool( p_dec, "davinci-viddec-fullscreen" );
var_AddCallback( p_dec, "davinci-viddec-fullscreen", fullscreen_cb, p_sys );
p_sys->b_resize = var_GetBool( p_dec->p_libvlc, "fullscreen" );
var_AddCallback( p_dec->p_libvlc, "fullscreen", fullscreen_cb, p_sys );
vlc_mutex_init( p_this, &p_sys->cb_lock );
#endif
......@@ -213,13 +228,14 @@ int OpenVideoDecoder( vlc_object_t *p_this )
p_dec->pf_decode_video = DecodeVideoBlock;
/* DaVinci decoder needs complete frames */
p_dec->b_need_packetized = VLC_TRUE;
p_dec->b_need_packetized = true;
free( psz_codec );
return VLC_SUCCESS;
error:
if( p_sys->e ) Engine_close( p_sys->e );
free( p_sys->psz_ti_engine );
free( p_sys );
free( psz_codec );
return VLC_EGENERIC;
......@@ -257,6 +273,7 @@ void CloseVideoDecoder( vlc_object_t *p_this )
FreeBuffer( &p_sys->in );
FreeBuffer( &p_sys->out );
free( p_sys->psz_ti_engine );
free( p_sys );
}
......@@ -278,7 +295,7 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
VIDDEC_Status status;
int i;
if( !p_sys->p_packetizer &&
if( !p_sys->p_packetizer &&
p_dec->fmt_in.i_codec == VLC_FOURCC( 'a', 'v', 'c', '1' ) )
{
p_sys->p_packetizer = vlc_object_create( p_dec, VLC_OBJECT_PACKETIZER );
......@@ -311,8 +328,7 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
if( p_sys->p_packetizer && !i_extra )
{
block_t *p_new_block = p_sys->p_packetizer->pf_packetize(
p_sys->p_packetizer, &p_block );
block_t *p_new_block = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, &p_block );
*pp_block = p_block = p_new_block; /* keep refernce to packetized blk */
if( !p_block )
......@@ -444,8 +460,8 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
msg_Err( p_dec, "Could not get picture" );
goto error;
}
p_pic->b_progressive = status.contentType == IVIDEO_INTERLACED ? VLC_FALSE
: VLC_TRUE;
p_pic->b_progressive = status.contentType == IVIDEO_INTERLACED ? false
: true;
#endif
#ifdef DEBUG_DAVINCI
switch( out_args.decodedFrameType )
......@@ -497,7 +513,7 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
#else
vlc_mutex_lock( &p_sys->cb_lock );
vlc_bool_t b_resize = p_sys->b_resize;
bool b_resize = p_sys->b_resize;
vlc_mutex_unlock( &p_sys->cb_lock );
Resize( p_dec, b_resize, &p_sys->rsz, &p_sys->fb, p_sys->out );
......
This diff is collapsed.
/*****************************************************************************
* resizer.c: Resize pictures directly into framebuffer (DaVinci specific)
*****************************************************************************
* Copyright (C) 2008 M2X BV
* Copyright (C) 2008-2009 M2X BV
*
* Authors: 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
......@@ -233,7 +234,7 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
}
}
void Resize( decoder_t *p_dec, vlc_bool_t b_scale, davinci_resizer_t *rsz,
void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
davinci_fb_t *fb, XDM_BufDesc out )
{
if( !rsz->i_yuyv )
......@@ -481,7 +482,7 @@ void DavinciClose( davinci_fb_t *fb, davinci_resizer_t *rsz )
for( i = 0 ; i < i_display_size ; i++ )
((uint32_t*)fb->p_map)[i] = 0x10801080;
munmap( fb->p_map, i_display_size );
}
......
/*****************************************************************************
* resizer.c: Resize pictures directly into framebuffer (DaVinci specific)
*****************************************************************************
* Copyright (C) 2008 M2X BV
* Copyright (C) 2008-2009 M2X BV
*
* Authors: Rafaël Carré <rcarre@m2x.nl>
*
......@@ -64,10 +64,10 @@ typedef struct
unsigned int i_out_width;
unsigned int i_out_height;
vlc_bool_t b_direct;
bool b_direct;
} davinci_resizer_t;
void Resize( decoder_t *, vlc_bool_t, davinci_resizer_t *, davinci_fb_t *,
void Resize( decoder_t *, bool, davinci_resizer_t *, davinci_fb_t *,
XDM_BufDesc );
int DavinciInit( decoder_t *, davinci_fb_t *, davinci_resizer_t * );
void DavinciClose( davinci_fb_t *, davinci_resizer_t * );
......
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