Changeset 3be7c61b0db43282fb51cc73d74a68c0d278328f

Show
Ignore:
Timestamp:
06/29/08 21:08:20 (2 months ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1214766500 +0000
git-parent:

[7544774bffebd4ae162d7aebd7f3f57bf62e573e]

git-author:
Laurent Aimar <fenrir@videolan.org> 1214766500 +0000
Message:

Added reget_buffer implementation for correct PTS for codec using it.
This allows playing of MS Video 1 file but it is not yet correct because
of the way VLC handles RGB (it won't work on big endian, and the colors
seem broken).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/codec/avcodec/video.c

    re8d41dd r3be7c61  
    9292static void ffmpeg_CopyPicture    ( decoder_t *, picture_t *, AVFrame * ); 
    9393static int  ffmpeg_GetFrameBuf    ( struct AVCodecContext *, AVFrame * ); 
     94static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * ); 
    9495static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * ); 
    9596 
     
    357358     * PTS correctly */ 
    358359    p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf; 
     360    p_sys->p_context->reget_buffer = ffmpeg_ReGetFrameBuf; 
    359361    p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf; 
    360362    p_sys->p_context->opaque = p_dec; 
     
    386388        p_sys->p_context->palctrl = 
    387389            (AVPaletteControl *)p_dec->fmt_in.video.p_palette; 
    388     else 
     390    else if( p_sys->i_codec_id != CODEC_ID_MSVIDEO1 ) 
    389391        p_sys->p_context->palctrl = &palette_control; 
    390392 
     
    885887 * decoded picture (even in indirect rendering mode). 
    886888 *****************************************************************************/ 
     889static void ffmpeg_SetFrameBufferPts( decoder_t *p_dec, AVFrame *p_ff_pic ); 
     890 
    887891static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, 
    888892                               AVFrame *p_ff_pic ) 
     
    893897 
    894898    /* Set picture PTS */ 
    895     if( p_sys->input_pts ) 
    896     { 
    897         p_ff_pic->pts = p_sys->input_pts; 
    898     } 
    899     else if( p_sys->input_dts ) 
    900     { 
    901         /* Some demuxers only set the dts so let's try to find a useful 
    902          * timestamp from this */ 
    903         if( !p_context->has_b_frames || !p_sys->b_has_b_frames || 
    904             !p_ff_pic->reference || !p_sys->i_pts ) 
    905         { 
    906             p_ff_pic->pts = p_sys->input_dts; 
    907         } 
    908         else p_ff_pic->pts = 0; 
    909     } 
    910     else p_ff_pic->pts = 0; 
    911  
    912     if( p_sys->i_pts ) /* make sure 1st frame has a pts > 0 */ 
    913     { 
    914         p_sys->input_pts = p_sys->input_dts = 0; 
    915     } 
    916  
     899    ffmpeg_SetFrameBufferPts( p_dec, p_ff_pic ); 
     900 
     901    /* */ 
    917902    p_ff_pic->opaque = 0; 
    918903 
     
    965950    return 0; 
    966951} 
     952static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *p_context, AVFrame *p_ff_pic ) 
     953{ 
     954    decoder_t *p_dec = (decoder_t *)p_context->opaque; 
     955 
     956    /* Set picture PTS */ 
     957    ffmpeg_SetFrameBufferPts( p_dec, p_ff_pic ); 
     958 
     959    /* We always use default reget function, it works perfectly fine */ 
     960    return avcodec_default_reget_buffer( p_context, p_ff_pic ); 
     961} 
     962 
     963static void ffmpeg_SetFrameBufferPts( decoder_t *p_dec, AVFrame *p_ff_pic ) 
     964{ 
     965    decoder_sys_t *p_sys = p_dec->p_sys; 
     966 
     967    /* Set picture PTS */ 
     968    if( p_sys->input_pts ) 
     969    { 
     970        p_ff_pic->pts = p_sys->input_pts; 
     971    } 
     972    else if( p_sys->input_dts ) 
     973    { 
     974        /* Some demuxers only set the dts so let's try to find a useful 
     975         * timestamp from this */ 
     976        if( !p_sys->p_context->has_b_frames || !p_sys->b_has_b_frames || 
     977            !p_ff_pic->reference || !p_sys->i_pts ) 
     978        { 
     979            p_ff_pic->pts = p_sys->input_dts; 
     980        } 
     981        else p_ff_pic->pts = 0; 
     982    } 
     983    else p_ff_pic->pts = 0; 
     984 
     985    if( p_sys->i_pts ) /* make sure 1st frame has a pts > 0 */ 
     986    { 
     987        p_sys->input_pts = p_sys->input_dts = 0; 
     988    } 
     989} 
    967990 
    968991static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,