#include <schroedinger/schro.h>
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+static int OpenDecoder ( vlc_object_t * );
+static void CloseDecoder ( vlc_object_t * );
+
+vlc_module_begin();
+ set_category( CAT_INPUT );
+ set_subcategory( SUBCAT_INPUT_VCODEC );
+ set_description( N_("Schroedinger video decoder") );
+ set_capability( "decoder", 200 );
+ set_callbacks( OpenDecoder, CloseDecoder );
+ add_shortcut( "schroedinger" );
+vlc_module_end();
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static picture_t *DecodeBlock ( decoder_t *p_dec, block_t **pp_block );
+
/*****************************************************************************
* picture_pts_t : store pts alongside picture number, not carried through
* decoder
mtime_t i_pts; //pts for this picture
};
+struct picture_free_t
+{
+ picture_t *p_pic;
+ decoder_t *p_dec;
+};
+
/*****************************************************************************
* decoder_sys_t : Schroedinger decoder descriptor
*****************************************************************************/
int i_ts_resync_hack;
};
-/*****************************************************************************
- * 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 );
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-
-vlc_module_begin();
- set_category( CAT_INPUT );
- set_subcategory( SUBCAT_INPUT_VCODEC );
- set_description( N_("Schroedinger video decoder") );
- set_capability( "decoder", 200 );
- set_callbacks( OpenDecoder, CloseDecoder );
- add_shortcut( "schroedinger" );
-vlc_module_end();
+//#define TRACE
/*****************************************************************************
* ResetPTStlb: Purge all entries in @p_dec@'s PTS-tlb
return VLC_EGENERIC;
}
+ /* Allocate the memory needed to store the decoder's structure */
+ p_sys = malloc(sizeof(decoder_sys_t));
+ if( p_sys == NULL )
+ return VLC_ENOMEM;
+
/* Initialise the schroedinger (and hence liboil libraries */
/* This does no allocation and is safe to call */
schro_init();
/* Initialise the schroedinger decoder */
- if( !(p_schro = schro_decoder_new()) ) 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;
+ if( !(p_schro = schro_decoder_new()) )
+ {
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
+ p_dec->p_sys = p_sys;
p_sys->p_schro = p_schro;
p_sys->p_format = NULL;
p_sys->i_lastpts = -1;
*****************************************************************************/
static void SchroFrameFree( SchroFrame *frame, void *priv)
{
- picture_t *p_pic = priv;
+ struct picture_free_t *p_free = priv;
- if( !p_pic )
+ if( !p_free )
return;
- if( p_pic->pf_release ) p_pic->pf_release( p_pic );
+ p_free->p_dec->pf_vout_buffer_del( p_free->p_dec, p_free->p_pic );
+ free(p_free);
+ (void)frame;
}
/*****************************************************************************
decoder_sys_t *p_sys = p_dec->p_sys;
SchroFrame *p_schroframe = schro_frame_new();
picture_t *p_pic = NULL;
+ struct picture_free_t *p_free;
if( !p_schroframe )
return NULL;
p_schroframe->width = p_sys->p_format->width;
p_schroframe->height = p_sys->p_format->height;
- schro_frame_set_free_callback( p_schroframe, SchroFrameFree, p_pic );
+
+ p_free = malloc( sizeof( *p_free ) );
+ p_free->p_pic = p_pic;
+ p_free->p_dec = p_dec;
+ schro_frame_set_free_callback( p_schroframe, SchroFrameFree, p_free );
for( int i=0; i<3; i++ )
{
return;
block_Release( p_block );
+ (void)buf;
}
/*****************************************************************************
picture_t *p_pic;
block_t *p_block;
uint32_t u_pnum;
- static int drop = 0;
if( !pp_block ) return NULL;
/* reset the decoder when seeking as the decode in progress is invalid */
/* discard the block as it is just a null magic block */
if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) {
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_RESET" );
+#endif
schro_decoder_reset( p_sys->p_schro );
ResetPTStlb( p_dec );
size_t i_pulen = GetDWBE( p_block->p_buffer + i_bufused + 5 );
uint8_t *p_pu = p_block->p_buffer + i_bufused;
+ if( 0 == i_pulen ) {
+ i_pulen = 13;
+ }
+
/* blocks that do not start with the parse info prefix are invalid */
if( p_pu[0] != 'B' || p_pu[1] != 'B' ||
p_pu[2] != 'C' || p_pu[3] != 'D')
b_bail = 1;
}
- msg_Dbg( p_dec, "Inserting bytes into decoder len=%d of %d pts=%"PRId64,
+#ifdef TRACE
+ msg_Dbg( p_dec, "Inserting bytes into decoder len=%zu of %zu pts=%"PRId64,
i_pulen, p_block->i_buffer, p_block->i_pts);
+#endif
/* this stops the same block being fed back into this function if
* we were on the next iteration of this loop to output a picture */
*pp_block = NULL;
i_bufused += i_pulen;
if( state == SCHRO_DECODER_FIRST_ACCESS_UNIT ) {
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_FIRST_ACCESS_UNIT");
+#endif
SetVideoFormat( p_dec );
ResetPTStlb( p_dec );
+
+ p_schroframe = CreateSchroFrameFromPic( p_dec );
+ if( p_schroframe ) {
+ schro_decoder_add_output_picture( p_sys->p_schro, p_schroframe);
+ }
}
if( b_bail )
break;
}
-
- if( (i_bufused > 0) && (i_bufused < p_block->i_buffer) )
- msg_Err( p_dec, "not submitted everything in p_buffer");
-
-
} while( 0 );
while( 1 )
switch( state )
{
case SCHRO_DECODER_NEED_BITS:
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_NEED_BITS" );
+#endif
return NULL;
case SCHRO_DECODER_NEED_FRAME:
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_NEED_FRAME" );
+#endif
p_schroframe = CreateSchroFrameFromPic( p_dec );
if( !p_schroframe )
case SCHRO_DECODER_OK:
u_pnum = schro_decoder_get_picture_number( p_sys->p_schro );
p_schroframe = schro_decoder_pull( p_sys->p_schro );
- p_pic = p_schroframe->priv;
+ p_pic = ((struct picture_free_t*) p_schroframe->priv)->p_pic;
p_schroframe->priv = NULL;
schro_frame_unref( p_schroframe );
p_pic->date = p_sys->i_lastpts + p_sys->i_frame_pts_delta;
p_sys->i_lastpts = p_pic->date;
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_OK num=%u date=%"PRId64,
u_pnum, p_pic->date);
-
+#endif
return p_pic;
case SCHRO_DECODER_EOS:
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_EOS");
+#endif
/* reset the decoder -- schro doesn't do this itself automatically */
/* there are no more pictures in the output buffer at this point */
schro_decoder_reset( p_sys->p_schro );
break;
case SCHRO_DECODER_ERROR:
+#ifdef TRACE
msg_Dbg( p_dec, "SCHRO_DECODER_ERROR");
+#endif
return NULL;
}
}
-
- /* Never reached */
- return NULL;
}
+