H.264 reference frame List Management Analysis -- Analysis of related functions in JM (medium)

Source: Internet
Author: User

This article describes several functions related to reference frame re-sorting.

[Cpp]
/*!
**************************************** ********************************
* \ Brief
* Reordering process for short-term reference pictures short-term reference frame Reordering
*
**************************************** ********************************
*/
Static void reorder_short_term (StorablePicture ** RefPicListX, int num_ref_idx_lX_active_minus1, int picNumLX, int * refIdxLX)
{
Int cIdx, nIdx;
 
StorablePicture * picLX;
 
PicLX = get_short_term_pic (picNumLX );//! <Obtain the corresponding short-term reference frame based on the given picNumLX
 
For (cIdx = num_ref_idx_lX_active_minus1 + 1; cIdx> * refIdxLX; cIdx --)
RefPicListX [cIdx] = RefPicListX [cIdx-1]; //! <Move the reference frames after refIdxLX in sequence

RefPicListX [(* refIdxLX) ++] = picLX ;//! <Save the specified picNumLX short-term reference frame to the refIdxLX position
 
NIdx = * refIdxLX;
 
For (cIdx = * refIdxLX; cIdx <= num_ref_idx_lX_active_minus1 + 1; cIdx ++)
If (RefPicListX [cIdx]) www.2cto.com
If (RefPicListX [cIdx]-> is_long_term) | (RefPicListX [cIdx]-> pic_num! = PicNumLX ))//! <This operation overwrites the reference frame whose serial number is picNumLX in the reference frame list.
RefPicListX [nIdx ++] = RefPicListX [cIdx];
 
}
 

[Cpp]
/*!
**************************************** ********************************
* \ Brief
* Returns short term pic with given picNum Returns the short-term reference frame of the given picNum number
*
**************************************** ********************************
*/
Static StorablePicture * get_short_term_pic (int picNum)
{
Unsigned I;
 
For (I = 0; I <dpb. ref_frames_in_buffer; I ++ )//! <Traverse reference frames in dpb
{
If (img-> structure = FRAME )//! <Frame mode
{
If (dpb. fs_ref [I]-> is_reference = 3)
If ((! Dpb. fs_ref [I]-> frame-> is_long_term) & (dpb. fs_ref [I]-> frame-> pic_num = picNum ))
Return dpb. fs_ref [I]-> frame ;//! <Find the short-term reference frame with pic_num equal to picNum and not a long-term reference frame, and return
}
Else //! <Field mode (omitted)
{
If (dpb. fs_ref [I]-> is_reference & 1)
If ((! Dpb. fs_ref [I]-> top_field-> is_long_term) & (dpb. fs_ref [I]-> top_field-> pic_num = picNum ))
Return dpb. fs_ref [I]-> top_field;
If (dpb. fs_ref [I]-> is_reference & 2)
If ((! Dpb. fs_ref [I]-> bottom_field-> is_long_term) & (dpb. fs_ref [I]-> bottom_field-> pic_num = picNum ))
Return dpb. fs_ref [I]-> bottom_field;
}
}
// Return NULL;
Return no_reference_picture;
}

 

[Cpp]
/*!
**************************************** ********************************
* \ Brief
* Reordering process for long-term reference pictures
*
**************************************** ********************************
*/
Static void reorder_long_term (StorablePicture ** RefPicListX, int num_ref_idx_lX_active_minus1, int LongTermPicNum, int * refIdxLX)
{
Int cIdx, nIdx;
 
StorablePicture * picLX;
 
PicLX = get_long_term_pic (LongTermPicNum );//! <Obtain the corresponding long-term reference frame of the given LongTermPicNum
 
For (cIdx = num_ref_idx_lX_active_minus1 + 1; cIdx> * refIdxLX; cIdx --)
RefPicListX [cIdx] = RefPicListX [cIdx-1]; //! <Shift the reference frames after refIdxLX to the right in sequence

RefPicListX [(* refIdxLX) ++] = picLX ;//! <Save LongTermPicNum's long-term reference frame to the refIdxLX position
 
NIdx = * refIdxLX;
 
For (cIdx = * refIdxLX; cIdx <= num_ref_idx_lX_active_minus1 + 1; cIdx ++)
If (RefPicListX [cIdx])
If ((! RefPicListX [cIdx]-> is_long_term) | (RefPicListX [cIdx]-> long_term_pic_num! = LongTermPicNum ))//! <Duplicate reference frames with the serial number LongTermPicNum can be overwritten.
RefPicListX [nIdx ++] = RefPicListX [cIdx];
}
[Cpp]
<Pre class = "cpp" name = "code"> /*!
**************************************** ********************************
* \ Brief
* Returns long term pic with given LongtermPicNum
*
**************************************** ********************************
*/
Static StorablePicture * get_long_term_pic (int LongtermPicNum)
{
Unsigned I;
 
For (I = 0; I <dpb. ltref_frames_in_buffer; I ++ )//! <Traverse all long-term reference frames in dpb
{
If (img-> structure = FRAME )//! <Frame mode
{
If (dpb. fs_ltref [I]-> is_reference = 3)
If (dpb. fs_ltref [I]-> frame-> is_long_term) & (dpb. fs_ltref [I]-> frame-> long_term_pic_num = LongtermPicNum ))
Return dpb. fs_ltref [I]-> frame ;//! <Find the long-term reference frame with long_term_pic_num equal to LongtermPicNum and return
}
Else //! <Field mode (omitted)
{
If (dpb. fs_ltref [I]-> is_reference & 1)
If (dpb. fs_ltref [I]-> top_field-> is_long_term) & (dpb. fs_ltref [I]-> top_field-> long_term_pic_num = LongtermPicNum ))
Return dpb. fs_ltref [I]-> top_field;
If (dpb. fs_ltref [I]-> is_reference & 2)
If (dpb. fs_ltref [I]-> bottom_field-> is_long_term) & (dpb. fs_ltref [I]-> bottom_field-> long_term_pic_num = LongtermPicNum ))
Return dpb. fs_ltref [I]-> bottom_field;
}
}
Return NULL;
} </Pre> <pre class = "cpp" name = "code"> </pre>
<Pre> </pre>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.