38 #define MIN_LOG2_MAX_FRAME_NUM 4 40 #define EXTENDED_SAR 255 43 { 6, 13, 20, 28, 13, 20, 28, 32,
44 20, 28, 32, 37, 28, 32, 37, 42 },
45 { 10, 14, 20, 24, 14, 20, 24, 27,
46 20, 24, 27, 30, 24, 27, 30, 34 }
50 { 6, 10, 13, 16, 18, 23, 25, 27,
51 10, 11, 16, 18, 23, 25, 27, 29,
52 13, 16, 18, 23, 25, 27, 29, 31,
53 16, 18, 23, 25, 27, 29, 31, 33,
54 18, 23, 25, 27, 29, 31, 33, 36,
55 23, 25, 27, 29, 31, 33, 36, 38,
56 25, 27, 29, 31, 33, 36, 38, 40,
57 27, 29, 31, 33, 36, 38, 40, 42 },
58 { 9, 13, 15, 17, 19, 21, 22, 24,
59 13, 13, 17, 19, 21, 22, 24, 25,
60 15, 17, 19, 21, 22, 24, 25, 27,
61 17, 19, 21, 22, 24, 25, 27, 28,
62 19, 21, 22, 24, 25, 27, 28, 30,
63 21, 22, 24, 25, 27, 28, 30, 32,
64 22, 24, 25, 27, 28, 30, 32, 33,
65 24, 25, 27, 28, 30, 32, 33, 35 }
113 if (cpb_count > 32
U) {
120 for (i = 0; i < cpb_count; i++) {
136 int aspect_ratio_info_present_flag;
137 unsigned int aspect_ratio_idc;
139 aspect_ratio_info_present_flag =
get_bits1(gb);
141 if (aspect_ratio_info_present_flag) {
198 if (!num_units_in_tick || !time_scale) {
200 "time_scale/num_units_in_tick invalid or unsupported (%u/%u)\n",
201 time_scale, num_units_in_tick);
242 "Clipping illegal num_reorder_frames %d\n",
256 int i, last = 8, next = 8;
259 memcpy(factors, fallback_list, size *
sizeof(
uint8_t));
261 for (i = 0; i <
size; i++) {
264 if (v < -128 || v > 127) {
268 next = (last + v) & 0xff;
271 memcpy(factors, jvt_list, size *
sizeof(
uint8_t));
274 last = factors[scan[
i]] = next ? next : last;
281 const PPS *
pps,
int is_sps,
339 int i, log2_max_frame_num_minus4;
356 constraint_set_flags |=
get_bits1(gb) << 0;
357 constraint_set_flags |=
get_bits1(gb) << 1;
358 constraint_set_flags |=
get_bits1(gb) << 2;
359 constraint_set_flags |=
get_bits1(gb) << 3;
360 constraint_set_flags |=
get_bits1(gb) << 4;
361 constraint_set_flags |=
get_bits1(gb) << 5;
410 "Different chroma and luma bit depth");
435 "log2_max_frame_num_minus4 out of range (0-12): %d\n",
436 log2_max_frame_num_minus4);
459 "offset_for_non_ref_pic or offset_for_top_to_bottom_field is out of range\n");
476 "offset_for_ref_frame is out of range\n");
510 if ((
unsigned)sps->
mb_width >= INT_MAX / 16 ||
511 (
unsigned)sps->
mb_height >= INT_MAX / 16 ||
520 #ifndef ALLOW_INTERLACE 523 "MBAFF support not included; enable it at compile-time.\n");
536 "values are l:%d r:%d t:%d b:%d\n",
537 crop_left, crop_right, crop_top, crop_bottom);
547 int step_x = 1 <<
hsub;
550 if (crop_left > (
unsigned)INT_MAX / 4 / step_x ||
551 crop_right > (unsigned)INT_MAX / 4 / step_x ||
552 crop_top > (
unsigned)INT_MAX / 4 / step_y ||
553 crop_bottom> (unsigned)INT_MAX / 4 / step_y ||
554 (crop_left + crop_right ) * step_x >= width ||
555 (crop_top + crop_bottom) * step_y >= height
557 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);
585 if (!ignore_truncation)
607 static const char csp[4][5] = {
"Gray",
"420",
"422",
"444" };
609 "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",
650 for (i = 0; i < 6; i++) {
652 for (j = 0; j <
i; j++)
661 for (q = 0; q < max_qp + 1; q++) {
664 for (x = 0; x < 64; x++)
676 for (i = 0; i < 6; i++) {
678 for (j = 0; j <
i; j++)
687 for (q = 0; q < max_qp + 1; q++) {
690 for (x = 0; x < 16; x++)
707 for (i = 0; i < 6; i++)
708 for (x = 0; x < 16; x++)
711 for (i = 0; i < 6; i++)
712 for (x = 0; x < 64; x++)
720 const int max_qp = 51 + 6 * (depth - 8);
721 for (i = 0; i < max_qp + 1; i++)
730 if ((profile_idc == 66 || profile_idc == 77 ||
733 "Current profile doesn't provide more RBSP data in PPS, skipping\n");
776 if (pps->data_size >
sizeof(pps->data)) {
779 pps->data_size,
sizeof(pps->data));
780 pps->data_size =
sizeof(pps->data);
782 memcpy(pps->data, gb->
buffer, pps->data_size);
796 pps->sps = (
const SPS*)pps->sps_ref->data;
801 "Invalid luma bit depth=%d\n",
807 "Unimplemented luma bit depth=%d",
816 if (pps->slice_group_count > 1) {
824 if (pps->ref_count[0] - 1 > 32 - 1 || pps->ref_count[1] - 1 > 32 - 1) {
833 pps->weighted_bipred_idc =
get_bits(gb, 2);
837 if (pps->chroma_qp_index_offset[0] < -12 || pps->chroma_qp_index_offset[0] > 12) {
842 pps->deblocking_filter_parameters_present =
get_bits1(gb);
843 pps->constrained_intra_pred =
get_bits1(gb);
844 pps->redundant_pic_cnt_present =
get_bits1(gb);
846 pps->transform_8x8_mode = 0;
848 sizeof(pps->scaling_matrix4));
850 sizeof(pps->scaling_matrix8));
861 if (pps->chroma_qp_index_offset[1] < -12 || pps->chroma_qp_index_offset[1] > 12) {
866 pps->chroma_qp_index_offset[1] = pps->chroma_qp_index_offset[0];
876 if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])
877 pps->chroma_qp_diff = 1;
881 "pps:%u sps:%u %s slice_groups:%d ref:%u/%u %s qp:%d/%d/%d/%d %s %s %s %s\n",
883 pps->cabac ?
"CABAC" :
"CAVLC",
884 pps->slice_group_count,
885 pps->ref_count[0], pps->ref_count[1],
886 pps->weighted_pred ?
"weighted" :
"",
887 pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1],
888 pps->deblocking_filter_parameters_present ?
"LPAR" :
"",
889 pps->constrained_intra_pred ?
"CONSTR" :
"",
890 pps->redundant_pic_cnt_present ?
"REDU" :
"",
891 pps->transform_8x8_mode ?
"8x8DCT" :
"");
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
static unsigned int show_bits1(GetBitContext *s)
int video_signal_type_present_flag
static void remove_pps(H264ParamSets *s, int id)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVBufferRef * sps_list[MAX_SPS_COUNT]
int scaling_matrix_present
uint8_t scaling_matrix4[6][16]
#define avpriv_request_sample(...)
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
int bitstream_restriction_flag
const uint8_t ff_h264_quant_rem6[QP_MAX_NUM+1]
uint32_t num_units_in_tick
const char * av_color_space_name(enum AVColorSpace space)
unsigned int crop_top
frame_cropping_rect_top_offset
int fixed_frame_rate_flag
uint8_t scaling_matrix4[6][16]
static const AVRational ff_h264_pixel_aspect[17]
const uint8_t ff_h264_dequant4_coeff_init[6][3]
unsigned int crop_left
frame_cropping_rect_left_offset
int offset_for_non_ref_pic
int gaps_in_frame_num_allowed_flag
int bit_depth_chroma
bit_depth_chroma_minus8 + 8
#define FF_DEBUG_PICT_INFO
enum AVColorPrimaries color_primaries
static void pps_free(void *opaque, uint8_t *data)
unsigned int crop_right
frame_cropping_rect_right_offset
int overread_warning_printed[2]
uint32_t(*[6] dequant4_coeff)[16]
int transform_bypass
qpprime_y_zero_transform_bypass_flag
uint32_t(*[6] dequant8_coeff)[64]
static int get_bits_count(const GetBitContext *s)
static const int level_max_dpb_mbs[][2]
#define AV_LOG_VERBOSE
Detailed information.
static int get_bits_left(GetBitContext *gb)
H.264 parameter set handling.
int mb_aff
mb_adaptive_frame_field_flag
enum AVColorTransferCharacteristic color_trc
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CODEC_FLAG2_IGNORE_CROP
Discard cropping information from SPS.
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
int poc_type
pic_order_cnt_type
const uint8_t ff_zigzag_scan[16+1]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
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])
#define MIN_LOG2_MAX_FRAME_NUM
int residual_color_transform_flag
residual_colour_transform_flag
int delta_pic_order_always_zero_flag
int offset_for_top_to_bottom_field
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
static void remove_sps(H264ParamSets *s, int id)
static void init_dequant8_coeff_table(PPS *pps, const SPS *sps)
int crop
frame_cropping_flag
uint8_t scaling_matrix8[6][64]
static int decode_vui_parameters(GetBitContext *gb, void *logctx, SPS *sps)
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...
int ref_frame_count
num_ref_frames
int initial_cpb_removal_delay_length
initial_cpb_removal_delay_length_minus1 + 1
int poc_cycle_length
num_ref_frames_in_pic_order_cnt_cycle
int colour_description_present_flag
uint8_t chroma_qp_table[2][QP_MAX_NUM+1]
pre-scaled (with chroma_qp_index_offset) version of qp_table
enum AVChromaLocation chroma_location
int direct_8x8_inference_flag
uint8_t scaling_matrix8[6][64]
static int decode_scaling_list(GetBitContext *gb, uint8_t *factors, int size, const uint8_t *jvt_list, const uint8_t *fallback_list)
#define FF_ARRAY_ELEMS(a)
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int more_rbsp_data_in_pps(const SPS *sps, void *logctx)
int timing_info_present_flag
static int get_se_golomb_long(GetBitContext *gb)
int vcl_hrd_parameters_present_flag
Libavcodec external API header.
#define MAX_DELAYED_PIC_COUNT
AVBufferRef * pps_list[MAX_PPS_COUNT]
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
main external API structure.
const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM+1]
int dpb_output_delay_length
dpb_output_delay_length_minus1 + 1
uint8_t * data
The data buffer.
int vui_parameters_present_flag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static void init_dequant4_coeff_table(PPS *pps, const SPS *sps)
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int constraint_set_flags
constraint_set[0-3]_flag
static unsigned int get_bits1(GetBitContext *s)
const uint8_t ff_h264_quant_div6[QP_MAX_NUM+1]
static void skip_bits(GetBitContext *s, int n)
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
const uint8_t ff_zigzag_direct[64]
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
static int decode_hrd_parameters(GetBitContext *gb, void *logctx, SPS *sps)
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int size
Size of data in bytes.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int transform_8x8_mode
transform_8x8_mode_flag
int pic_struct_present_flag
const uint8_t ff_h264_dequant8_coeff_init[6][6]
#define MAX_LOG2_MAX_FRAME_NUM
A reference to a data buffer.
common internal api header.
int nal_hrd_parameters_present_flag
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const uint8_t * buffer_end
static const uint8_t default_scaling4[2][16]
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
int bit_depth_luma
bit_depth_luma_minus8 + 8
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int ignore_truncation)
Decode SPS.
int mb_width
pic_width_in_mbs_minus1 + 1
int flags2
AV_CODEC_FLAG2_*.
int cpb_cnt
See H.264 E.1.2.
uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16]
int32_t offset_for_ref_frame[256]
static const uint8_t default_scaling8[2][64]
uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64]
int cpb_removal_delay_length
cpb_removal_delay_length_minus1 + 1
static void init_dequant_tables(PPS *pps, const SPS *sps)
#define MKTAG(a, b, c, d)
unsigned int crop_bottom
frame_cropping_rect_bottom_offset
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
const uint8_t ff_h264_dequant8_coeff_init_scan[16]
static void build_qp_table(PPS *pps, int t, int index, const int depth)
enum AVColorSpace colorspace