FFmpeg  4.0.3
cbs_h264_syntax_template.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
20 {
21  int err;
22  av_unused int one = 1, zero = 0;
23  xu(1, rbsp_stop_one_bit, one, 1, 1);
24  while (byte_alignment(rw) != 0)
25  xu(1, rbsp_alignment_zero_bit, zero, 0, 0);
26 
27  return 0;
28 }
29 
31  H264RawNALUnitHeader *current,
32  uint32_t valid_type_mask)
33 {
34  int err;
35 
36  u(1, forbidden_zero_bit, 0, 0);
37  u(2, nal_ref_idc, 0, 3);
38  u(5, nal_unit_type, 0, 31);
39 
40  if (!(1 << current->nal_unit_type & valid_type_mask)) {
41  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid NAL unit type %d.\n",
42  current->nal_unit_type);
43  return AVERROR_INVALIDDATA;
44  }
45 
46  if (current->nal_unit_type == 14 ||
47  current->nal_unit_type == 20 ||
48  current->nal_unit_type == 21) {
49  if (current->nal_unit_type != 21)
50  flag(svc_extension_flag);
51  else
52  flag(avc_3d_extension_flag);
53 
54  if (current->svc_extension_flag) {
55  av_log(ctx->log_ctx, AV_LOG_ERROR, "SVC not supported.\n");
56  return AVERROR_PATCHWELCOME;
57 
58  } else if (current->avc_3d_extension_flag) {
59  av_log(ctx->log_ctx, AV_LOG_ERROR, "3DAVC not supported.\n");
60  return AVERROR_PATCHWELCOME;
61 
62  } else {
63  av_log(ctx->log_ctx, AV_LOG_ERROR, "MVC not supported.\n");
64  return AVERROR_PATCHWELCOME;
65  }
66  }
67 
68  return 0;
69 }
70 
72  H264RawScalingList *current,
73  int size_of_scaling_list)
74 {
75  int err, i, scale;
76 
77  scale = 8;
78  for (i = 0; i < size_of_scaling_list; i++) {
79  xse(delta_scale, current->delta_scale[i], -128, +127);
80  scale = (scale + current->delta_scale[i] + 256) % 256;
81  if (scale == 0)
82  break;
83  }
84 
85  return 0;
86 }
87 
89  H264RawHRD *current)
90 {
91  int err, i;
92 
93  ue(cpb_cnt_minus1, 0, 31);
94  u(4, bit_rate_scale, 0, 15);
95  u(4, cpb_size_scale, 0, 15);
96 
97  for (i = 0; i <= current->cpb_cnt_minus1; i++) {
98  ue(bit_rate_value_minus1[i], 0, UINT32_MAX - 1);
99  ue(cpb_size_value_minus1[i], 0, UINT32_MAX - 1);
100  flag(cbr_flag[i]);
101  }
102 
103  u(5, initial_cpb_removal_delay_length_minus1, 0, 31);
104  u(5, cpb_removal_delay_length_minus1, 0, 31);
105  u(5, dpb_output_delay_length_minus1, 0, 31);
106  u(5, time_offset_length, 0, 31);
107 
108  return 0;
109 }
110 
112  H264RawVUI *current, H264RawSPS *sps)
113 {
114  int err;
115 
116  flag(aspect_ratio_info_present_flag);
117  if (current->aspect_ratio_info_present_flag) {
118  u(8, aspect_ratio_idc, 0, 255);
119  if (current->aspect_ratio_idc == 255) {
120  u(16, sar_width, 0, 65535);
121  u(16, sar_height, 0, 65535);
122  }
123  } else {
124  infer(aspect_ratio_idc, 0);
125  }
126 
127  flag(overscan_info_present_flag);
128  if (current->overscan_info_present_flag)
129  flag(overscan_appropriate_flag);
130 
131  flag(video_signal_type_present_flag);
132  if (current->video_signal_type_present_flag) {
133  u(3, video_format, 0, 7);
134  flag(video_full_range_flag);
135  flag(colour_description_present_flag);
136  if (current->colour_description_present_flag) {
137  u(8, colour_primaries, 0, 255);
138  u(8, transfer_characteristics, 0, 255);
139  u(8, matrix_coefficients, 0, 255);
140  }
141  } else {
142  infer(video_format, 5);
143  infer(video_full_range_flag, 0);
144  infer(colour_primaries, 2);
146  infer(matrix_coefficients, 2);
147  }
148 
149  flag(chroma_loc_info_present_flag);
150  if (current->chroma_loc_info_present_flag) {
151  ue(chroma_sample_loc_type_top_field, 0, 5);
152  ue(chroma_sample_loc_type_bottom_field, 0, 5);
153  } else {
154  infer(chroma_sample_loc_type_top_field, 0);
155  infer(chroma_sample_loc_type_bottom_field, 0);
156  }
157 
158  flag(timing_info_present_flag);
159  if (current->timing_info_present_flag) {
160  u(32, num_units_in_tick, 1, UINT32_MAX);
161  u(32, time_scale, 1, UINT32_MAX);
162  flag(fixed_frame_rate_flag);
163  } else {
164  infer(fixed_frame_rate_flag, 0);
165  }
166 
167  flag(nal_hrd_parameters_present_flag);
168  if (current->nal_hrd_parameters_present_flag)
169  CHECK(FUNC(hrd_parameters)(ctx, rw, &current->nal_hrd_parameters));
170 
171  flag(vcl_hrd_parameters_present_flag);
172  if (current->vcl_hrd_parameters_present_flag)
173  CHECK(FUNC(hrd_parameters)(ctx, rw, &current->vcl_hrd_parameters));
174 
175  if (current->nal_hrd_parameters_present_flag ||
176  current->vcl_hrd_parameters_present_flag)
177  flag(low_delay_hrd_flag);
178  else
179  infer(low_delay_hrd_flag, 1 - current->fixed_frame_rate_flag);
180 
181  flag(pic_struct_present_flag);
182 
183  flag(bitstream_restriction_flag);
184  if (current->bitstream_restriction_flag) {
185  flag(motion_vectors_over_pic_boundaries_flag);
186  ue(max_bytes_per_pic_denom, 0, 16);
187  ue(max_bits_per_mb_denom, 0, 16);
188  ue(log2_max_mv_length_horizontal, 0, 16);
189  ue(log2_max_mv_length_vertical, 0, 16);
190  ue(max_num_reorder_frames, 0, H264_MAX_DPB_FRAMES);
191  ue(max_dec_frame_buffering, 0, H264_MAX_DPB_FRAMES);
192  } else {
193  infer(motion_vectors_over_pic_boundaries_flag, 1);
194  infer(max_bytes_per_pic_denom, 2);
195  infer(max_bits_per_mb_denom, 1);
196  infer(log2_max_mv_length_horizontal, 16);
197  infer(log2_max_mv_length_vertical, 16);
198 
199  if ((sps->profile_idc == 44 || sps->profile_idc == 86 ||
200  sps->profile_idc == 110 || sps->profile_idc == 110 ||
201  sps->profile_idc == 122 || sps->profile_idc == 244) &&
202  sps->constraint_set3_flag) {
203  infer(max_num_reorder_frames, 0);
204  infer(max_dec_frame_buffering, 0);
205  } else {
206  infer(max_num_reorder_frames, H264_MAX_DPB_FRAMES);
207  infer(max_dec_frame_buffering, H264_MAX_DPB_FRAMES);
208  }
209  }
210 
211  return 0;
212 }
213 
215  H264RawSPS *current)
216 {
217  int err, i;
218 
219  HEADER("Sequence Parameter Set");
220 
221  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
222  1 << H264_NAL_SPS));
223 
224  u(8, profile_idc, 0, 255);
225 
226  flag(constraint_set0_flag);
227  flag(constraint_set1_flag);
228  flag(constraint_set2_flag);
229  flag(constraint_set3_flag);
230  flag(constraint_set4_flag);
231  flag(constraint_set5_flag);
232 
233  u(2, reserved_zero_2bits, 0, 0);
234 
235  u(8, level_idc, 0, 255);
236 
237  ue(seq_parameter_set_id, 0, 31);
238 
239  if (current->profile_idc == 100 || current->profile_idc == 110 ||
240  current->profile_idc == 122 || current->profile_idc == 244 ||
241  current->profile_idc == 44 || current->profile_idc == 83 ||
242  current->profile_idc == 86 || current->profile_idc == 118 ||
243  current->profile_idc == 128 || current->profile_idc == 138) {
244  ue(chroma_format_idc, 0, 3);
245 
246  if (current->chroma_format_idc == 3)
247  flag(separate_colour_plane_flag);
248  else
249  infer(separate_colour_plane_flag, 0);
250 
251  ue(bit_depth_luma_minus8, 0, 6);
252  ue(bit_depth_chroma_minus8, 0, 6);
253 
254  flag(qpprime_y_zero_transform_bypass_flag);
255 
256  flag(seq_scaling_matrix_present_flag);
257  if (current->seq_scaling_matrix_present_flag) {
258  for (i = 0; i < ((current->chroma_format_idc != 3) ? 8 : 12); i++) {
259  flag(seq_scaling_list_present_flag[i]);
260  if (current->seq_scaling_list_present_flag[i]) {
261  if (i < 6)
262  CHECK(FUNC(scaling_list)(ctx, rw,
263  &current->scaling_list_4x4[i],
264  16));
265  else
266  CHECK(FUNC(scaling_list)(ctx, rw,
267  &current->scaling_list_8x8[i - 6],
268  64));
269  }
270  }
271  }
272  } else {
273  infer(chroma_format_idc, current->profile_idc == 183 ? 0 : 1);
274 
275  infer(separate_colour_plane_flag, 0);
276  infer(bit_depth_luma_minus8, 0);
277  infer(bit_depth_chroma_minus8, 0);
278  }
279 
280  ue(log2_max_frame_num_minus4, 0, 12);
281  ue(pic_order_cnt_type, 0, 2);
282 
283  if (current->pic_order_cnt_type == 0) {
284  ue(log2_max_pic_order_cnt_lsb_minus4, 0, 12);
285  } else if (current->pic_order_cnt_type == 1) {
286  flag(delta_pic_order_always_zero_flag);
287  se(offset_for_non_ref_pic, INT32_MIN + 1, INT32_MAX);
288  se(offset_for_top_to_bottom_field, INT32_MIN + 1, INT32_MAX);
289  ue(num_ref_frames_in_pic_order_cnt_cycle, 0, 255);
290 
291  for (i = 0; i < current->num_ref_frames_in_pic_order_cnt_cycle; i++)
292  se(offset_for_ref_frame[i], INT32_MIN + 1, INT32_MAX);
293  }
294 
295  ue(max_num_ref_frames, 0, H264_MAX_DPB_FRAMES);
296  flag(gaps_in_frame_num_allowed_flag);
297 
298  ue(pic_width_in_mbs_minus1, 0, H264_MAX_MB_WIDTH);
299  ue(pic_height_in_map_units_minus1, 0, H264_MAX_MB_HEIGHT);
300 
301  flag(frame_mbs_only_flag);
302  if (!current->frame_mbs_only_flag)
303  flag(mb_adaptive_frame_field_flag);
304 
305  flag(direct_8x8_inference_flag);
306 
307  flag(frame_cropping_flag);
308  if (current->frame_cropping_flag) {
309  ue(frame_crop_left_offset, 0, H264_MAX_WIDTH);
310  ue(frame_crop_right_offset, 0, H264_MAX_WIDTH);
311  ue(frame_crop_top_offset, 0, H264_MAX_HEIGHT);
312  ue(frame_crop_bottom_offset, 0, H264_MAX_HEIGHT);
313  }
314 
315  flag(vui_parameters_present_flag);
316  if (current->vui_parameters_present_flag)
317  CHECK(FUNC(vui_parameters)(ctx, rw, &current->vui, current));
318 
320 
321  return 0;
322 }
323 
325  H264RawSPSExtension *current)
326 {
327  int err;
328 
329  HEADER("Sequence Parameter Set Extension");
330 
331  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
332  1 << H264_NAL_SPS_EXT));
333 
334  ue(seq_parameter_set_id, 0, 31);
335 
336  ue(aux_format_idc, 0, 3);
337 
338  if (current->aux_format_idc != 0) {
339  int bits;
340 
341  ue(bit_depth_aux_minus8, 0, 4);
342  flag(alpha_incr_flag);
343 
344  bits = current->bit_depth_aux_minus8 + 9;
345  u(bits, alpha_opaque_value, 0, MAX_UINT_BITS(bits));
346  u(bits, alpha_transparent_value, 0, MAX_UINT_BITS(bits));
347  }
348 
349  flag(additional_extension_flag);
350 
352 
353  return 0;
354 }
355 
357  H264RawPPS *current)
358 {
360  const H264RawSPS *sps;
361  int err, i;
362 
363  HEADER("Picture Parameter Set");
364 
365  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
366  1 << H264_NAL_PPS));
367 
368  ue(pic_parameter_set_id, 0, 255);
369  ue(seq_parameter_set_id, 0, 31);
370 
371  sps = h264->sps[current->seq_parameter_set_id];
372  if (!sps) {
373  av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
374  current->seq_parameter_set_id);
375  return AVERROR_INVALIDDATA;
376  }
377 
378  flag(entropy_coding_mode_flag);
379  flag(bottom_field_pic_order_in_frame_present_flag);
380 
381  ue(num_slice_groups_minus1, 0, 7);
382  if (current->num_slice_groups_minus1 > 0) {
383  unsigned int pic_size;
384  int iGroup;
385 
386  pic_size = (sps->pic_width_in_mbs_minus1 + 1) *
388 
389  ue(slice_group_map_type, 0, 6);
390 
391  if (current->slice_group_map_type == 0) {
392  for (iGroup = 0; iGroup <= current->num_slice_groups_minus1; iGroup++)
393  ue(run_length_minus1[iGroup], 0, pic_size - 1);
394 
395  } else if (current->slice_group_map_type == 2) {
396  for (iGroup = 0; iGroup < current->num_slice_groups_minus1; iGroup++) {
397  ue(top_left[iGroup], 0, pic_size - 1);
398  ue(bottom_right[iGroup], current->top_left[iGroup], pic_size - 1);
399  }
400  } else if (current->slice_group_map_type == 3 ||
401  current->slice_group_map_type == 4 ||
402  current->slice_group_map_type == 5) {
403  flag(slice_group_change_direction_flag);
404  ue(slice_group_change_rate_minus1, 0, pic_size - 1);
405  } else if (current->slice_group_map_type == 6) {
406  ue(pic_size_in_map_units_minus1, pic_size - 1, pic_size - 1);
407 
408  allocate(current->slice_group_id,
409  current->pic_size_in_map_units_minus1 + 1);
410  for (i = 0; i <= current->pic_size_in_map_units_minus1; i++)
411  u(av_log2(2 * current->num_slice_groups_minus1 + 1),
412  slice_group_id[i], 0, current->num_slice_groups_minus1);
413  }
414  }
415 
416  ue(num_ref_idx_l0_default_active_minus1, 0, 31);
417  ue(num_ref_idx_l1_default_active_minus1, 0, 31);
418 
419  flag(weighted_pred_flag);
420  u(2, weighted_bipred_idc, 0, 2);
421 
422  se(pic_init_qp_minus26, -26 - 6 * sps->bit_depth_luma_minus8, +25);
423  se(pic_init_qs_minus26, -26, +25);
424  se(chroma_qp_index_offset, -12, +12);
425 
426  flag(deblocking_filter_control_present_flag);
427  flag(constrained_intra_pred_flag);
428  flag(redundant_pic_cnt_present_flag);
429 
430  if (more_rbsp_data(current->more_rbsp_data))
431  {
432  flag(transform_8x8_mode_flag);
433 
434  flag(pic_scaling_matrix_present_flag);
435  if (current->pic_scaling_matrix_present_flag) {
436  for (i = 0; i < 6 + (((sps->chroma_format_idc != 3) ? 2 : 6) *
437  current->transform_8x8_mode_flag); i++) {
438  flag(pic_scaling_list_present_flag[i]);
439  if (current->pic_scaling_list_present_flag[i]) {
440  if (i < 6)
441  CHECK(FUNC(scaling_list)(ctx, rw,
442  &current->scaling_list_4x4[i],
443  16));
444  else
445  CHECK(FUNC(scaling_list)(ctx, rw,
446  &current->scaling_list_8x8[i - 6],
447  64));
448  }
449  }
450  }
451 
452  se(second_chroma_qp_index_offset, -12, +12);
453  } else {
454  infer(transform_8x8_mode_flag, 0);
455  infer(pic_scaling_matrix_present_flag, 0);
456  infer(second_chroma_qp_index_offset, current->chroma_qp_index_offset);
457  }
458 
460 
461  return 0;
462 }
463 
465  H264RawSEIBufferingPeriod *current)
466 {
468  const H264RawSPS *sps;
469  int err, i, length;
470 
471  ue(seq_parameter_set_id, 0, 31);
472 
473  sps = h264->sps[current->seq_parameter_set_id];
474  if (!sps) {
475  av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
476  current->seq_parameter_set_id);
477  return AVERROR_INVALIDDATA;
478  }
479  h264->active_sps = sps;
480 
482  for (i = 0; i <= sps->vui.nal_hrd_parameters.cpb_cnt_minus1; i++) {
484  xu(length, initial_cpb_removal_delay[SchedSelIdx],
485  current->nal.initial_cpb_removal_delay[i],
486  1, MAX_UINT_BITS(length));
487  xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
488  current->nal.initial_cpb_removal_delay_offset[i],
489  0, MAX_UINT_BITS(length));
490  }
491  }
492 
494  for (i = 0; i <= sps->vui.vcl_hrd_parameters.cpb_cnt_minus1; i++) {
496  xu(length, initial_cpb_removal_delay[SchedSelIdx],
497  current->vcl.initial_cpb_removal_delay[i],
498  1, MAX_UINT_BITS(length));
499  xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
500  current->vcl.initial_cpb_removal_delay_offset[i],
501  0, MAX_UINT_BITS(length));
502  }
503  }
504 
505  return 0;
506 }
507 
509  H264RawSEIPicTimestamp *current)
510 {
512  const H264RawSPS *sps;
513  uint8_t time_offset_length;
514  int err;
515 
516  u(2, ct_type, 0, 2);
517  flag(nuit_field_based_flag);
518  u(5, counting_type, 0, 6);
519  flag(full_timestamp_flag);
520  flag(discontinuity_flag);
521  flag(cnt_dropped_flag);
522  u(8, n_frames, 0, 255);
523  if (current->full_timestamp_flag) {
524  u(6, seconds_value, 0, 59);
525  u(6, minutes_value, 0, 59);
526  u(5, hours_value, 0, 23);
527  } else {
528  flag(seconds_flag);
529  if (current->seconds_flag) {
530  u(6, seconds_value, 0, 59);
531  flag(minutes_flag);
532  if (current->minutes_flag) {
533  u(6, minutes_value, 0, 59);
534  flag(hours_flag);
535  if (current->hours_flag)
536  u(5, hours_value, 0, 23);
537  }
538  }
539  }
540 
541  sps = h264->active_sps;
542  if (!sps) {
543  av_log(ctx->log_ctx, AV_LOG_ERROR,
544  "No active SPS for pic_timestamp.\n");
545  return AVERROR_INVALIDDATA;
546  }
547 
549  time_offset_length = sps->vui.nal_hrd_parameters.time_offset_length;
550  else if (sps->vui.vcl_hrd_parameters_present_flag)
551  time_offset_length = sps->vui.vcl_hrd_parameters.time_offset_length;
552  else
553  time_offset_length = 24;
554 
555  if (time_offset_length > 0)
556  u(time_offset_length, time_offset,
557  0, MAX_UINT_BITS(time_offset_length));
558  else
559  infer(time_offset, 0);
560 
561  return 0;
562 }
563 
565  H264RawSEIPicTiming *current)
566 {
568  const H264RawSPS *sps;
569  int err;
570 
571  sps = h264->active_sps;
572  if (!sps) {
573  // If there is exactly one possible SPS but it is not yet active
574  // then just assume that it should be the active one.
575  int i, k = -1;
576  for (i = 0; i < H264_MAX_SPS_COUNT; i++) {
577  if (h264->sps[i]) {
578  if (k >= 0) {
579  k = -1;
580  break;
581  }
582  k = i;
583  }
584  }
585  if (k >= 0)
586  sps = h264->sps[k];
587  }
588  if (!sps) {
589  av_log(ctx->log_ctx, AV_LOG_ERROR,
590  "No active SPS for pic_timing.\n");
591  return AVERROR_INVALIDDATA;
592  }
593 
596  const H264RawHRD *hrd;
597 
599  hrd = &sps->vui.nal_hrd_parameters;
600  else if (sps->vui.vcl_hrd_parameters_present_flag)
601  hrd = &sps->vui.vcl_hrd_parameters;
602  else {
603  av_log(ctx->log_ctx, AV_LOG_ERROR,
604  "No HRD parameters for pic_timing.\n");
605  return AVERROR_INVALIDDATA;
606  }
607 
608  u(hrd->cpb_removal_delay_length_minus1 + 1, cpb_removal_delay,
610  u(hrd->dpb_output_delay_length_minus1 + 1, dpb_output_delay,
612  }
613 
614  if (sps->vui.pic_struct_present_flag) {
615  static const int num_clock_ts[9] = {
616  1, 1, 1, 2, 2, 3, 3, 2, 3
617  };
618  int i;
619 
620  u(4, pic_struct, 0, 8);
621  if (current->pic_struct > 8)
622  return AVERROR_INVALIDDATA;
623 
624  for (i = 0; i < num_clock_ts[current->pic_struct]; i++) {
625  flag(clock_timestamp_flag[i]);
626  if (current->clock_timestamp_flag[i])
627  CHECK(FUNC(sei_pic_timestamp)(ctx, rw, &current->timestamp[i]));
628  }
629  }
630 
631  return 0;
632 }
633 
636  uint32_t *payload_size)
637 {
638  int err, i, j;
639 
640  u(8, itu_t_t35_country_code, 0x00, 0xff);
641  if (current->itu_t_t35_country_code != 0xff)
642  i = 1;
643  else {
644  u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
645  i = 2;
646  }
647 
648 #ifdef READ
649  if (*payload_size < i) {
650  av_log(ctx->log_ctx, AV_LOG_ERROR,
651  "Invalid SEI user data registered payload.\n");
652  return AVERROR_INVALIDDATA;
653  }
654  current->data_length = *payload_size - i;
655 #else
656  *payload_size = i + current->data_length;
657 #endif
658 
659  allocate(current->data, current->data_length + AV_INPUT_BUFFER_PADDING_SIZE);
660  for (j = 0; j < current->data_length; j++)
661  xu(8, itu_t_t35_payload_byte, current->data[j], 0x00, 0xff);
662 
663  return 0;
664 }
665 
668  uint32_t *payload_size)
669 {
670  int err, i;
671 
672 #ifdef READ
673  if (*payload_size < 16) {
674  av_log(ctx->log_ctx, AV_LOG_ERROR,
675  "Invalid SEI user data unregistered payload.\n");
676  return AVERROR_INVALIDDATA;
677  }
678  current->data_length = *payload_size - 16;
679 #else
680  *payload_size = 16 + current->data_length;
681 #endif
682 
683  for (i = 0; i < 16; i++) {
684  xu(8, uuid_iso_iec_11578,
685  current->uuid_iso_iec_11578[i], 0x00, 0xff);
686  }
687 
688  allocate(current->data, current->data_length);
689 
690  for (i = 0; i < current->data_length; i++)
691  xu(8, user_data_payload_byte, current->data[i], 0x00, 0xff);
692 
693  return 0;
694 }
695 
697  H264RawSEIRecoveryPoint *current)
698 {
699  int err;
700 
701  ue(recovery_frame_cnt, 0, 65535);
702  flag(exact_match_flag);
703  flag(broken_link_flag);
704  u(2, changing_slice_group_idc, 0, 2);
705 
706  return 0;
707 }
708 
711 {
712  int err;
713 
714  flag(display_orientation_cancel_flag);
715  if (!current->display_orientation_cancel_flag) {
716  flag(hor_flip);
717  flag(ver_flip);
718  u(16, anticlockwise_rotation, 0, 65535);
719  ue(display_orientation_repetition_period, 0, 16384);
720  flag(display_orientation_extension_flag);
721  }
722 
723  return 0;
724 }
725 
727  H264RawSEIPayload *current)
728 {
729  int err, i;
730  int start_position, end_position;
731 
732 #ifdef READ
733  start_position = get_bits_count(rw);
734 #else
735  start_position = put_bits_count(rw);
736 #endif
737 
738  switch (current->payload_type) {
741  (ctx, rw, &current->payload.buffering_period));
742  break;
745  (ctx, rw, &current->payload.pic_timing));
746  break;
748  {
749  av_unused int ff_byte = 0xff;
750  for (i = 0; i < current->payload_size; i++)
751  xu(8, ff_byte, ff_byte, 0xff, 0xff);
752  }
753  break;
756  (ctx, rw, &current->payload.user_data_registered, &current->payload_size));
757  break;
760  (ctx, rw, &current->payload.user_data_unregistered, &current->payload_size));
761  break;
764  (ctx, rw, &current->payload.recovery_point));
765  break;
768  (ctx, rw, &current->payload.display_orientation));
769  break;
770  default:
771  {
772  allocate(current->payload.other.data, current->payload_size);
773  for (i = 0; i < current->payload_size; i++)
774  xu(8, payload_byte, current->payload.other.data[i], 0, 255);
775  }
776  }
777 
778  if (byte_alignment(rw)) {
779  av_unused int one = 1, zero = 0;
780  xu(1, bit_equal_to_one, one, 1, 1);
781  while (byte_alignment(rw))
782  xu(1, bit_equal_to_zero, zero, 0, 0);
783  }
784 
785 #ifdef READ
786  end_position = get_bits_count(rw);
787  if (end_position < start_position + 8 * current->payload_size) {
788  av_log(ctx->log_ctx, AV_LOG_ERROR, "Incorrect SEI payload length: "
789  "header %"PRIu32" bits, actually %d bits.\n",
790  8 * current->payload_size,
791  end_position - start_position);
792  return AVERROR_INVALIDDATA;
793  }
794 #else
795  end_position = put_bits_count(rw);
796  current->payload_size = (end_position - start_position) / 8;
797 #endif
798 
799  return 0;
800 }
801 
803  H264RawSEI *current)
804 {
805  int err, k;
806 
807  HEADER("Supplemental Enhancement Information");
808 
809  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
810  1 << H264_NAL_SEI));
811 
812 #ifdef READ
813  for (k = 0; k < H264_MAX_SEI_PAYLOADS; k++) {
814  uint32_t payload_type = 0;
815  uint32_t payload_size = 0;
816  uint32_t tmp;
817 
818  while (show_bits(rw, 8) == 0xff) {
819  xu(8, ff_byte, tmp, 0xff, 0xff);
820  payload_type += 255;
821  }
822  xu(8, last_payload_type_byte, tmp, 0, 254);
823  payload_type += tmp;
824 
825  while (show_bits(rw, 8) == 0xff) {
826  xu(8, ff_byte, tmp, 0xff, 0xff);
827  payload_size += 255;
828  }
829  xu(8, last_payload_size_byte, tmp, 0, 254);
830  payload_size += tmp;
831 
832  current->payload[k].payload_type = payload_type;
833  current->payload[k].payload_size = payload_size;
834 
835  CHECK(FUNC(sei_payload)(ctx, rw, &current->payload[k]));
836 
838  break;
839  }
840  if (k >= H264_MAX_SEI_PAYLOADS) {
841  av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many payloads in "
842  "SEI message: found %d.\n", k);
843  return AVERROR_INVALIDDATA;
844  }
845  current->payload_count = k + 1;
846 #else
847  for (k = 0; k < current->payload_count; k++) {
848  PutBitContext start_state;
849  uint32_t tmp;
850  int need_size, i;
851 
852  // Somewhat clumsy: we write the payload twice when
853  // we don't know the size in advance. This will mess
854  // with trace output, but is otherwise harmless.
855  start_state = *rw;
856  need_size = !current->payload[k].payload_size;
857  for (i = 0; i < 1 + need_size; i++) {
858  *rw = start_state;
859 
860  tmp = current->payload[k].payload_type;
861  while (tmp >= 255) {
862  xu(8, ff_byte, 0xff, 0xff, 0xff);
863  tmp -= 255;
864  }
865  xu(8, last_payload_type_byte, tmp, 0, 254);
866 
867  tmp = current->payload[k].payload_size;
868  while (tmp >= 255) {
869  xu(8, ff_byte, 0xff, 0xff, 0xff);
870  tmp -= 255;
871  }
872  xu(8, last_payload_size_byte, tmp, 0, 254);
873 
874  CHECK(FUNC(sei_payload)(ctx, rw, &current->payload[k]));
875  }
876  }
877 #endif
878 
880 
881  return 0;
882 }
883 
885  H264RawAUD *current)
886 {
887  int err;
888 
889  HEADER("Access Unit Delimiter");
890 
891  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
892  1 << H264_NAL_AUD));
893 
894  u(3, primary_pic_type, 0, 7);
895 
897 
898  return 0;
899 }
900 
902  H264RawSliceHeader *current)
903 {
905  const H264RawSPS *sps = h264->active_sps;
906  int err, i, mopn;
907 
908  if (current->slice_type % 5 != 2 &&
909  current->slice_type % 5 != 4) {
910  flag(ref_pic_list_modification_flag_l0);
911  if (current->ref_pic_list_modification_flag_l0) {
912  for (i = 0; i < H264_MAX_RPLM_COUNT; i++) {
913  xue(modification_of_pic_nums_idc,
914  current->rplm_l0[i].modification_of_pic_nums_idc, 0, 3);
915 
916  mopn = current->rplm_l0[i].modification_of_pic_nums_idc;
917  if (mopn == 3)
918  break;
919 
920  if (mopn == 0 || mopn == 1)
921  xue(abs_diff_pic_num_minus1,
922  current->rplm_l0[i].abs_diff_pic_num_minus1,
923  0, (1 + current->field_pic_flag) *
924  (1 << (sps->log2_max_frame_num_minus4 + 4)));
925  else if (mopn == 2)
926  xue(long_term_pic_num,
927  current->rplm_l0[i].long_term_pic_num,
928  0, sps->max_num_ref_frames - 1);
929  }
930  }
931  }
932 
933  if (current->slice_type % 5 == 1) {
934  flag(ref_pic_list_modification_flag_l1);
935  if (current->ref_pic_list_modification_flag_l1) {
936  for (i = 0; i < H264_MAX_RPLM_COUNT; i++) {
937  xue(modification_of_pic_nums_idc,
938  current->rplm_l1[i].modification_of_pic_nums_idc, 0, 3);
939 
940  mopn = current->rplm_l1[i].modification_of_pic_nums_idc;
941  if (mopn == 3)
942  break;
943 
944  if (mopn == 0 || mopn == 1)
945  xue(abs_diff_pic_num_minus1,
946  current->rplm_l1[i].abs_diff_pic_num_minus1,
947  0, (1 + current->field_pic_flag) *
948  (1 << (sps->log2_max_frame_num_minus4 + 4)));
949  else if (mopn == 2)
950  xue(long_term_pic_num,
951  current->rplm_l1[i].long_term_pic_num,
952  0, sps->max_num_ref_frames - 1);
953  }
954  }
955  }
956 
957  return 0;
958 }
959 
961  H264RawSliceHeader *current)
962 {
964  const H264RawSPS *sps = h264->active_sps;
965  int chroma;
966  int err, i, j;
967 
968  ue(luma_log2_weight_denom, 0, 7);
969 
970  chroma = !sps->separate_colour_plane_flag && sps->chroma_format_idc != 0;
971  if (chroma)
972  ue(chroma_log2_weight_denom, 0, 7);
973 
974  for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
975  flag(luma_weight_l0_flag[i]);
976  if (current->luma_weight_l0_flag[i]) {
977  se(luma_weight_l0[i], -128, +127);
978  se(luma_offset_l0[i], -128, +127);
979  }
980  if (chroma) {
981  flag(chroma_weight_l0_flag[i]);
982  if (current->chroma_weight_l0_flag[i]) {
983  for (j = 0; j < 2; j++) {
984  se(chroma_weight_l0[i][j], -128, +127);
985  se(chroma_offset_l0[i][j], -128, +127);
986  }
987  }
988  }
989  }
990 
991  if (current->slice_type % 5 == 1) {
992  for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
993  flag(luma_weight_l1_flag[i]);
994  if (current->luma_weight_l1_flag[i]) {
995  se(luma_weight_l1[i], -128, +127);
996  se(luma_offset_l1[i], -128, +127);
997  }
998  if (chroma) {
999  flag(chroma_weight_l1_flag[i]);
1000  if (current->chroma_weight_l1_flag[i]) {
1001  for (j = 0; j < 2; j++) {
1002  se(chroma_weight_l1[i][j], -128, +127);
1003  se(chroma_offset_l1[i][j], -128, +127);
1004  }
1005  }
1006  }
1007  }
1008  }
1009 
1010  return 0;
1011 }
1012 
1014  H264RawSliceHeader *current, int idr_pic_flag)
1015 {
1017  const H264RawSPS *sps = h264->active_sps;
1018  int err, i;
1019  uint32_t mmco;
1020 
1021  if (idr_pic_flag) {
1022  flag(no_output_of_prior_pics_flag);
1023  flag(long_term_reference_flag);
1024  } else {
1025  flag(adaptive_ref_pic_marking_mode_flag);
1026  if (current->adaptive_ref_pic_marking_mode_flag) {
1027  for (i = 0; i < H264_MAX_MMCO_COUNT; i++) {
1028  xue(memory_management_control_operation,
1029  current->mmco[i].memory_management_control_operation,
1030  0, 6);
1031 
1032  mmco = current->mmco[i].memory_management_control_operation;
1033  if (mmco == 0)
1034  break;
1035 
1036  if (mmco == 1 || mmco == 3)
1037  xue(difference_of_pic_nums_minus1,
1038  current->mmco[i].difference_of_pic_nums_minus1,
1039  0, INT32_MAX);
1040  if (mmco == 2)
1041  xue(long_term_pic_num,
1042  current->mmco[i].long_term_pic_num,
1043  0, sps->max_num_ref_frames - 1);
1044  if (mmco == 3 || mmco == 6)
1045  xue(long_term_frame_idx,
1046  current->mmco[i].long_term_frame_idx,
1047  0, sps->max_num_ref_frames - 1);
1048  if (mmco == 4)
1049  xue(max_long_term_frame_idx_plus1,
1050  current->mmco[i].max_long_term_frame_idx_plus1,
1051  0, sps->max_num_ref_frames);
1052  }
1053  if (i == H264_MAX_MMCO_COUNT) {
1054  av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many "
1055  "memory management control operations.\n");
1056  return AVERROR_INVALIDDATA;
1057  }
1058  }
1059  }
1060 
1061  return 0;
1062 }
1063 
1065  H264RawSliceHeader *current)
1066 {
1068  const H264RawSPS *sps;
1069  const H264RawPPS *pps;
1070  int err;
1071  int idr_pic_flag;
1072  int slice_type_i, slice_type_p, slice_type_b;
1073  int slice_type_si, slice_type_sp;
1074 
1075  HEADER("Slice Header");
1076 
1077  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
1078  1 << H264_NAL_SLICE |
1079  1 << H264_NAL_IDR_SLICE |
1080  1 << H264_NAL_AUXILIARY_SLICE));
1081 
1082  if (current->nal_unit_header.nal_unit_type == H264_NAL_AUXILIARY_SLICE) {
1083  if (!h264->last_slice_nal_unit_type) {
1084  av_log(ctx->log_ctx, AV_LOG_ERROR, "Auxiliary slice "
1085  "is not decodable without the main picture "
1086  "in the same access unit.\n");
1087  return AVERROR_INVALIDDATA;
1088  }
1089  } else {
1090  h264->last_slice_nal_unit_type =
1091  current->nal_unit_header.nal_unit_type;
1092  }
1093  idr_pic_flag = h264->last_slice_nal_unit_type == H264_NAL_IDR_SLICE;
1094 
1095  ue(first_mb_in_slice, 0, H264_MAX_MB_PIC_SIZE - 1);
1096  ue(slice_type, 0, 9);
1097 
1098  slice_type_i = current->slice_type % 5 == 2;
1099  slice_type_p = current->slice_type % 5 == 0;
1100  slice_type_b = current->slice_type % 5 == 1;
1101  slice_type_si = current->slice_type % 5 == 4;
1102  slice_type_sp = current->slice_type % 5 == 3;
1103 
1104  if (idr_pic_flag && !(slice_type_i || slice_type_si)) {
1105  av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid slice type %d "
1106  "for IDR picture.\n", current->slice_type);
1107  return AVERROR_INVALIDDATA;
1108  }
1109 
1110  ue(pic_parameter_set_id, 0, 255);
1111 
1112  pps = h264->pps[current->pic_parameter_set_id];
1113  if (!pps) {
1114  av_log(ctx->log_ctx, AV_LOG_ERROR, "PPS id %d not available.\n",
1115  current->pic_parameter_set_id);
1116  return AVERROR_INVALIDDATA;
1117  }
1118  h264->active_pps = pps;
1119 
1120  sps = h264->sps[pps->seq_parameter_set_id];
1121  if (!sps) {
1122  av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1123  pps->seq_parameter_set_id);
1124  return AVERROR_INVALIDDATA;
1125  }
1126  h264->active_sps = sps;
1127 
1128  if (sps->separate_colour_plane_flag)
1129  u(2, colour_plane_id, 0, 2);
1130 
1131  u(sps->log2_max_frame_num_minus4 + 4, frame_num,
1133 
1134  if (!sps->frame_mbs_only_flag) {
1135  flag(field_pic_flag);
1136  if (current->field_pic_flag)
1137  flag(bottom_field_flag);
1138  else
1139  infer(bottom_field_flag, 0);
1140  } else {
1141  infer(field_pic_flag, 0);
1142  infer(bottom_field_flag, 0);
1143  }
1144 
1145  if (idr_pic_flag)
1146  ue(idr_pic_id, 0, 65535);
1147 
1148  if (sps->pic_order_cnt_type == 0) {
1149  u(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, pic_order_cnt_lsb,
1152  !current->field_pic_flag)
1153  se(delta_pic_order_cnt_bottom, INT32_MIN + 1, INT32_MAX);
1154 
1155  } else if (sps->pic_order_cnt_type == 1) {
1157  se(delta_pic_order_cnt[0], INT32_MIN + 1, INT32_MAX);
1159  !current->field_pic_flag)
1160  se(delta_pic_order_cnt[1], INT32_MIN + 1, INT32_MAX);
1161  else
1162  infer(delta_pic_order_cnt[1], 0);
1163  } else {
1164  infer(delta_pic_order_cnt[0], 0);
1165  infer(delta_pic_order_cnt[1], 0);
1166  }
1167  }
1168 
1170  ue(redundant_pic_cnt, 0, 127);
1171 
1172  if (slice_type_b)
1173  flag(direct_spatial_mv_pred_flag);
1174 
1175  if (slice_type_p || slice_type_sp || slice_type_b) {
1176  flag(num_ref_idx_active_override_flag);
1177  if (current->num_ref_idx_active_override_flag) {
1178  ue(num_ref_idx_l0_active_minus1, 0, 31);
1179  if (slice_type_b)
1180  ue(num_ref_idx_l1_active_minus1, 0, 31);
1181  } else {
1182  infer(num_ref_idx_l0_active_minus1,
1184  infer(num_ref_idx_l1_active_minus1,
1186  }
1187  }
1188 
1189  if (current->nal_unit_header.nal_unit_type == 20 ||
1190  current->nal_unit_header.nal_unit_type == 21) {
1191  av_log(ctx->log_ctx, AV_LOG_ERROR, "MVC / 3DAVC not supported.\n");
1192  return AVERROR_PATCHWELCOME;
1193  } else {
1194  CHECK(FUNC(ref_pic_list_modification)(ctx, rw, current));
1195  }
1196 
1197  if ((pps->weighted_pred_flag && (slice_type_p || slice_type_sp)) ||
1198  (pps->weighted_bipred_idc == 1 && slice_type_b)) {
1199  CHECK(FUNC(pred_weight_table)(ctx, rw, current));
1200  }
1201 
1202  if (current->nal_unit_header.nal_ref_idc != 0) {
1203  CHECK(FUNC(dec_ref_pic_marking)(ctx, rw, current, idr_pic_flag));
1204  }
1205 
1206  if (pps->entropy_coding_mode_flag &&
1207  !slice_type_i && !slice_type_si) {
1208  ue(cabac_init_idc, 0, 2);
1209  }
1210 
1211  se(slice_qp_delta, - 51 - 6 * sps->bit_depth_luma_minus8,
1212  + 51 + 6 * sps->bit_depth_luma_minus8);
1213  if (slice_type_sp || slice_type_si) {
1214  if (slice_type_sp)
1215  flag(sp_for_switch_flag);
1216  se(slice_qs_delta, -51, +51);
1217  }
1218 
1220  ue(disable_deblocking_filter_idc, 0, 2);
1221  if (current->disable_deblocking_filter_idc != 1) {
1222  se(slice_alpha_c0_offset_div2, -6, +6);
1223  se(slice_beta_offset_div2, -6, +6);
1224  } else {
1225  infer(slice_alpha_c0_offset_div2, 0);
1226  infer(slice_beta_offset_div2, 0);
1227  }
1228  } else {
1229  infer(disable_deblocking_filter_idc, 0);
1230  infer(slice_alpha_c0_offset_div2, 0);
1231  infer(slice_beta_offset_div2, 0);
1232  }
1233 
1234  if (pps->num_slice_groups_minus1 > 0 &&
1235  pps->slice_group_map_type >= 3 &&
1236  pps->slice_group_map_type <= 5) {
1237  unsigned int pic_size, max, bits;
1238 
1239  pic_size = (sps->pic_width_in_mbs_minus1 + 1) *
1240  (sps->pic_height_in_map_units_minus1 + 1);
1241  max = (pic_size + pps->slice_group_change_rate_minus1) /
1242  (pps->slice_group_change_rate_minus1 + 1);
1243  bits = av_log2(2 * max - 1);
1244 
1245  u(bits, slice_group_change_cycle, 0, max);
1246  }
1247 
1248  if (pps->entropy_coding_mode_flag) {
1249  av_unused int one = 1;
1250  while (byte_alignment(rw))
1251  xu(1, cabac_alignment_one_bit, one, 1, 1);
1252  }
1253 
1254  return 0;
1255 }
1256 
1258  H264RawFiller *current)
1259 {
1260  av_unused int ff_byte = 0xff;
1261  int err;
1262 
1263  HEADER("Filler Data");
1264 
1265  CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
1266  1 << H264_NAL_FILLER_DATA));
1267 
1268 #ifdef READ
1269  while (show_bits(rw, 8) == 0xff) {
1270  xu(8, ff_byte, ff_byte, 0xff, 0xff);
1271  ++current->filler_size;
1272  }
1273 #else
1274  {
1275  uint32_t i;
1276  for (i = 0; i < current->filler_size; i++)
1277  xu(8, ff_byte, ff_byte, 0xff, 0xff);
1278  }
1279 #endif
1280 
1282 
1283  return 0;
1284 }
#define allocate(name, size)
Definition: cbs_h2645.c:365
uint8_t deblocking_filter_control_present_flag
Definition: cbs_h264.h:212
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static int FUNC() dec_ref_pic_marking(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current, int idr_pic_flag)
#define se(name, range_min, range_max)
Definition: cbs_h2645.c:349
#define flag(name)
Definition: cbs_h2645.c:346
static av_always_inline void chroma(WaveformContext *s, AVFrame *in, AVFrame *out, int component, int intensity, int offset_y, int offset_x, int column, int mirror)
Definition: vf_waveform.c:1386
uint8_t dpb_output_delay_length_minus1
Definition: cbs_h264.h:64
uint8_t initial_cpb_removal_delay_length_minus1
Definition: cbs_h264.h:62
H264RawPPS * pps[H264_MAX_PPS_COUNT]
Definition: cbs_h264.h:425
uint8_t log2_max_frame_num_minus4
Definition: cbs_h264.h:138
static int FUNC() sps_extension(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPSExtension *current)
uint8_t time_offset_length
Definition: cbs_h264.h:65
H264RawVUI vui
Definition: cbs_h264.h:164
static int FUNC() sei_display_orientation(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIDisplayOrientation *current)
static int FUNC() scaling_list(CodedBitstreamContext *ctx, RWContext *rw, H264RawScalingList *current, int size_of_scaling_list)
uint8_t weighted_pred_flag
Definition: cbs_h264.h:205
H264RawHRD nal_hrd_parameters
Definition: cbs_h264.h:95
static int FUNC() sei_payload(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPayload *current)
uint8_t
uint16_t pic_width_in_mbs_minus1
Definition: cbs_h264.h:150
#define MAX_UINT_BITS(length)
Definition: cbs_internal.h:84
unregistered user data
Definition: h264_sei.h:32
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:344
display orientation
Definition: h264_sei.h:35
static int FUNC() pred_weight_table(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current)
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:200
H264RawSPS * sps[H264_MAX_SPS_COUNT]
Definition: cbs_h264.h:424
static int FUNC() slice_header(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current)
#define infer(name, value)
Definition: cbs_h2645.c:352
#define av_log(a,...)
uint8_t nal_hrd_parameters_present_flag
Definition: cbs_h264.h:94
uint8_t bit_depth_luma_minus8
Definition: cbs_h264.h:129
uint8_t slice_group_map_type
Definition: cbs_h264.h:191
buffering period (H.264, D.1.1)
Definition: h264_sei.h:28
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define FUNC(a)
uint8_t max_num_ref_frames
Definition: cbs_h264.h:147
uint8_t weighted_bipred_idc
Definition: cbs_h264.h:206
#define ue(name, range_min, range_max)
Definition: cbs_h2645.c:347
static int FUNC() rbsp_trailing_bits(CodedBitstreamContext *ctx, RWContext *rw)
#define zero
Definition: regdef.h:64
uint8_t num_ref_idx_l1_default_active_minus1
Definition: cbs_h264.h:203
uint8_t frame_mbs_only_flag
Definition: cbs_h264.h:153
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:85
uint8_t seq_parameter_set_id
Definition: cbs_h264.h:185
static int FUNC() sei_recovery_point(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIRecoveryPoint *current)
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
picture timing
Definition: h264_sei.h:29
static int FUNC() ref_pic_list_modification(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current)
uint8_t separate_colour_plane_flag
Definition: cbs_h264.h:128
uint8_t last_slice_nal_unit_type
Definition: cbs_h264.h:436
AVFormatContext * ctx
Definition: movenc.c:48
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:304
static int FUNC() sei_pic_timestamp(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPicTimestamp *current)
#define more_rbsp_data(var)
Definition: cbs_h2645.c:361
uint8_t chroma_format_idc
Definition: cbs_h264.h:127
static int FUNC() hrd_parameters(CodedBitstreamContext *ctx, RWContext *rw, H264RawHRD *current)
#define av_log2
Definition: intmath.h:83
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
static int FUNC() vui_parameters(CodedBitstreamContext *ctx, RWContext *rw, H264RawVUI *current, H264RawSPS *sps)
uint8_t cpb_cnt_minus1
Definition: cbs_h264.h:54
static int FUNC() nal_unit_header(CodedBitstreamContext *ctx, RWContext *rw, H264RawNALUnitHeader *current, uint32_t valid_type_mask)
uint8_t num_slice_groups_minus1
Definition: cbs_h264.h:190
uint8_t bottom_field_pic_order_in_frame_present_flag
Definition: cbs_h264.h:188
uint8_t entropy_coding_mode_flag
Definition: cbs_h264.h:187
#define byte_alignment(rw)
Definition: cbs_h2645.c:363
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
uint8_t pic_order_cnt_type
Definition: cbs_h264.h:139
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Context structure for coded bitstream operations.
Definition: cbs.h:156
uint8_t num_ref_idx_l0_default_active_minus1
Definition: cbs_h264.h:202
CHECK(-1) CHECK(-2) }} }} CHECK(1) CHECK(2) }} }} } if(diff0+diff1 > 0) temp -
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
recovery point (frame # to decoder sync)
Definition: h264_sei.h:33
static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
Definition: cbs_h2645.c:279
registered user data as specified by Rec. ITU-T T.35
Definition: h264_sei.h:31
static int FUNC() filler(CodedBitstreamContext *ctx, RWContext *rw, H264RawFiller *current)
static int FUNC() sei_user_data_registered(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIUserDataRegistered *current, uint32_t *payload_size)
uint8_t redundant_pic_cnt_present_flag
Definition: cbs_h264.h:217
uint8_t pic_struct_present_flag
Definition: cbs_h264.h:100
uint8_t cpb_removal_delay_length_minus1
Definition: cbs_h264.h:63
static int FUNC() sei_user_data_unregistered(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIUserDataUnregistered *current, uint32_t *payload_size)
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC() sei_buffering_period(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIBufferingPeriod *current)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:773
#define xse(name, var, range_min, range_max)
Definition: cbs_h2645.c:338
static int FUNC() sei_pic_timing(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPicTiming *current)
#define HEADER(name)
Definition: cbs_h2645.c:228
#define xue(name, var, range_min, range_max)
Definition: cbs_h2645.c:333
uint8_t log2_max_pic_order_cnt_lsb_minus4
Definition: cbs_h264.h:140
void * priv_data
Format private data.
Definition: avformat.h:1370
uint8_t delta_pic_order_always_zero_flag
Definition: cbs_h264.h:141
const H264RawPPS * active_pps
Definition: cbs_h264.h:431
#define RWContext
Definition: cbs_h2645.c:326
const char int length
Definition: avisynth_c.h:768
uint16_t pic_height_in_map_units_minus1
Definition: cbs_h264.h:151
#define xu(width, name, var, range_min, range_max)
Definition: cbs_h2645.c:328
#define av_unused
Definition: attributes.h:125
uint8_t vcl_hrd_parameters_present_flag
Definition: cbs_h264.h:96
H264RawHRD vcl_hrd_parameters
Definition: cbs_h264.h:97
const H264RawSPS * active_sps
Definition: cbs_h264.h:430
uint16_t slice_group_change_rate_minus1
Definition: cbs_h264.h:196
static uint8_t tmp[11]
Definition: aes_ctr.c:26