I'm trying to modify the motion detection part of FFMPEG. What I want to do is to extend the search space, so that whenever the macroblock hits the rightmost edge of the frame, I need it to still move the block towards the leftmost as if they are connected (in my example videos, the right edge is actually a continuation of the left edge). Can someone help me to point where exactly I can modify it within FFMPEG source code or x265, or x264?
I took H265 as an example from here. It has a motion.c file which nicely specifies the possible block sizes as shown below, but I can't find the specific loop that traverses the frame. Help is highly appreciated.
#define SETUP_SCALE(W, H) \
sizeScale[LUMA_ ## W ## x ## H] = (H * H) >> 4;
SETUP_SCALE(4, 4);
SETUP_SCALE(8, 8);
SETUP_SCALE(8, 4);
SETUP_SCALE(4, 8);
SETUP_SCALE(16, 16);
SETUP_SCALE(16, 8);
SETUP_SCALE(8, 16);
SETUP_SCALE(16, 12);
SETUP_SCALE(12, 16);
SETUP_SCALE(4, 16);
SETUP_SCALE(16, 4);
SETUP_SCALE(32, 32);
SETUP_SCALE(32, 16);
SETUP_SCALE(16, 32);
SETUP_SCALE(32, 24);
SETUP_SCALE(24, 32);
SETUP_SCALE(32, 8);
SETUP_SCALE(8, 32);
SETUP_SCALE(64, 64);
SETUP_SCALE(64, 32);
SETUP_SCALE(32, 64);
SETUP_SCALE(64, 48);
SETUP_SCALE(48, 64);
SETUP_SCALE(64, 16);
SETUP_SCALE(16, 64);
#undef SETUP_SCALE
A basic pseudo code should be like this:
block.rightX ==block.width; // a block initiates from left part of the frame
while(block.leftX <=frame.width) //until it hits the right most edge (assuming it moves from left to right for search)
for (int i=0;i<block.width();i++)
for(int j=0;j< i<block.height();j++)
block[i][j] = frame_pixel [(block.leftX+i) % frame.width] [block.leftY+j] //if the block's width passes frame's width, we just take the mod.
