Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Memory Transfert, Question
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
jpsdr
Posted: Sep 8 2008, 10:50 AM


Advanced Member


Group: Members
Posts: 335
Member No.: 20490
Joined: 23-December 06



Hello.

Something is bugging me a little.

If in a filter, the flag FILTERPARAM_SWAP_BUFFERS isn't used, it seems that *src and *dst can overlap.

In case of single memory transfert, can we do (as said in SDK) :

for i=0; i<h ; i++
{
memcpy(dst,src,line_size)
src+=src_pitch
dst+=dst_pitch
}

or is it safer to do

for i=0; i<h ; i++
{
memmove(dst,src,line_size)
src+=src_pitch
dst+=dst_pitch
}

???????
 
     Top
phaeron
Posted: Sep 9 2008, 05:38 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Almost.

If you fail to pass the FILTERPARAM_SWAP_BUFFERS flag, it isn't that the buffers can overlap. You're requesting that they overlap. That means that the memcpy() loop is always bad and the memmove() loop is OK, although strange (and probably unnecessary). I don't know of any implementations of memcpy() that will screw up if you pass exactly the same pointer for src and dst, but technically any overlapping memcpy() invokes undefined behavior according to the C standard.
 
    Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
1 replies since Sep 8 2008, 10:50 AM Track this topic | Email this topic | Print this topic

<< Back to VirtualDub Filters and Filter Development