Commit 00e50baf authored by David Flynn's avatar David Flynn Committed by Laurent Aimar

codec/dirac: remove decoder functionality

The schroedinger project and vlc module are much faster dirac decoders;
that should be used in preference to libdirac[-research]
Signed-off-by: default avatarDavid Flynn <davidf@rd.bbc.co.uk>
Signed-off-by: default avatarLaurent Aimar <fenrir@videolan.org>
parent f1d4df64
/*****************************************************************************
* dirac.c: Dirac decoder/encoder module making use of libdirac.
* dirac.c: Dirac encoder module making use of libdirac.
* (http://www.bbc.co.uk/rd/projects/dirac/index.shtml)
*****************************************************************************
* Copyright (C) 1999-2001 the VideoLAN team
......@@ -38,24 +38,9 @@
#include <libdirac_decoder/dirac_parser.h>
#include <libdirac_encoder/dirac_encoder.h>
/*****************************************************************************
* decoder_sys_t : theora decoder descriptor
*****************************************************************************/
struct decoder_sys_t
{
/*
* Dirac properties
*/
dirac_decoder_t *p_dirac;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int OpenDecoder ( vlc_object_t * );
static void CloseDecoder ( vlc_object_t * );
static picture_t *DecodeBlock ( decoder_t *p_dec, block_t **pp_block );
static int OpenEncoder( vlc_object_t *p_this );
static void CloseEncoder( vlc_object_t *p_this );
static block_t *Encode( encoder_t *p_enc, picture_t *p_pict );
......@@ -76,12 +61,6 @@ static const char *const ppsz_enc_options[] = {
vlc_module_begin ()
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_VCODEC )
set_description( N_("Dirac video decoder") )
set_capability( "decoder", 100 )
set_callbacks( OpenDecoder, CloseDecoder )
add_shortcut( "dirac" )
add_submodule ()
set_description( N_("Dirac video encoder") )
set_capability( "encoder", 100 )
set_callbacks( OpenEncoder, CloseEncoder )
......@@ -90,215 +69,6 @@ vlc_module_begin ()
vlc_module_end ()
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
dirac_decoder_t *p_dirac;
if( p_dec->fmt_in.i_codec != VLC_FOURCC('d','r','a','c') )
{
return VLC_EGENERIC;
}
/* Initialise the dirac decoder */
if( !(p_dirac = dirac_decoder_init(0)) ) return VLC_EGENERIC;
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
return VLC_ENOMEM;
p_sys->p_dirac = p_dirac;
/* Set output properties */
p_dec->fmt_out.i_cat = VIDEO_ES;
p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0');
/* Set callbacks */
p_dec->pf_decode_video = DecodeBlock;
return VLC_SUCCESS;
}
static void FreeFrameBuffer( dirac_decoder_t *p_dirac )
{
if( p_dirac->fbuf )
{
int i;
for( i = 0; i < 3; i++ )
{
free( p_dirac->fbuf->buf[i] );
p_dirac->fbuf->buf[i] = 0;
}
}
}
/*****************************************************************************
* GetNewPicture: Get a new picture from the vout and copy the decoder output
*****************************************************************************/
static picture_t *GetNewPicture( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
picture_t *p_pic;
int i_plane;
switch( p_sys->p_dirac->src_params.chroma )
{
case format420: p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0'); break;
case format422: p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','2'); break;
case format444: p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','4','4'); break; // XXX 0.6 ?
default:
p_dec->fmt_out.i_codec = 0;
break;
}
p_dec->fmt_out.video.i_visible_width =
p_dec->fmt_out.video.i_width = p_sys->p_dirac->src_params.width;
p_dec->fmt_out.video.i_visible_height =
p_dec->fmt_out.video.i_height = p_sys->p_dirac->src_params.height;
p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
p_dec->fmt_out.video.i_frame_rate =
p_sys->p_dirac->src_params.frame_rate.numerator;
p_dec->fmt_out.video.i_frame_rate_base =
p_sys->p_dirac->src_params.frame_rate.denominator;
/* Get a new picture */
p_pic = decoder_NewPicture( p_dec );
if( p_pic == NULL ) return NULL;
p_pic->b_progressive = !p_sys->p_dirac->src_params.source_sampling;
p_pic->b_top_field_first = p_sys->p_dirac->src_params.topfieldfirst;
p_pic->i_nb_fields = 2;
/* Copy picture stride by stride */
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
int i_line, i_width, i_dst_stride;
uint8_t *p_src = p_sys->p_dirac->fbuf->buf[i_plane];
uint8_t *p_dst = p_pic->p[i_plane].p_pixels;
i_width = p_pic->p[i_plane].i_visible_pitch;
i_dst_stride = p_pic->p[i_plane].i_pitch;
for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; i_line++ )
{
vlc_memcpy( p_dst, p_src, i_width );
p_src += i_width;
p_dst += i_dst_stride;
}
}
return p_pic;
}
/*****************************************************************************
* CloseDecoder: decoder destruction
*****************************************************************************/
static void CloseDecoder( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
FreeFrameBuffer( p_sys->p_dirac );
dirac_decoder_close( p_sys->p_dirac );
free( p_sys );
}
/****************************************************************************
* DecodeBlock: the whole thing
****************************************************************************
* This function must be fed with complete frames.
****************************************************************************/
static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
dirac_decoder_state_t state;
picture_t *p_pic;
block_t *p_block;
if( !pp_block || !*pp_block ) return NULL;
p_block = *pp_block;
while( 1 )
{
state = dirac_parse( p_sys->p_dirac );
switch( state )
{
case STATE_BUFFER:
if( !p_block->i_buffer )
{
block_Release( p_block );
return NULL;
}
msg_Dbg( p_dec, "STATE_BUFFER" );
dirac_buffer( p_sys->p_dirac, p_block->p_buffer,
p_block->p_buffer + p_block->i_buffer );
p_block->i_buffer = 0;
break;
case STATE_SEQUENCE:
{
/* Initialize video output */
uint8_t *buf[3];
msg_Dbg( p_dec, "%dx%d, chroma %i, %f fps",
p_sys->p_dirac->src_params.width,
p_sys->p_dirac->src_params.height,
p_sys->p_dirac->src_params.chroma,
(float)p_sys->p_dirac->src_params.frame_rate.numerator/
p_sys->p_dirac->src_params.frame_rate.denominator );
FreeFrameBuffer( p_sys->p_dirac );
buf[0] = malloc( p_sys->p_dirac->src_params.width *
p_sys->p_dirac->src_params.height );
buf[1] = malloc( p_sys->p_dirac->src_params.chroma_width *
p_sys->p_dirac->src_params.chroma_height );
buf[2] = malloc( p_sys->p_dirac->src_params.chroma_width *
p_sys->p_dirac->src_params.chroma_height );
dirac_set_buf( p_sys->p_dirac, buf, NULL );
break;
}
case STATE_SEQUENCE_END:
msg_Dbg( p_dec, "SEQUENCE_END" );
FreeFrameBuffer( p_sys->p_dirac );
break;
case STATE_PICTURE_AVAIL:
msg_Dbg( p_dec, "PICTURE_AVAIL : frame_num=%d",
p_sys->p_dirac->frame_num );
/* Picture available for display */
p_pic = GetNewPicture( p_dec );
p_pic->date = p_block->i_pts > 0 ? p_block->i_pts : p_block->i_dts;
p_pic->b_force = 1; // HACK
return p_pic;
break;
case STATE_INVALID:
msg_Dbg( p_dec, "STATE_INVALID" );
break;
default:
break;
}
}
/* Never reached */
return NULL;
}
/*****************************************************************************
* encoder_sys_t : dirac encoder descriptor
*****************************************************************************/
......
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