3

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?

enter image description here

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.
Tina J
  • 579
  • 1
  • 7
  • 21
  • 1
    I think your point is only related to the codec (x264 or x265), and not related to ffmpeg. You may want to edit your questions a bit. Other hint in case of no ones cold answer, you could send an email to the x265 developers through their mailing-list. Good luck with project! – RawBean Jun 16 '16 at 10:28
  • How can we ping him? @LordNeckbeard Can you please me? It doesn't have to be on H265, but targeting the latest version is always the best! – Tina J Jun 16 '16 at 16:56
  • oh, got his email... – Tina J Jun 16 '16 at 16:57
  • 1
    Sorry, but I don't have an answer for this question. Perhaps there is a x265 user help mailing list. Just so you know for next time, [crossposting the same question](http://stackoverflow.com/questions/37849595/ffmpeg-motion-compensation-and-search) and making [duplicate questions](http://stackoverflow.com/questions/37870564/libx265-motion-compensation-and-cu-traverse) is not recommended on Stack Exchange sites. – llogan Jun 17 '16 at 18:20
  • Yep. I was understand. I asked my group mates to ask the same question for more visibility. – Tina J Jun 17 '16 at 19:39

0 Answers0