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;
}
Thanks,
Chris