Go to the documentation of this file.
35 #define START_CODE 0x000001
37 #define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23)
38 #define IS_IDR_NAL(nal) (nal->type == HEVC_NAL_IDR_W_RADL || nal->type == HEVC_NAL_IDR_N_LP)
65 int i, num = 0, den = 0;
67 unsigned int pps_id, first_slice_in_pic_flag, dependent_slice_segment_flag;
71 s->picture_structure =
sei->picture_timing.picture_struct;
72 s->field_order =
sei->picture_timing.picture_struct;
87 ow = &
sps->output_window;
89 s->coded_width =
sps->width;
90 s->coded_height =
sps->height;
93 s->format =
sps->pix_fmt;
94 avctx->
profile =
sps->ptl.general_ptl.profile_idc;
95 avctx->
level =
sps->ptl.general_ptl.level_idc;
97 if (
sps->vps->vps_timing_info_present_flag) {
98 num =
sps->vps->vps_num_units_in_tick;
99 den =
sps->vps->vps_time_scale;
100 }
else if (
sps->vui.vui_timing_info_present_flag) {
101 num =
sps->vui.vui_num_units_in_tick;
102 den =
sps->vui.vui_time_scale;
105 if (num > 0 && den > 0)
109 if (!first_slice_in_pic_flag) {
110 unsigned int slice_segment_addr;
111 int slice_address_length;
113 if (
pps->dependent_slice_segments_enabled_flag)
114 dependent_slice_segment_flag =
get_bits1(gb);
116 dependent_slice_segment_flag = 0;
120 slice_segment_addr =
get_bitsz(gb, slice_address_length);
121 if (slice_segment_addr >=
sps->ctb_width *
sps->ctb_height) {
127 dependent_slice_segment_flag = 0;
129 if (dependent_slice_segment_flag)
132 for (
i = 0;
i <
pps->num_extra_slice_header_bits;
i++)
146 if (
pps->output_flag_present_flag)
149 if (
sps->separate_colour_plane)
153 int pic_order_cnt_lsb =
get_bits(gb,
sps->log2_max_poc_lsb);
154 s->output_picture_number =
ctx->poc =
157 s->output_picture_number =
ctx->poc = 0;
201 for (
i = 0;
i <
ctx->pkt.nb_nals;
i++) {
250 av_log(avctx,
AV_LOG_ERROR,
"missing picture in access unit with size %d\n", buf_size);
265 for (
i = 0;
i < buf_size;
i++) {
273 nut = (pc->
state64 >> 2 * 8 + 1) & 0x3F;
275 layer_id = (pc->
state64 >> 11) & 0x3F;
281 (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
284 if (!((pc->
state64 >> 6 * 8) & 0xFF))
290 int first_slice_segment_in_pic_flag = buf[
i] >> 7;
291 if (first_slice_segment_in_pic_flag) {
296 if (!((pc->
state64 >> 6 * 8) & 0xFF))
308 const uint8_t **poutbuf,
int *poutbuf_size,
309 const uint8_t *buf,
int buf_size)
314 int is_dummy_buf = !buf_size;
315 const uint8_t *dummy_buf = buf;
321 ctx->parsed_extradata = 1;
335 is_dummy_buf &= (dummy_buf == buf);
341 *poutbuf_size = buf_size;
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, HEVCSEI *sei, int *is_nalff, int *nal_length_size, int err_recognition, int apply_defdispwin, void *logctx)
static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static void hevc_parser_close(AVCodecParserContext *s)
unsigned int bottom_offset
const HEVCPPS * pps_list[HEVC_MAX_PPS_COUNT]
RefStruct references.
@ AV_PICTURE_STRUCTURE_UNKNOWN
unknown
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, AVCodecContext *avctx)
int temporal_id
HEVC only, nuh_temporal_id_plus_1 - 1.
@ H2645_FLAG_SMALL_PADDING
static void skip_bits(GetBitContext *s, int n)
static av_cold void close(AVCodecParserContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type)
Compute POC of the current frame and return it.
@ HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, enum HEVCNALUnitType type)
static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, int buf_size, AVCodecContext *avctx)
Parse NAL units of found picture and decode some basic information.
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
static void ff_hevc_reset_sei(HEVCSEI *sei)
Reset SEI values that are stored on the Context.
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
int level
Encoding level descriptor.
static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, int buf_size)
Find the end of the current frame in the bitstream.
static void skip_bits1(GetBitContext *s)
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
void ff_hevc_ps_uninit(HEVCParamSets *ps)
#define PARSER_FLAG_COMPLETE_FRAMES
#define i(width, name, range_min, range_max)
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
const FFCodecParser ff_hevc_parser
#define PARSER_CODEC_LIST(...)
#define START_CODE
start_code_prefix_one_3bytes
@ HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
main external API structure.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, unsigned nuh_layer_id, int apply_defdispwin)
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
uint64_t state64
contains the last 8 bytes in MSB order
unsigned int right_offset
@ AV_PICTURE_TYPE_P
Predicted.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int nal_length_size, enum AVCodecID codec_id, int flags)
Split an input packet into NAL units.
static av_always_inline av_const int av_ceil_log2_c(int x)
Compute ceil(log2(x)).