1.
Nalu_unit_type = * (unsigned char *) pemptybuf-> buf1_addr + 4 );
Nalu_unit_type = nalu_unit_type & 0x1f;
If (nalu_unit_type <= 5 & nalu_unit_type> = 1)
{
Slice_sum ++;
Printf ("% s: nalu_unit_type = % d, frame_size = % d, frame_id = % d, slice_sum = % d \ n" ,__ func __, nalu_unit_type, pemptybuf-> filledbufsize, frame_id, slice_sum );
}
Else
{
Frame_flag ++;
If (nalu_unit_type = 6) printf ("Sei... \ n ");
Else if (nalu_unit_type = 7) printf ("SPS... \ n ");
Else if (nalu_unit_type = 8) printf ("PPS... \ n ");
Else if (nalu_unit_type = 9) printf ("Cut FP... \ n ");
Else if (nalu_unit_type = 10) printf ("SPS end... \ n ");
Else if (nalu_unit_type = 11) printf ("stream end... \ n ");
Else printf ("unknow frame! \ N ");
Printf ("nalu_unit_type = % d, frame_flag = % d, slice_sum = % d, frame_id = % d \ n", nalu_unit_type, frame_flag, slice_sum, frame_id );
}
First_mb_in_slice = * (unsigned char *) pemptybuf-> bufvirtaddr + 5 );
If (first_mb_in_slice & 0x80) = 0x80)
Printf ("% s: first_mb_in_slice = % d frame_id = % d \ n" ,__ func __, first_mb_in_slice, frame_id); // per frame all is IFRAME
For (wordcount = 4; wordcount <bufferlen; wordcount ++)
{
Loopcount = wordcount;
If (stream [loopcount ++] = 0 & stream [loopcount ++] = 0 &&
Stream [loopcount ++] = 0 & stream [loopcount ++] = 0x01) |
(Stream [loopcount ++] = 0 & stream [loopcount ++] = 0 &&
Stream [loopcount ++] = 1 ))
{
Newnaltype = stream [loopcount ++] & 0x1f;
Firstmbinsliceflag = stream [loopcount ++] & 0x80; // Reuser header nal
Vcl_nal_flag = (newnaltype <= 5) & (newnaltype> 0 ));
If (vcl_nal_flag & prev_vcl_nal_flag) // It is the new frame between two frames, and it is the first block, I frame or P frame. The start of the new frame and the end of the previous Frame
{
Prev_nal_type = newnaltype;
Prev_vcl_nal_flag = vcl_nal_flag;
If (firstmbinsliceflag ))
Break;
}
If (prev_vcl_nal_flag &&! Vcl_nal_flag) // non-slice, but it may be sps pps sei IDR, which has no macro block and is also made into a frame.
{
Prev_nal_type = newnaltype;
Prev_vcl_nal_flag = vcl_nal_flag;
Break;
}
Prev_nal_type = newnaltype;
Prev_vcl_nal_flag = vcl_nal_flag;
}
Nallength ++;
}
2.
* (ADDR + 5) & 0x1f starting with SPS is 07 (67) followed by PPS 08 (68), SEI 06, IDR 05 (65) for decoding the first frame
3.
Next there will be I, and P frame I frame 05 (65), P frame 01 (41)
An SPS includes sps pps sei IDR as the first frame, and the first_mb_slice is the basic frame demarcation line.
Mw3 9 IDR Frames
Each 0001 is a server Load balancer MB.
Http://www.cnitblog.com/vcommon/archive/2007/05/31/27842.html Columbus code !!!
Http://70565912.blog.51cto.com/1358202/533736/
- // Determine whether the frame ends
- For (uint32_t I = 3; I <nal_length; I ++)
- {
- If (p_nal [I] & 0x80)
- {
- // Find frame_begin !!!! End of the previous frame, start of the next frame
- }
- }
After being resolved to the NALU at the end of a frame, you can determine the start and end of each frame (slice. Parse the slice_type of the slice. Based on the slice_type, you can determine the IPB type of the slice.
- // Determine the frame type based on the slice type
- Switch (slice. I _slice_type)
- {
- Case 2: Case 7:
- Case 4: Case 9:
- * P_flags = 0x0002/* block_flag_type_ I */;
- Break;
- Case 0: Case 5:
- Case 3: Case 8:
- * P_flags = 0x0004/* block_flag_type_p */;
- Break;
- Case 1:
- Case 6:
- * P_flags = 0x0008/* block_flag_type_ B */;
- Break;
- Default:
- * P_flags = 0;
- Break;
- }
Http://bbs.csdn.net/topics/380262907
Typedef struct
{
/* The largest layered structure does not cancel the sequence layer and image layer at the same time, and most of the syntactic elements originally belonging to the sequence and the header are removed to form
Parameter sets at the sequence and image levels. The remaining part is placed in the slice */
X1__sps_t * SPS;/* sequence Parameter Set */
X__pps_t * PPS;/* image parameter set */
/* Slice_type
Specify the slice type */
Int I _type;
// First_mb_in_slice
/* The address of the first macro block in the film. The film uses this syntactic element to calibrate its own address.
In the frame field adaptive mode, macro blocks appear in pairs. This is the first macro block pair represented by the syntactic element,
The actual address corresponding to the first macro block should be 2 * first_mb_in_slice */
Int I _first_mb;
Int I _last_mb;
Int I _pps_id;/* sequence number of the image parameter set */
// Frame_num
/* Each reference frame has a continuous frame_num as their identifier, which indicates the decoding sequence of each image.
However, as we can see in the table, the appearance of frame_num does not have the if statement restriction, which indicates that the titles of non-reference frames will also contain frame_num
Indicates that when the image is a reference frame, the syntactic element it carries makes sense during decoding */
Int I _frame_num;
Int B _mbaff;
// Field_pic_flag
/* Indicates the only syntactic element in the image encoding mode in the slice layer. The so-called encoding mode refers to frame encoding, field encoding, and frame field adaptive encoding.
This syntactic element belongs to field encoding when it is set to 1, and 0 is not field encoding */
Int B _field_pic;
/* If it is equal to 1, it indicates that the current image belongs to the base field. If it is equal to 0, it indicates that the current image belongs to the top field */
Int B _bottom_field;
/* IDR image identification. Different IDR images have different idr_pic_id values. IDR images are not the same as I images */
Int I _idr_pic_id;/*-1 If nal_type! = 5 */
/* The first POC algorithm uses this syntactic element to calculate the POC value. In the first POC algorithm, the POC value is explicitly transferred */
Int I _poc_lsb;
Int I _delta_poc_bottom;
/* The second and third algorithms of POC are mapped from frame_num. These two syntaxes are used for ing algorithms.
Delta_pic_order_cnt [0] is used for the base field and the field encoding Mode Field in the frame field encoding mode,
Delta_pic_order_cnt [1] is used for the top field in frame encoding mode. */
Int I _delta_poc [2];
// Redundant_pic_cnt
/* ID of the redundant part */
Int I _redundant_pic_cnt;
// Direct_spatial_mv_pred_flag
/* Specify whether to use time prediction or spatial prediction when B's direct prediction mode is set to 1. The spatial prediction value is set to 0 */
Int B _direct_spatial_mv_pred;
// Num_ref_idx_active_override_flag
/* The syntax elements num_ref_idx_10_active_minus1 and num_ref_idx_11_active_minus1 appear in the image parameter set.
Specify the number of reference frames actually available in the current reference frame queue. Reload the syntaxes on the titles to make a specific image more flexible.
This syntactic element indicates whether the title header will be reloaded. If it is equal to 1, a new num_ref_idx_10_active_minus1 */
Int B _num_ref_idx_override;
Int I _num_ref_idx_l0_active;
Int I _num_ref_idx_l1_active;
/* Reference the semantics of the rearranged image */
/* Indicates whether to perform the re-sorting operation. When the syntax is equal to 1, it indicates that a series of syntaxes are followed for reference to the re-sorting of the frame queue */
Int B _ref_pic_list_reordering_l0;
Int B _ref_pic_list_reordering_l1;
Struct {
Int IDC;
Int ARG;
} Ref_pic_list_order [2] [16];
// Cabac_init_idc
/* The table Selection Range for cabac Initialization is 0 ~ 2 */
Int I _cabac_init_idc;
Int I _qp;
/* Specify the initial values of the quantization parameters used for all macro blocks of the current chip (qP */
Int I _qp_delta;
/* Whether the P Macro Block decoding method in the SP frame is switching */
Int B _sp_for_swidth;
/* Similar to the I _qp_delta syntax */
Int I _qs_delta;
/* Deblocking Filter */
/* Specify some filtering settings */
Int I _disable_deblocking_filter_idc;
Int I _alpha_c0_offset;
Int I _beta_offset;
} X264_slice_header_t;
Http://linfengdu.blog.163.com/blog/static/117710732009111861540971/
Http://www.baidu.com? Ie = UTF-8 & F = 8 & Tn = Baidu & WD = bytes & rsv_bp = 1 & rsv_enter = 1 & rsv_n = 2 & rsv_sug3 = 1 & rsv_sug4 = 385 & rsv_sug2 = 0 & inputt = 1, 842
Multimedia Development --- h264 stream extraction and decoding Analysis