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

Fix davinci resizer module. Now works with UYVY as input and output. Example...

Fix davinci resizer module. Now works with UYVY as input and output. Example command line to decode stuff and resize to full TV size: ./vlc -vvv -I rc --color --no-audio --plugin-path modules --no-plugins-cache ../sw_8M.mov -V davincifb --fb-width 720 --fb-height 480 --davinci-viddec-chroma UYVY --file-logging --logfile ../output/vlc-log.txt
Signed-off-by: Jean-Paul Saman's avatarJean-Paul Saman <jean-paul.saman@m2x.nl>
parent d50294c0
...@@ -37,17 +37,6 @@ ...@@ -37,17 +37,6 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/vout.h> #include <vlc/vout.h>
/* Use some memory buffers from the device ... slower */
#define USE_BUFFERS
#ifndef USE_BUFFERS
/* Hack alert */
# define PAGE_OFFSET -0x40000000
# define PHYS_OFFSET -0x80000000
# define virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
# define phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
#endif
/***************************************************************************** /*****************************************************************************
* Local and extern prototypes. * Local and extern prototypes.
*****************************************************************************/ *****************************************************************************/
...@@ -55,9 +44,7 @@ static int Open( vlc_object_t * ); ...@@ -55,9 +44,7 @@ static int Open( vlc_object_t * );
static void Close( vlc_object_t * ); static void Close( vlc_object_t * );
static void Convert( vout_thread_t *, picture_t *, picture_t * ); static void Convert( vout_thread_t *, picture_t *, picture_t * );
#ifdef USE_BUFFERS
static uint8_t *GetBuffer( vout_thread_t *p_vout, int buf_type, int size, int *offset ); static uint8_t *GetBuffer( vout_thread_t *p_vout, int buf_type, int size, int *offset );
#endif
struct chroma_sys_t struct chroma_sys_t
{ {
...@@ -69,6 +56,8 @@ struct chroma_sys_t ...@@ -69,6 +56,8 @@ struct chroma_sys_t
int i_in_size; int i_in_size;
uint8_t *p_out; uint8_t *p_out;
int i_out_size; int i_out_size;
vlc_bool_t b_inited;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -76,7 +65,7 @@ struct chroma_sys_t ...@@ -76,7 +65,7 @@ struct chroma_sys_t
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
set_description( _("Conversions using /dev/davinci_resizer") ); set_description( _("Conversions using /dev/davinci_resizer") );
set_capability( "chroma", 0 /* FIXME once this module works */ ); set_capability( "chroma", 200 );
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
...@@ -89,9 +78,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -89,9 +78,12 @@ static int Open( vlc_object_t *p_this )
switch( p_vout->render.i_chroma ) switch( p_vout->render.i_chroma )
{ {
case VLC_FOURCC('Y','V','1','2'): /*case VLC_FOURCC('Y','V','1','2'):
case VLC_FOURCC('I','4','2','0'): case VLC_FOURCC('I','4','2','0'):
case VLC_FOURCC('I','Y','U','V'): case VLC_FOURCC('I','Y','U','V'):*/
case VLC_FOURCC('U','Y','V','Y'):
case VLC_FOURCC('U','Y','N','V'):
case VLC_FOURCC('Y','4','2','2'):
switch( p_vout->output.i_chroma ) switch( p_vout->output.i_chroma )
{ {
case VLC_FOURCC('U','Y','V','Y'): case VLC_FOURCC('U','Y','V','Y'):
...@@ -119,92 +111,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -119,92 +111,13 @@ static int Open( vlc_object_t *p_this )
p_sys->i_fd = open( "/dev/davinci_resizer", O_RDWR ); p_sys->i_fd = open( "/dev/davinci_resizer", O_RDWR );
if( p_sys->i_fd == -1 ) if( p_sys->i_fd == -1 )
{ {
msg_Err( p_vout, "Failed to open /dev/davinci_resizer (%m)" ); msg_Err( p_vout, "Failed to open /dev/davinci_resizer (%m)." );
goto err; goto err;
} }
msg_Info( p_vout, "/dev/davinci_resizer opened (" msg_Info( p_vout, "/dev/davinci_resizer opened (using buffers)" );
#ifdef USE_BUFFERS
"using buffers"
#else
"not using buffers"
#endif
")" );
/**
* Get the input and output buffers
*/
p_sys->i_in_size = (p_vout->render.i_width*p_vout->render.i_height*3)/2;
#ifdef USE_BUFFERS
p_sys->p_in = GetBuffer( p_vout, RSZ_BUF_IN, p_sys->i_in_size, &p_sys->resize.in_buf.offset );
if( !p_sys->p_in ) goto err;
p_sys->resize.in_buf.index = 0;
#endif
p_sys->i_out_size = p_vout->output.i_width*p_vout->output.i_height*2;
#ifdef USE_BUFFERS
p_sys->p_out = GetBuffer( p_vout, RSZ_BUF_OUT, p_sys->i_out_size, &p_sys->resize.out_buf.offset );
if( !p_sys->p_out ) goto err;
p_sys->resize.out_buf.index = 0;
#endif
/** p_sys->b_inited = VLC_FALSE;
* Set the parameters
*/
rsz_params_t params;
memset( &params, 0, sizeof( params ) );
params.in_hsize = p_vout->render.i_width;
params.in_vsize = p_vout->render.i_height;
params.in_pitch = p_vout->render.i_width * 2; /* FIXME: should be p_pic->p->i_pitch and not p_pic->p->i_visible_pitch */
params.inptyp = RSZ_INTYPE_PLANAR_8BIT;
params.pix_fmt = RSZ_PIX_FMT_PLANAR; /* Is this the input or output? */
params.pix_fmt = RSZ_PIX_FMT_UYVY; /* Is this the input or output? */
params.out_hsize = p_vout->output.i_width;
params.out_vsize = p_vout->output.i_height;
params.out_pitch = p_vout->output.i_width * 2; /* FIXME: should be p_pic->p->i_pitch and not p_pic->p->i_visible_pitch */
/* What does this do? :) */
params.hfilt_coeffs[0] = 256;
params.vfilt_coeffs[0] = 256;
#if 0
params.vfilt_coeffs[16] = -32;
params.vfilt_coeffs[17] = 160;
params.vfilt_coeffs[18] = 160;
params.vfilt_coeffs[19] = -32;
#endif
if( ioctl( p_sys->i_fd, RSZ_S_PARAM, &params ) )
{
msg_Err( p_vout, "Failed setting resizer parameters (%m)" );
goto err;
}
/**
* Set resizer speed to fastest
*/
int i_speed = 0;
if( ioctl( p_sys->i_fd, RSZ_S_EXP, &i_speed ) )
{
msg_Err( p_vout, "Failed setting resizer speed (%m)" );
goto err;
}
/**
* Initialize resize structure
*/
#ifndef USE_BUFFERS
p_sys->resize.in_buf.index = -1; /* User supplied */
#endif
p_sys->resize.in_buf.size = p_sys->i_in_size;
#ifndef USE_BUFFERS
p_sys->resize.out_buf.index = -1; /* User supplied */
#endif
p_sys->resize.out_buf.size = p_sys->i_out_size;
/**
* We're done
*/
msg_Info( p_vout, "davinci resizer initialized correctly (I hope...)" );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -224,7 +137,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -224,7 +137,6 @@ static void Close( vlc_object_t *p_this )
/* Following functions are local */ /* Following functions are local */
#ifdef USE_BUFFERS
/***************************************************************************** /*****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
...@@ -275,7 +187,6 @@ static uint8_t *GetBuffer( vout_thread_t *p_vout, int buf_type, int size, ...@@ -275,7 +187,6 @@ static uint8_t *GetBuffer( vout_thread_t *p_vout, int buf_type, int size,
return p_buf; return p_buf;
} }
#endif
/***************************************************************************** /*****************************************************************************
...@@ -285,24 +196,84 @@ static void Convert( vout_thread_t *p_vout, picture_t *p_source, ...@@ -285,24 +196,84 @@ static void Convert( vout_thread_t *p_vout, picture_t *p_source,
picture_t *p_dest ) picture_t *p_dest )
{ {
chroma_sys_t *p_sys = p_vout->chroma.p_sys; chroma_sys_t *p_sys = p_vout->chroma.p_sys;
#ifdef USE_BUFFERS
memcpy( p_sys->p_in, p_source->p->p_pixels, p_sys->i_in_size );
#else
p_sys->resize.in_buf.offset = virt_to_phys( p_source->p->p_pixels );
p_sys->resize.out_buf.offset = virt_to_phys( p_dest->p->p_pixels );
msg_Err( p_vout, "p_data: %p, %p\n", p_source->p->p_pixels, p_dest->p->p_pixels );
msg_Err( p_vout, "offsets: %x, %x\n", p_sys->resize.in_buf.offset, p_sys->resize.out_buf.offset );
#endif
if( !p_sys->b_inited )
{
int i;
/**
* Get the input and output buffers
*/
p_sys->i_in_size = p_source->p->i_pitch * p_source->p->i_visible_lines;//p_vout->render.i_width*p_vout->render.i_height*2;
p_sys->p_in = GetBuffer( p_vout, RSZ_BUF_IN, p_sys->i_in_size, &p_sys->resize.in_buf.offset );
if( !p_sys->p_in ) return;
p_sys->resize.in_buf.index = 0;
p_sys->i_out_size = p_dest->p->i_pitch * p_dest->p->i_visible_lines;
p_sys->p_out = GetBuffer( p_vout, RSZ_BUF_OUT, p_sys->i_out_size, &p_sys->resize.out_buf.offset );
if( !p_sys->p_out ) return;
p_sys->resize.out_buf.index = 0;
/**
* Set the parameters
*/
rsz_params_t params;
memset( &params, 0, sizeof( params ) );
params.in_hsize = p_source->p->i_visible_pitch / 2;
params.in_vsize = p_source->p->i_visible_lines;
params.in_pitch = p_source->p->i_pitch;
params.inptyp = RSZ_INTYPE_YCBCR422_16BIT;
params.pix_fmt = RSZ_PIX_FMT_YUYV;
params.out_hsize = p_dest->p->i_visible_pitch / 2;
params.out_vsize = p_dest->p->i_visible_lines;
params.out_pitch = p_dest->p->i_pitch;
/* What does this do? :) */
for( i = 0; i < 8; i++ )
{
params.hfilt_coeffs[4*i] = 256;
params.vfilt_coeffs[4*i] = 256;
}
params.yenh_params.type = RSZ_YENH_DISABLE;
if( ioctl( p_sys->i_fd, RSZ_S_PARAM, &params ) )
{
msg_Err( p_vout, "Failed setting resizer parameters (%m)" );
return;
}
/**
* Set resizer speed to fastest
*/
int i_speed = 0;
if( ioctl( p_sys->i_fd, RSZ_S_EXP, &i_speed ) )
{
msg_Err( p_vout, "Failed setting resizer speed (%m)" );
return;
}
/**
* Initialize resize structure
*/
p_sys->resize.in_buf.size = p_sys->i_in_size;
p_sys->resize.out_buf.size = p_sys->i_out_size;
/**
* We're done
*/
msg_Info( p_vout, "davinci resizer initialized correctly (I hope...)" );
p_sys->b_inited = VLC_TRUE;
}
msg_Dbg( p_vout, "About to resize..." );
memcpy( p_sys->p_in, p_source->p->p_pixels, p_sys->i_in_size );
if( ioctl( p_sys->i_fd, RSZ_RESIZE, &p_sys->resize ) ) if( ioctl( p_sys->i_fd, RSZ_RESIZE, &p_sys->resize ) )
{ {
msg_Err( p_vout, "Resize request failed." ); msg_Err( p_vout, "Resize request failed." );
return; return;
} }
msg_Dbg( p_vout, "Looks like resize worked!" ); msg_Dbg( p_vout, "Looks like resize worked!" );
#ifdef USE_BUFFERS
memcpy( p_dest->p->p_pixels, p_sys->p_out, p_sys->i_out_size ); memcpy( p_dest->p->p_pixels, p_sys->p_out, p_sys->i_out_size );
msg_Dbg( p_vout, "Memcpy too!" ); msg_Dbg( p_vout, "Memcpy too!" );
#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