You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
hevc_ps: expose SPS and VPS headers
This commit is contained in:
@@ -357,81 +357,84 @@ static int parse_ptl(GetBitContext *gb, AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void decode_sublayer_hrd(GetBitContext *gb, unsigned int nb_cpb,
|
static void decode_sublayer_hrd(GetBitContext *gb, unsigned int nb_cpb,
|
||||||
int subpic_params_present)
|
HEVCSublayerHdrParams *par, int subpic_params_present)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_cpb; i++) {
|
for (i = 0; i < nb_cpb; i++) {
|
||||||
get_ue_golomb_long(gb); // bit_rate_value_minus1
|
par->bit_rate_value_minus1[i] = get_ue_golomb_long(gb);
|
||||||
get_ue_golomb_long(gb); // cpb_size_value_minus1
|
par->cpb_size_value_minus1[i] = get_ue_golomb_long(gb);
|
||||||
|
|
||||||
if (subpic_params_present) {
|
if (subpic_params_present) {
|
||||||
get_ue_golomb_long(gb); // cpb_size_du_value_minus1
|
par->cpb_size_du_value_minus1[i] = get_ue_golomb_long(gb);
|
||||||
get_ue_golomb_long(gb); // bit_rate_du_value_minus1
|
par->bit_rate_du_value_minus1[i] = get_ue_golomb_long(gb);
|
||||||
}
|
}
|
||||||
skip_bits1(gb); // cbr_flag
|
|
||||||
|
par->cbr_flag = get_bits1(gb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_hrd(GetBitContext *gb, int common_inf_present,
|
static int decode_hrd(GetBitContext *gb, int common_inf_present,
|
||||||
int max_sublayers)
|
HEVCHdrParams *hdr, int max_sublayers)
|
||||||
{
|
{
|
||||||
int nal_params_present = 0, vcl_params_present = 0;
|
|
||||||
int subpic_params_present = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (common_inf_present) {
|
if (common_inf_present) {
|
||||||
nal_params_present = get_bits1(gb);
|
hdr->flags.nal_hrd_parameters_present_flag = get_bits1(gb);
|
||||||
vcl_params_present = get_bits1(gb);
|
hdr->flags.vcl_hrd_parameters_present_flag = get_bits1(gb);
|
||||||
|
|
||||||
if (nal_params_present || vcl_params_present) {
|
if (hdr->flags.nal_hrd_parameters_present_flag ||
|
||||||
subpic_params_present = get_bits1(gb);
|
hdr->flags.vcl_hrd_parameters_present_flag) {
|
||||||
|
hdr->flags.sub_pic_hrd_params_present_flag = get_bits1(gb);
|
||||||
|
|
||||||
if (subpic_params_present) {
|
if (hdr->flags.sub_pic_hrd_params_present_flag) {
|
||||||
skip_bits(gb, 8); // tick_divisor_minus2
|
hdr->tick_divisor_minus2 = get_bits(gb, 8);
|
||||||
skip_bits(gb, 5); // du_cpb_removal_delay_increment_length_minus1
|
hdr->du_cpb_removal_delay_increment_length_minus1 = get_bits(gb, 5);
|
||||||
skip_bits(gb, 1); // sub_pic_cpb_params_in_pic_timing_sei_flag
|
hdr->flags.sub_pic_cpb_params_in_pic_timing_sei_flag = get_bits1(gb);
|
||||||
skip_bits(gb, 5); // dpb_output_delay_du_length_minus1
|
hdr->dpb_output_delay_du_length_minus1 = get_bits(gb, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_bits(gb, 4); // bit_rate_scale
|
hdr->bit_rate_scale = get_bits(gb, 4);
|
||||||
skip_bits(gb, 4); // cpb_size_scale
|
hdr->cpb_size_scale = get_bits(gb, 4);
|
||||||
|
|
||||||
if (subpic_params_present)
|
if (hdr->flags.sub_pic_hrd_params_present_flag)
|
||||||
skip_bits(gb, 4); // cpb_size_du_scale
|
hdr->cpb_size_du_scale = get_bits(gb, 4);
|
||||||
|
|
||||||
skip_bits(gb, 5); // initial_cpb_removal_delay_length_minus1
|
hdr->initial_cpb_removal_delay_length_minus1 = get_bits(gb, 5);
|
||||||
skip_bits(gb, 5); // au_cpb_removal_delay_length_minus1
|
hdr->au_cpb_removal_delay_length_minus1 = get_bits(gb, 5);
|
||||||
skip_bits(gb, 5); // dpb_output_delay_length_minus1
|
hdr->dpb_output_delay_length_minus1 = get_bits(gb, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < max_sublayers; i++) {
|
for (int i = 0; i < max_sublayers; i++) {
|
||||||
int low_delay = 0;
|
hdr->flags.fixed_pic_rate_general_flag = get_bits1(gb);
|
||||||
unsigned int nb_cpb = 1;
|
|
||||||
int fixed_rate = get_bits1(gb);
|
|
||||||
|
|
||||||
if (!fixed_rate)
|
hdr->cpb_cnt_minus1[i] = 1;
|
||||||
fixed_rate = get_bits1(gb);
|
|
||||||
|
|
||||||
if (fixed_rate)
|
if (!hdr->flags.fixed_pic_rate_general_flag)
|
||||||
get_ue_golomb_long(gb); // elemental_duration_in_tc_minus1
|
hdr->flags.fixed_pic_rate_within_cvs_flag = get_bits1(gb);
|
||||||
|
|
||||||
|
if (hdr->flags.fixed_pic_rate_within_cvs_flag)
|
||||||
|
hdr->elemental_duration_in_tc_minus1[i] = get_ue_golomb_long(gb);
|
||||||
else
|
else
|
||||||
low_delay = get_bits1(gb);
|
hdr->flags.low_delay_hrd_flag = get_bits1(gb);
|
||||||
|
|
||||||
if (!low_delay) {
|
if (!hdr->flags.low_delay_hrd_flag) {
|
||||||
nb_cpb = get_ue_golomb_long(gb) + 1;
|
hdr->cpb_cnt_minus1[i] = get_ue_golomb_long(gb);
|
||||||
if (nb_cpb < 1 || nb_cpb > 32) {
|
if (hdr->cpb_cnt_minus1[i] > 31) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "nb_cpb %d invalid\n", nb_cpb);
|
av_log(NULL, AV_LOG_ERROR, "nb_cpb %d invalid\n",
|
||||||
|
hdr->cpb_cnt_minus1[i]);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nal_params_present)
|
if (hdr->flags.nal_hrd_parameters_present_flag)
|
||||||
decode_sublayer_hrd(gb, nb_cpb, subpic_params_present);
|
decode_sublayer_hrd(gb, hdr->cpb_cnt_minus1[i], &hdr->nal_params[i],
|
||||||
if (vcl_params_present)
|
hdr->flags.sub_pic_hrd_params_present_flag);
|
||||||
decode_sublayer_hrd(gb, nb_cpb, subpic_params_present);
|
|
||||||
|
if (hdr->flags.vcl_hrd_parameters_present_flag)
|
||||||
|
decode_sublayer_hrd(gb, hdr->cpb_cnt_minus1[i], &hdr->vcl_params[i],
|
||||||
|
hdr->flags.sub_pic_hrd_params_present_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,7 +541,8 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
|
|||||||
get_ue_golomb_long(gb); // hrd_layer_set_idx
|
get_ue_golomb_long(gb); // hrd_layer_set_idx
|
||||||
if (i)
|
if (i)
|
||||||
common_inf_present = get_bits1(gb);
|
common_inf_present = get_bits1(gb);
|
||||||
decode_hrd(gb, common_inf_present, vps->vps_max_sub_layers);
|
decode_hrd(gb, common_inf_present, &vps->hdr[i],
|
||||||
|
vps->vps_max_sub_layers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get_bits1(gb); /* vps_extension_flag */
|
get_bits1(gb); /* vps_extension_flag */
|
||||||
@@ -657,7 +661,7 @@ timing_info:
|
|||||||
vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
|
vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
|
||||||
vui->vui_hrd_parameters_present_flag = get_bits1(gb);
|
vui->vui_hrd_parameters_present_flag = get_bits1(gb);
|
||||||
if (vui->vui_hrd_parameters_present_flag)
|
if (vui->vui_hrd_parameters_present_flag)
|
||||||
decode_hrd(gb, 1, sps->max_sub_layers);
|
decode_hrd(gb, 1, &sps->hdr, sps->max_sub_layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
vui->bitstream_restriction_flag = get_bits1(gb);
|
vui->bitstream_restriction_flag = get_bits1(gb);
|
||||||
|
@@ -32,6 +32,43 @@
|
|||||||
#include "h2645_vui.h"
|
#include "h2645_vui.h"
|
||||||
#include "hevc.h"
|
#include "hevc.h"
|
||||||
|
|
||||||
|
typedef struct HEVCSublayerHdrParams {
|
||||||
|
uint32_t bit_rate_value_minus1[HEVC_MAX_CPB_CNT];
|
||||||
|
uint32_t cpb_size_value_minus1[HEVC_MAX_CPB_CNT];
|
||||||
|
uint32_t cpb_size_du_value_minus1[HEVC_MAX_CPB_CNT];
|
||||||
|
uint32_t bit_rate_du_value_minus1[HEVC_MAX_CPB_CNT];
|
||||||
|
uint32_t cbr_flag;
|
||||||
|
} HEVCSublayerHdrParams;
|
||||||
|
|
||||||
|
typedef struct HEVCHdrFlagParams {
|
||||||
|
uint32_t nal_hrd_parameters_present_flag;
|
||||||
|
uint32_t vcl_hrd_parameters_present_flag;
|
||||||
|
uint32_t sub_pic_hrd_params_present_flag;
|
||||||
|
uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag;
|
||||||
|
uint32_t fixed_pic_rate_general_flag;
|
||||||
|
uint32_t fixed_pic_rate_within_cvs_flag;
|
||||||
|
uint32_t low_delay_hrd_flag;
|
||||||
|
} HEVCHdrFlagParams;
|
||||||
|
|
||||||
|
typedef struct HEVCHdrParams {
|
||||||
|
HEVCHdrFlagParams flags;
|
||||||
|
|
||||||
|
uint8_t tick_divisor_minus2;
|
||||||
|
uint8_t du_cpb_removal_delay_increment_length_minus1;
|
||||||
|
uint8_t dpb_output_delay_du_length_minus1;
|
||||||
|
uint8_t bit_rate_scale;
|
||||||
|
uint8_t cpb_size_scale;
|
||||||
|
uint8_t cpb_size_du_scale;
|
||||||
|
uint8_t initial_cpb_removal_delay_length_minus1;
|
||||||
|
uint8_t au_cpb_removal_delay_length_minus1;
|
||||||
|
uint8_t dpb_output_delay_length_minus1;
|
||||||
|
uint8_t cpb_cnt_minus1[HEVC_MAX_SUB_LAYERS];
|
||||||
|
uint16_t elemental_duration_in_tc_minus1[HEVC_MAX_SUB_LAYERS];
|
||||||
|
|
||||||
|
HEVCSublayerHdrParams nal_params[HEVC_MAX_SUB_LAYERS];
|
||||||
|
HEVCSublayerHdrParams vcl_params[HEVC_MAX_SUB_LAYERS];
|
||||||
|
} HEVCHdrParams;
|
||||||
|
|
||||||
typedef struct ShortTermRPS {
|
typedef struct ShortTermRPS {
|
||||||
unsigned int num_negative_pics;
|
unsigned int num_negative_pics;
|
||||||
int num_delta_pocs;
|
int num_delta_pocs;
|
||||||
@@ -108,6 +145,8 @@ typedef struct PTL {
|
|||||||
} PTL;
|
} PTL;
|
||||||
|
|
||||||
typedef struct HEVCVPS {
|
typedef struct HEVCVPS {
|
||||||
|
HEVCHdrParams hdr[HEVC_MAX_LAYER_SETS];
|
||||||
|
|
||||||
uint8_t vps_temporal_id_nesting_flag;
|
uint8_t vps_temporal_id_nesting_flag;
|
||||||
int vps_max_layers;
|
int vps_max_layers;
|
||||||
int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
|
int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
|
||||||
@@ -146,6 +185,8 @@ typedef struct HEVCSPS {
|
|||||||
|
|
||||||
HEVCWindow pic_conf_win;
|
HEVCWindow pic_conf_win;
|
||||||
|
|
||||||
|
HEVCHdrParams hdr;
|
||||||
|
|
||||||
int bit_depth;
|
int bit_depth;
|
||||||
int bit_depth_chroma;
|
int bit_depth_chroma;
|
||||||
int pixel_shift;
|
int pixel_shift;
|
||||||
|
Reference in New Issue
Block a user