cmisip
Posts: 94
Joined: Tue Aug 25, 2015 12:38 am

Indexing into the motion vector array in C++

Sat Sep 15, 2018 9:23 pm

I want to make sure that I am properly assigning coordinates to the motion vector frames. This is what I am doing.

Get the number of macroblocks. For a 640x360 frame:

Code: Select all

    int frame_width=monitor->Width()+16;  //add the extra column, resulting in 656
    int frame_height=((monitor->Height()+16)/16)*16;  //make sure the height is a multiple of 16, resulting in 368
    int numblocks= (frame_width*frame_height)/256;  //divide by 16*16;
 


Assign the coordinates of the macroblocks top left pixel.
The vectors come in as an array of size numblocks of 4 bytes each. The first macroblock is top left, then in sequence left to right, then go down one row and then go left to right again, and so on.

Code: Select all

   coords=(Coord*)zm_mallocaligned(32,sizeof(Coord)*numblocks);
   for ( int i=0; i< numblocks; i++) {
	   coords[i].X()=(i*16) % (frame_width);  //frame_width already has +16 for the extra column
	   coords[i].Y()=((i*16)/(frame_width))*16;	
	}	
Is this correct?

Thanks,
Chris

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 14 guests