summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandra Hájková <alexandra@khirnov.net>2016-04-15 12:08:12 +0200
committerAlexandra Hájková <alexandra@khirnov.net>2016-05-22 16:48:00 +0200
commit85375937376bbcebdccace0f831c145f10a72638 (patch)
tree0b1a9ef985053c3b3718fc1a85d9531184f50a35
parent9aeea7f850050464d88b9d2063b78c4bd23c1064 (diff)
hevc (lavf): convert to the new bitstream reader
-rw-r--r--libavformat/hevc.c346
1 files changed, 173 insertions, 173 deletions
diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index c835f2243e..c516896118 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavcodec/get_bits.h"
+#include "libavcodec/bitstream.h"
#include "libavcodec/golomb.h"
#include "libavcodec/hevc.h"
#include "libavutil/intreadwrite.h"
@@ -121,7 +121,7 @@ static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc,
hvcc->general_constraint_indicator_flags &= ptl->constraint_indicator_flags;
}
-static void hvcc_parse_ptl(GetBitContext *gb,
+static void hvcc_parse_ptl(BitstreamContext *bc,
HEVCDecoderConfigurationRecord *hvcc,
unsigned int max_sub_layers_minus1)
{
@@ -130,22 +130,22 @@ static void hvcc_parse_ptl(GetBitContext *gb,
uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS];
uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS];
- general_ptl.profile_space = get_bits(gb, 2);
- general_ptl.tier_flag = get_bits1(gb);
- general_ptl.profile_idc = get_bits(gb, 5);
- general_ptl.profile_compatibility_flags = get_bits_long(gb, 32);
- general_ptl.constraint_indicator_flags = get_bits64(gb, 48);
- general_ptl.level_idc = get_bits(gb, 8);
+ general_ptl.profile_space = bitstream_read(bc, 2);
+ general_ptl.tier_flag = bitstream_read_bit(bc);
+ general_ptl.profile_idc = bitstream_read(bc, 5);
+ general_ptl.profile_compatibility_flags = bitstream_read(bc, 32);
+ general_ptl.constraint_indicator_flags = bitstream_read_63(bc, 48);
+ general_ptl.level_idc = bitstream_read(bc, 8);
hvcc_update_ptl(hvcc, &general_ptl);
for (i = 0; i < max_sub_layers_minus1; i++) {
- sub_layer_profile_present_flag[i] = get_bits1(gb);
- sub_layer_level_present_flag[i] = get_bits1(gb);
+ sub_layer_profile_present_flag[i] = bitstream_read_bit(bc);
+ sub_layer_level_present_flag[i] = bitstream_read_bit(bc);
}
if (max_sub_layers_minus1 > 0)
for (i = max_sub_layers_minus1; i < 8; i++)
- skip_bits(gb, 2); // reserved_zero_2bits[i]
+ bitstream_skip(bc, 2); // reserved_zero_2bits[i]
for (i = 0; i < max_sub_layers_minus1; i++) {
if (sub_layer_profile_present_flag[i]) {
@@ -160,36 +160,36 @@ static void hvcc_parse_ptl(GetBitContext *gb,
* sub_layer_frame_only_constraint_flag[i] u(1)
* sub_layer_reserved_zero_44bits[i] u(44)
*/
- skip_bits_long(gb, 32);
- skip_bits_long(gb, 32);
- skip_bits (gb, 24);
+ bitstream_skip(bc, 32);
+ bitstream_skip(bc, 32);
+ bitstream_skip (bc, 24);
}
if (sub_layer_level_present_flag[i])
- skip_bits(gb, 8);
+ bitstream_skip(bc, 8);
}
}
-static void skip_sub_layer_hrd_parameters(GetBitContext *gb,
+static void skip_sub_layer_hrd_parameters(BitstreamContext *bc,
unsigned int cpb_cnt_minus1,
uint8_t sub_pic_hrd_params_present_flag)
{
unsigned int i;
for (i = 0; i <= cpb_cnt_minus1; i++) {
- get_ue_golomb_long(gb); // bit_rate_value_minus1
- get_ue_golomb_long(gb); // cpb_size_value_minus1
+ get_ue_golomb_long(bc); // bit_rate_value_minus1
+ get_ue_golomb_long(bc); // cpb_size_value_minus1
if (sub_pic_hrd_params_present_flag) {
- get_ue_golomb_long(gb); // cpb_size_du_value_minus1
- get_ue_golomb_long(gb); // bit_rate_du_value_minus1
+ get_ue_golomb_long(bc); // cpb_size_du_value_minus1
+ get_ue_golomb_long(bc); // bit_rate_du_value_minus1
}
- skip_bits1(gb); // cbr_flag
+ bitstream_skip(bc, 1); // cbr_flag
}
}
-static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
+static void skip_hrd_parameters(BitstreamContext *bc, uint8_t cprms_present_flag,
unsigned int max_sub_layers_minus1)
{
unsigned int i;
@@ -198,12 +198,12 @@ static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
uint8_t vcl_hrd_parameters_present_flag = 0;
if (cprms_present_flag) {
- nal_hrd_parameters_present_flag = get_bits1(gb);
- vcl_hrd_parameters_present_flag = get_bits1(gb);
+ nal_hrd_parameters_present_flag = bitstream_read_bit(bc);
+ vcl_hrd_parameters_present_flag = bitstream_read_bit(bc);
if (nal_hrd_parameters_present_flag ||
vcl_hrd_parameters_present_flag) {
- sub_pic_hrd_params_present_flag = get_bits1(gb);
+ sub_pic_hrd_params_present_flag = bitstream_read_bit(bc);
if (sub_pic_hrd_params_present_flag)
/*
@@ -212,23 +212,23 @@ static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
* sub_pic_cpb_params_in_pic_timing_sei_flag u(1)
* dpb_output_delay_du_length_minus1 u(5)
*/
- skip_bits(gb, 19);
+ bitstream_skip(bc, 19);
/*
* bit_rate_scale u(4)
* cpb_size_scale u(4)
*/
- skip_bits(gb, 8);
+ bitstream_skip(bc, 8);
if (sub_pic_hrd_params_present_flag)
- skip_bits(gb, 4); // cpb_size_du_scale
+ bitstream_skip(bc, 4); // cpb_size_du_scale
/*
* initial_cpb_removal_delay_length_minus1 u(5)
* au_cpb_removal_delay_length_minus1 u(5)
* dpb_output_delay_length_minus1 u(5)
*/
- skip_bits(gb, 15);
+ bitstream_skip(bc, 15);
}
}
@@ -236,66 +236,66 @@ static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
unsigned int cpb_cnt_minus1 = 0;
uint8_t low_delay_hrd_flag = 0;
uint8_t fixed_pic_rate_within_cvs_flag = 0;
- uint8_t fixed_pic_rate_general_flag = get_bits1(gb);
+ uint8_t fixed_pic_rate_general_flag = bitstream_read_bit(bc);
if (!fixed_pic_rate_general_flag)
- fixed_pic_rate_within_cvs_flag = get_bits1(gb);
+ fixed_pic_rate_within_cvs_flag = bitstream_read_bit(bc);
if (fixed_pic_rate_within_cvs_flag)
- get_ue_golomb_long(gb); // elemental_duration_in_tc_minus1
+ get_ue_golomb_long(bc); // elemental_duration_in_tc_minus1
else
- low_delay_hrd_flag = get_bits1(gb);
+ low_delay_hrd_flag = bitstream_read_bit(bc);
if (!low_delay_hrd_flag)
- cpb_cnt_minus1 = get_ue_golomb_long(gb);
+ cpb_cnt_minus1 = get_ue_golomb_long(bc);
if (nal_hrd_parameters_present_flag)
- skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
+ skip_sub_layer_hrd_parameters(bc, cpb_cnt_minus1,
sub_pic_hrd_params_present_flag);
if (vcl_hrd_parameters_present_flag)
- skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
+ skip_sub_layer_hrd_parameters(bc, cpb_cnt_minus1,
sub_pic_hrd_params_present_flag);
}
}
-static void skip_timing_info(GetBitContext *gb)
+static void skip_timing_info(BitstreamContext *bc)
{
- skip_bits_long(gb, 32); // num_units_in_tick
- skip_bits_long(gb, 32); // time_scale
+ bitstream_skip(bc, 32); // num_units_in_tick
+ bitstream_skip(bc, 32); // time_scale
- if (get_bits1(gb)) // poc_proportional_to_timing_flag
- get_ue_golomb_long(gb); // num_ticks_poc_diff_one_minus1
+ if (bitstream_read_bit(bc)) // poc_proportional_to_timing_flag
+ get_ue_golomb_long(bc); // num_ticks_poc_diff_one_minus1
}
-static void hvcc_parse_vui(GetBitContext *gb,
+static void hvcc_parse_vui(BitstreamContext *bc,
HEVCDecoderConfigurationRecord *hvcc,
unsigned int max_sub_layers_minus1)
{
unsigned int min_spatial_segmentation_idc;
- if (get_bits1(gb)) // aspect_ratio_info_present_flag
- if (get_bits(gb, 8) == 255) // aspect_ratio_idc
- skip_bits_long(gb, 32); // sar_width u(16), sar_height u(16)
+ if (bitstream_read_bit(bc)) // aspect_ratio_info_present_flag
+ if (bitstream_read(bc, 8) == 255) // aspect_ratio_idc
+ bitstream_skip(bc, 32); // sar_width u(16), sar_height u(16)
- if (get_bits1(gb)) // overscan_info_present_flag
- skip_bits1(gb); // overscan_appropriate_flag
+ if (bitstream_read_bit(bc)) // overscan_info_present_flag
+ bitstream_skip(bc, 1); // overscan_appropriate_flag
- if (get_bits1(gb)) { // video_signal_type_present_flag
- skip_bits(gb, 4); // video_format u(3), video_full_range_flag u(1)
+ if (bitstream_read_bit(bc)) { // video_signal_type_present_flag
+ bitstream_skip(bc, 4); // video_format u(3), video_full_range_flag u(1)
- if (get_bits1(gb)) // colour_description_present_flag
+ if (bitstream_read_bit(bc)) // colour_description_present_flag
/*
* colour_primaries u(8)
* transfer_characteristics u(8)
* matrix_coeffs u(8)
*/
- skip_bits(gb, 24);
+ bitstream_skip(bc, 24);
}
- if (get_bits1(gb)) { // chroma_loc_info_present_flag
- get_ue_golomb_long(gb); // chroma_sample_loc_type_top_field
- get_ue_golomb_long(gb); // chroma_sample_loc_type_bottom_field
+ if (bitstream_read_bit(bc)) { // chroma_loc_info_present_flag
+ get_ue_golomb_long(bc); // chroma_sample_loc_type_top_field
+ get_ue_golomb_long(bc); // chroma_sample_loc_type_bottom_field
}
/*
@@ -303,31 +303,31 @@ static void hvcc_parse_vui(GetBitContext *gb,
* field_seq_flag u(1)
* frame_field_info_present_flag u(1)
*/
- skip_bits(gb, 3);
+ bitstream_skip(bc, 3);
- if (get_bits1(gb)) { // default_display_window_flag
- get_ue_golomb_long(gb); // def_disp_win_left_offset
- get_ue_golomb_long(gb); // def_disp_win_right_offset
- get_ue_golomb_long(gb); // def_disp_win_top_offset
- get_ue_golomb_long(gb); // def_disp_win_bottom_offset
+ if (bitstream_read_bit(bc)) { // default_display_window_flag
+ get_ue_golomb_long(bc); // def_disp_win_left_offset
+ get_ue_golomb_long(bc); // def_disp_win_right_offset
+ get_ue_golomb_long(bc); // def_disp_win_top_offset
+ get_ue_golomb_long(bc); // def_disp_win_bottom_offset
}
- if (get_bits1(gb)) { // vui_timing_info_present_flag
- skip_timing_info(gb);
+ if (bitstream_read_bit(bc)) { // vui_timing_info_present_flag
+ skip_timing_info(bc);
- if (get_bits1(gb)) // vui_hrd_parameters_present_flag
- skip_hrd_parameters(gb, 1, max_sub_layers_minus1);
+ if (bitstream_read_bit(bc)) // vui_hrd_parameters_present_flag
+ skip_hrd_parameters(bc, 1, max_sub_layers_minus1);
}
- if (get_bits1(gb)) { // bitstream_restriction_flag
+ if (bitstream_read_bit(bc)) { // bitstream_restriction_flag
/*
* tiles_fixed_structure_flag u(1)
* motion_vectors_over_pic_boundaries_flag u(1)
* restricted_ref_pic_lists_flag u(1)
*/
- skip_bits(gb, 3);
+ bitstream_skip(bc, 3);
- min_spatial_segmentation_idc = get_ue_golomb_long(gb);
+ min_spatial_segmentation_idc = get_ue_golomb_long(bc);
/*
* unsigned int(12) min_spatial_segmentation_idc;
@@ -339,21 +339,21 @@ static void hvcc_parse_vui(GetBitContext *gb,
hvcc->min_spatial_segmentation_idc = FFMIN(hvcc->min_spatial_segmentation_idc,
min_spatial_segmentation_idc);
- get_ue_golomb_long(gb); // max_bytes_per_pic_denom
- get_ue_golomb_long(gb); // max_bits_per_min_cu_denom
- get_ue_golomb_long(gb); // log2_max_mv_length_horizontal
- get_ue_golomb_long(gb); // log2_max_mv_length_vertical
+ get_ue_golomb_long(bc); // max_bytes_per_pic_denom
+ get_ue_golomb_long(bc); // max_bits_per_min_cu_denom
+ get_ue_golomb_long(bc); // log2_max_mv_length_horizontal
+ get_ue_golomb_long(bc); // log2_max_mv_length_vertical
}
}
-static void skip_sub_layer_ordering_info(GetBitContext *gb)
+static void skip_sub_layer_ordering_info(BitstreamContext *bc)
{
- get_ue_golomb_long(gb); // max_dec_pic_buffering_minus1
- get_ue_golomb_long(gb); // max_num_reorder_pics
- get_ue_golomb_long(gb); // max_latency_increase_plus1
+ get_ue_golomb_long(bc); // max_dec_pic_buffering_minus1
+ get_ue_golomb_long(bc); // max_num_reorder_pics
+ get_ue_golomb_long(bc); // max_latency_increase_plus1
}
-static int hvcc_parse_vps(GetBitContext *gb,
+static int hvcc_parse_vps(BitstreamContext *bc,
HEVCDecoderConfigurationRecord *hvcc)
{
unsigned int vps_max_sub_layers_minus1;
@@ -363,9 +363,9 @@ static int hvcc_parse_vps(GetBitContext *gb,
* vps_reserved_three_2bits u(2)
* vps_max_layers_minus1 u(6)
*/
- skip_bits(gb, 12);
+ bitstream_skip(bc, 12);
- vps_max_sub_layers_minus1 = get_bits(gb, 3);
+ vps_max_sub_layers_minus1 = bitstream_read(bc, 3);
/*
* numTemporalLayers greater than 1 indicates that the stream to which this
@@ -382,46 +382,46 @@ static int hvcc_parse_vps(GetBitContext *gb,
* vps_temporal_id_nesting_flag u(1)
* vps_reserved_0xffff_16bits u(16)
*/
- skip_bits(gb, 17);
+ bitstream_skip(bc, 17);
- hvcc_parse_ptl(gb, hvcc, vps_max_sub_layers_minus1);
+ hvcc_parse_ptl(bc, hvcc, vps_max_sub_layers_minus1);
/* nothing useful for hvcC past this point */
return 0;
}
-static void skip_scaling_list_data(GetBitContext *gb)
+static void skip_scaling_list_data(BitstreamContext *bc)
{
int i, j, k, num_coeffs;
for (i = 0; i < 4; i++)
for (j = 0; j < (i == 3 ? 2 : 6); j++)
- if (!get_bits1(gb)) // scaling_list_pred_mode_flag[i][j]
- get_ue_golomb_long(gb); // scaling_list_pred_matrix_id_delta[i][j]
+ if (!bitstream_read_bit(bc)) // scaling_list_pred_mode_flag[i][j]
+ get_ue_golomb_long(bc); // scaling_list_pred_matrix_id_delta[i][j]
else {
num_coeffs = FFMIN(64, 1 << (4 + (i << 1)));
if (i > 1)
- get_se_golomb_long(gb); // scaling_list_dc_coef_minus8[i-2][j]
+ get_se_golomb_long(bc); // scaling_list_dc_coef_minus8[i-2][j]
for (k = 0; k < num_coeffs; k++)
- get_se_golomb_long(gb); // scaling_list_delta_coef
+ get_se_golomb_long(bc); // scaling_list_delta_coef
}
}
-static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
+static int parse_rps(BitstreamContext *bc, unsigned int rps_idx,
unsigned int num_rps,
unsigned int num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT])
{
unsigned int i;
- if (rps_idx && get_bits1(gb)) { // inter_ref_pic_set_prediction_flag
+ if (rps_idx && bitstream_read_bit(bc)) { // inter_ref_pic_set_prediction_flag
/* this should only happen for slice headers, and this isn't one */
if (rps_idx >= num_rps)
return AVERROR_INVALIDDATA;
- skip_bits1 (gb); // delta_rps_sign
- get_ue_golomb_long(gb); // abs_delta_rps_minus1
+ bitstream_skip (bc, 1); // delta_rps_sign
+ get_ue_golomb_long(bc); // abs_delta_rps_minus1
num_delta_pocs[rps_idx] = 0;
@@ -446,42 +446,42 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
*/
for (i = 0; i < num_delta_pocs[rps_idx - 1]; i++) {
uint8_t use_delta_flag = 0;
- uint8_t used_by_curr_pic_flag = get_bits1(gb);
+ uint8_t used_by_curr_pic_flag = bitstream_read_bit(bc);
if (!used_by_curr_pic_flag)
- use_delta_flag = get_bits1(gb);
+ use_delta_flag = bitstream_read_bit(bc);
if (used_by_curr_pic_flag || use_delta_flag)
num_delta_pocs[rps_idx]++;
}
} else {
- unsigned int num_negative_pics = get_ue_golomb_long(gb);
- unsigned int num_positive_pics = get_ue_golomb_long(gb);
+ unsigned int num_negative_pics = get_ue_golomb_long(bc);
+ unsigned int num_positive_pics = get_ue_golomb_long(bc);
num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
for (i = 0; i < num_negative_pics; i++) {
- get_ue_golomb_long(gb); // delta_poc_s0_minus1[rps_idx]
- skip_bits1 (gb); // used_by_curr_pic_s0_flag[rps_idx]
+ get_ue_golomb_long(bc); // delta_poc_s0_minus1[rps_idx]
+ bitstream_skip (bc, 1); // used_by_curr_pic_s0_flag[rps_idx]
}
for (i = 0; i < num_positive_pics; i++) {
- get_ue_golomb_long(gb); // delta_poc_s1_minus1[rps_idx]
- skip_bits1 (gb); // used_by_curr_pic_s1_flag[rps_idx]
+ get_ue_golomb_long(bc); // delta_poc_s1_minus1[rps_idx]
+ bitstream_skip (bc, 1); // used_by_curr_pic_s1_flag[rps_idx]
}
}
return 0;
}
-static int hvcc_parse_sps(GetBitContext *gb,
+static int hvcc_parse_sps(BitstreamContext *bc,
HEVCDecoderConfigurationRecord *hvcc)
{
unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
unsigned int num_short_term_ref_pic_sets, num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT];
- skip_bits(gb, 4); // sps_video_parameter_set_id
+ bitstream_skip(bc, 4); // sps_video_parameter_set_id
- sps_max_sub_layers_minus1 = get_bits (gb, 3);
+ sps_max_sub_layers_minus1 = bitstream_read (bc, 3);
/*
* numTemporalLayers greater than 1 indicates that the stream to which this
@@ -494,93 +494,93 @@ static int hvcc_parse_sps(GetBitContext *gb,
hvcc->numTemporalLayers = FFMAX(hvcc->numTemporalLayers,
sps_max_sub_layers_minus1 + 1);
- hvcc->temporalIdNested = get_bits1(gb);
+ hvcc->temporalIdNested = bitstream_read_bit(bc);
- hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);
+ hvcc_parse_ptl(bc, hvcc, sps_max_sub_layers_minus1);
- get_ue_golomb_long(gb); // sps_seq_parameter_set_id
+ get_ue_golomb_long(bc); // sps_seq_parameter_set_id
- hvcc->chromaFormat = get_ue_golomb_long(gb);
+ hvcc->chromaFormat = get_ue_golomb_long(bc);
if (hvcc->chromaFormat == 3)
- skip_bits1(gb); // separate_colour_plane_flag
+ bitstream_skip(bc, 1); // separate_colour_plane_flag
- get_ue_golomb_long(gb); // pic_width_in_luma_samples
- get_ue_golomb_long(gb); // pic_height_in_luma_samples
+ get_ue_golomb_long(bc); // pic_width_in_luma_samples
+ get_ue_golomb_long(bc); // pic_height_in_luma_samples
- if (get_bits1(gb)) { // conformance_window_flag
- get_ue_golomb_long(gb); // conf_win_left_offset
- get_ue_golomb_long(gb); // conf_win_right_offset
- get_ue_golomb_long(gb); // conf_win_top_offset
- get_ue_golomb_long(gb); // conf_win_bottom_offset
+ if (bitstream_read_bit(bc)) { // conformance_window_flag
+ get_ue_golomb_long(bc); // conf_win_left_offset
+ get_ue_golomb_long(bc); // conf_win_right_offset
+ get_ue_golomb_long(bc); // conf_win_top_offset
+ get_ue_golomb_long(bc); // conf_win_bottom_offset
}
- hvcc->bitDepthLumaMinus8 = get_ue_golomb_long(gb);
- hvcc->bitDepthChromaMinus8 = get_ue_golomb_long(gb);
- log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb_long(gb);
+ hvcc->bitDepthLumaMinus8 = get_ue_golomb_long(bc);
+ hvcc->bitDepthChromaMinus8 = get_ue_golomb_long(bc);
+ log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb_long(bc);
/* sps_sub_layer_ordering_info_present_flag */
- i = get_bits1(gb) ? 0 : sps_max_sub_layers_minus1;
+ i = bitstream_read_bit(bc) ? 0 : sps_max_sub_layers_minus1;
for (; i <= sps_max_sub_layers_minus1; i++)
- skip_sub_layer_ordering_info(gb);
-
- get_ue_golomb_long(gb); // log2_min_luma_coding_block_size_minus3
- get_ue_golomb_long(gb); // log2_diff_max_min_luma_coding_block_size
- get_ue_golomb_long(gb); // log2_min_transform_block_size_minus2
- get_ue_golomb_long(gb); // log2_diff_max_min_transform_block_size
- get_ue_golomb_long(gb); // max_transform_hierarchy_depth_inter
- get_ue_golomb_long(gb); // max_transform_hierarchy_depth_intra
-
- if (get_bits1(gb) && // scaling_list_enabled_flag
- get_bits1(gb)) // sps_scaling_list_data_present_flag
- skip_scaling_list_data(gb);
-
- skip_bits1(gb); // amp_enabled_flag
- skip_bits1(gb); // sample_adaptive_offset_enabled_flag
-
- if (get_bits1(gb)) { // pcm_enabled_flag
- skip_bits (gb, 4); // pcm_sample_bit_depth_luma_minus1
- skip_bits (gb, 4); // pcm_sample_bit_depth_chroma_minus1
- get_ue_golomb_long(gb); // log2_min_pcm_luma_coding_block_size_minus3
- get_ue_golomb_long(gb); // log2_diff_max_min_pcm_luma_coding_block_size
- skip_bits1 (gb); // pcm_loop_filter_disabled_flag
+ skip_sub_layer_ordering_info(bc);
+
+ get_ue_golomb_long(bc); // log2_min_luma_coding_block_size_minus3
+ get_ue_golomb_long(bc); // log2_diff_max_min_luma_coding_block_size
+ get_ue_golomb_long(bc); // log2_min_transform_block_size_minus2
+ get_ue_golomb_long(bc); // log2_diff_max_min_transform_block_size
+ get_ue_golomb_long(bc); // max_transform_hierarchy_depth_inter
+ get_ue_golomb_long(bc); // max_transform_hierarchy_depth_intra
+
+ if (bitstream_read_bit(bc) && // scaling_list_enabled_flag
+ bitstream_read_bit(bc)) // sps_scaling_list_data_present_flag
+ skip_scaling_list_data(bc);
+
+ bitstream_skip(bc, 1); // amp_enabled_flag
+ bitstream_skip(bc, 1); // sample_adaptive_offset_enabled_flag
+
+ if (bitstream_read_bit(bc)) { // pcm_enabled_flag
+ bitstream_skip (bc, 4); // pcm_sample_bit_depth_luma_minus1
+ bitstream_skip (bc, 4); // pcm_sample_bit_depth_chroma_minus1
+ get_ue_golomb_long(bc); // log2_min_pcm_luma_coding_block_size_minus3
+ get_ue_golomb_long(bc); // log2_diff_max_min_pcm_luma_coding_block_size
+ bitstream_skip (bc, 1); // pcm_loop_filter_disabled_flag
}
- num_short_term_ref_pic_sets = get_ue_golomb_long(gb);
+ num_short_term_ref_pic_sets = get_ue_golomb_long(bc);
if (num_short_term_ref_pic_sets > MAX_SHORT_TERM_RPS_COUNT)
return AVERROR_INVALIDDATA;
for (i = 0; i < num_short_term_ref_pic_sets; i++) {
- int ret = parse_rps(gb, i, num_short_term_ref_pic_sets, num_delta_pocs);
+ int ret = parse_rps(bc, i, num_short_term_ref_pic_sets, num_delta_pocs);
if (ret < 0)
return ret;
}
- if (get_bits1(gb)) { // long_term_ref_pics_present_flag
- for (i = 0; i < get_ue_golomb_long(gb); i++) { // num_long_term_ref_pics_sps
+ if (bitstream_read_bit(bc)) { // long_term_ref_pics_present_flag
+ for (i = 0; i < get_ue_golomb_long(bc); i++) { // num_long_term_ref_pics_sps
int len = FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
- skip_bits (gb, len); // lt_ref_pic_poc_lsb_sps[i]
- skip_bits1(gb); // used_by_curr_pic_lt_sps_flag[i]
+ bitstream_skip (bc, len); // lt_ref_pic_poc_lsb_sps[i]
+ bitstream_skip(bc, 1); // used_by_curr_pic_lt_sps_flag[i]
}
}
- skip_bits1(gb); // sps_temporal_mvp_enabled_flag
- skip_bits1(gb); // strong_intra_smoothing_enabled_flag
+ bitstream_skip(bc, 1); // sps_temporal_mvp_enabled_flag
+ bitstream_skip(bc, 1); // strong_intra_smoothing_enabled_flag
- if (get_bits1(gb)) // vui_parameters_present_flag
- hvcc_parse_vui(gb, hvcc, sps_max_sub_layers_minus1);
+ if (bitstream_read_bit(bc)) // vui_parameters_present_flag
+ hvcc_parse_vui(bc, hvcc, sps_max_sub_layers_minus1);
/* nothing useful for hvcC past this point */
return 0;
}
-static int hvcc_parse_pps(GetBitContext *gb,
+static int hvcc_parse_pps(BitstreamContext *bc,
HEVCDecoderConfigurationRecord *hvcc)
{
uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
- get_ue_golomb_long(gb); // pps_pic_parameter_set_id
- get_ue_golomb_long(gb); // pps_seq_parameter_set_id
+ get_ue_golomb_long(bc); // pps_pic_parameter_set_id
+ get_ue_golomb_long(bc); // pps_seq_parameter_set_id
/*
* dependent_slice_segments_enabled_flag u(1)
@@ -589,33 +589,33 @@ static int hvcc_parse_pps(GetBitContext *gb,
* sign_data_hiding_enabled_flag u(1)
* cabac_init_present_flag u(1)
*/
- skip_bits(gb, 7);
+ bitstream_skip(bc, 7);
- get_ue_golomb_long(gb); // num_ref_idx_l0_default_active_minus1
- get_ue_golomb_long(gb); // num_ref_idx_l1_default_active_minus1
- get_se_golomb_long(gb); // init_qp_minus26
+ get_ue_golomb_long(bc); // num_ref_idx_l0_default_active_minus1
+ get_ue_golomb_long(bc); // num_ref_idx_l1_default_active_minus1
+ get_se_golomb_long(bc); // init_qp_minus26
/*
* constrained_intra_pred_flag u(1)
* transform_skip_enabled_flag u(1)
*/
- skip_bits(gb, 2);
+ bitstream_skip(bc, 2);
- if (get_bits1(gb)) // cu_qp_delta_enabled_flag
- get_ue_golomb_long(gb); // diff_cu_qp_delta_depth
+ if (bitstream_read_bit(bc)) // cu_qp_delta_enabled_flag
+ get_ue_golomb_long(bc); // diff_cu_qp_delta_depth
- get_se_golomb_long(gb); // pps_cb_qp_offset
- get_se_golomb_long(gb); // pps_cr_qp_offset
+ get_se_golomb_long(bc); // pps_cb_qp_offset
+ get_se_golomb_long(bc); // pps_cr_qp_offset
/*
* weighted_pred_flag u(1)
* weighted_bipred_flag u(1)
* transquant_bypass_enabled_flag u(1)
*/
- skip_bits(gb, 3);
+ bitstream_skip(bc, 3);
- tiles_enabled_flag = get_bits1(gb);
- entropy_coding_sync_enabled_flag = get_bits1(gb);
+ tiles_enabled_flag = bitstream_read_bit(bc);
+ entropy_coding_sync_enabled_flag = bitstream_read_bit(bc);
if (entropy_coding_sync_enabled_flag && tiles_enabled_flag)
hvcc->parallelismType = 0; // mixed-type parallel decoding
@@ -662,17 +662,17 @@ static uint8_t *nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len,
-static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
+static void nal_unit_parse_header(BitstreamContext *bc, uint8_t *nal_type)
{
- skip_bits1(gb); // forbidden_zero_bit
+ bitstream_skip(bc, 1); // forbidden_zero_bit
- *nal_type = get_bits(gb, 6);
+ *nal_type = bitstream_read(bc, 6);
/*
* nuh_layer_id u(6)
* nuh_temporal_id_plus1 u(3)
*/
- skip_bits(gb, 9);
+ bitstream_skip(bc, 9);
}
static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
@@ -733,7 +733,7 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
HEVCDecoderConfigurationRecord *hvcc)
{
int ret = 0;
- GetBitContext gbc;
+ BitstreamContext bcc;
uint8_t nal_type;
uint8_t *rbsp_buf;
uint32_t rbsp_size;
@@ -744,11 +744,11 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
goto end;
}
- ret = init_get_bits8(&gbc, rbsp_buf, rbsp_size);
+ ret = bitstream_init8(&bcc, rbsp_buf, rbsp_size);
if (ret < 0)
goto end;
- nal_unit_parse_header(&gbc, &nal_type);
+ nal_unit_parse_header(&bcc, &nal_type);
/*
* Note: only 'declarative' SEI messages are allowed in
@@ -766,11 +766,11 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
if (ret < 0)
goto end;
else if (nal_type == NAL_VPS)
- ret = hvcc_parse_vps(&gbc, hvcc);
+ ret = hvcc_parse_vps(&bcc, hvcc);
else if (nal_type == NAL_SPS)
- ret = hvcc_parse_sps(&gbc, hvcc);
+ ret = hvcc_parse_sps(&bcc, hvcc);
else if (nal_type == NAL_PPS)
- ret = hvcc_parse_pps(&gbc, hvcc);
+ ret = hvcc_parse_pps(&bcc, hvcc);
if (ret < 0)
goto end;
break;