Changeset 3be7c61b0db43282fb51cc73d74a68c0d278328f
- 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
| re8d41dd |
r3be7c61 |
|
| 92 | 92 | static void ffmpeg_CopyPicture ( decoder_t *, picture_t *, AVFrame * ); |
|---|
| 93 | 93 | static int ffmpeg_GetFrameBuf ( struct AVCodecContext *, AVFrame * ); |
|---|
| | 94 | static int ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * ); |
|---|
| 94 | 95 | static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * ); |
|---|
| 95 | 96 | |
|---|
| … | … | |
| 357 | 358 | * PTS correctly */ |
|---|
| 358 | 359 | p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf; |
|---|
| | 360 | p_sys->p_context->reget_buffer = ffmpeg_ReGetFrameBuf; |
|---|
| 359 | 361 | p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf; |
|---|
| 360 | 362 | p_sys->p_context->opaque = p_dec; |
|---|
| … | … | |
| 386 | 388 | p_sys->p_context->palctrl = |
|---|
| 387 | 389 | (AVPaletteControl *)p_dec->fmt_in.video.p_palette; |
|---|
| 388 | | else |
|---|
| | 390 | else if( p_sys->i_codec_id != CODEC_ID_MSVIDEO1 ) |
|---|
| 389 | 391 | p_sys->p_context->palctrl = &palette_control; |
|---|
| 390 | 392 | |
|---|
| … | … | |
| 885 | 887 | * decoded picture (even in indirect rendering mode). |
|---|
| 886 | 888 | *****************************************************************************/ |
|---|
| | 889 | static void ffmpeg_SetFrameBufferPts( decoder_t *p_dec, AVFrame *p_ff_pic ); |
|---|
| | 890 | |
|---|
| 887 | 891 | static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, |
|---|
| 888 | 892 | AVFrame *p_ff_pic ) |
|---|
| … | … | |
| 893 | 897 | |
|---|
| 894 | 898 | /* 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 | /* */ |
|---|
| 917 | 902 | p_ff_pic->opaque = 0; |
|---|
| 918 | 903 | |
|---|
| … | … | |
| 965 | 950 | return 0; |
|---|
| 966 | 951 | } |
|---|
| | 952 | static 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 | |
|---|
| | 963 | static 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 | } |
|---|
| 967 | 990 | |
|---|
| 968 | 991 | static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context, |
|---|