From 1863f5a569340132760ac3081c70a249ed72ff14 Mon Sep 17 00:00:00 2001 From: Jacob Trimble Date: Mon, 14 Mar 2016 12:09:26 -0700 Subject: [PATCH] Renamed SPS/PPS to Sps/Pps. H264SPS -> H264Sps H264PPS -> H264Pps ParseSPS -> ParseSps ParsePPS -> ParsePps GetSPS -> GetSps GetPPS -> GetPps Change-Id: Ib658c05d78baabc698af4e52d8b4c77dbfbd6870 --- .../filters/avc_decoder_configuration.cc | 4 +- packager/media/filters/h264_parser.cc | 50 +++++++++---------- packager/media/filters/h264_parser.h | 42 ++++++++-------- .../media/filters/h264_parser_unittest.cc | 12 ++--- packager/media/formats/mp2t/es_parser_h264.cc | 10 ++-- packager/media/formats/mp2t/es_parser_h264.h | 4 +- .../formats/mp4/video_slice_header_parser.cc | 4 +- 7 files changed, 63 insertions(+), 63 deletions(-) diff --git a/packager/media/filters/avc_decoder_configuration.cc b/packager/media/filters/avc_decoder_configuration.cc index 175a05606a..d0dd5c2c44 100644 --- a/packager/media/filters/avc_decoder_configuration.cc +++ b/packager/media/filters/avc_decoder_configuration.cc @@ -64,8 +64,8 @@ bool AVCDecoderConfiguration::ParseInternal() { // VideoStreamInfo. int sps_id = 0; H264Parser parser; - RCHECK(parser.ParseSPS(nalu, &sps_id) == H264Parser::kOk); - RCHECK(ExtractResolutionFromSps(*parser.GetSPS(sps_id), &coded_width_, + RCHECK(parser.ParseSps(nalu, &sps_id) == H264Parser::kOk); + RCHECK(ExtractResolutionFromSps(*parser.GetSps(sps_id), &coded_width_, &coded_height_, &pixel_width_, &pixel_height_)); } diff --git a/packager/media/filters/h264_parser.cc b/packager/media/filters/h264_parser.cc index 7cfd1f7657..7c8783f3d5 100644 --- a/packager/media/filters/h264_parser.cc +++ b/packager/media/filters/h264_parser.cc @@ -14,7 +14,7 @@ namespace media { // Implemented according to ISO/IEC 14496-10:2005 7.4.2.1 Sequence parameter set // RBSP semantics. -bool ExtractResolutionFromSps(const H264SPS& sps, +bool ExtractResolutionFromSps(const H264Sps& sps, uint32_t* coded_width, uint32_t* coded_height, uint32_t* pixel_width, @@ -97,11 +97,11 @@ bool H264SliceHeader::IsSISlice() const { return (slice_type % 5 == kSISlice); } -H264SPS::H264SPS() { +H264Sps::H264Sps() { memset(this, 0, sizeof(*this)); } -H264PPS::H264PPS() { +H264Pps::H264Pps() { memset(this, 0, sizeof(*this)); } @@ -189,11 +189,11 @@ H264Parser::~H264Parser() { STLDeleteValues(&active_PPSes_); } -const H264PPS* H264Parser::GetPPS(int pps_id) { +const H264Pps* H264Parser::GetPps(int pps_id) { return active_PPSes_[pps_id]; } -const H264SPS* H264Parser::GetSPS(int sps_id) { +const H264Sps* H264Parser::GetSps(int sps_id) { return active_SPSes_[sps_id]; } @@ -350,8 +350,8 @@ H264Parser::Result H264Parser::ParseScalingList(H26xBitReader* br, return kOk; } -H264Parser::Result H264Parser::ParseSPSScalingLists(H26xBitReader* br, - H264SPS* sps) { +H264Parser::Result H264Parser::ParseSpsScalingLists(H26xBitReader* br, + H264Sps* sps) { // See 7.4.2.1.1. bool seq_scaling_list_present_flag; bool use_default; @@ -402,9 +402,9 @@ H264Parser::Result H264Parser::ParseSPSScalingLists(H26xBitReader* br, return kOk; } -H264Parser::Result H264Parser::ParsePPSScalingLists(H26xBitReader* br, - const H264SPS& sps, - H264PPS* pps) { +H264Parser::Result H264Parser::ParsePpsScalingLists(H26xBitReader* br, + const H264Sps& sps, + H264Pps* pps) { // See 7.4.2.2. bool pic_scaling_list_present_flag; bool use_default; @@ -496,7 +496,7 @@ H264Parser::Result H264Parser::ParseAndIgnoreHRDParameters( } H264Parser::Result H264Parser::ParseVUIParameters(H26xBitReader* br, - H264SPS* sps) { + H264Sps* sps) { bool aspect_ratio_info_present_flag; READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag); if (aspect_ratio_info_present_flag) { @@ -576,7 +576,7 @@ H264Parser::Result H264Parser::ParseVUIParameters(H26xBitReader* br, return kOk; } -static void FillDefaultSeqScalingLists(H264SPS* sps) { +static void FillDefaultSeqScalingLists(H264Sps* sps) { for (int i = 0; i < 6; ++i) for (int j = 0; j < kH264ScalingList4x4Length; ++j) sps->scaling_list4x4[i][j] = 16; @@ -586,7 +586,7 @@ static void FillDefaultSeqScalingLists(H264SPS* sps) { sps->scaling_list8x8[i][j] = 16; } -H264Parser::Result H264Parser::ParseSPS(const Nalu& nalu, int* sps_id) { +H264Parser::Result H264Parser::ParseSps(const Nalu& nalu, int* sps_id) { // See 7.4.2.1. int data; Result res; @@ -596,7 +596,7 @@ H264Parser::Result H264Parser::ParseSPS(const Nalu& nalu, int* sps_id) { *sps_id = -1; - scoped_ptr sps(new H264SPS()); + scoped_ptr sps(new H264Sps()); READ_BITS_OR_RETURN(8, &sps->profile_idc); READ_BOOL_OR_RETURN(&sps->constraint_set0_flag); @@ -632,7 +632,7 @@ H264Parser::Result H264Parser::ParseSPS(const Nalu& nalu, int* sps_id) { if (sps->seq_scaling_matrix_present_flag) { DVLOG(4) << "Scaling matrix present"; - res = ParseSPSScalingLists(br, sps.get()); + res = ParseSpsScalingLists(br, sps.get()); if (res != kOk) return res; } else { @@ -711,9 +711,9 @@ H264Parser::Result H264Parser::ParseSPS(const Nalu& nalu, int* sps_id) { return kOk; } -H264Parser::Result H264Parser::ParsePPS(const Nalu& nalu, int* pps_id) { +H264Parser::Result H264Parser::ParsePps(const Nalu& nalu, int* pps_id) { // See 7.4.2.2. - const H264SPS* sps; + const H264Sps* sps; Result res; H26xBitReader reader; reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size()); @@ -721,13 +721,13 @@ H264Parser::Result H264Parser::ParsePPS(const Nalu& nalu, int* pps_id) { *pps_id = -1; - scoped_ptr pps(new H264PPS()); + scoped_ptr pps(new H264Pps()); READ_UE_OR_RETURN(&pps->pic_parameter_set_id); READ_UE_OR_RETURN(&pps->seq_parameter_set_id); TRUE_OR_RETURN(pps->seq_parameter_set_id < 32); - sps = GetSPS(pps->seq_parameter_set_id); + sps = GetSps(pps->seq_parameter_set_id); TRUE_OR_RETURN(sps); READ_BOOL_OR_RETURN(&pps->entropy_coding_mode_flag); @@ -769,7 +769,7 @@ H264Parser::Result H264Parser::ParsePPS(const Nalu& nalu, int* pps_id) { if (pps->pic_scaling_matrix_present_flag) { DVLOG(4) << "Picture scaling matrix present"; - res = ParsePPSScalingLists(br, *sps, pps.get()); + res = ParsePpsScalingLists(br, *sps, pps.get()); if (res != kOk) return res; } @@ -902,7 +902,7 @@ H264Parser::Result H264Parser::ParseWeightingFactors( } H264Parser::Result H264Parser::ParsePredWeightTable(H26xBitReader* br, - const H264SPS& sps, + const H264Sps& sps, H264SliceHeader* shdr) { READ_UE_OR_RETURN(&shdr->luma_log2_weight_denom); TRUE_OR_RETURN(shdr->luma_log2_weight_denom < 8); @@ -983,8 +983,8 @@ H264Parser::Result H264Parser::ParseDecRefPicMarking(H26xBitReader* br, H264Parser::Result H264Parser::ParseSliceHeader(const Nalu& nalu, H264SliceHeader* shdr) { // See 7.4.3. - const H264SPS* sps; - const H264PPS* pps; + const H264Sps* sps; + const H264Pps* pps; Result res; H26xBitReader reader; reader.Initialize(nalu.data() + nalu.header_size(), nalu.payload_size()); @@ -1003,10 +1003,10 @@ H264Parser::Result H264Parser::ParseSliceHeader(const Nalu& nalu, READ_UE_OR_RETURN(&shdr->pic_parameter_set_id); - pps = GetPPS(shdr->pic_parameter_set_id); + pps = GetPps(shdr->pic_parameter_set_id); TRUE_OR_RETURN(pps); - sps = GetSPS(pps->seq_parameter_set_id); + sps = GetSps(pps->seq_parameter_set_id); TRUE_OR_RETURN(sps); if (sps->separate_colour_plane_flag) { diff --git a/packager/media/filters/h264_parser.h b/packager/media/filters/h264_parser.h index 3413b02250..ea74af5938 100644 --- a/packager/media/filters/h264_parser.h +++ b/packager/media/filters/h264_parser.h @@ -21,8 +21,8 @@ namespace media { // On success, |coded_width| and |coded_height| contains coded resolution after // cropping; |pixel_width:pixel_height| contains pixel aspect ratio, 1:1 is // assigned if it is not present in SPS. -struct H264SPS; -bool ExtractResolutionFromSps(const H264SPS& sps, +struct H264Sps; +bool ExtractResolutionFromSps(const H264Sps& sps, uint32_t* coded_width, uint32_t* coded_height, uint32_t* pixel_width, @@ -33,8 +33,8 @@ enum { kH264ScalingList8x8Length = 64, }; -struct H264SPS { - H264SPS(); +struct H264Sps { + H264Sps(); int profile_idc; bool constraint_set0_flag; @@ -88,8 +88,8 @@ struct H264SPS { int chroma_array_type; }; -struct H264PPS { - H264PPS(); +struct H264Pps { + H264Pps(); int pic_parameter_set_id; int seq_parameter_set_id; @@ -261,15 +261,15 @@ class H264Parser { // // Parse an SPS/PPS NALU and save their data in the parser, returning id // of the parsed structure in |*pps_id|/|*sps_id|. - // To get a pointer to a given SPS/PPS structure, use GetSPS()/GetPPS(), + // To get a pointer to a given SPS/PPS structure, use GetSps()/GetPps(), // passing the returned |*sps_id|/|*pps_id| as parameter. - Result ParseSPS(const Nalu& nalu, int* sps_id); - Result ParsePPS(const Nalu& nalu, int* pps_id); + Result ParseSps(const Nalu& nalu, int* sps_id); + Result ParsePps(const Nalu& nalu, int* pps_id); // Return a pointer to SPS/PPS with given |sps_id|/|pps_id| or NULL if not // present. - const H264SPS* GetSPS(int sps_id); - const H264PPS* GetPPS(int pps_id); + const H264Sps* GetSps(int sps_id); + const H264Pps* GetPps(int pps_id); // Slice headers and SEI messages are not used across NALUs by the parser // and can be discarded after current NALU, so the parser does not store @@ -290,13 +290,13 @@ class H264Parser { int size, int* scaling_list, bool* use_default); - Result ParseSPSScalingLists(H26xBitReader* br, H264SPS* sps); - Result ParsePPSScalingLists(H26xBitReader* br, - const H264SPS& sps, - H264PPS* pps); + Result ParseSpsScalingLists(H26xBitReader* br, H264Sps* sps); + Result ParsePpsScalingLists(H26xBitReader* br, + const H264Sps& sps, + H264Pps* pps); // Parse optional VUI parameters in SPS (see spec). - Result ParseVUIParameters(H26xBitReader* br, H264SPS* sps); + Result ParseVUIParameters(H26xBitReader* br, H264Sps* sps); // Set |hrd_parameters_present| to true only if they are present. Result ParseAndIgnoreHRDParameters(H26xBitReader* br, bool* hrd_parameters_present); @@ -309,7 +309,7 @@ class H264Parser { // Parse prediction weight table (see spec). Result ParsePredWeightTable(H26xBitReader* br, - const H264SPS& sps, + const H264Sps& sps, H264SliceHeader* shdr); // Parse weighting factors (see spec). @@ -324,10 +324,10 @@ class H264Parser { Result ParseDecRefPicMarking(H26xBitReader* br, H264SliceHeader* shdr); // PPSes and SPSes stored for future reference. - typedef std::map SPSById; - typedef std::map PPSById; - SPSById active_SPSes_; - PPSById active_PPSes_; + typedef std::map SpsById; + typedef std::map PpsById; + SpsById active_SPSes_; + PpsById active_PPSes_; DISALLOW_COPY_AND_ASSIGN(H264Parser); }; diff --git a/packager/media/filters/h264_parser_unittest.cc b/packager/media/filters/h264_parser_unittest.cc index d15313890a..7f76df081d 100644 --- a/packager/media/filters/h264_parser_unittest.cc +++ b/packager/media/filters/h264_parser_unittest.cc @@ -46,11 +46,11 @@ TEST(H264ParserTest, StreamFileParsing) { break; case Nalu::H264_SPS: - ASSERT_EQ(parser.ParseSPS(nalu, &id), H264Parser::kOk); + ASSERT_EQ(parser.ParseSps(nalu, &id), H264Parser::kOk); break; case Nalu::H264_PPS: - ASSERT_EQ(parser.ParsePPS(nalu, &id), H264Parser::kOk); + ASSERT_EQ(parser.ParsePps(nalu, &id), H264Parser::kOk); break; case Nalu::H264_SEIMessage: @@ -75,13 +75,13 @@ TEST(H264ParserTest, ExtractResolutionFromSpsData) { int sps_id = 0; Nalu nalu; ASSERT_TRUE(nalu.InitializeFromH264(kSps, arraysize(kSps))); - ASSERT_EQ(H264Parser::kOk, parser.ParseSPS(nalu, &sps_id)); + ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id)); uint32_t coded_width = 0; uint32_t coded_height = 0; uint32_t pixel_width = 0; uint32_t pixel_height = 0; - ASSERT_TRUE(ExtractResolutionFromSps(*parser.GetSPS(sps_id), &coded_width, + ASSERT_TRUE(ExtractResolutionFromSps(*parser.GetSps(sps_id), &coded_width, &coded_height, &pixel_width, &pixel_height)); EXPECT_EQ(720u, coded_width); @@ -100,13 +100,13 @@ TEST(H264ParserTest, ExtractResolutionFromSpsDataWithCropping) { int sps_id = 0; Nalu nalu; ASSERT_TRUE(nalu.InitializeFromH264(kSps, arraysize(kSps))); - ASSERT_EQ(H264Parser::kOk, parser.ParseSPS(nalu, &sps_id)); + ASSERT_EQ(H264Parser::kOk, parser.ParseSps(nalu, &sps_id)); uint32_t coded_width = 0; uint32_t coded_height = 0; uint32_t pixel_width = 0; uint32_t pixel_height = 0; - ASSERT_TRUE(ExtractResolutionFromSps(*parser.GetSPS(sps_id), &coded_width, + ASSERT_TRUE(ExtractResolutionFromSps(*parser.GetSps(sps_id), &coded_width, &coded_height, &pixel_width, &pixel_height)); EXPECT_EQ(320u, coded_width); diff --git a/packager/media/formats/mp2t/es_parser_h264.cc b/packager/media/formats/mp2t/es_parser_h264.cc index fabe114299..aae88d542f 100644 --- a/packager/media/formats/mp2t/es_parser_h264.cc +++ b/packager/media/formats/mp2t/es_parser_h264.cc @@ -208,7 +208,7 @@ bool EsParserH264::ParseInternal() { case Nalu::H264_SPS: { DVLOG(LOG_LEVEL_ES) << "Nalu: SPS"; int sps_id; - if (h264_parser_->ParseSPS(nalu, &sps_id) != H264Parser::kOk) + if (h264_parser_->ParseSps(nalu, &sps_id) != H264Parser::kOk) return false; decoder_config_check_pending_ = true; break; @@ -216,7 +216,7 @@ bool EsParserH264::ParseInternal() { case Nalu::H264_PPS: { DVLOG(LOG_LEVEL_ES) << "Nalu: PPS"; int pps_id; - if (h264_parser_->ParsePPS(nalu, &pps_id) != H264Parser::kOk) { + if (h264_parser_->ParsePps(nalu, &pps_id) != H264Parser::kOk) { // Allow PPS parsing to fail if waiting for SPS. if (last_video_decoder_config_) return false; @@ -292,7 +292,7 @@ bool EsParserH264::EmitFrame(int64_t access_unit_pos, if (decoder_config_check_pending_) { // Update the video decoder configuration if needed. - const H264PPS* pps = h264_parser_->GetPPS(pps_id); + const H264Pps* pps = h264_parser_->GetPps(pps_id); if (!pps) { // Only accept an invalid PPS at the beginning when the stream // does not necessarily start with an SPS/PPS/IDR. @@ -302,7 +302,7 @@ bool EsParserH264::EmitFrame(int64_t access_unit_pos, if (last_video_decoder_config_) return false; } else { - const H264SPS* sps = h264_parser_->GetSPS(pps->seq_parameter_set_id); + const H264Sps* sps = h264_parser_->GetSps(pps->seq_parameter_set_id); if (!sps) return false; RCHECK(UpdateVideoDecoderConfig(sps)); @@ -327,7 +327,7 @@ bool EsParserH264::EmitFrame(int64_t access_unit_pos, return true; } -bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps) { +bool EsParserH264::UpdateVideoDecoderConfig(const H264Sps* sps) { std::vector decoder_config_record; if (!stream_converter_->GetAVCDecoderConfigurationRecord( &decoder_config_record)) { diff --git a/packager/media/formats/mp2t/es_parser_h264.h b/packager/media/formats/mp2t/es_parser_h264.h index 14f33c1f86..e56ca0f5b5 100644 --- a/packager/media/formats/mp2t/es_parser_h264.h +++ b/packager/media/formats/mp2t/es_parser_h264.h @@ -21,7 +21,7 @@ namespace media { class H264ByteToUnitStreamConverter; class H264Parser; class OffsetByteQueue; -struct H264SPS; +struct H264Sps; namespace mp2t { @@ -68,7 +68,7 @@ class EsParserH264 : public EsParser { // Update the video decoder config based on an H264 SPS. // Return true if successful. - bool UpdateVideoDecoderConfig(const H264SPS* sps); + bool UpdateVideoDecoderConfig(const H264Sps* sps); // Callbacks to pass the stream configuration and the frames. NewStreamInfoCB new_stream_info_cb_; diff --git a/packager/media/formats/mp4/video_slice_header_parser.cc b/packager/media/formats/mp4/video_slice_header_parser.cc index 0cc614c4b5..ba914cf721 100644 --- a/packager/media/formats/mp4/video_slice_header_parser.cc +++ b/packager/media/formats/mp4/video_slice_header_parser.cc @@ -25,10 +25,10 @@ bool H264VideoSliceHeaderParser::Initialize( int id; const Nalu& nalu = config.nalu(i); if (nalu.type() == Nalu::H264_SPS) { - RCHECK(parser_.ParseSPS(nalu, &id) == H264Parser::kOk); + RCHECK(parser_.ParseSps(nalu, &id) == H264Parser::kOk); } else { DCHECK_EQ(Nalu::H264_PPS, nalu.type()); - RCHECK(parser_.ParsePPS(nalu, &id) == H264Parser::kOk); + RCHECK(parser_.ParsePps(nalu, &id) == H264Parser::kOk); } }