FFmpeg
h264_ps.c
Go to the documentation of this file.
1 /*
2  * H.26L/H.264/AVC/JVT/14496-10/... parameter set decoding
3  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * H.264 / AVC / MPEG-4 part10 parameter set decoding.
25  * @author Michael Niedermayer <michaelni@gmx.at>
26  */
27 
28 #include <inttypes.h>
29 
30 #include "libavutil/imgutils.h"
31 #include "mathops.h"
32 #include "avcodec.h"
33 #include "h264data.h"
34 #include "h2645_vui.h"
35 #include "h264_ps.h"
36 #include "golomb.h"
37 
38 #define MIN_LOG2_MAX_FRAME_NUM 4
39 
40 static const uint8_t default_scaling4[2][16] = {
41  { 6, 13, 20, 28, 13, 20, 28, 32,
42  20, 28, 32, 37, 28, 32, 37, 42 },
43  { 10, 14, 20, 24, 14, 20, 24, 27,
44  20, 24, 27, 30, 24, 27, 30, 34 }
45 };
46 
47 static const uint8_t default_scaling8[2][64] = {
48  { 6, 10, 13, 16, 18, 23, 25, 27,
49  10, 11, 16, 18, 23, 25, 27, 29,
50  13, 16, 18, 23, 25, 27, 29, 31,
51  16, 18, 23, 25, 27, 29, 31, 33,
52  18, 23, 25, 27, 29, 31, 33, 36,
53  23, 25, 27, 29, 31, 33, 36, 38,
54  25, 27, 29, 31, 33, 36, 38, 40,
55  27, 29, 31, 33, 36, 38, 40, 42 },
56  { 9, 13, 15, 17, 19, 21, 22, 24,
57  13, 13, 17, 19, 21, 22, 24, 25,
58  15, 17, 19, 21, 22, 24, 25, 27,
59  17, 19, 21, 22, 24, 25, 27, 28,
60  19, 21, 22, 24, 25, 27, 28, 30,
61  21, 22, 24, 25, 27, 28, 30, 32,
62  22, 24, 25, 27, 28, 30, 32, 33,
63  24, 25, 27, 28, 30, 32, 33, 35 }
64 };
65 
66 /* maximum number of MBs in the DPB for a given level */
67 static const int level_max_dpb_mbs[][2] = {
68  { 10, 396 },
69  { 11, 900 },
70  { 12, 2376 },
71  { 13, 2376 },
72  { 20, 2376 },
73  { 21, 4752 },
74  { 22, 8100 },
75  { 30, 8100 },
76  { 31, 18000 },
77  { 32, 20480 },
78  { 40, 32768 },
79  { 41, 32768 },
80  { 42, 34816 },
81  { 50, 110400 },
82  { 51, 184320 },
83  { 52, 184320 },
84 };
85 
86 static void remove_pps(H264ParamSets *s, int id)
87 {
88  av_buffer_unref(&s->pps_list[id]);
89 }
90 
91 static void remove_sps(H264ParamSets *s, int id)
92 {
93 #if 0
94  int i;
95  if (s->sps_list[id]) {
96  /* drop all PPS that depend on this SPS */
97  for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
98  if (s->pps_list[i] && ((PPS*)s->pps_list[i]->data)->sps_id == id)
99  remove_pps(s, i);
100  }
101 #endif
102  av_buffer_unref(&s->sps_list[id]);
103 }
104 
105 static inline int decode_hrd_parameters(GetBitContext *gb, void *logctx,
106  SPS *sps)
107 {
108  int cpb_count, i;
109  cpb_count = get_ue_golomb_31(gb) + 1;
110 
111  if (cpb_count > 32U) {
112  av_log(logctx, AV_LOG_ERROR, "cpb_count %d invalid\n", cpb_count);
113  return AVERROR_INVALIDDATA;
114  }
115 
116  get_bits(gb, 4); /* bit_rate_scale */
117  get_bits(gb, 4); /* cpb_size_scale */
118  for (i = 0; i < cpb_count; i++) {
119  get_ue_golomb_long(gb); /* bit_rate_value_minus1 */
120  get_ue_golomb_long(gb); /* cpb_size_value_minus1 */
121  get_bits1(gb); /* cbr_flag */
122  }
123  sps->initial_cpb_removal_delay_length = get_bits(gb, 5) + 1;
124  sps->cpb_removal_delay_length = get_bits(gb, 5) + 1;
125  sps->dpb_output_delay_length = get_bits(gb, 5) + 1;
126  sps->time_offset_length = get_bits(gb, 5);
127  sps->cpb_cnt = cpb_count;
128  return 0;
129 }
130 
131 static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,
132  SPS *sps)
133 {
134  ff_h2645_decode_common_vui_params(gb, &sps->vui, logctx);
135 
136  if (show_bits1(gb) && get_bits_left(gb) < 10) {
137  av_log(logctx, AV_LOG_WARNING, "Truncated VUI (%d)\n", get_bits_left(gb));
138  return 0;
139  }
140 
141  sps->timing_info_present_flag = get_bits1(gb);
142  if (sps->timing_info_present_flag) {
143  unsigned num_units_in_tick = get_bits_long(gb, 32);
144  unsigned time_scale = get_bits_long(gb, 32);
145  if (!num_units_in_tick || !time_scale) {
146  av_log(logctx, AV_LOG_ERROR,
147  "time_scale/num_units_in_tick invalid or unsupported (%u/%u)\n",
148  time_scale, num_units_in_tick);
149  sps->timing_info_present_flag = 0;
150  } else {
151  sps->num_units_in_tick = num_units_in_tick;
152  sps->time_scale = time_scale;
153  }
154  sps->fixed_frame_rate_flag = get_bits1(gb);
155  }
156 
157  sps->nal_hrd_parameters_present_flag = get_bits1(gb);
158  if (sps->nal_hrd_parameters_present_flag)
159  if (decode_hrd_parameters(gb, logctx, sps) < 0)
160  return AVERROR_INVALIDDATA;
161  sps->vcl_hrd_parameters_present_flag = get_bits1(gb);
162  if (sps->vcl_hrd_parameters_present_flag)
163  if (decode_hrd_parameters(gb, logctx, sps) < 0)
164  return AVERROR_INVALIDDATA;
165  if (sps->nal_hrd_parameters_present_flag ||
166  sps->vcl_hrd_parameters_present_flag)
167  get_bits1(gb); /* low_delay_hrd_flag */
168  sps->pic_struct_present_flag = get_bits1(gb);
169  if (!get_bits_left(gb))
170  return 0;
171  sps->bitstream_restriction_flag = get_bits1(gb);
172  if (sps->bitstream_restriction_flag) {
173  get_bits1(gb); /* motion_vectors_over_pic_boundaries_flag */
174  get_ue_golomb_31(gb); /* max_bytes_per_pic_denom */
175  get_ue_golomb_31(gb); /* max_bits_per_mb_denom */
176  get_ue_golomb_31(gb); /* log2_max_mv_length_horizontal */
177  get_ue_golomb_31(gb); /* log2_max_mv_length_vertical */
178  sps->num_reorder_frames = get_ue_golomb_31(gb);
179  get_ue_golomb_31(gb); /*max_dec_frame_buffering*/
180 
181  if (get_bits_left(gb) < 0) {
182  sps->num_reorder_frames = 0;
183  sps->bitstream_restriction_flag = 0;
184  }
185 
186  if (sps->num_reorder_frames > 16U
187  /* max_dec_frame_buffering || max_dec_frame_buffering > 16 */) {
188  av_log(logctx, AV_LOG_ERROR,
189  "Clipping illegal num_reorder_frames %d\n",
190  sps->num_reorder_frames);
191  sps->num_reorder_frames = 16;
192  return AVERROR_INVALIDDATA;
193  }
194  }
195 
196  return 0;
197 }
198 
199 static int decode_scaling_list(GetBitContext *gb, uint8_t *factors, int size,
200  const uint8_t *jvt_list,
201  const uint8_t *fallback_list)
202 {
203  int i, last = 8, next = 8;
204  const uint8_t *scan = size == 16 ? ff_zigzag_scan : ff_zigzag_direct;
205  if (!get_bits1(gb)) /* matrix not written, we use the predicted one */
206  memcpy(factors, fallback_list, size * sizeof(uint8_t));
207  else
208  for (i = 0; i < size; i++) {
209  if (next) {
210  int v = get_se_golomb(gb);
211  if (v < -128 || v > 127) {
212  av_log(NULL, AV_LOG_ERROR, "delta scale %d is invalid\n", v);
213  return AVERROR_INVALIDDATA;
214  }
215  next = (last + v) & 0xff;
216  }
217  if (!i && !next) { /* matrix not written, we use the preset one */
218  memcpy(factors, jvt_list, size * sizeof(uint8_t));
219  break;
220  }
221  last = factors[scan[i]] = next ? next : last;
222  }
223  return 0;
224 }
225 
226 /* returns non zero if the provided SPS scaling matrix has been filled */
228  const PPS *pps, int is_sps,
229  uint8_t(*scaling_matrix4)[16],
230  uint8_t(*scaling_matrix8)[64])
231 {
232  int fallback_sps = !is_sps && sps->scaling_matrix_present;
233  const uint8_t *fallback[4] = {
234  fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0],
235  fallback_sps ? sps->scaling_matrix4[3] : default_scaling4[1],
236  fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0],
237  fallback_sps ? sps->scaling_matrix8[3] : default_scaling8[1]
238  };
239  int ret = 0;
240  if (get_bits1(gb)) {
241  ret |= decode_scaling_list(gb, scaling_matrix4[0], 16, default_scaling4[0], fallback[0]); // Intra, Y
242  ret |= decode_scaling_list(gb, scaling_matrix4[1], 16, default_scaling4[0], scaling_matrix4[0]); // Intra, Cr
243  ret |= decode_scaling_list(gb, scaling_matrix4[2], 16, default_scaling4[0], scaling_matrix4[1]); // Intra, Cb
244  ret |= decode_scaling_list(gb, scaling_matrix4[3], 16, default_scaling4[1], fallback[1]); // Inter, Y
245  ret |= decode_scaling_list(gb, scaling_matrix4[4], 16, default_scaling4[1], scaling_matrix4[3]); // Inter, Cr
246  ret |= decode_scaling_list(gb, scaling_matrix4[5], 16, default_scaling4[1], scaling_matrix4[4]); // Inter, Cb
247  if (is_sps || pps->transform_8x8_mode) {
248  ret |= decode_scaling_list(gb, scaling_matrix8[0], 64, default_scaling8[0], fallback[2]); // Intra, Y
249  ret |= decode_scaling_list(gb, scaling_matrix8[3], 64, default_scaling8[1], fallback[3]); // Inter, Y
250  if (sps->chroma_format_idc == 3) {
251  ret |= decode_scaling_list(gb, scaling_matrix8[1], 64, default_scaling8[0], scaling_matrix8[0]); // Intra, Cr
252  ret |= decode_scaling_list(gb, scaling_matrix8[4], 64, default_scaling8[1], scaling_matrix8[3]); // Inter, Cr
253  ret |= decode_scaling_list(gb, scaling_matrix8[2], 64, default_scaling8[0], scaling_matrix8[1]); // Intra, Cb
254  ret |= decode_scaling_list(gb, scaling_matrix8[5], 64, default_scaling8[1], scaling_matrix8[4]); // Inter, Cb
255  }
256  }
257  if (!ret)
258  ret = is_sps;
259  }
260 
261  return ret;
262 }
263 
265 {
266  int i;
267 
268  for (i = 0; i < MAX_SPS_COUNT; i++)
269  av_buffer_unref(&ps->sps_list[i]);
270 
271  for (i = 0; i < MAX_PPS_COUNT; i++)
272  av_buffer_unref(&ps->pps_list[i]);
273 
274  av_buffer_unref(&ps->pps_ref);
275 
276  ps->pps = NULL;
277  ps->sps = NULL;
278 }
279 
281  H264ParamSets *ps, int ignore_truncation)
282 {
283  AVBufferRef *sps_buf;
284  int profile_idc, level_idc, constraint_set_flags = 0;
285  unsigned int sps_id;
286  int i, log2_max_frame_num_minus4;
287  SPS *sps;
288  int ret;
289 
290  sps_buf = av_buffer_allocz(sizeof(*sps));
291  if (!sps_buf)
292  return AVERROR(ENOMEM);
293  sps = (SPS*)sps_buf->data;
294 
295  sps->data_size = gb->buffer_end - gb->buffer;
296  if (sps->data_size > sizeof(sps->data)) {
297  av_log(avctx, AV_LOG_DEBUG, "Truncating likely oversized SPS\n");
298  sps->data_size = sizeof(sps->data);
299  }
300  memcpy(sps->data, gb->buffer, sps->data_size);
301 
302  // Re-add the removed stop bit (may be used by hwaccels).
303  if (!(gb->size_in_bits & 7) && sps->data_size < sizeof(sps->data))
304  sps->data[sps->data_size++] = 0x80;
305 
306  profile_idc = get_bits(gb, 8);
307  constraint_set_flags |= get_bits1(gb) << 0; // constraint_set0_flag
308  constraint_set_flags |= get_bits1(gb) << 1; // constraint_set1_flag
309  constraint_set_flags |= get_bits1(gb) << 2; // constraint_set2_flag
310  constraint_set_flags |= get_bits1(gb) << 3; // constraint_set3_flag
311  constraint_set_flags |= get_bits1(gb) << 4; // constraint_set4_flag
312  constraint_set_flags |= get_bits1(gb) << 5; // constraint_set5_flag
313  skip_bits(gb, 2); // reserved_zero_2bits
314  level_idc = get_bits(gb, 8);
315  sps_id = get_ue_golomb_31(gb);
316 
317  if (sps_id >= MAX_SPS_COUNT) {
318  av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id);
319  goto fail;
320  }
321 
322  sps->sps_id = sps_id;
323  sps->time_offset_length = 24;
324  sps->profile_idc = profile_idc;
325  sps->constraint_set_flags = constraint_set_flags;
326  sps->level_idc = level_idc;
327  sps->vui.video_full_range_flag = -1;
328 
329  memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
330  memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
331  sps->scaling_matrix_present = 0;
332  sps->vui.matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
333 
334  if (sps->profile_idc == 100 || // High profile
335  sps->profile_idc == 110 || // High10 profile
336  sps->profile_idc == 122 || // High422 profile
337  sps->profile_idc == 244 || // High444 Predictive profile
338  sps->profile_idc == 44 || // Cavlc444 profile
339  sps->profile_idc == 83 || // Scalable Constrained High profile (SVC)
340  sps->profile_idc == 86 || // Scalable High Intra profile (SVC)
341  sps->profile_idc == 118 || // Stereo High profile (MVC)
342  sps->profile_idc == 128 || // Multiview High profile (MVC)
343  sps->profile_idc == 138 || // Multiview Depth High profile (MVCD)
344  sps->profile_idc == 144) { // old High444 profile
345  sps->chroma_format_idc = get_ue_golomb_31(gb);
346  if (sps->chroma_format_idc > 3U) {
347  avpriv_request_sample(avctx, "chroma_format_idc %u",
348  sps->chroma_format_idc);
349  goto fail;
350  } else if (sps->chroma_format_idc == 3) {
351  sps->residual_color_transform_flag = get_bits1(gb);
352  if (sps->residual_color_transform_flag) {
353  av_log(avctx, AV_LOG_ERROR, "separate color planes are not supported\n");
354  goto fail;
355  }
356  }
357  sps->bit_depth_luma = get_ue_golomb_31(gb) + 8;
358  sps->bit_depth_chroma = get_ue_golomb_31(gb) + 8;
359  if (sps->bit_depth_chroma != sps->bit_depth_luma) {
360  avpriv_request_sample(avctx,
361  "Different chroma and luma bit depth");
362  goto fail;
363  }
364  if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 ||
365  sps->bit_depth_chroma < 8 || sps->bit_depth_chroma > 14) {
366  av_log(avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
367  sps->bit_depth_luma, sps->bit_depth_chroma);
368  goto fail;
369  }
370  sps->transform_bypass = get_bits1(gb);
372  sps->scaling_matrix4, sps->scaling_matrix8);
373  if (ret < 0)
374  goto fail;
375  sps->scaling_matrix_present |= ret;
376  } else {
377  sps->chroma_format_idc = 1;
378  sps->bit_depth_luma = 8;
379  sps->bit_depth_chroma = 8;
380  }
381 
382  log2_max_frame_num_minus4 = get_ue_golomb_31(gb);
383  if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||
384  log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {
385  av_log(avctx, AV_LOG_ERROR,
386  "log2_max_frame_num_minus4 out of range (0-12): %d\n",
387  log2_max_frame_num_minus4);
388  goto fail;
389  }
390  sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;
391 
392  sps->poc_type = get_ue_golomb_31(gb);
393 
394  if (sps->poc_type == 0) { // FIXME #define
395  unsigned t = get_ue_golomb_31(gb);
396  if (t>12) {
397  av_log(avctx, AV_LOG_ERROR, "log2_max_poc_lsb (%d) is out of range\n", t);
398  goto fail;
399  }
400  sps->log2_max_poc_lsb = t + 4;
401  } else if (sps->poc_type == 1) { // FIXME #define
402  sps->delta_pic_order_always_zero_flag = get_bits1(gb);
403  sps->offset_for_non_ref_pic = get_se_golomb_long(gb);
404  sps->offset_for_top_to_bottom_field = get_se_golomb_long(gb);
405 
406  if ( sps->offset_for_non_ref_pic == INT32_MIN
407  || sps->offset_for_top_to_bottom_field == INT32_MIN
408  ) {
409  av_log(avctx, AV_LOG_ERROR,
410  "offset_for_non_ref_pic or offset_for_top_to_bottom_field is out of range\n");
411  goto fail;
412  }
413 
414  sps->poc_cycle_length = get_ue_golomb(gb);
415 
416  if ((unsigned)sps->poc_cycle_length >=
417  FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {
418  av_log(avctx, AV_LOG_ERROR,
419  "poc_cycle_length overflow %d\n", sps->poc_cycle_length);
420  goto fail;
421  }
422 
423  for (i = 0; i < sps->poc_cycle_length; i++) {
424  sps->offset_for_ref_frame[i] = get_se_golomb_long(gb);
425  if (sps->offset_for_ref_frame[i] == INT32_MIN) {
426  av_log(avctx, AV_LOG_ERROR,
427  "offset_for_ref_frame is out of range\n");
428  goto fail;
429  }
430  }
431  } else if (sps->poc_type != 2) {
432  av_log(avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
433  goto fail;
434  }
435 
436  sps->ref_frame_count = get_ue_golomb_31(gb);
437  if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
438  sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
439  if (sps->ref_frame_count > H264_MAX_DPB_FRAMES) {
440  av_log(avctx, AV_LOG_ERROR,
441  "too many reference frames %d\n", sps->ref_frame_count);
442  goto fail;
443  }
444  sps->gaps_in_frame_num_allowed_flag = get_bits1(gb);
445  sps->mb_width = get_ue_golomb(gb) + 1;
446  sps->mb_height = get_ue_golomb(gb) + 1;
447 
448  sps->frame_mbs_only_flag = get_bits1(gb);
449 
450  if (sps->mb_height >= INT_MAX / 2U) {
451  av_log(avctx, AV_LOG_ERROR, "height overflow\n");
452  goto fail;
453  }
454  sps->mb_height *= 2 - sps->frame_mbs_only_flag;
455 
456  if (!sps->frame_mbs_only_flag)
457  sps->mb_aff = get_bits1(gb);
458  else
459  sps->mb_aff = 0;
460 
461  if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
462  (unsigned)sps->mb_height >= INT_MAX / 16 ||
463  av_image_check_size(16 * sps->mb_width,
464  16 * sps->mb_height, 0, avctx)) {
465  av_log(avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
466  goto fail;
467  }
468 
469  sps->direct_8x8_inference_flag = get_bits1(gb);
470 
471  sps->crop = get_bits1(gb);
472  if (sps->crop) {
473  unsigned int crop_left = get_ue_golomb(gb);
474  unsigned int crop_right = get_ue_golomb(gb);
475  unsigned int crop_top = get_ue_golomb(gb);
476  unsigned int crop_bottom = get_ue_golomb(gb);
477  int width = 16 * sps->mb_width;
478  int height = 16 * sps->mb_height;
479 
480  if (avctx->flags2 & AV_CODEC_FLAG2_IGNORE_CROP) {
481  av_log(avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
482  "values are l:%d r:%d t:%d b:%d\n",
483  crop_left, crop_right, crop_top, crop_bottom);
484 
485  sps->crop_left =
486  sps->crop_right =
487  sps->crop_top =
488  sps->crop_bottom = 0;
489  } else {
490  int vsub = (sps->chroma_format_idc == 1) ? 1 : 0;
491  int hsub = (sps->chroma_format_idc == 1 ||
492  sps->chroma_format_idc == 2) ? 1 : 0;
493  int step_x = 1 << hsub;
494  int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
495 
496  if (crop_left > (unsigned)INT_MAX / 4 / step_x ||
497  crop_right > (unsigned)INT_MAX / 4 / step_x ||
498  crop_top > (unsigned)INT_MAX / 4 / step_y ||
499  crop_bottom> (unsigned)INT_MAX / 4 / step_y ||
500  (crop_left + crop_right ) * step_x >= width ||
501  (crop_top + crop_bottom) * step_y >= height
502  ) {
503  av_log(avctx, AV_LOG_ERROR, "crop values invalid %d %d %d %d / %d %d\n", crop_left, crop_right, crop_top, crop_bottom, width, height);
504  goto fail;
505  }
506 
507  sps->crop_left = crop_left * step_x;
508  sps->crop_right = crop_right * step_x;
509  sps->crop_top = crop_top * step_y;
510  sps->crop_bottom = crop_bottom * step_y;
511  }
512  } else {
513  sps->crop_left =
514  sps->crop_right =
515  sps->crop_top =
516  sps->crop_bottom =
517  sps->crop = 0;
518  }
519 
520  sps->vui_parameters_present_flag = get_bits1(gb);
521  if (sps->vui_parameters_present_flag) {
522  int ret = decode_vui_parameters(gb, avctx, sps);
523  if (ret < 0)
524  goto fail;
525  }
526 
527  if (get_bits_left(gb) < 0) {
528  av_log_once(avctx, ignore_truncation ? AV_LOG_WARNING : AV_LOG_ERROR, AV_LOG_DEBUG,
529  &ps->overread_warning_printed[sps->vui_parameters_present_flag],
530  "Overread %s by %d bits\n", sps->vui_parameters_present_flag ? "VUI" : "SPS", -get_bits_left(gb));
531  if (!ignore_truncation)
532  goto fail;
533  }
534 
535  /* if the maximum delay is not stored in the SPS, derive it based on the
536  * level */
537  if (!sps->bitstream_restriction_flag &&
538  (sps->ref_frame_count || avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)) {
539  sps->num_reorder_frames = H264_MAX_DPB_FRAMES - 1;
540  for (i = 0; i < FF_ARRAY_ELEMS(level_max_dpb_mbs); i++) {
541  if (level_max_dpb_mbs[i][0] == sps->level_idc) {
542  sps->num_reorder_frames = FFMIN(level_max_dpb_mbs[i][1] / (sps->mb_width * sps->mb_height),
543  sps->num_reorder_frames);
544  break;
545  }
546  }
547  }
548 
549  if (!sps->vui.sar.den)
550  sps->vui.sar.den = 1;
551 
552  if (avctx->debug & FF_DEBUG_PICT_INFO) {
553  static const char csp[4][5] = { "Gray", "420", "422", "444" };
554  av_log(avctx, AV_LOG_DEBUG,
555  "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %"PRId32"/%"PRId32" b%d reo:%d\n",
556  sps_id, sps->profile_idc, sps->level_idc,
557  sps->poc_type,
558  sps->ref_frame_count,
559  sps->mb_width, sps->mb_height,
560  sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
561  sps->direct_8x8_inference_flag ? "8B8" : "",
562  sps->crop_left, sps->crop_right,
563  sps->crop_top, sps->crop_bottom,
564  sps->vui_parameters_present_flag ? "VUI" : "",
565  csp[sps->chroma_format_idc],
566  sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
567  sps->timing_info_present_flag ? sps->time_scale : 0,
568  sps->bit_depth_luma,
569  sps->bitstream_restriction_flag ? sps->num_reorder_frames : -1
570  );
571  }
572 
573  /* check if this is a repeat of an already parsed SPS, then keep the
574  * original one.
575  * otherwise drop all PPSes that depend on it */
576  if (ps->sps_list[sps_id] &&
577  !memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) {
578  av_buffer_unref(&sps_buf);
579  } else {
580  remove_sps(ps, sps_id);
581  ps->sps_list[sps_id] = sps_buf;
582  }
583 
584  return 0;
585 
586 fail:
587  av_buffer_unref(&sps_buf);
588  return AVERROR_INVALIDDATA;
589 }
590 
591 static void init_dequant8_coeff_table(PPS *pps, const SPS *sps)
592 {
593  int i, j, q, x;
594  const int max_qp = 51 + 6 * (sps->bit_depth_luma - 8);
595 
596  for (i = 0; i < 6; i++) {
597  pps->dequant8_coeff[i] = pps->dequant8_buffer[i];
598  for (j = 0; j < i; j++)
599  if (!memcmp(pps->scaling_matrix8[j], pps->scaling_matrix8[i],
600  64 * sizeof(uint8_t))) {
601  pps->dequant8_coeff[i] = pps->dequant8_buffer[j];
602  break;
603  }
604  if (j < i)
605  continue;
606 
607  for (q = 0; q < max_qp + 1; q++) {
608  int shift = ff_h264_quant_div6[q];
609  int idx = ff_h264_quant_rem6[q];
610  for (x = 0; x < 64; x++)
611  pps->dequant8_coeff[i][q][(x >> 3) | ((x & 7) << 3)] =
612  ((uint32_t)ff_h264_dequant8_coeff_init[idx][ff_h264_dequant8_coeff_init_scan[((x >> 1) & 12) | (x & 3)]] *
613  pps->scaling_matrix8[i][x]) << shift;
614  }
615  }
616 }
617 
618 static void init_dequant4_coeff_table(PPS *pps, const SPS *sps)
619 {
620  int i, j, q, x;
621  const int max_qp = 51 + 6 * (sps->bit_depth_luma - 8);
622  for (i = 0; i < 6; i++) {
623  pps->dequant4_coeff[i] = pps->dequant4_buffer[i];
624  for (j = 0; j < i; j++)
625  if (!memcmp(pps->scaling_matrix4[j], pps->scaling_matrix4[i],
626  16 * sizeof(uint8_t))) {
627  pps->dequant4_coeff[i] = pps->dequant4_buffer[j];
628  break;
629  }
630  if (j < i)
631  continue;
632 
633  for (q = 0; q < max_qp + 1; q++) {
634  int shift = ff_h264_quant_div6[q] + 2;
635  int idx = ff_h264_quant_rem6[q];
636  for (x = 0; x < 16; x++)
637  pps->dequant4_coeff[i][q][(x >> 2) | ((x << 2) & 0xF)] =
638  ((uint32_t)ff_h264_dequant4_coeff_init[idx][(x & 1) + ((x >> 2) & 1)] *
639  pps->scaling_matrix4[i][x]) << shift;
640  }
641  }
642 }
643 
644 static void init_dequant_tables(PPS *pps, const SPS *sps)
645 {
646  int i, x;
648  memset(pps->dequant8_coeff, 0, sizeof(pps->dequant8_coeff));
649 
650  if (pps->transform_8x8_mode)
652  if (sps->transform_bypass) {
653  for (i = 0; i < 6; i++)
654  for (x = 0; x < 16; x++)
655  pps->dequant4_coeff[i][0][x] = 1 << 6;
656  if (pps->transform_8x8_mode)
657  for (i = 0; i < 6; i++)
658  for (x = 0; x < 64; x++)
659  pps->dequant8_coeff[i][0][x] = 1 << 6;
660  }
661 }
662 
663 static void build_qp_table(PPS *pps, int t, int index, const int depth)
664 {
665  int i;
666  const int max_qp = 51 + 6 * (depth - 8);
667  for (i = 0; i < max_qp + 1; i++)
668  pps->chroma_qp_table[t][i] =
669  ff_h264_chroma_qp[depth - 8][av_clip(i + index, 0, max_qp)];
670 }
671 
672 static int more_rbsp_data_in_pps(const SPS *sps, void *logctx)
673 {
674  int profile_idc = sps->profile_idc;
675 
676  if ((profile_idc == 66 || profile_idc == 77 ||
677  profile_idc == 88) && (sps->constraint_set_flags & 7)) {
678  av_log(logctx, AV_LOG_VERBOSE,
679  "Current profile doesn't provide more RBSP data in PPS, skipping\n");
680  return 0;
681  }
682 
683  return 1;
684 }
685 
686 static void pps_free(void *opaque, uint8_t *data)
687 {
688  PPS *pps = (PPS*)data;
689 
690  av_buffer_unref(&pps->sps_ref);
691 
692  av_freep(&data);
693 }
694 
696  H264ParamSets *ps, int bit_length)
697 {
698  AVBufferRef *pps_buf;
699  const SPS *sps;
700  unsigned int pps_id = get_ue_golomb(gb);
701  PPS *pps;
702  int qp_bd_offset;
703  int bits_left;
704  int ret;
705 
706  if (pps_id >= MAX_PPS_COUNT) {
707  av_log(avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
708  return AVERROR_INVALIDDATA;
709  }
710 
711  pps = av_mallocz(sizeof(*pps));
712  if (!pps)
713  return AVERROR(ENOMEM);
714  pps_buf = av_buffer_create((uint8_t*)pps, sizeof(*pps),
715  pps_free, NULL, 0);
716  if (!pps_buf) {
717  av_freep(&pps);
718  return AVERROR(ENOMEM);
719  }
720 
721  pps->data_size = gb->buffer_end - gb->buffer;
722  if (pps->data_size > sizeof(pps->data)) {
723  av_log(avctx, AV_LOG_DEBUG, "Truncating likely oversized PPS "
724  "(%"SIZE_SPECIFIER" > %"SIZE_SPECIFIER")\n",
725  pps->data_size, sizeof(pps->data));
726  pps->data_size = sizeof(pps->data);
727  }
728  memcpy(pps->data, gb->buffer, pps->data_size);
729 
730  // Re-add the removed stop bit (may be used by hwaccels).
731  if (!(bit_length & 7) && pps->data_size < sizeof(pps->data))
732  pps->data[pps->data_size++] = 0x80;
733 
734  pps->sps_id = get_ue_golomb_31(gb);
735  if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
736  !ps->sps_list[pps->sps_id]) {
737  av_log(avctx, AV_LOG_ERROR, "sps_id %u out of range\n", pps->sps_id);
739  goto fail;
740  }
741  pps->sps_ref = av_buffer_ref(ps->sps_list[pps->sps_id]);
742  if (!pps->sps_ref) {
743  ret = AVERROR(ENOMEM);
744  goto fail;
745  }
746  pps->sps = (const SPS*)pps->sps_ref->data;
747  sps = pps->sps;
748 
749  if (sps->bit_depth_luma > 14) {
750  av_log(avctx, AV_LOG_ERROR,
751  "Invalid luma bit depth=%d\n",
752  sps->bit_depth_luma);
754  goto fail;
755  } else if (sps->bit_depth_luma == 11 || sps->bit_depth_luma == 13) {
757  "Unimplemented luma bit depth=%d",
758  sps->bit_depth_luma);
760  goto fail;
761  }
762 
763  pps->cabac = get_bits1(gb);
764  pps->pic_order_present = get_bits1(gb);
765  pps->slice_group_count = get_ue_golomb(gb) + 1;
766  if (pps->slice_group_count > 1) {
767  pps->mb_slice_group_map_type = get_ue_golomb(gb);
768  avpriv_report_missing_feature(avctx, "FMO");
770  goto fail;
771  }
772  pps->ref_count[0] = get_ue_golomb(gb) + 1;
773  pps->ref_count[1] = get_ue_golomb(gb) + 1;
774  if (pps->ref_count[0] - 1 > 32 - 1 || pps->ref_count[1] - 1 > 32 - 1) {
775  av_log(avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
777  goto fail;
778  }
779 
780  qp_bd_offset = 6 * (sps->bit_depth_luma - 8);
781 
782  pps->weighted_pred = get_bits1(gb);
783  pps->weighted_bipred_idc = get_bits(gb, 2);
784  pps->init_qp = get_se_golomb(gb) + 26U + qp_bd_offset;
785  pps->init_qs = get_se_golomb(gb) + 26U + qp_bd_offset;
786  pps->chroma_qp_index_offset[0] = get_se_golomb(gb);
787  if (pps->chroma_qp_index_offset[0] < -12 || pps->chroma_qp_index_offset[0] > 12) {
789  goto fail;
790  }
791 
792  pps->deblocking_filter_parameters_present = get_bits1(gb);
793  pps->constrained_intra_pred = get_bits1(gb);
794  pps->redundant_pic_cnt_present = get_bits1(gb);
795 
796  pps->transform_8x8_mode = 0;
797  memcpy(pps->scaling_matrix4, sps->scaling_matrix4,
798  sizeof(pps->scaling_matrix4));
799  memcpy(pps->scaling_matrix8, sps->scaling_matrix8,
800  sizeof(pps->scaling_matrix8));
801 
802  bits_left = bit_length - get_bits_count(gb);
803  if (bits_left > 0 && more_rbsp_data_in_pps(sps, avctx)) {
804  pps->transform_8x8_mode = get_bits1(gb);
806  pps->scaling_matrix4, pps->scaling_matrix8);
807  if (ret < 0)
808  goto fail;
809  // second_chroma_qp_index_offset
810  pps->chroma_qp_index_offset[1] = get_se_golomb(gb);
811  if (pps->chroma_qp_index_offset[1] < -12 || pps->chroma_qp_index_offset[1] > 12) {
813  goto fail;
814  }
815  } else {
816  pps->chroma_qp_index_offset[1] = pps->chroma_qp_index_offset[0];
817  }
818 
819  build_qp_table(pps, 0, pps->chroma_qp_index_offset[0],
820  sps->bit_depth_luma);
821  build_qp_table(pps, 1, pps->chroma_qp_index_offset[1],
822  sps->bit_depth_luma);
823 
825 
826  if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])
827  pps->chroma_qp_diff = 1;
828 
829  if (avctx->debug & FF_DEBUG_PICT_INFO) {
830  av_log(avctx, AV_LOG_DEBUG,
831  "pps:%u sps:%u %s slice_groups:%d ref:%u/%u %s qp:%d/%d/%d/%d %s %s %s %s\n",
832  pps_id, pps->sps_id,
833  pps->cabac ? "CABAC" : "CAVLC",
834  pps->slice_group_count,
835  pps->ref_count[0], pps->ref_count[1],
836  pps->weighted_pred ? "weighted" : "",
837  pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1],
838  pps->deblocking_filter_parameters_present ? "LPAR" : "",
839  pps->constrained_intra_pred ? "CONSTR" : "",
840  pps->redundant_pic_cnt_present ? "REDU" : "",
841  pps->transform_8x8_mode ? "8x8DCT" : "");
842  }
843 
844  remove_pps(ps, pps_id);
845  ps->pps_list[pps_id] = pps_buf;
846 
847  return 0;
848 
849 fail:
850  av_buffer_unref(&pps_buf);
851  return ret;
852 }
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
H264ParamSets::sps
const SPS * sps
Definition: h264_ps.h:144
av_clip
#define av_clip
Definition: common.h:95
show_bits1
static unsigned int show_bits1(GetBitContext *s)
Definition: get_bits.h:533
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:839
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
ff_h264_ps_uninit
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
Definition: h264_ps.c:264
pps_free
static void pps_free(void *opaque, uint8_t *data)
Definition: h264_ps.c:686
get_se_golomb_long
static int get_se_golomb_long(GetBitContext *gb)
Definition: golomb.h:294
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:546
ff_h264_chroma_qp
const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM+1]
Definition: h264data.c:203
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
GetBitContext::size_in_bits
int size_in_bits
Definition: get_bits.h:68
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
level_idc
int level_idc
Definition: h264_levels.c:25
data
const char data[16]
Definition: mxf.c:146
FF_COMPLIANCE_STRICT
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
Definition: defs.h:59
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
init_dequant_tables
static void init_dequant_tables(PPS *pps, const SPS *sps)
Definition: h264_ps.c:644
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
FF_DEBUG_PICT_INFO
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:1328
AV_CODEC_FLAG2_IGNORE_CROP
#define AV_CODEC_FLAG2_IGNORE_CROP
Discard cropping information from SPS.
Definition: avcodec.h:326
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
ff_h264_decode_picture_parameter_set
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
Definition: h264_ps.c:695
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
golomb.h
exp golomb vlc stuff
remove_pps
static void remove_pps(H264ParamSets *s, int id)
Definition: h264_ps.c:86
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
fail
#define fail()
Definition: checkasm.h:134
GetBitContext
Definition: get_bits.h:61
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:256
H264ParamSets::overread_warning_printed
int overread_warning_printed[2]
Definition: h264_ps.h:146
H264_MAX_DPB_FRAMES
@ H264_MAX_DPB_FRAMES
Definition: h264.h:76
h264data.h
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
H264ParamSets::sps_list
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: h264_ps.h:138
get_se_golomb
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
Definition: golomb.h:239
decode_scaling_list
static int decode_scaling_list(GetBitContext *gb, uint8_t *factors, int size, const uint8_t *jvt_list, const uint8_t *fallback_list)
Definition: h264_ps.c:199
if
if(ret)
Definition: filter_design.txt:179
GetBitContext::buffer
const uint8_t * buffer
Definition: get_bits.h:62
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
av_buffer_unref
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:139
profile_idc
int profile_idc
Definition: h264_levels.c:53
more_rbsp_data_in_pps
static int more_rbsp_data_in_pps(const SPS *sps, void *logctx)
Definition: h264_ps.c:672
ff_h264_dequant8_coeff_init_scan
const uint8_t ff_h264_dequant8_coeff_init_scan[16]
Definition: h264data.c:161
SPS
Sequence parameter set.
Definition: h264_ps.h:45
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
PPS
Picture parameter set.
Definition: h264_ps.h:105
mathops.h
MAX_PPS_COUNT
#define MAX_PPS_COUNT
Definition: h264_ps.h:39
level_max_dpb_mbs
static const int level_max_dpb_mbs[][2]
Definition: h264_ps.c:67
h264_ps.h
index
int index
Definition: gxfenc.c:89
decode_hrd_parameters
static int decode_hrd_parameters(GetBitContext *gb, void *logctx, SPS *sps)
Definition: h264_ps.c:105
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:55
AVCodecContext::flags2
int flags2
AV_CODEC_FLAG2_*.
Definition: avcodec.h:485
ff_zigzag_scan
const uint8_t ff_zigzag_scan[16+1]
Definition: mathtables.c:109
ff_h264_dequant8_coeff_init
const uint8_t ff_h264_dequant8_coeff_init[6][6]
Definition: h264data.c:165
pps
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Definition: cbs_h264_syntax_template.c:404
shift
static int shift(int a, int b)
Definition: bonk.c:253
size
int size
Definition: twinvq_data.h:10344
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
remove_sps
static void remove_sps(H264ParamSets *s, int id)
Definition: h264_ps.c:91
init_dequant8_coeff_table
static void init_dequant8_coeff_table(PPS *pps, const SPS *sps)
Definition: h264_ps.c:591
MAX_LOG2_MAX_FRAME_NUM
#define MAX_LOG2_MAX_FRAME_NUM
Definition: h264_ps.h:40
height
#define height
ff_h264_quant_rem6
const uint8_t ff_h264_quant_rem6[QP_MAX_NUM+1]
Definition: h264data.c:174
decode_vui_parameters
static int decode_vui_parameters(GetBitContext *gb, void *logctx, SPS *sps)
Definition: h264_ps.c:131
decode_scaling_matrices
static int decode_scaling_matrices(GetBitContext *gb, const SPS *sps, const PPS *pps, int is_sps, uint8_t(*scaling_matrix4)[16], uint8_t(*scaling_matrix8)[64])
Definition: h264_ps.c:227
MIN_LOG2_MAX_FRAME_NUM
#define MIN_LOG2_MAX_FRAME_NUM
Definition: h264_ps.c:38
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:94
default_scaling4
static const uint8_t default_scaling4[2][16]
Definition: h264_ps.c:40
ff_h264_decode_seq_parameter_set
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int ignore_truncation)
Decode SPS.
Definition: h264_ps.c:280
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:264
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:590
GetBitContext::buffer_end
const uint8_t * buffer_end
Definition: get_bits.h:62
avcodec.h
ff_zigzag_direct
const uint8_t ff_zigzag_direct[64]
Definition: mathtables.c:98
av_buffer_allocz
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:93
ret
ret
Definition: filter_design.txt:187
h2645_vui.h
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1310
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
ff_h2645_decode_common_vui_params
void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
Definition: h2645_vui.c:37
default_scaling8
static const uint8_t default_scaling8[2][64]
Definition: h264_ps.c:47
build_qp_table
static void build_qp_table(PPS *pps, int t, int index, const int depth)
Definition: h264_ps.c:663
U
#define U(x)
Definition: vpx_arith.h:37
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:150
id
enum AVCodecID id
Definition: dts2pts_bsf.c:362
AVCodecContext
main external API structure.
Definition: avcodec.h:398
ff_h264_dequant4_coeff_init
const uint8_t ff_h264_dequant4_coeff_init[6][3]
Definition: h264data.c:152
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
H264ParamSets::pps_list
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: h264_ps.h:139
H264ParamSets
Definition: h264_ps.h:137
MAX_SPS_COUNT
#define MAX_SPS_COUNT
Definition: h264_ps.h:38
ff_h264_quant_div6
const uint8_t ff_h264_quant_div6[QP_MAX_NUM+1]
Definition: h264data.c:182
AVCodecContext::debug
int debug
debug
Definition: avcodec.h:1327
av_log_once
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
Definition: log.c:417
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
get_ue_golomb_long
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:104
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
init_dequant4_coeff_table
static void init_dequant4_coeff_table(PPS *pps, const SPS *sps)
Definition: h264_ps.c:618
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:423
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
imgutils.h
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
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
H264ParamSets::pps
const PPS * pps
Definition: h264_ps.h:143
av_image_check_size
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:318
H264ParamSets::pps_ref
AVBufferRef * pps_ref
Definition: h264_ps.h:141