Internal change

PiperOrigin-RevId: 521718577
This commit is contained in:
MediaPipe Team 2023-04-04 03:57:32 -07:00 committed by Copybara-Service
parent e95f465d58
commit ec1d84aff7
7 changed files with 61 additions and 61 deletions

View File

@ -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 :

View File

@ -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<Packet> AsPacket(const FieldData& data) {
Packet result;
switch (data.value_case()) {
case FieldData::ValueCase::kInt32Value:
result = MakePacket<int32>(data.int32_value());
result = MakePacket<int32_t>(data.int32_value());
break;
case FieldData::ValueCase::kInt64Value:
result = MakePacket<int64>(data.int64_value());
result = MakePacket<int64_t>(data.int64_value());
break;
case FieldData::ValueCase::kUint32Value:
result = MakePacket<uint32>(data.uint32_value());
result = MakePacket<uint32_t>(data.uint32_value());
break;
case FieldData::ValueCase::kUint64Value:
result = MakePacket<uint64>(data.uint64_value());
result = MakePacket<uint64_t>(data.uint64_value());
break;
case FieldData::ValueCase::kDoubleValue:
result = MakePacket<double>(data.double_value());
@ -538,11 +538,11 @@ absl::StatusOr<Packet> AsPacket(const FieldData& data) {
}
absl::StatusOr<FieldData> AsFieldData(Packet packet) {
static const auto* kTypeIds = new std::map<TypeId, int32>{
{kTypeId<int32>, WireFormatLite::CPPTYPE_INT32},
{kTypeId<int64>, WireFormatLite::CPPTYPE_INT64},
{kTypeId<uint32>, WireFormatLite::CPPTYPE_UINT32},
{kTypeId<uint64>, WireFormatLite::CPPTYPE_UINT64},
static const auto* kTypeIds = new std::map<TypeId, int32_t>{
{kTypeId<int32_t>, WireFormatLite::CPPTYPE_INT32},
{kTypeId<int64_t>, WireFormatLite::CPPTYPE_INT64},
{kTypeId<uint32_t>, WireFormatLite::CPPTYPE_UINT32},
{kTypeId<uint64_t>, WireFormatLite::CPPTYPE_UINT64},
{kTypeId<double>, WireFormatLite::CPPTYPE_DOUBLE},
{kTypeId<float>, WireFormatLite::CPPTYPE_FLOAT},
{kTypeId<bool>, WireFormatLite::CPPTYPE_BOOL},
@ -566,16 +566,16 @@ absl::StatusOr<FieldData> AsFieldData(Packet packet) {
switch (kTypeIds->at(packet.GetTypeId())) {
case WireFormatLite::CPPTYPE_INT32:
result.set_int32_value(packet.Get<int32>());
result.set_int32_value(packet.Get<int32_t>());
break;
case WireFormatLite::CPPTYPE_INT64:
result.set_int64_value(packet.Get<int64>());
result.set_int64_value(packet.Get<int64_t>());
break;
case WireFormatLite::CPPTYPE_UINT32:
result.set_uint32_value(packet.Get<uint32>());
result.set_uint32_value(packet.Get<uint32_t>());
break;
case WireFormatLite::CPPTYPE_UINT64:
result.set_uint64_value(packet.Get<uint64>());
result.set_uint64_value(packet.Get<uint64_t>());
break;
case WireFormatLite::CPPTYPE_DOUBLE:
result.set_double_value(packet.Get<double>());

View File

@ -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<std::string>* 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<std::string>* 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<std::string>& 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<proto_uint64, W::TYPE_UINT64>(&input, result);
case W::TYPE_INT32:
return ReadPrimitive<int32, W::TYPE_INT32>(&input, result);
return ReadPrimitive<int32_t, W::TYPE_INT32>(&input, result);
case W::TYPE_FIXED64:
return ReadPrimitive<proto_uint64, W::TYPE_FIXED64>(&input, result);
case W::TYPE_FIXED32:
return ReadPrimitive<uint32, W::TYPE_FIXED32>(&input, result);
return ReadPrimitive<uint32_t, W::TYPE_FIXED32>(&input, result);
case W::TYPE_BOOL:
return ReadPrimitive<bool, W::TYPE_BOOL>(&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<uint32, W::TYPE_UINT32>(&input, result);
return ReadPrimitive<uint32_t, W::TYPE_UINT32>(&input, result);
case W::TYPE_ENUM:
return ReadPrimitive<int, W::TYPE_ENUM>(&input, result);
case W::TYPE_SFIXED32:
return ReadPrimitive<int32, W::TYPE_SFIXED32>(&input, result);
return ReadPrimitive<int32_t, W::TYPE_SFIXED32>(&input, result);
case W::TYPE_SFIXED64:
return ReadPrimitive<proto_int64, W::TYPE_SFIXED64>(&input, result);
case W::TYPE_SINT32:
return ReadPrimitive<int32, W::TYPE_SINT32>(&input, result);
return ReadPrimitive<int32_t, W::TYPE_SINT32>(&input, result);
case W::TYPE_SINT64:
return ReadPrimitive<proto_int64, W::TYPE_SINT64>(&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<int32, WireFormatLite::TYPE_INT32>(field_bytes, &status));
ReadValue<int32_t, WireFormatLite::TYPE_INT32>(field_bytes, &status));
break;
case WireFormatLite::TYPE_SINT32:
result->set_int32_value(
ReadValue<int32, WireFormatLite::TYPE_SINT32>(field_bytes, &status));
result->set_int32_value(ReadValue<int32_t, WireFormatLite::TYPE_SINT32>(
field_bytes, &status));
break;
case WireFormatLite::TYPE_INT64:
result->set_int64_value(
ReadValue<int64, WireFormatLite::TYPE_INT64>(field_bytes, &status));
ReadValue<int64_t, WireFormatLite::TYPE_INT64>(field_bytes, &status));
break;
case WireFormatLite::TYPE_SINT64:
result->set_int64_value(
ReadValue<int64, WireFormatLite::TYPE_SINT64>(field_bytes, &status));
result->set_int64_value(ReadValue<int64_t, WireFormatLite::TYPE_SINT64>(
field_bytes, &status));
break;
case WireFormatLite::TYPE_UINT32:
result->set_uint32_value(
ReadValue<uint32, WireFormatLite::TYPE_UINT32>(field_bytes, &status));
result->set_uint32_value(ReadValue<uint32_t, WireFormatLite::TYPE_UINT32>(
field_bytes, &status));
break;
case WireFormatLite::TYPE_UINT64:
result->set_uint64_value(
ReadValue<uint32, WireFormatLite::TYPE_UINT32>(field_bytes, &status));
result->set_uint64_value(ReadValue<uint32_t, WireFormatLite::TYPE_UINT32>(
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<int32, WireFormatLite::TYPE_ENUM>(field_bytes, &status));
ReadValue<int32_t, WireFormatLite::TYPE_ENUM>(field_bytes, &status));
break;
case WireFormatLite::TYPE_STRING:
result->set_string_value(std::string(field_bytes));

View File

@ -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<int64> TimestampValues(
static std::vector<int64_t> TimestampValues(
const std::vector<Packet>& packets) {
std::vector<int64> result;
std::vector<int64_t> result;
for (const Packet& p : packets) {
result.push_back(p.Timestamp().Value());
}
return result;
}
static std::vector<int64> TimeValues(const std::vector<absl::Time>& times) {
std::vector<int64> result;
static std::vector<int64_t> TimeValues(const std::vector<absl::Time>& times) {
std::vector<int64_t> 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<uint64>(ts).At(Timestamp(ts))));
"input_packets_0", MakePacket<uint64_t>(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<uint64>(input_count).At(Timestamp(input_count)));
MakePacket<uint64_t>(input_count).At(Timestamp(input_count)));
return absl::OkStatus();
} else {
return tool::StatusStop();

View File

@ -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<bool>(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<bool>(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<bool>(false).At(Timestamp(t * 10000))));

View File

@ -182,13 +182,13 @@ absl::Status CompareImageFrames(const ImageFrame& image1,
case ImageFormat::SRGB:
case ImageFormat::SRGBA:
case ImageFormat::LAB8:
return CompareDiff<uint8>(image1, image2, max_color_diff, max_alpha_diff,
max_avg_diff, diff_image);
return CompareDiff<uint8_t>(image1, image2, max_color_diff,
max_alpha_diff, max_avg_diff, diff_image);
case ImageFormat::GRAY16:
case ImageFormat::SRGB48:
case ImageFormat::SRGBA64:
return CompareDiff<uint16>(image1, image2, max_color_diff, max_alpha_diff,
max_avg_diff, diff_image);
return CompareDiff<uint16_t>(image1, image2, max_color_diff,
max_alpha_diff, max_avg_diff, diff_image);
case ImageFormat::VEC32F1:
case ImageFormat::VEC32F2:
return CompareDiff<float>(image1, image2, max_color_diff, max_alpha_diff,
@ -350,17 +350,17 @@ std::unique_ptr<ImageFrame> GenerateLuminanceImage(
auto luminance_image =
absl::make_unique<ImageFrame>(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<uint8>(luminance);
luminance_byte = static_cast<uint8_t>(luminance);
}
pixel2[0] = luminance_byte;
pixel2[1] = luminance_byte;

View File

@ -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;