Commit f9897e48 authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Commit Bot

Complete H265 SPS parsing

This adds parsing of the VUI and methods for returning size and
colorspace information based on the SPS.

BUG=chromium:1141237,b:153111783
TEST=media_unitests, media_h265_parser_fuzzer

Change-Id: I6959bf7706183f5239a91ea201effeed9a735dfb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495838Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Cr-Commit-Position: refs/heads/master@{#821474}
parent 87e5225e
This diff is collapsed.
......@@ -176,6 +176,23 @@ struct MEDIA_EXPORT H265StRefPicSet {
int num_delta_pocs;
};
struct MEDIA_EXPORT H265VUIParameters {
H265VUIParameters();
// Syntax elements.
int sar_width;
int sar_height;
bool video_full_range_flag;
bool colour_description_present_flag;
int colour_primaries;
int transfer_characteristics;
int matrix_coeffs;
int def_disp_win_left_offset;
int def_disp_win_right_offset;
int def_disp_win_top_offset;
int def_disp_win_bottom_offset;
};
struct MEDIA_EXPORT H265SPS {
H265SPS();
......@@ -222,6 +239,7 @@ struct MEDIA_EXPORT H265SPS {
bool used_by_curr_pic_lt_sps_flag[kMaxLongTermRefPicSets];
bool sps_temporal_mvp_enabled_flag;
bool strong_intra_smoothing_enabled_flag;
H265VUIParameters vui_parameters;
// Calculated fields.
int chroma_array_type;
......@@ -239,6 +257,12 @@ struct MEDIA_EXPORT H265SPS {
int max_tb_log2_size_y;
int wp_offset_half_range_y;
int wp_offset_half_range_c;
// Helpers to compute frequently-used values. They do not verify that the
// results are in-spec for the given profile or level.
gfx::Size GetCodedSize() const;
gfx::Rect GetVisibleRect() const;
VideoColorSpace GetColorSpace() const;
};
// Class to parse an Annex-B H.265 stream.
......@@ -286,6 +310,8 @@ class MEDIA_EXPORT H265Parser {
// Return a pointer to SPS with given |sps_id| or null if not present.
const H265SPS* GetSPS(int sps_id) const;
static VideoCodecProfile ProfileIDCToVideoCodecProfile(int profile_idc);
private:
// Move the stream pointer to the beginning of the next NALU,
// i.e. pointing at the next start code.
......@@ -310,6 +336,12 @@ class MEDIA_EXPORT H265Parser {
Result ParseStRefPicSet(int st_rps_idx,
const H265SPS& sps,
H265StRefPicSet* st_ref_pic_set);
Result ParseVuiParameters(const H265SPS& sps, H265VUIParameters* vui);
Result ParseAndIgnoreHrdParameters(bool common_inf_present_flag,
int max_num_sub_layers_minus1);
Result ParseAndIgnoreSubLayerHrdParameters(
int cpb_cnt,
bool sub_pic_hrd_params_present_flag);
// Pointer to the current NALU in the stream.
const uint8_t* stream_;
......
......@@ -59,7 +59,7 @@ TEST_F(H265ParserTest, RawHevcStreamFileParsing) {
{"bbb.hevc", 64},
};
for (auto& data : test_data) {
for (const auto& data : test_data) {
LoadParserFile(data.file_name);
// Parse until the end of stream/unsupported stream/error in stream is
// found.
......@@ -143,6 +143,17 @@ TEST_F(H265ParserTest, SpsParsing) {
EXPECT_EQ(sps->num_long_term_ref_pics_sps, 0);
EXPECT_TRUE(sps->sps_temporal_mvp_enabled_flag);
EXPECT_TRUE(sps->strong_intra_smoothing_enabled_flag);
EXPECT_EQ(sps->vui_parameters.sar_width, 0);
EXPECT_EQ(sps->vui_parameters.sar_height, 0);
EXPECT_EQ(sps->vui_parameters.video_full_range_flag, 0);
EXPECT_EQ(sps->vui_parameters.colour_description_present_flag, 0);
EXPECT_EQ(sps->vui_parameters.colour_primaries, 0);
EXPECT_EQ(sps->vui_parameters.transfer_characteristics, 0);
EXPECT_EQ(sps->vui_parameters.matrix_coeffs, 0);
EXPECT_EQ(sps->vui_parameters.def_disp_win_left_offset, 0);
EXPECT_EQ(sps->vui_parameters.def_disp_win_right_offset, 0);
EXPECT_EQ(sps->vui_parameters.def_disp_win_top_offset, 0);
EXPECT_EQ(sps->vui_parameters.def_disp_win_bottom_offset, 0);
}
} // namespace media
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment