From ec1d84aff7f6a4d0a28da6fca8d164a883021bab Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Tue, 4 Apr 2023 03:57:32 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 521718577 --- mediapipe/framework/tool/executor_util.cc | 2 +- .../framework/tool/options_field_util.cc | 30 +++++------ mediapipe/framework/tool/proto_util_lite.cc | 50 +++++++++---------- .../framework/tool/simulation_clock_test.cc | 14 +++--- .../framework/tool/switch_container_test.cc | 6 +-- mediapipe/framework/tool/test_util.cc | 16 +++--- mediapipe/framework/tool/validate_name.cc | 4 +- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/mediapipe/framework/tool/executor_util.cc b/mediapipe/framework/tool/executor_util.cc index 91089cc71..6d967768e 100644 --- a/mediapipe/framework/tool/executor_util.cc +++ b/mediapipe/framework/tool/executor_util.cc @@ -22,7 +22,7 @@ namespace mediapipe { namespace tool { -void EnsureMinimumDefaultExecutorStackSize(const int32 min_stack_size, +void EnsureMinimumDefaultExecutorStackSize(const int32_t min_stack_size, CalculatorGraphConfig* config) { mediapipe::ExecutorConfig* default_executor_config = nullptr; for (mediapipe::ExecutorConfig& executor_config : diff --git a/mediapipe/framework/tool/options_field_util.cc b/mediapipe/framework/tool/options_field_util.cc index 483b023b9..308932d4f 100644 --- a/mediapipe/framework/tool/options_field_util.cc +++ b/mediapipe/framework/tool/options_field_util.cc @@ -487,24 +487,24 @@ FieldData AsFieldData(const proto_ns::MessageLite& message) { // Represents a protobuf enum value stored in a Packet. struct ProtoEnum { - ProtoEnum(int32 v) : value(v) {} - int32 value; + ProtoEnum(int32_t v) : value(v) {} + int32_t value; }; absl::StatusOr AsPacket(const FieldData& data) { Packet result; switch (data.value_case()) { case FieldData::ValueCase::kInt32Value: - result = MakePacket(data.int32_value()); + result = MakePacket(data.int32_value()); break; case FieldData::ValueCase::kInt64Value: - result = MakePacket(data.int64_value()); + result = MakePacket(data.int64_value()); break; case FieldData::ValueCase::kUint32Value: - result = MakePacket(data.uint32_value()); + result = MakePacket(data.uint32_value()); break; case FieldData::ValueCase::kUint64Value: - result = MakePacket(data.uint64_value()); + result = MakePacket(data.uint64_value()); break; case FieldData::ValueCase::kDoubleValue: result = MakePacket(data.double_value()); @@ -538,11 +538,11 @@ absl::StatusOr AsPacket(const FieldData& data) { } absl::StatusOr AsFieldData(Packet packet) { - static const auto* kTypeIds = new std::map{ - {kTypeId, WireFormatLite::CPPTYPE_INT32}, - {kTypeId, WireFormatLite::CPPTYPE_INT64}, - {kTypeId, WireFormatLite::CPPTYPE_UINT32}, - {kTypeId, WireFormatLite::CPPTYPE_UINT64}, + static const auto* kTypeIds = new std::map{ + {kTypeId, WireFormatLite::CPPTYPE_INT32}, + {kTypeId, WireFormatLite::CPPTYPE_INT64}, + {kTypeId, WireFormatLite::CPPTYPE_UINT32}, + {kTypeId, WireFormatLite::CPPTYPE_UINT64}, {kTypeId, WireFormatLite::CPPTYPE_DOUBLE}, {kTypeId, WireFormatLite::CPPTYPE_FLOAT}, {kTypeId, WireFormatLite::CPPTYPE_BOOL}, @@ -566,16 +566,16 @@ absl::StatusOr AsFieldData(Packet packet) { switch (kTypeIds->at(packet.GetTypeId())) { case WireFormatLite::CPPTYPE_INT32: - result.set_int32_value(packet.Get()); + result.set_int32_value(packet.Get()); break; case WireFormatLite::CPPTYPE_INT64: - result.set_int64_value(packet.Get()); + result.set_int64_value(packet.Get()); break; case WireFormatLite::CPPTYPE_UINT32: - result.set_uint32_value(packet.Get()); + result.set_uint32_value(packet.Get()); break; case WireFormatLite::CPPTYPE_UINT64: - result.set_uint64_value(packet.Get()); + result.set_uint64_value(packet.Get()); break; case WireFormatLite::CPPTYPE_DOUBLE: result.set_double_value(packet.Get()); diff --git a/mediapipe/framework/tool/proto_util_lite.cc b/mediapipe/framework/tool/proto_util_lite.cc index a810ce129..745f4a13b 100644 --- a/mediapipe/framework/tool/proto_util_lite.cc +++ b/mediapipe/framework/tool/proto_util_lite.cc @@ -48,11 +48,11 @@ bool IsLengthDelimited(WireFormatLite::WireType wire_type) { } // Reads a single data value for a wire type. -absl::Status ReadFieldValue(uint32 tag, CodedInputStream* in, +absl::Status ReadFieldValue(uint32_t tag, CodedInputStream* in, std::string* result) { WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); if (IsLengthDelimited(wire_type)) { - uint32 length; + uint32_t length; RET_CHECK_NO_LOG(in->ReadVarint32(&length)); RET_CHECK_NO_LOG(in->ReadString(result, length)); } else { @@ -72,10 +72,10 @@ absl::Status ReadFieldValue(uint32 tag, CodedInputStream* in, absl::Status ReadPackedValues(WireFormatLite::WireType wire_type, CodedInputStream* in, std::vector* field_values) { - uint32 data_size; + uint32_t data_size; RET_CHECK_NO_LOG(in->ReadVarint32(&data_size)); // fake_tag encodes the wire-type for calls to WireFormatLite::SkipField. - uint32 fake_tag = WireFormatLite::MakeTag(1, wire_type); + uint32_t fake_tag = WireFormatLite::MakeTag(1, wire_type); while (data_size > 0) { std::string number; MP_RETURN_IF_ERROR(ReadFieldValue(fake_tag, in, &number)); @@ -88,10 +88,10 @@ absl::Status ReadPackedValues(WireFormatLite::WireType wire_type, // Extracts the data value(s) for one field from a serialized message. // The message with these field values removed is written to |out|. -absl::Status GetFieldValues(uint32 field_id, CodedInputStream* in, +absl::Status GetFieldValues(uint32_t field_id, CodedInputStream* in, CodedOutputStream* out, std::vector* field_values) { - uint32 tag; + uint32_t tag; while ((tag = in->ReadTag()) != 0) { int field_number = WireFormatLite::GetTagFieldNumber(tag); WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); @@ -112,10 +112,10 @@ absl::Status GetFieldValues(uint32 field_id, CodedInputStream* in, } // Injects the data value(s) for one field into a serialized message. -void SetFieldValues(uint32 field_id, WireFormatLite::WireType wire_type, +void SetFieldValues(uint32_t field_id, WireFormatLite::WireType wire_type, const std::vector& field_values, CodedOutputStream* out) { - uint32 tag = WireFormatLite::MakeTag(field_id, wire_type); + uint32_t tag = WireFormatLite::MakeTag(field_id, wire_type); for (const std::string& field_value : field_values) { out->WriteVarint32(tag); if (IsLengthDelimited(wire_type)) { @@ -125,7 +125,7 @@ void SetFieldValues(uint32 field_id, WireFormatLite::WireType wire_type, } } -FieldAccess::FieldAccess(uint32 field_id, FieldType field_type) +FieldAccess::FieldAccess(uint32_t field_id, FieldType field_type) : field_id_(field_id), field_type_(field_type) {} absl::Status FieldAccess::SetMessage(const std::string& message) { @@ -397,11 +397,11 @@ static absl::Status DeserializeValue(const FieldValue& bytes, case W::TYPE_UINT64: return ReadPrimitive(&input, result); case W::TYPE_INT32: - return ReadPrimitive(&input, result); + return ReadPrimitive(&input, result); case W::TYPE_FIXED64: return ReadPrimitive(&input, result); case W::TYPE_FIXED32: - return ReadPrimitive(&input, result); + return ReadPrimitive(&input, result); case W::TYPE_BOOL: return ReadPrimitive(&input, result); case W::TYPE_BYTES: @@ -413,15 +413,15 @@ static absl::Status DeserializeValue(const FieldValue& bytes, case W::TYPE_MESSAGE: CHECK(false) << "DeserializeValue cannot deserialize a Message."; case W::TYPE_UINT32: - return ReadPrimitive(&input, result); + return ReadPrimitive(&input, result); case W::TYPE_ENUM: return ReadPrimitive(&input, result); case W::TYPE_SFIXED32: - return ReadPrimitive(&input, result); + return ReadPrimitive(&input, result); case W::TYPE_SFIXED64: return ReadPrimitive(&input, result); case W::TYPE_SINT32: - return ReadPrimitive(&input, result); + return ReadPrimitive(&input, result); case W::TYPE_SINT64: return ReadPrimitive(&input, result); } @@ -523,27 +523,27 @@ absl::Status ReadValue(absl::string_view field_bytes, FieldType field_type, switch (field_type) { case WireFormatLite::TYPE_INT32: result->set_int32_value( - ReadValue(field_bytes, &status)); + ReadValue(field_bytes, &status)); break; case WireFormatLite::TYPE_SINT32: - result->set_int32_value( - ReadValue(field_bytes, &status)); + result->set_int32_value(ReadValue( + field_bytes, &status)); break; case WireFormatLite::TYPE_INT64: result->set_int64_value( - ReadValue(field_bytes, &status)); + ReadValue(field_bytes, &status)); break; case WireFormatLite::TYPE_SINT64: - result->set_int64_value( - ReadValue(field_bytes, &status)); + result->set_int64_value(ReadValue( + field_bytes, &status)); break; case WireFormatLite::TYPE_UINT32: - result->set_uint32_value( - ReadValue(field_bytes, &status)); + result->set_uint32_value(ReadValue( + field_bytes, &status)); break; case WireFormatLite::TYPE_UINT64: - result->set_uint64_value( - ReadValue(field_bytes, &status)); + result->set_uint64_value(ReadValue( + field_bytes, &status)); break; case WireFormatLite::TYPE_DOUBLE: result->set_double_value( @@ -559,7 +559,7 @@ absl::Status ReadValue(absl::string_view field_bytes, FieldType field_type, break; case WireFormatLite::TYPE_ENUM: result->set_enum_value( - ReadValue(field_bytes, &status)); + ReadValue(field_bytes, &status)); break; case WireFormatLite::TYPE_STRING: result->set_string_value(std::string(field_bytes)); diff --git a/mediapipe/framework/tool/simulation_clock_test.cc b/mediapipe/framework/tool/simulation_clock_test.cc index 3f2c3615c..c4c76e37e 100644 --- a/mediapipe/framework/tool/simulation_clock_test.cc +++ b/mediapipe/framework/tool/simulation_clock_test.cc @@ -99,17 +99,17 @@ class SimulationClockTest : public ::testing::Test { void SetupRealClock() { clock_ = mediapipe::Clock::RealClock(); } // Return the values of the timestamps of a vector of Packets. - static std::vector TimestampValues( + static std::vector TimestampValues( const std::vector& packets) { - std::vector result; + std::vector result; for (const Packet& p : packets) { result.push_back(p.Timestamp().Value()); } return result; } - static std::vector TimeValues(const std::vector& times) { - std::vector result; + static std::vector TimeValues(const std::vector& times) { + std::vector result; for (const absl::Time& t : times) { result.push_back(absl::ToUnixMicros(t)); } @@ -225,9 +225,9 @@ TEST_F(SimulationClockTest, InFlight) { // Add 10 input packets to the graph, one each 10 ms, starting after 11 ms // of clock time. Timestamps lag clock times by 1 ms. clock_->Sleep(absl::Microseconds(11000)); - for (uint64 ts = 10000; ts <= 100000; ts += 10000) { + for (uint64_t ts = 10000; ts <= 100000; ts += 10000) { MP_EXPECT_OK(graph_.AddPacketToInputStream( - "input_packets_0", MakePacket(ts).At(Timestamp(ts)))); + "input_packets_0", MakePacket(ts).At(Timestamp(ts)))); clock_->Sleep(absl::Microseconds(10000)); } @@ -266,7 +266,7 @@ TEST_F(SimulationClockTest, DestroyClock) { clock_->Sleep(absl::Microseconds(20000)); if (++input_count < 4) { outputs->Index(0).AddPacket( - MakePacket(input_count).At(Timestamp(input_count))); + MakePacket(input_count).At(Timestamp(input_count))); return absl::OkStatus(); } else { return tool::StatusStop(); diff --git a/mediapipe/framework/tool/switch_container_test.cc b/mediapipe/framework/tool/switch_container_test.cc index b20979b10..08cc4ab5a 100644 --- a/mediapipe/framework/tool/switch_container_test.cc +++ b/mediapipe/framework/tool/switch_container_test.cc @@ -144,7 +144,7 @@ void RunTestContainer(CalculatorGraphConfig supergraph, if (!send_bounds) { // Send enable == true signal at 5000 us. - const int64 enable_ts = 5000; + const int64_t enable_ts = 5000; MP_EXPECT_OK(graph.AddPacketToInputStream( "enable", MakePacket(true).At(Timestamp(enable_ts)))); MP_ASSERT_OK(graph.WaitUntilIdle()); @@ -152,7 +152,7 @@ void RunTestContainer(CalculatorGraphConfig supergraph, const int packet_count = 10; // Send int value packets at {10K, 20K, 30K, ..., 100K}. - for (uint64 t = 1; t <= packet_count; ++t) { + for (uint64_t t = 1; t <= packet_count; ++t) { if (send_bounds) { MP_EXPECT_OK(graph.AddPacketToInputStream( "enable", MakePacket(true).At(Timestamp(t * 10000)))); @@ -180,7 +180,7 @@ void RunTestContainer(CalculatorGraphConfig supergraph, } // Send int value packets at {110K, 120K, ..., 200K}. - for (uint64 t = 11; t <= packet_count * 2; ++t) { + for (uint64_t t = 11; t <= packet_count * 2; ++t) { if (send_bounds) { MP_EXPECT_OK(graph.AddPacketToInputStream( "enable", MakePacket(false).At(Timestamp(t * 10000)))); diff --git a/mediapipe/framework/tool/test_util.cc b/mediapipe/framework/tool/test_util.cc index e8b02084b..d05171d20 100644 --- a/mediapipe/framework/tool/test_util.cc +++ b/mediapipe/framework/tool/test_util.cc @@ -182,13 +182,13 @@ absl::Status CompareImageFrames(const ImageFrame& image1, case ImageFormat::SRGB: case ImageFormat::SRGBA: case ImageFormat::LAB8: - return CompareDiff(image1, image2, max_color_diff, max_alpha_diff, - max_avg_diff, diff_image); + return CompareDiff(image1, image2, max_color_diff, + max_alpha_diff, max_avg_diff, diff_image); case ImageFormat::GRAY16: case ImageFormat::SRGB48: case ImageFormat::SRGBA64: - return CompareDiff(image1, image2, max_color_diff, max_alpha_diff, - max_avg_diff, diff_image); + return CompareDiff(image1, image2, max_color_diff, + max_alpha_diff, max_avg_diff, diff_image); case ImageFormat::VEC32F1: case ImageFormat::VEC32F2: return CompareDiff(image1, image2, max_color_diff, max_alpha_diff, @@ -350,17 +350,17 @@ std::unique_ptr GenerateLuminanceImage( auto luminance_image = absl::make_unique(original_image.Format(), width, height, ImageFrame::kGlDefaultAlignmentBoundary); - const uint8* pixel1 = original_image.PixelData(); - uint8* pixel2 = luminance_image->MutablePixelData(); + const uint8_t* pixel1 = original_image.PixelData(); + uint8_t* pixel2 = luminance_image->MutablePixelData(); const int width_padding1 = original_image.WidthStep() - width * channels; const int width_padding2 = luminance_image->WidthStep() - width * channels; for (int row = 0; row < height; ++row) { for (int col = 0; col < width; ++col) { float luminance = pixel1[0] * 0.2125f + pixel1[1] * 0.7154f + pixel1[2] * 0.0721f; - uint8 luminance_byte = 255; + uint8_t luminance_byte = 255; if (luminance < 255.0f) { - luminance_byte = static_cast(luminance); + luminance_byte = static_cast(luminance); } pixel2[0] = luminance_byte; pixel2[1] = luminance_byte; diff --git a/mediapipe/framework/tool/validate_name.cc b/mediapipe/framework/tool/validate_name.cc index bea857dd4..ad66b43d8 100644 --- a/mediapipe/framework/tool/validate_name.cc +++ b/mediapipe/framework/tool/validate_name.cc @@ -185,7 +185,7 @@ absl::Status ParseTagIndexName(const std::string& tag_index_name, tag_status = ValidateTag(v[0]); number_status = ValidateNumber(v[1]); if (number_status.ok()) { - int64 index64; + int64_t index64; RET_CHECK(absl::SimpleAtoi(v[1], &index64)); RET_CHECK_LE(index64, internal::kMaxCollectionItemId); the_index = index64; @@ -227,7 +227,7 @@ absl::Status ParseTagIndex(const std::string& tag_index, std::string* tag, } number_status = ValidateNumber(v[1]); if (number_status.ok()) { - int64 index64; + int64_t index64; RET_CHECK(absl::SimpleAtoi(v[1], &index64)); RET_CHECK_LE(index64, internal::kMaxCollectionItemId); the_index = index64;