]> git.sesse.net Git - vlc/commitdiff
Replace hardcoded memcpy with a more correct, parametrized one.
authorSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 18:55:04 +0000 (20:55 +0200)
committerSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 18:55:04 +0000 (20:55 +0200)
modules/access/sdi.cpp

index d31ed17068556997845b721ab6d2607d0e344269..c6080646ab7b0bcfec4e3c9572747f2263d227e2 100644 (file)
@@ -94,8 +94,13 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
             return S_OK;
         }
 
+        const int i_width = videoFrame->GetWidth();
+        const int i_height = videoFrame->GetHeight();
+        const int i_stride = videoFrame->GetRowBytes();
+        const int i_bpp = 2;
+
         block_t *p_frame;
-        p_frame = block_New( p_demux_, 720 * 576 * 3 );
+        p_frame = block_New( p_demux_, i_width * i_height * i_bpp );
         if( !p_frame )
         {
             msg_Err( p_demux_, "Could not allocate memory for frame" );
@@ -104,7 +109,12 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
 
         void *frame_bytes;
         videoFrame->GetBytes( &frame_bytes );
-        memcpy( p_frame->p_buffer, frame_bytes, 720 * 576 * 3 );
+        for( int y = 0; y < i_height; ++y )
+        {
+            const uint8_t *src = (const uint8_t *)frame_bytes + i_stride * y;
+            uint8_t *dst = (uint8_t *)p_frame->p_buffer + i_width * i_bpp * y;
+            memcpy( dst, src, i_width * i_bpp );
+        }
 
         BMDTimeValue stream_time, frame_duration;
         videoFrame->GetStreamTime( &stream_time, &frame_duration, CLOCK_FREQ );