Multi-reference frame issues in JM8.5
OUTLINE:
1. Related options for multi-reference frames in the CFG file
2. Data structure and global variables involved in multi-reference frames
3. Save the reconstruction image as reference frame
4. Set a reference frame list before encoding a frame
5, use of multi-reference frames (ie the selection policy problem of the reference frame)
6, legacy problem
1. Related options for multi-reference frames in the CFG file
######################################################################################################################################################################################################################################################################################################## ##############################20coder control
######################################################################################################################################################################################################################################################################################################## ###########################################
...
NumberReferenceFrames = 10 # Number of Previous Frames Used for Inter Motion Search (1-16)
Explanation:
A, first converted into input-> num_reference_frames via configure ()
b, INPUT-> NUM_REFERENCE_FRAMES, then return to the SPS-> Num_Ref_Frames in FillParametersTructures () in the Parset.c file.
C, FillParameterStructures () is actually called by the generateParameterSetsets () function in the Parset.c file, so the SPS is also assigned to active_SPS, and Active_SPS is a global variable.
D, active_sps-> num_ref_frames will be assigned to IMG-> Num_Reference_Frames in the init_img () function in lencod.c.
PLIST0REFERENCES = 0 # p SLICE LIST 0 Reference Override (0 Disable, n <= NumberReferenceFrames)
Explanation:
Used to limit the number of reference frames in LIST0
...
######################################################################################################################################################################################################################################################################################################## ###########################################
# B Frames
######################################################################################################################################################################################################################################################################################################## ###########################################
...
Blist0Reference = 0 # b Slice List 0 Reference Override (0 Disable, N <= NumberReferenceFrames)
Blist1Reference = 0 # b Slice List 1 Reference Override (0 Disable, N = NumberReferenceFrames)
...
2. Data structure and global variables involved in multi-reference frames
a, summary
Multi-reference frame-related important data structures are in the MBuffer.h file.
The important data structure is: StorblePicture, Framestore, DecodedPictureBuffer
Important global variables are:
Extern decodedPictureBuffer DPB;
Extern StoragePicture ** Listx [6];
Extern Int ListxSize [6];
B, the role of each data structure and the relationship between each other
StorblePicture is stored in a frame of frame mode or a field of reconstruction images
Framestore nested StorblePicture, increasing some flag information, if it has been output to file, etc., it can be used for universal representation of data structures (no fraction or frame) DecodedPictureBuffer and nested Framestore, which To save all reconstructed images (should be saved), where many auxiliary parameters are set, such as the use_size used to indicate the number of reconstructed images already saved.
C, the role of each global variable
The DPB's role from above is explained in DecodedPictureBuffer, which is already visible to store all reconstruction images. The value of the value is that it may save a non-reference frame to rebuild images.
ListX [6]: This variable is used to save the reference frame to be used in each of the frames per coded image. However, the reference frame image data to be used to be used is in the structural element corresponding to the DPB.
For P frames, just use Listx [0].
For B frame, use Listx [0], Listx [1]
For MBAFF encoding methods, Listx [2-5] may be used.
3. Save the reconstruction image as reference frame
The function used is: void store_picture_in_dpb (StoragePicture * P), MBuffer.c
This function is adjusted after the back section of the encode_one_frame () of image.c.
The important blocks are as follows:
// first try to remove unused frames When the buffer is full
IF (DPB.USED_SIZE == DPB.size)
{
REMOVE_UNUSED_FRAME_FROM_DPB (); // Only one frame is deleted. Is this strategy effective? doubt? ? ?
}
// Then Output Frames Until One Can Be Removed
While (dpb.used_size == dpb.size)
{
// Non-Reference Frames May Be Output Directly
If (! p-> subscriber_for_reference) // If the current frame does not act as a coupon frame, you can directly output to the reconstruction sequence file.
{
GET_SMALLEST_POC (& PoC, & POS);
IF ((-1 == POS) || (P-> POC { Direct_output (p, p_dec); Return; } } // Flush a frame OUTPUT_ONE_FRAME_FROM_DPB (); // Output frame to file } ... INSERT_PICTURE_IN_DPB (DPB.FS [DPB.USED_SIZE], P); // Insert the current decoding frame into the DPB tail 4. Set a reference frame list before encoding a frame The functions used are: init_lists (), MBuffer.c This function is called in the start portion of the code_a_picture () in Image.c. The important blocks are as follows: (only the case where the frame mode is analyzed) ... // Write the reference frame in the DPB to Listx IF (CurrslicType == i_SLICE) || (CurrsLicetyPE == Si_SLICE))) { ListXsize [0] = 0; ListXsize [1] = 0; Return; } IF ((CurrslicType == P_SLICE) || (CurrsLicetyPE == SP_SLICE)) { // Calculate FramenumWrap and Picnumif (Currpicstructure == Frame) { For (i = 0; i { IF (dpb.fs_ref [i] -> is_USED == 3) { IF ((DPB.FS_REF [I] -> frame-> buy_for_reference) && (! dpb.fs_ref [i] -> frame-> is_long_term)) { ListX [0] [LIST0IDX ] = DPB.FS_REF [I] -> frame; } } } // Order List 0 by PICNUM Qsort (Void *) Listx [0], LIST0IDX, SIZEOF (StorablePicture *), Compare_Pic_BY_PIC_NUM_DESC); ListXsize [0] = LIST0IDX; ... } ELSE // B_SLICE { ... } 5, use of multi-reference frames (ie the selection policy problem of the reference frame) The function used is: PartitionMotionSearch (), MV_Search.c The function of this function is to look for a macroblock or a Macular block for a variety of sizes. The blocks involving multiple reference frames are as follows: ... / / ===== loop over reason Frames ===== For (List = 0; List { For (REF = 0; Ref { ... Note: It can be seen from the above program that JM8.5 selection of multi-reference frames is a full traversal method, so it is highly computational. 6, legacy problem a, in init_lists () for the number of reference frames in Listx [0] and Listx [1], a switched mechanism is used, and I don't know how it is the purpose? B, DPB's reference frame has properties such as short_term or long_term, which affects the entire process of multi-reference frame mechanism, but I don't know how specific functions and principles?