[vlc-devel] decoder recommended changes

Moriarty, Mark F mark.f.moriarty at lmco.com
Fri Jul 30 17:07:37 CEST 2004


The purge if FIFO reaches XX bytes is a step, but I believe if you've hit this you can assert that you have a real problem, should signal the calling process that it might want to do something.  To do this, change input_decoderdecode to an int, and pass vlc errors back, as needed.  Things dealing with raw input types really ought to do a condition check, either abort or change parameters (for instance, in screen: it might be nice to automatically back down the frame rate, set new frame rate to 0.8 of the old and restart.  Otherwise, at least pause the thread execution or stop the screen: input entirely, with error message.)

Recommend the following changes to allow signalling to go back up the processing chain.  \modules\stream_out\display.c also uses input_decoderdecode, but if nobody has had problems with it, an error check likely isn't needed.

1) vlc_input.h -- change function type from void to int:
VLC_EXPORT( int, input_DecoderDecode,( decoder_t *, block_t * ) );  /* MFM -- changed from void to int */

2) \src\input\decoder.c, function input_DecoderDecode -- change to return an error condition:
int input_DecoderDecode( decoder_t * p_dec, block_t *p_block )    /* MFM -- changed from void to int */
{
    if( p_dec->p_owner->b_own_thread )
    {
        if( p_dec->p_owner->p_input->b_out_pace_control )
        {
            /* FIXME !!!!! */
            while( !p_dec->b_die && !p_dec->b_error &&
                   p_dec->p_owner->p_fifo->i_depth > 10 )
            {
                msleep( 1000 );
            }
        }
        else if( p_dec->p_owner->p_fifo->i_size > 40000000 /* MFM -- reduced to 40 MB */ )
        {
            /* FIXME: ideally we would check the time amount of data
             * in the fifo instead of its size. */
            msg_Warn( p_dec, "decoder/packetizer fifo full, resetting fifo!" ); /* MFM -- adjust to a Warn */
            block_FifoEmpty( p_dec->p_owner->p_fifo );
            block_FifoPut( p_dec->p_owner->p_fifo, p_block ); /* MFM */ 
            return VLC_ENOMEM;   /* MFM  */
        }

        block_FifoPut( p_dec->p_owner->p_fifo, p_block );
    }
    else
    {
        if( p_dec->b_error || p_block->i_buffer <= 0 )
        {
            block_Release( p_block );
        }
        else
        {
            DecoderDecode( p_dec, p_block );
        }
    }
    return VLC_SUCCESS;  /* MFM -- may need to trap on the DecoderDecode, but I'm not sure what error to look for, if any */
}


3)  \src\input\es_out.c, function EsOutSend -- return error code from input_decoderdecode:
   /* TODO handle mute */
    if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES || p_input->i_rate == INPUT_RATE_DEFAULT ) )
    {
        return input_DecoderDecode( es->p_dec, p_block ); /* MFM May also want to adjust the else part of the statement */
    }
    else
    {
        block_Release( p_block );
    }

    return VLC_SUCCESS;
}

4) \modules\access\screen\screen.c, function Demux -- trap input_decoderdecode error.  Need to have someone who is smart about VLC handles look at this change, modify to either reduce the frame rate or stop the screen: thread since this is a bad condition [just clearing FIFO won't help, CPU will stay locked and memory use will keep cycling up to max FIFO size]:

    es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
    if (es_out_Send( p_demux->out, p_sys->es, p_block ) != VLC_SUCCESS)  /* MFM -- should update to either terminate stream or auto-adjust rate */
    {
           msg_Err( p_demux, "Demux -- packet output error.");

    }

    p_sys->i_next_date += p_sys->i_incr;

5)  \modules\access\dshow\dshow.cpp, function Demux -- need to trap errors here, too, as I was definitely running into the memory leak and 100% CPU use when I used a high res framegrabber with a lightweight CPU.  I'd suggest not just generating the warning message, but also stopping the dshow input (things won't get better until/unless the user decrease fps or video size, so kill or pause the thread).  The return codes in Demux should perhaps be looked at -- it looks like it's returning 0 for error conditions, non-0 for success.

   es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_pts > 0 ? i_pts : 0 );
    if (es_out_Send( p_demux->out, p_sys->es[i_es], p_block ) != VLC_SUCCESS) /* MFM -- should probably update to terminate the Dshow input when this happens */
    {
              msg_Warn( p_demux, "Dshow Demux -- FIFO cannot keep up.  Reduce frame rate or input video size" );
    }



-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>



More information about the vlc-devel mailing list