]> git.sesse.net Git - vlc/commitdiff
* ALL: use rgb mask members in video_format_t.
authorGildas Bazin <gbazin@videolan.org>
Mon, 30 Aug 2004 19:24:55 +0000 (19:24 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 30 Aug 2004 19:24:55 +0000 (19:24 +0000)
* modules/demux/avi/avi.c: raw RGB 24 is in fact BGR 24.

include/vlc_es.h
modules/codec/ffmpeg/chroma.c
modules/codec/ffmpeg/video_filter.c
modules/codec/rawvideo.c
modules/demux/avi/avi.c
src/input/decoder.c

index 8a4f3f78f2627268b5d60f1970897049dd099b0d..622726d1e725aa8581e9a4334b47f8ef1c798bf6 100644 (file)
@@ -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 */
 };
 
index f7b14e45bb79388d6ee202ca0601cf0ccef01115..4d7bcb3d28504782544f43fb74a6d91e2d712650 100644 (file)
@@ -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,
index ae5795ddcbdd52d5f5722d14f37cf5e66675ada0..f420f1996c9f70ec227a9b9919722df7bc90956a 100644 (file)
@@ -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 &&
index 82be6aaabf93641c890de6f9063a6f4cd765c895..ce5a62740d2149c265010a4b0df0555e50dd530f 100644 (file)
@@ -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 **))
index eea48b6c522463eb44d9a55ea12fb9ea7f0ae480..2ce64de404bd5938f9dc778455ac4d48e85fea15 100644 (file)
@@ -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' );
                     }
index 44e3d1534996ff45c56a0f29bb94838801d7a2ee..3eee0e8fecd121037cc88fd7f05d3b35ce0c7b74 100644 (file)
@@ -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 */