- /* Unsatisfactory, and will later be fixed in schro:
- * - Schro can only handle a single Dirac parse unit at a time
- * - Multiple parse units may exist in p_block
- * - All mapping specs so far guarantee that p_block would
- * not contain anything after a picture
- * So, we can not give the whole block to schro, but piecemeal
- */
- size_t i_bufused = 0;
- while( schro_decoder_push_ready( p_sys->p_schro )) {
- if( p_block->i_buffer - i_bufused < 13 ) {
- *pp_block = NULL;
- block_Release( p_block );
- msg_Err( p_dec, "not enough data left in block" );
- break;
- }
-
- int b_bail = 0;
- 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')
- {
- *pp_block = NULL;
- block_Release( p_block );
- msg_Err( p_dec, "block does not start with dirac parse code" );
- break;
- }
-
- if( i_bufused + i_pulen > p_block->i_buffer ) {
- *pp_block = NULL;
- block_Release( p_block );
- break;
- }
-
- if( p_pu[4] & 0x08 )
- StorePicturePTS( p_dec, p_block, i_bufused );
-
- p_schrobuffer = schro_buffer_new_with_data( p_pu, i_pulen );
- if( i_pulen + i_bufused < p_block->i_buffer ) {
- /* don't let schro free this block, more data still in it */
- p_schrobuffer->free = 0;
- }
- else {
- p_schrobuffer->free = SchroBufferFree;
- p_schrobuffer->priv = p_block;
- b_bail = 1;
- }
-
-#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;
- state = schro_decoder_push( p_sys->p_schro, p_schrobuffer );
-
- /* DO NOT refer to p_block after this point, it may have been freed */
-
- 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 );
+ SchroBuffer *p_schrobuffer;
+ p_schrobuffer = schro_buffer_new_with_data( p_block->p_buffer, p_block->i_buffer );
+ p_schrobuffer->free = SchroBufferFree;
+ p_schrobuffer->priv = p_block;
+ if( p_block->i_pts > VLC_TS_INVALID ) {
+ mtime_t *p_pts = malloc( sizeof(*p_pts) );
+ if( p_pts ) {
+ *p_pts = p_block->i_pts;
+ /* if this call fails, p_pts is freed automatically */
+ p_schrobuffer->tag = schro_tag_new( p_pts, free );