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

Davinci decoder: New option "no-davinci-viddec-fullscreen" will let you

disable davinci resizer. (1:1 mode not implemented yet)
Signed-off-by: Jean-Paul Saman's avatarJean-Paul Saman <jean-paul.saman@m2x.nl>
parent 8e62eafb
......@@ -33,12 +33,18 @@
#define VIDDEC_CHROMA_LONGTEXT N_( \
"Force video decoder to output in specific chroma" )
#define VIDDEC_FULLSCREEN_TEXT N_( "Resize video to fullscreen" )
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 );
#ifdef DAVINCI_HACK
add_bool( "davinci-viddec-fullscreen", VLC_TRUE, fullscreen_cb,
VIDDEC_FULLSCREEN_TEXT, VIDDEC_FULLSCREEN_TEXT, VLC_FALSE );
#endif
add_string( "davinci-viddec-chroma", "", NULL,
VIDDEC_CHROMA_TEXT, VIDDEC_CHROMA_LONGTEXT, VLC_TRUE );
......@@ -211,4 +217,3 @@ XDAS_Int32 VlcChromaToXdm( vlc_fourcc_t i_chroma )
return XDM_CHROMA_NA;
}
}
......@@ -36,9 +36,14 @@
#include <ti/sdo/ce/Engine.h>
#define DEBUG_DAVINCI
#define DAVINCI_HACK /* directly resize and output the decoded video */
int OpenVideoDecoder( vlc_object_t * );
void CloseVideoDecoder( vlc_object_t * );
#ifdef DAVINCI_HACK
int fullscreen_cb( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
#endif
int OpenAudioDecoder( vlc_object_t * );
void CloseAudioDecoder( vlc_object_t * );
......
......@@ -29,8 +29,6 @@
#include <assert.h>
#include <ti/sdo/ce/video/viddec.h>
#define DAVINCI_HACK /* directly resize and output the decoded video */
#ifdef DAVINCI_HACK
#include <sys/types.h>
#include <sys/stat.h>
......@@ -79,8 +77,8 @@ struct decoder_sys_t
int i_fd_resizer;
unsigned int i_height;
unsigned int i_width;
vlc_bool_t b_resize;
#endif
};
......@@ -88,6 +86,7 @@ struct decoder_sys_t
static void Resize( decoder_t *p_dec,
unsigned int *i_width, unsigned int *i_height )
{
/* FIXME : take aspect ratio in account */
unsigned int i_vidw = p_dec->fmt_out.video.i_width;
unsigned int i_vidh = p_dec->fmt_out.video.i_height;
unsigned int i_hratio = VOUT_ASPECT_FACTOR * *i_height / i_vidh;
......@@ -342,6 +341,7 @@ int OpenVideoDecoder( vlc_object_t *p_this )
memset( p_sys, 0, sizeof( decoder_sys_t ) );
#ifdef DAVINCI_HACK
p_sys->i_fd_fb = p_sys->i_fd_resizer = -1;
p_sys->b_resize = var_CreateGetBool( p_dec, "davinci-viddec-fullscreen" );
#endif
/* Initialize the codec engine */
......@@ -748,104 +748,117 @@ static picture_t *DecodeVideoBlockInner( decoder_t *p_dec, block_t **pp_block, i
}
#else
/* Sets resizer parameters when video starts or when resolution changes */
if( p_sys->i_width != p_dec->fmt_out.video.i_width ||
p_sys->i_height != p_dec->fmt_out.video.i_height )
if( p_sys->b_resize )
{
rsz_params_t rsz_params;
memset( &rsz_params, 0, sizeof( rsz_params ) );
rsz_params.in_hsize = p_sys->i_width = p_dec->fmt_out.video.i_width;
rsz_params.in_vsize = p_sys->i_height = p_dec->fmt_out.video.i_height;
rsz_params.in_pitch =
(p_dec->fmt_out.video.i_width * BPP / 8 + 31) & ~31;
rsz_params.inptyp = RSZ_INTYPE_YCBCR422_16BIT;
rsz_params.pix_fmt = RSZ_PIX_FMT_YUYV;
/* Sets the destination resolution */
rsz_params.out_hsize = p_sys->var_info.xres;
rsz_params.out_vsize = p_sys->var_info.yres;
/* And then modify it to keep the same aspect ratio */
Resize( p_dec, &rsz_params.out_hsize, &rsz_params.out_vsize );
/* RSZ_PIX_FMT_YUYV is 2 bytes per pixel */
rsz_params.out_pitch = ( rsz_params.out_hsize * 2 + 15 ) & ~15;
short hcoefs[32] = {
0, 256, 0, 0,
-11, 245, 23, -1,
-17, 220, 58, -5,
-18, 184, 100, -10,
-15, 143, 143, -15,
-10, 100, 184, -18,
-5, 58, 220, -17,
-1, 23, 245, -11
};
short vcoefs[32] = {
0, 256, 0, 0,
-11, 245, 23, -1,
-17, 220, 58, -5,
-18, 184, 100, -10,
-15, 143, 143, -15,
-10, 100, 184, -18,
-5, 58, 220, -17,
-1, 23, 245, -11
};
/* HACK HACK HACK : use --davinci-viddec-chroma resize
* to not compute coefficients */
char *psz_chroma= var_CreateGetString( p_dec, "davinci-viddec-chroma" );
if( psz_chroma && strcmp( psz_chroma, "resize" ) )
/* Sets resizer parameters when video starts or when resolution changes */
if( p_sys->i_width != p_dec->fmt_out.video.i_width ||
p_sys->i_height != p_dec->fmt_out.video.i_height )
{
get_coeffs( hcoefs , rsz_params.in_hsize, rsz_params.out_hsize );
get_coeffs( vcoefs , rsz_params.in_vsize, rsz_params.out_vsize );
}
free( psz_chroma );
rsz_params_t rsz_params;
memset( &rsz_params, 0, sizeof( rsz_params ) );
rsz_params.in_hsize = p_sys->i_width = p_dec->fmt_out.video.i_width;
rsz_params.in_vsize = p_sys->i_height = p_dec->fmt_out.video.i_height;
rsz_params.in_pitch =
(p_dec->fmt_out.video.i_width * BPP / 8 + 31) & ~31;
rsz_params.inptyp = RSZ_INTYPE_YCBCR422_16BIT;
rsz_params.pix_fmt = RSZ_PIX_FMT_YUYV;
/* Sets the destination resolution */
rsz_params.out_hsize = p_sys->var_info.xres;
rsz_params.out_vsize = p_sys->var_info.yres;
/* And then modify it to keep the same aspect ratio */
Resize( p_dec, &rsz_params.out_hsize, &rsz_params.out_vsize );
/* RSZ_PIX_FMT_YUYV is 2 bytes per pixel */
rsz_params.out_pitch = ( rsz_params.out_hsize * 2 + 15 ) & ~15;
short hcoefs[32] = {
0, 256, 0, 0,
-11, 245, 23, -1,
-17, 220, 58, -5,
-18, 184, 100, -10,
-15, 143, 143, -15,
-10, 100, 184, -18,
-5, 58, 220, -17,
-1, 23, 245, -11
};
short vcoefs[32] = {
0, 256, 0, 0,
-11, 245, 23, -1,
-17, 220, 58, -5,
-18, 184, 100, -10,
-15, 143, 143, -15,
-10, 100, 184, -18,
-5, 58, 220, -17,
-1, 23, 245, -11
};
/* HACK HACK HACK : use --davinci-viddec-chroma resize
* to not compute coefficients */
char *psz_chroma= var_CreateGetString( p_dec, "davinci-viddec-chroma" );
if( psz_chroma && strcmp( psz_chroma, "resize" ) )
{
get_coeffs( hcoefs , rsz_params.in_hsize, rsz_params.out_hsize );
get_coeffs( vcoefs , rsz_params.in_vsize, rsz_params.out_vsize );
}
free( psz_chroma );
for( i = 0; i < 32; i++ )
{
rsz_params.hfilt_coeffs[i] = hcoefs[i];
rsz_params.vfilt_coeffs[i] = vcoefs[i];
}
for( i = 0; i < 32; i++ )
{
rsz_params.hfilt_coeffs[i] = hcoefs[i];
rsz_params.vfilt_coeffs[i] = vcoefs[i];
}
rsz_params.yenh_params.type = RSZ_YENH_DISABLE;
rsz_params.yenh_params.type = RSZ_YENH_DISABLE;
if( ioctl( p_sys->i_fd_resizer, RSZ_S_PARAM, &rsz_params ) )
{
msg_Err( p_dec, "Failed setting resizer parameters: "
"%dx%d (pitch %d) -> %dx%d (pitch %d) : %m",
rsz_params.in_hsize, rsz_params.in_vsize, rsz_params.in_pitch,
rsz_params.out_hsize, rsz_params.out_vsize, rsz_params.out_pitch
);
if( ioctl( p_sys->i_fd_resizer, RSZ_S_PARAM, &rsz_params ) )
{
msg_Err( p_dec, "Failed setting resizer parameters: "
"%dx%d (pitch %d) -> %dx%d (pitch %d) : %m",
rsz_params.in_hsize, rsz_params.in_vsize, rsz_params.in_pitch,
rsz_params.out_hsize, rsz_params.out_vsize, rsz_params.out_pitch
);
goto error;
goto error;
}
}
}
rsz_resize_t rsz;
rsz.in_buf.index = -1;
rsz.in_buf.buf_type = RSZ_BUF_IN;
rsz.in_buf.size =
p_dec->fmt_out.video.i_height *
((p_dec->fmt_out.video.i_width * BPP / 8 + 31) & ~31);
rsz.in_buf.offset = Memory_getBufferPhysicalAddress(
p_sys->out.bufs[0], rsz.in_buf.size, NULL );
assert( rsz.in_buf.offset );
rsz.out_buf.index = -1;
rsz.out_buf.buf_type = RSZ_BUF_OUT;
rsz.out_buf.offset = p_sys->p_physbufs[0]; /* FIXME: use NUM_BUFFERS */
rsz.out_buf.size = p_sys->var_info.xres * p_sys->var_info.yres_virtual;
while(1)
{
if( ioctl( p_sys->i_fd_resizer, RSZ_RESIZE, &rsz ) == -1 )
rsz_resize_t rsz;
rsz.in_buf.index = -1;
rsz.in_buf.buf_type = RSZ_BUF_IN;
rsz.in_buf.size =
p_dec->fmt_out.video.i_height *
((p_dec->fmt_out.video.i_width * BPP / 8 + 31) & ~31);
rsz.in_buf.offset = Memory_getBufferPhysicalAddress(
p_sys->out.bufs[0], rsz.in_buf.size, NULL );
assert( rsz.in_buf.offset );
rsz.out_buf.index = -1;
rsz.out_buf.buf_type = RSZ_BUF_OUT;
rsz.out_buf.offset = p_sys->p_physbufs[0]; /* FIXME: use NUM_BUFFERS */
rsz.out_buf.size = p_sys->var_info.xres * p_sys->var_info.yres_virtual;
while(1)
{
if( errno == EAGAIN ) continue;
if( ioctl( p_sys->i_fd_resizer, RSZ_RESIZE, &rsz ) == -1 )
{
if( errno == EAGAIN ) continue;
msg_Err( p_dec, "Resizing failed (%m)" );
abort();
goto error;
msg_Err( p_dec, "Resizing failed (%m)" );
abort();
goto error;
}
break;
}
break;
}
else
{
/* FIXME */
/*
* We should output black bars for the top and bottom
* Then for each line, output black at the left and right of video
* Then output the line at the center of the video
*/
;
}
int i_dummy;
......@@ -868,3 +881,13 @@ error:
block_Release( p_block );
return NULL;
}
#ifdef DAVINCI_HACK
int fullscreen_cb( vlc_object_t *p_this, const char *psz_var,
vlc_value_t old, vlc_value_t new, void * p_data )
{
((decoder_t*)p_this)->p_sys->b_resize = new.b_bool;
return VLC_SUCCESS;
}
#endif
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