FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 "hevcdec.h"
28 #include "h2645_parse.h"
29 #include "parser.h"
30 
31 #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
32 
33 #define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23)
34 
35 #define ADVANCED_PARSER CONFIG_HEVC_DECODER
36 
37 typedef struct HEVCParserContext {
39 
42 
44 
45 #if ADVANCED_PARSER
46  HEVCContext h;
47 #endif
49 
50 #if !ADVANCED_PARSER
52  AVCodecContext *avctx)
53 {
55  GetBitContext *gb = &nal->gb;
56 
57  HEVCPPS *pps;
58  HEVCSPS *sps;
59  unsigned int pps_id;
60 
61  get_bits1(gb); // first slice in pic
62  if (IS_IRAP_NAL(nal))
63  get_bits1(gb); // no output of prior pics
64 
65  pps_id = get_ue_golomb_long(gb);
66  if (pps_id >= HEVC_MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) {
67  av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
68  return AVERROR_INVALIDDATA;
69  }
70  pps = (HEVCPPS*)ctx->ps.pps_list[pps_id]->data;
71  sps = (HEVCSPS*)ctx->ps.sps_list[pps->sps_id]->data;
72 
73  /* export the stream parameters */
74  s->coded_width = sps->width;
75  s->coded_height = sps->height;
76  s->width = sps->output_width;
77  s->height = sps->output_height;
78  s->format = sps->pix_fmt;
79  avctx->profile = sps->ptl.general_ptl.profile_idc;
80  avctx->level = sps->ptl.general_ptl.level_idc;
81 
82  /* ignore the rest for now*/
83 
84  return 0;
85 }
86 
88  int buf_size, AVCodecContext *avctx)
89 {
91  int ret, i;
92 
93  ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
94  AV_CODEC_ID_HEVC, 1);
95  if (ret < 0)
96  return ret;
97 
98  for (i = 0; i < ctx->pkt.nb_nals; i++) {
99  H2645NAL *nal = &ctx->pkt.nals[i];
100 
101  /* ignore everything except parameter sets and VCL NALUs */
102  switch (nal->type) {
103  case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break;
104  case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break;
105  case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break;
106  case HEVC_NAL_TRAIL_R:
107  case HEVC_NAL_TRAIL_N:
108  case HEVC_NAL_TSA_N:
109  case HEVC_NAL_TSA_R:
110  case HEVC_NAL_STSA_N:
111  case HEVC_NAL_STSA_R:
112  case HEVC_NAL_BLA_W_LP:
113  case HEVC_NAL_BLA_W_RADL:
114  case HEVC_NAL_BLA_N_LP:
115  case HEVC_NAL_IDR_W_RADL:
116  case HEVC_NAL_IDR_N_LP:
117  case HEVC_NAL_CRA_NUT:
118  case HEVC_NAL_RADL_N:
119  case HEVC_NAL_RADL_R:
120  case HEVC_NAL_RASL_N:
121  case HEVC_NAL_RASL_R:
122  if (buf == avctx->extradata) {
123  av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type);
124  return AVERROR_INVALIDDATA;
125  }
126  hevc_parse_slice_header(s, nal, avctx);
127  break;
128  }
129  }
130 
131  return 0;
132 }
133 #endif
134 
135 /**
136  * Find the end of the current frame in the bitstream.
137  * @return the position of the first byte of the next frame, or END_NOT_FOUND
138  */
140  int buf_size)
141 {
142  int i;
143  ParseContext *pc = s->priv_data;
144 
145  for (i = 0; i < buf_size; i++) {
146  int nut;
147 
148  pc->state64 = (pc->state64 << 8) | buf[i];
149 
150  if (((pc->state64 >> 3 * 8) & 0xFFFFFF) != START_CODE)
151  continue;
152 
153  nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
154  // Beginning of access unit
155  if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_AUD) || nut == HEVC_NAL_SEI_PREFIX ||
156  (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
157  if (pc->frame_start_found) {
158  pc->frame_start_found = 0;
159  return i - 5;
160  }
161  } else if (nut <= HEVC_NAL_RASL_R ||
162  (nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT)) {
163  int first_slice_segment_in_pic_flag = buf[i] >> 7;
164  if (first_slice_segment_in_pic_flag) {
165  if (!pc->frame_start_found) {
166  pc->frame_start_found = 1;
167  } else { // First slice of next frame found
168  pc->frame_start_found = 0;
169  return i - 5;
170  }
171  }
172  }
173  }
174 
175  return END_NOT_FOUND;
176 }
177 
178 #if ADVANCED_PARSER
179 /**
180  * Parse NAL units of found picture and decode some basic information.
181  *
182  * @param s parser context.
183  * @param avctx codec context.
184  * @param buf buffer with field/frame data.
185  * @param buf_size size of the buffer.
186  */
187 static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
188  int buf_size, AVCodecContext *avctx)
189 {
191  HEVCContext *h = &ctx->h;
192  GetBitContext *gb;
193  SliceHeader *sh = &h->sh;
194  HEVCParamSets *ps = &h->ps;
195  H2645Packet *pkt = &ctx->pkt;
196  const uint8_t *buf_end = buf + buf_size;
197  int state = -1, i;
198  H2645NAL *nal;
199  int is_global = buf == avctx->extradata;
200 
201  if (!h->HEVClc)
202  h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
203  if (!h->HEVClc)
204  return AVERROR(ENOMEM);
205 
206  gb = &h->HEVClc->gb;
207 
208  /* set some sane default values */
210  s->key_frame = 0;
212 
213  h->avctx = avctx;
214 
216 
217  if (!buf_size)
218  return 0;
219 
220  if (pkt->nals_allocated < 1) {
221  H2645NAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp));
222  if (!tmp)
223  return AVERROR(ENOMEM);
224  pkt->nals = tmp;
225  memset(pkt->nals, 0, sizeof(*tmp));
226  pkt->nals_allocated = 1;
227  }
228 
229  nal = &pkt->nals[0];
230 
231  for (;;) {
232  int src_length, consumed;
233  int ret;
234  int num = 0, den = 0;
235  buf = avpriv_find_start_code(buf, buf_end, &state);
236  if (--buf + 2 >= buf_end)
237  break;
238  src_length = buf_end - buf;
239 
240  h->nal_unit_type = (*buf >> 1) & 0x3f;
241  h->temporal_id = (*(buf + 1) & 0x07) - 1;
242  if (h->nal_unit_type <= HEVC_NAL_CRA_NUT) {
243  // Do not walk the whole buffer just to decode slice segment header
244  if (src_length > 20)
245  src_length = 20;
246  }
247 
248  consumed = ff_h2645_extract_rbsp(buf, src_length, nal, 1);
249  if (consumed < 0)
250  return consumed;
251 
252  ret = init_get_bits8(gb, nal->data + 2, nal->size);
253  if (ret < 0)
254  return ret;
255 
256  switch (h->nal_unit_type) {
257  case HEVC_NAL_VPS:
258  ff_hevc_decode_nal_vps(gb, avctx, ps);
259  break;
260  case HEVC_NAL_SPS:
261  ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
262  break;
263  case HEVC_NAL_PPS:
264  ff_hevc_decode_nal_pps(gb, avctx, ps);
265  break;
266  case HEVC_NAL_SEI_PREFIX:
267  case HEVC_NAL_SEI_SUFFIX:
269  break;
270  case HEVC_NAL_TRAIL_N:
271  case HEVC_NAL_TRAIL_R:
272  case HEVC_NAL_TSA_N:
273  case HEVC_NAL_TSA_R:
274  case HEVC_NAL_STSA_N:
275  case HEVC_NAL_STSA_R:
276  case HEVC_NAL_RADL_N:
277  case HEVC_NAL_RADL_R:
278  case HEVC_NAL_RASL_N:
279  case HEVC_NAL_RASL_R:
280  case HEVC_NAL_BLA_W_LP:
281  case HEVC_NAL_BLA_W_RADL:
282  case HEVC_NAL_BLA_N_LP:
283  case HEVC_NAL_IDR_W_RADL:
284  case HEVC_NAL_IDR_N_LP:
285  case HEVC_NAL_CRA_NUT:
286 
287  if (is_global) {
288  av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type);
289  return AVERROR_INVALIDDATA;
290  }
291 
294  s->field_order = h->picture_struct;
295 
296  if (IS_IRAP(h)) {
297  s->key_frame = 1;
299  }
300 
301  sh->pps_id = get_ue_golomb(gb);
302  if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
303  av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
304  return AVERROR_INVALIDDATA;
305  }
306  ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
307 
308  if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
309  av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
310  return AVERROR_INVALIDDATA;
311  }
312  if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
313  ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
314  ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
315  }
316 
317  s->coded_width = ps->sps->width;
318  s->coded_height = ps->sps->height;
319  s->width = ps->sps->output_width;
320  s->height = ps->sps->output_height;
321  s->format = ps->sps->pix_fmt;
322  avctx->profile = ps->sps->ptl.general_ptl.profile_idc;
323  avctx->level = ps->sps->ptl.general_ptl.level_idc;
324 
326  num = ps->vps->vps_num_units_in_tick;
327  den = ps->vps->vps_time_scale;
328  } else if (ps->sps->vui.vui_timing_info_present_flag) {
329  num = ps->sps->vui.vui_num_units_in_tick;
330  den = ps->sps->vui.vui_time_scale;
331  }
332 
333  if (num != 0 && den != 0)
334  av_reduce(&avctx->framerate.den, &avctx->framerate.num,
335  num, den, 1 << 30);
336 
337  if (!sh->first_slice_in_pic_flag) {
338  int slice_address_length;
339 
342  else
344 
345  slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
346  ps->sps->ctb_height);
347  sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
348  if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
349  av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
350  sh->slice_segment_addr);
351  return AVERROR_INVALIDDATA;
352  }
353  } else
355 
357  break;
358 
359  for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
360  skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
361 
362  sh->slice_type = get_ue_golomb(gb);
363  if (!(sh->slice_type == HEVC_SLICE_I || sh->slice_type == HEVC_SLICE_P ||
364  sh->slice_type == HEVC_SLICE_B)) {
365  av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
366  sh->slice_type);
367  return AVERROR_INVALIDDATA;
368  }
372 
373  if (ps->pps->output_flag_present_flag)
374  sh->pic_output_flag = get_bits1(gb);
375 
377  sh->colour_plane_id = get_bits(gb, 2);
378 
379  if (!IS_IDR(h)) {
382  } else
383  s->output_picture_number = h->poc = 0;
384 
385  if (h->temporal_id == 0 &&
393  h->pocTid0 = h->poc;
394 
395  return 0; /* no need to evaluate the rest */
396  }
397  buf += consumed;
398  }
399  /* didn't find a picture! */
400  if (!is_global)
401  av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");
402  return -1;
403 }
404 #endif
405 
407  AVCodecContext *avctx,
408  const uint8_t **poutbuf, int *poutbuf_size,
409  const uint8_t *buf, int buf_size)
410 {
411  int next;
412  HEVCParserContext *ctx = s->priv_data;
413  ParseContext *pc = &ctx->pc;
414 
415  if (avctx->extradata && !ctx->parsed_extradata) {
416  parse_nal_units(s, avctx->extradata, avctx->extradata_size, avctx);
417  ctx->parsed_extradata = 1;
418  }
419 
421  next = buf_size;
422  } else {
423  next = hevc_find_frame_end(s, buf, buf_size);
424  if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
425  *poutbuf = NULL;
426  *poutbuf_size = 0;
427  return buf_size;
428  }
429  }
430 
431  parse_nal_units(s, buf, buf_size, avctx);
432 
433  *poutbuf = buf;
434  *poutbuf_size = buf_size;
435  return next;
436 }
437 
438 // Split after the parameter sets at the beginning of the stream if they exist.
439 static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
440 {
441  const uint8_t *ptr = buf, *end = buf + buf_size;
442  uint32_t state = -1;
443  int has_vps = 0;
444  int has_sps = 0;
445  int has_pps = 0;
446  int nut;
447 
448  while (ptr < end) {
449  ptr = avpriv_find_start_code(ptr, end, &state);
450  if ((state >> 8) != START_CODE)
451  break;
452  nut = (state >> 1) & 0x3F;
453  if (nut == HEVC_NAL_VPS)
454  has_vps = 1;
455  else if (nut == HEVC_NAL_SPS)
456  has_sps = 1;
457  else if (nut == HEVC_NAL_PPS)
458  has_pps = 1;
459  else if ((nut != HEVC_NAL_SEI_PREFIX || has_pps) &&
460  nut != HEVC_NAL_AUD) {
461  if (has_vps && has_sps) {
462  while (ptr - 4 > buf && ptr[-5] == 0)
463  ptr--;
464  return ptr - 4 - buf;
465  }
466  }
467  }
468  return 0;
469 }
470 
472 {
473  HEVCParserContext *ctx = s->priv_data;
474  int i;
475 
476 #if ADVANCED_PARSER
477  HEVCContext *h = &ctx->h;
478 
479  for (i = 0; i < FF_ARRAY_ELEMS(h->ps.vps_list); i++)
480  av_buffer_unref(&h->ps.vps_list[i]);
481  for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++)
482  av_buffer_unref(&h->ps.sps_list[i]);
483  for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++)
484  av_buffer_unref(&h->ps.pps_list[i]);
485 
486  h->ps.sps = NULL;
487 
488  av_freep(&h->HEVClc);
489 #endif
490 
491  for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.vps_list); i++)
492  av_buffer_unref(&ctx->ps.vps_list[i]);
493  for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.sps_list); i++)
494  av_buffer_unref(&ctx->ps.sps_list[i]);
495  for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.pps_list); i++)
496  av_buffer_unref(&ctx->ps.pps_list[i]);
497 
498  ctx->ps.sps = NULL;
499 
501 
502  av_freep(&ctx->pc.buffer);
503 }
504 
507  .priv_data_size = sizeof(HEVCParserContext),
508  .parser_parse = hevc_parse,
509  .parser_close = hevc_parser_close,
510  .split = hevc_split,
511 };
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)
Split an input packet into NAL units.
Definition: h2645_parse.c:250
const HEVCPPS * pps
Definition: hevc_ps.h:319
#define NULL
Definition: coverity.c:32
AVRational framerate
Definition: avcodec.h:3429
const char * s
Definition: avisynth_c.h:768
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int pic_order_cnt_lsb
Definition: hevcdec.h:257
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:125
static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, AVCodecContext *avctx)
Definition: hevc_parser.c:51
int ctb_height
Definition: hevc_ps.h:215
AVBufferRef * vps_list[HEVC_MAX_VPS_COUNT]
Definition: hevc_ps.h:312
int size
Definition: h2645_parse.h:35
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:261
static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Definition: hevc_parser.c:439
int width
Dimensions of the decoded video intended for presentation.
Definition: avcodec.h:5222
VUI vui
Definition: hevc_ps.h:167
enum AVFieldOrder field_order
Definition: avcodec.h:5199
int num
Numerator.
Definition: rational.h:59
uint32_t vui_time_scale
Definition: hevc_ps.h:76
int codec_ids[5]
Definition: avcodec.h:5243
int coded_width
Dimensions of the coded video.
Definition: avcodec.h:5228
H2645Packet pkt
Definition: hevc_parser.c:40
HEVCParamSets ps
Definition: hevcdec.h:492
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
static AVPacket pkt
uint8_t dependent_slice_segment_flag
Definition: hevcdec.h:260
int profile
profile
Definition: avcodec.h:3235
int frame_start_found
Definition: parser.h:34
int width
Definition: hevc_ps.h:212
int output_width
Definition: hevc_ps.h:148
unsigned int slice_segment_addr
address (in raster order) of the first block in the current slice
Definition: hevcdec.h:251
enum HEVCSliceType slice_type
Definition: hevcdec.h:255
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
Definition: hevc_ps.h:313
enum AVPictureStructure picture_structure
Indicate whether a picture is coded as a frame, top field or bottom field.
Definition: avcodec.h:5209
uint8_t
enum HEVCNALUnitType nal_unit_type
Definition: hevcdec.h:503
void ff_hevc_reset_sei(HEVCContext *s)
Reset SEI values that are stored on the Context.
Definition: hevc_sei.c:383
uint8_t vps_timing_info_present_flag
Definition: hevc_ps.h:124
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
const HEVCVPS * vps
Definition: hevc_ps.h:317
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1847
AVCodecContext * avctx
Definition: hevcdec.h:469
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
Definition: h2645_parse.c:371
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal, int small_padding)
Extract the raw (unescaped) bitstream.
Definition: h2645_parse.c:32
uint8_t first_slice_in_pic_flag
Definition: hevcdec.h:259
AVBufferRef * pps_list[HEVC_MAX_PPS_COUNT]
Definition: hevc_ps.h:314
uint8_t pic_output_flag
Definition: hevcdec.h:261
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
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:184
#define av_log(a,...)
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
int temporal_id
temporal_id_plus1 - 1
Definition: hevcdec.h:504
uint8_t no_output_of_prior_pics_flag
Definition: hevcdec.h:274
HEVCParamSets ps
Definition: hevc_parser.c:41
uint8_t colour_plane_id
RPS coded in the slice header itself is stored here.
Definition: hevcdec.h:262
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
Definition: golomb.h:53
unsigned int log2_max_poc_lsb
Definition: hevc_ps.h:157
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
Definition: hevc_ps.c:416
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:250
#define AVERROR(e)
Definition: error.h:43
int vui_timing_info_present_flag
Definition: hevc_ps.h:74
static struct @253 state
int picture_struct
Definition: hevcdec.h:587
#define IS_IDR(s)
Definition: hevcdec.h:76
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:139
static char * split(char *message, char delim)
Definition: af_channelmap.c:81
static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, int buf_size, AVCodecContext *avctx)
Definition: hevc_parser.c:87
uint32_t vps_num_units_in_tick
Definition: hevc_ps.h:125
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
Compute POC of the current frame and return it.
Definition: hevc_refs.c:519
const HEVCSPS * sps
Definition: hevc_ps.h:318
#define IS_IRAP(s)
Definition: hevcdec.h:79
uint8_t profile_idc
Definition: hevc_ps.h:95
int output_height
Definition: hevc_ps.h:148
AVFormatContext * ctx
Definition: movenc.c:48
int level
level
Definition: avcodec.h:3333
int ctb_width
Definition: hevc_ps.h:214
int height
Definition: hevc_ps.h:213
uint8_t output_flag_present_flag
Definition: hevc_ps.h:256
PTLCommon general_ptl
Definition: hevc_ps.h:105
int type
NAL unit type.
Definition: h2645_parse.h:52
#define IS_IRAP_NAL(nal)
Definition: hevc_parser.c:33
unsigned vps_id
Definition: hevc_ps.h:143
#define FF_ARRAY_ELEMS(a)
ParseContext pc
Definition: hevc_parser.c:38
unsigned int pps_id
address (in raster order) of the first block in the current slice segment
Definition: hevcdec.h:248
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
Definition: golomb.h:85
uint32_t vps_time_scale
Definition: hevc_ps.h:126
enum AVPixelFormat pix_fmt
Definition: hevc_ps.h:155
uint8_t * buffer
Definition: parser.h:29
int nals_allocated
Definition: h2645_parse.h:72
PTL ptl
Definition: hevc_ps.h:168
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:456
#define START_CODE
start_code_prefix_one_3bytes
Definition: hevc_parser.c:31
int ff_hevc_decode_nal_sei(HEVCContext *s)
Definition: hevc_sei.c:371
unsigned int sps_id
seq_parameter_set_id
Definition: hevc_ps.h:235
main external API structure.
Definition: avcodec.h:1732
int num_extra_slice_header_bits
Definition: hevc_ps.h:281
uint8_t * data
The data buffer.
Definition: buffer.h:89
const uint8_t * data
Definition: h2645_parse.h:36
void * buf
Definition: avisynth_c.h:690
AVCodecParser ff_hevc_parser
Definition: hevc_parser.c:505
uint32_t vui_num_units_in_tick
Definition: hevc_ps.h:75
int extradata_size
Definition: avcodec.h:1848
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:313
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:306
uint64_t state64
contains the last 8 bytes in MSB order
Definition: parser.h:37
#define HEVC_MAX_SPS_COUNT
Definition: hevc.h:66
GetBitContext gb
Definition: hevcdec.h:431
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
Definition: hevc_ps.c:1467
#define END_NOT_FOUND
Definition: parser.h:40
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, int apply_defdispwin)
Definition: hevc_ps.c:1224
int pocTid0
Definition: hevcdec.h:508
HEVCLocalContext * HEVClc
Definition: hevcdec.h:474
int output_picture_number
Picture number incremented in presentation or output order.
Definition: avcodec.h:5217
uint8_t level_idc
Definition: hevc_ps.h:97
common internal and external API header
if(ret< 0)
Definition: vf_mcdeint.c:282
Bi-dir predicted.
Definition: avutil.h:276
#define HEVC_MAX_PPS_COUNT
Definition: hevc.h:67
#define PARSER_FLAG_COMPLETE_FRAMES
Definition: avcodec.h:5109
int den
Denominator.
Definition: rational.h:60
GetBitContext gb
Definition: h2645_parse.h:47
int format
The format of the coded data, corresponds to enum AVPixelFormat for video and for enum AVSampleFormat...
Definition: avcodec.h:5239
H2645NAL * nals
Definition: h2645_parse.h:70
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:406
#define av_freep(p)
static void hevc_parser_close(AVCodecParserContext *s)
Definition: hevc_parser.c:471
static av_always_inline av_const int av_ceil_log2_c(int x)
Compute ceil(log2(x)).
Definition: common.h:308
SliceHeader sh
Definition: hevcdec.h:500
exp golomb vlc stuff
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
Definition: avcodec.h:5124
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
Definition: hevc_ps.h:145
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
Definition: get_bits.h:276
Predicted.
Definition: avutil.h:275
uint8_t dependent_slice_segments_enabled_flag
Definition: hevc_ps.h:259
static uint8_t tmp[11]
Definition: aes_ctr.c:26