1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

h264_ps: K&R formatting cosmetics

This commit is contained in:
Diego Biurrun 2013-08-19 15:16:05 +02:00
parent 8fed466b0a
commit 330ad1f6a5

View File

@ -69,31 +69,20 @@ static const AVRational pixel_aspect[17]={
QP(39, d), QP(39, d), QP(39, d), QP(39, d) QP(39, d), QP(39, d), QP(39, d), QP(39, d)
const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM + 1] = { const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM + 1] = {
{ { CHROMA_QP_TABLE_END(8) },
CHROMA_QP_TABLE_END(8) { 0, 1, 2, 3, 4, 5,
}, CHROMA_QP_TABLE_END(9) },
{ { 0, 1, 2, 3, 4, 5,
0, 1, 2, 3, 4, 5,
CHROMA_QP_TABLE_END(9)
},
{
0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11,
CHROMA_QP_TABLE_END(10) CHROMA_QP_TABLE_END(10) },
},
}; };
static const uint8_t default_scaling4[2][16] = { static const uint8_t default_scaling4[2][16] = {
{ 6,13,20,28, { 6, 13, 20, 28, 13, 20, 28, 32,
13,20,28,32, 20, 28, 32, 37, 28, 32, 37, 42 },
20,28,32,37, { 10, 14, 20, 24, 14, 20, 24, 27,
28,32,37,42 20, 24, 27, 30, 24, 27, 30, 34 }
},{ };
10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
}};
static const uint8_t default_scaling8[2][64] = { static const uint8_t default_scaling8[2][64] = {
{ 6, 10, 13, 16, 18, 23, 25, 27, { 6, 10, 13, 16, 18, 23, 25, 27,
@ -103,19 +92,19 @@ static const uint8_t default_scaling8[2][64]={
18, 23, 25, 27, 29, 31, 33, 36, 18, 23, 25, 27, 29, 31, 33, 36,
23, 25, 27, 29, 31, 33, 36, 38, 23, 25, 27, 29, 31, 33, 36, 38,
25, 27, 29, 31, 33, 36, 38, 40, 25, 27, 29, 31, 33, 36, 38, 40,
27,29,31,33,36,38,40,42 27, 29, 31, 33, 36, 38, 40, 42 },
},{ { 9, 13, 15, 17, 19, 21, 22, 24,
9,13,15,17,19,21,22,24,
13, 13, 17, 19, 21, 22, 24, 25, 13, 13, 17, 19, 21, 22, 24, 25,
15, 17, 19, 21, 22, 24, 25, 27, 15, 17, 19, 21, 22, 24, 25, 27,
17, 19, 21, 22, 24, 25, 27, 28, 17, 19, 21, 22, 24, 25, 27, 28,
19, 21, 22, 24, 25, 27, 28, 30, 19, 21, 22, 24, 25, 27, 28, 30,
21, 22, 24, 25, 27, 28, 30, 32, 21, 22, 24, 25, 27, 28, 30, 32,
22, 24, 25, 27, 28, 30, 32, 33, 22, 24, 25, 27, 28, 30, 32, 33,
24,25,27,28,30,32,33,35 24, 25, 27, 28, 30, 32, 33, 35 }
}}; };
static inline int decode_hrd_parameters(H264Context *h, SPS *sps){ static inline int decode_hrd_parameters(H264Context *h, SPS *sps)
{
int cpb_count, i; int cpb_count, i;
cpb_count = get_ue_golomb_31(&h->gb) + 1; cpb_count = get_ue_golomb_31(&h->gb) + 1;
@ -139,7 +128,8 @@ static inline int decode_hrd_parameters(H264Context *h, SPS *sps){
return 0; return 0;
} }
static inline int decode_vui_parameters(H264Context *h, SPS *sps){ static inline int decode_vui_parameters(H264Context *h, SPS *sps)
{
int aspect_ratio_info_present_flag; int aspect_ratio_info_present_flag;
unsigned int aspect_ratio_idc; unsigned int aspect_ratio_idc;
@ -161,9 +151,8 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
sps->sar.den = 0; sps->sar.den = 0;
} }
if(get_bits1(&h->gb)){ /* overscan_info_present_flag */ if (get_bits1(&h->gb)) /* overscan_info_present_flag */
get_bits1(&h->gb); /* overscan_appropriate_flag */ get_bits1(&h->gb); /* overscan_appropriate_flag */
}
sps->video_signal_type_present_flag = get_bits1(&h->gb); sps->video_signal_type_present_flag = get_bits1(&h->gb);
if (sps->video_signal_type_present_flag) { if (sps->video_signal_type_present_flag) {
@ -184,8 +173,10 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
} }
} }
if(get_bits1(&h->gb)){ /* chroma_location_info_present_flag */ /* chroma_location_info_present_flag */
h->avctx->chroma_sample_location = get_ue_golomb(&h->gb)+1; /* chroma_sample_location_type_top_field */ if (get_bits1(&h->gb)) {
/* chroma_sample_location_type_top_field */
h->avctx->chroma_sample_location = get_ue_golomb(&h->gb) + 1;
get_ue_golomb(&h->gb); /* chroma_sample_location_type_bottom_field */ get_ue_golomb(&h->gb); /* chroma_sample_location_type_bottom_field */
} }
@ -194,7 +185,9 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
sps->num_units_in_tick = get_bits_long(&h->gb, 32); sps->num_units_in_tick = get_bits_long(&h->gb, 32);
sps->time_scale = get_bits_long(&h->gb, 32); sps->time_scale = get_bits_long(&h->gb, 32);
if (!sps->num_units_in_tick || !sps->time_scale) { if (!sps->num_units_in_tick || !sps->time_scale) {
av_log(h->avctx, AV_LOG_ERROR, "time_scale/num_units_in_tick invalid or unsupported (%d/%d)\n", sps->time_scale, sps->num_units_in_tick); av_log(h->avctx, AV_LOG_ERROR,
"time_scale/num_units_in_tick invalid or unsupported (%d/%d)\n",
sps->time_scale, sps->num_units_in_tick);
return -1; return -1;
} }
sps->fixed_frame_rate_flag = get_bits1(&h->gb); sps->fixed_frame_rate_flag = get_bits1(&h->gb);
@ -208,7 +201,8 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
if (sps->vcl_hrd_parameters_present_flag) if (sps->vcl_hrd_parameters_present_flag)
if (decode_hrd_parameters(h, sps) < 0) if (decode_hrd_parameters(h, sps) < 0)
return -1; return -1;
if(sps->nal_hrd_parameters_present_flag || sps->vcl_hrd_parameters_present_flag) if (sps->nal_hrd_parameters_present_flag ||
sps->vcl_hrd_parameters_present_flag)
get_bits1(&h->gb); /* low_delay_hrd_flag */ get_bits1(&h->gb); /* low_delay_hrd_flag */
sps->pic_struct_present_flag = get_bits1(&h->gb); sps->pic_struct_present_flag = get_bits1(&h->gb);
@ -227,13 +221,16 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
sps->bitstream_restriction_flag = 0; sps->bitstream_restriction_flag = 0;
} }
if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){ if (sps->num_reorder_frames > 16U
av_log(h->avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames); /* max_dec_frame_buffering || max_dec_frame_buffering > 16 */) {
av_log(h->avctx, AV_LOG_ERROR,
"illegal num_reorder_frames %d\n", sps->num_reorder_frames);
return -1; return -1;
} }
} }
if (get_bits_left(&h->gb) < 0) { if (get_bits_left(&h->gb) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "Overread VUI by %d bits\n", -get_bits_left(&h->gb)); av_log(h->avctx, AV_LOG_ERROR,
"Overread VUI by %d bits\n", -get_bits_left(&h->gb));
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -241,7 +238,9 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
} }
static void decode_scaling_list(H264Context *h, uint8_t *factors, int size, static void decode_scaling_list(H264Context *h, uint8_t *factors, int size,
const uint8_t *jvt_list, const uint8_t *fallback_list){ const uint8_t *jvt_list,
const uint8_t *fallback_list)
{
int i, last = 8, next = 8; int i, last = 8, next = 8;
const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct; const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct;
if (!get_bits1(&h->gb)) /* matrix not written, we use the predicted one */ if (!get_bits1(&h->gb)) /* matrix not written, we use the predicted one */
@ -258,8 +257,11 @@ static void decode_scaling_list(H264Context *h, uint8_t *factors, int size,
} }
} }
static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_sps, static void decode_scaling_matrices(H264Context *h, SPS *sps,
uint8_t (*scaling_matrix4)[16], uint8_t (*scaling_matrix8)[64]){ PPS *pps, int is_sps,
uint8_t(*scaling_matrix4)[16],
uint8_t(*scaling_matrix8)[64])
{
int fallback_sps = !is_sps && sps->scaling_matrix_present; int fallback_sps = !is_sps && sps->scaling_matrix_present;
const uint8_t *fallback[4] = { const uint8_t *fallback[4] = {
fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0], fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0],
@ -290,7 +292,8 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s
} }
} }
int ff_h264_decode_seq_parameter_set(H264Context *h){ int ff_h264_decode_seq_parameter_set(H264Context *h)
{
int profile_idc, level_idc, constraint_set_flags = 0; int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id; unsigned int sps_id;
int i, log2_max_frame_num_minus4; int i, log2_max_frame_num_minus4;
@ -329,7 +332,9 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->profile_idc == 128 || sps->profile_idc == 144) { sps->profile_idc == 128 || sps->profile_idc == 144) {
sps->chroma_format_idc = get_ue_golomb_31(&h->gb); sps->chroma_format_idc = get_ue_golomb_31(&h->gb);
if (sps->chroma_format_idc > 3) { if (sps->chroma_format_idc > 3) {
av_log(h->avctx, AV_LOG_ERROR, "chroma_format_idc (%u) out of range\n", sps->chroma_format_idc); av_log(h->avctx, AV_LOG_ERROR,
"chroma_format_idc (%u) out of range\n",
sps->chroma_format_idc);
goto fail; goto fail;
} else if (sps->chroma_format_idc == 3) { } else if (sps->chroma_format_idc == 3) {
sps->residual_color_transform_flag = get_bits1(&h->gb); sps->residual_color_transform_flag = get_bits1(&h->gb);
@ -337,7 +342,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8; sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8;
sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8; sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;
sps->transform_bypass = get_bits1(&h->gb); sps->transform_bypass = get_bits1(&h->gb);
decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8); decode_scaling_matrices(h, sps, NULL, 1,
sps->scaling_matrix4, sps->scaling_matrix8);
} else { } else {
sps->chroma_format_idc = 1; sps->chroma_format_idc = 1;
sps->bit_depth_luma = 8; sps->bit_depth_luma = 8;
@ -364,8 +370,10 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->offset_for_top_to_bottom_field = get_se_golomb(&h->gb); sps->offset_for_top_to_bottom_field = get_se_golomb(&h->gb);
sps->poc_cycle_length = get_ue_golomb(&h->gb); sps->poc_cycle_length = get_ue_golomb(&h->gb);
if((unsigned)sps->poc_cycle_length >= FF_ARRAY_ELEMS(sps->offset_for_ref_frame)){ if ((unsigned)sps->poc_cycle_length >=
av_log(h->avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", sps->poc_cycle_length); FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {
av_log(h->avctx, AV_LOG_ERROR,
"poc_cycle_length overflow %u\n", sps->poc_cycle_length);
goto fail; goto fail;
} }
@ -377,15 +385,18 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
} }
sps->ref_frame_count = get_ue_golomb_31(&h->gb); sps->ref_frame_count = get_ue_golomb_31(&h->gb);
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count >= 32U){ if (sps->ref_frame_count > MAX_PICTURE_COUNT - 2 ||
sps->ref_frame_count >= 32U) {
av_log(h->avctx, AV_LOG_ERROR, "too many reference frames\n"); av_log(h->avctx, AV_LOG_ERROR, "too many reference frames\n");
goto fail; goto fail;
} }
sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb); sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb);
sps->mb_width = get_ue_golomb(&h->gb) + 1; sps->mb_width = get_ue_golomb(&h->gb) + 1;
sps->mb_height = get_ue_golomb(&h->gb) + 1; sps->mb_height = get_ue_golomb(&h->gb) + 1;
if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 || if ((unsigned)sps->mb_width >= INT_MAX / 16 ||
av_image_check_size(16*sps->mb_width, 16*sps->mb_height, 0, h->avctx)){ (unsigned)sps->mb_height >= INT_MAX / 16 ||
av_image_check_size(16 * sps->mb_width,
16 * sps->mb_height, 0, h->avctx)) {
av_log(h->avctx, AV_LOG_ERROR, "mb_width/height overflow\n"); av_log(h->avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail; goto fail;
} }
@ -398,13 +409,15 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->direct_8x8_inference_flag = get_bits1(&h->gb); sps->direct_8x8_inference_flag = get_bits1(&h->gb);
if (!sps->frame_mbs_only_flag && !sps->direct_8x8_inference_flag) { if (!sps->frame_mbs_only_flag && !sps->direct_8x8_inference_flag) {
av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n"); av_log(h->avctx, AV_LOG_ERROR,
"This stream was generated by a broken encoder, invalid 8x8 inference\n");
goto fail; goto fail;
} }
#ifndef ALLOW_INTERLACE #ifndef ALLOW_INTERLACE
if (sps->mb_aff) if (sps->mb_aff)
av_log(h->avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n"); av_log(h->avctx, AV_LOG_ERROR,
"MBAFF support not included; enable it at compile-time.\n");
#endif #endif
sps->crop = get_bits1(&h->gb); sps->crop = get_bits1(&h->gb);
if (sps->crop) { if (sps->crop) {
@ -415,8 +428,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
if (h->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { if (h->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) {
av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original " av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original "
"values are l:%u r:%u t:%u b:%u\n", crop_left, crop_right, "values are l:%u r:%u t:%u b:%u\n",
crop_top, crop_bottom); crop_left, crop_right, crop_top, crop_bottom);
sps->crop_left = sps->crop_left =
sps->crop_right = sps->crop_right =
@ -424,14 +437,16 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->crop_bottom = 0; sps->crop_bottom = 0;
} else { } else {
int vsub = (sps->chroma_format_idc == 1) ? 1 : 0; int vsub = (sps->chroma_format_idc == 1) ? 1 : 0;
int hsub = (sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2) ? 1 : 0; int hsub = (sps->chroma_format_idc == 1 ||
sps->chroma_format_idc == 2) ? 1 : 0;
int step_x = 1 << hsub; int step_x = 1 << hsub;
int step_y = (2 - sps->frame_mbs_only_flag) << vsub; int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) && if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&
!(h->avctx->flags & CODEC_FLAG_UNALIGNED)) { !(h->avctx->flags & CODEC_FLAG_UNALIGNED)) {
crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8)); crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));
av_log(h->avctx, AV_LOG_WARNING, "Reducing left cropping to %d " av_log(h->avctx, AV_LOG_WARNING,
"Reducing left cropping to %d "
"chroma samples to preserve alignment.\n", "chroma samples to preserve alignment.\n",
crop_left); crop_left);
} }
@ -445,7 +460,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->crop_left = sps->crop_left =
sps->crop_right = sps->crop_right =
sps->crop_top = sps->crop_top =
sps->crop_bottom= 0; sps->crop_bottom =
sps->crop = 0; sps->crop = 0;
} }
@ -459,7 +474,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
if (h->avctx->debug & FF_DEBUG_PICT_INFO) { if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
static const char csp[4][5] = { "Gray", "420", "422", "444" }; static const char csp[4][5] = { "Gray", "420", "422", "444" };
av_log(h->avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n", av_log(h->avctx, AV_LOG_DEBUG,
"sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n",
sps_id, sps->profile_idc, sps->level_idc, sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type, sps->poc_type,
sps->ref_frame_count, sps->ref_frame_count,
@ -471,8 +487,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->vui_parameters_present_flag ? "VUI" : "", sps->vui_parameters_present_flag ? "VUI" : "",
csp[sps->chroma_format_idc], csp[sps->chroma_format_idc],
sps->timing_info_present_flag ? sps->num_units_in_tick : 0, sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
sps->timing_info_present_flag ? sps->time_scale : 0 sps->timing_info_present_flag ? sps->time_scale : 0);
);
} }
sps->new = 1; sps->new = 1;
@ -482,21 +497,23 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
h->current_sps_id = sps_id; h->current_sps_id = sps_id;
return 0; return 0;
fail: fail:
av_free(sps); av_free(sps);
return -1; return -1;
} }
static void static void build_qp_table(PPS *pps, int t, int index, const int depth)
build_qp_table(PPS *pps, int t, int index, const int depth)
{ {
int i; int i;
const int max_qp = 51 + 6 * (depth - 8); const int max_qp = 51 + 6 * (depth - 8);
for (i = 0; i < max_qp + 1; i++) for (i = 0; i < max_qp + 1; i++)
pps->chroma_qp_table[t][i] = ff_h264_chroma_qp[depth-8][av_clip(i + index, 0, max_qp)]; pps->chroma_qp_table[t][i] =
ff_h264_chroma_qp[depth - 8][av_clip(i + index, 0, max_qp)];
} }
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
{
unsigned int pps_id = get_ue_golomb(&h->gb); unsigned int pps_id = get_ue_golomb(&h->gb);
PPS *pps; PPS *pps;
const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
@ -506,7 +523,9 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
av_log(h->avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); av_log(h->avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
return -1; return -1;
} else if (h->sps.bit_depth_luma > 10) { } else if (h->sps.bit_depth_luma > 10) {
av_log(h->avctx, AV_LOG_ERROR, "Unimplemented luma bit depth=%d (max=10)\n", h->sps.bit_depth_luma); av_log(h->avctx, AV_LOG_ERROR,
"Unimplemented luma bit depth=%d (max=10)\n",
h->sps.bit_depth_luma);
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
@ -514,7 +533,8 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
if (pps == NULL) if (pps == NULL)
return -1; return -1;
pps->sps_id = get_ue_golomb_31(&h->gb); pps->sps_id = get_ue_golomb_31(&h->gb);
if((unsigned)pps->sps_id>=MAX_SPS_COUNT || h->sps_buffers[pps->sps_id] == NULL){ if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
h->sps_buffers[pps->sps_id] == NULL) {
av_log(h->avctx, AV_LOG_ERROR, "sps_id out of range\n"); av_log(h->avctx, AV_LOG_ERROR, "sps_id out of range\n");
goto fail; goto fail;
} }
@ -534,8 +554,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
break; break;
case 2: case 2:
#if 0 #if 0
| for( i = 0; i < num_slice_groups_minus1; i++ ) | | | | for (i = 0; i < num_slice_groups_minus1; i++) { | | |
|{ | | |
| top_left_mb[i] |1 |ue(v) | | top_left_mb[i] |1 |ue(v) |
| bottom_right_mb[i] |1 |ue(v) | | bottom_right_mb[i] |1 |ue(v) |
| } | | | | } | | |
@ -552,8 +571,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
case 6: case 6:
#if 0 #if 0
| slice_group_id_cnt_minus1 |1 |ue(v) | | slice_group_id_cnt_minus1 |1 |ue(v) |
| for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | | for (i = 0; i <= slice_group_id_cnt_minus1; i++)| | |
|) | | |
| slice_group_id[i] |1 |u(v) | | slice_group_id[i] |1 |u(v) |
#endif #endif
break; break;
@ -576,27 +594,35 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
pps->redundant_pic_cnt_present = get_bits1(&h->gb); pps->redundant_pic_cnt_present = get_bits1(&h->gb);
pps->transform_8x8_mode = 0; pps->transform_8x8_mode = 0;
h->dequant_coeff_pps= -1; //contents of sps/pps can change even if id doesn't, so reinit // contents of sps/pps can change even if id doesn't, so reinit
memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); h->dequant_coeff_pps = -1;
memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4,
sizeof(pps->scaling_matrix4));
memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8,
sizeof(pps->scaling_matrix8));
bits_left = bit_length - get_bits_count(&h->gb); bits_left = bit_length - get_bits_count(&h->gb);
if (bits_left && (bits_left > 8 || if (bits_left && (bits_left > 8 ||
show_bits(&h->gb, bits_left) != 1 << (bits_left - 1))) { show_bits(&h->gb, bits_left) != 1 << (bits_left - 1))) {
pps->transform_8x8_mode = get_bits1(&h->gb); pps->transform_8x8_mode = get_bits1(&h->gb);
decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0,
pps->chroma_qp_index_offset[1]= get_se_golomb(&h->gb); //second_chroma_qp_index_offset pps->scaling_matrix4, pps->scaling_matrix8);
// second_chroma_qp_index_offset
pps->chroma_qp_index_offset[1] = get_se_golomb(&h->gb);
} else { } else {
pps->chroma_qp_index_offset[1] = pps->chroma_qp_index_offset[0]; pps->chroma_qp_index_offset[1] = pps->chroma_qp_index_offset[0];
} }
build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], h->sps.bit_depth_luma); build_qp_table(pps, 0, pps->chroma_qp_index_offset[0],
build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], h->sps.bit_depth_luma); h->sps.bit_depth_luma);
build_qp_table(pps, 1, pps->chroma_qp_index_offset[1],
h->sps.bit_depth_luma);
if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])
pps->chroma_qp_diff = 1; pps->chroma_qp_diff = 1;
if (h->avctx->debug & FF_DEBUG_PICT_INFO) { if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", av_log(h->avctx, AV_LOG_DEBUG,
"pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n",
pps_id, pps->sps_id, pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC", pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count, pps->slice_group_count,
@ -606,13 +632,13 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
pps->deblocking_filter_parameters_present ? "LPAR" : "", pps->deblocking_filter_parameters_present ? "LPAR" : "",
pps->constrained_intra_pred ? "CONSTR" : "", pps->constrained_intra_pred ? "CONSTR" : "",
pps->redundant_pic_cnt_present ? "REDU" : "", pps->redundant_pic_cnt_present ? "REDU" : "",
pps->transform_8x8_mode ? "8x8DCT" : "" pps->transform_8x8_mode ? "8x8DCT" : "");
);
} }
av_free(h->pps_buffers[pps_id]); av_free(h->pps_buffers[pps_id]);
h->pps_buffers[pps_id] = pps; h->pps_buffers[pps_id] = pps;
return 0; return 0;
fail: fail:
av_free(pps); av_free(pps);
return -1; return -1;