]> git.sesse.net Git - vlc/blobdiff - modules/codec/rawvideo.c
Swedish translation update by Daniel Nylander
[vlc] / modules / codec / rawvideo.c
index fa4add7a005d3b6ca4850c40dd021f7717aabdaa..c1498644df2659eb9b0803bedc629ee968974eac 100644 (file)
@@ -28,7 +28,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_vout.h>
@@ -70,14 +70,14 @@ static block_t   *SendFrame  ( decoder_t *, block_t * );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("Pseudo raw video decoder") );
+    set_description( N_("Pseudo raw video decoder") );
     set_capability( "decoder", 50 );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_VCODEC );
     set_callbacks( OpenDecoder, CloseDecoder );
 
     add_submodule();
-    set_description( _("Pseudo raw video packetizer") );
+    set_description( N_("Pseudo raw video packetizer") );
     set_capability( "packetizer", 100 );
     set_callbacks( OpenPacketizer, CloseDecoder );
 vlc_module_end();
@@ -132,10 +132,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
-    {
-        msg_Err( p_dec, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
     /* Misc init */
     p_dec->p_sys->b_packetizer = false;
     p_sys->i_pts = 0;
@@ -232,7 +229,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     if( p_block->i_buffer < p_sys->i_raw_size )
     {
-        msg_Warn( p_dec, "invalid frame size (%d < %d)",
+        msg_Warn( p_dec, "invalid frame size (%zu < %zu)",
                   p_block->i_buffer, p_sys->i_raw_size );
 
         block_Release( p_block );
@@ -260,30 +257,26 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
  *****************************************************************************/
 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;
+    int i_plane;
     decoder_sys_t *p_sys = p_dec->p_sys;
-
-    p_src = p_block->p_buffer;
-    i_src = p_block->i_buffer;
+    uint8_t *p_src = p_block->p_buffer;
 
     for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
     {
-        p_dst = p_pic->p[i_plane].p_pixels;
-        i_width = 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));
-
-        for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; i_line++ )
-        {
-            vlc_memcpy( p_dst, p_src, i_width );
-            p_src += p_sys->b_invert ? -i_width : i_width;
-            p_dst += i_width;
-        }
+        int i_pitch = p_pic->p[i_plane].i_pitch;
+        int i_visible_pitch = p_pic->p[i_plane].i_visible_pitch;
+        int i_visible_lines = p_pic->p[i_plane].i_visible_lines;
+        uint8_t *p_dst = p_pic->p[i_plane].p_pixels;
+        uint8_t *p_dst_end = p_dst+i_pitch*i_visible_lines;
 
         if( p_sys->b_invert )
-            p_src += (i_width * (p_pic->p[i_plane].i_visible_lines + 1));
+            for( p_dst_end -= i_pitch; p_dst <= p_dst_end;
+                 p_dst_end -= i_pitch, p_src += i_visible_pitch )
+                vlc_memcpy( p_dst_end, p_src, i_visible_pitch );
+        else
+            for( ; p_dst < p_dst_end;
+                 p_dst += i_pitch, p_src += i_visible_pitch )
+                vlc_memcpy( p_dst, p_src, i_visible_pitch );
     }
 }
 
@@ -338,6 +331,8 @@ static block_t *SendFrame( decoder_t *p_dec, block_t *p_block )
         }
 
         p_tmp = malloc( pic.p[0].i_pitch );
+        if( !p_tmp )
+            return p_block;
         p_pixels = p_block->p_buffer;
         for( i = 0; i < pic.i_planes; i++ )
         {