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 "h2645_parse.h"
28 #include "parser.h"
29 
30 #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
31 
32 #define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23)
33 
34 #define ADVANCED_PARSER CONFIG_HEVC_DECODER
35 
36 typedef struct HEVCParserContext {
38 
41 
43 
44 #if ADVANCED_PARSER
45  HEVCContext h;
46 #endif
48 
49 #if !ADVANCED_PARSER
51  AVCodecContext *avctx)
52 {
54  GetBitContext *gb = &nal->gb;
55 
56  HEVCPPS *pps;
57  HEVCSPS *sps;
58  unsigned int pps_id;
59 
60  get_bits1(gb); // first slice in pic
61  if (IS_IRAP_NAL(nal))
62  get_bits1(gb); // no output of prior pics
63 
64  pps_id = get_ue_golomb_long(gb);
65  if (pps_id >= MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) {
66  av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
67  return AVERROR_INVALIDDATA;
68  }
69  pps = (HEVCPPS*)ctx->ps.pps_list[pps_id]->data;
70  sps = (HEVCSPS*)ctx->ps.sps_list[pps->sps_id]->data;
71 
72  /* export the stream parameters */
73  s->coded_width = sps->width;
74  s->coded_height = sps->height;
75  s->width = sps->output_width;
76  s->height = sps->output_height;
77  s->format = sps->pix_fmt;
78  avctx->profile = sps->ptl.general_ptl.profile_idc;
79  avctx->level = sps->ptl.general_ptl.level_idc;
80 
81  /* ignore the rest for now*/
82 
83  return 0;
84 }
85 
87  int buf_size, AVCodecContext *avctx)
88 {
90  int ret, i;
91 
92  ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
93  AV_CODEC_ID_HEVC, 1);
94  if (ret < 0)
95  return ret;
96 
97  for (i = 0; i < ctx->pkt.nb_nals; i++) {
98  H2645NAL *nal = &ctx->pkt.nals[i];
99 
100  /* ignore everything except parameter sets and VCL NALUs */
101  switch (nal->type) {
102  case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break;
103  case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break;
104  case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break;
105  case NAL_TRAIL_R:
106  case NAL_TRAIL_N:
107  case NAL_TSA_N:
108  case NAL_TSA_R:
109  case NAL_STSA_N:
110  case NAL_STSA_R:
111  case NAL_BLA_W_LP:
112  case NAL_BLA_W_RADL:
113  case NAL_BLA_N_LP:
114  case NAL_IDR_W_RADL:
115  case NAL_IDR_N_LP:
116  case NAL_CRA_NUT:
117  case NAL_RADL_N:
118  case NAL_RADL_R:
119  case NAL_RASL_N:
120  case NAL_RASL_R:
121  if (buf == avctx->extradata) {
122  av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type);
123  return AVERROR_INVALIDDATA;
124  }
125  hevc_parse_slice_header(s, nal, avctx);
126  break;
127  }
128  }
129 
130  return 0;
131 }
132 #endif
133 
134 /**
135  * Find the end of the current frame in the bitstream.
136  * @return the position of the first byte of the next frame, or END_NOT_FOUND
137  */
139  int buf_size)
140 {
141  int i;
142  ParseContext *pc = s->priv_data;
143 
144  for (i = 0; i < buf_size; i++) {
145  int nut;
146 
147  pc->state64 = (pc->state64 << 8) | buf[i];
148 
149  if (((pc->state64 >> 3 * 8) & 0xFFFFFF) != START_CODE)
150  continue;
151 
152  nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
153  // Beginning of access unit
154  if ((nut >= NAL_VPS && nut <= NAL_AUD) || nut == NAL_SEI_PREFIX ||
155  (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
156  if (pc->frame_start_found) {
157  pc->frame_start_found = 0;
158  return i - 5;
159  }
160  } else if (nut <= NAL_RASL_R ||
161  (nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT)) {
162  int first_slice_segment_in_pic_flag = buf[i] >> 7;
163  if (first_slice_segment_in_pic_flag) {
164  if (!pc->frame_start_found) {
165  pc->frame_start_found = 1;
166  } else { // First slice of next frame found
167  pc->frame_start_found = 0;
168  return i - 5;
169  }
170  }
171  }
172  }
173 
174  return END_NOT_FOUND;
175 }
176 
177 #if ADVANCED_PARSER
178 /**
179  * Parse NAL units of found picture and decode some basic information.
180  *
181  * @param s parser context.
182  * @param avctx codec context.
183  * @param buf buffer with field/frame data.
184  * @param buf_size size of the buffer.
185  */
186 static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
187  int buf_size, AVCodecContext *avctx)
188 {
190  HEVCContext *h = &ctx->h;
191  GetBitContext *gb;
192  SliceHeader *sh = &h->sh;
193  HEVCParamSets *ps = &h->ps;
194  H2645Packet *pkt = &ctx->pkt;
195  const uint8_t *buf_end = buf + buf_size;
196  int state = -1, i;
197  H2645NAL *nal;
198  int is_global = buf == avctx->extradata;
199 
200  if (!h->HEVClc)
201  h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
202  if (!h->HEVClc)
203  return AVERROR(ENOMEM);
204 
205  gb = &h->HEVClc->gb;
206 
207  /* set some sane default values */
209  s->key_frame = 0;
211 
212  h->avctx = avctx;
213 
215 
216  if (!buf_size)
217  return 0;
218 
219  if (pkt->nals_allocated < 1) {
220  H2645NAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp));
221  if (!tmp)
222  return AVERROR(ENOMEM);
223  pkt->nals = tmp;
224  memset(pkt->nals, 0, sizeof(*tmp));
225  pkt->nals_allocated = 1;
226  }
227 
228  nal = &pkt->nals[0];
229 
230  for (;;) {
231  int src_length, consumed;
232  int ret;
233  buf = avpriv_find_start_code(buf, buf_end, &state);
234  if (--buf + 2 >= buf_end)
235  break;
236  src_length = buf_end - buf;
237 
238  h->nal_unit_type = (*buf >> 1) & 0x3f;
239  h->temporal_id = (*(buf + 1) & 0x07) - 1;
240  if (h->nal_unit_type <= NAL_CRA_NUT) {
241  // Do not walk the whole buffer just to decode slice segment header
242  if (src_length > 20)
243  src_length = 20;
244  }
245 
246  consumed = ff_h2645_extract_rbsp(buf, src_length, nal, 1);
247  if (consumed < 0)
248  return consumed;
249 
250  ret = init_get_bits8(gb, nal->data + 2, nal->size);
251  if (ret < 0)
252  return ret;
253 
254  switch (h->nal_unit_type) {
255  case NAL_VPS:
256  ff_hevc_decode_nal_vps(gb, avctx, ps);
257  break;
258  case NAL_SPS:
259  ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
260  break;
261  case NAL_PPS:
262  ff_hevc_decode_nal_pps(gb, avctx, ps);
263  break;
264  case NAL_SEI_PREFIX:
265  case NAL_SEI_SUFFIX:
267  break;
268  case NAL_TRAIL_N:
269  case NAL_TRAIL_R:
270  case NAL_TSA_N:
271  case NAL_TSA_R:
272  case NAL_STSA_N:
273  case NAL_STSA_R:
274  case NAL_RADL_N:
275  case NAL_RADL_R:
276  case NAL_RASL_N:
277  case NAL_RASL_R:
278  case NAL_BLA_W_LP:
279  case NAL_BLA_W_RADL:
280  case NAL_BLA_N_LP:
281  case NAL_IDR_W_RADL:
282  case NAL_IDR_N_LP:
283  case NAL_CRA_NUT:
284 
285  if (is_global) {
286  av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type);
287  return AVERROR_INVALIDDATA;
288  }
289 
292  s->field_order = h->picture_struct;
293 
294  if (IS_IRAP(h)) {
295  s->key_frame = 1;
297  }
298 
299  sh->pps_id = get_ue_golomb(gb);
300  if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
301  av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
302  return AVERROR_INVALIDDATA;
303  }
304  ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
305 
306  if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
307  av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
308  return AVERROR_INVALIDDATA;
309  }
310  if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
311  ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
312  ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
313  }
314 
315  if (!sh->first_slice_in_pic_flag) {
316  int slice_address_length;
317 
320  else
322 
323  slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
324  ps->sps->ctb_height);
325  sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
326  if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
327  av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
328  sh->slice_segment_addr);
329  return AVERROR_INVALIDDATA;
330  }
331  } else
333 
335  break;
336 
337  for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
338  skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
339 
340  sh->slice_type = get_ue_golomb(gb);
341  if (!(sh->slice_type == I_SLICE || sh->slice_type == P_SLICE ||
342  sh->slice_type == B_SLICE)) {
343  av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
344  sh->slice_type);
345  return AVERROR_INVALIDDATA;
346  }
350 
351  if (ps->pps->output_flag_present_flag)
352  sh->pic_output_flag = get_bits1(gb);
353 
355  sh->colour_plane_id = get_bits(gb, 2);
356 
357  if (!IS_IDR(h)) {
360  } else
361  s->output_picture_number = h->poc = 0;
362 
363  if (h->temporal_id == 0 &&
364  h->nal_unit_type != NAL_TRAIL_N &&
365  h->nal_unit_type != NAL_TSA_N &&
366  h->nal_unit_type != NAL_STSA_N &&
367  h->nal_unit_type != NAL_RADL_N &&
368  h->nal_unit_type != NAL_RASL_N &&
369  h->nal_unit_type != NAL_RADL_R &&
371  h->pocTid0 = h->poc;
372 
373  return 0; /* no need to evaluate the rest */
374  }
375  buf += consumed;
376  }
377  /* didn't find a picture! */
378  if (!is_global)
379  av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");
380  return -1;
381 }
382 #endif
383 
385  AVCodecContext *avctx,
386  const uint8_t **poutbuf, int *poutbuf_size,
387  const uint8_t *buf, int buf_size)
388 {
389  int next;
390  HEVCParserContext *ctx = s->priv_data;
391  ParseContext *pc = &ctx->pc;
392 
393  if (avctx->extradata && !ctx->parsed_extradata) {
394  parse_nal_units(s, avctx->extradata, avctx->extradata_size, avctx);
395  ctx->parsed_extradata = 1;
396  }
397 
399  next = buf_size;
400  } else {
401  next = hevc_find_frame_end(s, buf, buf_size);
402  if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
403  *poutbuf = NULL;
404  *poutbuf_size = 0;
405  return buf_size;
406  }
407  }
408 
409  parse_nal_units(s, buf, buf_size, avctx);
410 
411  *poutbuf = buf;
412  *poutbuf_size = buf_size;
413  return next;
414 }
415 
416 // Split after the parameter sets at the beginning of the stream if they exist.
417 static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
418 {
419  const uint8_t *ptr = buf, *end = buf + buf_size;
420  uint32_t state = -1;
421  int has_vps = 0;
422  int has_sps = 0;
423  int has_pps = 0;
424  int nut;
425 
426  while (ptr < end) {
427  ptr = avpriv_find_start_code(ptr, end, &state);
428  if ((state >> 8) != START_CODE)
429  break;
430  nut = (state >> 1) & 0x3F;
431  if (nut == NAL_VPS)
432  has_vps = 1;
433  else if (nut == NAL_SPS)
434  has_sps = 1;
435  else if (nut == NAL_PPS)
436  has_pps = 1;
437  else if ((nut != NAL_SEI_PREFIX || has_pps) &&
438  nut != NAL_AUD) {
439  if (has_vps && has_sps) {
440  while (ptr - 4 > buf && ptr[-5] == 0)
441  ptr--;
442  return ptr - 4 - buf;
443  }
444  }
445  }
446  return 0;
447 }
448 
450 {
451  HEVCParserContext *ctx = s->priv_data;
452  int i;
453 
454 #if ADVANCED_PARSER
455  HEVCContext *h = &ctx->h;
456 
457  for (i = 0; i < FF_ARRAY_ELEMS(h->ps.vps_list); i++)
458  av_buffer_unref(&h->ps.vps_list[i]);
459  for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++)
460  av_buffer_unref(&h->ps.sps_list[i]);
461  for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++)
462  av_buffer_unref(&h->ps.pps_list[i]);
463 
464  h->ps.sps = NULL;
465 
466  av_freep(&h->HEVClc);
467 #endif
468 
469  for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.vps_list); i++)
470  av_buffer_unref(&ctx->ps.vps_list[i]);
471  for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.sps_list); i++)
472  av_buffer_unref(&ctx->ps.sps_list[i]);
473  for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.pps_list); i++)
474  av_buffer_unref(&ctx->ps.pps_list[i]);
475 
476  ctx->ps.sps = NULL;
477 
479 
480  av_freep(&ctx->pc.buffer);
481 }
482 
485  .priv_data_size = sizeof(HEVCParserContext),
486  .parser_parse = hevc_parse,
487  .parser_close = hevc_parser_close,
488  .split = hevc_split,
489 };
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.h:579
#define NULL
Definition: coverity.c:32
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: hevc.h:592
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:124
static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, AVCodecContext *avctx)
Definition: hevc_parser.c:50
int ctb_height
Definition: hevc.h:475
#define MAX_SPS_COUNT
Definition: h264_ps.h:37
int size
Definition: h2645_parse.h:35
Definition: hevc.h:97
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:247
static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Definition: hevc_parser.c:417
int width
Dimensions of the decoded video intended for presentation.
Definition: avcodec.h:5128
enum AVFieldOrder field_order
Definition: avcodec.h:5105
int codec_ids[5]
Definition: avcodec.h:5149
int coded_width
Dimensions of the coded video.
Definition: avcodec.h:5134
H2645Packet pkt
Definition: hevc_parser.c:39
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, int apply_defdispwin)
Definition: hevc_ps.c:1185
HEVCParamSets ps
Definition: hevc.h:827
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:252
static AVPacket pkt
uint8_t dependent_slice_segment_flag
Definition: hevc.h:595
int profile
profile
Definition: avcodec.h:3181
AVBufferRef * vps_list[MAX_VPS_COUNT]
Definition: hevc.h:572
int frame_start_found
Definition: parser.h:34
int width
Definition: hevc.h:472
int output_width
Definition: hevc.h:408
unsigned int slice_segment_addr
address (in raster order) of the first block in the current slice
Definition: hevc.h:586
enum AVPictureStructure picture_structure
Indicate whether a picture is coded as a frame, top field or bottom field.
Definition: avcodec.h:5115
uint8_t
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
const HEVCVPS * vps
Definition: hevc.h:577
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1791
AVCodecContext * avctx
Definition: hevc.h:804
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
#define MAX_PPS_COUNT
Definition: h264_ps.h:38
uint8_t first_slice_in_pic_flag
Definition: hevc.h:594
int ff_hevc_decode_nal_sei(HEVCContext *s)
Definition: hevc_sei.c:365
uint8_t pic_output_flag
Definition: hevc.h:596
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:208
#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: hevc.h:839
uint8_t no_output_of_prior_pics_flag
Definition: hevc.h:609
Definition: hevc.h:113
HEVCParamSets ps
Definition: hevc_parser.c:40
uint8_t colour_plane_id
RPS coded in the slice header itself is stored here.
Definition: hevc.h:597
#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.h:417
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
Definition: hevc_ps.c:1428
void ff_hevc_reset_sei(HEVCContext *s)
Reset SEI values that are stored on the Context.
Definition: hevc_sei.c:377
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 ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
Compute POC of the current frame and return it.
Definition: hevc_refs.c:518
int picture_struct
Definition: hevc.h:922
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:138
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:86
const HEVCSPS * sps
Definition: hevc.h:578
uint8_t profile_idc
Definition: hevc.h:355
#define IS_IDR(s)
Definition: hevc.h:86
int output_height
Definition: hevc.h:408
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: hevc.h:574
AVFormatContext * ctx
Definition: movenc.c:48
Definition: hevc.h:134
int level
level
Definition: avcodec.h:3279
int ctb_width
Definition: hevc.h:474
int height
Definition: hevc.h:473
uint8_t output_flag_present_flag
Definition: hevc.h:516
PTLCommon general_ptl
Definition: hevc.h:365
int type
NAL unit type.
Definition: h2645_parse.h:52
#define IS_IRAP_NAL(nal)
Definition: hevc_parser.c:32
Definition: hevc.h:112
unsigned vps_id
Definition: hevc.h:403
#define FF_ARRAY_ELEMS(a)
ParseContext pc
Definition: hevc_parser.c:37
unsigned int pps_id
address (in raster order) of the first block in the current slice segment
Definition: hevc.h:583
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
Definition: hevc.h:133
Definition: hevc.h:402
enum AVPixelFormat pix_fmt
Definition: hevc.h:415
Definition: hevc.h:372
Definition: hevc.h:494
uint8_t * buffer
Definition: parser.h:29
#define IS_IRAP(s)
Definition: hevc.h:89
int nals_allocated
Definition: h2645_parse.h:72
PTL ptl
Definition: hevc.h:428
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:437
#define START_CODE
start_code_prefix_one_3bytes
Definition: hevc_parser.c:30
unsigned int sps_id
seq_parameter_set_id
Definition: hevc.h:495
main external API structure.
Definition: avcodec.h:1676
int num_extra_slice_header_bits
Definition: hevc.h:541
uint8_t * data
The data buffer.
Definition: buffer.h:89
Definition: hevc.h:111
const uint8_t * data
Definition: h2645_parse.h:36
static struct @246 state
void * buf
Definition: avisynth_c.h:690
AVCodecParser ff_hevc_parser
Definition: hevc_parser.c:483
int extradata_size
Definition: avcodec.h:1792
Definition: hevc.h:114
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:299
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:292
uint64_t state64
contains the last 8 bytes in MSB order
Definition: parser.h:37
GetBitContext gb
Definition: hevc.h:766
int poc
Definition: hevc.h:842
#define END_NOT_FOUND
Definition: parser.h:40
enum NALUnitType nal_unit_type
Definition: hevc.h:838
int pocTid0
Definition: hevc.h:843
HEVCLocalContext * HEVClc
Definition: hevc.h:809
int output_picture_number
Picture number incremented in presentation or output order.
Definition: avcodec.h:5123
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
Definition: hevc_ps.c:397
uint8_t level_idc
Definition: hevc.h:357
common internal and external API header
if(ret< 0)
Definition: vf_mcdeint.c:282
Definition: hevc.h:98
Bi-dir predicted.
Definition: avutil.h:270
#define PARSER_FLAG_COMPLETE_FRAMES
Definition: avcodec.h:5015
GetBitContext gb
Definition: h2645_parse.h:47
static uint8_t tmp[8]
Definition: des.c:38
int format
The format of the coded data, corresponds to enum AVPixelFormat for video and for enum AVSampleFormat...
Definition: avcodec.h:5145
H2645NAL * nals
Definition: h2645_parse.h:70
Definition: hevc.h:132
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:384
#define av_freep(p)
static void hevc_parser_close(AVCodecParserContext *s)
Definition: hevc_parser.c:449
enum SliceType slice_type
Definition: hevc.h:590
static av_always_inline av_const int av_ceil_log2_c(int x)
Compute ceil(log2(x)).
Definition: common.h:308
SliceHeader sh
Definition: hevc.h:835
exp golomb vlc stuff
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
Definition: avcodec.h:5030
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: hevc.h:573
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
Definition: hevc.h:405
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
Definition: get_bits.h:262
Predicted.
Definition: avutil.h:269
uint8_t dependent_slice_segments_enabled_flag
Definition: hevc.h:519