The difference between the I frame and the IDR frame

Source: Internet
Author: User

I the difference between frame and IDR frame:http://blog.csdn.net/skygray/article/details/6223358

The IDR frame belongs to the I frame. When the decoder receives an IDR frame, it discards all reference frame queues (implemented with the X264_reference_reset function-in the encoder.c file). This is a common feature for all I frames, but when an IDR frame is received, the decoder also needs to do the following: Update all PPS and SPS parameters. Thus, on the encoder side, each send an IDR, the corresponding to send a pps&sps_nal_unit

This is an online search for an answer, there is a certain reference value it.

Note: All IDR frames are I-frames, but not all I-frames are IDR frames. That is, the IDR frame is a subset of I frames. (one IDR frame per 250 frames is set in our program)

The procedure we use is this:

/*-------------------Setup Frame Context-----------------------------*/

/* 5:init da ta dependant of frame type */

if (H->fenc->i_type = = X264_TYPE_IDR)

{

/* Reset ref Pictures */

X264_reference_reset (h);

I_nal_type = NAL_SLICE_IDR;

I_NAL_REF_IDC = nal_priority_ highest;

I_slice_type = Slice_type_ I ;

}

else if (H->fenc->i_type = = x264_type_i)

{

I_nal_type = Nal_slice;

I_NAL_REF_IDC = Nal_priority_ high; /* Not completely true if it is (as any i/p is kept as ref) */

I_slice_type = Slice_type_ I ;

}

else if (H->fenc->i_type = = x264_type_p)

{

I_nal_type = Nal_slice;

I_NAL_REF_IDC = Nal_priority_high; /* Not completely true if it is (as any i/p is kept as ref) */

I_slice_type = slice_type_p;

}

else if (H->fenc->i_type = = x264_type_bref)

{

I_nal_type = Nal_slice;

I_NAL_REF_IDC = Nal_priority_high; /* Maybe add mmco to forget it? --Low * *

I_slice_type = Slice_type_b;

}

else/* B Frame */

{

I_nal_type = Nal_slice;

I_NAL_REF_IDC = nal_priority_disposable;

I_slice_type = Slice_type_b;

}

X264_reference_reset the function is defined as follows: (in fact, since this code is generic, it should be the reference frame queue.) However, we only use one reference frame, and "queue" is meaningless. )

static inline void X264_reference_reset (x264_t *h)

{

int i;

/* Reset ref Pictures */

for (i = 1; i < h->frames.i_max_dpb; i++)

{

H->frames.reference[i]->i_poc =-1;

}

H->frames.reference[0]->i_poc = 0;

}

It appears that all reference frame queues are discarded when an IDR frame is encountered (X264_reference_reset (h); ) 。 In fact, our program only uses a reference frame by default, this problem is not very meaningful.

Multi-reference frame case.

For example: There are a sequence of frames: ipppp I P PPP ... (our program does not have B-frames, so the frame sequence is simpler, but the rationale is the same). Encoded according to 3 reference frames.

The reference frame queue Length is 3 because it is encoded according to 3 reference frames.

When encountering the green I , the reference frame queue is not emptied, and the I frame is added to the reference frame queue (I encode without reference frames, of course). )。 When the red P -Frame is detected, the PPI three frame is used for reference.

Not afraid of their own wordy (good memory than bad pen), and then emphasize a: a reference frame, that is, referring to the frame before the current frame (because it does not involve the B-frame, so "the front frame" is both the playing order, but also the encoding sequence). Multiple reference frames is one reason. (I've been misunderstood to find the most appropriate reference frame from the previous frames)

Finally, "but when the IDR frame is received, the decoder also needs to do is to update all PPS and SPS parameters." Thus, on the encoder side, each with an IDR, the corresponding to send a pps&sps_nal_unit "should be right." First think this:)

A chance to find out: idr-instantaneous decoding Refresh (IDR) picture;

A coded which all slices is I or SI slices that causes the decoding process to mark all reference pictures as "Unused for reference", immediately after decoding, the IDR picture. After the decoding of a IDR picture all following coded pictures in decoding order can be decoded without inter predictio N from any picture decoded prior to the IDR picture. The first picture of each coded video sequence is a IDR picture.

In other words, the presence of IDR is tantamount to sending a signal to the decoder to clean up the reference buffer, which says that all encoded frames before this frame cannot be reference frames for Inter. ”

Also: "Since 264 has a multi-frame prediction, it is possible that P after the I-frame in display order will refer to frames before the I-frame so that if I am only looking for the I-frame in random access, then the reference frame of the subsequent frame may be unavailable. A special I-frame, which is defined to ensure that the back P must not refer to its front frame, you can safely random access.

(RPM) The difference between the I frame and the IDR frame

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.