From: Steinar Gunderson Date: Fri, 24 Sep 2010 18:55:04 +0000 (+0200) Subject: Replace hardcoded memcpy with a more correct, parametrized one. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=581a1ef87d1a35d9684aaba00b6a952f9b55ff3c;p=vlc Replace hardcoded memcpy with a more correct, parametrized one. --- diff --git a/modules/access/sdi.cpp b/modules/access/sdi.cpp index d31ed17068..c6080646ab 100644 --- a/modules/access/sdi.cpp +++ b/modules/access/sdi.cpp @@ -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 );