1 /*****************************************************************************
2 * h264_slice.c: h264 slice parser
3 *****************************************************************************
4 * Copyright (C) 2001-17 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20 #ifndef VLC_H264_SLICE_H
21 #define VLC_H264_SLICE_H
23 enum h264_slice_type_e
25 H264_SLICE_TYPE_P
= 0,
30 H264_SLICE_TYPE_UNKNOWN
,
38 enum h264_slice_type_e type
;
39 int i_pic_parameter_set_id
;
43 int i_bottom_field_flag
;
47 int i_pic_order_cnt_type
;
48 int i_pic_order_cnt_lsb
;
49 int i_delta_pic_order_cnt_bottom
;
51 int i_delta_pic_order_cnt0
;
52 int i_delta_pic_order_cnt1
;
57 static inline void h264_slice_init( h264_slice_t
*p_slice
)
59 p_slice
->i_nal_type
= -1;
60 p_slice
->i_nal_ref_idc
= -1;
61 p_slice
->i_idr_pic_id
= -1;
62 p_slice
->i_frame_num
= 0;
63 p_slice
->type
= H264_SLICE_TYPE_UNKNOWN
;
64 p_slice
->i_pic_parameter_set_id
= -1;
65 p_slice
->i_field_pic_flag
= 0;
66 p_slice
->i_bottom_field_flag
= -1;
67 p_slice
->i_pic_order_cnt_type
= -1;
68 p_slice
->i_pic_order_cnt_lsb
= -1;
69 p_slice
->i_delta_pic_order_cnt_bottom
= -1;
70 p_slice
->i_delta_pic_order_cnt0
= 0;
71 p_slice
->i_delta_pic_order_cnt1
= 0;
72 p_slice
->has_mmco5
= false;
75 bool h264_decode_slice( const uint8_t *p_buffer
, size_t i_buffer
,
76 void (* get_sps_pps
)(uint8_t pps_id
, void *,
77 const h264_sequence_parameter_set_t
**,
78 const h264_picture_parameter_set_t
** ),
79 void *, h264_slice_t
*p_slice
);
88 unsigned prevFrameNum
;
89 unsigned prevFrameNumOffset
;
90 int prevRefPictureTFOC
;
91 bool prevRefPictureIsBottomField
;
92 bool prevRefPictureHasMMCO5
;
95 static inline void h264_poc_context_init( h264_poc_context_t
*p_ctx
)
97 p_ctx
->prevPicOrderCnt
.lsb
= 0;
98 p_ctx
->prevPicOrderCnt
.msb
= 0;
99 p_ctx
->prevFrameNum
= 0;
100 p_ctx
->prevFrameNumOffset
= 0;
101 p_ctx
->prevRefPictureIsBottomField
= false;
102 p_ctx
->prevRefPictureHasMMCO5
= false;
105 void h264_compute_poc( const h264_sequence_parameter_set_t
*p_sps
,
106 const h264_slice_t
*p_slice
, h264_poc_context_t
*p_ctx
,
107 int *p_PictureOrderCount
, int *p_tFOC
, int *p_bFOC
);
109 uint8_t h264_get_num_ts( const h264_sequence_parameter_set_t
*p_sps
,
110 const h264_slice_t
*p_slice
, uint8_t pic_struct
, int tFOC
, int bFOC
);