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