[FFmpeg-devel] [QUESTION] Understanding `fill_decode_neighbors` and `fill_decode_caches` in H.264 Decoding

xu 603219296 at qq.com
Fri Dec 27 16:39:43 EET 2024


Hello FFmpeg developers,


I am currently studying FFmpeg's H.264 decoding implementation and have encountered some challenges in understanding parts of the code, particularly the functions `fill_decode_neighbors` and `fill_decode_caches`.


1, In the `fill_decode_neighbors` function, there is a static array:  
   ```c
   static const uint8_t left_block_options[4][32] = {
       { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 },
       { 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 },
       { 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 },
       { 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }
   };

I am struggling to understand the meaning of the elements in this array. Are they referring to positions, prediction modes, or something else? How is this array used during decoding? Is it related to intra-frame prediction or macroblock boundary processing?


2,In the fill_decode_caches function, I noticed the following comment:/* 
 * 0 . T T. T T T T
 * 1 L . .L . . . .
 * 2 L . .L . . . .
 * 3 . T TL . . . .
 * 4 L . .L . . . .
 * 5 L . .. . . . .
 */
     I am curious about the meaning of this layout. How does it relate to macroblock processing? Are "T" and "L" referring to top and left neighbors, or something else?


3,Given the complexity of these decoding rules, I wonder if there are relevant sections in the FFmpeg documentation, academic papers, or H.264 standards that I can reference to better understand the underlying mechanisms. If possible, could you kindly provide any relevant keywords, links, or references?

I greatly appreciate your time and assistance. Any pointers or suggestions would be incredibly helpful as I navigate through this learning process.

Thank you in advance for your guidance!



Best regards,
Py. Xu


More information about the ffmpeg-devel mailing list