FFmpeg
hevc_parser.c
Go to the documentation of this file.
1 /*
2  * HEVC Annex B format parser
3  *
4  * Copyright (C) 2012 - 2013 Guillaume Martres
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavutil/common.h"
24 
25 #include "golomb.h"
26 #include "hevc.h"
27 #include "hevc_parse.h"
28 #include "hevc_ps.h"
29 #include "hevc_sei.h"
30 #include "h2645_parse.h"
31 #include "parser.h"
32 
33 #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
34 
35 #define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23)
36 #define IS_IDR_NAL(nal) (nal->type == HEVC_NAL_IDR_W_RADL || nal->type == HEVC_NAL_IDR_N_LP)
37 
38 typedef struct HEVCParserContext {
40 
44 
45  int is_avc;
48 
49  int poc;
50  int pocTid0;
52 
54  AVCodecContext *avctx)
55 {
56  HEVCParserContext *ctx = s->priv_data;
57  HEVCParamSets *ps = &ctx->ps;
58  HEVCSEI *sei = &ctx->sei;
59  GetBitContext *gb = &nal->gb;
60  const HEVCWindow *ow;
61  int i, num = 0, den = 0;
62 
63  unsigned int pps_id, first_slice_in_pic_flag, dependent_slice_segment_flag;
64  enum HEVCSliceType slice_type;
65 
66  first_slice_in_pic_flag = get_bits1(gb);
67  s->picture_structure = sei->picture_timing.picture_struct;
68  s->field_order = sei->picture_timing.picture_struct;
69 
70  if (IS_IRAP_NAL(nal)) {
71  s->key_frame = 1;
72  skip_bits1(gb); // no_output_of_prior_pics_flag
73  }
74 
75  pps_id = get_ue_golomb(gb);
76  if (pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[pps_id]) {
77  av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
78  return AVERROR_INVALIDDATA;
79  }
80  ps->pps = (HEVCPPS*)ps->pps_list[pps_id]->data;
81 
82  if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
83  av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
84  return AVERROR_INVALIDDATA;
85  }
86  if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
87  ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
88  ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
89  }
90  ow = &ps->sps->output_window;
91 
92  s->coded_width = ps->sps->width;
93  s->coded_height = ps->sps->height;
94  s->width = ps->sps->width - ow->left_offset - ow->right_offset;
95  s->height = ps->sps->height - ow->top_offset - ow->bottom_offset;
96  s->format = ps->sps->pix_fmt;
97  avctx->profile = ps->sps->ptl.general_ptl.profile_idc;
98  avctx->level = ps->sps->ptl.general_ptl.level_idc;
99 
101  num = ps->vps->vps_num_units_in_tick;
102  den = ps->vps->vps_time_scale;
103  } else if (ps->sps->vui.vui_timing_info_present_flag) {
104  num = ps->sps->vui.vui_num_units_in_tick;
105  den = ps->sps->vui.vui_time_scale;
106  }
107 
108  if (num != 0 && den != 0)
109  av_reduce(&avctx->framerate.den, &avctx->framerate.num,
110  num, den, 1 << 30);
111 
112  if (!first_slice_in_pic_flag) {
113  unsigned int slice_segment_addr;
114  int slice_address_length;
115 
117  dependent_slice_segment_flag = get_bits1(gb);
118  else
119  dependent_slice_segment_flag = 0;
120 
121  slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
122  ps->sps->ctb_height);
123  slice_segment_addr = get_bitsz(gb, slice_address_length);
124  if (slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
125  av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
126  slice_segment_addr);
127  return AVERROR_INVALIDDATA;
128  }
129  } else
130  dependent_slice_segment_flag = 0;
131 
132  if (dependent_slice_segment_flag)
133  return 0; /* break; */
134 
135  for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
136  skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
137 
138  slice_type = get_ue_golomb_31(gb);
139  if (!(slice_type == HEVC_SLICE_I || slice_type == HEVC_SLICE_P ||
140  slice_type == HEVC_SLICE_B)) {
141  av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
142  slice_type);
143  return AVERROR_INVALIDDATA;
144  }
145  s->pict_type = slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B :
146  slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P :
148 
149  if (ps->pps->output_flag_present_flag)
150  skip_bits1(gb); // pic_output_flag
151 
153  skip_bits(gb, 2); // colour_plane_id
154 
155  if (!IS_IDR_NAL(nal)) {
156  int pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb);
157  s->output_picture_number = ctx->poc =
158  ff_hevc_compute_poc(ps->sps, ctx->pocTid0, pic_order_cnt_lsb, nal->type);
159  } else
160  s->output_picture_number = ctx->poc = 0;
161 
162  if (nal->temporal_id == 0 &&
163  nal->type != HEVC_NAL_TRAIL_N &&
164  nal->type != HEVC_NAL_TSA_N &&
165  nal->type != HEVC_NAL_STSA_N &&
166  nal->type != HEVC_NAL_RADL_N &&
167  nal->type != HEVC_NAL_RASL_N &&
168  nal->type != HEVC_NAL_RADL_R &&
169  nal->type != HEVC_NAL_RASL_R)
170  ctx->pocTid0 = ctx->poc;
171 
172  return 1; /* no need to evaluate the rest */
173 }
174 
175 /**
176  * Parse NAL units of found picture and decode some basic information.
177  *
178  * @param s parser context.
179  * @param avctx codec context.
180  * @param buf buffer with field/frame data.
181  * @param buf_size size of the buffer.
182  */
183 static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
184  int buf_size, AVCodecContext *avctx)
185 {
186  HEVCParserContext *ctx = s->priv_data;
187  HEVCParamSets *ps = &ctx->ps;
188  HEVCSEI *sei = &ctx->sei;
189  int ret, i;
190 
191  /* set some sane default values */
192  s->pict_type = AV_PICTURE_TYPE_I;
193  s->key_frame = 0;
194  s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
195 
197 
198  ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, ctx->is_avc,
199  ctx->nal_length_size, AV_CODEC_ID_HEVC, 1, 0);
200  if (ret < 0)
201  return ret;
202 
203  for (i = 0; i < ctx->pkt.nb_nals; i++) {
204  H2645NAL *nal = &ctx->pkt.nals[i];
205  GetBitContext *gb = &nal->gb;
206 
207  if (nal->nuh_layer_id > 0)
208  continue;
209 
210  switch (nal->type) {
211  case HEVC_NAL_VPS:
212  ff_hevc_decode_nal_vps(gb, avctx, ps);
213  break;
214  case HEVC_NAL_SPS:
215  ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
216  break;
217  case HEVC_NAL_PPS:
218  ff_hevc_decode_nal_pps(gb, avctx, ps);
219  break;
220  case HEVC_NAL_SEI_PREFIX:
221  case HEVC_NAL_SEI_SUFFIX:
222  ff_hevc_decode_nal_sei(gb, avctx, sei, ps, nal->type);
223  break;
224  case HEVC_NAL_TRAIL_N:
225  case HEVC_NAL_TRAIL_R:
226  case HEVC_NAL_TSA_N:
227  case HEVC_NAL_TSA_R:
228  case HEVC_NAL_STSA_N:
229  case HEVC_NAL_STSA_R:
230  case HEVC_NAL_BLA_W_LP:
231  case HEVC_NAL_BLA_W_RADL:
232  case HEVC_NAL_BLA_N_LP:
233  case HEVC_NAL_IDR_W_RADL:
234  case HEVC_NAL_IDR_N_LP:
235  case HEVC_NAL_CRA_NUT:
236  case HEVC_NAL_RADL_N:
237  case HEVC_NAL_RADL_R:
238  case HEVC_NAL_RASL_N:
239  case HEVC_NAL_RASL_R:
240  if (ctx->sei.picture_timing.picture_struct == HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING) {
241  s->repeat_pict = 1;
242  } else if (ctx->sei.picture_timing.picture_struct == HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING) {
243  s->repeat_pict = 2;
244  }
245  ret = hevc_parse_slice_header(s, nal, avctx);
246  if (ret)
247  return ret;
248  break;
249  }
250  }
251  /* didn't find a picture! */
252  av_log(avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size);
253  return -1;
254 }
255 
256 /**
257  * Find the end of the current frame in the bitstream.
258  * @return the position of the first byte of the next frame, or END_NOT_FOUND
259  */
260 static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
261  int buf_size)
262 {
263  HEVCParserContext *ctx = s->priv_data;
264  ParseContext *pc = &ctx->pc;
265  int i;
266 
267  for (i = 0; i < buf_size; i++) {
268  int nut;
269 
270  pc->state64 = (pc->state64 << 8) | buf[i];
271 
272  if (((pc->state64 >> 3 * 8) & 0xFFFFFF) != START_CODE)
273  continue;
274 
275  nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
276  // Beginning of access unit
277  if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_EOB_NUT) || nut == HEVC_NAL_SEI_PREFIX ||
278  (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
279  if (pc->frame_start_found) {
280  pc->frame_start_found = 0;
281  return i - 5;
282  }
283  } else if (nut <= HEVC_NAL_RASL_R ||
284  (nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT)) {
285  int first_slice_segment_in_pic_flag = buf[i] >> 7;
286  if (first_slice_segment_in_pic_flag) {
287  if (!pc->frame_start_found) {
288  pc->frame_start_found = 1;
289  } else { // First slice of next frame found
290  pc->frame_start_found = 0;
291  return i - 5;
292  }
293  }
294  }
295  }
296 
297  return END_NOT_FOUND;
298 }
299 
301  const uint8_t **poutbuf, int *poutbuf_size,
302  const uint8_t *buf, int buf_size)
303 {
304  int next;
305  HEVCParserContext *ctx = s->priv_data;
306  ParseContext *pc = &ctx->pc;
307  int is_dummy_buf = !buf_size;
308  const uint8_t *dummy_buf = buf;
309 
310  if (avctx->extradata && !ctx->parsed_extradata) {
311  ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size, &ctx->ps, &ctx->sei,
312  &ctx->is_avc, &ctx->nal_length_size, avctx->err_recognition,
313  1, avctx);
314  ctx->parsed_extradata = 1;
315  }
316 
317  if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
318  next = buf_size;
319  } else {
320  next = hevc_find_frame_end(s, buf, buf_size);
321  if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
322  *poutbuf = NULL;
323  *poutbuf_size = 0;
324  return buf_size;
325  }
326  }
327 
328  is_dummy_buf &= (dummy_buf == buf);
329 
330  if (!is_dummy_buf)
331  parse_nal_units(s, buf, buf_size, avctx);
332 
333  *poutbuf = buf;
334  *poutbuf_size = buf_size;
335  return next;
336 }
337 
339 {
340  HEVCParserContext *ctx = s->priv_data;
341 
342  ff_hevc_ps_uninit(&ctx->ps);
344  ff_hevc_reset_sei(&ctx->sei);
345 
346  av_freep(&ctx->pc.buffer);
347 }
348 
351  .priv_data_size = sizeof(HEVCParserContext),
352  .parser_parse = hevc_parse,
353  .parser_close = hevc_parser_close,
354 };
HEVCSPS::vui
VUI vui
Definition: hevc_ps.h:165
HEVC_NAL_RADL_N
@ HEVC_NAL_RADL_N
Definition: hevc.h:35
HEVCParserContext::sei
HEVCSEI sei
Definition: hevc_parser.c:43
h2645_parse.h
VUI::vui_time_scale
uint32_t vui_time_scale
Definition: hevc_ps.h:63
HEVCSliceType
HEVCSliceType
Definition: hevc.h:95
HEVCWindow::bottom_offset
unsigned int bottom_offset
Definition: hevc_ps.h:47
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
hevc_parser_close
static void hevc_parser_close(AVCodecParserContext *s)
Definition: hevc_parser.c:338
AV_PICTURE_STRUCTURE_UNKNOWN
@ AV_PICTURE_STRUCTURE_UNKNOWN
unknown
Definition: avcodec.h:2806
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1382
HEVC_NAL_STSA_N
@ HEVC_NAL_STSA_N
Definition: hevc.h:33
HEVCParserContext::pc
ParseContext pc
Definition: hevc_parser.c:39
parse_nal_units
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.
Definition: hevc_parser.c:183
HEVCParserContext::pocTid0
int pocTid0
Definition: hevc_parser.c:50
HEVC_MAX_SPS_COUNT
@ HEVC_MAX_SPS_COUNT
Definition: hevc.h:112
H2645NAL::nuh_layer_id
int nuh_layer_id
Definition: h2645_parse.h:67
HEVCPPS::output_flag_present_flag
uint8_t output_flag_present_flag
Definition: hevc_ps.h:258
HEVCVPS::vps_num_units_in_tick
uint32_t vps_num_units_in_tick
Definition: hevc_ps.h:123
HEVC_NAL_TSA_N
@ HEVC_NAL_TSA_N
Definition: hevc.h:31
HEVC_MAX_PPS_COUNT
@ HEVC_MAX_PPS_COUNT
Definition: hevc.h:114
get_ue_golomb
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
Definition: golomb.h:53
ff_h2645_packet_uninit
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
Definition: h2645_parse.c:528
HEVC_NAL_RASL_N
@ HEVC_NAL_RASL_N
Definition: hevc.h:37
HEVC_NAL_STSA_R
@ HEVC_NAL_STSA_R
Definition: hevc.h:34
HEVC_NAL_BLA_W_RADL
@ HEVC_NAL_BLA_W_RADL
Definition: hevc.h:46
hevc_find_frame_end
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.
Definition: hevc_parser.c:260
hevc_parse
static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition: hevc_parser.c:300
H2645NAL::temporal_id
int temporal_id
HEVC only, nuh_temporal_id_plus_1 - 1.
Definition: h2645_parse.h:62
HEVCSPS::output_window
HEVCWindow output_window
Definition: hevc_ps.h:145
HEVCSPS::separate_colour_plane_flag
uint8_t separate_colour_plane_flag
Definition: hevc_ps.h:143
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:371
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1750
golomb.h
exp golomb vlc stuff
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:325
ParseContext
Definition: parser.h:28
HEVCVPS::vps_time_scale
uint32_t vps_time_scale
Definition: hevc_ps.h:124
HEVCParserContext::parsed_extradata
int parsed_extradata
Definition: hevc_parser.c:47
HEVCWindow::left_offset
unsigned int left_offset
Definition: hevc_ps.h:44
GetBitContext
Definition: get_bits.h:107
HEVCParserContext::is_avc
int is_avc
Definition: hevc_parser.c:45
HEVCSPS::log2_max_poc_lsb
unsigned int log2_max_poc_lsb
Definition: hevc_ps.h:154
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
ff_hevc_decode_nal_sei
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, enum HEVCNALUnitType type)
Definition: hevc_sei.c:278
AVRational::num
int num
Numerator.
Definition: rational.h:59
hevc_parse.h
START_CODE
#define START_CODE
start_code_prefix_one_3bytes
Definition: hevc_parser.c:33
HEVCPPS::num_extra_slice_header_bits
int num_extra_slice_header_bits
Definition: hevc_ps.h:283
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
HEVC_NAL_BLA_N_LP
@ HEVC_NAL_BLA_N_LP
Definition: hevc.h:47
HEVCParserContext::pkt
H2645Packet pkt
Definition: hevc_parser.c:41
HEVC_NAL_RADL_R
@ HEVC_NAL_RADL_R
Definition: hevc.h:36
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:528
s
#define s(width, name)
Definition: cbs_vp9.c:256
HEVCSPS::height
int height
Definition: hevc_ps.h:215
HEVCSEI
Definition: hevc_sei.h:95
ctx
AVFormatContext * ctx
Definition: movenc.c:48
HEVCWindow::top_offset
unsigned int top_offset
Definition: hevc_ps.h:46
HEVC_SLICE_I
@ HEVC_SLICE_I
Definition: hevc.h:98
PTLCommon::profile_idc
uint8_t profile_idc
Definition: hevc_ps.h:82
hevc_parse_slice_header
static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, AVCodecContext *avctx)
Definition: hevc_parser.c:53
H2645NAL::type
int type
NAL unit type.
Definition: h2645_parse.h:52
HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING
@ HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING
Definition: hevc_sei.h:36
PTL::general_ptl
PTLCommon general_ptl
Definition: hevc_ps.h:103
if
if(ret)
Definition: filter_design.txt:179
HEVC_NAL_IDR_N_LP
@ HEVC_NAL_IDR_N_LP
Definition: hevc.h:49
HEVC_SLICE_B
@ HEVC_SLICE_B
Definition: hevc.h:96
NULL
#define NULL
Definition: coverity.c:32
ff_hevc_ps_uninit
void ff_hevc_ps_uninit(HEVCParamSets *ps)
Definition: hevc_ps.c:1687
HEVC_NAL_PPS
@ HEVC_NAL_PPS
Definition: hevc.h:63
VUI::vui_timing_info_present_flag
int vui_timing_info_present_flag
Definition: hevc_ps.h:61
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:378
ParseContext::frame_start_found
int frame_start_found
Definition: parser.h:34
HEVCPPS::dependent_slice_segments_enabled_flag
uint8_t dependent_slice_segments_enabled_flag
Definition: hevc_ps.h:261
HEVC_NAL_SEI_SUFFIX
@ HEVC_NAL_SEI_SUFFIX
Definition: hevc.h:69
HEVCParamSets::vps
const HEVCVPS * vps
Definition: hevc_ps.h:320
HEVC_NAL_CRA_NUT
@ HEVC_NAL_CRA_NUT
Definition: hevc.h:50
ff_hevc_decode_extradata
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)
Definition: hevc_parse.c:80
sei
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
Definition: cbs_h264_syntax_template.c:825
AVCodecContext::level
int level
level
Definition: avcodec.h:1691
HEVC_NAL_RASL_R
@ HEVC_NAL_RASL_R
Definition: hevc.h:38
HEVCWindow
Definition: hevc_ps.h:43
AVCodecParser::codec_ids
int codec_ids[7]
Definition: avcodec.h:2972
ff_hevc_decode_nal_sps
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, int apply_defdispwin)
Definition: hevc_ps.c:1190
HEVC_NAL_BLA_W_LP
@ HEVC_NAL_BLA_W_LP
Definition: hevc.h:45
HEVCParserContext::nal_length_size
int nal_length_size
Definition: hevc_parser.c:46
ff_hevc_compute_poc
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.
Definition: hevc_ps.c:1703
H2645NAL::gb
GetBitContext gb
Definition: h2645_parse.h:47
H2645NAL
Definition: h2645_parse.h:34
ff_hevc_decode_nal_vps
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
Definition: hevc_ps.c:436
VUI::vui_num_units_in_tick
uint32_t vui_num_units_in_tick
Definition: hevc_ps.h:62
HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING
@ HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING
Definition: hevc_sei.h:35
ff_h2645_packet_split
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id, int small_padding, int use_ref)
Split an input packet into NAL units.
Definition: h2645_parse.c:396
HEVCParamSets::pps_list
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
Definition: hevc_ps.h:317
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:403
ff_combine_frame
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
Definition: parser.c:199
HEVC_NAL_TRAIL_R
@ HEVC_NAL_TRAIL_R
Definition: hevc.h:30
hevc_ps.h
PARSER_FLAG_COMPLETE_FRAMES
#define PARSER_FLAG_COMPLETE_FRAMES
Definition: avcodec.h:2846
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:527
HEVCParamSets::sps
const HEVCSPS * sps
Definition: hevc_ps.h:321
HEVCParserContext::ps
HEVCParamSets ps
Definition: hevc_parser.c:42
common.h
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:226
HEVC_SLICE_P
@ HEVC_SLICE_P
Definition: hevc.h:97
HEVCSPS::width
int width
Definition: hevc_ps.h:214
parser.h
HEVC_NAL_TSA_R
@ HEVC_NAL_TSA_R
Definition: hevc.h:32
HEVCParserContext::poc
int poc
Definition: hevc_parser.c:49
hevc.h
AVCodecParserContext
Definition: avcodec.h:2812
HEVC_NAL_VPS
@ HEVC_NAL_VPS
Definition: hevc.h:61
HEVC_NAL_IDR_W_RADL
@ HEVC_NAL_IDR_W_RADL
Definition: hevc.h:48
ret
ret
Definition: filter_design.txt:187
HEVCParserContext
Definition: hevc_parser.c:38
ff_hevc_parser
const AVCodecParser ff_hevc_parser
Definition: hevc_parser.c:349
HEVC_NAL_TRAIL_N
@ HEVC_NAL_TRAIL_N
Definition: hevc.h:29
AVCodecContext
main external API structure.
Definition: avcodec.h:426
get_ue_golomb_31
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
Definition: golomb.h:120
AV_PICTURE_TYPE_B
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition: avutil.h:276
IS_IDR_NAL
#define IS_IDR_NAL(nal)
Definition: hevc_parser.c:36
AVRational::den
int den
Denominator.
Definition: rational.h:60
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1565
ParseContext::state64
uint64_t state64
contains the last 8 bytes in MSB order
Definition: parser.h:37
HEVCSPS::ctb_height
int ctb_height
Definition: hevc_ps.h:217
PTLCommon::level_idc
uint8_t level_idc
Definition: hevc_ps.h:99
HEVCParamSets::sps_list
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
Definition: hevc_ps.h:316
HEVCParamSets::pps
const HEVCPPS * pps
Definition: hevc_ps.h:322
HEVCWindow::right_offset
unsigned int right_offset
Definition: hevc_ps.h:45
HEVCVPS::vps_timing_info_present_flag
uint8_t vps_timing_info_present_flag
Definition: hevc_ps.h:122
IS_IRAP_NAL
#define IS_IRAP_NAL(nal)
Definition: hevc_parser.c:35
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
HEVC_NAL_SPS
@ HEVC_NAL_SPS
Definition: hevc.h:62
HEVCSPS::ctb_width
int ctb_width
Definition: hevc_ps.h:216
get_bitsz
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
Definition: get_bits.h:341
HEVCVPS
Definition: hevc_ps.h:110
HEVCSPS
Definition: hevc_ps.h:140
HEVCPPS
Definition: hevc_ps.h:236
HEVCPPS::sps_id
unsigned int sps_id
seq_parameter_set_id
Definition: hevc_ps.h:237
END_NOT_FOUND
#define END_NOT_FOUND
Definition: parser.h:40
ff_hevc_reset_sei
static void ff_hevc_reset_sei(HEVCSEI *sei)
Reset SEI values that are stored on the Context.
Definition: hevc_sei.h:122
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AVCodecParser
Definition: avcodec.h:2971
HEVCSPS::vps_id
unsigned vps_id
Definition: hevc_ps.h:141
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ff_hevc_decode_nal_pps
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
Definition: hevc_ps.c:1439
HEVC_NAL_EOB_NUT
@ HEVC_NAL_EOB_NUT
Definition: hevc.h:66
HEVC_NAL_SEI_PREFIX
@ HEVC_NAL_SEI_PREFIX
Definition: hevc.h:68
H2645Packet
Definition: h2645_parse.h:82
hevc_sei.h
HEVCSPS::pix_fmt
enum AVPixelFormat pix_fmt
Definition: hevc_ps.h:152
HEVCParamSets::vps_list
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]
Definition: hevc_ps.h:315
av_ceil_log2_c
static av_always_inline av_const int av_ceil_log2_c(int x)
Compute ceil(log2(x)).
Definition: common.h:417
HEVCParamSets
Definition: hevc_ps.h:314
HEVCSPS::ptl
PTL ptl
Definition: hevc_ps.h:166