From: Gildas Bazin Date: Mon, 30 Aug 2004 19:24:55 +0000 (+0000) Subject: * ALL: use rgb mask members in video_format_t. X-Git-Tag: 0.8.0~521 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8ca6f29c3aa74031f4e7626637942df6ac519502;p=vlc * ALL: use rgb mask members in video_format_t. * modules/demux/avi/avi.c: raw RGB 24 is in fact BGR 24. --- diff --git a/include/vlc_es.h b/include/vlc_es.h index 8a4f3f78f2..622726d1e7 100644 --- a/include/vlc_es.h +++ b/include/vlc_es.h @@ -102,7 +102,7 @@ struct video_format_t unsigned int i_frame_rate; /**< frame rate numerator */ unsigned int i_frame_rate_base; /**< frame rate denominator */ - int i_rmask, i_rgmask, i_bmask; /**< color masks for RGB chroma */ + int i_rmask, i_gmask, i_bmask; /**< color masks for RGB chroma */ video_palette_t *p_palette; /**< video palette from demuxer */ }; diff --git a/modules/codec/ffmpeg/chroma.c b/modules/codec/ffmpeg/chroma.c index f7b14e45bb..4d7bcb3d28 100644 --- a/modules/codec/ffmpeg/chroma.c +++ b/modules/codec/ffmpeg/chroma.c @@ -88,6 +88,7 @@ int E_(OpenChroma)( vlc_object_t *p_this ) p_vout->chroma.p_sys->i_dst_vlc_chroma = p_vout->output.i_chroma; p_vout->chroma.p_sys->i_src_ffmpeg_chroma = i_ffmpeg_chroma[0]; p_vout->chroma.p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1]; + if( ( p_vout->render.i_height != p_vout->output.i_height || p_vout->render.i_width != p_vout->output.i_width ) && ( p_vout->chroma.p_sys->i_dst_vlc_chroma == VLC_FOURCC('I','4','2','0') || @@ -95,10 +96,9 @@ int E_(OpenChroma)( vlc_object_t *p_this ) { msg_Dbg( p_vout, "preparing to resample picture" ); - p_vout->chroma.p_sys->p_rsc = img_resample_init( p_vout->output.i_width, - p_vout->output.i_height, - p_vout->render.i_width, - p_vout->render.i_height ); + p_vout->chroma.p_sys->p_rsc = + img_resample_init( p_vout->output.i_width, p_vout->output.i_height, + p_vout->render.i_width, p_vout->render.i_height ); avpicture_alloc( &p_vout->chroma.p_sys->tmp_pic, p_vout->chroma.p_sys->i_dst_ffmpeg_chroma, p_vout->render.i_width, p_vout->render.i_height ); @@ -152,6 +152,10 @@ static void ChromaConversion( vout_thread_t *p_vout, dest_pic.data[1] = p_dest->p[2].p_pixels; dest_pic.data[2] = p_dest->p[1].p_pixels; } + if( p_vout->chroma.p_sys->i_src_ffmpeg_chroma == PIX_FMT_RGB24 ) + if( p_vout->render.i_bmask == 0x00ff0000 ) + p_vout->chroma.p_sys->i_src_ffmpeg_chroma = PIX_FMT_BGR24; + if( p_vout->chroma.p_sys->p_rsc ) { img_convert( &p_vout->chroma.p_sys->tmp_pic, diff --git a/modules/codec/ffmpeg/video_filter.c b/modules/codec/ffmpeg/video_filter.c index ae5795ddcb..f420f1996c 100644 --- a/modules/codec/ffmpeg/video_filter.c +++ b/modules/codec/ffmpeg/video_filter.c @@ -195,6 +195,9 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic ) dest_pic.data[1] = p_pic_dst->p[2].p_pixels; dest_pic.data[2] = p_pic_dst->p[1].p_pixels; } + if( p_sys->i_src_ffmpeg_chroma == PIX_FMT_RGB24 ) + if( p_filter->fmt_in.video.i_bmask == 0x00ff0000 ) + p_sys->i_src_ffmpeg_chroma = PIX_FMT_BGR24; #if 0 if( p_sys->b_resize && diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c index 82be6aaabf..ce5a62740d 100644 --- a/modules/codec/rawvideo.c +++ b/modules/codec/rawvideo.c @@ -139,11 +139,19 @@ static int OpenDecoder( vlc_object_t *p_this ) /* Set output properties */ p_dec->fmt_out.i_cat = VIDEO_ES; p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec; - //if( !p_dec->fmt_in.video.i_aspect ) + if( !p_dec->fmt_in.video.i_aspect ) { p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_out.video.i_width / p_dec->fmt_out.video.i_height; } + else p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect; + + if( p_dec->fmt_in.video.i_rmask ) + p_dec->fmt_out.video.i_rmask = p_dec->fmt_in.video.i_rmask; + if( p_dec->fmt_in.video.i_gmask ) + p_dec->fmt_out.video.i_gmask = p_dec->fmt_in.video.i_gmask; + if( p_dec->fmt_in.video.i_bmask ) + p_dec->fmt_out.video.i_bmask = p_dec->fmt_in.video.i_bmask; /* Set callbacks */ p_dec->pf_decode_video = (picture_t *(*)(decoder_t *, block_t **)) diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index eea48b6c52..2ce64de404 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -415,11 +415,20 @@ static int Open( vlc_object_t * p_this ) break; } es_format_Init( &fmt, VIDEO_ES, tk->i_codec ); + + if( p_vids->p_bih->biBitCount == 24 ) + { + /* This is in BGR format */ + fmt.video.i_bmask = 0x00ff0000; + fmt.video.i_gmask = 0x0000ff00; + fmt.video.i_rmask = 0x000000ff; + } } else { es_format_Init( &fmt, VIDEO_ES, p_vids->p_bih->biCompression ); - if( tk->i_codec == FOURCC_mp4v && !strncasecmp( (char*)&p_strh->i_handler, "XVID", 4 ) ) + if( tk->i_codec == FOURCC_mp4v && + !strncasecmp( (char*)&p_strh->i_handler, "XVID", 4 ) ) { fmt.i_codec = VLC_FOURCC( 'X', 'V', 'I', 'D' ); } diff --git a/src/input/decoder.c b/src/input/decoder.c index 44e3d15349..3eee0e8fec 100644 --- a/src/input/decoder.c +++ b/src/input/decoder.c @@ -235,9 +235,9 @@ void input_DecoderDecode( decoder_t * p_dec, block_t *p_block ) } else { - if( p_dec->b_error || p_block->i_buffer <= 0 ) + if( p_dec->b_error || (p_block && p_block->i_buffer <= 0) ) { - block_Release( p_block ); + if( p_block ) block_Release( p_block ); } else { @@ -503,9 +503,9 @@ static int DecoderThread( decoder_t * p_dec ) */ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) { - int i_rate = p_block->i_rate; + int i_rate = p_block ? p_block->i_rate : 1000; - if( p_block->i_buffer <= 0 ) + if( p_block && p_block->i_buffer <= 0 ) { block_Release( p_block ); return VLC_SUCCESS; @@ -515,7 +515,8 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) { block_t *p_sout_block; - while( (p_sout_block = p_dec->pf_packetize( p_dec, &p_block )) ) + while( ( p_sout_block = + p_dec->pf_packetize( p_dec, p_block ? &p_block : 0 ) ) ) { if( !p_dec->p_owner->p_sout_input ) { @@ -828,6 +829,13 @@ static picture_t *vout_new_buffer( decoder_t *p_dec ) p_dec->b_error = VLC_TRUE; return NULL; } + + if( p_sys->video.i_rmask ) + p_sys->p_vout->render.i_rmask = p_sys->video.i_rmask; + if( p_sys->video.i_gmask ) + p_sys->p_vout->render.i_gmask = p_sys->video.i_gmask; + if( p_sys->video.i_bmask ) + p_sys->p_vout->render.i_bmask = p_sys->video.i_bmask; } /* Get a new picture */