]> git.sesse.net Git - vlc/commitdiff
* modules/demux/avi/avi.c, modules/codec/rawvideo.c: RGB DIBs are coded from bottom...
authorGildas Bazin <gbazin@videolan.org>
Mon, 30 Aug 2004 19:58:56 +0000 (19:58 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 30 Aug 2004 19:58:56 +0000 (19:58 +0000)
modules/codec/rawvideo.c
modules/demux/avi/avi.c

index ce5a62740d2149c265010a4b0df0555e50dd530f..6f4d53086a926a800444c9ea99fdacf3cd9a4295 100644 (file)
@@ -40,6 +40,7 @@ struct decoder_sys_t
      * Input properties
      */
     int i_raw_size;
+    vlc_bool_t b_invert;
 
     /*
      * Common properties
@@ -119,9 +120,17 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Misc init */
     p_dec->p_sys->b_packetizer = VLC_FALSE;
     p_sys->i_pts = 0;
+    p_sys->b_invert = 0;
 
-    if( p_dec->fmt_in.video.i_width <= 0 ||
-        p_dec->fmt_in.video.i_height <= 0 )
+    if( (int)p_dec->fmt_in.video.i_height < 0 )
+    {
+        /* Frames are coded from bottom to top */
+        p_dec->fmt_in.video.i_height =
+            (unsigned int)(-(int)p_dec->fmt_in.video.i_height);
+        p_sys->b_invert = VLC_TRUE;
+    }
+
+    if( p_dec->fmt_in.video.i_width <= 0 || p_dec->fmt_in.video.i_height <= 0 )
     {
         msg_Err( p_dec, "invalid display size %dx%d",
                  p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height );
@@ -234,8 +243,9 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
 {
     uint8_t *p_src, *p_dst;
     int i_src, i_plane, i_line, i_width;
+    decoder_sys_t *p_sys = p_dec->p_sys;
 
-    p_src  = p_block->p_buffer;
+    p_src = p_block->p_buffer;
     i_src = p_block->i_buffer;
 
     for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
@@ -243,12 +253,18 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
         p_dst = p_pic->p[i_plane].p_pixels;
         i_width = p_pic->p[i_plane].i_visible_pitch;
 
+        if( p_sys->b_invert )
+            p_src += (i_width * (p_pic->p[i_plane].i_visible_lines - 1));
+
         for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; i_line++ )
         {
             p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_width );
-            p_src += i_width;
+            p_src += p_sys->b_invert ? -i_width : i_width;
             p_dst += p_pic->p[i_plane].i_pitch;
         }
+
+        if( p_sys->b_invert )
+            p_src += (i_width * (p_pic->p[i_plane].i_visible_lines + 1));
     }
 }
 
index 2ce64de404bd5938f9dc778455ac4d48e85fea15..436850580ab462dc3c7baaf93eeb9832a8f33d3c 100644 (file)
@@ -448,6 +448,13 @@ static int Open( vlc_object_t * p_this )
                          p_vids->p_bih->biHeight,
                          p_vids->p_bih->biBitCount,
                          (float)tk->i_rate/(float)tk->i_scale );
+
+                if( p_vids->p_bih->biCompression == 0x00 )
+                {
+                    /* RGB DIB are coded from bottom to top */
+                    fmt.video.i_height =
+                        (unsigned int)(-(int)p_vids->p_bih->biHeight);
+                }
                 break;
             default:
                 msg_Warn( p_demux, "stream[%d] unknown type", i );