diff --git a/WORKSPACE b/WORKSPACE index b8a1d9dd0..31a7a1b29 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,7 +10,7 @@ http_archive( sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e", ) load("@bazel_skylib//lib:versions.bzl", "versions") -versions.check(minimum_bazel_version = "0.23.0") +versions.check(minimum_bazel_version = "0.24.1") # ABSL cpp library. http_archive( diff --git a/mediapipe/calculators/audio/audio_decoder_calculator.cc b/mediapipe/calculators/audio/audio_decoder_calculator.cc index 5e379ce4d..24689492e 100644 --- a/mediapipe/calculators/audio/audio_decoder_calculator.cc +++ b/mediapipe/calculators/audio/audio_decoder_calculator.cc @@ -74,7 +74,7 @@ class AudioDecoderCalculator : public CalculatorBase { cc->InputSidePackets().Tag("INPUT_FILE_PATH").Get(); const auto& decoder_options = cc->Options(); decoder_ = absl::make_unique(); - RETURN_IF_ERROR(decoder_->Initialize(input_file_path, decoder_options)); + MP_RETURN_IF_ERROR(decoder_->Initialize(input_file_path, decoder_options)); std::unique_ptr header = absl::make_unique(); if (decoder_->FillAudioHeader(decoder_options.audio_stream(0), header.get()) diff --git a/mediapipe/calculators/audio/audio_decoder_calculator_test.cc b/mediapipe/calculators/audio/audio_decoder_calculator_test.cc index e65fe1e41..be0cd1836 100644 --- a/mediapipe/calculators/audio/audio_decoder_calculator_test.cc +++ b/mediapipe/calculators/audio/audio_decoder_calculator_test.cc @@ -39,11 +39,10 @@ TEST(AudioDecoderCalculatorTest, TestWAV) { file::JoinPath("./", "/mediapipe/calculators/audio/" "testdata/sine_wave_1k_44100_mono_2_sec_wav.audio")); - MEDIAPIPE_ASSERT_OK(runner.Run()); - MEDIAPIPE_EXPECT_OK( - runner.Outputs() - .Tag("AUDIO_HEADER") - .header.ValidateAsType()); + MP_ASSERT_OK(runner.Run()); + MP_EXPECT_OK(runner.Outputs() + .Tag("AUDIO_HEADER") + .header.ValidateAsType()); const mediapipe::TimeSeriesHeader& header = runner.Outputs() .Tag("AUDIO_HEADER") @@ -71,11 +70,10 @@ TEST(AudioDecoderCalculatorTest, Test48KWAV) { file::JoinPath("./", "/mediapipe/calculators/audio/" "testdata/sine_wave_1k_48000_stereo_2_sec_wav.audio")); - MEDIAPIPE_ASSERT_OK(runner.Run()); - MEDIAPIPE_EXPECT_OK( - runner.Outputs() - .Tag("AUDIO_HEADER") - .header.ValidateAsType()); + MP_ASSERT_OK(runner.Run()); + MP_EXPECT_OK(runner.Outputs() + .Tag("AUDIO_HEADER") + .header.ValidateAsType()); const mediapipe::TimeSeriesHeader& header = runner.Outputs() .Tag("AUDIO_HEADER") @@ -103,11 +101,10 @@ TEST(AudioDecoderCalculatorTest, TestMP3) { file::JoinPath("./", "/mediapipe/calculators/audio/" "testdata/sine_wave_1k_44100_stereo_2_sec_mp3.audio")); - MEDIAPIPE_ASSERT_OK(runner.Run()); - MEDIAPIPE_EXPECT_OK( - runner.Outputs() - .Tag("AUDIO_HEADER") - .header.ValidateAsType()); + MP_ASSERT_OK(runner.Run()); + MP_EXPECT_OK(runner.Outputs() + .Tag("AUDIO_HEADER") + .header.ValidateAsType()); const mediapipe::TimeSeriesHeader& header = runner.Outputs() .Tag("AUDIO_HEADER") @@ -135,11 +132,10 @@ TEST(AudioDecoderCalculatorTest, TestAAC) { file::JoinPath("./", "/mediapipe/calculators/audio/" "testdata/sine_wave_1k_44100_stereo_2_sec_aac.audio")); - MEDIAPIPE_ASSERT_OK(runner.Run()); - MEDIAPIPE_EXPECT_OK( - runner.Outputs() - .Tag("AUDIO_HEADER") - .header.ValidateAsType()); + MP_ASSERT_OK(runner.Run()); + MP_EXPECT_OK(runner.Outputs() + .Tag("AUDIO_HEADER") + .header.ValidateAsType()); const mediapipe::TimeSeriesHeader& header = runner.Outputs() .Tag("AUDIO_HEADER") diff --git a/mediapipe/calculators/audio/basic_time_series_calculators.cc b/mediapipe/calculators/audio/basic_time_series_calculators.cc index e05dde6a0..4d966f47f 100644 --- a/mediapipe/calculators/audio/basic_time_series_calculators.cc +++ b/mediapipe/calculators/audio/basic_time_series_calculators.cc @@ -51,11 +51,11 @@ static bool SafeMultiply(int x, int y, int* result) { ::mediapipe::Status BasicTimeSeriesCalculatorBase::Open(CalculatorContext* cc) { TimeSeriesHeader input_header; - RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( + MP_RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( cc->Inputs().Index(0).Header(), &input_header)); auto output_header = new TimeSeriesHeader(input_header); - RETURN_IF_ERROR(MutateHeader(output_header)); + MP_RETURN_IF_ERROR(MutateHeader(output_header)); cc->Outputs().Index(0).SetHeader(Adopt(output_header)); return ::mediapipe::OkStatus(); } @@ -63,11 +63,11 @@ static bool SafeMultiply(int x, int y, int* result) { ::mediapipe::Status BasicTimeSeriesCalculatorBase::Process( CalculatorContext* cc) { const Matrix& input = cc->Inputs().Index(0).Get(); - RETURN_IF_ERROR(time_series_util::IsMatrixShapeConsistentWithHeader( + MP_RETURN_IF_ERROR(time_series_util::IsMatrixShapeConsistentWithHeader( input, cc->Inputs().Index(0).Header().Get())); std::unique_ptr output(new Matrix(ProcessMatrix(input))); - RETURN_IF_ERROR(time_series_util::IsMatrixShapeConsistentWithHeader( + MP_RETURN_IF_ERROR(time_series_util::IsMatrixShapeConsistentWithHeader( *output, cc->Outputs().Index(0).Header().Get())); cc->Outputs().Index(0).Add(output.release(), cc->InputTimestamp()); diff --git a/mediapipe/calculators/audio/mfcc_mel_calculators.cc b/mediapipe/calculators/audio/mfcc_mel_calculators.cc index 009a63e83..93c44b1fb 100644 --- a/mediapipe/calculators/audio/mfcc_mel_calculators.cc +++ b/mediapipe/calculators/audio/mfcc_mel_calculators.cc @@ -105,7 +105,7 @@ class FramewiseTransformCalculatorBase : public CalculatorBase { ::mediapipe::Status FramewiseTransformCalculatorBase::Open( CalculatorContext* cc) { TimeSeriesHeader input_header; - RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( + MP_RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( cc->Inputs().Index(0).Header(), &input_header)); ::mediapipe::Status status = ConfigureTransform(input_header, cc); diff --git a/mediapipe/calculators/audio/mfcc_mel_calculators_test.cc b/mediapipe/calculators/audio/mfcc_mel_calculators_test.cc index 38727e232..b2ceacf00 100644 --- a/mediapipe/calculators/audio/mfcc_mel_calculators_test.cc +++ b/mediapipe/calculators/audio/mfcc_mel_calculators_test.cc @@ -112,7 +112,7 @@ TEST_F(MfccCalculatorTest, AudioSampleRateFromInputHeader) { SetupGraphAndHeader(); SetupRandomInputPackets(); - MEDIAPIPE_EXPECT_OK(Run()); + MP_EXPECT_OK(Run()); CheckResults(options_.mfcc_count()); } @@ -134,7 +134,7 @@ TEST_F(MelSpectrumCalculatorTest, AudioSampleRateFromInputHeader) { SetupGraphAndHeader(); SetupRandomInputPackets(); - MEDIAPIPE_EXPECT_OK(Run()); + MP_EXPECT_OK(Run()); CheckResults(options_.channel_count()); } diff --git a/mediapipe/calculators/audio/rational_factor_resample_calculator.cc b/mediapipe/calculators/audio/rational_factor_resample_calculator.cc index 6af157a71..3ed67bd88 100644 --- a/mediapipe/calculators/audio/rational_factor_resample_calculator.cc +++ b/mediapipe/calculators/audio/rational_factor_resample_calculator.cc @@ -74,7 +74,7 @@ void CopyVectorToChannel(const std::vector& vec, Matrix* matrix, target_sample_rate_ = resample_options.target_sample_rate(); TimeSeriesHeader input_header; - RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( + MP_RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( cc->Inputs().Index(0).Header(), &input_header)); source_sample_rate_ = input_header.sample_rate(); diff --git a/mediapipe/calculators/audio/rational_factor_resample_calculator_test.cc b/mediapipe/calculators/audio/rational_factor_resample_calculator_test.cc index 38b947517..f21cff516 100644 --- a/mediapipe/calculators/audio/rational_factor_resample_calculator_test.cc +++ b/mediapipe/calculators/audio/rational_factor_resample_calculator_test.cc @@ -209,25 +209,25 @@ class RationalFactorResampleCalculatorTest TEST_F(RationalFactorResampleCalculatorTest, Upsample) { const double kUpsampleRate = input_sample_rate_ * 1.9; - MEDIAPIPE_ASSERT_OK(Run(kUpsampleRate)); + MP_ASSERT_OK(Run(kUpsampleRate)); CheckOutput(kUpsampleRate); } TEST_F(RationalFactorResampleCalculatorTest, Downsample) { const double kDownsampleRate = input_sample_rate_ / 1.9; - MEDIAPIPE_ASSERT_OK(Run(kDownsampleRate)); + MP_ASSERT_OK(Run(kDownsampleRate)); CheckOutput(kDownsampleRate); } TEST_F(RationalFactorResampleCalculatorTest, UsesRationalFactorResampler) { const double kUpsampleRate = input_sample_rate_ * 2; - MEDIAPIPE_ASSERT_OK(Run(kUpsampleRate)); + MP_ASSERT_OK(Run(kUpsampleRate)); CheckOutput(kUpsampleRate); } TEST_F(RationalFactorResampleCalculatorTest, PassthroughIfSampleRateUnchanged) { const double kUpsampleRate = input_sample_rate_; - MEDIAPIPE_ASSERT_OK(Run(kUpsampleRate)); + MP_ASSERT_OK(Run(kUpsampleRate)); CheckOutputUnchanged(); } @@ -239,7 +239,7 @@ TEST_F(RationalFactorResampleCalculatorTest, DoesNotDieOnEmptyInput) { options_.set_target_sample_rate(input_sample_rate_); InitializeGraph(); FillInputHeader(); - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); EXPECT_TRUE(output().packets.empty()); } diff --git a/mediapipe/calculators/audio/spectrogram_calculator.cc b/mediapipe/calculators/audio/spectrogram_calculator.cc index 6415a295b..5f7f20c06 100644 --- a/mediapipe/calculators/audio/spectrogram_calculator.cc +++ b/mediapipe/calculators/audio/spectrogram_calculator.cc @@ -194,7 +194,7 @@ const float SpectrogramCalculator::kLnPowerToDb = 4.342944819032518; } TimeSeriesHeader input_header; - RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( + MP_RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( cc->Inputs().Index(0).Header(), &input_header)); input_sample_rate_ = input_header.sample_rate(); diff --git a/mediapipe/calculators/audio/spectrogram_calculator_test.cc b/mediapipe/calculators/audio/spectrogram_calculator_test.cc index e783f04fa..200bdee11 100644 --- a/mediapipe/calculators/audio/spectrogram_calculator_test.cc +++ b/mediapipe/calculators/audio/spectrogram_calculator_test.cc @@ -303,7 +303,7 @@ TEST_F(SpectrogramCalculatorTest, IntegerFrameDurationNoOverlap) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -324,7 +324,7 @@ TEST_F(SpectrogramCalculatorTest, IntegerFrameDurationSomeOverlap) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -344,7 +344,7 @@ TEST_F(SpectrogramCalculatorTest, NonintegerFrameDurationAndOverlap) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -365,7 +365,7 @@ TEST_F(SpectrogramCalculatorTest, ShortInitialPacketNoOverlap) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -382,7 +382,7 @@ TEST_F(SpectrogramCalculatorTest, TrailingSamplesNoPad) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -399,7 +399,7 @@ TEST_F(SpectrogramCalculatorTest, NoTrailingSamplesWithPad) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -418,7 +418,7 @@ TEST_F(SpectrogramCalculatorTest, TrailingSamplesWithPad) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -435,7 +435,7 @@ TEST_F(SpectrogramCalculatorTest, VeryShortInputWillPad) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -452,7 +452,7 @@ TEST_F(SpectrogramCalculatorTest, VeryShortInputZeroOutputFramesIfNoPad) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -468,7 +468,7 @@ TEST_F(SpectrogramCalculatorTest, DCSignalIsPeakBin) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); const float dc_frequency_hz = 0.0; @@ -486,7 +486,7 @@ TEST_F(SpectrogramCalculatorTest, A440ToneIsPeakBin) { const float tone_frequency_hz = 440.0; SetupCosineInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); int num_output_frames = output().packets[0].Get().cols(); @@ -507,7 +507,7 @@ TEST_F(SpectrogramCalculatorTest, SquaredMagnitudeOutputLooksRight) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_FLOAT_EQ(output().packets[0].Get()(0, 0), @@ -525,7 +525,7 @@ TEST_F(SpectrogramCalculatorTest, DefaultOutputIsSquaredMagnitude) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_FLOAT_EQ(output().packets[0].Get()(0, 0), @@ -543,7 +543,7 @@ TEST_F(SpectrogramCalculatorTest, LinearMagnitudeOutputLooksRight) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_FLOAT_EQ(output().packets[0].Get()(0, 0), @@ -561,7 +561,7 @@ TEST_F(SpectrogramCalculatorTest, DbMagnitudeOutputLooksRight) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_FLOAT_EQ(output().packets[0].Get()(0, 0), @@ -581,7 +581,7 @@ TEST_F(SpectrogramCalculatorTest, OutputScalingLooksRight) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_FLOAT_EQ( @@ -600,7 +600,7 @@ TEST_F(SpectrogramCalculatorTest, ComplexOutputLooksRight) { // Setup packets with DC input (non-zero constant value). SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_FLOAT_EQ(std::norm(output().packets[0].Get()(0, 0)), @@ -623,7 +623,7 @@ TEST_F(SpectrogramCalculatorTest, ComplexOutputLooksRightForImpulses) { // Make two impulse packets offset one sample from each other SetupImpulseInputPackets(input_packet_sizes, input_packet_impulse_offsets); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); const int num_buckets = @@ -671,7 +671,7 @@ TEST_F(SpectrogramCalculatorTest, SquaredMagnitudeOutputLooksRightForNonDC) { const float tone_frequency_hz = target_bin * (input_sample_rate_ / fft_size); SetupCosineInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); // For a non-DC bin, the magnitude will be split between positive and @@ -696,7 +696,7 @@ TEST_F(SpectrogramCalculatorTest, ZeroOutputsForZeroInputsWithPaddingEnabled) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(OutputFramesPerPacket(), expected_output_packet_sizes); @@ -713,7 +713,7 @@ TEST_F(SpectrogramCalculatorTest, NumChannelsIsRight) { FillInputHeader(); const float tone_frequency_hz = 440.0; SetupCosineInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); EXPECT_EQ(output().packets[0].Get>().size(), @@ -732,7 +732,7 @@ TEST_F(SpectrogramCalculatorTest, NumSamplesAndPacketRateAreCleared) { FillInputHeader(); SetupConstantInputPackets(input_packet_sizes); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); const TimeSeriesHeader& output_header = output().header.Get(); @@ -751,7 +751,7 @@ TEST_F(SpectrogramCalculatorTest, MultichannelSpectrogramSizesAreRight) { FillInputHeader(); const float tone_frequency_hz = 440.0; SetupCosineInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); auto spectrograms = output().packets[0].Get>(); @@ -776,7 +776,7 @@ TEST_F(SpectrogramCalculatorTest, MultichannelSpectrogramValuesAreRight) { const float tone_frequency_hz = 440.0; SetupMultichannelInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); auto spectrograms = output().packets[0].Get>(); @@ -805,7 +805,7 @@ TEST_F(SpectrogramCalculatorTest, MultichannelHandlesShortInitialPacket) { FillInputHeader(); const float tone_frequency_hz = 440.0; SetupCosineInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); auto spectrograms = output().packets[0].Get>(); @@ -833,7 +833,7 @@ TEST_F(SpectrogramCalculatorTest, FillInputHeader(); const float tone_frequency_hz = 440.0; SetupCosineInputPackets(input_packet_sizes, tone_frequency_hz); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutputHeadersAndTimestamps(); auto spectrograms = output().packets[0].Get>(); diff --git a/mediapipe/calculators/audio/stabilized_log_calculator.cc b/mediapipe/calculators/audio/stabilized_log_calculator.cc index 817819c1c..50ccc01a0 100644 --- a/mediapipe/calculators/audio/stabilized_log_calculator.cc +++ b/mediapipe/calculators/audio/stabilized_log_calculator.cc @@ -65,7 +65,7 @@ class StabilizedLogCalculator : public CalculatorBase { // If the input packets have a header, propagate the header to the output. if (!cc->Inputs().Index(0).Header().IsEmpty()) { TimeSeriesHeader input_header; - RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( + MP_RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( cc->Inputs().Index(0).Header(), &input_header)); cc->Outputs().Index(0).SetHeader( Adopt(new TimeSeriesHeader(input_header))); diff --git a/mediapipe/calculators/audio/stabilized_log_calculator_test.cc b/mediapipe/calculators/audio/stabilized_log_calculator_test.cc index e7c6d64fe..9831f4fe9 100644 --- a/mediapipe/calculators/audio/stabilized_log_calculator_test.cc +++ b/mediapipe/calculators/audio/stabilized_log_calculator_test.cc @@ -42,7 +42,7 @@ class StabilizedLogCalculatorTest num_input_samples_ = kNumSamples; } - void RunGraphNoReturn() { MEDIAPIPE_ASSERT_OK(RunGraph()); } + void RunGraphNoReturn() { MP_ASSERT_OK(RunGraph()); } }; TEST_F(StabilizedLogCalculatorTest, BasicOperation) { @@ -60,7 +60,7 @@ TEST_F(StabilizedLogCalculatorTest, BasicOperation) { AppendInputPacket(new Matrix(input_data_matrix), timestamp); } - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); ExpectOutputHeaderEqualsInputHeader(); for (int output_packet = 0; output_packet < kNumPackets; ++output_packet) { ExpectApproximatelyEqual( @@ -86,7 +86,7 @@ TEST_F(StabilizedLogCalculatorTest, OutputScaleWorks) { AppendInputPacket(new Matrix(input_data_matrix), timestamp); } - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); ExpectOutputHeaderEqualsInputHeader(); for (int output_packet = 0; output_packet < kNumPackets; ++output_packet) { ExpectApproximatelyEqual( @@ -101,7 +101,7 @@ TEST_F(StabilizedLogCalculatorTest, ZerosAreStabilized) { FillInputHeader(); AppendInputPacket(new Matrix(Matrix::Zero(kNumChannels, kNumSamples)), 0 /* timestamp */); - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); ExpectOutputHeaderEqualsInputHeader(); ExpectApproximatelyEqual( Matrix::Constant(kNumChannels, kNumSamples, kStabilizer).array().log(), @@ -124,7 +124,7 @@ TEST_F(StabilizedLogCalculatorTest, NegativeValuesDoNotCheckFailIfCheckIsOff) { AppendInputPacket( new Matrix(Matrix::Constant(kNumChannels, kNumSamples, -1.0)), 0 /* timestamp */); - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); // Results are undefined. } diff --git a/mediapipe/calculators/audio/time_series_framer_calculator.cc b/mediapipe/calculators/audio/time_series_framer_calculator.cc index 60344f462..34adb5700 100644 --- a/mediapipe/calculators/audio/time_series_framer_calculator.cc +++ b/mediapipe/calculators/audio/time_series_framer_calculator.cc @@ -219,7 +219,7 @@ void TimeSeriesFramerCalculator::FrameOutput(CalculatorContext* cc) { << framer_options.frame_overlap_seconds(); TimeSeriesHeader input_header; - RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( + MP_RETURN_IF_ERROR(time_series_util::FillTimeSeriesHeaderIfValid( cc->Inputs().Index(0).Header(), &input_header)); sample_rate_ = input_header.sample_rate(); diff --git a/mediapipe/calculators/audio/time_series_framer_calculator_test.cc b/mediapipe/calculators/audio/time_series_framer_calculator_test.cc index ec64b2b1a..1a370faa1 100644 --- a/mediapipe/calculators/audio/time_series_framer_calculator_test.cc +++ b/mediapipe/calculators/audio/time_series_framer_calculator_test.cc @@ -226,7 +226,7 @@ class TimeSeriesFramerCalculatorTest TEST_F(TimeSeriesFramerCalculatorTest, IntegerSampleDurationNoOverlap) { options_.set_frame_duration_seconds(100.0 / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutput(); } @@ -234,7 +234,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, IntegerSampleDurationNoOverlapHammingWindow) { options_.set_frame_duration_seconds(100.0 / input_sample_rate_); options_.set_window_function(TimeSeriesFramerCalculatorOptions::HAMMING); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutput(); } @@ -242,14 +242,14 @@ TEST_F(TimeSeriesFramerCalculatorTest, IntegerSampleDurationNoOverlapHannWindow) { options_.set_frame_duration_seconds(100.0 / input_sample_rate_); options_.set_window_function(TimeSeriesFramerCalculatorOptions::HANN); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutput(); } TEST_F(TimeSeriesFramerCalculatorTest, IntegerSampleDurationAndOverlap) { options_.set_frame_duration_seconds(100.0 / input_sample_rate_); options_.set_frame_overlap_seconds(40.0 / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutput(); } @@ -257,7 +257,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, NonintegerSampleDurationAndOverlap) { options_.set_frame_duration_seconds(98.5 / input_sample_rate_); options_.set_frame_overlap_seconds(38.4 / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutput(); } @@ -267,7 +267,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, NegativeOverlapExactFrames) { // the 1100 input samples. options_.set_frame_duration_seconds(100.0 / input_sample_rate_); options_.set_frame_overlap_seconds(-10.0 / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); EXPECT_EQ(output().packets.size(), 10); CheckOutput(); } @@ -277,7 +277,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, NegativeOverlapExactFramesLessSkip) { // the 1100 input samples. options_.set_frame_duration_seconds(100.0 / input_sample_rate_); options_.set_frame_overlap_seconds(-100.0 / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); EXPECT_EQ(output().packets.size(), 6); CheckOutput(); } @@ -287,7 +287,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, NegativeOverlapWithPadding) { // on the sixth and last frame given 1100 sample input. options_.set_frame_duration_seconds(100.0 / input_sample_rate_); options_.set_frame_overlap_seconds(-100.0 / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); EXPECT_EQ(output().packets.size(), 6); CheckOutput(); } @@ -297,7 +297,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, FixedFrameOverlap) { // results in ceil((1100 - 30) / 11) + 1 = 99 packets. options_.set_frame_duration_seconds(30 / input_sample_rate_); options_.set_frame_overlap_seconds((30.0 - 11.4) / input_sample_rate_); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); EXPECT_EQ(output().packets.size(), 99); CheckOutput(); } @@ -308,7 +308,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, VariableFrameOverlap) { options_.set_frame_duration_seconds(30 / input_sample_rate_); options_.set_frame_overlap_seconds((30 - 11.4) / input_sample_rate_); options_.set_emulate_fractional_frame_overlap(true); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); EXPECT_EQ(output().packets.size(), 95); CheckOutput(); } @@ -319,7 +319,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, VariableFrameSkip) { options_.set_frame_duration_seconds(30 / input_sample_rate_); options_.set_frame_overlap_seconds((30 - 41.4) / input_sample_rate_); options_.set_emulate_fractional_frame_overlap(true); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); EXPECT_EQ(output().packets.size(), 27); CheckOutput(); } @@ -328,7 +328,7 @@ TEST_F(TimeSeriesFramerCalculatorTest, NoFinalPacketPadding) { options_.set_frame_duration_seconds(98.5 / input_sample_rate_); options_.set_pad_final_packet(false); - MEDIAPIPE_ASSERT_OK(Run()); + MP_ASSERT_OK(Run()); CheckOutput(); } @@ -369,7 +369,7 @@ class TimeSeriesFramerCalculatorWindowingSanityTest FillInputHeader(); AppendInputPacket(new Matrix(Matrix::Ones(1, FrameDurationSamples())), kInitialTimestampOffsetMicroseconds); - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); ASSERT_EQ(1, output().packets.size()); ASSERT_NEAR(expected_average * FrameDurationSamples(), output().packets[0].Get().sum(), 1e-5); diff --git a/mediapipe/calculators/core/BUILD b/mediapipe/calculators/core/BUILD index 1fd56f153..ebef8127f 100644 --- a/mediapipe/calculators/core/BUILD +++ b/mediapipe/calculators/core/BUILD @@ -76,7 +76,7 @@ mediapipe_cc_proto_library( name = "packet_cloner_calculator_cc_proto", srcs = ["packet_cloner_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":packet_cloner_calculator_proto"], ) @@ -84,7 +84,7 @@ mediapipe_cc_proto_library( name = "packet_resampler_calculator_cc_proto", srcs = ["packet_resampler_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":packet_resampler_calculator_proto"], ) @@ -92,7 +92,7 @@ mediapipe_cc_proto_library( name = "split_vector_calculator_cc_proto", srcs = ["split_vector_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":split_vector_calculator_proto"], ) @@ -108,7 +108,7 @@ mediapipe_cc_proto_library( name = "quantize_float_vector_calculator_cc_proto", srcs = ["quantize_float_vector_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":quantize_float_vector_calculator_proto"], ) @@ -116,7 +116,7 @@ mediapipe_cc_proto_library( name = "sequence_shift_calculator_cc_proto", srcs = ["sequence_shift_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":sequence_shift_calculator_proto"], ) @@ -124,7 +124,7 @@ mediapipe_cc_proto_library( name = "gate_calculator_cc_proto", srcs = ["gate_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":gate_calculator_proto"], ) diff --git a/mediapipe/calculators/core/add_header_calculator_test.cc b/mediapipe/calculators/core/add_header_calculator_test.cc index 206974125..b67cf04dc 100644 --- a/mediapipe/calculators/core/add_header_calculator_test.cc +++ b/mediapipe/calculators/core/add_header_calculator_test.cc @@ -42,7 +42,7 @@ TEST_F(AddHeaderCalculatorTest, Works) { } // Run calculator. - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); ASSERT_EQ(1, runner.Outputs().NumEntries()); @@ -69,7 +69,7 @@ TEST_F(AddHeaderCalculatorTest, HandlesEmptyHeaderStream) { // No header and no packets. // Run calculator. - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_TRUE(runner.Outputs().Index(0).header.IsEmpty()); } diff --git a/mediapipe/calculators/core/concatenate_vector_calculator_test.cc b/mediapipe/calculators/core/concatenate_vector_calculator_test.cc index 89f6976c0..0baceaa26 100644 --- a/mediapipe/calculators/core/concatenate_vector_calculator_test.cc +++ b/mediapipe/calculators/core/concatenate_vector_calculator_test.cc @@ -45,7 +45,7 @@ TEST(TestConcatenateIntVectorCalculatorTest, EmptyVectorInputs) { std::vector> inputs = {{}, {}, {}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(1, outputs.size()); @@ -60,7 +60,7 @@ TEST(TestConcatenateIntVectorCalculatorTest, OneTimestamp) { std::vector> inputs = {{1, 2, 3}, {4}, {5, 6}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(1, outputs.size()); @@ -81,7 +81,7 @@ TEST(TestConcatenateIntVectorCalculatorTest, TwoInputsAtTwoTimestamps) { std::vector> inputs = {{0, 2}, {1}, {3, 5}}; AddInputVectors(inputs, /*timestamp=*/2, &runner); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(2, outputs.size()); @@ -106,7 +106,7 @@ TEST(TestConcatenateIntVectorCalculatorTest, OneEmptyStreamStillOutput) { std::vector> inputs = {{1, 2, 3}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(1, outputs.size()); @@ -125,7 +125,7 @@ TEST(TestConcatenateIntVectorCalculatorTest, OneEmptyStreamNoOutput) { std::vector> inputs = {{1, 2, 3}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(0, outputs.size()); @@ -146,7 +146,7 @@ TEST(ConcatenateFloatVectorCalculatorTest, EmptyVectorInputs) { std::vector> inputs = {{}, {}, {}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(1, outputs.size()); @@ -162,7 +162,7 @@ TEST(ConcatenateFloatVectorCalculatorTest, OneTimestamp) { std::vector> inputs = { {1.0f, 2.0f, 3.0f}, {4.0f}, {5.0f, 6.0f}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(1, outputs.size()); @@ -185,7 +185,7 @@ TEST(ConcatenateFloatVectorCalculatorTest, TwoInputsAtTwoTimestamps) { {0.0f, 2.0f}, {1.0f}, {3.0f, 5.0f}}; AddInputVectors(inputs, /*timestamp=*/2, &runner); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(2, outputs.size()); @@ -210,7 +210,7 @@ TEST(ConcatenateFloatVectorCalculatorTest, OneEmptyStreamStillOutput) { std::vector> inputs = {{1.0f, 2.0f, 3.0f}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(1, outputs.size()); @@ -229,7 +229,7 @@ TEST(ConcatenateFloatVectorCalculatorTest, OneEmptyStreamNoOutput) { std::vector> inputs = {{1.0f, 2.0f, 3.0f}}; AddInputVectors(inputs, /*timestamp=*/1, &runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Index(0).packets; EXPECT_EQ(0, outputs.size()); diff --git a/mediapipe/calculators/core/flow_limiter_calculator_test.cc b/mediapipe/calculators/core/flow_limiter_calculator_test.cc index 23d13ef4b..895c88e6d 100644 --- a/mediapipe/calculators/core/flow_limiter_calculator_test.cc +++ b/mediapipe/calculators/core/flow_limiter_calculator_test.cc @@ -91,7 +91,7 @@ TEST(FlowLimiterCalculator, OneOutputTest) { } // Run the calculator. - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& frame_output_packets = runner.Outputs().Index(0).packets; @@ -117,7 +117,7 @@ TEST(FlowLimiterCalculator, BasicTest) { } // Run the calculator. - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& frame_output_packets = runner.Outputs().Index(0).packets; @@ -198,7 +198,7 @@ class FlowLimiterCalculatorTest : public testing::Test { close_count_++; return ::mediapipe::OkStatus(); }; - MEDIAPIPE_ASSERT_OK(graph_.Initialize( + MP_ASSERT_OK(graph_.Initialize( graph_config_, { {"max_in_flight", MakePacket(max_in_flight)}, {"callback_0", Adopt(new auto(semaphore_0_func))}, @@ -209,7 +209,7 @@ class FlowLimiterCalculatorTest : public testing::Test { // Adds a packet to a graph input stream. void AddPacket(const std::string& input_name, int value) { - MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream( + MP_EXPECT_OK(graph_.AddPacketToInputStream( input_name, MakePacket(value).At(Timestamp(value)))); } @@ -277,10 +277,10 @@ class FlowLimiterCalculatorTest : public testing::Test { // TEST_F(FlowLimiterCalculatorTest, BackEdgeCloses) { InitializeGraph(1); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK(graph_.StartRun({})); auto send_packet = [this](const std::string& input_name, int64 n) { - MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream( + MP_EXPECT_OK(graph_.AddPacketToInputStream( input_name, MakePacket(n).At(Timestamp(n)))); }; @@ -288,14 +288,14 @@ TEST_F(FlowLimiterCalculatorTest, BackEdgeCloses) { send_packet("in_1", i * 10); // This next input should be dropped. send_packet("in_1", i * 10 + 5); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); send_packet("in_2", i * 10); exit_semaphore_.Release(1); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); } - MEDIAPIPE_EXPECT_OK(graph_.CloseInputStream("in_1")); - MEDIAPIPE_EXPECT_OK(graph_.CloseInputStream("in_2")); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.CloseInputStream("in_1")); + MP_EXPECT_OK(graph_.CloseInputStream("in_2")); + MP_EXPECT_OK(graph_.WaitUntilIdle()); // All output streams are closed and all output packets are delivered, // with stream "in_1" and stream "in_2" closed. @@ -321,17 +321,17 @@ TEST_F(FlowLimiterCalculatorTest, BackEdgeCloses) { // input streams are closed after the last input packet has been processed. TEST_F(FlowLimiterCalculatorTest, AllStreamsClose) { InitializeGraph(1); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK(graph_.StartRun({})); exit_semaphore_.Release(10); for (int i = 0; i < 10; i++) { AddPacket("in_1", i); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); AddPacket("in_2", i); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); } - MEDIAPIPE_EXPECT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.CloseAllInputStreams()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(out_1_packets_), TimestampValues(out_2_packets_)); EXPECT_EQ(TimestampValues(out_1_packets_), @@ -371,7 +371,7 @@ TEST(FlowLimiterCalculator, TwoStreams) { }; CalculatorGraph graph_; - MEDIAPIPE_EXPECT_OK(graph_.Initialize( + MP_EXPECT_OK(graph_.Initialize( graph_config_, { {"max_in_flight", MakePacket(1)}, @@ -379,63 +379,63 @@ TEST(FlowLimiterCalculator, TwoStreams) { MakePacket>(allow_cb)}, })); - MEDIAPIPE_EXPECT_OK(graph_.StartRun({})); + MP_EXPECT_OK(graph_.StartRun({})); auto send_packet = [&graph_](const std::string& input_name, int n) { - MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream( + MP_EXPECT_OK(graph_.AddPacketToInputStream( input_name, MakePacket(n).At(Timestamp(n)))); }; send_packet("in_a", 1); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(allow, false); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{})); send_packet("in_a", 2); send_packet("in_b", 1); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1})); EXPECT_EQ(allow, false); send_packet("finished", 1); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1})); EXPECT_EQ(allow, true); send_packet("in_b", 2); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1})); EXPECT_EQ(allow, true); send_packet("in_b", 3); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1, 3})); EXPECT_EQ(allow, false); send_packet("in_b", 4); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1, 3})); EXPECT_EQ(allow, false); send_packet("in_a", 3); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1, 3})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1, 3})); EXPECT_EQ(allow, false); send_packet("finished", 3); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(a_passed), (std::vector{1, 3})); EXPECT_EQ(TimestampValues(b_passed), (std::vector{1, 3})); EXPECT_EQ(allow, true); - MEDIAPIPE_EXPECT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilDone()); + MP_EXPECT_OK(graph_.CloseAllInputStreams()); + MP_EXPECT_OK(graph_.WaitUntilDone()); } TEST(FlowLimiterCalculator, CanConsume) { @@ -465,7 +465,7 @@ TEST(FlowLimiterCalculator, CanConsume) { }; CalculatorGraph graph_; - MEDIAPIPE_EXPECT_OK(graph_.Initialize( + MP_EXPECT_OK(graph_.Initialize( graph_config_, { {"max_in_flight", MakePacket(1)}, @@ -473,21 +473,21 @@ TEST(FlowLimiterCalculator, CanConsume) { MakePacket>(allow_cb)}, })); - MEDIAPIPE_EXPECT_OK(graph_.StartRun({})); + MP_EXPECT_OK(graph_.StartRun({})); auto send_packet = [&graph_](const std::string& input_name, int n) { - MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream( + MP_EXPECT_OK(graph_.AddPacketToInputStream( input_name, MakePacket(n).At(Timestamp(n)))); }; send_packet("in", 1); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(allow, false); EXPECT_EQ(TimestampValues(in_sampled_packets_), (std::vector{1})); - MEDIAPIPE_EXPECT_OK(in_sampled_packets_[0].Consume()); + MP_EXPECT_OK(in_sampled_packets_[0].Consume()); - MEDIAPIPE_EXPECT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilDone()); + MP_EXPECT_OK(graph_.CloseAllInputStreams()); + MP_EXPECT_OK(graph_.WaitUntilDone()); } } // anonymous namespace diff --git a/mediapipe/calculators/core/gate_calculator_test.cc b/mediapipe/calculators/core/gate_calculator_test.cc index e00038879..8a7272416 100644 --- a/mediapipe/calculators/core/gate_calculator_test.cc +++ b/mediapipe/calculators/core/gate_calculator_test.cc @@ -32,7 +32,7 @@ class GateCalculatorTest : public ::testing::Test { ->Tag(control_tag) .packets.push_back(MakePacket(control).At(Timestamp(timestamp))); - MEDIAPIPE_ASSERT_OK(runner_->Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner_->Run()) << "Calculator execution failed."; } void SetRunner(const std::string& proto) { diff --git a/mediapipe/calculators/core/immediate_mux_calculator_test.cc b/mediapipe/calculators/core/immediate_mux_calculator_test.cc index 974113e75..4afe358f2 100644 --- a/mediapipe/calculators/core/immediate_mux_calculator_test.cc +++ b/mediapipe/calculators/core/immediate_mux_calculator_test.cc @@ -217,23 +217,23 @@ class ImmediateMuxCalculatorTest : public ::testing::Test { // Start running the graph. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config_)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(graph_config_)); + MP_ASSERT_OK(graph.StartRun({})); // Send each packet to the graph in the specified order. for (int t = 0; t < input_sets.size(); t++) { const std::vector& input_set = input_sets[t]; - MEDIAPIPE_EXPECT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.WaitUntilIdle()); for (int i = 0; i < input_set.size(); i++) { const Packet& packet = input_set[i]; if (!IsNone(packet)) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( absl::StrCat("input_packets_", i), packet)); } } } - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); } CalculatorGraphConfig graph_config_; @@ -335,22 +335,22 @@ TEST_F(ImmediateMuxCalculatorTest, Demux) { // Start the graph and add five input packets. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize( - graph_config_, { - {"callback_0", Adopt(new auto(wait_0))}, - {"callback_1", Adopt(new auto(wait_1))}, - })); - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream("output_packets_0", out_cb)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_EXPECT_OK( + MP_ASSERT_OK(graph.Initialize(graph_config_, + { + {"callback_0", Adopt(new auto(wait_0))}, + {"callback_1", Adopt(new auto(wait_1))}, + })); + MP_ASSERT_OK(graph.ObserveOutputStream("output_packets_0", out_cb)); + MP_ASSERT_OK(graph.StartRun({})); + MP_EXPECT_OK( graph.AddPacketToInputStream("input_packets_0", PacketAt(10000))); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("input_packets_0", PacketAt(20000))); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("input_packets_0", PacketAt(30000))); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("input_packets_0", PacketAt(40000))); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("input_packets_0", PacketAt(50000))); // Release the outputs in order 20000, 10000, 30000, 50000, 40000. @@ -362,8 +362,8 @@ TEST_F(ImmediateMuxCalculatorTest, Demux) { semaphore_0.Release(1); // 50000 wait_for([&] { return out_packets.size() >= 3; }); semaphore_1.Release(1); // 40000 - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); // Output packets 10000 and 40000 are superseded and dropped. EXPECT_THAT(TimestampValues(out_packets), ElementsAre(20000, 30000, 50000)); diff --git a/mediapipe/calculators/core/matrix_multiply_calculator_test.cc b/mediapipe/calculators/core/matrix_multiply_calculator_test.cc index 7c519d444..e62ca8073 100644 --- a/mediapipe/calculators/core/matrix_multiply_calculator_test.cc +++ b/mediapipe/calculators/core/matrix_multiply_calculator_test.cc @@ -219,7 +219,7 @@ TEST(MatrixMultiplyCalculatorTest, Multiply) { Adopt(sample).At(Timestamp(i))); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_EQ(runner.MutableInputs()->Index(0).packets.size(), runner.Outputs().Index(0).packets.size()); diff --git a/mediapipe/calculators/core/matrix_subtract_calculator_test.cc b/mediapipe/calculators/core/matrix_subtract_calculator_test.cc index edba5f116..162d10e0c 100644 --- a/mediapipe/calculators/core/matrix_subtract_calculator_test.cc +++ b/mediapipe/calculators/core/matrix_subtract_calculator_test.cc @@ -112,7 +112,7 @@ TEST(MatrixSubtractCalculatorTest, SubtractFromInput) { runner.MutableInputs()->Tag("MINUEND").packets.push_back( Adopt(input_matrix).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_EQ(1, runner.Outputs().Index(0).packets.size()); EXPECT_EQ(Timestamp(0), runner.Outputs().Index(0).packets[0].Timestamp()); @@ -142,7 +142,7 @@ TEST(MatrixSubtractCalculatorTest, SubtractFromSideMatrix) { ->Tag("SUBTRAHEND") .packets.push_back(Adopt(input_matrix).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_EQ(1, runner.Outputs().Index(0).packets.size()); EXPECT_EQ(Timestamp(0), runner.Outputs().Index(0).packets[0].Timestamp()); diff --git a/mediapipe/calculators/core/matrix_to_vector_calculator_test.cc b/mediapipe/calculators/core/matrix_to_vector_calculator_test.cc index 08a548ad0..1f994cbed 100644 --- a/mediapipe/calculators/core/matrix_to_vector_calculator_test.cc +++ b/mediapipe/calculators/core/matrix_to_vector_calculator_test.cc @@ -67,7 +67,7 @@ TEST_F(MatrixToVectorCalculatorTest, SingleRow) { SetInputHeader(1, 4); // 1 channel x 4 samples const std::vector& data_vector = {1.0, 2.0, 3.0, 4.0}; AppendInput(data_vector, 0); - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); CheckOutputPacket(0, data_vector); } @@ -79,7 +79,7 @@ TEST_F(MatrixToVectorCalculatorTest, RegularMatrix) { 5.0, 6.0, 7.0, 8.0}; AppendInput(data_vector, 0); - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); CheckOutputPacket(0, data_vector); } diff --git a/mediapipe/calculators/core/merge_calculator_test.cc b/mediapipe/calculators/core/merge_calculator_test.cc index 53185c0d8..aeaa4273e 100644 --- a/mediapipe/calculators/core/merge_calculator_test.cc +++ b/mediapipe/calculators/core/merge_calculator_test.cc @@ -78,7 +78,7 @@ TEST(MediaPipeDetectionToSoapboxDetectionCalculatorTest, runner.MutableInputs()->Index(1).packets.push_back( Adopt(new float(35.5)).At(Timestamp(35))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // Expected combined_output: 5.5, 10, 20, 30, 35.5 at times 5, 10, 20, 30, 35. const std::vector& actual_output = runner.Outputs().Index(0).packets; @@ -120,7 +120,7 @@ TEST(MediaPipeDetectionToSoapboxDetectionCalculatorTest, runner.MutableInputs()->Index(2).packets.push_back( Adopt(new char('c')).At(Timestamp(10))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // Expected combined_output: 'c', 20.5, 30 at times 10, 20, 30. const std::vector& actual_output = runner.Outputs().Index(0).packets; diff --git a/mediapipe/calculators/core/packet_inner_join_calculator_test.cc b/mediapipe/calculators/core/packet_inner_join_calculator_test.cc index 8eed9a3e6..4f4d9884c 100644 --- a/mediapipe/calculators/core/packet_inner_join_calculator_test.cc +++ b/mediapipe/calculators/core/packet_inner_join_calculator_test.cc @@ -37,7 +37,7 @@ TEST(PacketInnerJoinCalculatorTest, AllMatching) { for (int packet_load : packets_on_stream2) { runner.MutableInputs()->Index(1).packets.push_back(PacketFrom(packet_load)); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // Check. const std::vector expected = {0, 1, 2, 3}; ASSERT_EQ(expected.size(), runner.Outputs().Index(0).packets.size()); @@ -64,7 +64,7 @@ TEST(PacketInnerJoinCalculatorTest, NoneMatching) { for (int packet_load : packets_on_stream2) { runner.MutableInputs()->Index(1).packets.push_back(PacketFrom(packet_load)); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // Check. EXPECT_TRUE(runner.Outputs().Index(0).packets.empty()); EXPECT_TRUE(runner.Outputs().Index(1).packets.empty()); @@ -82,7 +82,7 @@ TEST(PacketInnerJoinCalculatorTest, SomeMatching) { for (int packet_load : packets_on_stream2) { runner.MutableInputs()->Index(1).packets.push_back(PacketFrom(packet_load)); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // Check. const std::vector expected = {0, 2, 4, 6}; ASSERT_EQ(expected.size(), runner.Outputs().Index(0).packets.size()); diff --git a/mediapipe/calculators/core/packet_resampler_calculator.cc b/mediapipe/calculators/core/packet_resampler_calculator.cc index 5b851e874..4271435fd 100644 --- a/mediapipe/calculators/core/packet_resampler_calculator.cc +++ b/mediapipe/calculators/core/packet_resampler_calculator.cc @@ -287,9 +287,9 @@ TimestampDiff TimestampDiffFromSeconds(double seconds) { } } if (jitter_ != 0.0 && random_ != nullptr) { - RETURN_IF_ERROR(ProcessWithJitter(cc)); + MP_RETURN_IF_ERROR(ProcessWithJitter(cc)); } else { - RETURN_IF_ERROR(ProcessWithoutJitter(cc)); + MP_RETURN_IF_ERROR(ProcessWithoutJitter(cc)); } last_packet_ = cc->Inputs().Get(input_data_id_).Value(); return ::mediapipe::OkStatus(); diff --git a/mediapipe/calculators/core/packet_resampler_calculator_test.cc b/mediapipe/calculators/core/packet_resampler_calculator_test.cc index c7be91439..786e1e069 100644 --- a/mediapipe/calculators/core/packet_resampler_calculator_test.cc +++ b/mediapipe/calculators/core/packet_resampler_calculator_test.cc @@ -103,7 +103,7 @@ TEST(PacketResamplerCalculatorTest, NoPacketsInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); } } @@ -114,7 +114,7 @@ TEST(PacketResamplerCalculatorTest, SinglePacketInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0}, {0}); } @@ -124,7 +124,7 @@ TEST(PacketResamplerCalculatorTest, SinglePacketInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({1000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({1000}, {1000}); } @@ -134,7 +134,7 @@ TEST(PacketResamplerCalculatorTest, SinglePacketInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({16668}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({16668}, {16668}); } } @@ -146,7 +146,7 @@ TEST(PacketResamplerCalculatorTest, TwoPacketsInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 16666}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0}, {0}); } @@ -156,7 +156,7 @@ TEST(PacketResamplerCalculatorTest, TwoPacketsInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 16667}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 16667}, {0, 33333}); } @@ -166,7 +166,7 @@ TEST(PacketResamplerCalculatorTest, TwoPacketsInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 49999}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 49999}, {0, 33333}); } @@ -176,7 +176,7 @@ TEST(PacketResamplerCalculatorTest, TwoPacketsInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 50000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 0, 50000}, {0, 33333, 66667}); } @@ -186,7 +186,7 @@ TEST(PacketResamplerCalculatorTest, TwoPacketsInStream) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({2000, 118666}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({2000, 2000, 2000, 118666}, {2000, 35333, 68667, 102000}); } @@ -197,7 +197,7 @@ TEST(PacketResamplerCalculatorTest, InputAtExactFrequencyMiddlepoints) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 33333, 66667, 100000, 133333, 166667, 200000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps( {0, 33333, 66667, 100000, 133333, 166667, 200000}, {0, 33333, 66667, 100000, 133333, 166667, 200000}); @@ -210,7 +210,7 @@ TEST(PacketResamplerCalculatorTest, MultiplePacketsForPeriods) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 16666, 16667, 20000, 33300, 49999, 50000, 66600}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 33300, 66600}, {0, 33333, 66667}); } @@ -222,7 +222,7 @@ TEST(PacketResamplerCalculatorTest, FillPeriodsWithLatestPacket) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 5000, 16666, 83334}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 16666, 16666, 83334}, {0, 33333, 66667, 100000}); } @@ -232,7 +232,7 @@ TEST(PacketResamplerCalculatorTest, FillPeriodsWithLatestPacket) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 16666, 16667, 25000, 33000, 35000, 135000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 33000, 35000, 35000, 135000}, {0, 33333, 66667, 100000, 133333}); } @@ -242,7 +242,7 @@ TEST(PacketResamplerCalculatorTest, FillPeriodsWithLatestPacket) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({0, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 32000, 49999, 49999, 49999, 150000}, {0, 33333, 66667, 100000, 133333, 166667}); } @@ -255,7 +255,7 @@ TEST(PacketResamplerCalculatorTest, SuperHighFrameRate) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:500000}"); runner.SetInput({0, 10, 13}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 0, 0, 0, 0, 10, 10, 13}, {0, 2, 4, 6, 8, 10, 12, 14}); } @@ -266,7 +266,7 @@ TEST(PacketResamplerCalculatorTest, SuperHighFrameRate) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:1000000}"); runner.SetInput({0, 10, 13}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps( {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 13}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}); @@ -280,7 +280,7 @@ TEST(PacketResamplerCalculatorTest, NegativeTimestampTest) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({-200, -20, 16466}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-200}, {-200}); } @@ -290,7 +290,7 @@ TEST(PacketResamplerCalculatorTest, NegativeTimestampTest) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({-200, -20, 16467}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-200, 16467}, {-200, 33133}); } @@ -300,7 +300,7 @@ TEST(PacketResamplerCalculatorTest, NegativeTimestampTest) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({-500, 66667}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-500, -500, 66667}, {-500, 32833, 66167}); } @@ -310,7 +310,7 @@ TEST(PacketResamplerCalculatorTest, NegativeTimestampTest) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({-50000, -33334, 33334}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-50000, -33334, -33334, 33334}, {-50000, -16667, 16667, 50000}); } @@ -323,7 +323,7 @@ TEST(PacketResamplerCalculatorTest, ExactFramesPerSecond) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:50}"); runner.SetInput({0, 9999, 29999}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 29999}, {0, 20000}); } @@ -333,7 +333,7 @@ TEST(PacketResamplerCalculatorTest, ExactFramesPerSecond) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:50}"); runner.SetInput({0, 10000, 50000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 10000, 10000, 50000}, {0, 20000, 40000, 60000}); } @@ -347,7 +347,7 @@ TEST(PacketResamplerCalculatorTest, FrameRateTest) { "{frame_rate:50, output_header:UPDATE_VIDEO_HEADER}"); runner.SetInput({0, 10000, 30000, 50000, 60000}); runner.SetVideoHeader(50.0); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 10000, 30000, 60000}, {0, 20000, 40000, 60000}); runner.CheckVideoHeader(50.0); @@ -360,7 +360,7 @@ TEST(PacketResamplerCalculatorTest, FrameRateTest) { "{frame_rate:50, output_header:UPDATE_VIDEO_HEADER}"); runner.SetInput({0, 5000, 10010, 15001, 19990}); runner.SetVideoHeader(200.0); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 19990}, {0, 20000}); runner.CheckVideoHeader(50.0); } @@ -372,7 +372,7 @@ TEST(PacketResamplerCalculatorTest, FrameRateTest) { "{frame_rate:50, output_header:PASS_HEADER}"); runner.SetInput({0, 5000, 10010, 15001, 19990}); runner.SetVideoHeader(200.0); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({0, 19990}, {0, 20000}); runner.CheckVideoHeader(200.0); } @@ -404,7 +404,7 @@ TEST(PacketResamplerCalculatorTest, SetVideoHeader) { ->Tag("VIDEO_HEADER") .packets.push_back( Adopt(new VideoHeader(video_header_in)).At(Timestamp::PreStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); ASSERT_EQ(1, runner.Outputs().Tag("VIDEO_HEADER").packets.size()); EXPECT_EQ(Timestamp::PreStream(), @@ -424,7 +424,7 @@ TEST(PacketResamplerCalculatorTest, FlushLastPacketWithoutRound) { frame_rate: 1 })"); runner.SetInput({0, 333333, 666667, 1000000, 1333333}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // 1333333 is not emitted as 2000000, because it does not round to 2000000. runner.CheckOutputTimestamps({0, 1000000}, {0, 1000000}); } @@ -435,7 +435,7 @@ TEST(PacketResamplerCalculatorTest, FlushLastPacketWithRound) { frame_rate: 1 })"); runner.SetInput({0, 333333, 666667, 1000000, 1333333, 1666667}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // 1666667 is emitted as 2000000, because it rounds to 2000000. runner.CheckOutputTimestamps({0, 1000000, 1666667}, {0, 1000000, 2000000}); } @@ -447,7 +447,7 @@ TEST(PacketResamplerCalculatorTest, DoNotFlushLastPacketWithoutRound) { flush_last_packet: false })"); runner.SetInput({0, 333333, 666667, 1000000, 1333333}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // 1333333 is not emitted no matter what; see FlushLastPacketWithoutRound. runner.CheckOutputTimestamps({0, 1000000}, {0, 1000000}); } @@ -459,7 +459,7 @@ TEST(PacketResamplerCalculatorTest, DoNotFlushLastPacketWithRound) { flush_last_packet: false })"); runner.SetInput({0, 333333, 666667, 1000000, 1333333, 1666667}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); // 1666667 is not emitted due to flush_last_packet: false. runner.CheckOutputTimestamps({0, 1000000}, {0, 1000000}); } @@ -473,7 +473,7 @@ TEST(PacketResamplerCalculatorTest, InputAtExactFrequencyMiddlepointsAligned) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({33111, 66667, 100000, 133333, 166667, 200000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({33111, 66667, 100000, 133333, 166667, 200000}, {33111, 66444, 99778, 133111, 166444, 199778}); } @@ -484,7 +484,7 @@ TEST(PacketResamplerCalculatorTest, InputAtExactFrequencyMiddlepointsAligned) { "{frame_rate:30 " "base_timestamp:0}"); runner.SetInput({33111, 66667, 100000, 133333, 166667, 200000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps( {33111, 66667, 100000, 133333, 166667, 200000}, {33333, 66666, 100000, 133333, 166666, 200000}); @@ -499,7 +499,7 @@ TEST(PacketResamplerCalculatorTest, MultiplePacketsForPeriodsAligned) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({-222, 16666, 16667, 20000, 33300, 49999, 50000, 66600}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-222, 33300, 66600}, {-222, 33111, 66445}); } { @@ -509,7 +509,7 @@ TEST(PacketResamplerCalculatorTest, MultiplePacketsForPeriodsAligned) { "{frame_rate:30 " "base_timestamp:900011}"); runner.SetInput({-222, 16666, 16667, 20000, 33300, 49999, 50000, 66600}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-222, 33300, 66600}, {11, 33344, 66678}); } { @@ -521,7 +521,7 @@ TEST(PacketResamplerCalculatorTest, MultiplePacketsForPeriodsAligned) { "base_timestamp:11}"); runner.SetInput( {899888, 916666, 916667, 920000, 933300, 949999, 950000, 966600}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({899888, 933300, 966600}, {900011, 933344, 966678}); } @@ -536,7 +536,7 @@ TEST(PacketResamplerCalculatorTest, FillPeriodsWithLatestPacketAligned) { "[mediapipe.PacketResamplerCalculatorOptions.ext]: " "{frame_rate:30}"); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-222, 32000, 49999, 49999, 49999, 150000}, {-222, 33111, 66445, 99778, 133111, 166445}); } @@ -547,7 +547,7 @@ TEST(PacketResamplerCalculatorTest, FillPeriodsWithLatestPacketAligned) { "{frame_rate:30 " "base_timestamp:0}"); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-222, 32000, 49999, 49999, 49999, 150000}, {0, 33333, 66667, 100000, 133333, 166667}); } @@ -565,7 +565,7 @@ TEST(PacketResamplerCalculatorTest, FirstInputAfterMiddlepointAligned) { "{frame_rate:30 " "base_timestamp:0}"); runner.SetInput({66667, 100020, 133333, 166667}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({66667, 100020, 133333, 166667}, {66667, 100000, 133334, 166667}); } @@ -582,7 +582,7 @@ TEST(PacketResamplerCalculatorTest, FirstInputAfterMiddlepointAligned) { "{frame_rate:30 " "base_timestamp:0}"); runner.SetInput({100020, 133333, 166667}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({100020, 133333, 166667}, {100000, 133333, 166667}); } @@ -596,7 +596,7 @@ TEST(PacketResamplerCalculatorTest, OutputTimestampRangeAligned) { "{frame_rate:30 " "base_timestamp:0}"); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({-222, 32000, 49999, 49999, 49999, 150000}, {0, 33333, 66667, 100000, 133333, 166667}); } @@ -609,7 +609,7 @@ TEST(PacketResamplerCalculatorTest, OutputTimestampRangeAligned) { "start_time:40000 " "end_time:160000}"); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({49999, 49999, 49999}, {66667, 100000, 133333}); } @@ -624,7 +624,7 @@ TEST(PacketResamplerCalculatorTest, OutputTimestampRangeAligned) { "end_time:160000 " "round_limits:true}"); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); runner.CheckOutputTimestamps({32000, 49999, 49999, 49999, 150000}, {33333, 66667, 100000, 133333, 166667}); } @@ -654,7 +654,7 @@ TEST(PacketResamplerCalculatorTest, OptionsSidePacket) { })")); runner.MutableSidePackets()->Tag("OPTIONS") = Adopt(options); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_EQ(6, runner.Outputs().Index(0).packets.size()); } { @@ -670,7 +670,7 @@ TEST(PacketResamplerCalculatorTest, OptionsSidePacket) { runner.MutableSidePackets()->Tag("OPTIONS") = Adopt(options); runner.SetInput({-222, 15000, 32000, 49999, 150000}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_EQ(6, runner.Outputs().Index(0).packets.size()); } } diff --git a/mediapipe/calculators/core/previous_loopback_calculator_test.cc b/mediapipe/calculators/core/previous_loopback_calculator_test.cc index 1dc359ba1..6ad569865 100644 --- a/mediapipe/calculators/core/previous_loopback_calculator_test.cc +++ b/mediapipe/calculators/core/previous_loopback_calculator_test.cc @@ -74,11 +74,11 @@ TEST(PreviousLoopbackCalculator, CorrectTimestamps) { tool::AddVectorSink("pair", &graph_config_, &in_prev); CalculatorGraph graph_; - MEDIAPIPE_ASSERT_OK(graph_.Initialize(graph_config_, {})); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK(graph_.Initialize(graph_config_, {})); + MP_ASSERT_OK(graph_.StartRun({})); auto send_packet = [&graph_](const std::string& input_name, int n) { - MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream( + MP_EXPECT_OK(graph_.AddPacketToInputStream( input_name, MakePacket(n).At(Timestamp(n)))); }; auto pair_values = [](const Packet& packet) { @@ -89,22 +89,22 @@ TEST(PreviousLoopbackCalculator, CorrectTimestamps) { }; send_packet("in", 1); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(in_prev), (std::vector{1})); EXPECT_EQ(pair_values(in_prev.back()), std::make_pair(1, -1)); send_packet("in", 5); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(in_prev), (std::vector{1, 5})); EXPECT_EQ(pair_values(in_prev.back()), std::make_pair(5, 1)); send_packet("in", 15); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilIdle()); + MP_EXPECT_OK(graph_.WaitUntilIdle()); EXPECT_EQ(TimestampValues(in_prev), (std::vector{1, 5, 15})); EXPECT_EQ(pair_values(in_prev.back()), std::make_pair(15, 5)); - MEDIAPIPE_EXPECT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_EXPECT_OK(graph_.WaitUntilDone()); + MP_EXPECT_OK(graph_.CloseAllInputStreams()); + MP_EXPECT_OK(graph_.WaitUntilDone()); } } // anonymous namespace diff --git a/mediapipe/calculators/core/quantize_float_vector_calculator_test.cc b/mediapipe/calculators/core/quantize_float_vector_calculator_test.cc index c5566297e..46f397688 100644 --- a/mediapipe/calculators/core/quantize_float_vector_calculator_test.cc +++ b/mediapipe/calculators/core/quantize_float_vector_calculator_test.cc @@ -124,7 +124,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestEmptyVector) { ->Tag("FLOAT_VECTOR") .packets.push_back( MakePacket>(empty_vector).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Tag("ENCODED").packets; EXPECT_EQ(1, outputs.size()); EXPECT_TRUE(outputs[0].Get().empty()); @@ -150,7 +150,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestNonEmptyVector) { ->Tag("FLOAT_VECTOR") .packets.push_back( MakePacket>(vector).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Tag("ENCODED").packets; EXPECT_EQ(1, outputs.size()); const std::string& result = outputs[0].Get(); @@ -188,7 +188,7 @@ TEST(QuantizeFloatVectorCalculatorTest, TestSaturation) { ->Tag("FLOAT_VECTOR") .packets.push_back( MakePacket>(vector).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& outputs = runner.Outputs().Tag("ENCODED").packets; EXPECT_EQ(1, outputs.size()); const std::string& result = outputs[0].Get(); diff --git a/mediapipe/calculators/core/sequence_shift_calculator_test.cc b/mediapipe/calculators/core/sequence_shift_calculator_test.cc index 0466fe3b1..1fee61daa 100644 --- a/mediapipe/calculators/core/sequence_shift_calculator_test.cc +++ b/mediapipe/calculators/core/sequence_shift_calculator_test.cc @@ -38,7 +38,7 @@ TEST(SequenceShiftCalculatorTest, ZeroShift) { "[mediapipe.SequenceShiftCalculatorOptions.ext]: { packet_offset: 0 }", 1, 1, 0); AddPackets(&runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& input_packets = runner.MutableInputs()->Index(0).packets; const std::vector& output_packets = runner.Outputs().Index(0).packets; @@ -59,7 +59,7 @@ TEST(SequenceShiftCalculatorTest, PositiveShift) { "[mediapipe.SequenceShiftCalculatorOptions.ext]: { packet_offset: 3 }", 1, 1, 0); AddPackets(&runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& input_packets = runner.MutableInputs()->Index(0).packets; const std::vector& output_packets = runner.Outputs().Index(0).packets; @@ -83,7 +83,7 @@ TEST(SequenceShiftCalculatorTest, NegativeShift) { "[mediapipe.SequenceShiftCalculatorOptions.ext]: { packet_offset: -2 }", 1, 1, 0); AddPackets(&runner); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const std::vector& input_packets = runner.MutableInputs()->Index(0).packets; const std::vector& output_packets = runner.Outputs().Index(0).packets; diff --git a/mediapipe/calculators/core/split_vector_calculator_test.cc b/mediapipe/calculators/core/split_vector_calculator_test.cc index 939783f3e..4187e8aba 100644 --- a/mediapipe/calculators/core/split_vector_calculator_test.cc +++ b/mediapipe/calculators/core/split_vector_calculator_test.cc @@ -161,12 +161,12 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTest) { // Run the graph. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.Initialize(graph_config)); + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "tensor_in", Adopt(input_vec_.release()).At(Timestamp(0)))); // Wait until the calculator finishes processing. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ValidateVectorOutput(range_0_packets, /*expected_elements=*/1, /*input_begin_index=*/0); @@ -176,8 +176,8 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTest) { /*input_begin_index=*/4); // Fully close the graph at the end. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("tensor_in")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("tensor_in")); + MP_ASSERT_OK(graph.WaitUntilDone()); } TEST_F(SplitTfLiteTensorVectorCalculatorTest, InvalidRangeTest) { @@ -270,12 +270,12 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTestElementOnly) { // Run the graph. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.Initialize(graph_config)); + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "tensor_in", Adopt(input_vec_.release()).At(Timestamp(0)))); // Wait until the calculator finishes processing. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ValidateElementOutput(range_0_packets, /*input_begin_index=*/0); @@ -285,8 +285,8 @@ TEST_F(SplitTfLiteTensorVectorCalculatorTest, SmokeTestElementOnly) { /*input_begin_index=*/4); // Fully close the graph at the end. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("tensor_in")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("tensor_in")); + MP_ASSERT_OK(graph.WaitUntilDone()); } TEST_F(SplitTfLiteTensorVectorCalculatorTest, diff --git a/mediapipe/calculators/image/BUILD b/mediapipe/calculators/image/BUILD index 070150c7f..3773a2180 100644 --- a/mediapipe/calculators/image/BUILD +++ b/mediapipe/calculators/image/BUILD @@ -81,7 +81,7 @@ mediapipe_cc_proto_library( name = "opencv_image_encoder_calculator_cc_proto", srcs = ["opencv_image_encoder_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":opencv_image_encoder_calculator_proto"], ) @@ -89,7 +89,7 @@ mediapipe_cc_proto_library( name = "mask_overlay_calculator_cc_proto", srcs = ["mask_overlay_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":mask_overlay_calculator_proto"], ) @@ -100,7 +100,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/framework/formats:image_format_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":scale_image_calculator_proto"], ) @@ -110,7 +110,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":set_alpha_calculator_proto"], ) @@ -120,17 +120,17 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":image_cropping_calculator_proto"], ) mediapipe_cc_proto_library( name = "bilateral_filter_calculator_cc_proto", srcs = ["bilateral_filter_calculator.proto"], - cc_deps = [ - "//mediapipe/framework:calculator_cc_proto", + cc_deps = ["//mediapipe/framework:calculator_cc_proto"], + visibility = [ + "//visibility:public", ], - visibility = ["//mediapipe:__subpackages__"], deps = [":bilateral_filter_calculator_proto"], ) @@ -141,7 +141,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/util:color_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":recolor_calculator_proto"], ) @@ -291,7 +291,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/gpu:scale_mode_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":image_transformation_calculator_proto"], ) diff --git a/mediapipe/calculators/image/bilateral_filter_calculator.cc b/mediapipe/calculators/image/bilateral_filter_calculator.cc index b8b6a88f5..0adb9390a 100644 --- a/mediapipe/calculators/image/bilateral_filter_calculator.cc +++ b/mediapipe/calculators/image/bilateral_filter_calculator.cc @@ -153,7 +153,7 @@ REGISTER_CALCULATOR(BilateralFilterCalculator); } #if defined(__ANDROID__) || defined(__EMSCRIPTEN__) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ || __EMSCRIPTEN__ return ::mediapipe::OkStatus(); @@ -181,7 +181,7 @@ REGISTER_CALCULATOR(BilateralFilterCalculator); if (use_gpu_) { #if defined(__ANDROID__) || defined(__EMSCRIPTEN__) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #endif } @@ -191,18 +191,18 @@ REGISTER_CALCULATOR(BilateralFilterCalculator); ::mediapipe::Status BilateralFilterCalculator::Process(CalculatorContext* cc) { if (use_gpu_) { #if defined(__ANDROID__) || defined(__EMSCRIPTEN__) - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status { if (!gpu_initialized_) { - RETURN_IF_ERROR(GlSetup(cc)); + MP_RETURN_IF_ERROR(GlSetup(cc)); gpu_initialized_ = true; } - RETURN_IF_ERROR(RenderGpu(cc)); + MP_RETURN_IF_ERROR(RenderGpu(cc)); return ::mediapipe::OkStatus(); })); #endif // __ANDROID__ || __EMSCRIPTEN__ } else { - RETURN_IF_ERROR(RenderCpu(cc)); + MP_RETURN_IF_ERROR(RenderCpu(cc)); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/calculators/image/image_cropping_calculator.cc b/mediapipe/calculators/image/image_cropping_calculator.cc index c0a7894ba..b893cd260 100644 --- a/mediapipe/calculators/image/image_cropping_calculator.cc +++ b/mediapipe/calculators/image/image_cropping_calculator.cc @@ -131,7 +131,7 @@ REGISTER_CALCULATOR(ImageCroppingCalculator); } #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ or iOS return ::mediapipe::OkStatus(); @@ -148,7 +148,7 @@ REGISTER_CALCULATOR(ImageCroppingCalculator); if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #else RET_CHECK_FAIL() << "GPU processing is for Android and iOS only."; #endif // __ANDROID__ or iOS @@ -160,18 +160,18 @@ REGISTER_CALCULATOR(ImageCroppingCalculator); ::mediapipe::Status ImageCroppingCalculator::Process(CalculatorContext* cc) { if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status { if (!gpu_initialized_) { - RETURN_IF_ERROR(InitGpu(cc)); + MP_RETURN_IF_ERROR(InitGpu(cc)); gpu_initialized_ = true; } - RETURN_IF_ERROR(RenderGpu(cc)); + MP_RETURN_IF_ERROR(RenderGpu(cc)); return ::mediapipe::OkStatus(); })); #endif // __ANDROID__ or iOS } else { - RETURN_IF_ERROR(RenderCpu(cc)); + MP_RETURN_IF_ERROR(RenderCpu(cc)); } return ::mediapipe::OkStatus(); } diff --git a/mediapipe/calculators/image/image_transformation_calculator.cc b/mediapipe/calculators/image/image_transformation_calculator.cc index 233bb1ab7..c2d894547 100644 --- a/mediapipe/calculators/image/image_transformation_calculator.cc +++ b/mediapipe/calculators/image/image_transformation_calculator.cc @@ -213,7 +213,7 @@ REGISTER_CALCULATOR(ImageTransformationCalculator); } #if defined(__ANDROID__) || defined(__APPLE__) && !TARGET_OS_OSX - RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ || iOS return ::mediapipe::OkStatus(); @@ -252,7 +252,7 @@ REGISTER_CALCULATOR(ImageTransformationCalculator); if (use_gpu_) { #if defined(__ANDROID__) || defined(__APPLE__) && !TARGET_OS_OSX // Let the helper access the GL context information. - RETURN_IF_ERROR(helper_.Open(cc)); + MP_RETURN_IF_ERROR(helper_.Open(cc)); #else RET_CHECK_FAIL() << "GPU processing is for Android and iOS only."; #endif // __ANDROID__ || iOS @@ -398,7 +398,7 @@ REGISTER_CALCULATOR(ImageTransformationCalculator); input.format() == GpuBufferFormat::kBiPlanar420YpCbCr8FullRange) { if (!yuv_renderer_) { yuv_renderer_ = absl::make_unique(); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( yuv_renderer_->GlSetup(::mediapipe::kYUV2TexToRGBFragmentShader, {"video_frame_y", "video_frame_uv"})); } @@ -412,7 +412,7 @@ REGISTER_CALCULATOR(ImageTransformationCalculator); if (src1.target() == GL_TEXTURE_EXTERNAL_OES) { if (!ext_rgb_renderer_) { ext_rgb_renderer_ = absl::make_unique(); - RETURN_IF_ERROR(ext_rgb_renderer_->GlSetup( + MP_RETURN_IF_ERROR(ext_rgb_renderer_->GlSetup( ::mediapipe::kBasicTexturedFragmentShaderOES, {"video_frame"})); } renderer = ext_rgb_renderer_.get(); @@ -421,7 +421,7 @@ REGISTER_CALCULATOR(ImageTransformationCalculator); { if (!rgb_renderer_) { rgb_renderer_ = absl::make_unique(); - RETURN_IF_ERROR(rgb_renderer_->GlSetup()); + MP_RETURN_IF_ERROR(rgb_renderer_->GlSetup()); } renderer = rgb_renderer_.get(); } @@ -446,7 +446,7 @@ REGISTER_CALCULATOR(ImageTransformationCalculator); glActiveTexture(GL_TEXTURE1); glBindTexture(src1.target(), src1.name()); - RETURN_IF_ERROR(renderer->GlRender( + MP_RETURN_IF_ERROR(renderer->GlRender( src1.width(), src1.height(), dst.width(), dst.height(), scale_mode, rotation, options_.flip_horizontally(), options_.flip_vertically(), /*flip_texture=*/false)); diff --git a/mediapipe/calculators/image/mask_overlay_calculator.cc b/mediapipe/calculators/image/mask_overlay_calculator.cc index ef0cc4ca3..eda3f4f91 100644 --- a/mediapipe/calculators/image/mask_overlay_calculator.cc +++ b/mediapipe/calculators/image/mask_overlay_calculator.cc @@ -74,7 +74,7 @@ REGISTER_CALCULATOR(MaskOverlayCalculator); // static ::mediapipe::Status MaskOverlayCalculator::GetContract(CalculatorContract* cc) { - RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); cc->Inputs().Get("VIDEO", 0).Set(); cc->Inputs().Get("VIDEO", 1).Set(); if (cc->Inputs().HasTag("MASK")) @@ -103,7 +103,7 @@ REGISTER_CALCULATOR(MaskOverlayCalculator); const auto& options = cc->Options(); const auto mask_channel = options.mask_channel(); - RETURN_IF_ERROR(GlSetup(mask_channel)); + MP_RETURN_IF_ERROR(GlSetup(mask_channel)); initialized_ = true; } @@ -147,7 +147,7 @@ REGISTER_CALCULATOR(MaskOverlayCalculator); glActiveTexture(GL_TEXTURE3); glBindTexture(mask_tex.target(), mask_tex.name()); - RETURN_IF_ERROR(GlRender(mask_const)); + MP_RETURN_IF_ERROR(GlRender(mask_const)); glActiveTexture(GL_TEXTURE3); glBindTexture(mask_tex.target(), 0); @@ -155,7 +155,7 @@ REGISTER_CALCULATOR(MaskOverlayCalculator); } else { const float mask_const = mask_packet.Get(); - RETURN_IF_ERROR(GlRender(mask_const)); + MP_RETURN_IF_ERROR(GlRender(mask_const)); } glActiveTexture(GL_TEXTURE2); diff --git a/mediapipe/calculators/image/opencv_encoded_image_to_image_frame_calculator_test.cc b/mediapipe/calculators/image/opencv_encoded_image_to_image_frame_calculator_test.cc index b5db460e9..b3944c300 100644 --- a/mediapipe/calculators/image/opencv_encoded_image_to_image_frame_calculator_test.cc +++ b/mediapipe/calculators/image/opencv_encoded_image_to_image_frame_calculator_test.cc @@ -30,7 +30,7 @@ namespace { TEST(OpenCvEncodedImageToImageFrameCalculatorTest, TestRgbJpeg) { std::string contents; - MEDIAPIPE_ASSERT_OK(file::GetContents( + MP_ASSERT_OK(file::GetContents( file::JoinPath("./", "/mediapipe/calculators/image/testdata/dino.jpg"), &contents)); Packet input_packet = MakePacket(contents); @@ -44,7 +44,7 @@ TEST(OpenCvEncodedImageToImageFrameCalculatorTest, TestRgbJpeg) { CalculatorRunner runner(node_config); runner.MutableInputs()->Index(0).packets.push_back( input_packet.At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& outputs = runner.Outputs(); ASSERT_EQ(1, outputs.NumEntries()); const std::vector& packets = outputs.Index(0).packets; @@ -87,7 +87,7 @@ TEST(OpenCvEncodedImageToImageFrameCalculatorTest, TestGrayscaleJpeg) { CalculatorRunner runner(node_config); runner.MutableInputs()->Index(0).packets.push_back( input_packet.At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& outputs = runner.Outputs(); ASSERT_EQ(1, outputs.NumEntries()); const std::vector& packets = outputs.Index(0).packets; diff --git a/mediapipe/calculators/image/opencv_image_encoder_calculator_test.cc b/mediapipe/calculators/image/opencv_image_encoder_calculator_test.cc index 48b867c2f..9d2986579 100644 --- a/mediapipe/calculators/image/opencv_image_encoder_calculator_test.cc +++ b/mediapipe/calculators/image/opencv_image_encoder_calculator_test.cc @@ -55,7 +55,7 @@ TEST(OpenCvImageEncoderCalculatorTest, TestJpegWithQualities) { CalculatorRunner runner(node_config); runner.MutableInputs()->Index(0).packets.push_back( input_packet.At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& outputs = runner.Outputs(); ASSERT_EQ(1, outputs.NumEntries()); const std::vector& packets = outputs.Index(0).packets; diff --git a/mediapipe/calculators/image/recolor_calculator.cc b/mediapipe/calculators/image/recolor_calculator.cc index 1c2a0fcda..b23eda481 100644 --- a/mediapipe/calculators/image/recolor_calculator.cc +++ b/mediapipe/calculators/image/recolor_calculator.cc @@ -135,7 +135,7 @@ REGISTER_CALCULATOR(RecolorCalculator); } #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ or iOS return ::mediapipe::OkStatus(); @@ -147,11 +147,11 @@ REGISTER_CALCULATOR(RecolorCalculator); if (cc->Inputs().HasTag("IMAGE_GPU")) { use_gpu_ = true; #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #endif // __ANDROID__ or iOS } - RETURN_IF_ERROR(LoadOptions(cc)); + MP_RETURN_IF_ERROR(LoadOptions(cc)); return ::mediapipe::OkStatus(); } @@ -159,18 +159,18 @@ REGISTER_CALCULATOR(RecolorCalculator); ::mediapipe::Status RecolorCalculator::Process(CalculatorContext* cc) { if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, &cc]() -> ::mediapipe::Status { if (!initialized_) { - RETURN_IF_ERROR(InitGpu(cc)); + MP_RETURN_IF_ERROR(InitGpu(cc)); initialized_ = true; } - RETURN_IF_ERROR(RenderGpu(cc)); + MP_RETURN_IF_ERROR(RenderGpu(cc)); return ::mediapipe::OkStatus(); })); #endif // __ANDROID__ or iOS } else { - RETURN_IF_ERROR(RenderCpu(cc)); + MP_RETURN_IF_ERROR(RenderCpu(cc)); } return ::mediapipe::OkStatus(); } diff --git a/mediapipe/calculators/image/scale_image_calculator.cc b/mediapipe/calculators/image/scale_image_calculator.cc index c9be8774b..5d88d9892 100644 --- a/mediapipe/calculators/image/scale_image_calculator.cc +++ b/mediapipe/calculators/image/scale_image_calculator.cc @@ -253,21 +253,21 @@ ScaleImageCalculator::~ScaleImageCalculator() {} ::mediapipe::Status ScaleImageCalculator::InitializeFrameInfo( CalculatorContext* cc) { - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( scale_image::FindCropDimensions(input_width_, input_height_, // options_.min_aspect_ratio(), // options_.max_aspect_ratio(), // &crop_width_, &crop_height_, // &col_start_, &row_start_)); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( scale_image::FindOutputDimensions(crop_width_, crop_height_, // options_.target_width(), // options_.target_height(), // options_.preserve_aspect_ratio(), // options_.scale_to_multiple_of_two(), // &output_width_, &output_height_)); - RETURN_IF_ERROR(FindInterpolationAlgorithm(options_.algorithm(), - &interpolation_algorithm_)); + MP_RETURN_IF_ERROR(FindInterpolationAlgorithm(options_.algorithm(), + &interpolation_algorithm_)); if (interpolation_algorithm_ == -1 && (output_width_ > crop_width_ || output_height_ > crop_height_)) { output_width_ = crop_width_; @@ -327,7 +327,7 @@ ScaleImageCalculator::~ScaleImageCalculator() {} bool has_override_options = cc->Inputs().HasTag("OVERRIDE_OPTIONS"); if (!has_override_options) { - RETURN_IF_ERROR(InitializeFromOptions()); + MP_RETURN_IF_ERROR(InitializeFromOptions()); } if (!cc->Inputs().Get(input_data_id_).Header().IsEmpty()) { @@ -377,8 +377,8 @@ ScaleImageCalculator::~ScaleImageCalculator() {} if (input_width_ > 0 && input_height_ > 0 && input_format_ != ImageFormat::UNKNOWN && output_format_ != ImageFormat::UNKNOWN) { - RETURN_IF_ERROR(ValidateImageFormats()); - RETURN_IF_ERROR(InitializeFrameInfo(cc)); + MP_RETURN_IF_ERROR(ValidateImageFormats()); + MP_RETURN_IF_ERROR(InitializeFrameInfo(cc)); std::unique_ptr output_header(new VideoHeader()); *output_header = input_video_header_; output_header->format = output_format_; @@ -461,9 +461,9 @@ ScaleImageCalculator::~ScaleImageCalculator() {} } else { output_format_ = input_format_; } - RETURN_IF_ERROR(InitializeFrameInfo(cc)); + MP_RETURN_IF_ERROR(InitializeFrameInfo(cc)); } - RETURN_IF_ERROR(ValidateImageFormats()); + MP_RETURN_IF_ERROR(ValidateImageFormats()); } else { if (input_width_ != image_frame.Width() || input_height_ != image_frame.Height()) { @@ -503,9 +503,9 @@ ScaleImageCalculator::~ScaleImageCalculator() {} } else { output_format_ = input_format_; } - RETURN_IF_ERROR(InitializeFrameInfo(cc)); + MP_RETURN_IF_ERROR(InitializeFrameInfo(cc)); } - RETURN_IF_ERROR(ValidateImageFormats()); + MP_RETURN_IF_ERROR(ValidateImageFormats()); } else { if (input_width_ != yuv_image.width() || input_height_ != yuv_image.height()) { @@ -531,7 +531,7 @@ ScaleImageCalculator::~ScaleImageCalculator() {} options_.MergeFrom(cc->Inputs() .Tag("OVERRIDE_OPTIONS") .Get()); - RETURN_IF_ERROR(InitializeFromOptions()); + MP_RETURN_IF_ERROR(InitializeFromOptions()); } if (cc->Inputs().UsesTags() && cc->Inputs().HasTag("VIDEO_HEADER") && !cc->Inputs().Tag("VIDEO_HEADER").IsEmpty()) { @@ -548,7 +548,7 @@ ScaleImageCalculator::~ScaleImageCalculator() {} if (input_format_ == ImageFormat::YCBCR420P) { const YUVImage* yuv_image = &cc->Inputs().Get(input_data_id_).Get(); - RETURN_IF_ERROR(ValidateYUVImage(cc, *yuv_image)); + MP_RETURN_IF_ERROR(ValidateYUVImage(cc, *yuv_image)); if (output_format_ == ImageFormat::SRGB) { // TODO: For ease of implementation, YUVImage is converted to @@ -596,7 +596,7 @@ ScaleImageCalculator::~ScaleImageCalculator() {} } } else { image_frame = &cc->Inputs().Get(input_data_id_).Get(); - RETURN_IF_ERROR(ValidateImageFrame(cc, *image_frame)); + MP_RETURN_IF_ERROR(ValidateImageFrame(cc, *image_frame)); } std::unique_ptr cropped_image; diff --git a/mediapipe/calculators/image/scale_image_utils_test.cc b/mediapipe/calculators/image/scale_image_utils_test.cc index 62522be8f..d6421631b 100644 --- a/mediapipe/calculators/image/scale_image_utils_test.cc +++ b/mediapipe/calculators/image/scale_image_utils_test.cc @@ -28,8 +28,8 @@ TEST(ScaleImageUtilsTest, FindCropDimensions) { int col_start; int row_start; // No cropping because aspect ratios should be ignored. - MEDIAPIPE_ASSERT_OK(FindCropDimensions(50, 100, "0/1", "1/0", &crop_width, - &crop_height, &col_start, &row_start)); + MP_ASSERT_OK(FindCropDimensions(50, 100, "0/1", "1/0", &crop_width, + &crop_height, &col_start, &row_start)); EXPECT_EQ(50, crop_width); EXPECT_EQ(100, crop_height); EXPECT_EQ(0, row_start); @@ -37,39 +37,38 @@ TEST(ScaleImageUtilsTest, FindCropDimensions) { // Tests proto examples. // 16:9 aspect ratio, should be unchanged. - MEDIAPIPE_ASSERT_OK(FindCropDimensions(1920, 1080, "9/16", "16/9", - &crop_width, &crop_height, &col_start, - &row_start)); + MP_ASSERT_OK(FindCropDimensions(1920, 1080, "9/16", "16/9", &crop_width, + &crop_height, &col_start, &row_start)); EXPECT_EQ(0, col_start); EXPECT_EQ(1920, crop_width); EXPECT_EQ(0, row_start); EXPECT_EQ(1080, crop_height); // 10:16 aspect ratio, should be unchanged. - MEDIAPIPE_ASSERT_OK(FindCropDimensions(640, 1024, "9/16", "16/9", &crop_width, - &crop_height, &col_start, &row_start)); + MP_ASSERT_OK(FindCropDimensions(640, 1024, "9/16", "16/9", &crop_width, + &crop_height, &col_start, &row_start)); EXPECT_EQ(0, col_start); EXPECT_EQ(640, crop_width); EXPECT_EQ(0, row_start); EXPECT_EQ(1024, crop_height); // 2:1 aspect ratio, width is cropped. - MEDIAPIPE_ASSERT_OK(FindCropDimensions(640, 320, "9/16", "16/9", &crop_width, - &crop_height, &col_start, &row_start)); + MP_ASSERT_OK(FindCropDimensions(640, 320, "9/16", "16/9", &crop_width, + &crop_height, &col_start, &row_start)); EXPECT_EQ(36, col_start); EXPECT_EQ(568, crop_width); EXPECT_EQ(0, row_start); EXPECT_EQ(320, crop_height); // 1:5 aspect ratio, height is cropped. - MEDIAPIPE_ASSERT_OK(FindCropDimensions(96, 480, "9/16", "16/9", &crop_width, - &crop_height, &col_start, &row_start)); + MP_ASSERT_OK(FindCropDimensions(96, 480, "9/16", "16/9", &crop_width, + &crop_height, &col_start, &row_start)); EXPECT_EQ(0, col_start); EXPECT_EQ(96, crop_width); EXPECT_EQ(155, row_start); EXPECT_EQ(170, crop_height); // Tests min = max, crops width. - MEDIAPIPE_ASSERT_OK(FindCropDimensions(200, 100, "1/1", "1/1", &crop_width, - &crop_height, &col_start, &row_start)); + MP_ASSERT_OK(FindCropDimensions(200, 100, "1/1", "1/1", &crop_width, + &crop_height, &col_start, &row_start)); EXPECT_EQ(50, col_start); EXPECT_EQ(100, crop_width); EXPECT_EQ(0, row_start); @@ -80,49 +79,49 @@ TEST(ScaleImageUtilsTest, FindOutputDimensionsPreserveRatio) { int output_width; int output_height; // Not scale. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, -1, -1, true, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, -1, -1, true, true, &output_width, + &output_height)); EXPECT_EQ(200, output_width); EXPECT_EQ(100, output_height); // Not scale with odd input size. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(201, 101, -1, -1, false, false, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(201, 101, -1, -1, false, false, + &output_width, &output_height)); EXPECT_EQ(201, output_width); EXPECT_EQ(101, output_height); // Scale down by 1/2. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 100, -1, true, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 100, -1, true, true, + &output_width, &output_height)); EXPECT_EQ(100, output_width); EXPECT_EQ(50, output_height); // Scale up, doubling dimensions. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, -1, 200, true, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, -1, 200, true, true, + &output_width, &output_height)); EXPECT_EQ(400, output_width); EXPECT_EQ(200, output_height); // Fits a 2:1 image into a 150 x 150 box. Output dimensions are always // visible by 2. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 150, 150, true, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 150, 150, true, true, + &output_width, &output_height)); EXPECT_EQ(150, output_width); EXPECT_EQ(74, output_height); // Fits a 2:1 image into a 400 x 50 box. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 400, 50, true, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 400, 50, true, true, + &output_width, &output_height)); EXPECT_EQ(100, output_width); EXPECT_EQ(50, output_height); // Scale to multiple number with odd targe size. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 101, -1, true, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 101, -1, true, true, + &output_width, &output_height)); EXPECT_EQ(100, output_width); EXPECT_EQ(50, output_height); // Scale to multiple number with odd targe size. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 101, -1, true, false, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 101, -1, true, false, + &output_width, &output_height)); EXPECT_EQ(100, output_width); EXPECT_EQ(50, output_height); // Scale to odd size. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 151, 101, false, false, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 151, 101, false, false, + &output_width, &output_height)); EXPECT_EQ(151, output_width); EXPECT_EQ(101, output_height); } @@ -132,18 +131,18 @@ TEST(ScaleImageUtilsTest, FindOutputDimensionsNoAspectRatio) { int output_width; int output_height; // Scale width only. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 100, -1, false, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 100, -1, false, true, + &output_width, &output_height)); EXPECT_EQ(100, output_width); EXPECT_EQ(100, output_height); // Scale height only. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, -1, 200, false, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, -1, 200, false, true, + &output_width, &output_height)); EXPECT_EQ(200, output_width); EXPECT_EQ(200, output_height); // Scale both dimensions. - MEDIAPIPE_ASSERT_OK(FindOutputDimensions(200, 100, 150, 200, false, true, - &output_width, &output_height)); + MP_ASSERT_OK(FindOutputDimensions(200, 100, 150, 200, false, true, + &output_width, &output_height)); EXPECT_EQ(150, output_width); EXPECT_EQ(200, output_height); } diff --git a/mediapipe/calculators/image/set_alpha_calculator.cc b/mediapipe/calculators/image/set_alpha_calculator.cc index 4c3ab29ae..f3f6cedaa 100644 --- a/mediapipe/calculators/image/set_alpha_calculator.cc +++ b/mediapipe/calculators/image/set_alpha_calculator.cc @@ -157,7 +157,7 @@ REGISTER_CALCULATOR(SetAlphaCalculator); } #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ or iOS return ::mediapipe::OkStatus(); @@ -188,7 +188,7 @@ REGISTER_CALCULATOR(SetAlphaCalculator); if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #endif } @@ -198,18 +198,18 @@ REGISTER_CALCULATOR(SetAlphaCalculator); ::mediapipe::Status SetAlphaCalculator::Process(CalculatorContext* cc) { if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status { if (!gpu_initialized_) { - RETURN_IF_ERROR(GlSetup(cc)); + MP_RETURN_IF_ERROR(GlSetup(cc)); gpu_initialized_ = true; } - RETURN_IF_ERROR(RenderGpu(cc)); + MP_RETURN_IF_ERROR(RenderGpu(cc)); return ::mediapipe::OkStatus(); })); #endif // __ANDROID__ or iOS } else { - RETURN_IF_ERROR(RenderCpu(cc)); + MP_RETURN_IF_ERROR(RenderCpu(cc)); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/calculators/internal/BUILD b/mediapipe/calculators/internal/BUILD index 20f77fbd2..eab1678e0 100644 --- a/mediapipe/calculators/internal/BUILD +++ b/mediapipe/calculators/internal/BUILD @@ -29,7 +29,7 @@ mediapipe_cc_proto_library( name = "callback_packet_calculator_cc_proto", srcs = ["callback_packet_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":callback_packet_calculator_proto"], ) diff --git a/mediapipe/calculators/tensorflow/BUILD b/mediapipe/calculators/tensorflow/BUILD index bbc59703e..45d6cf965 100644 --- a/mediapipe/calculators/tensorflow/BUILD +++ b/mediapipe/calculators/tensorflow/BUILD @@ -22,7 +22,7 @@ load("//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library" proto_library( name = "graph_tensors_packet_generator_proto", srcs = ["graph_tensors_packet_generator.proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [ "//mediapipe/framework:calculator_proto", "//mediapipe/framework:packet_generator_proto", @@ -118,7 +118,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/framework:packet_generator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":graph_tensors_packet_generator_proto"], ) @@ -129,7 +129,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "@org_tensorflow//tensorflow/core:protos_all_cc", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":image_frame_to_tensor_calculator_proto"], ) @@ -137,7 +137,7 @@ mediapipe_cc_proto_library( name = "matrix_to_tensor_calculator_options_cc_proto", srcs = ["matrix_to_tensor_calculator_options.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":matrix_to_tensor_calculator_options_proto"], ) @@ -145,7 +145,7 @@ mediapipe_cc_proto_library( name = "lapped_tensor_buffer_calculator_cc_proto", srcs = ["lapped_tensor_buffer_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":lapped_tensor_buffer_calculator_proto"], ) @@ -153,7 +153,7 @@ mediapipe_cc_proto_library( name = "object_detection_tensors_to_detections_calculator_cc_proto", srcs = ["object_detection_tensors_to_detections_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":object_detection_tensors_to_detections_calculator_proto"], ) @@ -164,7 +164,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "@org_tensorflow//tensorflow/core:protos_all_cc", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":pack_media_sequence_calculator_proto"], ) @@ -172,7 +172,7 @@ mediapipe_cc_proto_library( name = "tensorflow_inference_calculator_cc_proto", srcs = ["tensorflow_inference_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensorflow_inference_calculator_proto"], ) @@ -183,7 +183,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:packet_generator_cc_proto", "@org_tensorflow//tensorflow/core:protos_all_cc", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensorflow_session_from_frozen_graph_generator_proto"], ) @@ -194,7 +194,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "@org_tensorflow//tensorflow/core:protos_all_cc", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensorflow_session_from_frozen_graph_calculator_proto"], ) @@ -202,7 +202,7 @@ mediapipe_cc_proto_library( name = "tensorflow_session_from_saved_model_generator_cc_proto", srcs = ["tensorflow_session_from_saved_model_generator.proto"], cc_deps = ["//mediapipe/framework:packet_generator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensorflow_session_from_saved_model_generator_proto"], ) @@ -210,7 +210,7 @@ mediapipe_cc_proto_library( name = "tensorflow_session_from_saved_model_calculator_cc_proto", srcs = ["tensorflow_session_from_saved_model_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensorflow_session_from_saved_model_calculator_proto"], ) @@ -218,7 +218,7 @@ mediapipe_cc_proto_library( name = "tensor_squeeze_dimensions_calculator_cc_proto", srcs = ["tensor_squeeze_dimensions_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensor_squeeze_dimensions_calculator_proto"], ) @@ -226,7 +226,7 @@ mediapipe_cc_proto_library( name = "tensor_to_image_frame_calculator_cc_proto", srcs = ["tensor_to_image_frame_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensor_to_image_frame_calculator_proto"], ) @@ -237,7 +237,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/framework/formats:time_series_header_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensor_to_matrix_calculator_proto"], ) @@ -245,7 +245,7 @@ mediapipe_cc_proto_library( name = "tensor_to_vector_float_calculator_options_cc_proto", srcs = ["tensor_to_vector_float_calculator_options.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tensor_to_vector_float_calculator_options_proto"], ) @@ -256,7 +256,7 @@ mediapipe_cc_proto_library( "//mediapipe/calculators/core:packet_resampler_calculator_cc_proto", "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":unpack_media_sequence_calculator_proto"], ) @@ -264,7 +264,7 @@ mediapipe_cc_proto_library( name = "vector_float_to_tensor_calculator_options_cc_proto", srcs = ["vector_float_to_tensor_calculator_options.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":vector_float_to_tensor_calculator_options_proto"], ) diff --git a/mediapipe/calculators/tensorflow/graph_tensors_packet_generator_test.cc b/mediapipe/calculators/tensorflow/graph_tensors_packet_generator_test.cc index d826ce9e3..77069c658 100644 --- a/mediapipe/calculators/tensorflow/graph_tensors_packet_generator_test.cc +++ b/mediapipe/calculators/tensorflow/graph_tensors_packet_generator_test.cc @@ -74,7 +74,7 @@ TEST_F(GraphTensorsPacketGeneratorTest, VerifyTensorSizeShapeAndValue) { ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "GraphTensorsPacketGenerator", extendable_options_, inputs, &outputs); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); VerifyTensorMap(&outputs); } diff --git a/mediapipe/calculators/tensorflow/image_frame_to_tensor_calculator_test.cc b/mediapipe/calculators/tensorflow/image_frame_to_tensor_calculator_test.cc index 925d40d25..86b12d6f9 100644 --- a/mediapipe/calculators/tensorflow/image_frame_to_tensor_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/image_frame_to_tensor_calculator_test.cc @@ -171,7 +171,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, SolidRedRGBFrame) { runner_ = ::absl::make_unique( "ImageFrameToTensorCalculator", "", 1, 1, 0); AddRGBFrame(width, height); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -212,7 +212,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, SolidRedRGBAFrame) { runner_.reset( new CalculatorRunner("ImageFrameToTensorCalculator", "", 1, 1, 0)); AddRGBAFrame(width, height); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -254,7 +254,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, SolidGray8Frame) { runner_.reset( new CalculatorRunner("ImageFrameToTensorCalculator", "", 1, 1, 0)); AddGray8Frame(width, height); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -293,7 +293,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, SolidGray16Frame) { runner_.reset( new CalculatorRunner("ImageFrameToTensorCalculator", "", 1, 1, 0)); AddGray16Frame(width, height); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -332,7 +332,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, SolidFloatFrame) { runner_.reset( new CalculatorRunner("ImageFrameToTensorCalculator", "", 1, 1, 0)); AddFloatFrame(width, height); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -363,7 +363,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, FixedNoiseRGBFrame) { runner_.reset( new CalculatorRunner("ImageFrameToTensorCalculator", "", 1, 1, 0)); AddFixedNoiseRGBFrame(); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -396,7 +396,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, RandomRGBFrame) { runner_.reset( new CalculatorRunner("ImageFrameToTensorCalculator", "", 1, 1, 0)); AddRandomRGBFrame(width, height, seed); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -440,7 +440,7 @@ TEST_F(ImageFrameToTensorCalculatorTest, FixedRGBFrameWithMeanAndStddev) { runner_->MutableInputs()->Index(0).packets.push_back( Adopt(image_frame.release()).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const auto& tensor = runner_->Outputs().Index(0).packets[0].Get(); EXPECT_EQ(tensor.dtype(), tf::DT_FLOAT); diff --git a/mediapipe/calculators/tensorflow/matrix_to_tensor_calculator_test.cc b/mediapipe/calculators/tensorflow/matrix_to_tensor_calculator_test.cc index df9e7bc44..c3c6ef5f8 100644 --- a/mediapipe/calculators/tensorflow/matrix_to_tensor_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/matrix_to_tensor_calculator_test.cc @@ -74,7 +74,7 @@ TEST_F(MatrixToTensorCalculatorTest, RandomMatrix) { runner_ = ::absl::make_unique("MatrixToTensorCalculator", "", 1, 1, 0); AddRandomMatrix(num_rows, num_columns, kSeed); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -106,7 +106,7 @@ TEST_F(MatrixToTensorCalculatorTest, RandomMatrixTranspose) { runner_ = ::absl::make_unique( "MatrixToTensorCalculator", kTransposeOptionsString, 1, 1, 0); AddRandomMatrix(num_rows, num_columns, kSeed); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); @@ -138,7 +138,7 @@ TEST_F(MatrixToTensorCalculatorTest, RandomMatrixAddDimension) { runner_ = ::absl::make_unique( "MatrixToTensorCalculator", kAddDimensionOptionsString, 1, 1, 0); AddRandomMatrix(num_rows, num_columns, kSeed); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Index(0).packets; ASSERT_EQ(1, output_packets.size()); diff --git a/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator_test.cc b/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator_test.cc index adce27040..3a9f6a73e 100644 --- a/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/object_detection_tensors_to_detections_calculator_test.cc @@ -134,7 +134,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest runner_->MutableInputs()->Tag(kClasses).packets.push_back( PointToForeign(&input_classes_).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); ASSERT_EQ(1, runner_->Outputs().Tag(kDetections).packets.size()); } @@ -146,7 +146,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest PointToForeign(&input_scores_for_all_classes_) .At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); ASSERT_EQ(1, runner_->Outputs().Tag(kDetections).packets.size()); } @@ -167,7 +167,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest .packets.push_back( PointToForeign(&input_keypoints_).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); ASSERT_EQ(1, runner_->Outputs().Tag(kDetections).packets.size()); } @@ -201,7 +201,7 @@ class ObjectDetectionTensorsToDetectionsCalculatorTest runner_->MutableInputs()->Tag(kClasses).packets.push_back( PointToForeign(&input_classes_).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); ASSERT_EQ(1, runner_->Outputs().Tag(kDetections).packets.size()); } diff --git a/mediapipe/calculators/tensorflow/pack_media_sequence_calculator_test.cc b/mediapipe/calculators/tensorflow/pack_media_sequence_calculator_test.cc index 033271528..19b302e13 100644 --- a/mediapipe/calculators/tensorflow/pack_media_sequence_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/pack_media_sequence_calculator_test.cc @@ -87,7 +87,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -131,7 +131,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoPrefixedImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -169,7 +169,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoFloatLists) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -214,7 +214,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksAdditionalContext) { runner_->MutableInputs()->Tag("IMAGE").packets.push_back( Adopt(image_ptr.release()).At(Timestamp(0))); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -257,7 +257,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoForwardFlowEncodeds) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -321,7 +321,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoBBoxDetections) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -374,7 +374,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoKeypoints) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -424,7 +424,7 @@ TEST_F(PackMediaSequenceCalculatorTest, PacksTwoMaskDetections) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -473,7 +473,7 @@ TEST_F(PackMediaSequenceCalculatorTest, MissingStreamOK) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -536,7 +536,7 @@ TEST_F(PackMediaSequenceCalculatorTest, TestReplacingImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -562,7 +562,7 @@ TEST_F(PackMediaSequenceCalculatorTest, TestReplacingFlowImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -599,7 +599,7 @@ TEST_F(PackMediaSequenceCalculatorTest, TestReplacingFloatVectors) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; @@ -643,7 +643,7 @@ TEST_F(PackMediaSequenceCalculatorTest, TestReconcilingAnnotations) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("SEQUENCE_EXAMPLE").packets; ASSERT_EQ(1, output_packets.size()); diff --git a/mediapipe/calculators/tensorflow/tensorflow_inference_calculator.cc b/mediapipe/calculators/tensorflow/tensorflow_inference_calculator.cc index 1ba7c2cd1..80f54d554 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_inference_calculator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_inference_calculator.cc @@ -365,14 +365,14 @@ class TensorFlowInferenceCalculator : public CalculatorBase { } if (batch_timestamps_.size() == options_.batch_size()) { - RETURN_IF_ERROR(OutputBatch(cc)); + MP_RETURN_IF_ERROR(OutputBatch(cc)); } return ::mediapipe::OkStatus(); } ::mediapipe::Status Close(CalculatorContext* cc) override { if (!batch_timestamps_.empty()) { - RETURN_IF_ERROR(OutputBatch(cc)); + MP_RETURN_IF_ERROR(OutputBatch(cc)); } return ::mediapipe::OkStatus(); } diff --git a/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc b/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc index f0b8ea5e1..4f07b897c 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_inference_calculator_test.cc @@ -122,7 +122,7 @@ TEST_F(TensorflowInferenceCalculatorTest, GetConstants) { runner_ = absl::make_unique(config); AddSessionInputSidePacket(); AddVectorToInputsAsTensor({0, 0, 0}, "A", 0); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_b = runner_->Outputs().Tag("B").packets; @@ -163,7 +163,7 @@ TEST_F(TensorflowInferenceCalculatorTest, GetComputed) { AddSessionInputSidePacket(); AddVectorToInputsAsTensor({2, 2, 2}, "A", 0); AddVectorToInputsAsTensor({3, 4, 5}, "B", 0); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -217,7 +217,7 @@ TEST_F(TensorflowInferenceCalculatorTest, GetMultiBatchComputed) { AddVectorToInputsAsTensor({3, 4, 5}, "B", 0); AddVectorToInputsAsTensor({3, 3, 3}, "A", 1); AddVectorToInputsAsTensor({3, 4, 5}, "B", 1); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -255,7 +255,7 @@ TEST_F(TensorflowInferenceCalculatorTest, GetSingleBatchComputed) { AddVectorToInputsAsTensor({3, 4, 5}, "B", 0); AddVectorToInputsAsTensor({3, 3, 3}, "A", 1); AddVectorToInputsAsTensor({3, 4, 5}, "B", 1); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -293,7 +293,7 @@ TEST_F(TensorflowInferenceCalculatorTest, GetCloseBatchComputed) { AddVectorToInputsAsTensor({3, 4, 5}, "B", 0); AddVectorToInputsAsTensor({3, 3, 3}, "A", 1); AddVectorToInputsAsTensor({3, 4, 5}, "B", 1); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -331,7 +331,7 @@ TEST_F(TensorflowInferenceCalculatorTest, TestRecurrentStates) { AddSessionInputSidePacket(); AddVectorToInputsAsTensor({3, 4, 5}, "B", 0); AddVectorToInputsAsTensor({3, 4, 5}, "B", 1); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -372,7 +372,7 @@ TEST_F(TensorflowInferenceCalculatorTest, TestRecurrentStateOverride) { AddVectorToInputsAsTensor({3, 4, 5}, "B", 0); AddVectorToInputsAsTensor({1, 1, 1}, "A", 1); AddVectorToInputsAsTensor({3, 4, 5}, "B", 1); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -409,7 +409,7 @@ TEST_F(TensorflowInferenceCalculatorTest, DISABLED_CheckTiming) { runner_ = absl::make_unique(config); AddSessionInputSidePacket(); AddVectorToInputsAsTensor({0, 0, 0}, "A", 0); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); EXPECT_EQ(1, runner_ ->GetCounter( @@ -465,7 +465,7 @@ TEST_F(TensorflowInferenceCalculatorTest, MissingInputFeature_Skip) { runner_ = absl::make_unique(config); AddSessionInputSidePacket(); AddVectorToInputsAsTensor({2, 2, 2}, "A", 0); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; @@ -494,7 +494,7 @@ TEST_F(TensorflowInferenceCalculatorTest, AddVectorToInputsAsTensor({2, 2, 2}, "A", 0); AddVectorToInputsAsTensor({3, 3, 3}, "A", 1); AddVectorToInputsAsTensor({3, 4, 5}, "B", 1); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets_mult = runner_->Outputs().Tag("MULTIPLIED").packets; diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator_test.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator_test.cc index e9c5c604b..c2b774278 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_calculator_test.cc @@ -108,7 +108,7 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, })", calculator_options_->DebugString())); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); VerifySignatureMap(session); @@ -148,17 +148,17 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, calculator_options_->DebugString())); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("multiplied_tensor"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "a_tensor", Adopt(new auto(TensorMatrix1x3(1, -1, 10))).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("a_tensor")); + MP_ASSERT_OK(graph.CloseInputStream("a_tensor")); Packet packet; ASSERT_TRUE(poller.Next(&packet)); @@ -168,7 +168,7 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, packet.Get().DebugString()); ASSERT_FALSE(poller.Next(&packet)); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, @@ -186,11 +186,11 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, calculator_options_->DebugString())); std::string serialized_graph_contents; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), - &serialized_graph_contents)); + MP_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), + &serialized_graph_contents)); runner.MutableSidePackets()->Tag("STRING_MODEL") = Adopt(new std::string(serialized_graph_contents)); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); @@ -213,7 +213,7 @@ TEST_F( calculator_options_->DebugString())); runner.MutableSidePackets()->Tag("STRING_MODEL_FILE_PATH") = Adopt(new std::string(GetGraphDefPath())); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); @@ -256,8 +256,8 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, runner.MutableSidePackets()->Tag("STRING_MODEL_FILE_PATH") = Adopt(new std::string(GetGraphDefPath())); std::string serialized_graph_contents; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), - &serialized_graph_contents)); + MP_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), + &serialized_graph_contents)); runner.MutableSidePackets()->Tag("STRING_MODEL") = Adopt(new std::string(serialized_graph_contents)); auto run_status = runner.Run(); @@ -283,8 +283,8 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, runner.MutableSidePackets()->Tag("STRING_MODEL_FILE_PATH") = Adopt(new std::string(GetGraphDefPath())); std::string serialized_graph_contents; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), - &serialized_graph_contents)); + MP_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), + &serialized_graph_contents)); runner.MutableSidePackets()->Tag("STRING_MODEL") = Adopt(new std::string(serialized_graph_contents)); auto run_status = runner.Run(); @@ -305,7 +305,7 @@ TEST_F(TensorFlowSessionFromFrozenGraphCalculatorTest, } })", calculator_options_->DebugString())); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator_test.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator_test.cc index ca9cc8141..d11007299 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator_test.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_frozen_graph_generator_test.cc @@ -106,7 +106,7 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromFrozenGraphGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); VerifySignatureMap(&output_side_packets); } @@ -144,17 +144,17 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, generator_options_->DebugString())); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("multiplied_tensor"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "a_tensor", Adopt(new auto(TensorMatrix1x3(1, -1, 10))).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("a_tensor")); + MP_ASSERT_OK(graph.CloseInputStream("a_tensor")); Packet packet; ASSERT_TRUE(poller.Next(&packet)); @@ -164,7 +164,7 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, packet.Get().DebugString()); ASSERT_FALSE(poller.Next(&packet)); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, @@ -174,15 +174,15 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, PacketSet output_side_packets( tool::CreateTagMap({"SESSION:session"}).ValueOrDie()); std::string serialized_graph_contents; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), - &serialized_graph_contents)); + MP_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), + &serialized_graph_contents)); generator_options_->clear_graph_proto_path(); input_side_packets.Tag("STRING_MODEL") = Adopt(new std::string(serialized_graph_contents)); ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromFrozenGraphGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); VerifySignatureMap(&output_side_packets); } @@ -199,7 +199,7 @@ TEST_F( ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromFrozenGraphGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); VerifySignatureMap(&output_side_packets); } @@ -229,8 +229,8 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, PacketSet output_side_packets( tool::CreateTagMap({"SESSION:session"}).ValueOrDie()); std::string serialized_graph_contents; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), - &serialized_graph_contents)); + MP_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), + &serialized_graph_contents)); input_side_packets.Tag("STRING_MODEL") = Adopt(new std::string(serialized_graph_contents)); input_side_packets.Tag("STRING_MODEL_FILE_PATH") = @@ -254,8 +254,8 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, PacketSet output_side_packets( tool::CreateTagMap({"SESSION:session"}).ValueOrDie()); std::string serialized_graph_contents; - EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), - &serialized_graph_contents)); + MP_EXPECT_OK(mediapipe::file::GetContents(GetGraphDefPath(), + &serialized_graph_contents)); input_side_packets.Tag("STRING_MODEL") = Adopt(new std::string(serialized_graph_contents)); input_side_packets.Tag("STRING_MODEL_FILE_PATH") = @@ -280,7 +280,7 @@ TEST_F(TensorFlowSessionFromFrozenGraphGeneratorTest, ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromFrozenGraphGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status); + MP_EXPECT_OK(run_status); VerifySignatureMap(&output_side_packets); } diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc index 525eb4237..51ef81ed4 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator.cc @@ -14,10 +14,6 @@ #include -#if defined(MEDIAPIPE_TPU_SUPPORT) -#include "learning/brain/google/xla/global_tpu_init.h" -#include "tensorflow/core/protobuf/tpu/topology.pb.h" -#endif #if !defined(__ANDROID__) #include "mediapipe/framework/port/file_helpers.h" #endif diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator_test.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator_test.cc index 1a6902dc8..a202308db 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_calculator_test.cc @@ -75,7 +75,7 @@ TEST_F(TensorFlowSessionFromSavedModelCalculatorTest, } })", options_->DebugString())); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); // Session must be set. @@ -119,7 +119,7 @@ TEST_F(TensorFlowSessionFromSavedModelCalculatorTest, options_->DebugString())); runner.MutableSidePackets()->Tag("STRING_SAVED_MODEL_PATH") = MakePacket(GetSavedModelDir()); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); // Session must be set. @@ -159,17 +159,17 @@ TEST_F(TensorFlowSessionFromSavedModelCalculatorTest, options_->DebugString())); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config)); + MP_ASSERT_OK(graph.Initialize(graph_config)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("multiplied_tensor"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "a_tensor", Adopt(new auto(TensorMatrix1x3(1, -1, 10))).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("a_tensor")); + MP_ASSERT_OK(graph.CloseInputStream("a_tensor")); Packet packet; ASSERT_TRUE(poller.Next(&packet)); @@ -179,7 +179,7 @@ TEST_F(TensorFlowSessionFromSavedModelCalculatorTest, packet.Get().DebugString()); ASSERT_FALSE(poller.Next(&packet)); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } TEST_F(TensorFlowSessionFromSavedModelCalculatorTest, @@ -197,7 +197,7 @@ TEST_F(TensorFlowSessionFromSavedModelCalculatorTest, } })", options_->DebugString())); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const TensorFlowSession& session = runner.OutputSidePackets().Tag("SESSION").Get(); // Session must be set. diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc index d9959c5b7..6bcc91265 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator.cc @@ -14,10 +14,6 @@ #include -#if defined(MEDIAPIPE_TPU_SUPPORT) -#include "learning/brain/google/xla/global_tpu_init.h" -#include "tensorflow/core/protobuf/tpu/topology.pb.h" -#endif #if !defined(__ANDROID__) #include "mediapipe/framework/port/file_helpers.h" #endif diff --git a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator_test.cc b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator_test.cc index 268158f86..24603d050 100644 --- a/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator_test.cc +++ b/mediapipe/calculators/tensorflow/tensorflow_session_from_saved_model_generator_test.cc @@ -71,7 +71,7 @@ TEST_F(TensorFlowSessionFromSavedModelGeneratorTest, ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromSavedModelGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); const TensorFlowSession& session = output_side_packets.Tag("SESSION").Get(); // Session must be set. @@ -113,7 +113,7 @@ TEST_F(TensorFlowSessionFromSavedModelGeneratorTest, ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromSavedModelGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); const TensorFlowSession& session = output_side_packets.Tag("SESSION").Get(); // Session must be set. @@ -154,17 +154,17 @@ TEST_F(TensorFlowSessionFromSavedModelGeneratorTest, generator_options_->DebugString())); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config)); + MP_ASSERT_OK(graph.Initialize(graph_config)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("multiplied_tensor"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "a_tensor", Adopt(new auto(TensorMatrix1x3(1, -1, 10))).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("a_tensor")); + MP_ASSERT_OK(graph.CloseInputStream("a_tensor")); Packet packet; ASSERT_TRUE(poller.Next(&packet)); @@ -174,7 +174,7 @@ TEST_F(TensorFlowSessionFromSavedModelGeneratorTest, packet.Get().DebugString()); ASSERT_FALSE(poller.Next(&packet)); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } TEST_F(TensorFlowSessionFromSavedModelGeneratorTest, @@ -189,7 +189,7 @@ TEST_F(TensorFlowSessionFromSavedModelGeneratorTest, ::mediapipe::Status run_status = tool::RunGenerateAndValidateTypes( "TensorFlowSessionFromSavedModelGenerator", extendable_options_, input_side_packets, &output_side_packets); - MEDIAPIPE_EXPECT_OK(run_status) << run_status.message(); + MP_EXPECT_OK(run_status) << run_status.message(); const TensorFlowSession& session = output_side_packets.Tag("SESSION").Get(); // Session must be set. diff --git a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc index d8492a9dc..36958ef8f 100644 --- a/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc +++ b/mediapipe/calculators/tensorflow/unpack_media_sequence_calculator_test.cc @@ -97,7 +97,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksOneImage) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("IMAGE").packets; @@ -126,7 +126,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksTwoImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("IMAGE").packets; @@ -156,7 +156,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksTwoPrefixedImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("IMAGE_PREFIX").packets; @@ -183,7 +183,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksOneForwardFlowImage) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("FORWARD_FLOW_ENCODED").packets; @@ -212,7 +212,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksTwoForwardFlowImages) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("FORWARD_FLOW_ENCODED").packets; @@ -242,7 +242,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksBBoxes) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("BBOX").packets; @@ -276,7 +276,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksPrefixedBBoxes) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("BBOX_PREFIX").packets; @@ -308,7 +308,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksTwoFloatLists) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("FLOAT_FEATURE_TEST").packets; @@ -353,7 +353,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksNonOverlappingTimestamps) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& output_packets = runner_->Outputs().Tag("IMAGE").packets; @@ -390,7 +390,7 @@ TEST_F(UnpackMediaSequenceCalculatorTest, UnpacksTwoPostStreamFloatLists) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(input_sequence.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); const std::vector& fdense_avg_packets = runner_->Outputs().Tag("FLOAT_FEATURE_FDENSE_AVG").packets; @@ -419,11 +419,11 @@ TEST_F(UnpackMediaSequenceCalculatorTest, GetDatasetFromPacket) { std::string root = "test_root"; runner_->MutableSidePackets()->Tag("DATASET_ROOT") = PointToForeign(&root); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); - MEDIAPIPE_ASSERT_OK(runner_->OutputSidePackets() - .Tag("DATA_PATH") - .ValidateAsType()); + MP_ASSERT_OK(runner_->OutputSidePackets() + .Tag("DATA_PATH") + .ValidateAsType()); ASSERT_EQ(runner_->OutputSidePackets().Tag("DATA_PATH").Get(), root + "/" + data_path_); } @@ -437,11 +437,11 @@ TEST_F(UnpackMediaSequenceCalculatorTest, GetDatasetFromOptions) { runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(sequence_.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); - MEDIAPIPE_ASSERT_OK(runner_->OutputSidePackets() - .Tag("DATA_PATH") - .ValidateAsType()); + MP_ASSERT_OK(runner_->OutputSidePackets() + .Tag("DATA_PATH") + .ValidateAsType()); ASSERT_EQ(runner_->OutputSidePackets().Tag("DATA_PATH").Get(), root + "/" + data_path_); } @@ -450,11 +450,11 @@ TEST_F(UnpackMediaSequenceCalculatorTest, GetDatasetFromExample) { SetUpCalculator({}, {"DATA_PATH:data_path"}); runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(sequence_.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); - MEDIAPIPE_ASSERT_OK(runner_->OutputSidePackets() - .Tag("DATA_PATH") - .ValidateAsType()); + MP_ASSERT_OK(runner_->OutputSidePackets() + .Tag("DATA_PATH") + .ValidateAsType()); ASSERT_EQ(runner_->OutputSidePackets().Tag("DATA_PATH").Get(), data_path_); } @@ -473,11 +473,11 @@ TEST_F(UnpackMediaSequenceCalculatorTest, GetPacketResamplingOptions) { SetUpCalculator({}, {"RESAMPLER_OPTIONS:resampler_options"}, {}, &options); runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(sequence_.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); + MP_ASSERT_OK(runner_->Run()); - MEDIAPIPE_EXPECT_OK(runner_->OutputSidePackets() - .Tag("RESAMPLER_OPTIONS") - .ValidateAsType()); + MP_EXPECT_OK(runner_->OutputSidePackets() + .Tag("RESAMPLER_OPTIONS") + .ValidateAsType()); EXPECT_NEAR(runner_->OutputSidePackets() .Tag("RESAMPLER_OPTIONS") .Get() @@ -502,10 +502,10 @@ TEST_F(UnpackMediaSequenceCalculatorTest, GetFrameRateFromExample) { SetUpCalculator({}, {"IMAGE_FRAME_RATE:frame_rate"}); runner_->MutableSidePackets()->Tag("SEQUENCE_EXAMPLE") = Adopt(sequence_.release()); - MEDIAPIPE_ASSERT_OK(runner_->Run()); - MEDIAPIPE_EXPECT_OK(runner_->OutputSidePackets() - .Tag("IMAGE_FRAME_RATE") - .ValidateAsType()); + MP_ASSERT_OK(runner_->Run()); + MP_EXPECT_OK(runner_->OutputSidePackets() + .Tag("IMAGE_FRAME_RATE") + .ValidateAsType()); EXPECT_EQ(runner_->OutputSidePackets().Tag("IMAGE_FRAME_RATE").Get(), image_frame_rate_); } diff --git a/mediapipe/calculators/tflite/BUILD b/mediapipe/calculators/tflite/BUILD index 8f86adc8e..93f08edc5 100644 --- a/mediapipe/calculators/tflite/BUILD +++ b/mediapipe/calculators/tflite/BUILD @@ -79,7 +79,7 @@ mediapipe_cc_proto_library( name = "ssd_anchors_calculator_cc_proto", srcs = ["ssd_anchors_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":ssd_anchors_calculator_proto"], ) @@ -87,7 +87,7 @@ mediapipe_cc_proto_library( name = "tflite_custom_op_resolver_calculator_cc_proto", srcs = ["tflite_custom_op_resolver_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_custom_op_resolver_calculator_proto"], ) @@ -95,7 +95,7 @@ mediapipe_cc_proto_library( name = "tflite_converter_calculator_cc_proto", srcs = ["tflite_converter_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_converter_calculator_proto"], ) @@ -103,7 +103,7 @@ mediapipe_cc_proto_library( name = "tflite_tensors_to_segmentation_calculator_cc_proto", srcs = ["tflite_tensors_to_segmentation_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_tensors_to_segmentation_calculator_proto"], ) @@ -111,7 +111,7 @@ mediapipe_cc_proto_library( name = "tflite_inference_calculator_cc_proto", srcs = ["tflite_inference_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_inference_calculator_proto"], ) @@ -119,7 +119,7 @@ mediapipe_cc_proto_library( name = "tflite_tensors_to_detections_calculator_cc_proto", srcs = ["tflite_tensors_to_detections_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_tensors_to_detections_calculator_proto"], ) @@ -127,7 +127,7 @@ mediapipe_cc_proto_library( name = "tflite_tensors_to_classification_calculator_cc_proto", srcs = ["tflite_tensors_to_classification_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_tensors_to_classification_calculator_proto"], ) @@ -135,7 +135,7 @@ mediapipe_cc_proto_library( name = "tflite_tensors_to_landmarks_calculator_cc_proto", srcs = ["tflite_tensors_to_landmarks_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":tflite_tensors_to_landmarks_calculator_proto"], ) @@ -200,7 +200,6 @@ cc_library( srcs = ["tflite_inference_calculator.cc"], copts = select({ "//mediapipe:ios": [ - "-std=c++11", "-x objective-c++", "-fobjc-arc", # enable reference-counting ], @@ -246,7 +245,6 @@ cc_library( srcs = ["tflite_converter_calculator.cc"], copts = select({ "//mediapipe:ios": [ - "-std=c++11", "-x objective-c++", "-fobjc-arc", # enable reference-counting ], diff --git a/mediapipe/calculators/tflite/ssd_anchors_calculator.cc b/mediapipe/calculators/tflite/ssd_anchors_calculator.cc index 086636245..c63b5ce94 100644 --- a/mediapipe/calculators/tflite/ssd_anchors_calculator.cc +++ b/mediapipe/calculators/tflite/ssd_anchors_calculator.cc @@ -79,7 +79,7 @@ class SsdAnchorsCalculator : public CalculatorBase { cc->Options(); auto anchors = absl::make_unique>(); - RETURN_IF_ERROR(GenerateAnchors(anchors.get(), options)); + MP_RETURN_IF_ERROR(GenerateAnchors(anchors.get(), options)); cc->OutputSidePackets().Index(0).Set(Adopt(anchors.release())); return ::mediapipe::OkStatus(); } diff --git a/mediapipe/calculators/tflite/ssd_anchors_calculator_test.cc b/mediapipe/calculators/tflite/ssd_anchors_calculator_test.cc index df0814e8f..7a5b555db 100644 --- a/mediapipe/calculators/tflite/ssd_anchors_calculator_test.cc +++ b/mediapipe/calculators/tflite/ssd_anchors_calculator_test.cc @@ -90,12 +90,12 @@ TEST(SsdAnchorCalculatorTest, FaceDetectionConfig) { } )")); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const auto& anchors = runner.OutputSidePackets().Index(0).Get>(); std::string anchors_string; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents( + MP_EXPECT_OK(mediapipe::file::GetContents( GetGoldenFilePath("anchor_golden_file_0.txt"), &anchors_string)); std::vector anchors_golden; @@ -133,12 +133,12 @@ TEST(SsdAnchorCalculatorTest, MobileSSDConfig) { } )")); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const auto& anchors = runner.OutputSidePackets().Index(0).Get>(); std::string anchors_string; - MEDIAPIPE_EXPECT_OK(mediapipe::file::GetContents( + MP_EXPECT_OK(mediapipe::file::GetContents( GetGoldenFilePath("anchor_golden_file_1.txt"), &anchors_string)); std::vector anchors_golden; diff --git a/mediapipe/calculators/tflite/tflite_converter_calculator.cc b/mediapipe/calculators/tflite/tflite_converter_calculator.cc index 6a6306df2..37952008b 100644 --- a/mediapipe/calculators/tflite/tflite_converter_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_converter_calculator.cc @@ -190,9 +190,9 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); #endif #if defined(__ANDROID__) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #elif defined(__APPLE__) && !TARGET_OS_OSX // iOS - RETURN_IF_ERROR([MPPMetalHelper updateContract:cc]); + MP_RETURN_IF_ERROR([MPPMetalHelper updateContract:cc]); #endif // Assign this calculator's default InputStreamHandler. @@ -204,7 +204,7 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); ::mediapipe::Status TfLiteConverterCalculator::Open(CalculatorContext* cc) { cc->SetOffset(TimestampDiff(0)); - RETURN_IF_ERROR(LoadOptions(cc)); + MP_RETURN_IF_ERROR(LoadOptions(cc)); if (cc->Inputs().HasTag("IMAGE_GPU") || cc->Outputs().HasTag("IMAGE_OUT_GPU")) { @@ -222,7 +222,7 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); // Cannot use quantization. use_quantized_tensors_ = false; #if defined(__ANDROID__) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #elif defined(__APPLE__) && !TARGET_OS_OSX // iOS gpu_helper_ = [[MPPMetalHelper alloc] initWithCalculatorContext:cc]; RET_CHECK(gpu_helper_); @@ -239,14 +239,14 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); ::mediapipe::Status TfLiteConverterCalculator::Process(CalculatorContext* cc) { if (use_gpu_) { if (!initialized_) { - RETURN_IF_ERROR(InitGpu(cc)); + MP_RETURN_IF_ERROR(InitGpu(cc)); initialized_ = true; } // Convert to GPU tensors type. - RETURN_IF_ERROR(ProcessGPU(cc)); + MP_RETURN_IF_ERROR(ProcessGPU(cc)); } else { // Convert to CPU tensors or Matrix type. - RETURN_IF_ERROR(ProcessCPU(cc)); + MP_RETURN_IF_ERROR(ProcessCPU(cc)); } return ::mediapipe::OkStatus(); @@ -321,11 +321,11 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); float* tensor_buffer = tensor->data.f; RET_CHECK(tensor_buffer); if (image_frame.ByteDepth() == 1) { - RETURN_IF_ERROR(NormalizeImage(image_frame, zero_center_, - flip_vertically_, tensor_buffer)); + MP_RETURN_IF_ERROR(NormalizeImage( + image_frame, zero_center_, flip_vertically_, tensor_buffer)); } else if (image_frame.ByteDepth() == 4) { - RETURN_IF_ERROR(NormalizeImage(image_frame, zero_center_, - flip_vertically_, tensor_buffer)); + MP_RETURN_IF_ERROR(NormalizeImage( + image_frame, zero_center_, flip_vertically_, tensor_buffer)); } else { return ::mediapipe::InternalError( "Only byte-based (8 bit) and float (32 bit) images supported."); @@ -359,7 +359,7 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); float* tensor_buffer = tensor->data.f; RET_CHECK(tensor_buffer); - RETURN_IF_ERROR(CopyMatrixToTensor(matrix, tensor_buffer)); + MP_RETURN_IF_ERROR(CopyMatrixToTensor(matrix, tensor_buffer)); auto output_tensors = absl::make_unique>(); output_tensors->emplace_back(*tensor); @@ -375,7 +375,7 @@ REGISTER_CALCULATOR(TfLiteConverterCalculator); #if defined(__ANDROID__) // GpuBuffer to tflite::gpu::GlBuffer conversion. const auto& input = cc->Inputs().Tag("IMAGE_GPU").Get(); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, &input]() -> ::mediapipe::Status { // Convert GL texture into TfLite GlBuffer (SSBO). auto src = gpu_helper_.CreateSourceTexture(input); diff --git a/mediapipe/calculators/tflite/tflite_converter_calculator_test.cc b/mediapipe/calculators/tflite/tflite_converter_calculator_test.cc index 3360586a2..d7d2d5fd1 100644 --- a/mediapipe/calculators/tflite/tflite_converter_calculator_test.cc +++ b/mediapipe/calculators/tflite/tflite_converter_calculator_test.cc @@ -67,7 +67,7 @@ class TfLiteConverterCalculatorTest : public ::testing::Test { } } } - MEDIAPIPE_ASSERT_OK(graph_->AddPacketToInputStream( + MP_ASSERT_OK(graph_->AddPacketToInputStream( "matrix", Adopt(matrix.release()).At(Timestamp(0)))); } @@ -99,14 +99,14 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixColMajor) { // Run the graph. graph_ = absl::make_unique(); - MEDIAPIPE_ASSERT_OK(graph_->Initialize(graph_config)); - MEDIAPIPE_ASSERT_OK(graph_->StartRun({})); + MP_ASSERT_OK(graph_->Initialize(graph_config)); + MP_ASSERT_OK(graph_->StartRun({})); // Push the tensor into the graph. AddRandomMatrix(num_rows, num_columns, kSeed, /*row_major_matrix=*/false); // Wait until the calculator done processing. - MEDIAPIPE_ASSERT_OK(graph_->WaitUntilIdle()); + MP_ASSERT_OK(graph_->WaitUntilIdle()); EXPECT_EQ(1, output_packets.size()); // Get and process results. @@ -128,8 +128,8 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixColMajor) { // Fully close graph at end, otherwise calculator+tensors are destroyed // after calling WaitUntilDone(). - MEDIAPIPE_ASSERT_OK(graph_->CloseInputStream("matrix")); - MEDIAPIPE_ASSERT_OK(graph_->WaitUntilDone()); + MP_ASSERT_OK(graph_->CloseInputStream("matrix")); + MP_ASSERT_OK(graph_->WaitUntilDone()); graph_.reset(); } @@ -160,14 +160,14 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixRowMajor) { // Run the graph. graph_ = absl::make_unique(); - MEDIAPIPE_ASSERT_OK(graph_->Initialize(graph_config)); - MEDIAPIPE_ASSERT_OK(graph_->StartRun({})); + MP_ASSERT_OK(graph_->Initialize(graph_config)); + MP_ASSERT_OK(graph_->StartRun({})); // Push the tensor into the graph. AddRandomMatrix(num_rows, num_columns, kSeed, /*row_major_matrix=*/true); // Wait until the calculator done processing. - MEDIAPIPE_ASSERT_OK(graph_->WaitUntilIdle()); + MP_ASSERT_OK(graph_->WaitUntilIdle()); EXPECT_EQ(1, output_packets.size()); // Get and process results. @@ -189,8 +189,8 @@ TEST_F(TfLiteConverterCalculatorTest, RandomMatrixRowMajor) { // Fully close graph at end, otherwise calculator+tensors are destroyed // after calling WaitUntilDone(). - MEDIAPIPE_ASSERT_OK(graph_->CloseInputStream("matrix")); - MEDIAPIPE_ASSERT_OK(graph_->WaitUntilDone()); + MP_ASSERT_OK(graph_->CloseInputStream("matrix")); + MP_ASSERT_OK(graph_->WaitUntilDone()); graph_.reset(); } diff --git a/mediapipe/calculators/tflite/tflite_inference_calculator.cc b/mediapipe/calculators/tflite/tflite_inference_calculator.cc index 76208b661..f9b5646a4 100644 --- a/mediapipe/calculators/tflite/tflite_inference_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_inference_calculator.cc @@ -182,9 +182,9 @@ REGISTER_CALCULATOR(TfLiteInferenceCalculator); } #if defined(__ANDROID__) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #elif defined(__APPLE__) && !TARGET_OS_OSX // iOS - RETURN_IF_ERROR([MPPMetalHelper updateContract:cc]); + MP_RETURN_IF_ERROR([MPPMetalHelper updateContract:cc]); #endif // Assign this calculator's default InputStreamHandler. @@ -196,7 +196,7 @@ REGISTER_CALCULATOR(TfLiteInferenceCalculator); ::mediapipe::Status TfLiteInferenceCalculator::Open(CalculatorContext* cc) { cc->SetOffset(TimestampDiff(0)); - RETURN_IF_ERROR(LoadOptions(cc)); + MP_RETURN_IF_ERROR(LoadOptions(cc)); if (cc->Inputs().HasTag("TENSORS_GPU")) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) @@ -217,17 +217,17 @@ REGISTER_CALCULATOR(TfLiteInferenceCalculator); #endif } - RETURN_IF_ERROR(LoadModel(cc)); + MP_RETURN_IF_ERROR(LoadModel(cc)); if (gpu_inference_) { #if defined(__ANDROID__) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #elif defined(__APPLE__) && !TARGET_OS_OSX // iOS gpu_helper_ = [[MPPMetalHelper alloc] initWithCalculatorContext:cc]; RET_CHECK(gpu_helper_); #endif - RETURN_IF_ERROR(LoadDelegate(cc)); + MP_RETURN_IF_ERROR(LoadDelegate(cc)); } return ::mediapipe::OkStatus(); @@ -241,7 +241,7 @@ REGISTER_CALCULATOR(TfLiteInferenceCalculator); const auto& input_tensors = cc->Inputs().Tag("TENSORS_GPU").Get>(); RET_CHECK_EQ(input_tensors.size(), 1); - RETURN_IF_ERROR(gpu_helper_.RunInGlContext( + MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext( [this, &input_tensors]() -> ::mediapipe::Status { // Explicit copy input. tflite::gpu::gl::CopyBuffer(input_tensors[0], gpu_data_in_->buffer); @@ -290,10 +290,11 @@ REGISTER_CALCULATOR(TfLiteInferenceCalculator); // 2. Run inference. if (gpu_inference_) { #if defined(__ANDROID__) - RETURN_IF_ERROR(gpu_helper_.RunInGlContext([this]() -> ::mediapipe::Status { - RET_CHECK_EQ(interpreter_->Invoke(), kTfLiteOk); - return ::mediapipe::OkStatus(); - })); + MP_RETURN_IF_ERROR( + gpu_helper_.RunInGlContext([this]() -> ::mediapipe::Status { + RET_CHECK_EQ(interpreter_->Invoke(), kTfLiteOk); + return ::mediapipe::OkStatus(); + })); #elif defined(__APPLE__) && !TARGET_OS_OSX // iOS RET_CHECK_EQ(interpreter_->Invoke(), kTfLiteOk); #endif @@ -367,7 +368,7 @@ REGISTER_CALCULATOR(TfLiteInferenceCalculator); ::mediapipe::Status TfLiteInferenceCalculator::Close(CalculatorContext* cc) { if (delegate_) { #if defined(__ANDROID__) - RETURN_IF_ERROR(gpu_helper_.RunInGlContext([this]() -> Status { + MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext([this]() -> Status { TfLiteGpuDelegateDelete(delegate_); gpu_data_in_.reset(); for (int i = 0; i < gpu_data_out_.size(); ++i) { diff --git a/mediapipe/calculators/tflite/tflite_inference_calculator_test.cc b/mediapipe/calculators/tflite/tflite_inference_calculator_test.cc index ab2c8c87a..ae9ac144d 100644 --- a/mediapipe/calculators/tflite/tflite_inference_calculator_test.cc +++ b/mediapipe/calculators/tflite/tflite_inference_calculator_test.cc @@ -93,13 +93,13 @@ TEST_F(TfLiteInferenceCalculatorTest, SmokeTest) { std::vector output_packets; tool::AddVectorSink("tensor_out", &graph_config, &output_packets); CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); // Push the tensor into the graph. - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "tensor_in", Adopt(input_vec.release()).At(Timestamp(0)))); // Wait until the calculator done processing. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(1, output_packets.size()); // Get and process results. @@ -116,8 +116,8 @@ TEST_F(TfLiteInferenceCalculatorTest, SmokeTest) { // Fully close graph at end, otherwise calculator+tensors are destroyed // after calling WaitUntilDone(). - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("tensor_in")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("tensor_in")); + MP_ASSERT_OK(graph.WaitUntilDone()); } } // namespace mediapipe diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc b/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc index d786dafcc..5e9e9988e 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator.cc @@ -103,7 +103,7 @@ REGISTER_CALCULATOR(TfLiteTensorsToClassificationCalculator); ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(options.label_map_path())); std::string label_map_string; - RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); + MP_RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); std::istringstream stream(label_map_string); std::string line; diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator_test.cc b/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator_test.cc index 657fa8910..a7290b112 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator_test.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator_test.cc @@ -83,7 +83,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest, CorrectOutput) { )")); BuildGraph(&runner, {0, 0.5, 1}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& output_packets_ = runner.Outputs().Tag("CLASSIFICATIONS").packets; @@ -115,7 +115,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest, )")); BuildGraph(&runner, {0, 0.5, 1}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& output_packets_ = runner.Outputs().Tag("CLASSIFICATIONS").packets; @@ -147,7 +147,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest, )")); BuildGraph(&runner, {0, 0.5, 1}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& output_packets_ = runner.Outputs().Tag("CLASSIFICATIONS").packets; @@ -174,7 +174,7 @@ TEST_F(TfLiteTensorsToClassificationCalculatorTest, CorrectOutputWithTopK) { )")); BuildGraph(&runner, {0, 0.5, 1}); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& output_packets_ = runner.Outputs().Tag("CLASSIFICATIONS").packets; diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc b/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc index cb9e5cf14..057a1831b 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator.cc @@ -188,7 +188,7 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); } #if defined(__ANDROID__) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif return ::mediapipe::OkStatus(); @@ -201,15 +201,15 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); if (cc->Inputs().HasTag("TENSORS_GPU")) { gpu_input_ = true; #if defined(__ANDROID__) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #endif } - RETURN_IF_ERROR(LoadOptions(cc)); + MP_RETURN_IF_ERROR(LoadOptions(cc)); side_packet_anchors_ = cc->InputSidePackets().HasTag("ANCHORS"); if (gpu_input_) { - RETURN_IF_ERROR(GlSetup(cc)); + MP_RETURN_IF_ERROR(GlSetup(cc)); } return ::mediapipe::OkStatus(); @@ -225,9 +225,9 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); auto output_detections = absl::make_unique>(); if (gpu_input_) { - RETURN_IF_ERROR(ProcessGPU(cc, output_detections.get())); + MP_RETURN_IF_ERROR(ProcessGPU(cc, output_detections.get())); } else { - RETURN_IF_ERROR(ProcessCPU(cc, output_detections.get())); + MP_RETURN_IF_ERROR(ProcessCPU(cc, output_detections.get())); } // if gpu_input_ // Output @@ -282,7 +282,7 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); anchors_init_ = true; } std::vector boxes(num_boxes_ * num_coords_); - RETURN_IF_ERROR(DecodeBoxes(raw_boxes, anchors_, &boxes)); + MP_RETURN_IF_ERROR(DecodeBoxes(raw_boxes, anchors_, &boxes)); std::vector detection_scores(num_boxes_); std::vector detection_classes(num_boxes_); @@ -316,9 +316,9 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); detection_classes[i] = class_id; } - RETURN_IF_ERROR(ConvertToDetections(boxes.data(), detection_scores.data(), - detection_classes.data(), - output_detections)); + MP_RETURN_IF_ERROR( + ConvertToDetections(boxes.data(), detection_scores.data(), + detection_classes.data(), output_detections)); } else { // Postprocessing on CPU with postprocessing op (e.g. anchor decoding and // non-maximum suppression) within the model. @@ -350,9 +350,9 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); detection_classes[i] = static_cast(detection_classes_tensor->data.f[i]); } - RETURN_IF_ERROR(ConvertToDetections(detection_boxes, detection_scores, - detection_classes.data(), - output_detections)); + MP_RETURN_IF_ERROR(ConvertToDetections(detection_boxes, detection_scores, + detection_classes.data(), + output_detections)); } return ::mediapipe::OkStatus(); } @@ -381,7 +381,7 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); } // Run shaders. - RETURN_IF_ERROR(gpu_helper_.RunInGlContext( + MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext( [this, &input_tensors]() -> ::mediapipe::Status { // Decode boxes. decoded_boxes_buffer_->BindToIndex(0); @@ -419,9 +419,9 @@ REGISTER_CALCULATOR(TfLiteTensorsToDetectionsCalculator); detection_scores[i] = score_class_id_pairs[i * 2]; detection_classes[i] = static_cast(score_class_id_pairs[i * 2 + 1]); } - RETURN_IF_ERROR(ConvertToDetections(boxes.data(), detection_scores.data(), - detection_classes.data(), - output_detections)); + MP_RETURN_IF_ERROR(ConvertToDetections(boxes.data(), detection_scores.data(), + detection_classes.data(), + output_detections)); #else LOG(ERROR) << "GPU input on non-Android not supported yet."; #endif // defined(__ANDROID__) diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator.cc b/mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator.cc index d77e1514c..3b938a1cd 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator.cc @@ -89,7 +89,7 @@ REGISTER_CALCULATOR(TfLiteTensorsToLandmarksCalculator); CalculatorContext* cc) { cc->SetOffset(TimestampDiff(0)); - RETURN_IF_ERROR(LoadOptions(cc)); + MP_RETURN_IF_ERROR(LoadOptions(cc)); if (cc->Outputs().HasTag("NORM_LANDMARKS")) { RET_CHECK(options_.has_input_image_height() && diff --git a/mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator.cc b/mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator.cc index 7b903f157..20aca8e30 100644 --- a/mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator.cc @@ -177,7 +177,7 @@ REGISTER_CALCULATOR(TfLiteTensorsToSegmentationCalculator); #endif // __ANDROID__ #if defined(__ANDROID__) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ return ::mediapipe::OkStatus(); @@ -190,17 +190,17 @@ REGISTER_CALCULATOR(TfLiteTensorsToSegmentationCalculator); if (cc->Inputs().HasTag("TENSORS_GPU")) { use_gpu_ = true; #if defined(__ANDROID__) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #endif // __ANDROID__ } - RETURN_IF_ERROR(LoadOptions(cc)); + MP_RETURN_IF_ERROR(LoadOptions(cc)); if (use_gpu_) { #if defined(__ANDROID__) - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status { - RETURN_IF_ERROR(InitGpu(cc)); + MP_RETURN_IF_ERROR(InitGpu(cc)); return ::mediapipe::OkStatus(); })); #else @@ -216,14 +216,14 @@ REGISTER_CALCULATOR(TfLiteTensorsToSegmentationCalculator); CalculatorContext* cc) { if (use_gpu_) { #if defined(__ANDROID__) - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status { - RETURN_IF_ERROR(ProcessGpu(cc)); + MP_RETURN_IF_ERROR(ProcessGpu(cc)); return ::mediapipe::OkStatus(); })); #endif // __ANDROID__ } else { - RETURN_IF_ERROR(ProcessCpu(cc)); + MP_RETURN_IF_ERROR(ProcessCpu(cc)); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/calculators/util/BUILD b/mediapipe/calculators/util/BUILD index 8204ff384..3dde96aee 100644 --- a/mediapipe/calculators/util/BUILD +++ b/mediapipe/calculators/util/BUILD @@ -79,7 +79,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/util:color_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":annotation_overlay_calculator_proto"], ) @@ -89,7 +89,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [ ":detection_label_id_to_text_calculator_proto", ], @@ -106,7 +106,7 @@ mediapipe_cc_proto_library( name = "non_max_suppression_calculator_cc_proto", srcs = ["non_max_suppression_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":non_max_suppression_calculator_proto"], ) @@ -303,7 +303,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":thresholding_calculator_proto"], ) @@ -326,7 +326,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":landmarks_to_detection_calculator_proto"], ) @@ -352,7 +352,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":detections_to_rects_calculator_proto"], ) @@ -362,7 +362,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":landmark_projection_calculator_proto"], ) @@ -372,7 +372,7 @@ mediapipe_cc_proto_library( cc_deps = [ "//mediapipe/framework:calculator_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":rect_transformation_calculator_proto"], ) @@ -517,7 +517,7 @@ mediapipe_cc_proto_library( "//mediapipe/util:color_cc_proto", "//mediapipe/util:render_data_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":rect_to_render_data_calculator_proto"], ) @@ -529,7 +529,7 @@ mediapipe_cc_proto_library( "//mediapipe/util:color_cc_proto", "//mediapipe/util:render_data_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":detections_to_render_data_calculator_proto"], ) @@ -560,7 +560,7 @@ mediapipe_cc_proto_library( "//mediapipe/util:color_cc_proto", "//mediapipe/util:render_data_cc_proto", ], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":landmarks_to_render_data_calculator_proto"], ) diff --git a/mediapipe/calculators/util/annotation_overlay_calculator.cc b/mediapipe/calculators/util/annotation_overlay_calculator.cc index 5cd4e20e2..ee21302ef 100644 --- a/mediapipe/calculators/util/annotation_overlay_calculator.cc +++ b/mediapipe/calculators/util/annotation_overlay_calculator.cc @@ -200,7 +200,7 @@ REGISTER_CALCULATOR(AnnotationOverlayCalculator); } #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(mediapipe::GlCalculatorHelper::UpdateContract(cc)); #endif // __ANDROID__ or iOS return ::mediapipe::OkStatus(); @@ -247,7 +247,7 @@ REGISTER_CALCULATOR(AnnotationOverlayCalculator); if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) - RETURN_IF_ERROR(gpu_helper_.Open(cc)); + MP_RETURN_IF_ERROR(gpu_helper_.Open(cc)); #endif // __ANDROID__ or iOS } @@ -262,17 +262,17 @@ REGISTER_CALCULATOR(AnnotationOverlayCalculator); if (use_gpu_) { #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) if (!gpu_initialized_) { - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( gpu_helper_.RunInGlContext([this, cc]() -> ::mediapipe::Status { - RETURN_IF_ERROR(GlSetup(cc)); + MP_RETURN_IF_ERROR(GlSetup(cc)); return ::mediapipe::OkStatus(); })); gpu_initialized_ = true; } #endif // __ANDROID__ or iOS - RETURN_IF_ERROR(CreateRenderTargetGpu(cc, image_mat)); + MP_RETURN_IF_ERROR(CreateRenderTargetGpu(cc, image_mat)); } else { - RETURN_IF_ERROR(CreateRenderTargetCpu(cc, image_mat, &target_format)); + MP_RETURN_IF_ERROR(CreateRenderTargetCpu(cc, image_mat, &target_format)); } // Reset the renderer with the image_mat. No copy here. @@ -291,16 +291,16 @@ REGISTER_CALCULATOR(AnnotationOverlayCalculator); #if defined(__ANDROID__) || (defined(__APPLE__) && !TARGET_OS_OSX) // Overlay rendered image in OpenGL, onto a copy of input. uchar* image_mat_ptr = image_mat->data; - RETURN_IF_ERROR(gpu_helper_.RunInGlContext( + MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext( [this, cc, image_mat_ptr]() -> ::mediapipe::Status { - RETURN_IF_ERROR(RenderToGpu(cc, image_mat_ptr)); + MP_RETURN_IF_ERROR(RenderToGpu(cc, image_mat_ptr)); return ::mediapipe::OkStatus(); })); #endif // __ANDROID__ or iOS } else { // Copy the rendered image to output. uchar* image_mat_ptr = image_mat->data; - RETURN_IF_ERROR(RenderToCpu(cc, target_format, image_mat_ptr)); + MP_RETURN_IF_ERROR(RenderToCpu(cc, target_format, image_mat_ptr)); } return ::mediapipe::OkStatus(); @@ -372,7 +372,7 @@ REGISTER_CALCULATOR(AnnotationOverlayCalculator); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, image_mat_tex_); - RETURN_IF_ERROR(GlRender(cc)); + MP_RETURN_IF_ERROR(GlRender(cc)); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc b/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc index 1c33b45a9..0fb2d30b8 100644 --- a/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc +++ b/mediapipe/calculators/util/detection_label_id_to_text_calculator.cc @@ -75,7 +75,7 @@ REGISTER_CALCULATOR(DetectionLabelIdToTextCalculator); std::string string_path; ASSIGN_OR_RETURN(string_path, PathToResourceAsFile(options.label_map_path())); std::string label_map_string; - RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); + MP_RETURN_IF_ERROR(file::GetContents(string_path, &label_map_string)); std::istringstream stream(label_map_string); std::string line; diff --git a/mediapipe/calculators/util/detection_letterbox_removal_calculator_test.cc b/mediapipe/calculators/util/detection_letterbox_removal_calculator_test.cc index e2a04e525..250816305 100644 --- a/mediapipe/calculators/util/detection_letterbox_removal_calculator_test.cc +++ b/mediapipe/calculators/util/detection_letterbox_removal_calculator_test.cc @@ -86,7 +86,7 @@ TEST(DetectionLetterboxRemovalCalculatorTest, PaddingLeftRight) { ->Tag("LETTERBOX_PADDING") .packets.push_back(Adopt(padding.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("DETECTIONS").packets; ASSERT_EQ(1, output.size()); @@ -134,7 +134,7 @@ TEST(DetectionLetterboxRemovalCalculatorTest, PaddingTopBottom) { ->Tag("LETTERBOX_PADDING") .packets.push_back(Adopt(padding.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("DETECTIONS").packets; ASSERT_EQ(1, output.size()); diff --git a/mediapipe/calculators/util/detections_to_rects_calculator.cc b/mediapipe/calculators/util/detections_to_rects_calculator.cc index 4dbf90054..bb5ba6d4d 100644 --- a/mediapipe/calculators/util/detections_to_rects_calculator.cc +++ b/mediapipe/calculators/util/detections_to_rects_calculator.cc @@ -245,7 +245,7 @@ REGISTER_CALCULATOR(DetectionsToRectsCalculator); if (cc->Outputs().HasTag(kRectTag)) { auto output_rect = absl::make_unique(); - RETURN_IF_ERROR(DetectionToRect(detections[0], output_rect.get())); + MP_RETURN_IF_ERROR(DetectionToRect(detections[0], output_rect.get())); if (rotate_) { output_rect->set_rotation(ComputeRotation(detections[0], image_size)); } @@ -254,7 +254,7 @@ REGISTER_CALCULATOR(DetectionsToRectsCalculator); } if (cc->Outputs().HasTag(kNormRectTag)) { auto output_rect = absl::make_unique(); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( DetectionToNormalizedRect(detections[0], output_rect.get())); if (rotate_) { output_rect->set_rotation(ComputeRotation(detections[0], image_size)); @@ -266,7 +266,8 @@ REGISTER_CALCULATOR(DetectionsToRectsCalculator); if (cc->Outputs().HasTag(kRectsTag)) { auto output_rects = absl::make_unique>(detections.size()); for (int i = 0; i < detections.size(); ++i) { - RETURN_IF_ERROR(DetectionToRect(detections[i], &(output_rects->at(i)))); + MP_RETURN_IF_ERROR( + DetectionToRect(detections[i], &(output_rects->at(i)))); if (rotate_) { output_rects->at(i).set_rotation( ComputeRotation(detections[i], image_size)); @@ -279,7 +280,7 @@ REGISTER_CALCULATOR(DetectionsToRectsCalculator); auto output_rects = absl::make_unique>(detections.size()); for (int i = 0; i < detections.size(); ++i) { - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( DetectionToNormalizedRect(detections[i], &(output_rects->at(i)))); if (rotate_) { output_rects->at(i).set_rotation( diff --git a/mediapipe/calculators/util/detections_to_rects_calculator_test.cc b/mediapipe/calculators/util/detections_to_rects_calculator_test.cc index 8b2b8f166..7281847ca 100644 --- a/mediapipe/calculators/util/detections_to_rects_calculator_test.cc +++ b/mediapipe/calculators/util/detections_to_rects_calculator_test.cc @@ -66,7 +66,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToRect) { .packets.push_back( Adopt(detection.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("RECT").packets; ASSERT_EQ(1, output.size()); const auto& rect = output[0].Get(); @@ -91,7 +91,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToNormalizedRect) { .packets.push_back( Adopt(detection.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("NORM_RECT").packets; ASSERT_EQ(1, output.size()); const auto& rect = output[0].Get(); @@ -117,7 +117,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToRect) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("RECT").packets; ASSERT_EQ(1, output.size()); const auto& rect = output[0].Get(); @@ -143,7 +143,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToNormalizedRect) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("NORM_RECT").packets; ASSERT_EQ(1, output.size()); const auto& rect = output[0].Get(); @@ -169,7 +169,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToRects) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("RECTS").packets; ASSERT_EQ(1, output.size()); const auto& rects = output[0].Get>(); @@ -200,7 +200,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionsToNormalizedRects) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("NORM_RECTS").packets; ASSERT_EQ(1, output.size()); @@ -231,7 +231,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToRects) { .packets.push_back( Adopt(detection.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("RECTS").packets; ASSERT_EQ(1, output.size()); const auto& rects = output[0].Get>(); @@ -257,7 +257,7 @@ TEST(DetectionsToRectsCalculatorTest, DetectionToNormalizedRects) { .packets.push_back( Adopt(detection.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("NORM_RECTS").packets; ASSERT_EQ(1, output.size()); diff --git a/mediapipe/calculators/util/detections_to_render_data_calculator_test.cc b/mediapipe/calculators/util/detections_to_render_data_calculator_test.cc index 23a4d7874..2f1c6faa8 100644 --- a/mediapipe/calculators/util/detections_to_render_data_calculator_test.cc +++ b/mediapipe/calculators/util/detections_to_render_data_calculator_test.cc @@ -101,7 +101,7 @@ TEST(DetectionsToRenderDataCalculatorTest, OnlyDetecctionList) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("RENDER_DATA").packets; ASSERT_EQ(1, output.size()); @@ -135,7 +135,7 @@ TEST(DetectionsToRenderDataCalculatorTest, OnlyDetecctionVector) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("RENDER_DATA").packets; ASSERT_EQ(1, output.size()); @@ -178,7 +178,7 @@ TEST(DetectionsToRenderDataCalculatorTest, BothDetecctionListAndVector) { .packets.push_back( Adopt(detections.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& actual = runner.Outputs().Tag("RENDER_DATA").packets; ASSERT_EQ(1, actual.size()); @@ -218,7 +218,7 @@ TEST(DetectionsToRenderDataCalculatorTest, ProduceEmptyPacket) { .packets.push_back( Adopt(detections1.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner1.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner1.Run()) << "Calculator execution failed."; const std::vector& exact1 = runner1.Outputs().Tag("RENDER_DATA").packets; ASSERT_EQ(0, exact1.size()); @@ -248,7 +248,7 @@ TEST(DetectionsToRenderDataCalculatorTest, ProduceEmptyPacket) { .packets.push_back( Adopt(detections2.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner2.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner2.Run()) << "Calculator execution failed."; const std::vector& exact2 = runner2.Outputs().Tag("RENDER_DATA").packets; ASSERT_EQ(1, exact2.size()); diff --git a/mediapipe/calculators/util/landmark_letterbox_removal_calculator_test.cc b/mediapipe/calculators/util/landmark_letterbox_removal_calculator_test.cc index 8bea2c54d..33724890e 100644 --- a/mediapipe/calculators/util/landmark_letterbox_removal_calculator_test.cc +++ b/mediapipe/calculators/util/landmark_letterbox_removal_calculator_test.cc @@ -58,7 +58,7 @@ TEST(LandmarkLetterboxRemovalCalculatorTest, PaddingLeftRight) { ->Tag("LETTERBOX_PADDING") .packets.push_back(Adopt(padding.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("LANDMARKS").packets; ASSERT_EQ(1, output.size()); const auto& output_landmarks = @@ -92,7 +92,7 @@ TEST(LandmarkLetterboxRemovalCalculatorTest, PaddingTopBottom) { ->Tag("LETTERBOX_PADDING") .packets.push_back(Adopt(padding.release()).At(Timestamp::PostStream())); - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output = runner.Outputs().Tag("LANDMARKS").packets; ASSERT_EQ(1, output.size()); const auto& output_landmarks = diff --git a/mediapipe/calculators/util/packet_frequency_calculator_test.cc b/mediapipe/calculators/util/packet_frequency_calculator_test.cc index 7e2bfa706..f1549654a 100644 --- a/mediapipe/calculators/util/packet_frequency_calculator_test.cc +++ b/mediapipe/calculators/util/packet_frequency_calculator_test.cc @@ -87,7 +87,7 @@ TEST(PacketFrequencyCalculatorTest, MultiPacketTest) { Adopt(new int).At(Timestamp(9000000))); // Run the calculator. - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output_packets = runner.Outputs().Index(0).packets; // Very first packet. So frequency is zero. @@ -153,7 +153,7 @@ TEST(PacketFrequencyCalculatorTest, MultiStreamTest) { Adopt(new std::string).At(Timestamp(3000000))); // Run the calculator. - MEDIAPIPE_ASSERT_OK(runner.Run()) << "Calculator execution failed."; + MP_ASSERT_OK(runner.Run()) << "Calculator execution failed."; const std::vector& output_packets_stream_1 = runner.Outputs().Index(0).packets; const std::vector& output_packets_stream_2 = diff --git a/mediapipe/calculators/util/packet_latency_calculator_test.cc b/mediapipe/calculators/util/packet_latency_calculator_test.cc index 8c32d7dcc..25d28d061 100644 --- a/mediapipe/calculators/util/packet_latency_calculator_test.cc +++ b/mediapipe/calculators/util/packet_latency_calculator_test.cc @@ -34,7 +34,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test { void SetupSimulationClock() { auto executor = std::make_shared(4); simulation_clock_ = executor->GetClock(); - MEDIAPIPE_ASSERT_OK(graph_.SetExecutor("", executor)); + MP_ASSERT_OK(graph_.SetExecutor("", executor)); } void InitializeSingleStreamGraph() { @@ -72,10 +72,10 @@ class PacketLatencyCalculatorTest : public ::testing::Test { simulation_clock_); // Start graph run. - MEDIAPIPE_ASSERT_OK(graph_.Initialize(graph_config_, {})); - MEDIAPIPE_ASSERT_OK(graph_.StartRun(side_packet)); + MP_ASSERT_OK(graph_.Initialize(graph_config_, {})); + MP_ASSERT_OK(graph_.StartRun(side_packet)); // Let Calculator::Open() calls finish before continuing. - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilIdle()); + MP_ASSERT_OK(graph_.WaitUntilIdle()); } void InitializeMultipleStreamGraph() { @@ -115,7 +115,7 @@ class PacketLatencyCalculatorTest : public ::testing::Test { &out_1_packets_); mediapipe::tool::AddVectorSink("packet_latency_2", &graph_config_, &out_2_packets_); - MEDIAPIPE_ASSERT_OK(graph_.Initialize(graph_config_, {})); + MP_ASSERT_OK(graph_.Initialize(graph_config_, {})); // Create the simulation clock side packet. simulation_clock_.reset(new SimulationClock()); @@ -125,9 +125,9 @@ class PacketLatencyCalculatorTest : public ::testing::Test { simulation_clock_); // Start graph run. - MEDIAPIPE_ASSERT_OK(graph_.StartRun(side_packet)); + MP_ASSERT_OK(graph_.StartRun(side_packet)); // Let Calculator::Open() calls finish before continuing. - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilIdle()); + MP_ASSERT_OK(graph_.WaitUntilIdle()); } void InitializeSingleStreamGraphWithoutClock() { @@ -163,10 +163,10 @@ class PacketLatencyCalculatorTest : public ::testing::Test { simulation_clock_); // Start graph run. - MEDIAPIPE_ASSERT_OK(graph_.Initialize(graph_config_, {})); - MEDIAPIPE_ASSERT_OK(graph_.StartRun(side_packet)); + MP_ASSERT_OK(graph_.Initialize(graph_config_, {})); + MP_ASSERT_OK(graph_.StartRun(side_packet)); // Let Calculator::Open() calls finish before continuing. - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilIdle()); + MP_ASSERT_OK(graph_.WaitUntilIdle()); } PacketLatency CreatePacketLatency(const double latency_usec, @@ -205,16 +205,16 @@ TEST_F(PacketLatencyCalculatorTest, DoesNotOutputUntilInputPacketReceived) { dynamic_cast(&*simulation_clock_)->ThreadStart(); // Send reference packets with timestamps 0, 6 and 10 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(6)))); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(10)))); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect zero output packets. ASSERT_EQ(out_0_packets_.size(), 0); @@ -228,20 +228,20 @@ TEST_F(PacketLatencyCalculatorTest, OutputsCorrectLatencyForSingleStream) { // Send a reference packet with timestamp 10 usec at time 12 usec. simulation_clock_->Sleep(absl::Microseconds(12)); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(10)))); // Add two delayed packets with timestamp 1 and 8 resp. simulation_clock_->Sleep(absl::Microseconds(1)); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(1)))); simulation_clock_->Sleep(absl::Microseconds(1)); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(8)))); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect two latency packets with timestamp 1 and 8 resp. ASSERT_EQ(out_0_packets_.size(), 2); @@ -270,26 +270,26 @@ TEST_F(PacketLatencyCalculatorTest, DoesNotOutputUntilReferencePacketReceived) { dynamic_cast(&*simulation_clock_)->ThreadStart(); // Add two packets with timestamp 1 and 2. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(2)))); // Send a reference packet with timestamp 10 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(10)))); simulation_clock_->Sleep(absl::Microseconds(1)); // Add two delayed packets with timestamp 7 and 9 resp. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(7)))); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(9)))); simulation_clock_->Sleep(absl::Microseconds(1)); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect two latency packets with timestamp 7 and 9 resp. The packets with // timestamps 1 and 2 should not have any latency associated with them since @@ -320,18 +320,18 @@ TEST_F(PacketLatencyCalculatorTest, OutputsCorrectLatencyWhenNoClock) { dynamic_cast(&*simulation_clock_)->ThreadStart(); // Send a reference packet with timestamp 10 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(10)))); // Add two delayed packets with timestamp 5 and 10 resp. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(5)))); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(10)))); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect two latency packets with timestamp 5 and 10 resp. ASSERT_EQ(out_0_packets_.size(), 2); @@ -347,18 +347,18 @@ TEST_F(PacketLatencyCalculatorTest, dynamic_cast(&*simulation_clock_)->ThreadStart(); // Send a reference packet with timestamp 20 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(20)))); // Add two delayed packets with timestamp 0 and 20 resp. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(20)))); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect two latency packets with timestamp 0 and 20 resp. ASSERT_EQ(out_0_packets_.size(), 2); @@ -387,24 +387,24 @@ TEST_F(PacketLatencyCalculatorTest, ResetsHistogramAndAverageCorrectly) { dynamic_cast(&*simulation_clock_)->ThreadStart(); // Send a reference packet with timestamp 0 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(0)))); // Add a delayed packet with timestamp 0 usec at time 20 usec. simulation_clock_->Sleep(absl::Microseconds(20)); - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(0)))); // Do a long sleep so that histogram and average are reset. simulation_clock_->Sleep(absl::Microseconds(100)); // Add a delayed packet with timestamp 115 usec at time 120 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(115)))); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect two latency packets with timestamp 0 and 115 resp. ASSERT_EQ(out_0_packets_.size(), 2); @@ -435,26 +435,26 @@ TEST_F(PacketLatencyCalculatorTest, OutputsCorrectLatencyForMultipleStreams) { dynamic_cast(&*simulation_clock_)->ThreadStart(); // Send a reference packet with timestamp 10 usec. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "camera_frames", Adopt(new double()).At(Timestamp(10)))); // Add delayed packets on each input stream. // Fastest stream. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_0", Adopt(new double()).At(Timestamp(10)))); // Slow stream. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_1", Adopt(new double()).At(Timestamp(5)))); // Slowest stream. - MEDIAPIPE_ASSERT_OK(graph_.AddPacketToInputStream( + MP_ASSERT_OK(graph_.AddPacketToInputStream( "delayed_packet_2", Adopt(new double()).At(Timestamp(0)))); dynamic_cast(&*simulation_clock_)->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Expect one latency packet on each output stream. ASSERT_EQ(out_0_packets_.size(), 1); diff --git a/mediapipe/calculators/video/BUILD b/mediapipe/calculators/video/BUILD index 2244ad0dc..63781a8b4 100644 --- a/mediapipe/calculators/video/BUILD +++ b/mediapipe/calculators/video/BUILD @@ -37,7 +37,7 @@ mediapipe_cc_proto_library( name = "flow_to_image_calculator_cc_proto", srcs = ["flow_to_image_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":flow_to_image_calculator_proto"], ) @@ -45,7 +45,7 @@ mediapipe_cc_proto_library( name = "opencv_video_encoder_calculator_cc_proto", srcs = ["opencv_video_encoder_calculator.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":opencv_video_encoder_calculator_proto"], ) diff --git a/mediapipe/calculators/video/opencv_video_decoder_calculator_test.cc b/mediapipe/calculators/video/opencv_video_decoder_calculator_test.cc index 7d78bd728..0b57f494c 100644 --- a/mediapipe/calculators/video/opencv_video_decoder_calculator_test.cc +++ b/mediapipe/calculators/video/opencv_video_decoder_calculator_test.cc @@ -41,13 +41,13 @@ TEST(OpenCvVideoDecoderCalculatorTest, TestMp4Avc720pVideo) { file::JoinPath("./", "/mediapipe/calculators/video/" "testdata/format_MP4_AVC720P_AAC.video")); - MEDIAPIPE_EXPECT_OK(runner.Run()); + MP_EXPECT_OK(runner.Run()); EXPECT_EQ(runner.Outputs().Tag("VIDEO_PRESTREAM").packets.size(), 1); - MEDIAPIPE_EXPECT_OK(runner.Outputs() - .Tag("VIDEO_PRESTREAM") - .packets[0] - .ValidateAsType()); + MP_EXPECT_OK(runner.Outputs() + .Tag("VIDEO_PRESTREAM") + .packets[0] + .ValidateAsType()); const mediapipe::VideoHeader& header = runner.Outputs().Tag("VIDEO_PRESTREAM").packets[0].Get(); EXPECT_EQ(ImageFormat::SRGB, header.format); @@ -83,13 +83,13 @@ TEST(OpenCvVideoDecoderCalculatorTest, TestFlvH264Video) { file::JoinPath("./", "/mediapipe/calculators/video/" "testdata/format_FLV_H264_AAC.video")); - MEDIAPIPE_EXPECT_OK(runner.Run()); + MP_EXPECT_OK(runner.Run()); EXPECT_EQ(runner.Outputs().Tag("VIDEO_PRESTREAM").packets.size(), 1); - MEDIAPIPE_EXPECT_OK(runner.Outputs() - .Tag("VIDEO_PRESTREAM") - .packets[0] - .ValidateAsType()); + MP_EXPECT_OK(runner.Outputs() + .Tag("VIDEO_PRESTREAM") + .packets[0] + .ValidateAsType()); const mediapipe::VideoHeader& header = runner.Outputs().Tag("VIDEO_PRESTREAM").packets[0].Get(); EXPECT_EQ(ImageFormat::SRGB, header.format); @@ -127,13 +127,13 @@ TEST(OpenCvVideoDecoderCalculatorTest, TestMkvVp8Video) { file::JoinPath("./", "/mediapipe/calculators/video/" "testdata/format_MKV_VP8_VORBIS.video")); - MEDIAPIPE_EXPECT_OK(runner.Run()); + MP_EXPECT_OK(runner.Run()); EXPECT_EQ(runner.Outputs().Tag("VIDEO_PRESTREAM").packets.size(), 1); - MEDIAPIPE_EXPECT_OK(runner.Outputs() - .Tag("VIDEO_PRESTREAM") - .packets[0] - .ValidateAsType()); + MP_EXPECT_OK(runner.Outputs() + .Tag("VIDEO_PRESTREAM") + .packets[0] + .ValidateAsType()); const mediapipe::VideoHeader& header = runner.Outputs().Tag("VIDEO_PRESTREAM").packets[0].Get(); EXPECT_EQ(ImageFormat::SRGB, header.format); diff --git a/mediapipe/calculators/video/opencv_video_encoder_calculator_test.cc b/mediapipe/calculators/video/opencv_video_encoder_calculator_test.cc index 4323ce016..97adade07 100644 --- a/mediapipe/calculators/video/opencv_video_encoder_calculator_test.cc +++ b/mediapipe/calculators/video/opencv_video_encoder_calculator_test.cc @@ -66,17 +66,17 @@ TEST(OpenCvVideoEncoderCalculatorTest, DISABLED_TestMp4Avc720pVideo) { input_side_packets["output_file_path"] = MakePacket(output_file_path); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config, input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config, input_side_packets)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("video_prestream"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); Packet packet; while (poller.Next(&packet)) { } - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); const VideoHeader& video_header = packet.Get(); // Checks the generated video file has the same width, height, fps, and @@ -125,17 +125,17 @@ TEST(OpenCvVideoEncoderCalculatorTest, TestFlvH264Video) { input_side_packets["output_file_path"] = MakePacket(output_file_path); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config, input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config, input_side_packets)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("video_prestream"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); Packet packet; while (poller.Next(&packet)) { } - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); const VideoHeader& video_header = packet.Get(); // Checks the generated video file has the same width, height, fps, and @@ -186,17 +186,17 @@ TEST(OpenCvVideoEncoderCalculatorTest, TestMkvVp8Video) { input_side_packets["output_file_path"] = MakePacket(output_file_path); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config, input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config, input_side_packets)); StatusOrPoller status_or_poller = graph.AddOutputStreamPoller("video_prestream"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); Packet packet; while (poller.Next(&packet)) { } - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); const VideoHeader& video_header = packet.Get(); // Checks the generated video file has the same width, height, fps, and diff --git a/mediapipe/calculators/video/tool/BUILD b/mediapipe/calculators/video/tool/BUILD index 422bb034a..3d561c3a7 100644 --- a/mediapipe/calculators/video/tool/BUILD +++ b/mediapipe/calculators/video/tool/BUILD @@ -24,6 +24,7 @@ load("//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library" proto_library( name = "flow_quantizer_model_proto", srcs = ["flow_quantizer_model.proto"], + visibility = ["//mediapipe:__subpackages__"], ) mediapipe_cc_proto_library( diff --git a/mediapipe/calculators/video/tvl1_optical_flow_calculator.cc b/mediapipe/calculators/video/tvl1_optical_flow_calculator.cc index 2d361a8e2..8ee666c57 100644 --- a/mediapipe/calculators/video/tvl1_optical_flow_calculator.cc +++ b/mediapipe/calculators/video/tvl1_optical_flow_calculator.cc @@ -133,16 +133,16 @@ class Tvl1OpticalFlowCalculator : public CalculatorBase { cc->Inputs().Tag("SECOND_FRAME").Value().Get(); if (forward_requested_) { auto forward_optical_flow_field = absl::make_unique(); - RETURN_IF_ERROR(CalculateOpticalFlow(first_frame, second_frame, - forward_optical_flow_field.get())); + MP_RETURN_IF_ERROR(CalculateOpticalFlow(first_frame, second_frame, + forward_optical_flow_field.get())); cc->Outputs() .Tag("FORWARD_FLOW") .Add(forward_optical_flow_field.release(), cc->InputTimestamp()); } if (backward_requested_) { auto backward_optical_flow_field = absl::make_unique(); - RETURN_IF_ERROR(CalculateOpticalFlow(second_frame, first_frame, - backward_optical_flow_field.get())); + MP_RETURN_IF_ERROR(CalculateOpticalFlow(second_frame, first_frame, + backward_optical_flow_field.get())); cc->Outputs() .Tag("BACKWARD_FLOW") .Add(backward_optical_flow_field.release(), cc->InputTimestamp()); diff --git a/mediapipe/calculators/video/tvl1_optical_flow_calculator_test.cc b/mediapipe/calculators/video/tvl1_optical_flow_calculator_test.cc index e187d1aa9..b226dfd87 100644 --- a/mediapipe/calculators/video/tvl1_optical_flow_calculator_test.cc +++ b/mediapipe/calculators/video/tvl1_optical_flow_calculator_test.cc @@ -49,12 +49,12 @@ void AddInputPackets(int num_packets, CalculatorGraph* graph) { } for (int i = 0; i < num_packets; ++i) { - MEDIAPIPE_ASSERT_OK(graph->AddPacketToInputStream( - "first_frames", packet1.At(Timestamp(i)))); - MEDIAPIPE_ASSERT_OK(graph->AddPacketToInputStream( - "second_frames", packet2.At(Timestamp(i)))); + MP_ASSERT_OK(graph->AddPacketToInputStream("first_frames", + packet1.At(Timestamp(i)))); + MP_ASSERT_OK(graph->AddPacketToInputStream("second_frames", + packet2.At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph->CloseAllInputStreams()); + MP_ASSERT_OK(graph->CloseAllInputStreams()); } void RunTest(int num_input_packets, int max_in_flight) { @@ -74,7 +74,7 @@ void RunTest(int num_input_packets, int max_in_flight) { )", max_in_flight)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); StatusOrPoller status_or_poller1 = graph.AddOutputStreamPoller("forward_flow"); ASSERT_TRUE(status_or_poller1.ok()); @@ -84,7 +84,7 @@ void RunTest(int num_input_packets, int max_in_flight) { ASSERT_TRUE(status_or_poller2.ok()); OutputStreamPoller poller2 = std::move(status_or_poller2.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); AddInputPackets(num_input_packets, &graph); Packet packet; std::vector forward_optical_flow_packets; @@ -95,7 +95,7 @@ void RunTest(int num_input_packets, int max_in_flight) { while (poller2.Next(&packet)) { backward_optical_flow_packets.emplace_back(packet); } - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(num_input_packets, forward_optical_flow_packets.size()); int count = 0; diff --git a/mediapipe/docs/install.md b/mediapipe/docs/install.md index 808fe13f8..4b82b7cb0 100644 --- a/mediapipe/docs/install.md +++ b/mediapipe/docs/install.md @@ -7,11 +7,11 @@ future. Note: If you plan to use TensorFlow calculators and example apps, there is a known issue with gcc and g++ version 6.3 and 7.3. Please use other versions. -Note: While Mediapipe configuring TensorFlow with Python 2, if you see the +Note: While Mediapipe configures TensorFlow, if you see the following error: -'"/private/var/.../org_tensorflow/third_party/git/git_configure.bzl", line 14, -in _fail fail(("%sGit Configuration Error:%s %...)))', please install the python -future library by `$ pip install --user future` +`"...git_configure.bzl", line 14, in _fail fail(("%sGit Configuration +Error:%s %...)))`, +please install the python future library using: `$ pip install --user future`. Choose your operating system: @@ -41,7 +41,7 @@ To build and run iOS apps: $ cd mediapipe ``` -2. Install Bazel (0.23 and above required). +2. Install Bazel (0.24.1 and above required). Option 1. Use package manager tool to install the latest version of Bazel. @@ -139,7 +139,7 @@ To build and run iOS apps: $ cd mediapipe ``` -2. Install Bazel (0.23 and above required). +2. Install Bazel (0.24.1 and above required). Follow Bazel's [documentation](https://docs.bazel.build/versions/master/install-redhat.html) @@ -227,7 +227,7 @@ To build and run iOS apps: $ cd mediapipe ``` -3. Install Bazel (0.23 and above required). +3. Install Bazel (0.24.1 and above required). Option 1. Use package manager tool to install the latest version of Bazel. @@ -360,7 +360,7 @@ To build and run iOS apps: username@DESKTOP-TMVLBJ1:~$ sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential git python zip adb openjdk-8-jdk ``` -5. Install Bazel (0.23 and above required). +5. Install Bazel (0.24.1 and above required). ```bash username@DESKTOP-TMVLBJ1:~$ curl -sLO --retry 5 --retry-max-time 10 \ @@ -571,9 +571,10 @@ Please verify all the necessary packages are installed. ### Setting up Android Studio with MediaPipe -The steps below use Android Studio to build and install a MediaPipe example app. +The steps below use Android Studio 3.5 to build and install a MediaPipe example +app. -1. Install and launch Android Studio. +1. Install and launch Android Studio 3.5. 2. Select `Configure` | `SDK Manager` | `SDK Platforms`. @@ -588,24 +589,31 @@ The steps below use Android Studio to build and install a MediaPipe example app. * Verify that Android SDK Tools 26.1.1 is installed. * Verify that Android NDK 17c or above is installed. * Take note of the Android NDK Location, e.g., - `/usr/local/home/Android/Sdk/ndk-bundle`. + `/usr/local/home/Android/Sdk/ndk-bundle` or + `/usr/local/home/Android/Sdk/ndk/20.0.5594570`. 4. Set environment variables `$ANDROID_HOME` and `$ANDROID_NDK_HOME` to point to the installed SDK and NDK. ```bash export ANDROID_HOME=/usr/local/home/Android/Sdk + + # If the NDK libraries are installed by a previous version of Android Studio, do export ANDROID_NDK_HOME=/usr/local/home/Android/Sdk/ndk-bundle + # If the NDK libraries are installed by Android Studio 3.5, do + export ANDROID_NDK_HOME=/usr/local/home/Android/Sdk/ndk/ ``` 5. Select `Configure` | `Plugins` install `Bazel`. -6. Select `Android Studio` | `Preferences` | `Bazel settings` and modify `Bazel binary location` to be the same as the output of `$ which bazel`. +6. On Linux, select `File` | `Settings`| `Bazel settings`. On macos, select + `Android Studio` | `Preferences` | `Bazel settings`. Then, modify `Bazel + binary location` to be the same as the output of `$ which bazel`. 7. Select `Import Bazel Project`. - * Select `Workspace`: `/path/to/mediapipe`. - * Select `Generate from BUILD file`: `/path/to/mediapipe/BUILD`. + * Select `Workspace`: `/path/to/mediapipe` and select `Next`. + * Select `Generate from BUILD file`: `/path/to/mediapipe/BUILD` and select `Next`. * Modify `Project View` to be the following and select `Finish`. ``` @@ -616,19 +624,43 @@ The steps below use Android Studio to build and install a MediaPipe example app. -mediapipe/examples/ios targets: - //mediapipe/...:all + //mediapipe/examples/android/...:all + //mediapipe/java/...:all android_sdk_platform: android-29 ``` -8. Connect an Android device to the workstation. +8. Select `Bazel` | `Sync` | `Sync project with Build files`. -9. Select `Run...` | `Edit Configurations...`. + Note: Even after doing step 4, if you still see the error: + `"no such package '@androidsdk//': Either the path + attribute of android_sdk_repository or the ANDROID_HOME environment variable + must be set."`, please modify the **WORKSPACE** file to point + to your SDK and NDK library locations, as below: + ``` + android_sdk_repository( + name = "androidsdk", + path = "/path/to/android/sdk" + ) + + android_ndk_repository( + name = "androidndk", + path = "/path/to/android/ndk" + ) + ``` + +9. Connect an Android device to the workstation. + +10. Select `Run...` | `Edit Configurations...`. + + * Select `Templates` | `Bazel Command`. * Enter Target Expression: `//mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu` - * Enter Bazel command: `mobile-install` - * Enter Bazel flags: `-c opt --config=android_arm64` select `Run` + * Enter Bazel command: `mobile-install`. + * Enter Bazel flags: `-c opt --config=android_arm64`. + * Press the `[+]` button to add the new configuration. + * Select `Run` to run the example app on the connected Android device. [`WORKSAPCE`]: https://github.com/google/mediapipe/tree/master/WORKSPACE [`opencv_linux.BUILD`]: https://github.com/google/mediapipe/tree/master/third_party/opencv_linux.BUILD diff --git a/mediapipe/examples/desktop/hello_world/hello_world.cc b/mediapipe/examples/desktop/hello_world/hello_world.cc index 64f3d348b..b7dfa40c3 100644 --- a/mediapipe/examples/desktop/hello_world/hello_world.cc +++ b/mediapipe/examples/desktop/hello_world/hello_world.cc @@ -39,17 +39,17 @@ namespace mediapipe { )"); CalculatorGraph graph; - RETURN_IF_ERROR(graph.Initialize(config)); + MP_RETURN_IF_ERROR(graph.Initialize(config)); ASSIGN_OR_RETURN(OutputStreamPoller poller, graph.AddOutputStreamPoller("out")); - RETURN_IF_ERROR(graph.StartRun({})); + MP_RETURN_IF_ERROR(graph.StartRun({})); // Give 10 input packets that contains the same std::string "Hello World!". for (int i = 0; i < 10; ++i) { - RETURN_IF_ERROR(graph.AddPacketToInputStream( + MP_RETURN_IF_ERROR(graph.AddPacketToInputStream( "in", MakePacket("Hello World!").At(Timestamp(i)))); } // Close the input stream "in". - RETURN_IF_ERROR(graph.CloseInputStream("in")); + MP_RETURN_IF_ERROR(graph.CloseInputStream("in")); mediapipe::Packet packet; // Get the output packets std::string. while (poller.Next(&packet)) { diff --git a/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc b/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc index bc2d911bf..5b46c114c 100644 --- a/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc +++ b/mediapipe/examples/desktop/media_sequence/run_graph_file_io_main.cc @@ -39,7 +39,7 @@ DEFINE_string(output_side_packets, "", ::mediapipe::Status RunMPPGraph() { std::string calculator_graph_config_contents; - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( FLAGS_calculator_graph_config_file, &calculator_graph_config_contents)); LOG(INFO) << "Get calculator graph config contents: " << calculator_graph_config_contents; @@ -54,16 +54,16 @@ DEFINE_string(output_side_packets, "", RET_CHECK(name_and_value.size() == 2); RET_CHECK(!::mediapipe::ContainsKey(input_side_packets, name_and_value[0])); std::string input_side_packet_contents; - RETURN_IF_ERROR(mediapipe::file::GetContents(name_and_value[1], - &input_side_packet_contents)); + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( + name_and_value[1], &input_side_packet_contents)); input_side_packets[name_and_value[0]] = ::mediapipe::MakePacket(input_side_packet_contents); } LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; - RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); + MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); LOG(INFO) << "Start running the calculator graph."; - RETURN_IF_ERROR(graph.Run()); + MP_RETURN_IF_ERROR(graph.Run()); LOG(INFO) << "Gathering output side packets."; kv_pairs = absl::StrSplit(FLAGS_output_side_packets, ','); for (const std::string& kv_pair : kv_pairs) { @@ -75,7 +75,7 @@ DEFINE_string(output_side_packets, "", << "Packet " << name_and_value[0] << " was not available."; const std::string& serialized_string = output_packet.ValueOrDie().Get(); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( mediapipe::file::SetContents(name_and_value[1], serialized_string)); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/examples/desktop/simple_run_graph_main.cc b/mediapipe/examples/desktop/simple_run_graph_main.cc index 7fc93142c..c912837f8 100644 --- a/mediapipe/examples/desktop/simple_run_graph_main.cc +++ b/mediapipe/examples/desktop/simple_run_graph_main.cc @@ -33,7 +33,7 @@ DEFINE_string(input_side_packets, "", ::mediapipe::Status RunMPPGraph() { std::string calculator_graph_config_contents; - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( FLAGS_calculator_graph_config_file, &calculator_graph_config_contents)); LOG(INFO) << "Get calculator graph config contents: " << calculator_graph_config_contents; @@ -52,7 +52,7 @@ DEFINE_string(input_side_packets, "", } LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; - RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); + MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); LOG(INFO) << "Start running the calculator graph."; return graph.Run(); } diff --git a/mediapipe/examples/desktop/youtube8m/README.md b/mediapipe/examples/desktop/youtube8m/README.md index e5227666f..b777cd789 100644 --- a/mediapipe/examples/desktop/youtube8m/README.md +++ b/mediapipe/examples/desktop/youtube8m/README.md @@ -47,7 +47,7 @@ --define MEDIAPIPE_DISABLE_GPU=1 --define no_aws_support=true \ mediapipe/examples/desktop/youtube8m:extract_yt8m_features - ./bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_features + ./bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_features \ --calculator_graph_config_file=mediapipe/graphs/youtube8m/feature_extraction.pbtxt \ --input_side_packets=input_sequence_example=/tmp/mediapipe/metadata.tfrecord \ --output_side_packets=output_sequence_example=/tmp/mediapipe/output.tfrecord diff --git a/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc b/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc index 09b6a2bc0..6807dbd66 100644 --- a/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc +++ b/mediapipe/examples/desktop/youtube8m/extract_yt8m_features.cc @@ -40,7 +40,7 @@ DEFINE_string(output_side_packets, "", ::mediapipe::Status RunMPPGraph() { std::string calculator_graph_config_contents; - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( FLAGS_calculator_graph_config_file, &calculator_graph_config_contents)); LOG(INFO) << "Get calculator graph config contents: " << calculator_graph_config_contents; @@ -55,8 +55,8 @@ DEFINE_string(output_side_packets, "", RET_CHECK(name_and_value.size() == 2); RET_CHECK(!::mediapipe::ContainsKey(input_side_packets, name_and_value[0])); std::string input_side_packet_contents; - RETURN_IF_ERROR(mediapipe::file::GetContents(name_and_value[1], - &input_side_packet_contents)); + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( + name_and_value[1], &input_side_packet_contents)); input_side_packets[name_and_value[0]] = ::mediapipe::MakePacket(input_side_packet_contents); } @@ -68,7 +68,7 @@ DEFINE_string(output_side_packets, "", vggish_pca_mean_matrix, vggish_pca_projection_matrix; std::string content; - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( "/tmp/mediapipe/inception3_mean_matrix_data.pb", &content)); inc3_pca_mean_matrix_data.ParseFromString(content); mediapipe::MatrixFromMatrixDataProto(inc3_pca_mean_matrix_data, @@ -76,7 +76,7 @@ DEFINE_string(output_side_packets, "", input_side_packets["inception3_pca_mean_matrix"] = ::mediapipe::MakePacket(inc3_pca_mean_matrix); - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( "/tmp/mediapipe/inception3_projection_matrix_data.pb", &content)); inc3_pca_projection_matrix_data.ParseFromString(content); mediapipe::MatrixFromMatrixDataProto(inc3_pca_projection_matrix_data, @@ -84,7 +84,7 @@ DEFINE_string(output_side_packets, "", input_side_packets["inception3_pca_projection_matrix"] = ::mediapipe::MakePacket(inc3_pca_projection_matrix); - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( "/tmp/mediapipe/vggish_mean_matrix_data.pb", &content)); vggish_pca_mean_matrix_data.ParseFromString(content); mediapipe::MatrixFromMatrixDataProto(vggish_pca_mean_matrix_data, @@ -92,7 +92,7 @@ DEFINE_string(output_side_packets, "", input_side_packets["vggish_pca_mean_matrix"] = ::mediapipe::MakePacket(vggish_pca_mean_matrix); - RETURN_IF_ERROR(mediapipe::file::GetContents( + MP_RETURN_IF_ERROR(mediapipe::file::GetContents( "/tmp/mediapipe/vggish_projection_matrix_data.pb", &content)); vggish_pca_projection_matrix_data.ParseFromString(content); mediapipe::MatrixFromMatrixDataProto(vggish_pca_projection_matrix_data, @@ -102,9 +102,9 @@ DEFINE_string(output_side_packets, "", LOG(INFO) << "Initialize the calculator graph."; mediapipe::CalculatorGraph graph; - RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); + MP_RETURN_IF_ERROR(graph.Initialize(config, input_side_packets)); LOG(INFO) << "Start running the calculator graph."; - RETURN_IF_ERROR(graph.Run()); + MP_RETURN_IF_ERROR(graph.Run()); LOG(INFO) << "Gathering output side packets."; kv_pairs = absl::StrSplit(FLAGS_output_side_packets, ','); for (const std::string& kv_pair : kv_pairs) { @@ -116,7 +116,7 @@ DEFINE_string(output_side_packets, "", << "Packet " << name_and_value[0] << " was not available."; const std::string& serialized_string = output_packet.ValueOrDie().Get(); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( mediapipe::file::SetContents(name_and_value[1], serialized_string)); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/framework/BUILD b/mediapipe/framework/BUILD index bc9badfec..bc83ebcd8 100644 --- a/mediapipe/framework/BUILD +++ b/mediapipe/framework/BUILD @@ -52,7 +52,7 @@ proto_library( proto_library( name = "calculator_options_proto", srcs = ["calculator_options.proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], ) proto_library( @@ -87,7 +87,6 @@ proto_library( srcs = ["packet_generator.proto"], visibility = [ "//mediapipe:__subpackages__", - "//mediapipe/packet_generator:__pkg__", ], ) @@ -187,7 +186,9 @@ mediapipe_cc_proto_library( mediapipe_cc_proto_library( name = "packet_generator_cc_proto", srcs = ["packet_generator.proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = [ + "//mediapipe:__subpackages__", + ], deps = [":packet_generator_proto"], ) @@ -220,7 +221,7 @@ mediapipe_cc_proto_library( testonly = 1, srcs = ["test_calculators.proto"], cc_deps = [":calculator_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":test_calculators_proto"], ) @@ -1086,7 +1087,6 @@ cc_library( copts = select({ "//conditions:default": [], "//mediapipe:apple": [ - "-std=c++11", "-ObjC++", ], }), diff --git a/mediapipe/framework/calculator_base_test.cc b/mediapipe/framework/calculator_base_test.cc index 474c010f4..a7fbfae1e 100644 --- a/mediapipe/framework/calculator_base_test.cc +++ b/mediapipe/framework/calculator_base_test.cc @@ -111,9 +111,9 @@ TEST(CalculatorTest, SourceProcessOrder) { output0_type.SetAny(); output1_type.SetAny(); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( output_stream_managers.Index(0).Initialize("output0", &output0_type)); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( output_stream_managers.Index(1).Initialize("output1", &output1_type)); PacketSet input_side_packets(tool::CreateTagMap({}).ValueOrDie()); @@ -158,22 +158,22 @@ TEST(CalculatorTest, SourceProcessOrder) { // Tests registration of a calculator within a namespace. // DeadEndCalculator is registered in namespace "mediapipe::test_ns". TEST(CalculatorTest, CreateByName) { - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByName( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByName( // "mediapipe.test_ns.DeadEndCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByName( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByName( // ".mediapipe.test_ns.DeadEndCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "alpha", ".mediapipe.test_ns.DeadEndCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "alpha", "mediapipe.test_ns.DeadEndCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe", "mediapipe.test_ns.DeadEndCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe.test_ns.sub_ns", "DeadEndCalculator")); EXPECT_EQ(CalculatorBaseRegistry::CreateByNameInNamespace( // @@ -204,23 +204,23 @@ TEST(CalculatorTest, CreateByNameWhitelisted) { absl::make_unique< ::mediapipe::test_ns::whitelisted_ns::DeadCalculator>); // A whitelisted calculator can be found in its own namespace. - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "", "mediapipe.test_ns.whitelisted_ns.DeadCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe.sub_ns", "test_ns.whitelisted_ns.DeadCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe.sub_ns", "mediapipe.EndCalculator")); // A whitelisted calculator can be found in the top-level namespace. - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "", "DeadCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe", "DeadCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe.test_ns.sub_ns", "DeadCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "", "EndCalculator")); - MEDIAPIPE_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // + MP_EXPECT_OK(CalculatorBaseRegistry::CreateByNameInNamespace( // "mediapipe.test_ns.sub_ns", "EndCalculator")); } diff --git a/mediapipe/framework/calculator_contract_test.cc b/mediapipe/framework/calculator_contract_test.cc index c3eb5d6c7..e9c3813c6 100644 --- a/mediapipe/framework/calculator_contract_test.cc +++ b/mediapipe/framework/calculator_contract_test.cc @@ -40,7 +40,7 @@ TEST(CalculatorContractTest, Calculator) { output_stream: "egraph_topical_detection" )"); CalculatorContract contract; - MEDIAPIPE_EXPECT_OK(contract.Initialize(node)); + MP_EXPECT_OK(contract.Initialize(node)); EXPECT_EQ(contract.Inputs().NumEntries(), 4); EXPECT_EQ(contract.Outputs().NumEntries(), 1); EXPECT_EQ(contract.InputSidePackets().NumEntries(), 1); @@ -59,7 +59,7 @@ TEST(CalculatorContractTest, CalculatorOptions) { [mediapipe.CalculatorContractTestOptions.ext] { test_field: 1.0 } })"); CalculatorContract contract; - MEDIAPIPE_EXPECT_OK(contract.Initialize(node)); + MP_EXPECT_OK(contract.Initialize(node)); const auto& test_options = contract.Options().GetExtension(CalculatorContractTestOptions::ext); EXPECT_EQ(test_options.test_field(), 1.0); @@ -80,7 +80,7 @@ TEST(CalculatorContractTest, PacketGenerator) { output_side_packet: "content_fingerprint" )"); CalculatorContract contract; - MEDIAPIPE_EXPECT_OK(contract.Initialize(node)); + MP_EXPECT_OK(contract.Initialize(node)); EXPECT_EQ(contract.InputSidePackets().NumEntries(), 1); EXPECT_EQ(contract.OutputSidePackets().NumEntries(), 4); } @@ -93,7 +93,7 @@ TEST(CalculatorContractTest, StatusHandler) { input_side_packet: "SPEC:task_specification" )"); CalculatorContract contract; - MEDIAPIPE_EXPECT_OK(contract.Initialize(node)); + MP_EXPECT_OK(contract.Initialize(node)); EXPECT_EQ(contract.InputSidePackets().NumEntries(), 2); } diff --git a/mediapipe/framework/calculator_graph.cc b/mediapipe/framework/calculator_graph.cc index 265c8ad60..ecc50cd1d 100644 --- a/mediapipe/framework/calculator_graph.cc +++ b/mediapipe/framework/calculator_graph.cc @@ -139,7 +139,7 @@ CalculatorGraph::~CalculatorGraph() {} ++index) { const EdgeInfo& edge_info = validated_graph_->OutputSidePacketInfos()[index]; - RETURN_IF_ERROR(output_side_packets_[index].Initialize( + MP_RETURN_IF_ERROR(output_side_packets_[index].Initialize( edge_info.name, edge_info.packet_type)); } @@ -166,7 +166,7 @@ CalculatorGraph::~CalculatorGraph() {} for (int index = 0; index < validated_graph_->InputStreamInfos().size(); ++index) { const EdgeInfo& edge_info = validated_graph_->InputStreamInfos()[index]; - RETURN_IF_ERROR(input_stream_managers_[index].Initialize( + MP_RETURN_IF_ERROR(input_stream_managers_[index].Initialize( edge_info.name, edge_info.packet_type, edge_info.back_edge)); } @@ -176,7 +176,7 @@ CalculatorGraph::~CalculatorGraph() {} for (int index = 0; index < validated_graph_->OutputStreamInfos().size(); ++index) { const EdgeInfo& edge_info = validated_graph_->OutputStreamInfos()[index]; - RETURN_IF_ERROR(output_stream_managers_[index].Initialize( + MP_RETURN_IF_ERROR(output_stream_managers_[index].Initialize( edge_info.name, edge_info.packet_type)); } @@ -313,8 +313,8 @@ CalculatorGraph::~CalculatorGraph() {} } if (!::mediapipe::ContainsKey(executors_, "")) { - RETURN_IF_ERROR(InitializeDefaultExecutor(*default_executor_options, - use_application_thread)); + MP_RETURN_IF_ERROR(InitializeDefaultExecutor(*default_executor_options, + use_application_thread)); } return ::mediapipe::OkStatus(); @@ -345,7 +345,7 @@ CalculatorGraph::~CalculatorGraph() {} std::max({validated_graph_->Config().node().size(), validated_graph_->Config().packet_generator().size(), 1})); } - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( CreateDefaultThreadPool(default_executor_options, num_threads)); return ::mediapipe::OkStatus(); } @@ -359,12 +359,12 @@ CalculatorGraph::~CalculatorGraph() {} << "validated_graph is not initialized."; validated_graph_ = std::move(validated_graph); - RETURN_IF_ERROR(InitializeExecutors()); - RETURN_IF_ERROR(InitializePacketGeneratorGraph(side_packets)); - RETURN_IF_ERROR(InitializeStreams()); - RETURN_IF_ERROR(InitializeCalculatorNodes()); + MP_RETURN_IF_ERROR(InitializeExecutors()); + MP_RETURN_IF_ERROR(InitializePacketGeneratorGraph(side_packets)); + MP_RETURN_IF_ERROR(InitializeStreams()); + MP_RETURN_IF_ERROR(InitializeCalculatorNodes()); #ifdef MEDIAPIPE_PROFILER_AVAILABLE - RETURN_IF_ERROR(InitializeProfiler()); + MP_RETURN_IF_ERROR(InitializeProfiler()); #endif initialized_ = true; @@ -380,7 +380,7 @@ CalculatorGraph::~CalculatorGraph() {} const CalculatorGraphConfig& input_config, const std::map& side_packets) { auto validated_graph = absl::make_unique(); - RETURN_IF_ERROR(validated_graph->Initialize(input_config)); + MP_RETURN_IF_ERROR(validated_graph->Initialize(input_config)); return Initialize(std::move(validated_graph), side_packets); } @@ -390,8 +390,8 @@ CalculatorGraph::~CalculatorGraph() {} const std::map& side_packets, const std::string& graph_type, const Subgraph::SubgraphOptions* options) { auto validated_graph = absl::make_unique(); - RETURN_IF_ERROR(validated_graph->Initialize(input_configs, input_templates, - graph_type, options)); + MP_RETURN_IF_ERROR(validated_graph->Initialize(input_configs, input_templates, + graph_type, options)); return Initialize(std::move(validated_graph), side_packets); } @@ -409,7 +409,7 @@ CalculatorGraph::~CalculatorGraph() {} << "\" because it doesn't exist."; } auto observer = absl::make_unique(); - RETURN_IF_ERROR(observer->Initialize( + MP_RETURN_IF_ERROR(observer->Initialize( stream_name, &any_packet_type_, std::move(packet_callback), &output_stream_managers_[output_stream_index])); graph_output_streams_.push_back(std::move(observer)); @@ -427,7 +427,7 @@ CalculatorGraph::AddOutputStreamPoller(const std::string& stream_name) { << "\" because it doesn't exist."; } auto internal_poller = std::make_shared(); - RETURN_IF_ERROR(internal_poller->Initialize( + MP_RETURN_IF_ERROR(internal_poller->Initialize( stream_name, &any_packet_type_, std::bind(&CalculatorGraph::UpdateThrottledNodes, this, std::placeholders::_1, std::placeholders::_2), @@ -479,7 +479,7 @@ CalculatorGraph::AddOutputStreamPoller(const std::string& stream_name) { RET_CHECK(graph_input_streams_.empty()).SetNoLogging() << "When using graph input streams, call StartRun() instead of Run() so " "that AddPacketToInputStream() and CloseInputStream() can be called."; - RETURN_IF_ERROR(StartRun(extra_side_packets, {})); + MP_RETURN_IF_ERROR(StartRun(extra_side_packets, {})); return WaitUntilDone(); } @@ -488,8 +488,8 @@ CalculatorGraph::AddOutputStreamPoller(const std::string& stream_name) { const std::map& stream_headers) { RET_CHECK(initialized_).SetNoLogging() << "CalculatorGraph is not initialized."; - RETURN_IF_ERROR(PrepareForRun(extra_side_packets, stream_headers)); - RETURN_IF_ERROR(profiler_->Start(executors_[""].get())); + MP_RETURN_IF_ERROR(PrepareForRun(extra_side_packets, stream_headers)); + MP_RETURN_IF_ERROR(profiler_->Start(executors_[""].get())); scheduler_.Start(); return ::mediapipe::OkStatus(); } @@ -570,7 +570,7 @@ CalculatorGraph::PrepareGpu(const std::map& side_packets) { } } for (const auto& name_executor : gpu_resources->GetGpuExecutors()) { - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( SetExecutorInternal(name_executor.first, name_executor.second)); } } @@ -755,7 +755,7 @@ CalculatorGraph::PrepareGpu(const std::map& side_packets) { return ::mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC) << "WaitUntilIdle called on a graph with source nodes."; } - RETURN_IF_ERROR(scheduler_.WaitUntilIdle()); + MP_RETURN_IF_ERROR(scheduler_.WaitUntilIdle()); VLOG(2) << "Scheduler idle."; ::mediapipe::Status status = ::mediapipe::OkStatus(); if (GetCombinedErrors(&status)) { @@ -766,7 +766,7 @@ CalculatorGraph::PrepareGpu(const std::map& side_packets) { ::mediapipe::Status CalculatorGraph::WaitUntilDone() { VLOG(2) << "Waiting for scheduler to terminate..."; - RETURN_IF_ERROR(scheduler_.WaitUntilDone()); + MP_RETURN_IF_ERROR(scheduler_.WaitUntilDone()); VLOG(2) << "Scheduler terminated."; return FinishRun(); @@ -1186,7 +1186,7 @@ Packet CalculatorGraph::GetServicePacket(const GraphServiceBase& service) { if (name.empty()) { scheduler_.SetExecutor(executor.get()); } else { - RETURN_IF_ERROR(scheduler_.SetNonDefaultExecutor(name, executor.get())); + MP_RETURN_IF_ERROR(scheduler_.SetNonDefaultExecutor(name, executor.get())); } return ::mediapipe::OkStatus(); } @@ -1225,7 +1225,7 @@ bool CalculatorGraph::IsReservedExecutorName(const std::string& name) { ::mediapipe::Status CalculatorGraph::FinishRun() { // Check for any errors that may have occurred. ::mediapipe::Status status = ::mediapipe::OkStatus(); - RETURN_IF_ERROR(profiler_->Stop()); + MP_RETURN_IF_ERROR(profiler_->Stop()); GetCombinedErrors(&status); CleanupAfterRun(&status); return status; diff --git a/mediapipe/framework/calculator_graph.h b/mediapipe/framework/calculator_graph.h index 01959e61b..0e8f29204 100644 --- a/mediapipe/framework/calculator_graph.h +++ b/mediapipe/framework/calculator_graph.h @@ -77,17 +77,17 @@ typedef ::mediapipe::StatusOr StatusOrPoller; // #include "mediapipe/framework/calculator_framework.h" // // mediapipe::CalculatorGraphConfig config; -// RETURN_IF_ERROR(mediapipe::tool::ParseGraphFromString(kGraphStr, &config)); -// mediapipe::CalculatorGraph graph; -// RETURN_IF_ERROR(graph.Initialize(config)); +// MP_RETURN_IF_ERROR(mediapipe::tool::ParseGraphFromString(kGraphStr, +// &config)); mediapipe::CalculatorGraph graph; +// MP_RETURN_IF_ERROR(graph.Initialize(config)); // // std::map extra_side_packets; // extra_side_packets["video_id"] = mediapipe::MakePacket( // "3edb9503834e9b42"); -// RETURN_IF_ERROR(graph.Run(extra_side_packets)); +// MP_RETURN_IF_ERROR(graph.Run(extra_side_packets)); // // // Run again (demonstrating the more concise initializer list syntax). -// RETURN_IF_ERROR(graph.Run( +// MP_RETURN_IF_ERROR(graph.Run( // {{"video_id", mediapipe::MakePacket("Ex-uGhDzue4")}})); // // See mediapipe/framework/graph_runner.h for an interface // // to insert and extract packets from a graph as it runs. @@ -186,15 +186,15 @@ class CalculatorGraph { // subsequent call to StartRun can be attempted. // // Example: - // RETURN_IF_ERROR(graph.StartRun(...)); + // MP_RETURN_IF_ERROR(graph.StartRun(...)); // while (true) { // if (graph.HasError() || want_to_stop) break; - // RETURN_IF_ERROR(graph.AddPacketToInputStream(...)); + // MP_RETURN_IF_ERROR(graph.AddPacketToInputStream(...)); // } // for (const std::string& stream : streams) { - // RETURN_IF_ERROR(graph.CloseInputStream(stream)); + // MP_RETURN_IF_ERROR(graph.CloseInputStream(stream)); // } - // RETURN_IF_ERROR(graph.WaitUntilDone()); + // MP_RETURN_IF_ERROR(graph.WaitUntilDone()); ::mediapipe::Status StartRun( const std::map& extra_side_packets) { return StartRun(extra_side_packets, {}); diff --git a/mediapipe/framework/calculator_graph_bounds_test.cc b/mediapipe/framework/calculator_graph_bounds_test.cc index 09441c027..750042522 100644 --- a/mediapipe/framework/calculator_graph_bounds_test.cc +++ b/mediapipe/framework/calculator_graph_bounds_test.cc @@ -77,27 +77,27 @@ TEST(CalculatorGraphBounds, ImmediateHandlerBounds) { )"); CalculatorGraph graph; std::vector output_packets; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream("output", [&](const Packet& p) { + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.ObserveOutputStream("output", [&](const Packet& p) { output_packets.push_back(p); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Add four packets into the graph. for (int i = 0; i < 4; ++i) { Packet p = MakePacket(33).At(Timestamp(i)); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream("input", p)); + MP_ASSERT_OK(graph.AddPacketToInputStream("input", p)); } // Four packets arrive at the output only if timestamp bounds are propagated. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_EQ(output_packets.size(), 4); // Eventually four packets arrive. - MEDIAPIPE_ASSERT_OK(graph.CloseAllPacketSources()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllPacketSources()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(output_packets.size(), 4); } diff --git a/mediapipe/framework/calculator_graph_event_loop_test.cc b/mediapipe/framework/calculator_graph_event_loop_test.cc index 835a38b13..599d079a1 100644 --- a/mediapipe/framework/calculator_graph_event_loop_test.cc +++ b/mediapipe/framework/calculator_graph_event_loop_test.cc @@ -136,14 +136,14 @@ TEST_F(CalculatorGraphEventLoopTest, WellProvisionedEventLoop) { // Start MediaPipe graph. CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}})); // Insert 100 packets at the rate the calculator can keep up with. for (int i = 0; i < 100; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_numbers", Adopt(new int(i)).At(Timestamp(i)))); // Wait for all packets to be received by the sink. while (true) { @@ -167,13 +167,13 @@ TEST_F(CalculatorGraphEventLoopTest, WellProvisionedEventLoop) { // Insert 100 more packets at rate the graph can't keep up. for (int i = 100; i < 200; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_numbers", Adopt(new int(i)).At(Timestamp(i)))); } // Don't wait but just close the input stream. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph.CloseInputStream("input_numbers")); // Wait properly via the API until the graph is done. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); // Check final results. { absl::ReaderMutexLock lock(&output_packets_mutex_); @@ -225,7 +225,7 @@ TEST_F(CalculatorGraphEventLoopTest, FailingEventLoop) { // Start MediaPipe graph. CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}})); @@ -243,7 +243,7 @@ TEST_F(CalculatorGraphEventLoopTest, FailingEventLoop) { break; } } - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph.CloseInputStream("input_numbers")); status = graph.WaitUntilDone(); ASSERT_THAT(status.message(), testing::HasSubstr("Meant to fail (magicstringincludedhere).")); @@ -270,7 +270,7 @@ TEST_F(CalculatorGraphEventLoopTest, StepByStepSchedulerLoop) { // Start MediaPipe graph. CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}})); @@ -278,16 +278,16 @@ TEST_F(CalculatorGraphEventLoopTest, StepByStepSchedulerLoop) { // Add packet one at a time, we should be able to syncrhonize the output for // each addition in the step by step mode. for (int i = 0; i < 100; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_numbers", Adopt(new int(i)).At(Timestamp(i)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); absl::ReaderMutexLock lock(&output_packets_mutex_); ASSERT_EQ(i + 1, output_packets_.size()); } // Don't wait but just close the input stream. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph.CloseInputStream("input_numbers")); // Wait properly via the API until the graph is done. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } // Test setting the stream header. @@ -310,7 +310,7 @@ TEST_F(CalculatorGraphEventLoopTest, SetStreamHeader) { &graph_config)); CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}})); @@ -327,15 +327,15 @@ TEST_F(CalculatorGraphEventLoopTest, SetStreamHeader) { header->width = 320; header->height = 240; // With stream header set, the StartRun should succeed. - MEDIAPIPE_ASSERT_OK(graph2.StartRun( + MP_ASSERT_OK(graph2.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}}, {{"input_numbers", Adopt(header.release())}})); // Don't wait but just close the input stream. - MEDIAPIPE_ASSERT_OK(graph2.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph2.CloseInputStream("input_numbers")); // Wait properly via the API until the graph is done. - MEDIAPIPE_ASSERT_OK(graph2.WaitUntilDone()); + MP_ASSERT_OK(graph2.WaitUntilDone()); } // Test ADD_IF_NOT_FULL mode for graph input streams (by creating more packets @@ -369,7 +369,7 @@ TEST_F(CalculatorGraphEventLoopTest, TryToAddPacketToInputStream) { CalculatorGraph::GraphInputStreamAddMode::ADD_IF_NOT_FULL); // Start MediaPipe graph. - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}, @@ -397,9 +397,9 @@ TEST_F(CalculatorGraphEventLoopTest, TryToAddPacketToInputStream) { EXPECT_GE(fail_count, kNumInputPackets - kMaxQueueSize - 1); // Don't wait but just close the input stream. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph.CloseInputStream("input_numbers")); // Wait properly via the API until the graph is done. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } // Verify that "max_queue_size: -1" disables throttling of graph-input-streams. @@ -426,18 +426,18 @@ TEST_F(CalculatorGraphEventLoopTest, ThrottlingDisabled) { CalculatorGraph::GraphInputStreamAddMode::ADD_IF_NOT_FULL); // Start MediaPipe graph. - MEDIAPIPE_ASSERT_OK(graph.StartRun({{"blocking_mutex", mutex_side_packet}})); + MP_ASSERT_OK(graph.StartRun({{"blocking_mutex", mutex_side_packet}})); // Lock the mutex so that the BlockingPassThroughCalculator cannot read any // of these packets. mutex->Lock(); for (int i = 0; i < 10; ++i) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "input_numbers", Adopt(new int(i)).At(Timestamp(i)))); } mutex->Unlock(); - MEDIAPIPE_EXPECT_OK(graph.CloseInputStream("input_numbers")); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilDone()); + MP_EXPECT_OK(graph.CloseInputStream("input_numbers")); + MP_EXPECT_OK(graph.WaitUntilDone()); } // Verify that the graph input stream throttling code still works if we run the @@ -467,8 +467,7 @@ TEST_F(CalculatorGraphEventLoopTest, ThrottleGraphInputStreamTwice) { // Run the graph twice. for (int i = 0; i < 2; ++i) { // Start MediaPipe graph. - MEDIAPIPE_ASSERT_OK( - graph.StartRun({{"blocking_mutex", mutex_side_packet}})); + MP_ASSERT_OK(graph.StartRun({{"blocking_mutex", mutex_side_packet}})); // Lock the mutex so that the BlockingPassThroughCalculator cannot read any // of these packets. @@ -485,8 +484,8 @@ TEST_F(CalculatorGraphEventLoopTest, ThrottleGraphInputStreamTwice) { ASSERT_FALSE(status.ok()); EXPECT_EQ(status.code(), ::mediapipe::StatusCode::kUnavailable); EXPECT_THAT(status.message(), testing::HasSubstr("Graph is throttled.")); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph.WaitUntilDone()); } } @@ -515,7 +514,7 @@ TEST_F(CalculatorGraphEventLoopTest, WaitToAddPacketToInputStream) { // Start MediaPipe graph. CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &CalculatorGraphEventLoopTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}})); @@ -534,9 +533,9 @@ TEST_F(CalculatorGraphEventLoopTest, WaitToAddPacketToInputStream) { EXPECT_EQ(0, fail_count); // Don't wait but just close the input stream. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_numbers")); + MP_ASSERT_OK(graph.CloseInputStream("input_numbers")); // Wait properly via the API until the graph is done. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); absl::ReaderMutexLock lock(&output_packets_mutex_); ASSERT_EQ(kNumInputPackets, output_packets_.size()); diff --git a/mediapipe/framework/calculator_graph_stopping_test.cc b/mediapipe/framework/calculator_graph_stopping_test.cc index 37f9b3171..b7a9fafcc 100644 --- a/mediapipe/framework/calculator_graph_stopping_test.cc +++ b/mediapipe/framework/calculator_graph_stopping_test.cc @@ -188,7 +188,7 @@ TEST(CalculatorGraphStoppingTest, CloseAllPacketSources) { )", &graph_config)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {})); + MP_ASSERT_OK(graph.Initialize(graph_config, {})); // Observe output packets, and call CloseAllPacketSources after kNumPackets. std::vector out_packets; @@ -196,37 +196,37 @@ TEST(CalculatorGraphStoppingTest, CloseAllPacketSources) { std::vector event_packets; std::vector event_out_packets; int kNumPackets = 8; - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( // + MP_ASSERT_OK(graph.ObserveOutputStream( // "input_out", [&](const Packet& packet) { out_packets.push_back(packet); if (out_packets.size() >= kNumPackets) { - MEDIAPIPE_EXPECT_OK(graph.CloseAllPacketSources()); + MP_EXPECT_OK(graph.CloseAllPacketSources()); } return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( // + MP_ASSERT_OK(graph.ObserveOutputStream( // "count_out", [&](const Packet& packet) { count_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( // + MP_ASSERT_OK(graph.ObserveOutputStream( // "event", [&](const Packet& packet) { event_packets.push_back(packet.Get()); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( // + MP_ASSERT_OK(graph.ObserveOutputStream( // "event_out", [&](const Packet& packet) { event_out_packets.push_back(packet.Get()); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < kNumPackets; ++i) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "input", MakePacket(i).At(Timestamp(i)))); } // The graph run should complete with no error status. - MEDIAPIPE_EXPECT_OK(graph.WaitUntilDone()); + MP_EXPECT_OK(graph.WaitUntilDone()); EXPECT_EQ(kNumPackets, out_packets.size()); EXPECT_LE(kNumPackets, count_packets.size()); std::vector expected_events = {1, 2}; @@ -254,11 +254,11 @@ TEST(CalculatorGraphStoppingTest, DeadlockReporting) { )", &config)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); graph.SetGraphInputStreamAddMode( CalculatorGraph::GraphInputStreamAddMode::WAIT_TILL_NOT_FULL); std::vector out_packets; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out_1", [&out_packets](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); @@ -278,15 +278,15 @@ TEST(CalculatorGraphStoppingTest, DeadlockReporting) { }; // Start the graph. - MEDIAPIPE_ASSERT_OK(graph.StartRun({ + MP_ASSERT_OK(graph.StartRun({ {"callback_1", AdoptAsUniquePtr(new auto(callback_1))}, })); // Add 3 packets to "in_1" with no packets on "in_2". // This causes throttling and deadlock with max_queue_size 2. semaphore.Release(3); - MEDIAPIPE_EXPECT_OK(add_packet("in_1", 1)); - MEDIAPIPE_EXPECT_OK(add_packet("in_1", 2)); + MP_EXPECT_OK(add_packet("in_1", 1)); + MP_EXPECT_OK(add_packet("in_1", 2)); EXPECT_FALSE(add_packet("in_1", 3).ok()); ::mediapipe::Status status = graph.WaitUntilIdle(); @@ -295,7 +295,7 @@ TEST(CalculatorGraphStoppingTest, DeadlockReporting) { status.message(), testing::HasSubstr("Detected a deadlock due to input throttling")); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); EXPECT_FALSE(graph.WaitUntilDone().ok()); ASSERT_EQ(0, out_packets.size()); } @@ -319,11 +319,11 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) { )", &config)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); graph.SetGraphInputStreamAddMode( CalculatorGraph::GraphInputStreamAddMode::WAIT_TILL_NOT_FULL); std::vector out_packets; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out_1", [&out_packets](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); @@ -343,7 +343,7 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) { }; // Start the graph. - MEDIAPIPE_ASSERT_OK(graph.StartRun({ + MP_ASSERT_OK(graph.StartRun({ {"callback_1", AdoptAsUniquePtr(new auto(callback_1))}, })); @@ -351,19 +351,19 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) { // This grows the input stream "in_1" to max-queue-size 10. semaphore.Release(9); for (int i = 1; i <= 9; ++i) { - MEDIAPIPE_EXPECT_OK(add_packet("in_1", i)); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(add_packet("in_1", i)); + MP_ASSERT_OK(graph.WaitUntilIdle()); } // Advance the timestamp-bound and flush "in_1". semaphore.Release(1); - MEDIAPIPE_EXPECT_OK(add_packet("in_2", 30)); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(add_packet("in_2", 30)); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Fill up input stream "in_1", with the semaphore blocked and deadlock // resolution disabled. for (int i = 11; i < 23; ++i) { - MEDIAPIPE_EXPECT_OK(add_packet("in_1", i)); + MP_EXPECT_OK(add_packet("in_1", i)); } // Adding any more packets fails with error "Graph is throttled". @@ -374,9 +374,9 @@ TEST(CalculatorGraphStoppingTest, DeadlockResolution) { // Allow the 12 blocked calls to "callback_1" to complete. semaphore.Release(12); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(21, out_packets.size()); } diff --git a/mediapipe/framework/calculator_graph_test.cc b/mediapipe/framework/calculator_graph_test.cc index 2976a1fec..3f9505250 100644 --- a/mediapipe/framework/calculator_graph_test.cc +++ b/mediapipe/framework/calculator_graph_test.cc @@ -1684,7 +1684,7 @@ void RunComprehensiveTest(CalculatorGraph* graph, tool::AddPostStreamPacketSink("final_sum", &proto, &dumped_final_sum_packet); tool::AddPostStreamPacketSink("final_stddev", &proto, &dumped_final_stddev_packet); - MEDIAPIPE_ASSERT_OK(graph->Initialize(proto)); + MP_ASSERT_OK(graph->Initialize(proto)); std::map extra_side_packets; extra_side_packets.emplace("node_3", Adopt(new uint64((15LL << 32) | 3))); @@ -1699,7 +1699,7 @@ void RunComprehensiveTest(CalculatorGraph* graph, dumped_final_sum_packet = Packet(); dumped_final_stddev_packet = Packet(); dumped_final_packet = Packet(); - MEDIAPIPE_ASSERT_OK(graph->Run(extra_side_packets)); + MP_ASSERT_OK(graph->Run(extra_side_packets)); // The merger will output the timestamp and all ints output from // the range calculators. The saver will concatenate together the // strings with a '/' deliminator. @@ -1764,7 +1764,7 @@ TEST(CalculatorGraph, BadInitialization) { TEST(CalculatorGraph, BadRun) { CalculatorGraphConfig proto = GetConfig(); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(proto)); + MP_ASSERT_OK(graph.Initialize(proto)); // Don't set the input side packets. EXPECT_FALSE(graph.Run().ok()); } @@ -1785,8 +1785,7 @@ TEST(CalculatorGraph, RunsCorrectlyOnApplicationThread) { TEST(CalculatorGraph, RunsCorrectlyWithExternalExecutor) { CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( - graph.SetExecutor("", std::make_shared(1))); + MP_ASSERT_OK(graph.SetExecutor("", std::make_shared(1))); CalculatorGraphConfig proto = GetConfig(); RunComprehensiveTest(&graph, proto, /*define_node_5=*/true); } @@ -1796,7 +1795,7 @@ TEST(CalculatorGraph, RunsCorrectlyWithExternalExecutor) { // result in a recursive call to itself. TEST(CalculatorGraph, RunsCorrectlyWithCurrentThreadExecutor) { CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.SetExecutor("", std::make_shared())); CalculatorGraphConfig proto = GetConfig(); RunComprehensiveTest(&graph, proto, /*define_node_5=*/true); @@ -1805,9 +1804,9 @@ TEST(CalculatorGraph, RunsCorrectlyWithCurrentThreadExecutor) { TEST(CalculatorGraph, RunsCorrectlyWithNonDefaultExecutors) { CalculatorGraph graph; // Add executors "second" and "third". - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.SetExecutor("second", std::make_shared(1))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.SetExecutor("third", std::make_shared(1))); CalculatorGraphConfig proto = GetConfig(); ExecutorConfig* executor = proto.add_executor(); @@ -1903,23 +1902,23 @@ TEST(CalculatorGraph, TypeMismatch) { config.mutable_node(0)->set_calculator("StringEmptySourceCalculator"); config.mutable_node(1)->set_calculator("StringSinkCalculator"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); - MEDIAPIPE_EXPECT_OK(graph->Run()); + MP_ASSERT_OK(graph->Initialize(config)); + MP_EXPECT_OK(graph->Run()); graph.reset(nullptr); // Type matches, expect success. config.mutable_node(0)->set_calculator("IntEmptySourceCalculator"); config.mutable_node(1)->set_calculator("IntSinkCalculator"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); - MEDIAPIPE_EXPECT_OK(graph->Run()); + MP_ASSERT_OK(graph->Initialize(config)); + MP_EXPECT_OK(graph->Run()); graph.reset(nullptr); // Type mismatch, expect non-crashing failure. config.mutable_node(0)->set_calculator("StringEmptySourceCalculator"); config.mutable_node(1)->set_calculator("IntSinkCalculator"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); EXPECT_FALSE(graph->Run().ok()); graph.reset(nullptr); @@ -1927,7 +1926,7 @@ TEST(CalculatorGraph, TypeMismatch) { config.mutable_node(0)->set_calculator("IntEmptySourceCalculator"); config.mutable_node(1)->set_calculator("StringSinkCalculator"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); EXPECT_FALSE(graph->Run().ok()); graph.reset(nullptr); } @@ -1974,8 +1973,8 @@ TEST(CalculatorGraph, LayerOrdering) { std::map input_side_packets; input_side_packets["global_counter"] = Adopt(new auto(&global_counter)); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph->Run(input_side_packets)); + MP_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Run(input_side_packets)); graph.reset(nullptr); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, @@ -2047,10 +2046,10 @@ TEST(CalculatorGraph, StatusHandlerInputVerification) { input_side_packet: "extra_string" } )"); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); Packet extra_string = Adopt(new std::string("foo")); Packet a_uint64 = Adopt(new uint64(0)); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph->Run({{"extra_string", extra_string}, {"a_uint64", a_uint64}})); // Should fail verification when missing a required input. The generator is @@ -2137,16 +2136,16 @@ TEST(CalculatorGraph, GenerateInInitialize) { } )"); int initial_count = StaticCounterStringGenerator::NumPacketsGenerated(); - MEDIAPIPE_ASSERT_OK(graph.Initialize( + MP_ASSERT_OK(graph.Initialize( config, {{"created_by_factory", MakePacket("default string")}, {"input_in_initialize", MakePacket(10)}})); EXPECT_EQ(initial_count + 2, StaticCounterStringGenerator::NumPacketsGenerated()); - MEDIAPIPE_ASSERT_OK(graph.Run({{"input_in_run", MakePacket(11)}})); + MP_ASSERT_OK(graph.Run({{"input_in_run", MakePacket(11)}})); EXPECT_EQ(initial_count + 4, StaticCounterStringGenerator::NumPacketsGenerated()); - MEDIAPIPE_ASSERT_OK(graph.Run({{"input_in_run", MakePacket(12)}})); + MP_ASSERT_OK(graph.Run({{"input_in_run", MakePacket(12)}})); EXPECT_EQ(initial_count + 6, StaticCounterStringGenerator::NumPacketsGenerated()); } @@ -2241,7 +2240,7 @@ TEST(CalculatorGraph, HandlersRun) { // run at initialize time. config.mutable_packet_generator(0)->add_input_side_packet("unused_input"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); ResetCounters(&input_side_packets); EXPECT_THAT(graph->Run(input_side_packets).ToString(), testing::HasSubstr("FailingPacketGenerator")); @@ -2263,7 +2262,7 @@ TEST(CalculatorGraph, HandlersRun) { config.mutable_packet_generator(0)->set_packet_generator( "StaticCounterStringGenerator"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); ResetCounters(&input_side_packets); // The entire graph should still fail because of the FailingSourceCalculator. EXPECT_THAT(graph->Run(input_side_packets).ToString(), @@ -2286,9 +2285,9 @@ TEST(CalculatorGraph, HandlersRun) { // of the successful graph run. config.mutable_node(0)->set_calculator("StringEmptySourceCalculator"); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); ResetCounters(&input_side_packets); - MEDIAPIPE_EXPECT_OK(graph->Run(input_side_packets)); + MP_EXPECT_OK(graph->Run(input_side_packets)); EXPECT_EQ(1, *GetFromUniquePtr(input_side_packets.at("no_input_counter1"))); EXPECT_EQ(1, @@ -2309,7 +2308,7 @@ TEST(CalculatorGraph, HandlersRun) { IncrementingStatusHandler::SetPreRunStatusResult( ::mediapipe::InternalError("Fail at pre-run")); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); ResetCounters(&input_side_packets); run_status = graph->Run(input_side_packets); EXPECT_TRUE(run_status.code() == ::mediapipe::StatusCode::kInternal); @@ -2332,7 +2331,7 @@ TEST(CalculatorGraph, HandlersRun) { IncrementingStatusHandler::SetPostRunStatusResult( ::mediapipe::InternalError("Fail at post-run")); graph.reset(new CalculatorGraph()); - MEDIAPIPE_ASSERT_OK(graph->Initialize(config)); + MP_ASSERT_OK(graph->Initialize(config)); ResetCounters(&input_side_packets); run_status = graph->Run(input_side_packets); EXPECT_TRUE(run_status.code() == ::mediapipe::StatusCode::kInternal); @@ -2365,9 +2364,9 @@ TEST(CalculatorGraph, SetOffsetInProcess) { } )"); - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_EXPECT_OK(graph.StartRun({})); - MEDIAPIPE_EXPECT_OK( + MP_ASSERT_OK(graph.Initialize(config)); + MP_EXPECT_OK(graph.StartRun({})); + MP_EXPECT_OK( graph.AddPacketToInputStream("in", MakePacket(0).At(Timestamp(0)))); ::mediapipe::Status status = graph.WaitUntilIdle(); EXPECT_FALSE(status.ok()); @@ -2398,18 +2397,18 @@ TEST(CalculatorGraph, InputPacketLifetime) { return Adopt(tracker.MakeObject().release()).At(++timestamp); }; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_EXPECT_OK(graph.StartRun({})); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_EXPECT_OK(graph.StartRun({})); + MP_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); + MP_EXPECT_OK(graph.WaitUntilIdle()); EXPECT_EQ(0, tracker.live_count()); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); + MP_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); + MP_EXPECT_OK(graph.AddPacketToInputStream("in", new_packet())); + MP_EXPECT_OK(graph.WaitUntilIdle()); EXPECT_EQ(0, tracker.live_count()); - MEDIAPIPE_EXPECT_OK(graph.CloseInputStream("in")); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilDone()); + MP_EXPECT_OK(graph.CloseInputStream("in")); + MP_EXPECT_OK(graph.WaitUntilDone()); } // Test that SetNextTimestampBound propagates. @@ -2453,15 +2452,14 @@ TEST(CalculatorGraph, SetNextTimestampBoundPropagation) { Timestamp timestamp = Timestamp(0); auto send_inputs = [&graph, ×tamp](int input, bool pass) { ++timestamp; - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "in", MakePacket(input).At(timestamp))); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "gate", MakePacket(pass).At(timestamp))); }; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK( - graph.StartRun({{"shift", MakePacket(0)}})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({{"shift", MakePacket(0)}})); auto pass_counter = graph.GetCounterFactory()->GetCounter("ValveCalculator-PassThrough"); @@ -2474,7 +2472,7 @@ TEST(CalculatorGraph, SetNextTimestampBoundPropagation) { send_inputs(2, true); send_inputs(3, false); send_inputs(4, false); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Verify that MergeCalculator was able to run even when the gated branch // was blocked. @@ -2484,21 +2482,20 @@ TEST(CalculatorGraph, SetNextTimestampBoundPropagation) { send_inputs(5, true); send_inputs(6, false); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_EQ(3, pass_counter->Get()); EXPECT_EQ(3, block_counter->Get()); EXPECT_EQ(6, merged_counter->Get()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); // Now test with time shift - MEDIAPIPE_ASSERT_OK( - graph.StartRun({{"shift", MakePacket(-1)}})); + MP_ASSERT_OK(graph.StartRun({{"shift", MakePacket(-1)}})); send_inputs(7, true); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // The merger should have run only once now, at timestamp 6, with inputs // . If we do not respect the offset and unblock the merger for @@ -2508,8 +2505,8 @@ TEST(CalculatorGraph, SetNextTimestampBoundPropagation) { EXPECT_EQ(3, block_counter->Get()); EXPECT_EQ(7, merged_counter->Get()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(4, pass_counter->Get()); EXPECT_EQ(3, block_counter->Get()); @@ -2561,8 +2558,8 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) { std::vector packet_dump; tool::AddVectorSink("out", &config, &packet_dump); - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); Timestamp timestamp = Timestamp(0); @@ -2573,11 +2570,11 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) { // input streams of the IntAdderCalculator will become 2. ++timestamp; // Timestamp 1. - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( - "in0_unfiltered", MakePacket(1).At(timestamp))); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( - "in1_to_be_filtered", MakePacket(2).At(timestamp))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.AddPacketToInputStream("in0_unfiltered", + MakePacket(1).At(timestamp))); + MP_EXPECT_OK(graph.AddPacketToInputStream("in1_to_be_filtered", + MakePacket(2).At(timestamp))); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(1, packet_dump.size()); EXPECT_EQ(3, packet_dump[0].Get()); @@ -2586,30 +2583,30 @@ TEST(CalculatorGraph, NotAllInputPacketsAtNextTimestampBoundAvailable) { // in1_filtered input stream of the IntAdderCalculator will become 3. ++timestamp; // Timestamp 2. - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( - "in1_to_be_filtered", MakePacket(3).At(timestamp))); + MP_EXPECT_OK(graph.AddPacketToInputStream("in1_to_be_filtered", + MakePacket(3).At(timestamp))); // We send an integer with timestamp 3 to the in0_unfiltered input stream of // the IntAdderCalculator. MediaPipe should propagate the next timestamp bound // across the IntAdderCalculator but should not run its Process() method. ++timestamp; // Timestamp 3. - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( - "in0_unfiltered", MakePacket(3).At(timestamp))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.AddPacketToInputStream("in0_unfiltered", + MakePacket(3).At(timestamp))); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(1, packet_dump.size()); // We send an even integer with timestamp 3 to the IntAdderCalculator. This // packet will go through and the IntAdderCalculator will run. - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( - "in1_to_be_filtered", MakePacket(4).At(timestamp))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.AddPacketToInputStream("in1_to_be_filtered", + MakePacket(4).At(timestamp))); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(2, packet_dump.size()); EXPECT_EQ(7, packet_dump[1].Get()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(2, packet_dump.size()); } @@ -2666,14 +2663,14 @@ TEST(CalculatorGraph, IfThenElse) { Timestamp timestamp = Timestamp(0); auto send_inputs = [&graph, ×tamp](int input, int select) { ++timestamp; - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "in", MakePacket(input).At(timestamp))); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "select", MakePacket(select).At(timestamp))); }; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); // If the "select" input is 0, we apply a double operation. If "select" is 1, // we apply a square operation. To make the code easier to understand, define @@ -2682,29 +2679,29 @@ TEST(CalculatorGraph, IfThenElse) { const int kApplySquare = 1; send_inputs(1, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(1, packet_dump.size()); EXPECT_EQ(2, packet_dump[0].Get()); send_inputs(2, kApplySquare); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(2, packet_dump.size()); EXPECT_EQ(4, packet_dump[1].Get()); send_inputs(3, kApplyDouble); send_inputs(4, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_EQ(4, packet_dump.size()); EXPECT_EQ(6, packet_dump[2].Get()); EXPECT_EQ(8, packet_dump[3].Get()); send_inputs(5, kApplySquare); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(5, packet_dump.size()); EXPECT_EQ(25, packet_dump[4].Get()); send_inputs(6, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(6, packet_dump.size()); EXPECT_EQ(12, packet_dump[5].Get()); @@ -2712,15 +2709,15 @@ TEST(CalculatorGraph, IfThenElse) { send_inputs(8, kApplySquare); send_inputs(9, kApplySquare); send_inputs(10, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(10, packet_dump.size()); EXPECT_EQ(49, packet_dump[6].Get()); EXPECT_EQ(64, packet_dump[7].Get()); EXPECT_EQ(81, packet_dump[8].Get()); EXPECT_EQ(20, packet_dump[9].Get()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(10, packet_dump.size()); } @@ -2810,14 +2807,14 @@ TEST(CalculatorGraph, IfThenElse2) { Timestamp timestamp = Timestamp(0); auto send_inputs = [&graph, ×tamp](int input, int select) { ++timestamp; - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "in", MakePacket(input).At(timestamp))); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "select", MakePacket(select).At(timestamp))); }; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); // If the "select" input is 0, we apply a double operation. If "select" is 1, // we apply a square operation. To make the code easier to understand, define @@ -2826,29 +2823,29 @@ TEST(CalculatorGraph, IfThenElse2) { const int kApplySquare = 1; send_inputs(1, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(1, packet_dump.size()); EXPECT_EQ(2, packet_dump[0].Get()); send_inputs(2, kApplySquare); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(2, packet_dump.size()); EXPECT_EQ(4, packet_dump[1].Get()); send_inputs(3, kApplyDouble); send_inputs(4, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_EQ(4, packet_dump.size()); EXPECT_EQ(6, packet_dump[2].Get()); EXPECT_EQ(8, packet_dump[3].Get()); send_inputs(5, kApplySquare); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(5, packet_dump.size()); EXPECT_EQ(25, packet_dump[4].Get()); send_inputs(6, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(6, packet_dump.size()); EXPECT_EQ(12, packet_dump[5].Get()); @@ -2856,15 +2853,15 @@ TEST(CalculatorGraph, IfThenElse2) { send_inputs(8, kApplySquare); send_inputs(9, kApplySquare); send_inputs(10, kApplyDouble); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(10, packet_dump.size()); EXPECT_EQ(49, packet_dump[6].Get()); EXPECT_EQ(64, packet_dump[7].Get()); EXPECT_EQ(81, packet_dump[8].Get()); EXPECT_EQ(20, packet_dump[9].Get()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(10, packet_dump.size()); } @@ -2912,8 +2909,8 @@ TEST(CalculatorGraph, ClosedSourceNodeShouldNotBeUnthrottled) { )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run()); } // Tests that a calculator can output a packet in the Open() method. @@ -2953,8 +2950,8 @@ TEST(CalculatorGraph, OutputPacketInOpen) { input_side_packets["global_counter"] = Adopt(new auto(&global_counter)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets + 1, packet_dump.size()); EXPECT_EQ(0, packet_dump[0].Get()); @@ -3003,8 +3000,8 @@ TEST(CalculatorGraph, OutputPacketInOpen2) { input_side_packets["global_counter"] = Adopt(new auto(&global_counter)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets + 1, packet_dump.size()); int i; @@ -3053,8 +3050,8 @@ TEST(CalculatorGraph, EmptyInputInOpen) { input_side_packets["global_counter"] = Adopt(new auto(&global_counter)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_EXPECT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_EXPECT_OK(graph.Run(input_side_packets)); } // Test for b/33568859. @@ -3097,8 +3094,8 @@ TEST(CalculatorGraph, UnthrottleRespectsLayers) { input_side_packets["output_in_open"] = MakePacket(kOutputInOpen); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, layer0_packets.size()); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, @@ -3159,8 +3156,8 @@ TEST(CalculatorGraph, Cycle) { input_side_packets["global_counter"] = Adopt(new auto(&global_counter)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, packet_dump.size()); int sum = 0; for (int i = 0; i < GlobalCountSourceCalculator::kNumOutputPackets; ++i) { @@ -3210,8 +3207,8 @@ TEST(CalculatorGraph, CycleUntimed) { input_side_packets["global_counter"] = Adopt(new auto(&global_counter)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, packet_dump.size()); int sum = 0; for (int i = 0; i < GlobalCountSourceCalculator::kNumOutputPackets; ++i) { @@ -3313,8 +3310,8 @@ TEST(CalculatorGraph, DirectFormI) { input_side_packets["a1"] = Adopt(new float(1.5)); input_side_packets["b1"] = Adopt(new float(2.0)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, packet_dump.size()); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, 5); EXPECT_FLOAT_EQ(1.0, packet_dump[0].Get()); @@ -3416,8 +3413,8 @@ TEST(CalculatorGraph, DirectFormII) { input_side_packets["b1"] = Adopt(new float(2.0)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run(input_side_packets)); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run(input_side_packets)); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, packet_dump.size()); ASSERT_EQ(GlobalCountSourceCalculator::kNumOutputPackets, 5); EXPECT_FLOAT_EQ(1.0, packet_dump[0].Get()); @@ -3497,8 +3494,8 @@ TEST(CalculatorGraph, DotProduct) { tool::AddVectorSink("dot_product", &config, &packet_dump); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run()); // The calculator graph performs the following computation: // test_sequence_1 is split into x_1, y_1, z_1. @@ -3543,14 +3540,14 @@ TEST(CalculatorGraph, TerminatesOnCancelWithOpenGraphInputStreams) { input_stream: 'in_b' )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); + MP_EXPECT_OK(graph.AddPacketToInputStream( "in_a", MakePacket(1).At(Timestamp(1)))); - MEDIAPIPE_EXPECT_OK(graph.CloseInputStream("in_a")); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.CloseInputStream("in_a")); + MP_EXPECT_OK(graph.AddPacketToInputStream( "in_b", MakePacket(2).At(Timestamp(2)))); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.WaitUntilIdle()); graph.Cancel(); // This tests that the graph doesn't deadlock on WaitUntilDone (because // the scheduler thread is sleeping). @@ -3569,11 +3566,11 @@ TEST(CalculatorGraph, TerminatesOnCancelAfterPause) { input_stream: 'in' )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); graph.Pause(); // Make the PassThroughCalculator runnable while the scheduler is paused. - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("in", MakePacket(1).At(Timestamp(1)))); // Now cancel the graph run. A non-empty scheduler queue should not prevent // the scheduler from terminating. @@ -3699,16 +3696,15 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) { // Next, create a ValidatedGraphConfig for both configs. ValidatedGraphConfig validated_calculator_config; - MEDIAPIPE_ASSERT_OK( - validated_calculator_config.Initialize(calculator_config)); + MP_ASSERT_OK(validated_calculator_config.Initialize(calculator_config)); ValidatedGraphConfig validated_generator_config; - MEDIAPIPE_ASSERT_OK(validated_generator_config.Initialize(generator_config)); + MP_ASSERT_OK(validated_generator_config.Initialize(generator_config)); // Create a PacketGeneratorGraph. Side packets max_count1, max_count2, // and max_count3 are created upon initialization. // Note that validated_generator_config must outlive generator_graph. PacketGeneratorGraph generator_graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( generator_graph.Initialize(&validated_generator_config, nullptr, {{"max_count1", MakePacket(10)}, {"max_count3", MakePacket(20)}})); @@ -3723,7 +3719,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) { graphs.emplace_back(absl::make_unique()); // Do not pass extra side packets here. // Note that validated_calculator_config must outlive the graph. - MEDIAPIPE_ASSERT_OK(graphs.back()->Initialize(calculator_config, {})); + MP_ASSERT_OK(graphs.back()->Initialize(calculator_config, {})); } // Run a bunch of graphs, reusing side packets max_count1, max_count2, // and max_count3. The side packet max_count4 is added per run, @@ -3732,7 +3728,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) { for (int i = 0; i < 100; ++i) { std::map all_side_packets; // Creates max_count4 and max_count5. - MEDIAPIPE_ASSERT_OK(generator_graph.RunGraphSetup( + MP_ASSERT_OK(generator_graph.RunGraphSetup( {{"max_count4", MakePacket(30 + i)}}, &all_side_packets)); ASSERT_THAT(all_side_packets, testing::ElementsAre( @@ -3740,7 +3736,7 @@ TEST(CalculatorGraph, SharePacketGeneratorGraph) { testing::Key("max_count3"), testing::Key("max_count4"), testing::Key("max_count5"))); // Pass all the side packets prepared by generator_graph here. - MEDIAPIPE_ASSERT_OK(graphs[i]->Run(all_side_packets)); + MP_ASSERT_OK(graphs[i]->Run(all_side_packets)); // TODO Verify the actual output. } @@ -3774,20 +3770,19 @@ TEST(CalculatorGraph, RecoverAfterRunError) { int packet_count = 0; CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config, {})); - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( - "count1", [&packet_count](const Packet& packet) { - ++packet_count; - return ::mediapipe::OkStatus(); - })); + MP_ASSERT_OK(graph.Initialize(config, {})); + MP_ASSERT_OK(graph.ObserveOutputStream("count1", + [&packet_count](const Packet& packet) { + ++packet_count; + return ::mediapipe::OkStatus(); + })); // Set ERROR_COUNT higher than MAX_COUNT and hence the calculator will // finish successfully. packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); // Fail in PacketGenerator::Generate(). // Negative max_count1 will cause EnsurePositivePacketGenerator to fail. @@ -3798,11 +3793,10 @@ TEST(CalculatorGraph, RecoverAfterRunError) { MakePacket(FailableStatusHandler::kOk)}}) .ok()); packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); // Fail in PacketGenerator::Generate() also fail in StatusHandler. ASSERT_FALSE(graph @@ -3812,11 +3806,10 @@ TEST(CalculatorGraph, RecoverAfterRunError) { MakePacket(FailableStatusHandler::kFailPreRun)}}) .ok()); packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); ASSERT_FALSE( graph @@ -3826,11 +3819,10 @@ TEST(CalculatorGraph, RecoverAfterRunError) { MakePacket(FailableStatusHandler::kFailPostRun)}}) .ok()); packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); // Fail in Calculator::Process(). ASSERT_FALSE(graph @@ -3840,11 +3832,10 @@ TEST(CalculatorGraph, RecoverAfterRunError) { MakePacket(FailableStatusHandler::kOk)}}) .ok()); packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); // Fail in Calculator::Process() also fail in StatusHandler. ASSERT_FALSE(graph @@ -3854,11 +3845,10 @@ TEST(CalculatorGraph, RecoverAfterRunError) { MakePacket(FailableStatusHandler::kFailPreRun)}}) .ok()); packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); ASSERT_FALSE( graph @@ -3868,11 +3858,10 @@ TEST(CalculatorGraph, RecoverAfterRunError) { MakePacket(FailableStatusHandler::kFailPostRun)}}) .ok()); packet_count = 0; - MEDIAPIPE_ASSERT_OK( - graph.Run({{"max_count1", MakePacket(10)}, - {"max_error1", MakePacket(20)}, - {"status_handler_command", - MakePacket(FailableStatusHandler::kOk)}})); + MP_ASSERT_OK(graph.Run({{"max_count1", MakePacket(10)}, + {"max_error1", MakePacket(20)}, + {"status_handler_command", + MakePacket(FailableStatusHandler::kOk)}})); EXPECT_EQ(packet_count, 10); } @@ -3899,16 +3888,16 @@ TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) { max_queue_size: 100 )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); graph.SetGraphInputStreamAddMode( CalculatorGraph::GraphInputStreamAddMode::ADD_IF_NOT_FULL); - MEDIAPIPE_ASSERT_OK(graph.SetInputStreamMaxQueueSize("in", 1)); + MP_ASSERT_OK(graph.SetInputStreamMaxQueueSize("in", 1)); Semaphore calc_entered_process(0); Semaphore calc_can_exit_process(0); Semaphore calc_entered_process_busy(0); Semaphore calc_can_exit_process_busy(0); - MEDIAPIPE_ASSERT_OK(graph.StartRun({ + MP_ASSERT_OK(graph.StartRun({ {"post_sem", MakePacket(&calc_entered_process)}, {"wait_sem", MakePacket(&calc_can_exit_process)}, {"post_sem_busy", MakePacket(&calc_entered_process_busy)}, @@ -3918,16 +3907,16 @@ TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) { Timestamp timestamp(0); // Prevent deadlock resolution by running the "busy" SemaphoreCalculator // for the duration of the test. - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("in_2", MakePacket(0).At(timestamp))); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("in", MakePacket(0).At(timestamp++))); for (int i = 1; i < 20; ++i, ++timestamp) { // Wait for the calculator to begin its Process call. calc_entered_process.Acquire(1); // Now the calculator is stuck processing a packet. We can queue up // another one. - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.AddPacketToInputStream("in", MakePacket(i).At(timestamp))); // We should be prevented from adding another, since the queue is now full. ::mediapipe::Status status = graph.AddPacketToInputStream( @@ -3940,8 +3929,8 @@ TEST(CalculatorGraph, SetInputStreamMaxQueueSizeWorksSlowCalculator) { calc_can_exit_process.Release(1); calc_can_exit_process_busy.Release(1); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); } // Verify the scheduler unthrottles the graph input stream to avoid a deadlock, @@ -3988,36 +3977,36 @@ TEST(CalculatorGraph, AddPacketNoBusyLoop) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); graph.SetGraphInputStreamAddMode( CalculatorGraph::GraphInputStreamAddMode::WAIT_TILL_NOT_FULL); std::vector out_packets; // Packets from the output stream "out". - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out", [&out_packets](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); const int kDecimationRatio = DecimatorCalculator::kDecimationRatio; // To leave the graph input stream "in" in the throttled state, kNumPackets // can be any value other than a multiple of kDecimationRatio plus one. const int kNumPackets = 2 * kDecimationRatio; for (int i = 0; i < kNumPackets; ++i) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "in", MakePacket(i).At(Timestamp(i)))); } // The graph input stream "in" is throttled. Wait until the graph is idle. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Check that Pause() does not block forever trying to acquire a mutex. // This is a regression test for an old bug. graph.Pause(); graph.Resume(); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); // The expected output packets are: // "Timestamp(0) 0 0" @@ -4086,11 +4075,11 @@ TEST(CalculatorGraph, CalculatorInNamepsace) { )", &config)); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); nested_ns::ProcessFunction callback_1; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.StartRun({{"callback_1", AdoptAsUniquePtr(new auto(callback_1))}})); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilIdle()); + MP_EXPECT_OK(graph.WaitUntilIdle()); } // A ProcessFunction that passes through all packets. @@ -4125,23 +4114,23 @@ TEST(CalculatorGraph, ObserveOutputStream) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(config, {{"max_count", MakePacket(max_count)}})); // Observe the internal output stream "count" and the unconnected output // stream "out". std::vector count_packets; // Packets from the output stream "count". std::vector out_packets; // Packets from the output stream "out". - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( + MP_ASSERT_OK(graph.ObserveOutputStream( "count", [&count_packets](const Packet& packet) { count_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out", [&out_packets](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Run()); ASSERT_EQ(max_count, count_packets.size()); for (int i = 0; i < count_packets.size(); ++i) { EXPECT_EQ(i, count_packets[i].Get()); @@ -4189,16 +4178,16 @@ TEST(CalculatorGraph, ObserveOutputStreamSubgraph) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(config, {{"max_count", MakePacket(max_count)}})); // Observe the unconnected output stream "out". std::vector out_packets; // Packets from the output stream "out". - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out", [&out_packets](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Run()); ASSERT_EQ(max_count, out_packets.size()); for (int i = 0; i < out_packets.size(); ++i) { EXPECT_EQ(i, out_packets[i].Get()); @@ -4228,13 +4217,13 @@ TEST(CalculatorGraph, ObserveOutputStreamError) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(config, {{"max_count", MakePacket(max_count)}})); // Observe the internal output stream "count" and the unconnected output // stream "out". std::vector count_packets; // Packets from the output stream "count". std::vector out_packets; // Packets from the output stream "out". - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( + MP_ASSERT_OK(graph.ObserveOutputStream( "count", [&count_packets](const Packet& packet) { count_packets.push_back(packet); if (count_packets.size() >= fail_count) { @@ -4243,7 +4232,7 @@ TEST(CalculatorGraph, ObserveOutputStreamError) { return ::mediapipe::OkStatus(); } })); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out", [&out_packets](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); @@ -4278,7 +4267,7 @@ TEST(CalculatorGraph, ObserveOutputStreamNonexistent) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(config, {{"max_count", MakePacket(max_count)}})); // Observe the internal output stream "count". std::vector count_packets; // Packets from the output stream "count". @@ -4308,9 +4297,9 @@ TEST(CalculatorGraph, FastSourceSlowSink) { node { calculator: 'SlowCountingSinkCalculator' input_stream: 'out' } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(config, {{"max_count", MakePacket(max_count)}})); - MEDIAPIPE_EXPECT_OK(graph.Run()); + MP_EXPECT_OK(graph.Run()); } TEST(CalculatorGraph, GraphFinishesWhilePaused) { @@ -4331,13 +4320,13 @@ TEST(CalculatorGraph, GraphFinishesWhilePaused) { node { calculator: 'OneShot20MsCalculator' } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_EXPECT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_EXPECT_OK(graph.StartRun({})); absl::SleepFor(absl::Milliseconds(10)); graph.Pause(); absl::SleepFor(absl::Milliseconds(20)); graph.Resume(); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilDone()); + MP_EXPECT_OK(graph.WaitUntilDone()); } // There should be no memory leaks, no error messages (requires manual @@ -4374,11 +4363,11 @@ TEST(CalculatorGraph, RecoverAfterPreviousFailInOpen) { node { calculator: 'IntSinkCalculator' input_stream: 'd' } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(config, {{"max_count", MakePacket(max_count)}})); for (int i = 0; i < 2; ++i) { EXPECT_FALSE(graph.Run({{"fail", MakePacket(true)}}).ok()); - MEDIAPIPE_EXPECT_OK(graph.Run({{"fail", MakePacket(false)}})); + MP_EXPECT_OK(graph.Run({{"fail", MakePacket(false)}})); } } @@ -4412,8 +4401,8 @@ TEST(CalculatorGraph, PropagateBoundLoop) { tool::AddVectorSink("sum", &config, &packet_dump); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run()); ASSERT_EQ(101, packet_dump.size()); int sum = 0; for (int i = 0; i < 101; ++i) { @@ -4461,7 +4450,7 @@ TEST(CalculatorGraph, ReuseValidatedGraphConfig) { } )"); ValidatedGraphConfig validated_graph; - MEDIAPIPE_ASSERT_OK(validated_graph.Initialize(config)); + MP_ASSERT_OK(validated_graph.Initialize(config)); std::atomic global_counter(0); Packet global_counter_packet = Adopt(new auto(&global_counter)); @@ -4472,7 +4461,7 @@ TEST(CalculatorGraph, ReuseValidatedGraphConfig) { int initial_generator_count = StaticCounterStringGenerator::NumPacketsGenerated(); int initial_calculator_count = global_counter.load(); - MEDIAPIPE_ASSERT_OK(graph.Initialize( + MP_ASSERT_OK(graph.Initialize( config, {{"created_by_factory", MakePacket("default string")}, {"input_in_initialize", MakePacket(10)}, @@ -4487,7 +4476,7 @@ TEST(CalculatorGraph, ReuseValidatedGraphConfig) { int initial_generator_count = StaticCounterStringGenerator::NumPacketsGenerated(); int initial_calculator_count = global_counter.load(); - MEDIAPIPE_ASSERT_OK(graph.Run({{"input_in_run", MakePacket(11)}})); + MP_ASSERT_OK(graph.Run({{"input_in_run", MakePacket(11)}})); EXPECT_EQ(initial_generator_count + 2, StaticCounterStringGenerator::NumPacketsGenerated()); EXPECT_EQ(initial_calculator_count + @@ -4626,9 +4615,9 @@ TEST(CalculatorGraph, RunsCorrectlyWithSubgraphs) { TEST(CalculatorGraph, SetExecutorTwice) { // SetExecutor must not be called more than once for the same executor name. CalculatorGraph graph; - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.SetExecutor("xyz", std::make_shared(1))); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph.SetExecutor("abc", std::make_shared(1))); ::mediapipe::Status status = graph.SetExecutor("xyz", std::make_shared(1)); @@ -4717,7 +4706,7 @@ TEST(CalculatorGraph, UndeclaredExecutor) { // ExecutorConfig, even if the executor is provided to the graph with a // CalculatorGraph::SetExecutor() call. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.SetExecutor("xyz", std::make_shared(1))); CalculatorGraphConfig config = ::mediapipe::ParseTextProtoOrDie(R"( @@ -4761,7 +4750,7 @@ TEST(CalculatorGraph, UntypedExecutorDeclaredButNotSet) { TEST(CalculatorGraph, DuplicateExecutorConfig) { // More than one ExecutorConfig cannot have the same name. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.SetExecutor("xyz", std::make_shared(1))); CalculatorGraphConfig config = ::mediapipe::ParseTextProtoOrDie(R"( @@ -4786,7 +4775,7 @@ TEST(CalculatorGraph, TypedExecutorDeclaredAndSet) { // If an executor is declared with a "type" field, it must not be provided // to the graph with a CalculatorGraph::SetExecutor() call. CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.SetExecutor("xyz", std::make_shared(1))); CalculatorGraphConfig config = ::mediapipe::ParseTextProtoOrDie(R"( @@ -4871,7 +4860,7 @@ TEST(CalculatorGraph, NumThreadsAndNonDefaultExecutorConfig) { output_stream: 'out' } )"); - MEDIAPIPE_EXPECT_OK(graph.Initialize(config)); + MP_EXPECT_OK(graph.Initialize(config)); } // Verifies that the application thread is used only when @@ -4906,14 +4895,14 @@ TEST(CalculatorGraph, RunWithNumThreadsInExecutorConfig) { config.mutable_executor(0)->set_type(cases[i].executor_type); } CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); Packet out_packet; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("out", [&out_packet](const Packet& packet) { out_packet = packet; return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Run()); EXPECT_EQ(cases[i].use_app_thread_is_expected, out_packet.Get() == pthread_self()) << "for case " << i; @@ -4940,9 +4929,9 @@ TEST(CalculatorGraph, SimulateAssertFailure) { input_stream: 'in_b' )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_EXPECT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); + MP_EXPECT_OK(graph.WaitUntilIdle()); // End the test here to simulate an ASSERT_ failure, which will skip the // rest of the test and exit the test function immediately. The test should @@ -4965,8 +4954,8 @@ TEST(CalculatorGraph, CheckInputTimestamp) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run()); } // Verifies Calculator::InputTimestamp() returns the expected value in Open(), @@ -4986,8 +4975,8 @@ TEST(CalculatorGraph, CheckInputTimestamp2) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run()); } TEST(CalculatorGraph, CheckBatchProcessingBoundPropagation) { @@ -5018,8 +5007,8 @@ TEST(CalculatorGraph, CheckBatchProcessingBoundPropagation) { node { calculator: 'IntSinkCalculator' input_stream: 'output' } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Run()); } TEST(CalculatorGraph, OutputSidePacketInProcess) { @@ -5039,9 +5028,9 @@ TEST(CalculatorGraph, OutputSidePacketInProcess) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); std::vector output_packets; - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( + MP_ASSERT_OK(graph.ObserveOutputStream( "output", [&output_packets](const Packet& packet) { output_packets.push_back(packet); return ::mediapipe::OkStatus(); @@ -5050,11 +5039,11 @@ TEST(CalculatorGraph, OutputSidePacketInProcess) { // Run the graph twice. for (int run = 0; run < 2; ++run) { output_packets.clear(); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "offset", MakePacket(offset).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("offset")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("offset")); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(1, output_packets.size()); EXPECT_EQ(offset, output_packets[0].Get().Value()); } @@ -5072,15 +5061,15 @@ TEST(CalculatorGraph, OutputSidePacketAlreadySet) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); // Send two input packets to cause OutputSidePacketInProcessCalculator to // set the output side packet twice. - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "offset", MakePacket(offset).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "offset", MakePacket(offset).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("offset")); + MP_ASSERT_OK(graph.CloseInputStream("offset")); ::mediapipe::Status status = graph.WaitUntilDone(); EXPECT_EQ(status.code(), ::mediapipe::StatusCode::kAlreadyExists); @@ -5099,15 +5088,15 @@ TEST(CalculatorGraph, OutputSidePacketWithTimestamp) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); // The OutputSidePacketWithTimestampCalculator neglects to clear the // timestamp in the input packet when it copies the input packet to the // output side packet. The timestamp value should appear in the error // message. - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "offset", MakePacket(offset).At(Timestamp(237)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("offset")); + MP_ASSERT_OK(graph.CloseInputStream("offset")); ::mediapipe::Status status = graph.WaitUntilDone(); EXPECT_EQ(status.code(), ::mediapipe::StatusCode::kInvalidArgument); EXPECT_THAT(status.message(), testing::HasSubstr("has a timestamp 237.")); @@ -5135,24 +5124,24 @@ TEST(CalculatorGraph, OutputSidePacketConsumedBySourceNode) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); std::vector output_packets; - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( + MP_ASSERT_OK(graph.ObserveOutputStream( "output", [&output_packets](const Packet& packet) { output_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); // Wait until the graph is idle so that // Scheduler::TryToScheduleNextSourceLayer() gets called. // Scheduler::TryToScheduleNextSourceLayer() should not activate source // nodes that haven't been opened. We can't call graph.WaitUntilIdle() // because the graph has a source node. absl::SleepFor(absl::Milliseconds(10)); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "max_count", MakePacket(max_count).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("max_count")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("max_count")); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(max_count, output_packets.size()); for (int i = 0; i < output_packets.size(); ++i) { EXPECT_EQ(i, output_packets[i].Get()); @@ -5176,14 +5165,14 @@ TEST(CalculatorGraph, GraphInputStreamWithTag) { std::vector packet_dump; tool::AddVectorSink("output_0", &config, &packet_dump); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < 5; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "video_metadata", MakePacket(i).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseAllPacketSources()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllPacketSources()); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(5, packet_dump.size()); } @@ -5272,7 +5261,7 @@ TEST(CalculatorGraph, SourceLayerInversion) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize( + MP_ASSERT_OK(graph.Initialize( config, {{"max_count", MakePacket(max_count)}, {"initial_value1", MakePacket(initial_value1)}})); ::mediapipe::Status status = graph.Run(); @@ -5316,14 +5305,14 @@ TEST(CalculatorGraph, PacketGeneratorLikeCalculators) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); std::vector output_packets; - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( + MP_ASSERT_OK(graph.ObserveOutputStream( "output", [&output_packets](const Packet& packet) { output_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Run()); ASSERT_EQ(1, output_packets.size()); EXPECT_EQ(3, output_packets[0].Get()); EXPECT_EQ(Timestamp::PostStream(), output_packets[0].Timestamp()); @@ -5345,9 +5334,9 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); std::vector output_packets; - MEDIAPIPE_ASSERT_OK(graph.ObserveOutputStream( + MP_ASSERT_OK(graph.ObserveOutputStream( "output", [&output_packets](const Packet& packet) { output_packets.push_back(packet); return ::mediapipe::OkStatus(); @@ -5357,13 +5346,13 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) { int max_count = 100; for (int run = 0; run < 1; ++run) { output_packets.clear(); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < max_count; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_packets", MakePacket(i).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_packets")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("input_packets")); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(1, output_packets.size()); EXPECT_EQ(max_count, output_packets[0].Get()); EXPECT_EQ(Timestamp::PostStream(), output_packets[0].Timestamp()); @@ -5390,12 +5379,12 @@ TEST(CalculatorGraph, GetOutputSidePacket) { } )"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); // Check a packet generated by the PacketGenerator, which is available after // graph initialization, can be fetched before graph starts. ::mediapipe::StatusOr status_or_packet = graph.GetOutputSidePacket("output_uint64"); - MEDIAPIPE_ASSERT_OK(status_or_packet); + MP_ASSERT_OK(status_or_packet); EXPECT_EQ(Timestamp::Unset(), status_or_packet.ValueOrDie().Timestamp()); // IntSplitterPacketGenerator is missing its input side packet and we // won't be able to get its output side packet now. @@ -5407,15 +5396,15 @@ TEST(CalculatorGraph, GetOutputSidePacket) { std::map extra_side_packets; extra_side_packets.insert({"input_uint64", MakePacket(1123)}); for (int run = 0; run < 1; ++run) { - MEDIAPIPE_ASSERT_OK(graph.StartRun(extra_side_packets)); + MP_ASSERT_OK(graph.StartRun(extra_side_packets)); status_or_packet = graph.GetOutputSidePacket("output_uint32_pair"); - MEDIAPIPE_ASSERT_OK(status_or_packet); + MP_ASSERT_OK(status_or_packet); EXPECT_EQ(Timestamp::Unset(), status_or_packet.ValueOrDie().Timestamp()); for (int i = 0; i < max_count; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_packets", MakePacket(i).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_packets")); + MP_ASSERT_OK(graph.CloseInputStream("input_packets")); // Should return NOT_FOUND for invalid side packets. status_or_packet = graph.GetOutputSidePacket("unknown"); @@ -5430,23 +5419,23 @@ TEST(CalculatorGraph, GetOutputSidePacket) { status_or_packet.status().code()); // Should stil return a base even before graph is done. status_or_packet = graph.GetOutputSidePacket("output_uint64"); - MEDIAPIPE_ASSERT_OK(status_or_packet); + MP_ASSERT_OK(status_or_packet); EXPECT_EQ(Timestamp::Unset(), status_or_packet.ValueOrDie().Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); // Check packets are available after graph is done. status_or_packet = graph.GetOutputSidePacket("num_of_packets"); - MEDIAPIPE_ASSERT_OK(status_or_packet); + MP_ASSERT_OK(status_or_packet); EXPECT_EQ(max_count, status_or_packet.ValueOrDie().Get()); EXPECT_EQ(Timestamp::Unset(), status_or_packet.ValueOrDie().Timestamp()); // Should still return a base packet after graph is done. status_or_packet = graph.GetOutputSidePacket("output_uint64"); - MEDIAPIPE_ASSERT_OK(status_or_packet); + MP_ASSERT_OK(status_or_packet); EXPECT_EQ(Timestamp::Unset(), status_or_packet.ValueOrDie().Timestamp()); // Should still return a non-base packet after graph is done. status_or_packet = graph.GetOutputSidePacket("output_uint32_pair"); - MEDIAPIPE_ASSERT_OK(status_or_packet); + MP_ASSERT_OK(status_or_packet); EXPECT_EQ(Timestamp::Unset(), status_or_packet.ValueOrDie().Timestamp()); } } @@ -5461,11 +5450,11 @@ TEST(CalculatorGraph, TestPollPacket) { node->add_input_side_packet("MAX_COUNT:max_count"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); auto status_or_poller = graph.AddOutputStreamPoller("output"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.StartRun({{"max_count", MakePacket(kDefaultMaxCount)}})); Packet packet; int num_packets = 0; @@ -5473,8 +5462,8 @@ TEST(CalculatorGraph, TestPollPacket) { EXPECT_EQ(num_packets, packet.Get()); ++num_packets; } - MEDIAPIPE_ASSERT_OK(graph.CloseAllPacketSources()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllPacketSources()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_FALSE(poller.Next(&packet)); EXPECT_EQ(kDefaultMaxCount, num_packets); } @@ -5488,12 +5477,12 @@ TEST(CalculatorGraph, TestOutputStreamPollerDesiredQueueSize) { for (int queue_size = 1; queue_size < 10; ++queue_size) { CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); auto status_or_poller = graph.AddOutputStreamPoller("output"); ASSERT_TRUE(status_or_poller.ok()); OutputStreamPoller poller = std::move(status_or_poller.ValueOrDie()); poller.SetMaxQueueSize(queue_size); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.StartRun({{"max_count", MakePacket(kDefaultMaxCount)}})); Packet packet; int num_packets = 0; @@ -5501,8 +5490,8 @@ TEST(CalculatorGraph, TestOutputStreamPollerDesiredQueueSize) { EXPECT_EQ(num_packets, packet.Get()); ++num_packets; } - MEDIAPIPE_ASSERT_OK(graph.CloseAllPacketSources()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllPacketSources()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_FALSE(poller.Next(&packet)); EXPECT_EQ(kDefaultMaxCount, num_packets); } @@ -5520,14 +5509,14 @@ TEST(CalculatorGraph, TestPollPacketsFromMultipleStreams) { node2->add_output_stream("stream2"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); auto status_or_poller1 = graph.AddOutputStreamPoller("stream1"); ASSERT_TRUE(status_or_poller1.ok()); OutputStreamPoller poller1 = std::move(status_or_poller1.ValueOrDie()); auto status_or_poller2 = graph.AddOutputStreamPoller("stream2"); ASSERT_TRUE(status_or_poller2.ok()); OutputStreamPoller poller2 = std::move(status_or_poller2.ValueOrDie()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.StartRun({{"max_count", MakePacket(kDefaultMaxCount)}})); Packet packet1; Packet packet2; @@ -5546,8 +5535,8 @@ TEST(CalculatorGraph, TestPollPacketsFromMultipleStreams) { --running_pollers; } } - MEDIAPIPE_ASSERT_OK(graph.CloseAllPacketSources()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllPacketSources()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_FALSE(poller1.Next(&packet1)); EXPECT_FALSE(poller2.Next(&packet2)); EXPECT_EQ(kDefaultMaxCount, num_packets1); @@ -5577,21 +5566,21 @@ TEST(CalculatorGraph, SimpleMuxCalculatorWithCustomInputStreamHandler) { std::vector packet_dump; tool::AddVectorSink("output", &config, &packet_dump); - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); // Send packets to input stream "input0" at timestamps 0 and 1 consecutively. Timestamp input0_timestamp = Timestamp(0); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "input0", MakePacket(1).At(input0_timestamp))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(1, packet_dump.size()); EXPECT_EQ(1, packet_dump[0].Get()); ++input0_timestamp; - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "input0", MakePacket(3).At(input0_timestamp))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(2, packet_dump.size()); EXPECT_EQ(3, packet_dump[1].Get()); @@ -5600,7 +5589,7 @@ TEST(CalculatorGraph, SimpleMuxCalculatorWithCustomInputStreamHandler) { // in a mismatch in timestamps as the SimpleMuxCalculator doesn't handle // inputs from all streams in monotonically increasing order of timestamps. Timestamp input1_timestamp = Timestamp(0); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( "input1", MakePacket(2).At(input1_timestamp))); ::mediapipe::Status run_status = graph.WaitUntilIdle(); EXPECT_THAT( diff --git a/mediapipe/framework/calculator_node.cc b/mediapipe/framework/calculator_node.cc index 42fd7e06a..f3cd90eea 100644 --- a/mediapipe/framework/calculator_node.cc +++ b/mediapipe/framework/calculator_node.cc @@ -103,14 +103,14 @@ Timestamp CalculatorNode::SourceProcessOrder( // TODO Propagate types between calculators when SetAny is used. - RETURN_IF_ERROR(InitializeOutputSidePackets( + MP_RETURN_IF_ERROR(InitializeOutputSidePackets( node_type_info.OutputSidePacketTypes(), output_side_packets)); - RETURN_IF_ERROR(InitializeInputSidePackets(output_side_packets)); + MP_RETURN_IF_ERROR(InitializeInputSidePackets(output_side_packets)); - RETURN_IF_ERROR(InitializeOutputStreamHandler( + MP_RETURN_IF_ERROR(InitializeOutputStreamHandler( node_config.output_stream_handler(), node_type_info.OutputStreamTypes())); - RETURN_IF_ERROR(InitializeOutputStreams(output_stream_managers)); + MP_RETURN_IF_ERROR(InitializeOutputStreams(output_stream_managers)); calculator_state_ = absl::make_unique( name_, node_id_, node_config.calculator(), node_config, @@ -142,7 +142,7 @@ Timestamp CalculatorNode::SourceProcessOrder( // Use calculator or graph specified InputStreamHandler, or the default ISH // already set from graph. - RETURN_IF_ERROR(InitializeInputStreamHandler( + MP_RETURN_IF_ERROR(InitializeInputStreamHandler( use_calc_specified ? handler_config : node_config.input_stream_handler(), node_type_info.InputStreamTypes())); @@ -216,7 +216,7 @@ Timestamp CalculatorNode::SourceProcessOrder( RET_CHECK_LE(0, node_type_info.InputStreamBaseIndex()); InputStreamManager* current_input_stream_managers = &input_stream_managers[node_type_info.InputStreamBaseIndex()]; - RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers( + MP_RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers( current_input_stream_managers)); // Set all the mirrors. @@ -278,7 +278,7 @@ Timestamp CalculatorNode::SourceProcessOrder( ::mediapipe::Status CalculatorNode::ConnectShardsToStreams( CalculatorContext* calculator_context) { RET_CHECK(calculator_context); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( input_stream_handler_->SetupInputShards(&calculator_context->Inputs())); return output_stream_handler_->SetupOutputShards( &calculator_context->Outputs()); @@ -338,7 +338,7 @@ void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) { const PacketTypeSet* input_side_packet_types = &validated_graph_->CalculatorInfos()[node_id_].InputSidePacketTypes(); - RETURN_IF_ERROR(input_side_packet_handler_.PrepareForRun( + MP_RETURN_IF_ERROR(input_side_packet_handler_.PrepareForRun( input_side_packet_types, all_side_packets, [this]() { CalculatorNode::InputSidePacketsReady(); }, std::move(error_callback))); @@ -361,7 +361,7 @@ void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) { } } - RETURN_IF_ERROR(calculator_context_manager_.PrepareForRun(std::bind( + MP_RETURN_IF_ERROR(calculator_context_manager_.PrepareForRun(std::bind( &CalculatorNode::ConnectShardsToStreams, this, std::placeholders::_1))); auto calculator_statusor = CreateCalculator( @@ -426,7 +426,7 @@ void CalculatorNode::SetMaxInputStreamQueueSize(int max_queue_size) { "Open() on node \"$0\" returned tool::StatusStop() which should only be " "used to signal that a source node is done producing data.", DebugName()); - RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute( + MP_RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute( "Calculator::Open() for node \"$0\" failed: ", DebugName()); needs_to_close_ = true; @@ -519,7 +519,7 @@ void CalculatorNode::CloseOutputStreams(OutputStreamShardSet* outputs) { status_ = kStateClosed; } - RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute( + MP_RETURN_IF_ERROR(result).SetPrepend() << absl::Substitute( "Calculator::Close() for node \"$0\" failed: ", DebugName()); VLOG(2) << "Closed node " << DebugName(); @@ -745,7 +745,7 @@ std::string CalculatorNode::DebugName() const { } output_stream_handler_->PostProcess(input_timestamp); if (node_stopped) { - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( CloseNode(::mediapipe::OkStatus(), /*graph_run_ended=*/false)); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/framework/calculator_node_test.cc b/mediapipe/framework/calculator_node_test.cc index 899436ba8..9e7e18b93 100644 --- a/mediapipe/framework/calculator_node_test.cc +++ b/mediapipe/framework/calculator_node_test.cc @@ -159,7 +159,7 @@ class CalculatorNodeTest : public ::testing::Test { input_side_packets_.emplace("input_b", Adopt(new int(42))); node_.reset(new CalculatorNode()); - MEDIAPIPE_ASSERT_OK(node_->Initialize( + MP_ASSERT_OK(node_->Initialize( &validated_graph_, 2, input_stream_managers_.get(), output_stream_managers_.get(), output_side_packets_.get(), &buffer_size_hint_, graph_profiler_)); @@ -190,7 +190,7 @@ class CalculatorNodeTest : public ::testing::Test { ++index) { const EdgeInfo& edge_info = validated_graph_.OutputSidePacketInfos()[index]; - RETURN_IF_ERROR(output_side_packets_[index].Initialize( + MP_RETURN_IF_ERROR(output_side_packets_[index].Initialize( edge_info.name, edge_info.packet_type)); } // END OF: code is copied from @@ -203,7 +203,7 @@ class CalculatorNodeTest : public ::testing::Test { for (int index = 0; index < validated_graph_.InputStreamInfos().size(); ++index) { const EdgeInfo& edge_info = validated_graph_.InputStreamInfos()[index]; - RETURN_IF_ERROR(input_stream_managers_[index].Initialize( + MP_RETURN_IF_ERROR(input_stream_managers_[index].Initialize( edge_info.name, edge_info.packet_type, edge_info.back_edge)); } @@ -213,7 +213,7 @@ class CalculatorNodeTest : public ::testing::Test { for (int index = 0; index < validated_graph_.OutputStreamInfos().size(); ++index) { const EdgeInfo& edge_info = validated_graph_.OutputStreamInfos()[index]; - RETURN_IF_ERROR(output_stream_managers_[index].Initialize( + MP_RETURN_IF_ERROR(output_stream_managers_[index].Initialize( edge_info.name, edge_info.packet_type)); } // END OF: code is copied from CalculatorGraph::InitializeStreams. @@ -277,7 +277,7 @@ TEST_F(CalculatorNodeTest, Initialize) { TEST_F(CalculatorNodeTest, PrepareForRun) { InitializeEnvironment(/*use_tags=*/false); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); EXPECT_TRUE(node_->Prepared()); EXPECT_FALSE(node_->Opened()); @@ -296,11 +296,11 @@ TEST_F(CalculatorNodeTest, PrepareForRun) { TEST_F(CalculatorNodeTest, Open) { InitializeEnvironment(/*use_tags=*/false); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); EXPECT_EQ(0, ready_for_open_count_); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); EXPECT_TRUE(node_->Prepared()); EXPECT_TRUE(node_->Opened()); @@ -319,10 +319,10 @@ TEST_F(CalculatorNodeTest, Open) { TEST_F(CalculatorNodeTest, Process) { InitializeEnvironment(/*use_tags=*/false); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); OutputStreamShard stream_a_shard; stream_a_shard.SetSpec(stream_a_manager_->Spec()); @@ -332,7 +332,7 @@ TEST_F(CalculatorNodeTest, Process) { // Expects that a CalculatorContext has been prepared. EXPECT_NE(nullptr, cc_); EXPECT_TRUE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); cc_ = nullptr; node_->EndScheduling(); @@ -356,10 +356,10 @@ TEST_F(CalculatorNodeTest, Process) { TEST_F(CalculatorNodeTest, ProcessSeveral) { InitializeEnvironment(/*use_tags=*/false); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); OutputStreamShard stream_a_shard; stream_a_shard.SetSpec(stream_a_manager_->Spec()); @@ -369,7 +369,7 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) { EXPECT_EQ(1, schedule_count_); EXPECT_TRUE(node_->TryToBeginScheduling()); EXPECT_NE(nullptr, cc_); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); EXPECT_EQ(1, schedule_count_); @@ -383,7 +383,7 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) { EXPECT_TRUE(node_->TryToBeginScheduling()); // Expects that a CalculatorContext has been prepared. EXPECT_NE(nullptr, cc_); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); EXPECT_EQ(3, schedule_count_); EXPECT_TRUE(node_->TryToBeginScheduling()); @@ -397,13 +397,13 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) { // The max parallelism is already reached. EXPECT_FALSE(node_->TryToBeginScheduling()); EXPECT_NE(nullptr, cc_); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); EXPECT_EQ(4, schedule_count_); EXPECT_TRUE(node_->TryToBeginScheduling()); EXPECT_NE(nullptr, cc_); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); cc_ = nullptr; node_->EndScheduling(); @@ -425,10 +425,10 @@ TEST_F(CalculatorNodeTest, ProcessSeveral) { TEST_F(CalculatorNodeTest, Close) { InitializeEnvironment(/*use_tags=*/false); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); OutputStreamShard stream_a_shard; stream_a_shard.SetSpec(stream_a_manager_->Spec()); @@ -438,11 +438,11 @@ TEST_F(CalculatorNodeTest, Close) { stream_a_manager_->Close(); // The max parallelism is already reached. EXPECT_FALSE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); EXPECT_TRUE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); EXPECT_TRUE(node_->Closed()); EXPECT_EQ(2, schedule_count_); @@ -464,10 +464,10 @@ TEST_F(CalculatorNodeTest, Close) { TEST_F(CalculatorNodeTest, CleanupAfterRun) { InitializeEnvironment(/*use_tags=*/false); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); OutputStreamShard stream_a_shard; stream_a_shard.SetSpec(stream_a_manager_->Spec()); stream_a_shard.Add(new int(1), Timestamp(1)); @@ -476,11 +476,11 @@ TEST_F(CalculatorNodeTest, CleanupAfterRun) { stream_a_manager_->Close(); // The max parallelism is already reached. EXPECT_FALSE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); // Call ProcessNode again for the node to see the end of the stream. EXPECT_TRUE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); // The max parallelism is already reached. EXPECT_FALSE(node_->TryToBeginScheduling()); @@ -501,10 +501,10 @@ TEST_F(CalculatorNodeTest, CleanupAfterRun) { } void CalculatorNodeTest::TestCleanupAfterRunTwice() { - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); OutputStreamShard stream_a_shard; stream_a_shard.SetSpec(stream_a_manager_->Spec()); stream_a_shard.Add(new int(1), Timestamp(1)); @@ -513,20 +513,20 @@ void CalculatorNodeTest::TestCleanupAfterRunTwice() { stream_a_manager_->Close(); // The max parallelism is already reached. EXPECT_FALSE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); // We should get Timestamp::Done here. EXPECT_TRUE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); node_->CleanupAfterRun(::mediapipe::OkStatus()); stream_a_manager_->PrepareForRun(nullptr); - MEDIAPIPE_ASSERT_OK(PrepareNodeForRun()); + MP_ASSERT_OK(PrepareNodeForRun()); SimulateParentOpenNode(); - MEDIAPIPE_EXPECT_OK(node_->OpenNode()); + MP_EXPECT_OK(node_->OpenNode()); stream_a_manager_->ResetShard(&stream_a_shard); stream_a_shard.Add(new int(2), Timestamp(4)); stream_a_shard.Add(new int(3), Timestamp(8)); @@ -534,14 +534,14 @@ void CalculatorNodeTest::TestCleanupAfterRunTwice() { EXPECT_TRUE(node_->TryToBeginScheduling()); stream_a_manager_->Close(); EXPECT_FALSE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); EXPECT_TRUE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); // We should get Timestamp::Done here. EXPECT_TRUE(node_->TryToBeginScheduling()); - MEDIAPIPE_EXPECT_OK(node_->ProcessNode(cc_)); + MP_EXPECT_OK(node_->ProcessNode(cc_)); node_->EndScheduling(); // The max parallelism is already reached. EXPECT_FALSE(node_->TryToBeginScheduling()); diff --git a/mediapipe/framework/calculator_parallel_execution_test.cc b/mediapipe/framework/calculator_parallel_execution_test.cc index c97b066ee..10e6453c4 100644 --- a/mediapipe/framework/calculator_parallel_execution_test.cc +++ b/mediapipe/framework/calculator_parallel_execution_test.cc @@ -117,7 +117,7 @@ TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) { CalculatorGraph graph(graph_config); // Runs the graph twice. for (int i = 0; i < 2; ++i) { - MEDIAPIPE_ASSERT_OK(graph.StartRun( + MP_ASSERT_OK(graph.StartRun( {{"callback", MakePacket>(std::bind( &ParallelExecutionTest::AddThreadSafeVectorSink, this, std::placeholders::_1))}})); @@ -134,15 +134,15 @@ TEST_F(ParallelExecutionTest, SlowPlusOneCalculatorsTest) { EXPECT_EQ(0, fail_count); // Doesn't wait but just close the input stream. - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input")); + MP_ASSERT_OK(graph.CloseInputStream("input")); // Waits properly via the API until the graph is done. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); absl::ReaderMutexLock lock(&output_packets_mutex_); ASSERT_EQ(kTotalNums - kTotalNums / 4, output_packets_.size()); int index = 1; for (const Packet& packet : output_packets_) { - MEDIAPIPE_ASSERT_OK(packet.ValidateAsType()); + MP_ASSERT_OK(packet.ValidateAsType()); EXPECT_EQ(index + 2, packet.Get()); EXPECT_EQ(Timestamp(index), packet.Timestamp()); if (++index % 4 == 0) { diff --git a/mediapipe/framework/calculator_registry_util.cc b/mediapipe/framework/calculator_registry_util.cc index b1c2110b5..77aab0be4 100644 --- a/mediapipe/framework/calculator_registry_util.cc +++ b/mediapipe/framework/calculator_registry_util.cc @@ -40,7 +40,7 @@ bool IsLegacyCalculator(const std::string& package_name, internal::StaticAccessToCalculatorBaseRegistry::CreateByNameInNamespace( package_name, node_class), _ << "Unable to find Calculator \"" << node_class << "\""); - RETURN_IF_ERROR(static_access_to_calculator_base->GetContract(contract)) + MP_RETURN_IF_ERROR(static_access_to_calculator_base->GetContract(contract)) .SetPrepend() << node_class << ": "; return ::mediapipe::OkStatus(); diff --git a/mediapipe/framework/calculator_runner.cc b/mediapipe/framework/calculator_runner.cc index 8b5239883..9c4a31335 100644 --- a/mediapipe/framework/calculator_runner.cc +++ b/mediapipe/framework/calculator_runner.cc @@ -238,8 +238,8 @@ std::map CalculatorRunner::GetCountersValues() { std::string name; std::string tag; int index; - RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i), &tag, - &index, &name)); + MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i), + &tag, &index, &name)); // Add a source for each input stream. auto* node = config.add_node(); node->set_calculator("CalculatorRunnerSourceCalculator"); @@ -250,8 +250,8 @@ std::map CalculatorRunner::GetCountersValues() { std::string name; std::string tag; int index; - RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i), &tag, - &index, &name)); + MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i), + &tag, &index, &name)); // Add a sink for each output stream. auto* node = config.add_node(); node->set_calculator("CalculatorRunnerSinkCalculator"); @@ -276,12 +276,12 @@ std::map CalculatorRunner::GetCountersValues() { } graph_ = absl::make_unique(); - RETURN_IF_ERROR(graph_->Initialize(config)); + MP_RETURN_IF_ERROR(graph_->Initialize(config)); return ::mediapipe::OkStatus(); } ::mediapipe::Status CalculatorRunner::Run() { - RETURN_IF_ERROR(BuildGraph()); + MP_RETURN_IF_ERROR(BuildGraph()); // Set the input side packets for the sources. std::map input_side_packets; int positional_index = -1; @@ -289,8 +289,8 @@ std::map CalculatorRunner::GetCountersValues() { std::string name; std::string tag; int index; - RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i), &tag, - &index, &name)); + MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_stream(i), + &tag, &index, &name)); const CalculatorRunner::StreamContents* contents; if (index == -1) { // positional_index considers the case when the tag is empty, which is @@ -310,8 +310,8 @@ std::map CalculatorRunner::GetCountersValues() { std::string name; std::string tag; int index; - RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.input_side_packet(i), - &tag, &index, &name)); + MP_RETURN_IF_ERROR(tool::ParseTagIndexName( + node_config_.input_side_packet(i), &tag, &index, &name)); const Packet* packet; if (index == -1) { packet = &input_side_packets_->Get(tag, ++positional_index); @@ -326,8 +326,8 @@ std::map CalculatorRunner::GetCountersValues() { std::string name; std::string tag; int index; - RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i), &tag, - &index, &name)); + MP_RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_stream(i), + &tag, &index, &name)); CalculatorRunner::StreamContents* contents; if (index == -1) { contents = &outputs_->Get(tag, ++positional_index); @@ -339,15 +339,15 @@ std::map CalculatorRunner::GetCountersValues() { input_side_packets.emplace(absl::StrCat(kSinkPrefix, name), Adopt(new auto(contents))); } - RETURN_IF_ERROR(graph_->Run(input_side_packets)); + MP_RETURN_IF_ERROR(graph_->Run(input_side_packets)); positional_index = -1; for (int i = 0; i < node_config_.output_side_packet_size(); ++i) { std::string name; std::string tag; int index; - RETURN_IF_ERROR(tool::ParseTagIndexName(node_config_.output_side_packet(i), - &tag, &index, &name)); + MP_RETURN_IF_ERROR(tool::ParseTagIndexName( + node_config_.output_side_packet(i), &tag, &index, &name)); Packet& contents = output_side_packets_->Get( tag, (index == -1) ? ++positional_index : index); ASSIGN_OR_RETURN(contents, graph_->GetOutputSidePacket(name)); diff --git a/mediapipe/framework/calculator_runner_test.cc b/mediapipe/framework/calculator_runner_test.cc index 692a9a554..95dd76144 100644 --- a/mediapipe/framework/calculator_runner_test.cc +++ b/mediapipe/framework/calculator_runner_test.cc @@ -150,7 +150,7 @@ TEST(CalculatorRunner, RunsCalculator) { const int input_side_packet_content = 10 + iter; runner.MutableSidePackets()->Index(0) = Adopt(new int(input_side_packet_content)); - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); EXPECT_EQ(input_side_packet_content, runner.OutputSidePackets().Tag("SIDE_OUTPUT").Get()); const auto& outputs = runner.Outputs(); @@ -204,7 +204,7 @@ TEST(CalculatorRunner, MultiTagTestCalculatorOk) { ->Get("", ts % 2) .packets.push_back(Adopt(new int(ts)).At(Timestamp(ts))); } - MEDIAPIPE_ASSERT_OK(runner.Run()); + MP_ASSERT_OK(runner.Run()); const auto& outputs = runner.Outputs(); ASSERT_EQ(3, outputs.NumEntries()); diff --git a/mediapipe/framework/collection_test.cc b/mediapipe/framework/collection_test.cc index 0a617b3a6..9fd8cb340 100644 --- a/mediapipe/framework/collection_test.cc +++ b/mediapipe/framework/collection_test.cc @@ -76,7 +76,7 @@ TEST(CollectionTest, MixedTagAndIndexUsage) { auto tags_statusor = tool::CreateTagMap({"TAG_A:a", "TAG_B:1:b", "TAG_A:2:c", "TAG_B:d", "TAG_C:0:e", "TAG_A:1:f"}); - MEDIAPIPE_ASSERT_OK(tags_statusor); + MP_ASSERT_OK(tags_statusor); internal::Collection collection1(std::move(tags_statusor.ValueOrDie())); collection1.Get("TAG_A", 0) = 100; @@ -452,9 +452,8 @@ template } TEST(CollectionTest, TestCollectionWithPointersIntAndString) { - MEDIAPIPE_ASSERT_OK( - TestCollectionWithPointers({3, 7, -2, 0, 4, -3}, 17, 10)); - MEDIAPIPE_ASSERT_OK(TestCollectionWithPointers( + MP_ASSERT_OK(TestCollectionWithPointers({3, 7, -2, 0, 4, -3}, 17, 10)); + MP_ASSERT_OK(TestCollectionWithPointers( {"a0", "a1", "a2", "b0", "b1", "c0"}, "inject1", "inject2")); } diff --git a/mediapipe/framework/deps/BUILD b/mediapipe/framework/deps/BUILD index f3f66eaa8..f3ca5dc1d 100644 --- a/mediapipe/framework/deps/BUILD +++ b/mediapipe/framework/deps/BUILD @@ -31,7 +31,7 @@ proto_library( mediapipe_cc_proto_library( name = "proto_descriptor_cc_proto", srcs = ["proto_descriptor.proto"], - visibility = ["//visibility:public"], + visibility = ["//mediapipe/framework:__subpackages__"], deps = [":proto_descriptor_proto"], ) diff --git a/mediapipe/framework/deps/ret_check.h b/mediapipe/framework/deps/ret_check.h index ceecd3818..54c05a7e6 100644 --- a/mediapipe/framework/deps/ret_check.h +++ b/mediapipe/framework/deps/ret_check.h @@ -48,7 +48,8 @@ inline StatusBuilder RetCheckImpl(const ::mediapipe::Status& status, return ::mediapipe::RetCheckFailSlowPath(MEDIAPIPE_LOC, #cond) #define RET_CHECK_OK(status) \ - RETURN_IF_ERROR(::mediapipe::RetCheckImpl((status), #status, MEDIAPIPE_LOC)) + MP_RETURN_IF_ERROR( \ + ::mediapipe::RetCheckImpl((status), #status, MEDIAPIPE_LOC)) #define RET_CHECK_FAIL() return ::mediapipe::RetCheckFailSlowPath(MEDIAPIPE_LOC) diff --git a/mediapipe/framework/deps/status.h b/mediapipe/framework/deps/status.h index 80f4055ce..8f5e3bfc0 100644 --- a/mediapipe/framework/deps/status.h +++ b/mediapipe/framework/deps/status.h @@ -154,7 +154,7 @@ inline std::string* MediaPipeCheckOpHelper(::mediapipe::Status v, while (auto _result = ::mediapipe::MediaPipeCheckOpHelper(val, #val)) \ LOG(level) << *(_result) -// To be consistent with MEDIAPIPE_EXPECT_OK, we add prefix MEDIAPIPE_ to +// To be consistent with MP_EXPECT_OK, we add prefix MEDIAPIPE_ to // CHECK_OK, QCHECK_OK, and DCHECK_OK. We prefer to use the marcos with // MEDIAPIPE_ prefix in mediapipe's codebase. #define MEDIAPIPE_CHECK_OK(val) MEDIAPIPE_DO_CHECK_OK(val, FATAL) diff --git a/mediapipe/framework/deps/status_macros.h b/mediapipe/framework/deps/status_macros.h index 90b23cc22..3e97510f5 100644 --- a/mediapipe/framework/deps/status_macros.h +++ b/mediapipe/framework/deps/status_macros.h @@ -31,8 +31,8 @@ // // For example: // ::mediapipe::Status MultiStepFunction() { -// RETURN_IF_ERROR(Function(args...)); -// RETURN_IF_ERROR(foo.Method(args...)); +// MP_RETURN_IF_ERROR(Function(args...)); +// MP_RETURN_IF_ERROR(foo.Method(args...)); // return ::mediapipe::OkStatus(); // } // @@ -42,8 +42,8 @@ // // For example: // ::mediapipe::Status MultiStepFunction() { -// RETURN_IF_ERROR(Function(args...)) << "in MultiStepFunction"; -// RETURN_IF_ERROR(foo.Method(args...)).Log(base_logging::ERROR) +// MP_RETURN_IF_ERROR(Function(args...)) << "in MultiStepFunction"; +// MP_RETURN_IF_ERROR(foo.Method(args...)).Log(base_logging::ERROR) // << "while processing query: " << query.DebugString(); // return ::mediapipe::OkStatus(); // } @@ -58,8 +58,8 @@ // return std::move(builder.Log(base_logging::WARNING).Attach(...)); // } // -// RETURN_IF_ERROR(foo()).With(TeamPolicy); -// RETURN_IF_ERROR(bar()).With(TeamPolicy); +// MP_RETURN_IF_ERROR(foo()).With(TeamPolicy); +// MP_RETURN_IF_ERROR(bar()).With(TeamPolicy); // // Changing the return type allows the macro to be used with Task and Rpc // interfaces. See `::mediapipe::TaskReturn` and `rpc::RpcSetStatus` for @@ -67,8 +67,8 @@ // // void Read(StringPiece name, ::mediapipe::Task* task) { // int64 id; -// RETURN_IF_ERROR(GetIdForName(name, &id)).With(TaskReturn(task)); -// RETURN_IF_ERROR(ReadForId(id)).With(TaskReturn(task)); +// MP_RETURN_IF_ERROR(GetIdForName(name, &id)).With(TaskReturn(task)); +// MP_RETURN_IF_ERROR(ReadForId(id)).With(TaskReturn(task)); // task->Return(); // } // @@ -77,11 +77,11 @@ // `::mediapipe::Status` type. E.g. // // []() -> ::mediapipe::Status { -// RETURN_IF_ERROR(Function(args...)); -// RETURN_IF_ERROR(foo.Method(args...)); +// MP_RETURN_IF_ERROR(Function(args...)); +// MP_RETURN_IF_ERROR(foo.Method(args...)); // return ::mediapipe::OkStatus(); // } -#define RETURN_IF_ERROR(expr) \ +#define MP_RETURN_IF_ERROR(expr) \ STATUS_MACROS_IMPL_ELSE_BLOCKER_ \ if (::mediapipe::status_macro_internal::StatusAdaptorForMacros \ status_macro_internal_adaptor = {(expr), __FILE__, __LINE__}) { \ @@ -124,7 +124,7 @@ // well as a `::mediapipe::StatusBuilder` object populated with the error and // named by a single underscore `_`. The expression typically uses the // builder to modify the status and is returned directly in manner similar -// to RETURN_IF_ERROR. The expression may, however, evaluate to any type +// to MP_RETURN_IF_ERROR. The expression may, however, evaluate to any type // returnable by the function, including (void). For example: // // Example: Adjusting the error message. @@ -175,7 +175,7 @@ // because it thinks you might want the else to bind to the first if. This // leads to problems with code like: // -// if (do_expr) RETURN_IF_ERROR(expr) << "Some message"; +// if (do_expr) MP_RETURN_IF_ERROR(expr) << "Some message"; // // The "switch (0) case 0:" idiom is used to suppress this. #define STATUS_MACROS_IMPL_ELSE_BLOCKER_ \ diff --git a/mediapipe/framework/deps/status_matchers.h b/mediapipe/framework/deps/status_matchers.h index 01255e231..179e321e7 100644 --- a/mediapipe/framework/deps/status_matchers.h +++ b/mediapipe/framework/deps/status_matchers.h @@ -18,11 +18,7 @@ #include "gtest/gtest.h" #include "mediapipe/framework/deps/status.h" -// EXPECT_OK marco is already defined in our external dependency library -// protobuf. To be consistent with MEDIAPIPE_EXPECT_OK, we also add prefix -// MEDIAPIPE_ to ASSERT_OK. We prefer to use the marcos with MEDIAPIPE_ prefix -// in mediapipe's codebase. -#define MEDIAPIPE_EXPECT_OK(statement) EXPECT_TRUE((statement).ok()) -#define MEDIAPIPE_ASSERT_OK(statement) ASSERT_TRUE((statement).ok()) +#define MP_EXPECT_OK(statement) EXPECT_TRUE((statement).ok()) +#define MP_ASSERT_OK(statement) ASSERT_TRUE((statement).ok()) #endif // MEDIAPIPE_DEPS_STATUS_MATCHERS_H_ diff --git a/mediapipe/framework/deps/status_test.cc b/mediapipe/framework/deps/status_test.cc index 59eeaa4e9..61dd88ecf 100644 --- a/mediapipe/framework/deps/status_test.cc +++ b/mediapipe/framework/deps/status_test.cc @@ -22,8 +22,8 @@ namespace mediapipe { TEST(Status, OK) { EXPECT_EQ(OkStatus().code(), ::mediapipe::StatusCode::kOk); EXPECT_EQ(OkStatus().error_message(), ""); - MEDIAPIPE_EXPECT_OK(OkStatus()); - MEDIAPIPE_ASSERT_OK(OkStatus()); + MP_EXPECT_OK(OkStatus()); + MP_ASSERT_OK(OkStatus()); EXPECT_EQ(OkStatus(), Status()); Status s; EXPECT_TRUE(s.ok()); diff --git a/mediapipe/framework/graph_output_stream.cc b/mediapipe/framework/graph_output_stream.cc index 1c94e1137..c50ed2ff6 100644 --- a/mediapipe/framework/graph_output_stream.cc +++ b/mediapipe/framework/graph_output_stream.cc @@ -33,9 +33,9 @@ namespace internal { /*calculator_run_in_parallel=*/false); const CollectionItemId& id = tag_map->BeginId(); input_stream_ = absl::make_unique(); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( input_stream_->Initialize(stream_name, packet_type, /*back_edge=*/false)); - RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers( + MP_RETURN_IF_ERROR(input_stream_handler_->InitializeInputStreamManagers( input_stream_.get())); output_stream_manager->AddMirror(input_stream_handler_.get(), id); return ::mediapipe::OkStatus(); @@ -74,7 +74,7 @@ void GraphOutputStream::PrepareForRun( RET_CHECK_EQ(num_packets_dropped, 0).SetNoLogging() << absl::Substitute("Dropped $0 packet(s) on input stream \"$1\".", num_packets_dropped, input_stream_->Name()); - RETURN_IF_ERROR(packet_callback_(packet)); + MP_RETURN_IF_ERROR(packet_callback_(packet)); } return ::mediapipe::OkStatus(); } @@ -83,8 +83,8 @@ void GraphOutputStream::PrepareForRun( const std::string& stream_name, const PacketType* packet_type, std::function queue_size_callback, OutputStreamManager* output_stream_manager) { - RETURN_IF_ERROR(GraphOutputStream::Initialize(stream_name, packet_type, - output_stream_manager)); + MP_RETURN_IF_ERROR(GraphOutputStream::Initialize(stream_name, packet_type, + output_stream_manager)); input_stream_handler_->SetQueueSizeCallbacks(queue_size_callback, queue_size_callback); return ::mediapipe::OkStatus(); diff --git a/mediapipe/framework/graph_service_test.cc b/mediapipe/framework/graph_service_test.cc index fbaaebefe..0cb79e933 100644 --- a/mediapipe/framework/graph_service_test.cc +++ b/mediapipe/framework/graph_service_test.cc @@ -56,8 +56,8 @@ class GraphServiceTest : public ::testing::Test { output_stream: "out" } )"); - MEDIAPIPE_ASSERT_OK(graph_.Initialize(config)); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK(graph_.Initialize(config)); + MP_ASSERT_OK( graph_.ObserveOutputStream("out", [this](const Packet& packet) { output_packets_.push_back(packet); return ::mediapipe::OkStatus(); @@ -72,26 +72,26 @@ TEST_F(GraphServiceTest, SetOnGraph) { EXPECT_EQ(graph_.GetServiceObject(kTestService).get(), nullptr); auto service_object = std::make_shared(TestServiceObject{{"delta", 3}}); - MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); + MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); EXPECT_EQ(graph_.GetServiceObject(kTestService), service_object); service_object = std::make_shared( TestServiceObject{{"delta", 5}, {"count", 0}}); - MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); + MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); EXPECT_EQ(graph_.GetServiceObject(kTestService), service_object); } TEST_F(GraphServiceTest, UseInCalculator) { auto service_object = std::make_shared( TestServiceObject{{"delta", 5}, {"count", 0}}); - MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); + MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK( graph_.AddPacketToInputStream("in", MakePacket(3).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); EXPECT_EQ(PacketValues(output_packets_), (std::vector{8})); EXPECT_EQ(1, (*service_object)["count"]); } @@ -104,8 +104,8 @@ TEST_F(GraphServiceTest, Contract) { output_stream: "out" )"); CalculatorContract contract; - MEDIAPIPE_EXPECT_OK(contract.Initialize(node)); - MEDIAPIPE_EXPECT_OK(TestServiceCalculator::GetContract(&contract)); + MP_EXPECT_OK(contract.Initialize(node)); + MP_EXPECT_OK(TestServiceCalculator::GetContract(&contract)); EXPECT_THAT( contract.ServiceRequests(), UnorderedElementsAre(Key(kTestService.key), Key(kAnotherService.key))); @@ -125,28 +125,28 @@ TEST_F(GraphServiceTest, OptionalIsOptional) { // Provide only required service. auto service_object = std::make_shared( TestServiceObject{{"delta", 5}, {"count", 0}}); - MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); + MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); - MEDIAPIPE_EXPECT_OK(graph_.StartRun({})); - MEDIAPIPE_ASSERT_OK( + MP_EXPECT_OK(graph_.StartRun({})); + MP_ASSERT_OK( graph_.AddPacketToInputStream("in", MakePacket(3).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); EXPECT_EQ(PacketValues(output_packets_), (std::vector{8})); } TEST_F(GraphServiceTest, OptionalIsAvailable) { auto service_object = std::make_shared( TestServiceObject{{"delta", 5}, {"count", 0}}); - MEDIAPIPE_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK(graph_.SetServiceObject(kTestService, service_object)); + MP_EXPECT_OK( graph_.SetServiceObject(kAnotherService, std::make_shared(100))); - MEDIAPIPE_EXPECT_OK(graph_.StartRun({})); - MEDIAPIPE_ASSERT_OK( + MP_EXPECT_OK(graph_.StartRun({})); + MP_ASSERT_OK( graph_.AddPacketToInputStream("in", MakePacket(3).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); EXPECT_EQ(PacketValues(output_packets_), (std::vector{108})); } diff --git a/mediapipe/framework/graph_validation_test.cc b/mediapipe/framework/graph_validation_test.cc index c3ffc8314..c67bf57df 100644 --- a/mediapipe/framework/graph_validation_test.cc +++ b/mediapipe/framework/graph_validation_test.cc @@ -59,10 +59,10 @@ TEST(ValidatedGraphConfigTest, InitializeGraphFromProtos) { )"); GraphValidation validation_1; - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( validation_1.Validate({config_1, config_2}, {}, {}, "PassThroughGraph")); CalculatorGraph graph_1; - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( graph_1.Initialize({config_1, config_2}, {}, {}, "PassThroughGraph")); EXPECT_THAT( graph_1.Config(), @@ -79,9 +79,9 @@ TEST(ValidatedGraphConfigTest, InitializeGraphFromProtos) { )"))); GraphValidation validation_2; - MEDIAPIPE_EXPECT_OK(validation_2.Validate({config_1, config_2}, {})); + MP_EXPECT_OK(validation_2.Validate({config_1, config_2}, {})); CalculatorGraph graph_2; - MEDIAPIPE_EXPECT_OK(graph_2.Initialize({config_1, config_2}, {})); + MP_EXPECT_OK(graph_2.Initialize({config_1, config_2}, {})); EXPECT_THAT( graph_2.Config(), EqualsProto(::mediapipe::ParseTextProtoOrDie(R"( @@ -164,11 +164,11 @@ TEST(ValidatedGraphConfigTest, InitializeTemplateFromProtos) { })"); GraphValidation validation_1; - MEDIAPIPE_EXPECT_OK(validation_1.Validate({config_2}, {config_1}, {}, - "PassThroughGraph", &options)); + MP_EXPECT_OK(validation_1.Validate({config_2}, {config_1}, {}, + "PassThroughGraph", &options)); CalculatorGraph graph_1; - MEDIAPIPE_EXPECT_OK(graph_1.Initialize({config_2}, {config_1}, {}, - "PassThroughGraph", &options)); + MP_EXPECT_OK(graph_1.Initialize({config_2}, {config_1}, {}, + "PassThroughGraph", &options)); EXPECT_THAT( graph_1.Config(), EqualsProto(::mediapipe::ParseTextProtoOrDie(R"( @@ -185,9 +185,9 @@ TEST(ValidatedGraphConfigTest, InitializeTemplateFromProtos) { )"))); GraphValidation validation_2; - MEDIAPIPE_EXPECT_OK(validation_2.Validate({config_2}, {config_1})); + MP_EXPECT_OK(validation_2.Validate({config_2}, {config_1})); CalculatorGraph graph_2; - MEDIAPIPE_EXPECT_OK(graph_2.Initialize({config_2}, {config_1})); + MP_EXPECT_OK(graph_2.Initialize({config_2}, {config_1})); EXPECT_THAT( graph_2.Config(), EqualsProto(::mediapipe::ParseTextProtoOrDie(R"( diff --git a/mediapipe/framework/input_stream_manager_test.cc b/mediapipe/framework/input_stream_manager_test.cc index ddc3e1a4d..141619a44 100644 --- a/mediapipe/framework/input_stream_manager_test.cc +++ b/mediapipe/framework/input_stream_manager_test.cc @@ -42,9 +42,8 @@ class InputStreamManagerTest : public ::testing::Test { packet_type_.Set(); input_stream_manager_ = absl::make_unique(); - MEDIAPIPE_ASSERT_OK(input_stream_manager_->Initialize("a_test", - &packet_type_, - /*back_edge=*/false)); + MP_ASSERT_OK(input_stream_manager_->Initialize("a_test", &packet_type_, + /*back_edge=*/false)); queue_full_callback_ = std::bind(&InputStreamManagerTest::ReportQueueBecomesFull, this, @@ -99,7 +98,7 @@ TEST_F(InputStreamManagerTest, AddPackets) { packets.push_back(MakePacket("packet 3").At(Timestamp(30))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_TRUE(notify_); EXPECT_FALSE(input_stream_manager_->IsEmpty()); @@ -116,7 +115,7 @@ TEST_F(InputStreamManagerTest, MovePackets) { packets.push_back(MakePacket("packet 3").At(Timestamp(30))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->MovePackets(&packets, ¬ify_)); // Notification EXPECT_TRUE(notify_); EXPECT_FALSE(input_stream_manager_->IsEmpty()); @@ -182,7 +181,7 @@ TEST_F(InputStreamManagerTest, AddPacketsOnlyPreStream) { MakePacket("packet 1").At(Timestamp::PreStream())); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -210,7 +209,7 @@ TEST_F(InputStreamManagerTest, AddPacketsOnlyPostStream) { MakePacket("packet 1").At(Timestamp::PostStream())); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -260,7 +259,7 @@ TEST_F(InputStreamManagerTest, PopPacketAtTimestamp) { EXPECT_TRUE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(input_stream_manager_->QueueHead().IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -319,8 +318,8 @@ TEST_F(InputStreamManagerTest, PopPacketAtTimestamp) { num_packets_dropped_ = 0; popped_packet_ = Packet(); stream_is_done_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( - Timestamp::Done(), ¬ify_)); + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(Timestamp::Done(), + ¬ify_)); EXPECT_TRUE(notify_); popped_packet_ = input_stream_manager_->PopPacketAtTimestamp( Timestamp(40), &num_packets_dropped_, &stream_is_done_); @@ -344,7 +343,7 @@ TEST_F(InputStreamManagerTest, PopQueueHead) { MakePacket(expected_value_at_30).At(Timestamp(30))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(input_stream_manager_->QueueHead().IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_TRUE(notify_); EXPECT_FALSE(input_stream_manager_->IsEmpty()); @@ -385,8 +384,8 @@ TEST_F(InputStreamManagerTest, PopQueueHead) { num_packets_dropped_ = 0; popped_packet_ = Packet(); stream_is_done_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( - Timestamp::Done(), ¬ify_)); + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound(Timestamp::Done(), + ¬ify_)); EXPECT_TRUE(notify_); popped_packet_ = input_stream_manager_->PopQueueHead(&stream_is_done_); EXPECT_TRUE(popped_packet_.IsEmpty()); @@ -412,7 +411,7 @@ TEST_F(InputStreamManagerTest, Close) { packets.push_back(MakePacket("packet 3").At(Timestamp(30))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -436,7 +435,7 @@ TEST_F(InputStreamManagerTest, ReuseInputStreamManager) { EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -465,7 +464,7 @@ TEST_F(InputStreamManagerTest, ReuseInputStreamManager) { packets.push_back(MakePacket("packet 3").At(Timestamp(30))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -487,7 +486,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) { packets.push_back(MakePacket("packet 2").At(Timestamp(20))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -495,7 +494,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) { notify_ = false; packets.clear(); packets.push_back(MakePacket("packet 3").At(Timestamp(30))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // No notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); // Notification isn't triggered since the queue is already non-empty. @@ -511,7 +510,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) { packets.clear(); packets.push_back(MakePacket("packet 4").At(Timestamp(60))); packets.push_back(MakePacket("packet 5").At(Timestamp(70))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -519,7 +518,7 @@ TEST_F(InputStreamManagerTest, MultipleNotifications) { TEST_F(InputStreamManagerTest, SetHeader) { Packet header = MakePacket("blah"); - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetHeader(header)); + MP_ASSERT_OK(input_stream_manager_->SetHeader(header)); EXPECT_EQ(header.Get(), input_stream_manager_->Header().Get()); @@ -532,13 +531,13 @@ TEST_F(InputStreamManagerTest, BackwardsInTime) { packets.push_back(MakePacket("packet 2").At(Timestamp(20))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(50), ¬ify_)); // No notification // The queue is already non-empty. EXPECT_FALSE(notify_); @@ -572,7 +571,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTime) { popped_packet_ = Packet(); packets.clear(); packets.push_back(MakePacket("packet 4").At(Timestamp(110))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -599,7 +598,7 @@ TEST_F(InputStreamManagerTest, SelectBackwardsInTime) { packets.push_back(MakePacket("packet 2").At(Timestamp(20))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -643,7 +642,7 @@ TEST_F(InputStreamManagerTest, TimestampBound) { packets.push_back(MakePacket("packet 2").At(Timestamp(20))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -652,19 +651,19 @@ TEST_F(InputStreamManagerTest, TimestampBound) { EXPECT_EQ(Timestamp(10), input_stream_manager_->MinTimestampOrBound(&is_empty)); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(30), ¬ify_)); // No notification. EXPECT_FALSE(notify_); EXPECT_EQ(Timestamp(10), input_stream_manager_->MinTimestampOrBound(&is_empty)); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(40), ¬ify_)); // No notification. EXPECT_FALSE(notify_); EXPECT_EQ(Timestamp(10), input_stream_manager_->MinTimestampOrBound(&is_empty)); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(50), ¬ify_)); // No notification. EXPECT_FALSE(notify_); @@ -701,19 +700,19 @@ TEST_F(InputStreamManagerTest, TimestampBound) { // TODO These notifications may be bad if they schedule a // Calculator Process() call at times that are irrelevant. notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(60), ¬ify_)); // Notification. EXPECT_TRUE(notify_); EXPECT_EQ(Timestamp(60), input_stream_manager_->MinTimestampOrBound(&is_empty)); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(70), ¬ify_)); // Notification. EXPECT_TRUE(notify_); EXPECT_EQ(Timestamp(70), input_stream_manager_->MinTimestampOrBound(&is_empty)); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(80), ¬ify_)); // Notification. EXPECT_TRUE(notify_); EXPECT_EQ(Timestamp(80), @@ -722,7 +721,7 @@ TEST_F(InputStreamManagerTest, TimestampBound) { notify_ = false; packets.clear(); packets.push_back(MakePacket("packet 3").At(Timestamp(90))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_TRUE(notify_); @@ -756,7 +755,7 @@ TEST_F(InputStreamManagerTest, QueueSizeTest) { packets.push_back(MakePacket("packet 3").At(Timestamp(30))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -773,7 +772,7 @@ TEST_F(InputStreamManagerTest, QueueSizeTest) { packets.push_back(MakePacket("packet 4").At(Timestamp(60))); packets.push_back(MakePacket("packet 5").At(Timestamp(70))); notify_ = false; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -785,8 +784,8 @@ TEST_F(InputStreamManagerTest, QueueSizeTest) { TEST_F(InputStreamManagerTest, InputReleaseTest) { packet_type_.Set(); input_stream_manager_ = absl::make_unique(); - MEDIAPIPE_ASSERT_OK(input_stream_manager_->Initialize("a_test", &packet_type_, - /*back_edge=*/false)); + MP_ASSERT_OK(input_stream_manager_->Initialize("a_test", &packet_type_, + /*back_edge=*/false)); input_stream_manager_->PrepareForRun(); input_stream_manager_->SetQueueSizeCallbacks(queue_full_callback_, queue_not_full_callback_); @@ -798,12 +797,9 @@ TEST_F(InputStreamManagerTest, InputReleaseTest) { }; input_stream_manager_->SetMaxQueueSize(3); - MEDIAPIPE_ASSERT_OK( - input_stream_manager_->AddPackets({new_packet()}, ¬ify_)); - MEDIAPIPE_ASSERT_OK( - input_stream_manager_->AddPackets({new_packet()}, ¬ify_)); - MEDIAPIPE_ASSERT_OK( - input_stream_manager_->AddPackets({new_packet()}, ¬ify_)); + MP_ASSERT_OK(input_stream_manager_->AddPackets({new_packet()}, ¬ify_)); + MP_ASSERT_OK(input_stream_manager_->AddPackets({new_packet()}, ¬ify_)); + MP_ASSERT_OK(input_stream_manager_->AddPackets({new_packet()}, ¬ify_)); EXPECT_EQ(3, tracker.live_count()); popped_packet_ = input_stream_manager_->PopPacketAtTimestamp( @@ -843,7 +839,7 @@ TEST_F(InputStreamManagerTest, AddPacketsAfterPreStreamUntimed) { packets.push_back(MakePacket("packet 2").At(Timestamp(10))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -859,7 +855,7 @@ TEST_F(InputStreamManagerTest, AddPacketsBeforePostStreamUntimed) { MakePacket("packet 2").At(Timestamp::PostStream())); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); @@ -872,18 +868,18 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) { packets.push_back(MakePacket("packet 2").At(Timestamp(20))); EXPECT_TRUE(input_stream_manager_->IsEmpty()); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_FALSE(input_stream_manager_->IsEmpty()); EXPECT_TRUE(notify_); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(50), ¬ify_)); // No notification EXPECT_FALSE(notify_); notify_ = false; - MEDIAPIPE_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( + MP_ASSERT_OK(input_stream_manager_->SetNextTimestampBound( Timestamp(40), ¬ify_)); // Set Timestamp bound backwards in time EXPECT_FALSE(notify_); @@ -891,7 +887,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) { packets.push_back(MakePacket("packet 3") .At(Timestamp(30))); // Backwards in time notify_ = false; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // No notification // Notification isn't triggered since the queue is already non-empty. EXPECT_FALSE(notify_); @@ -909,7 +905,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) { packets.push_back(MakePacket("packet 4").At(Timestamp(110))); notify_ = false; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_TRUE(notify_); @@ -921,7 +917,7 @@ TEST_F(InputStreamManagerTest, BackwardsInTimeUntimed) { .At(Timestamp(130))); // Backwards in time notify_ = false; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( input_stream_manager_->AddPackets(packets, ¬ify_)); // Notification EXPECT_TRUE(notify_); } diff --git a/mediapipe/framework/output_stream_manager_test.cc b/mediapipe/framework/output_stream_manager_test.cc index 41cb2b39b..e0f47f078 100644 --- a/mediapipe/framework/output_stream_manager_test.cc +++ b/mediapipe/framework/output_stream_manager_test.cc @@ -53,8 +53,7 @@ class OutputStreamManagerTest : public ::testing::Test { std::placeholders::_1, std::placeholders::_2); output_stream_manager_ = absl::make_unique(); - MEDIAPIPE_ASSERT_OK( - output_stream_manager_->Initialize("a_test", &packet_type_)); + MP_ASSERT_OK(output_stream_manager_->Initialize("a_test", &packet_type_)); output_stream_manager_->PrepareForRun(error_callback_); output_stream_shard_.SetSpec(output_stream_manager_->Spec()); output_stream_manager_->ResetShard(&output_stream_shard_); @@ -68,10 +67,9 @@ class OutputStreamManagerTest : public ::testing::Test { input_stream_handler_ = std::move(status_or_handler.ValueOrDie()); const CollectionItemId& id = tag_map->BeginId(); - MEDIAPIPE_ASSERT_OK(input_stream_manager_.Initialize("a_test", - &packet_type_, - /*back_edge=*/false)); - MEDIAPIPE_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers( + MP_ASSERT_OK(input_stream_manager_.Initialize("a_test", &packet_type_, + /*back_edge=*/false)); + MP_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers( &input_stream_manager_)); output_stream_manager_->AddMirror(input_stream_handler_.get(), id); input_stream_handler_->PrepareForRun(headers_ready_callback_, @@ -695,7 +693,7 @@ TEST_F(OutputStreamManagerTest, AddPacketAndMovePacket) { output_stream_shard_.AddPacket(packet_1); // packet_1 has an extra copy in the output stream. ASSERT_FALSE(packet_1.IsEmpty()); - MEDIAPIPE_ASSERT_OK(packet_1.ValidateAsType()); + MP_ASSERT_OK(packet_1.ValidateAsType()); EXPECT_EQ("packet 1", packet_1.Get()); Packet packet_2 = MakePacket("packet 2").At(Timestamp(20)); diff --git a/mediapipe/framework/packet.h b/mediapipe/framework/packet.h index 048e2d2d8..8782d924c 100644 --- a/mediapipe/framework/packet.h +++ b/mediapipe/framework/packet.h @@ -130,7 +130,7 @@ class Packet { // // use an adaptor which returns void. // ASSIGN_OR_RETURN(auto detection, p.ConsumeOrCopy(), // _.With([](const ::mediapipe::Status& status) { - // EXPECT_OK(status); + // MP_EXPECT_OK(status); // // Use CHECK_OK to crash and report a usable line // // number (which the ValueOrDie alternative does not). // // Include a return statement if the return value is @@ -495,7 +495,7 @@ inline Packet& Packet::operator=(const Packet& packet) { template inline ::mediapipe::StatusOr> Packet::Consume() { // If type validation fails, returns error. - RETURN_IF_ERROR(ValidateAsType()); + MP_RETURN_IF_ERROR(ValidateAsType()); // Clients who use this function are responsible for ensuring that no // other thread is doing anything with this Packet. if (holder_.unique()) { @@ -518,7 +518,7 @@ template inline ::mediapipe::StatusOr> Packet::ConsumeOrCopy( bool* was_copied, typename std::enable_if::value>::type*) { - RETURN_IF_ERROR(ValidateAsType()); + MP_RETURN_IF_ERROR(ValidateAsType()); // If holder is the sole owner of the underlying data, consumes this packet. if (!holder_->HolderIsOfType>() && holder_.unique()) { @@ -549,7 +549,7 @@ inline ::mediapipe::StatusOr> Packet::ConsumeOrCopy( bool* was_copied, typename std::enable_if::value && std::extent::value != 0>::type*) { - RETURN_IF_ERROR(ValidateAsType()); + MP_RETURN_IF_ERROR(ValidateAsType()); // If holder is the sole owner of the underlying data, consumes this packet. if (!holder_->HolderIsOfType>() && holder_.unique()) { diff --git a/mediapipe/framework/packet_generator_graph.cc b/mediapipe/framework/packet_generator_graph.cc index aac131ac9..ad9111908 100644 --- a/mediapipe/framework/packet_generator_graph.cc +++ b/mediapipe/framework/packet_generator_graph.cc @@ -102,14 +102,14 @@ namespace { internal::StaticAccessToGeneratorRegistry::CreateByNameInNamespace( validated_graph.Package(), generator_name), _ << generator_name << " is not a valid PacketGenerator."); - RETURN_IF_ERROR(static_access->Generate(generator_config.options(), - input_side_packet_set, - output_side_packet_set)) + MP_RETURN_IF_ERROR(static_access->Generate(generator_config.options(), + input_side_packet_set, + output_side_packet_set)) .SetPrepend() << generator_name << "::Generate() failed. "; - RETURN_IF_ERROR(ValidatePacketSet(node_type_info.OutputSidePacketTypes(), - *output_side_packet_set)) + MP_RETURN_IF_ERROR(ValidatePacketSet(node_type_info.OutputSidePacketTypes(), + *output_side_packet_set)) .SetPrepend() << generator_name << "::Generate() output packets were of incorrect type: "; @@ -364,7 +364,8 @@ PacketGeneratorGraph::~PacketGeneratorGraph() {} validated_graph_ = validated_graph; executor_ = executor; base_packets_ = input_side_packets; - RETURN_IF_ERROR(validated_graph_->CanAcceptSidePackets(input_side_packets)); + MP_RETURN_IF_ERROR( + validated_graph_->CanAcceptSidePackets(input_side_packets)); return ExecuteGenerators(&base_packets_, &non_base_generators_, /*initial=*/true); } @@ -383,12 +384,13 @@ PacketGeneratorGraph::~PacketGeneratorGraph() {} } std::vector non_scheduled_generators; - RETURN_IF_ERROR(validated_graph_->CanAcceptSidePackets(input_side_packets)); + MP_RETURN_IF_ERROR( + validated_graph_->CanAcceptSidePackets(input_side_packets)); // This type check on the required side packets is redundant with // error checking in ExecuteGenerators, but we do it now to fail early. - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( validated_graph_->ValidateRequiredSidePackets(*output_side_packets)); - RETURN_IF_ERROR(ExecuteGenerators( + MP_RETURN_IF_ERROR(ExecuteGenerators( output_side_packets, &non_scheduled_generators, /*initial=*/false)); RET_CHECK(non_scheduled_generators.empty()) << "Some Generators were unrunnable (validation should have failed).\n" diff --git a/mediapipe/framework/packet_generator_test.cc b/mediapipe/framework/packet_generator_test.cc index 477d85618..f56e892d3 100644 --- a/mediapipe/framework/packet_generator_test.cc +++ b/mediapipe/framework/packet_generator_test.cc @@ -62,7 +62,7 @@ TEST(PacketGeneratorTest, FillExpectationsOnConfig) { config.add_input_side_packet("of_inputs"); config.add_output_side_packet("any_number_of"); config.add_output_side_packet("output_side_packets"); - MEDIAPIPE_EXPECT_OK(tool::RunGeneratorFillExpectations(config)); + MP_EXPECT_OK(tool::RunGeneratorFillExpectations(config)); } } // namespace diff --git a/mediapipe/framework/packet_test.cc b/mediapipe/framework/packet_test.cc index ec35207cb..2282f0303 100644 --- a/mediapipe/framework/packet_test.cc +++ b/mediapipe/framework/packet_test.cc @@ -86,7 +86,7 @@ TEST(PacketTest, UsesLvalueAndRvalueReferencePacketAtFunctions) { // with the given timestamp. EXPECT_TRUE(packet1.IsEmpty()); // NOLINT used after std::move(). ASSERT_FALSE(packet2.IsEmpty()); - MEDIAPIPE_ASSERT_OK(packet2.ValidateAsType()); + MP_ASSERT_OK(packet2.ValidateAsType()); EXPECT_EQ(0, packet2.Get()); EXPECT_EQ(Timestamp(100), packet2.Timestamp()); @@ -97,8 +97,8 @@ TEST(PacketTest, UsesLvalueAndRvalueReferencePacketAtFunctions) { // has the given timestamp. ASSERT_FALSE(packet3.IsEmpty()); ASSERT_FALSE(packet4.IsEmpty()); - MEDIAPIPE_ASSERT_OK(packet3.ValidateAsType()); - MEDIAPIPE_ASSERT_OK(packet4.ValidateAsType()); + MP_ASSERT_OK(packet3.ValidateAsType()); + MP_ASSERT_OK(packet4.ValidateAsType()); EXPECT_EQ(1, packet3.Get()); EXPECT_EQ(1, packet4.Get()); EXPECT_EQ(Timestamp(), packet3.Timestamp()); @@ -111,7 +111,7 @@ TEST(PacketTest, HandlesUniquePtr) { {AdoptAsUniquePtr(static_cast(new MyClass)), AdoptAsUniquePtr(new MyClass), Adopt(new std::unique_ptr(new MyClass))}) { - MEDIAPIPE_EXPECT_OK(packet.ValidateAsType>()); + MP_EXPECT_OK(packet.ValidateAsType>()); } bool exists = false; Packet packet = AdoptAsUniquePtr(new MyClass(&exists)); @@ -192,7 +192,7 @@ TEST(PacketTest, ValidateAsProtoMessageLite) { auto proto_ptr = absl::make_unique<::mediapipe::PacketTestProto>(); proto_ptr->add_x(123); Packet packet = Adopt(proto_ptr.release()); - MEDIAPIPE_EXPECT_OK(packet.ValidateAsProtoMessageLite()); + MP_EXPECT_OK(packet.ValidateAsProtoMessageLite()); Packet packet2 = MakePacket(3); ::mediapipe::Status status = packet2.ValidateAsProtoMessageLite(); EXPECT_EQ(status.code(), ::mediapipe::StatusCode::kInvalidArgument); diff --git a/mediapipe/framework/profiler/BUILD b/mediapipe/framework/profiler/BUILD index 23bc99fba..634c36845 100644 --- a/mediapipe/framework/profiler/BUILD +++ b/mediapipe/framework/profiler/BUILD @@ -277,7 +277,6 @@ cc_library( copts = select({ "//conditions:default": [], "//mediapipe:apple": [ - "-std=c++11", "-ObjC++", ], "//mediapipe:macos": [], diff --git a/mediapipe/framework/profiler/graph_profiler.cc b/mediapipe/framework/profiler/graph_profiler.cc index f404d2872..46b009731 100644 --- a/mediapipe/framework/profiler/graph_profiler.cc +++ b/mediapipe/framework/profiler/graph_profiler.cc @@ -224,7 +224,7 @@ void GraphProfiler::Reset() { Pause(); // If specified, write a final profile. if (IsTraceLogEnabled(profiler_config_)) { - RETURN_IF_ERROR(WriteProfile()); + MP_RETURN_IF_ERROR(WriteProfile()); } return ::mediapipe::OkStatus(); } diff --git a/mediapipe/framework/profiler/graph_profiler_test.cc b/mediapipe/framework/profiler/graph_profiler_test.cc index d6107a74c..cf7717556 100644 --- a/mediapipe/framework/profiler/graph_profiler_test.cc +++ b/mediapipe/framework/profiler/graph_profiler_test.cc @@ -204,7 +204,7 @@ class GraphProfilerTestPeer : public testing::Test { std::vector Profiles() { std::vector result; - MEDIAPIPE_EXPECT_OK(profiler_.GetCalculatorProfiles(&result)); + MP_EXPECT_OK(profiler_.GetCalculatorProfiles(&result)); return result; } @@ -1078,28 +1078,28 @@ TEST(GraphProfilerTest, ParallelReads) { absl::Mutex out_1_mutex; std::vector out_1_packets; CalculatorGraph graph; - ASSERT_OK(graph.Initialize(config)); - ASSERT_OK(graph.ObserveOutputStream("out_1", [&](const Packet& packet) { + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.ObserveOutputStream("out_1", [&](const Packet& packet) { absl::MutexLock lock(&out_1_mutex); out_1_packets.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_EXPECT_OK(graph.StartRun( + MP_EXPECT_OK(graph.StartRun( {{"range_step", MakePacket>(1000, 1)}})); // Repeatedly poll for profile data while the graph runs. while (true) { std::vector profiles; - ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles)); + MP_ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles)); EXPECT_EQ(2, profiles.size()); absl::MutexLock lock(&out_1_mutex); if (out_1_packets.size() >= 1001) { break; } } - ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); std::vector profiles; - ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles)); + MP_ASSERT_OK(graph.profiler()->GetCalculatorProfiles(&profiles)); // GraphProfiler internally uses map and the profile order is not fixed. if (profiles[0].name() == "RangeCalculator") { EXPECT_EQ(1000, profiles[0].process_runtime().count(0)); diff --git a/mediapipe/framework/profiler/graph_tracer_test.cc b/mediapipe/framework/profiler/graph_tracer_test.cc index 89b021bba..ea82f3cb3 100644 --- a/mediapipe/framework/profiler/graph_tracer_test.cc +++ b/mediapipe/framework/profiler/graph_tracer_test.cc @@ -413,7 +413,7 @@ class GraphTracerE2ETest : public ::testing::Test { simulation_clock_->ThreadStart(); clock_->SleepUntil(StartTime()); simulation_clock_->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.SetExecutor("", executor)); + MP_ASSERT_OK(graph_.SetExecutor("", executor)); } void SetUpRealClock() { clock_ = ::mediapipe::Clock::RealClock(); } @@ -490,31 +490,30 @@ class GraphTracerE2ETest : public ::testing::Test { }; // Start the graph with the callbacks. - MEDIAPIPE_ASSERT_OK(graph_.Initialize( - graph_config_, { - {"callback_0", Adopt(new auto(wait_0))}, - })); + MP_ASSERT_OK(graph_.Initialize(graph_config_, + { + {"callback_0", Adopt(new auto(wait_0))}, + })); graph_.profiler()->SetClock(simulation_clock_); std::vector out_packets; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph_.ObserveOutputStream("output_0", [&](const Packet& packet) { out_packets.push_back(packet); return ::mediapipe::OkStatus(); })); simulation_clock_->ThreadStart(); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK(graph_.StartRun({})); // The first 6 packets to send into the graph at 5001 us intervals. for (int ts = 10000; ts < 70000; ts += 10000) { clock_->Sleep(absl::Microseconds(5001)); - MEDIAPIPE_EXPECT_OK( - graph_.AddPacketToInputStream("input_0", PacketAt(ts))); + MP_EXPECT_OK(graph_.AddPacketToInputStream("input_0", PacketAt(ts))); } // Wait for all packets to be processed. - MEDIAPIPE_ASSERT_OK(graph_.CloseAllPacketSources()); + MP_ASSERT_OK(graph_.CloseAllPacketSources()); clock_->Sleep(absl::Microseconds(240000 + 0)); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.WaitUntilDone()); simulation_clock_->ThreadFinish(); // Validate the graph run. @@ -557,26 +556,26 @@ class GraphTracerE2ETest : public ::testing::Test { } // Start the graph with the callbacks. - MEDIAPIPE_ASSERT_OK(graph_.Initialize( - graph_config_, { - {"max_in_flight", MakePacket(4)}, - {"callback_0", Adopt(new auto(wait_0))}, - {"callback_1", Adopt(new auto(wait_1))}, - {"callback_2", Adopt(new auto(wait_2))}, - })); + MP_ASSERT_OK(graph_.Initialize(graph_config_, + { + {"max_in_flight", MakePacket(4)}, + {"callback_0", Adopt(new auto(wait_0))}, + {"callback_1", Adopt(new auto(wait_1))}, + {"callback_2", Adopt(new auto(wait_2))}, + })); graph_.profiler()->SetClock(simulation_clock_); std::vector out_packets; - MEDIAPIPE_ASSERT_OK(graph_.ObserveOutputStream( - "output_packets_0", [&](const Packet& packet) { - out_packets.push_back(packet); - return ::mediapipe::OkStatus(); - })); + MP_ASSERT_OK(graph_.ObserveOutputStream("output_packets_0", + [&](const Packet& packet) { + out_packets.push_back(packet); + return ::mediapipe::OkStatus(); + })); simulation_clock_->ThreadStart(); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK(graph_.StartRun({})); // Wait for all packets to be added and processed. clock_->Sleep(absl::Microseconds(160000 + 0)); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.WaitUntilDone()); simulation_clock_->ThreadFinish(); // Validate the graph run. @@ -614,7 +613,7 @@ TEST_F(GraphTracerE2ETest, PassThroughGraphProfile) { graph_config_.mutable_profiler_config()->set_trace_log_disabled(true); RunPassThroughGraph(); std::vector profiles; - MEDIAPIPE_EXPECT_OK(graph_.profiler()->GetCalculatorProfiles(&profiles)); + MP_EXPECT_OK(graph_.profiler()->GetCalculatorProfiles(&profiles)); EXPECT_EQ(1, profiles.size()); CalculatorProfile expected = ::mediapipe::ParseTextProtoOrDie(R"( @@ -930,7 +929,7 @@ TEST_F(GraphTracerE2ETest, DemuxGraphLogFile) { graph_config_.mutable_profiler_config()->set_trace_log_interval_usec(-1); RunDemuxInFlightGraph(); GraphProfile profile; - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( ReadGraphProfile(absl::StrCat(log_path, 0, ".binarypb"), &profile)); EXPECT_EQ(89, profile.graph_trace(0).calculator_trace().size()); } @@ -1143,7 +1142,7 @@ TEST_F(GraphTracerE2ETest, LoggingHappensWithDefaultPath) { SetUpDemuxInFlightGraph(); graph_config_.mutable_profiler_config()->set_trace_log_disabled(false); RunDemuxInFlightGraph(); - MEDIAPIPE_EXPECT_OK(mediapipe::file::Exists(log_path)); + MP_EXPECT_OK(mediapipe::file::Exists(log_path)); } TEST_F(GraphTracerE2ETest, GpuTaskTrace) { @@ -1279,7 +1278,7 @@ TEST_F(GraphTracerE2ETest, GpuTracing) { &graph_config_)); // Create the CalculatorGraph with only trace_enabled set. - MEDIAPIPE_ASSERT_OK(graph_.Initialize(graph_config_, {})); + MP_ASSERT_OK(graph_.Initialize(graph_config_, {})); // Check that GPU profiling is enabled wihout running the graph. // This graph with GlFlatColorCalculator cannot run on desktop. EXPECT_NE(nullptr, graph_.profiler()->CreateGlProfilingHelper()); diff --git a/mediapipe/framework/stream_handler/BUILD b/mediapipe/framework/stream_handler/BUILD index f22c54fe9..9dacd4d60 100644 --- a/mediapipe/framework/stream_handler/BUILD +++ b/mediapipe/framework/stream_handler/BUILD @@ -54,7 +54,7 @@ mediapipe_cc_proto_library( name = "default_input_stream_handler_cc_proto", srcs = ["default_input_stream_handler.proto"], cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":default_input_stream_handler_proto"], ) @@ -62,7 +62,7 @@ mediapipe_cc_proto_library( name = "fixed_size_input_stream_handler_cc_proto", srcs = ["fixed_size_input_stream_handler.proto"], cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":fixed_size_input_stream_handler_proto"], ) @@ -70,7 +70,7 @@ mediapipe_cc_proto_library( name = "sync_set_input_stream_handler_cc_proto", srcs = ["sync_set_input_stream_handler.proto"], cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":sync_set_input_stream_handler_proto"], ) @@ -78,7 +78,7 @@ mediapipe_cc_proto_library( name = "timestamp_align_input_stream_handler_cc_proto", srcs = ["timestamp_align_input_stream_handler.proto"], cc_deps = ["//mediapipe/framework:mediapipe_options_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":timestamp_align_input_stream_handler_proto"], ) diff --git a/mediapipe/framework/stream_handler/barrier_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/barrier_input_stream_handler_test.cc index da5c6ea1f..a0881b04f 100644 --- a/mediapipe/framework/stream_handler/barrier_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/barrier_input_stream_handler_test.cc @@ -66,7 +66,7 @@ class BarrierInputStreamHandlerTest : public ::testing::Test { id < input_tag_map->EndId(); ++id) { const std::string& stream_name = names[id.value()]; name_to_id_[stream_name] = id; - MEDIAPIPE_ASSERT_OK(input_stream_managers_[id.value()].Initialize( + MP_ASSERT_OK(input_stream_managers_[id.value()].Initialize( stream_name, &packet_type_, /*back_edge=*/false)); } SetupInputStreamHandler(input_tag_map); @@ -89,9 +89,9 @@ class BarrierInputStreamHandlerTest : public ::testing::Test { /*calculator_run_in_parallel=*/false); ASSERT_TRUE(status_or_handler.ok()); input_stream_handler_ = std::move(status_or_handler.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers( + MP_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers( input_stream_managers_.get())); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( calculator_context_manager_.PrepareForRun(setup_shards_callback_)); input_stream_handler_->PrepareForRun(headers_ready_callback_, notification_callback_, diff --git a/mediapipe/framework/stream_handler/default_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/default_input_stream_handler_test.cc index 1705cac28..b41ccb356 100644 --- a/mediapipe/framework/stream_handler/default_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/default_input_stream_handler_test.cc @@ -53,34 +53,34 @@ TEST(DefaultInputStreamHandlerTest, NoBatchingWorks) { tool::AddVectorSink("output1", &config, &sink_1); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(1)).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // No packets expected as the second stream is not ready to be processed. EXPECT_EQ(0, sink_0.size()); EXPECT_EQ(0, sink_1.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input1", Adopt(new int(2)).At(Timestamp(2)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // First stream can produce output because the timestamp bound of the second // stream is higher. EXPECT_EQ(1, sink_0.size()); EXPECT_EQ(0, sink_1.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(2)).At(Timestamp(2)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Both streams have packets at the same timestamp, therefore both can produce // packets. EXPECT_EQ(2, sink_0.size()); EXPECT_EQ(1, sink_1.size()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); } // This test shows the effect of batching on the DefaultInputStreamHandler. @@ -107,43 +107,43 @@ TEST(DefaultInputStreamHandlerTest, Batches) { tool::AddVectorSink("output0", &config, &sink); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(1)).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // There shouldn't be any outputs until a set of two packets is batched. EXPECT_TRUE(sink.empty()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(2)).At(Timestamp(2)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // There should be two packets, processed during a single invocation. ASSERT_EQ(2, sink.size()); EXPECT_THAT(std::vector({sink[0].Get(), sink[1].Get()}), testing::ElementsAre(1, 2)); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(3)).At(Timestamp(3)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // There shouldn't be any outputs until another set of two packets is batched. EXPECT_EQ(2, sink.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(4)).At(Timestamp(4)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // The new batch was complete. There should be two more output packets. ASSERT_EQ(4, sink.size()); EXPECT_THAT(std::vector({sink[0].Get(), sink[1].Get(), sink[2].Get(), sink[3].Get()}), testing::ElementsAre(1, 2, 3, 4)); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); } // This test shows that any packets get flushed (outputted) when the input @@ -171,32 +171,32 @@ TEST(DefaultInputStreamHandlerTest, BatchIsFlushedWhenClosing) { tool::AddVectorSink("output0", &config, &sink); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(1)).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // There shouldn't be any outputs until a set of two packets is batched. EXPECT_TRUE(sink.empty()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(2)).At(Timestamp(2)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // There should be two packets, processed during a single invocation. ASSERT_EQ(2, sink.size()); EXPECT_THAT(std::vector({sink[0].Get(), sink[1].Get()}), testing::ElementsAre(1, 2)); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(3)).At(Timestamp(3)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // There shouldn't be any outputs until another set of two packets is batched. EXPECT_EQ(2, sink.size()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); // When the streams are done, the packets currently being batched should be // flushed out. @@ -237,45 +237,45 @@ TEST(DefaultInputStreamHandlerTest, DoesntPropagateTimestampWhenBatching) { std::vector sink; tool::AddVectorSink("output", &config, &sink); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(0)).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_TRUE(sink.empty()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(1)).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input1", Adopt(new int(1)).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Both calculators have packet 1. First node is currently batching and it // propagates the first input timestamp in the batch. Therefore, the // second node should produce output for the packet at 0. EXPECT_EQ(1, sink.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(2)).At(Timestamp(2)))); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input1", Adopt(new int(2)).At(Timestamp(2)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Due to batching on the first node, timestamp is not propagated for the // packet at timestamp 2. Therefore, the second node cannot process the packet // at timestamp 1. EXPECT_EQ(1, sink.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input0", Adopt(new int(3)).At(Timestamp(3)))); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input1", Adopt(new int(3)).At(Timestamp(3)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Batching is complete on the first node. It produced outputs at timestamp 1, // 2, and 3. The first node can now process the input packets at timestamps 1, // 2, and 3 as well. EXPECT_EQ(4, sink.size()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(4, sink.size()); } diff --git a/mediapipe/framework/stream_handler/fixed_size_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/fixed_size_input_stream_handler_test.cc index a29c76a45..abb310927 100644 --- a/mediapipe/framework/stream_handler/fixed_size_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/fixed_size_input_stream_handler_test.cc @@ -165,8 +165,8 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPackets) { std::vector output_packets; tool::AddVectorSink("output_packets", &graph_config, &output_packets); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config)); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Initialize(graph_config)); + MP_ASSERT_OK(graph.Run()); // The TestSlowCalculator consumes one packet after every tenth packet // is sent. All other packets are dropped by the FixedSizeInputStreamHandler. @@ -209,10 +209,10 @@ TEST_P(FixedSizeInputStreamHandlerTest, DropsPacketsInFullStream) { std::vector output_packets; tool::AddVectorSink("output_packets", &graph_config, &output_packets); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.Initialize(graph_config, {{"max_count", MakePacket(10)}, {"batch_size", MakePacket(10)}})); - MEDIAPIPE_ASSERT_OK(graph.Run()); + MP_ASSERT_OK(graph.Run()); } // Tests FixedSizeInputStreamHandler with several input streams running @@ -249,8 +249,8 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) { &output_packets[i]); } CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {})); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(graph_config, {})); + MP_ASSERT_OK(graph.StartRun({})); { ::mediapipe::ThreadPool pool(3); @@ -262,15 +262,15 @@ TEST_P(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) { std::string stream_name = absl::StrCat("in_", w); for (int i = 0; i < 50; ++i) { Packet p = MakePacket(i).At(Timestamp(i)); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p)); + MP_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p)); absl::SleepFor(absl::Microseconds(100)); } }); } } - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); for (int i = 0; i < 3; ++i) { EXPECT_EQ(output_packets[i].size(), output_packets[0].size()); for (int j = 0; j < output_packets[i].size(); j++) { @@ -320,27 +320,27 @@ TEST_P(FixedSizeInputStreamHandlerTest, LateArrivalDrop) { &output_packets[i]); } CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {})); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(graph_config, {})); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 1; i <= 6; i++) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( in_streams[0], MakePacket(i).At(Timestamp(i)))); } for (int i = 3; i <= 7; i++) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( in_streams[1], MakePacket(i).At(Timestamp(i)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); } // At this point everything before ts 5 should be dropped. for (int i = 4; i <= 7; i++) { - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream( + MP_EXPECT_OK(graph.AddPacketToInputStream( in_streams[2], MakePacket(i).At(Timestamp(i)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); } - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); if (GetParam()) { EXPECT_THAT(TimestampValues(output_packets[0]), diff --git a/mediapipe/framework/stream_handler/immediate_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/immediate_input_stream_handler_test.cc index 9e5d3e665..399344384 100644 --- a/mediapipe/framework/stream_handler/immediate_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/immediate_input_stream_handler_test.cc @@ -89,9 +89,9 @@ class ImmediateInputStreamHandlerTest : public ::testing::Test { /*calculator_run_in_parallel=*/false); ASSERT_TRUE(status_or_handler.ok()); input_stream_handler_ = std::move(status_or_handler.ValueOrDie()); - MEDIAPIPE_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers( + MP_ASSERT_OK(input_stream_handler_->InitializeInputStreamManagers( input_stream_managers_.get())); - MEDIAPIPE_ASSERT_OK(cc_manager_.PrepareForRun(setup_shards_callback_)); + MP_ASSERT_OK(cc_manager_.PrepareForRun(setup_shards_callback_)); input_stream_handler_->PrepareForRun(headers_ready_callback_, notification_callback_, schedule_callback_, error_callback_); diff --git a/mediapipe/framework/stream_handler/mux_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/mux_input_stream_handler_test.cc index 22cbb7934..dbf85401f 100644 --- a/mediapipe/framework/stream_handler/mux_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/mux_input_stream_handler_test.cc @@ -77,14 +77,14 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) { input_stream_handler { input_stream_handler: "MuxInputStreamHandler" } })"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < 2000; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input", Adopt(new int(i)).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); } } // namespace diff --git a/mediapipe/framework/stream_handler/set_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/set_input_stream_handler_test.cc index b2ae2f27e..c31fd1631 100644 --- a/mediapipe/framework/stream_handler/set_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/set_input_stream_handler_test.cc @@ -84,14 +84,14 @@ TEST(MuxInputStreamHandlerTest, AtomicAccessToControlAndDataStreams) { # MuxInputStreamHandler set in GetContract(). })"); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < 2000; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input", Adopt(new int(i)).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); } // Copied from pass_through_calculator.cc, and modified to specify @@ -218,8 +218,8 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) { &output_packets[i]); } CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(graph_config, {})); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(graph_config, {})); + MP_ASSERT_OK(graph.StartRun({})); { ::mediapipe::ThreadPool pool(NUM_STREAMS); @@ -231,15 +231,15 @@ TEST(FixedSizeInputStreamHandlerTest, ParallelWriteAndRead) { std::string stream_name = absl::StrCat("in_", w); for (int i = 0; i < 50; ++i) { Packet p = MakePacket(i).At(Timestamp(i)); - MEDIAPIPE_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p)); + MP_EXPECT_OK(graph.AddPacketToInputStream(stream_name, p)); absl::SleepFor(absl::Microseconds(100)); } }); } } - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); for (int i = 0; i < NUM_STREAMS; ++i) { EXPECT_EQ(output_packets[i].size(), output_packets[0].size()); for (int j = 0; j < output_packets[i].size(); j++) { diff --git a/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc index 2efe75a99..f6716a5a6 100644 --- a/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/sync_set_input_stream_handler_test.cc @@ -266,16 +266,16 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) { VLOG(2) << "Modified configuration: " << modified_config.DebugString(); // Setup and run the graph. - MEDIAPIPE_ASSERT_OK(graph.Initialize( + MP_ASSERT_OK(graph.Initialize( modified_config, {{"lambda", MakePacket(InputsToDebugString)}})); std::deque outputs; - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.ObserveOutputStream("output", [&outputs](const Packet& packet) { outputs.push_back(packet); return ::mediapipe::OkStatus(); })); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); for (int command_index = 0; command_index < shuffled_commands.size(); /* command_index is incremented by the inner loop. */) { int initial_command_index = command_index; @@ -295,14 +295,14 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) { VLOG(1) << "Adding (" << stream_name << ", Timestamp: " << timestamp << ")"; if (timestamp == Timestamp::Done()) { - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream(stream_name)); + MP_ASSERT_OK(graph.CloseInputStream(stream_name)); } else { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( stream_name, MakePacket(0).At(timestamp))); } } // Ensure that we produce all packets which we can. - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Check the output strings (ignoring order, since calculator may // have run in parallel). @@ -319,7 +319,7 @@ TEST(SyncSetInputStreamHandlerTest, OrdinaryOperation) { EXPECT_THAT(actual_strings, testing::UnorderedElementsAreArray(expected_strings)); } - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.WaitUntilDone()); } } diff --git a/mediapipe/framework/stream_handler/timestamp_align_input_stream_handler_test.cc b/mediapipe/framework/stream_handler/timestamp_align_input_stream_handler_test.cc index e2c679d86..1be620189 100644 --- a/mediapipe/framework/stream_handler/timestamp_align_input_stream_handler_test.cc +++ b/mediapipe/framework/stream_handler/timestamp_align_input_stream_handler_test.cc @@ -49,38 +49,38 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) { tool::AddVectorSink("output_camera", &config, &sink_camera); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_camera", Adopt(new int(1)).At(Timestamp(101)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // The timestamp base stream's packet is output immediately. EXPECT_EQ(0, sink_video.size()); ASSERT_EQ(1, sink_camera.size()); EXPECT_EQ(1, sink_camera[0].Get()); EXPECT_EQ(Timestamp(101), sink_camera[0].Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_camera", Adopt(new int(2)).At(Timestamp(102)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // The timestamp base stream's packet is output immediately. EXPECT_EQ(0, sink_video.size()); ASSERT_EQ(2, sink_camera.size()); EXPECT_EQ(2, sink_camera[1].Get()); EXPECT_EQ(Timestamp(102), sink_camera[1].Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_video", Adopt(new int(1)).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // No packet is output. The packet added to input_video is buffered in the // input stream. EXPECT_EQ(0, sink_video.size()); EXPECT_EQ(2, sink_camera.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_camera", Adopt(new int(3)).At(Timestamp(103)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Both input streams have a packet. The following equivalence of timestamps // is established: // input_video input_camera @@ -96,23 +96,23 @@ TEST(TimestampAlignInputStreamHandlerTest, Initialization) { EXPECT_EQ(3, sink_camera[2].Get()); EXPECT_EQ(Timestamp(103), sink_camera[2].Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_camera", Adopt(new int(4)).At(Timestamp(104)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // The timestamp base stream does not receive special treatment now. EXPECT_EQ(1, sink_video.size()); EXPECT_EQ(3, sink_camera.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_video", Adopt(new int(4)).At(Timestamp(4)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_EQ(1, sink_video.size()); ASSERT_EQ(4, sink_camera.size()); EXPECT_EQ(4, sink_camera[3].Get()); EXPECT_EQ(Timestamp(104), sink_camera[3].Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(2, sink_video.size()); EXPECT_EQ(4, sink_camera.size()); EXPECT_EQ(4, sink_video[1].Get()); @@ -145,21 +145,21 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) { tool::AddVectorSink("output_camera", &config, &sink_camera); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); // Video timestamps start from 0 seconds. Video frame rate is 2 fps. - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_video", Adopt(new int(0)).At(Timestamp(0)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // No packets expected as the timestamp base stream has not seen any packet. EXPECT_EQ(0, sink_video.size()); EXPECT_EQ(0, sink_camera.size()); // Camera timestamps start from 100 seconds. Camera frame rate is 1 fps. - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_camera", Adopt(new int(0)).At(Timestamp(100000000)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); // Both input streams have a packet. The following equivalence of timestamps // is established: // input_video input_camera @@ -171,17 +171,17 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) { EXPECT_EQ(0, sink_camera[0].Get()); EXPECT_EQ(Timestamp(100000000), sink_camera[0].Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_video", Adopt(new int(1)).At(Timestamp(500000)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); EXPECT_EQ(1, sink_video.size()); EXPECT_EQ(1, sink_camera.size()); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_video", Adopt(new int(2)).At(Timestamp(1000000)))); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_camera", Adopt(new int(1)).At(Timestamp(101000000)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); ASSERT_EQ(3, sink_video.size()); ASSERT_EQ(3, sink_camera.size()); EXPECT_EQ(1, sink_video[1].Get()); @@ -193,8 +193,8 @@ TEST(TimestampAlignInputStreamHandlerTest, TickRate) { EXPECT_EQ(1, sink_camera[2].Get()); EXPECT_EQ(Timestamp(101000000), sink_camera[2].Timestamp()); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(3, sink_video.size()); ASSERT_EQ(3, sink_camera.size()); } diff --git a/mediapipe/framework/subgraph.cc b/mediapipe/framework/subgraph.cc index ef221ea94..a1479c5bf 100644 --- a/mediapipe/framework/subgraph.cc +++ b/mediapipe/framework/subgraph.cc @@ -48,7 +48,7 @@ TemplateSubgraph::~TemplateSubgraph() {} options.GetExtension(TemplateSubgraphOptions::ext).dict(); tool::TemplateExpander expander; CalculatorGraphConfig config; - RETURN_IF_ERROR(expander.ExpandTemplates(arguments, templ_, &config)); + MP_RETURN_IF_ERROR(expander.ExpandTemplates(arguments, templ_, &config)); return config; } @@ -94,7 +94,7 @@ bool GraphRegistry::IsRegistered(const std::string& ns, local_factories_.IsRegistered(ns, type_name) ? local_factories_.Invoke(ns, type_name) : global_factories_->Invoke(ns, type_name); - RETURN_IF_ERROR(maker.status()); + MP_RETURN_IF_ERROR(maker.status()); return maker.ValueOrDie()->GetConfig(graph_options); } diff --git a/mediapipe/framework/subgraph_test.cc b/mediapipe/framework/subgraph_test.cc index 1b994c3eb..f112d20fb 100644 --- a/mediapipe/framework/subgraph_test.cc +++ b/mediapipe/framework/subgraph_test.cc @@ -48,17 +48,17 @@ class SubgraphTest : public ::testing::Test { tool::AddVectorSink("quads", &config, &quads); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.StartRun({})); constexpr int kCount = 5; for (int i = 0; i < kCount; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "in", MakePacket(i).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("in")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("in")); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(dubs.size(), kCount); EXPECT_EQ(quads.size(), kCount); diff --git a/mediapipe/framework/tool/BUILD b/mediapipe/framework/tool/BUILD index bb7052fca..06d178cc0 100644 --- a/mediapipe/framework/tool/BUILD +++ b/mediapipe/framework/tool/BUILD @@ -82,10 +82,7 @@ mediapipe_cc_proto_library( "//mediapipe/framework:calculator_cc_proto", "//mediapipe/framework/deps:proto_descriptor_cc_proto", ], - visibility = [ - "//mediapipe/framework:__subpackages__", - "//mediapipe/java/com/google/mediapipe/framework:__subpackages__", - ], + visibility = ["//visibility:public"], deps = [":calculator_graph_template_proto"], ) @@ -93,7 +90,7 @@ mediapipe_cc_proto_library( name = "source_cc_proto", srcs = ["source.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe/framework:__subpackages__"], + visibility = ["//visibility:public"], deps = [":source_proto"], ) diff --git a/mediapipe/framework/tool/fill_packet_set_test.cc b/mediapipe/framework/tool/fill_packet_set_test.cc index 07173e9f6..ae399831e 100644 --- a/mediapipe/framework/tool/fill_packet_set_test.cc +++ b/mediapipe/framework/tool/fill_packet_set_test.cc @@ -45,7 +45,7 @@ TEST(FillPacketSetTest, Success) { .Set( // double2 ); - MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); + MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); std::map all_side_packets; all_side_packets["side_packet1"] = MakePacket(70); @@ -87,7 +87,7 @@ TEST(FillPacketSetTest, MissingSidePacketError) { .Set( // double2 ); - MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); + MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); std::map all_side_packets; all_side_packets["side_packet1"] = MakePacket(70); @@ -125,7 +125,7 @@ TEST(FillPacketSetTest, MissingSidePacketOk) { .Set( // double2 ); - MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); + MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); std::map all_side_packets; all_side_packets["side_packet1"] = MakePacket(70); @@ -169,7 +169,7 @@ TEST(FillPacketSetTest, WrongSidePacketType) { .Set( // double2 ); - MEDIAPIPE_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); + MP_EXPECT_OK(ValidatePacketTypeSet(input_side_packet_types)); std::map all_side_packets; all_side_packets["side_packet1"] = MakePacket(3.0f); // Wrong Type. diff --git a/mediapipe/framework/tool/proto_util_lite.cc b/mediapipe/framework/tool/proto_util_lite.cc index e244165a7..263a7c3a7 100644 --- a/mediapipe/framework/tool/proto_util_lite.cc +++ b/mediapipe/framework/tool/proto_util_lite.cc @@ -72,7 +72,7 @@ bool IsLengthDelimited(WireFormatLite::WireType wire_type) { uint32 fake_tag = WireFormatLite::MakeTag(1, wire_type); while (data_size > 0) { std::string number; - RETURN_IF_ERROR(ReadFieldValue(fake_tag, in, &number)); + MP_RETURN_IF_ERROR(ReadFieldValue(fake_tag, in, &number)); RET_CHECK_LE(number.size(), data_size); field_values->push_back(number); data_size -= number.size(); @@ -92,10 +92,10 @@ bool IsLengthDelimited(WireFormatLite::WireType wire_type) { if (field_number == field_id) { if (!IsLengthDelimited(wire_type) && IsLengthDelimited(WireFormatLite::GetTagWireType(tag))) { - RETURN_IF_ERROR(ReadPackedValues(wire_type, in, field_values)); + MP_RETURN_IF_ERROR(ReadPackedValues(wire_type, in, field_values)); } else { std::string value; - RETURN_IF_ERROR(ReadFieldValue(tag, in, &value)); + MP_RETURN_IF_ERROR(ReadFieldValue(tag, in, &value)); field_values->push_back(value); } } else { @@ -155,12 +155,12 @@ std::vector* FieldAccess::mutable_field_values() { FieldAccess access(field_id, !proto_path.empty() ? WireFormatLite::TYPE_MESSAGE : field_type); - RETURN_IF_ERROR(access.SetMessage(*message)); + MP_RETURN_IF_ERROR(access.SetMessage(*message)); std::vector& v = *access.mutable_field_values(); if (!proto_path.empty()) { RET_CHECK(index >= 0 && index < v.size()); - RETURN_IF_ERROR(ReplaceFieldRange(&v[index], proto_path, length, field_type, - field_values)); + MP_RETURN_IF_ERROR(ReplaceFieldRange(&v[index], proto_path, length, + field_type, field_values)); } else { RET_CHECK(index >= 0 && index <= v.size()); RET_CHECK(index + length >= 0 && index + length <= v.size()); @@ -182,11 +182,11 @@ std::vector* FieldAccess::mutable_field_values() { FieldAccess access(field_id, !proto_path.empty() ? WireFormatLite::TYPE_MESSAGE : field_type); - RETURN_IF_ERROR(access.SetMessage(message)); + MP_RETURN_IF_ERROR(access.SetMessage(message)); std::vector& v = *access.mutable_field_values(); if (!proto_path.empty()) { RET_CHECK(index >= 0 && index < v.size()); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( GetFieldRange(v[index], proto_path, length, field_type, field_values)); } else { RET_CHECK(index >= 0 && index <= v.size()); @@ -243,7 +243,7 @@ template void (*writer)(T, proto_ns::io::CodedOutputStream*), const std::string& text, CodedOutputStream* out) { T value; - RETURN_IF_ERROR(ParseValue(text, &value)); + MP_RETURN_IF_ERROR(ParseValue(text, &value)); (*writer)(value, out); return ::mediapipe::OkStatus(); } @@ -370,7 +370,7 @@ static ::mediapipe::Status DeserializeValue(const FieldValue& bytes, result->reserve(text_values.size()); for (const std::string& text_value : text_values) { FieldValue field_value; - RETURN_IF_ERROR(SerializeValue(text_value, field_type, &field_value)); + MP_RETURN_IF_ERROR(SerializeValue(text_value, field_type, &field_value)); result->push_back(field_value); } return ::mediapipe::OkStatus(); @@ -383,7 +383,7 @@ static ::mediapipe::Status DeserializeValue(const FieldValue& bytes, result->reserve(field_values.size()); for (const FieldValue& field_value : field_values) { std::string text_value; - RETURN_IF_ERROR(DeserializeValue(field_value, field_type, &text_value)); + MP_RETURN_IF_ERROR(DeserializeValue(field_value, field_type, &text_value)); result->push_back(text_value); } return ::mediapipe::OkStatus(); diff --git a/mediapipe/framework/tool/simulation_clock_test.cc b/mediapipe/framework/tool/simulation_clock_test.cc index 3aa291387..4a03ef6f6 100644 --- a/mediapipe/framework/tool/simulation_clock_test.cc +++ b/mediapipe/framework/tool/simulation_clock_test.cc @@ -92,7 +92,7 @@ class SimulationClockTest : public ::testing::Test { auto executor = std::make_shared(4); simulation_clock_ = executor->GetClock(); clock_ = simulation_clock_.get(); - MEDIAPIPE_ASSERT_OK(graph_.SetExecutor("", executor)); + MP_ASSERT_OK(graph_.SetExecutor("", executor)); } // Initialize the test clock as a RealClock. @@ -213,20 +213,20 @@ TEST_F(SimulationClockTest, InFlight) { SetUpInFlightGraph(); std::vector out_packets; tool::AddVectorSink("output_packets_0", &graph_config_, &out_packets); - MEDIAPIPE_ASSERT_OK(graph_.Initialize( - graph_config_, { - {"max_in_flight", MakePacket(2)}, - {"callback_0", Adopt(new auto(wait_0))}, - {"callback_1", Adopt(new auto(wait_1))}, - })); - MEDIAPIPE_ASSERT_OK(graph_.StartRun({})); + MP_ASSERT_OK(graph_.Initialize(graph_config_, + { + {"max_in_flight", MakePacket(2)}, + {"callback_0", Adopt(new auto(wait_0))}, + {"callback_1", Adopt(new auto(wait_1))}, + })); + MP_ASSERT_OK(graph_.StartRun({})); simulation_clock_->ThreadStart(); // 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) { - MEDIAPIPE_EXPECT_OK(graph_.AddPacketToInputStream( + MP_EXPECT_OK(graph_.AddPacketToInputStream( "input_packets_0", MakePacket(ts).At(Timestamp(ts)))); clock_->Sleep(absl::Microseconds(10000)); } @@ -234,8 +234,8 @@ TEST_F(SimulationClockTest, InFlight) { // Wait for 100 ms of clock time, then close the graph. clock_->Sleep(absl::Microseconds(100000)); simulation_clock_->ThreadFinish(); - MEDIAPIPE_ASSERT_OK(graph_.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph_.WaitUntilDone()); + MP_ASSERT_OK(graph_.CloseAllInputStreams()); + MP_ASSERT_OK(graph_.WaitUntilDone()); // Validate the graph run. EXPECT_THAT(TimestampValues(out_packets), diff --git a/mediapipe/framework/tool/sink_test.cc b/mediapipe/framework/tool/sink_test.cc index 1e514d9a6..d5223041c 100644 --- a/mediapipe/framework/tool/sink_test.cc +++ b/mediapipe/framework/tool/sink_test.cc @@ -58,14 +58,14 @@ TEST(CallbackFromGeneratorTest, TestAddVectorSink) { tool::AddVectorSink("input_packets", &graph_config, &dumped_data); graph_config.add_input_stream("input_packets"); CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < 10; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_packets", MakePacket(i).At(Timestamp(i)))); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilIdle()); + MP_ASSERT_OK(graph.WaitUntilIdle()); } - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_packets")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("input_packets")); + MP_ASSERT_OK(graph.WaitUntilDone()); ASSERT_EQ(10, dumped_data.size()); for (int i = 0; i < 10; ++i) { EXPECT_EQ(Timestamp(i), dumped_data[i].Timestamp()); @@ -87,18 +87,18 @@ TEST(CalculatorGraph, OutputSummarySidePacketInClose) { Packet summary_packet; tool::AddSidePacketSink("num_of_packets", &config, &summary_packet); CalculatorGraph graph; - MEDIAPIPE_ASSERT_OK(graph.Initialize(config)); + MP_ASSERT_OK(graph.Initialize(config)); // Run the graph twice. int max_count = 100; for (int run = 0; run < 1; ++run) { - MEDIAPIPE_ASSERT_OK(graph.StartRun({})); + MP_ASSERT_OK(graph.StartRun({})); for (int i = 0; i < max_count; ++i) { - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "input_packets", MakePacket(i).At(Timestamp(i)))); } - MEDIAPIPE_ASSERT_OK(graph.CloseInputStream("input_packets")); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseInputStream("input_packets")); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_EQ(max_count, summary_packet.Get()); EXPECT_EQ(Timestamp::PostStream(), summary_packet.Timestamp()); } @@ -124,24 +124,24 @@ TEST(CallbackTest, TestAddMultiStreamCallback) { &graph_config, &cb_packet); CalculatorGraph graph(graph_config); - MEDIAPIPE_ASSERT_OK(graph.StartRun({cb_packet})); + MP_ASSERT_OK(graph.StartRun({cb_packet})); - MEDIAPIPE_ASSERT_OK(graph.AddPacketToInputStream( + MP_ASSERT_OK(graph.AddPacketToInputStream( "foo", MakePacket(10).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.AddPacketToInputStream("bar", MakePacket(5).At(Timestamp(1)))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.AddPacketToInputStream("foo", MakePacket(7).At(Timestamp(2)))); // no bar input at 2 - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.AddPacketToInputStream("foo", MakePacket(4).At(Timestamp(3)))); - MEDIAPIPE_ASSERT_OK( + MP_ASSERT_OK( graph.AddPacketToInputStream("bar", MakePacket(5).At(Timestamp(3)))); - MEDIAPIPE_ASSERT_OK(graph.CloseAllInputStreams()); - MEDIAPIPE_ASSERT_OK(graph.WaitUntilDone()); + MP_ASSERT_OK(graph.CloseAllInputStreams()); + MP_ASSERT_OK(graph.WaitUntilDone()); EXPECT_THAT(sums, testing::ElementsAre(15, 7, 9)); } diff --git a/mediapipe/framework/tool/status_util_test.cc b/mediapipe/framework/tool/status_util_test.cc index 0e3b198f9..2719545e5 100644 --- a/mediapipe/framework/tool/status_util_test.cc +++ b/mediapipe/framework/tool/status_util_test.cc @@ -79,10 +79,10 @@ TEST(StatusTest, CombinedStatus) { errors.clear(); errors.emplace_back(::mediapipe::StatusCode::kOk, "error_with_this_string"); errors.emplace_back(::mediapipe::StatusCode::kOk, "error_with_that_string"); - MEDIAPIPE_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors)); + MP_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors)); errors.clear(); - MEDIAPIPE_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors)); + MP_EXPECT_OK(tool::CombinedStatus(prefix_error_message, errors)); } // Verify tool::StatusInvalid() and tool::StatusFail() and the alternatives diff --git a/mediapipe/framework/tool/subgraph_expansion.cc b/mediapipe/framework/tool/subgraph_expansion.cc index 0cb1d87be..a91b20d92 100644 --- a/mediapipe/framework/tool/subgraph_expansion.cc +++ b/mediapipe/framework/tool/subgraph_expansion.cc @@ -60,14 +60,14 @@ namespace tool { {config->mutable_input_stream(), config->mutable_output_stream(), config->mutable_input_side_packet(), config->mutable_output_side_packet()}) { - RETURN_IF_ERROR(TransformStreamNames(streams, transform)); + MP_RETURN_IF_ERROR(TransformStreamNames(streams, transform)); } for (auto& node : *config->mutable_node()) { for (auto* streams : {node.mutable_input_stream(), node.mutable_output_stream(), node.mutable_input_side_packet(), node.mutable_output_side_packet()}) { - RETURN_IF_ERROR(TransformStreamNames(streams, transform)); + MP_RETURN_IF_ERROR(TransformStreamNames(streams, transform)); } if (!node.name().empty()) { node.set_name(transform(node.name())); @@ -76,11 +76,11 @@ namespace tool { for (auto& generator : *config->mutable_packet_generator()) { for (auto* streams : {generator.mutable_input_side_packet(), generator.mutable_output_side_packet()}) { - RETURN_IF_ERROR(TransformStreamNames(streams, transform)); + MP_RETURN_IF_ERROR(TransformStreamNames(streams, transform)); } } for (auto& status_handler : *config->mutable_status_handler()) { - RETURN_IF_ERROR(TransformStreamNames( + MP_RETURN_IF_ERROR(TransformStreamNames( status_handler.mutable_input_side_packet(), transform)); } return ::mediapipe::OkStatus(); @@ -164,28 +164,29 @@ static ::mediapipe::Status PrefixNames(int subgraph_index, const CalculatorGraphConfig::Node& subgraph_node, CalculatorGraphConfig* subgraph_config) { std::map stream_map; - RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map, - subgraph_config->input_stream(), - subgraph_node.input_stream())) + MP_RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map, + subgraph_config->input_stream(), + subgraph_node.input_stream())) .SetPrepend() << "while processing the input streams of subgraph node " << subgraph_node.calculator() << ": "; - RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map, - subgraph_config->output_stream(), - subgraph_node.output_stream())) + MP_RETURN_IF_ERROR(FindCorrespondingStreams(&stream_map, + subgraph_config->output_stream(), + subgraph_node.output_stream())) .SetPrepend() << "while processing the output streams of subgraph node " << subgraph_node.calculator() << ": "; std::map side_packet_map; - RETURN_IF_ERROR(FindCorrespondingStreams(&side_packet_map, - subgraph_config->input_side_packet(), - subgraph_node.input_side_packet())) + MP_RETURN_IF_ERROR(FindCorrespondingStreams( + &side_packet_map, subgraph_config->input_side_packet(), + subgraph_node.input_side_packet())) .SetPrepend() << "while processing the input side packets of subgraph node " << subgraph_node.calculator() << ": "; - RETURN_IF_ERROR(FindCorrespondingStreams( - &side_packet_map, subgraph_config->output_side_packet(), - subgraph_node.output_side_packet())) + MP_RETURN_IF_ERROR( + FindCorrespondingStreams(&side_packet_map, + subgraph_config->output_side_packet(), + subgraph_node.output_side_packet())) .SetPrepend() << "while processing the output side packets of subgraph node " << subgraph_node.calculator() << ": "; @@ -197,22 +198,22 @@ static ::mediapipe::Status PrefixNames(int subgraph_index, }; for (auto& node : *subgraph_config->mutable_node()) { name_map = &stream_map; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( TransformStreamNames(node.mutable_input_stream(), replace_names)); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( TransformStreamNames(node.mutable_output_stream(), replace_names)); name_map = &side_packet_map; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( TransformStreamNames(node.mutable_input_side_packet(), replace_names)); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( TransformStreamNames(node.mutable_output_side_packet(), replace_names)); } name_map = &side_packet_map; for (auto& generator : *subgraph_config->mutable_packet_generator()) { - RETURN_IF_ERROR(TransformStreamNames(generator.mutable_input_side_packet(), - replace_names)); - RETURN_IF_ERROR(TransformStreamNames(generator.mutable_output_side_packet(), - replace_names)); + MP_RETURN_IF_ERROR(TransformStreamNames( + generator.mutable_input_side_packet(), replace_names)); + MP_RETURN_IF_ERROR(TransformStreamNames( + generator.mutable_output_side_packet(), replace_names)); } return ::mediapipe::OkStatus(); } @@ -235,12 +236,12 @@ static ::mediapipe::Status PrefixNames(int subgraph_index, std::vector subgraphs; for (auto it = subgraph_nodes_start; it != nodes->end(); ++it) { const auto& node = *it; - RETURN_IF_ERROR(ValidateSubgraphFields(node)); + MP_RETURN_IF_ERROR(ValidateSubgraphFields(node)); ASSIGN_OR_RETURN(auto subgraph, graph_registry->CreateByName( config->package(), node.calculator(), &node.options())); - RETURN_IF_ERROR(PrefixNames(subgraph_counter++, &subgraph)); - RETURN_IF_ERROR(ConnectSubgraphStreams(node, &subgraph)); + MP_RETURN_IF_ERROR(PrefixNames(subgraph_counter++, &subgraph)); + MP_RETURN_IF_ERROR(ConnectSubgraphStreams(node, &subgraph)); subgraphs.push_back(subgraph); } nodes->erase(subgraph_nodes_start, nodes->end()); diff --git a/mediapipe/framework/tool/subgraph_expansion_test.cc b/mediapipe/framework/tool/subgraph_expansion_test.cc index a469e702a..8502d7461 100644 --- a/mediapipe/framework/tool/subgraph_expansion_test.cc +++ b/mediapipe/framework/tool/subgraph_expansion_test.cc @@ -213,7 +213,7 @@ TEST(SubgraphExpansionTest, TransformStreamNames) { } )"); auto add_foo = [](absl::string_view s) { return absl::StrCat(s, "_foo"); }; - MEDIAPIPE_EXPECT_OK(tool::TransformStreamNames( + MP_EXPECT_OK(tool::TransformStreamNames( (*config.mutable_node())[0].mutable_input_stream(), add_foo)); EXPECT_THAT(config, mediapipe::EqualsProto(expected_config)); } @@ -258,7 +258,7 @@ TEST(SubgraphExpansionTest, TransformNames) { auto add_prefix = [](absl::string_view s) { return absl::StrCat("__sg0_", s); }; - MEDIAPIPE_EXPECT_OK(tool::TransformNames(&config, add_prefix)); + MP_EXPECT_OK(tool::TransformNames(&config, add_prefix)); EXPECT_THAT(config, mediapipe::EqualsProto(expected_config)); } @@ -281,7 +281,7 @@ TEST(SubgraphExpansionTest, FindCorrespondingStreams) { } )"); std::map stream_map; - MEDIAPIPE_EXPECT_OK(tool::FindCorrespondingStreams( + MP_EXPECT_OK(tool::FindCorrespondingStreams( &stream_map, config1.input_stream(), config2.node()[0].input_stream())); EXPECT_THAT(stream_map, testing::UnorderedElementsAre(testing::Pair("input_1", "foo"), @@ -416,8 +416,7 @@ TEST(SubgraphExpansionTest, ConnectSubgraphStreams) { output_side_packet: "flop" } )"); - MEDIAPIPE_EXPECT_OK( - tool::ConnectSubgraphStreams(supergraph.node()[0], &subgraph)); + MP_EXPECT_OK(tool::ConnectSubgraphStreams(supergraph.node()[0], &subgraph)); EXPECT_THAT(subgraph, mediapipe::EqualsProto(expected_subgraph)); } @@ -455,7 +454,7 @@ TEST(SubgraphExpansionTest, ExpandSubgraphs) { output_side_packet: "__sg0_side" } )"); - MEDIAPIPE_EXPECT_OK(tool::ExpandSubgraphs(&supergraph)); + MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph)); EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph)); } @@ -521,7 +520,7 @@ TEST(SubgraphExpansionTest, ExecutorFieldOfNodeInSubgraphPreserved) { executor: "custom_thread_pool" } )"); - MEDIAPIPE_EXPECT_OK(tool::ExpandSubgraphs(&supergraph)); + MP_EXPECT_OK(tool::ExpandSubgraphs(&supergraph)); EXPECT_THAT(supergraph, mediapipe::EqualsProto(expected_graph)); } diff --git a/mediapipe/framework/tool/tag_map.cc b/mediapipe/framework/tool/tag_map.cc index 67f6c3609..fcc9a92fe 100644 --- a/mediapipe/framework/tool/tag_map.cc +++ b/mediapipe/framework/tool/tag_map.cc @@ -44,7 +44,7 @@ void TagMap::InitializeNames( std::string tag; int index; std::string name; - RETURN_IF_ERROR(ParseTagIndexName(tag_index_name, &tag, &index, &name)); + MP_RETURN_IF_ERROR(ParseTagIndexName(tag_index_name, &tag, &index, &name)); // Get a reference to the tag data (possibly creating it). TagData& tag_data = mapping_[tag]; diff --git a/mediapipe/framework/tool/tag_map.h b/mediapipe/framework/tool/tag_map.h index 6e5c802e9..bdc250924 100644 --- a/mediapipe/framework/tool/tag_map.h +++ b/mediapipe/framework/tool/tag_map.h @@ -56,7 +56,7 @@ class TagMap { static ::mediapipe::StatusOr> Create( const proto_ns::RepeatedPtrField& tag_index_names) { std::shared_ptr output(new TagMap()); - RETURN_IF_ERROR(output->Initialize(tag_index_names)); + MP_RETURN_IF_ERROR(output->Initialize(tag_index_names)); return std::move(output); } @@ -67,7 +67,7 @@ class TagMap { static ::mediapipe::StatusOr> Create( const TagAndNameInfo& info) { std::shared_ptr output(new TagMap()); - RETURN_IF_ERROR(output->Initialize(info)); + MP_RETURN_IF_ERROR(output->Initialize(info)); return std::move(output); } diff --git a/mediapipe/framework/tool/tag_map_test.cc b/mediapipe/framework/tool/tag_map_test.cc index de6d7291e..cac666988 100644 --- a/mediapipe/framework/tool/tag_map_test.cc +++ b/mediapipe/framework/tool/tag_map_test.cc @@ -26,37 +26,35 @@ namespace { TEST(TagMapTest, Create) { // Create using tags. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMapFromTags({})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH1", "BLAH2"})); + MP_EXPECT_OK(tool::CreateTagMapFromTags({})); + MP_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH"})); + MP_EXPECT_OK(tool::CreateTagMapFromTags({"BLAH1", "BLAH2"})); // Tags must be uppercase. EXPECT_FALSE(tool::CreateTagMapFromTags({"blah1", "BLAH2"}).ok()); // Create with TAG::names. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"blah"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"blah1", "blah2"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH:blah"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH1:blah1", "BLAH2:blah2"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH:0:blah1", "BLAH:1:blah2"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"BLAH:blah1", "BLAH:1:blah2"})); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap( + MP_EXPECT_OK(tool::CreateTagMap({})); + MP_EXPECT_OK(tool::CreateTagMap({"blah"})); + MP_EXPECT_OK(tool::CreateTagMap({"blah1", "blah2"})); + MP_EXPECT_OK(tool::CreateTagMap({"BLAH:blah"})); + MP_EXPECT_OK(tool::CreateTagMap({"BLAH1:blah1", "BLAH2:blah2"})); + MP_EXPECT_OK(tool::CreateTagMap({"BLAH:0:blah1", "BLAH:1:blah2"})); + MP_EXPECT_OK(tool::CreateTagMap({"BLAH:blah1", "BLAH:1:blah2"})); + MP_EXPECT_OK(tool::CreateTagMap( {"A:2:a2", "B:1:b1", "C:c0", "A:0:a0", "B:b0", "A:1:a1"})); - MEDIAPIPE_EXPECT_OK( - tool::CreateTagMap({"w", "A:2:a2", "x", "B:1:b1", "C:c0", "y", "A:0:a0", - "B:b0", "z", "A:1:a1"})); - MEDIAPIPE_EXPECT_OK( - tool::CreateTagMap({"A:2:a2", "w", "x", "B:1:b1", "C:c0", "y", "A:0:a0", - "B:b0", "z", "A:1:a1"})); + MP_EXPECT_OK(tool::CreateTagMap({"w", "A:2:a2", "x", "B:1:b1", "C:c0", "y", + "A:0:a0", "B:b0", "z", "A:1:a1"})); + MP_EXPECT_OK(tool::CreateTagMap({"A:2:a2", "w", "x", "B:1:b1", "C:c0", "y", + "A:0:a0", "B:b0", "z", "A:1:a1"})); // Reuse name. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"a", "A:a"})); + MP_EXPECT_OK(tool::CreateTagMap({"a", "A:a"})); // Reuse name. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"a", "a"})); + MP_EXPECT_OK(tool::CreateTagMap({"a", "a"})); // Reuse name. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"C:c", "a", "a"})); + MP_EXPECT_OK(tool::CreateTagMap({"C:c", "a", "a"})); // Reuse name. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap({"A:a", "B:a"})); + MP_EXPECT_OK(tool::CreateTagMap({"A:a", "B:a"})); // Reuse same tag. EXPECT_FALSE(tool::CreateTagMap({"BLAH:blah1", "BLAH:blah2"}).ok()); @@ -71,20 +69,20 @@ TEST(TagMapTest, Create) { tool::CreateTagMap({"blah0", "BLAH:1:blah1", "BLAH:2:blah2"}).ok()); // Create using an index. - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap(0)); - MEDIAPIPE_EXPECT_OK(tool::CreateTagMap(3)); + MP_EXPECT_OK(tool::CreateTagMap(0)); + MP_EXPECT_OK(tool::CreateTagMap(3)); // Negative number of entries. EXPECT_FALSE(tool::CreateTagMap(-1).ok()); // Create using a TagAndNameInfo. tool::TagAndNameInfo info; info.names = {"blah1", "blah2"}; - MEDIAPIPE_EXPECT_OK(tool::TagMap::Create(info)); + MP_EXPECT_OK(tool::TagMap::Create(info)); info.tags = {"BLAH1", "BLAH2", "BLAH3"}; // Number of tags and names do not match. EXPECT_FALSE(tool::TagMap::Create(info).ok()); info.names.push_back("blah3"); - MEDIAPIPE_EXPECT_OK(tool::TagMap::Create(info)); + MP_EXPECT_OK(tool::TagMap::Create(info)); } void TestSuccessTagMap(const std::vector& tag_index_names, @@ -296,11 +294,11 @@ TEST(TagMapTest, SameAs) { if (std::get<1>(parameters)) { auto statusor_tag_map = tool::CreateTagMapFromTags(std::get<2>(parameters)); - MEDIAPIPE_ASSERT_OK(statusor_tag_map); + MP_ASSERT_OK(statusor_tag_map); tag_maps.push_back(std::move(statusor_tag_map.ValueOrDie())); } else { auto statusor_tag_map = tool::CreateTagMap(std::get<2>(parameters)); - MEDIAPIPE_ASSERT_OK(statusor_tag_map); + MP_ASSERT_OK(statusor_tag_map); tag_maps.push_back(std::move(statusor_tag_map.ValueOrDie())); } } @@ -327,7 +325,7 @@ void TestDebugString(const ::mediapipe::StatusOr>& statusor_tag_map, const std::vector& canonical_entries, Matcher short_string_matcher) { - MEDIAPIPE_ASSERT_OK(statusor_tag_map); + MP_ASSERT_OK(statusor_tag_map); tool::TagMap& tag_map = *statusor_tag_map.ValueOrDie(); std::string debug_string = tag_map.DebugString(); std::string short_string = tag_map.ShortDebugString(); diff --git a/mediapipe/framework/tool/template_expander.cc b/mediapipe/framework/tool/template_expander.cc index adcade2bf..2597dd597 100644 --- a/mediapipe/framework/tool/template_expander.cc +++ b/mediapipe/framework/tool/template_expander.cc @@ -604,7 +604,8 @@ class TemplateExpanderImpl { ? mediapipe::SimpleDtoa(args[i].num()) : args[i].str(); std::vector r; - RETURN_IF_ERROR(ProtoUtilLite::Serialize({text_value}, field_type, &r)); + MP_RETURN_IF_ERROR( + ProtoUtilLite::Serialize({text_value}, field_type, &r)); result->push_back(r[0]); } } diff --git a/mediapipe/framework/tool/text_to_binary_graph.cc b/mediapipe/framework/tool/text_to_binary_graph.cc index b2c96d790..3f083302a 100644 --- a/mediapipe/framework/tool/text_to_binary_graph.cc +++ b/mediapipe/framework/tool/text_to_binary_graph.cc @@ -72,7 +72,7 @@ mediapipe::Status ReadFile(const std::string& proto_source, bool read_text, proto_ns::Message* result) { std::ifstream ifs(proto_source); proto_ns::io::IstreamInputStream in(&ifs); - RETURN_IF_ERROR(ReadProto(&in, read_text, proto_source, result)); + MP_RETURN_IF_ERROR(ReadProto(&in, read_text, proto_source, result)); return mediapipe::OkStatus(); } @@ -81,7 +81,7 @@ mediapipe::Status WriteFile(const std::string& proto_output, bool write_text, const proto_ns::Message& message) { std::ofstream ofs(proto_output, std::ofstream::out | std::ofstream::trunc); proto_ns::io::OstreamOutputStream out(&ofs); - RETURN_IF_ERROR(WriteProto(message, write_text, proto_output, &out)); + MP_RETURN_IF_ERROR(WriteProto(message, write_text, proto_output, &out)); return mediapipe::OkStatus(); } diff --git a/mediapipe/framework/tool/validate.cc b/mediapipe/framework/tool/validate.cc index 4ef340d0a..f0ddf13b3 100644 --- a/mediapipe/framework/tool/validate.cc +++ b/mediapipe/framework/tool/validate.cc @@ -28,7 +28,7 @@ namespace tool { ::mediapipe::Status ValidateInput(const InputCollection& input_collection) { if (!input_collection.name().empty()) { - RETURN_IF_ERROR(tool::ValidateName(input_collection.name())).SetPrepend() + MP_RETURN_IF_ERROR(tool::ValidateName(input_collection.name())).SetPrepend() << "InputCollection " << input_collection.name() << " has improperly specified name: "; } diff --git a/mediapipe/framework/tool/validate_name.cc b/mediapipe/framework/tool/validate_name.cc index e68841b1f..48cd48dfb 100644 --- a/mediapipe/framework/tool/validate_name.cc +++ b/mediapipe/framework/tool/validate_name.cc @@ -50,7 +50,7 @@ namespace tool { for (const auto& tag_and_name : tags_and_names) { std::string tag; std::string name; - RETURN_IF_ERROR(ParseTagAndName(tag_and_name, &tag, &name)); + MP_RETURN_IF_ERROR(ParseTagAndName(tag_and_name, &tag, &name)); if (!tag.empty()) { info->tags.push_back(tag); } @@ -73,7 +73,7 @@ namespace tool { tags_and_names->Clear(); if (info.tags.empty()) { for (const auto& name : info.names) { - RETURN_IF_ERROR(ValidateName(name)); + MP_RETURN_IF_ERROR(ValidateName(name)); *tags_and_names->Add() = name; } } else { @@ -83,8 +83,8 @@ namespace tool { << " does not match the number of tags " << info.tags.size(); } for (int i = 0; i < info.tags.size(); ++i) { - RETURN_IF_ERROR(ValidateTag(info.tags[i])); - RETURN_IF_ERROR(ValidateName(info.names[i])); + MP_RETURN_IF_ERROR(ValidateTag(info.tags[i])); + MP_RETURN_IF_ERROR(ValidateName(info.names[i])); *tags_and_names->Add() = absl::StrCat(info.tags[i], ":", info.names[i]); } } diff --git a/mediapipe/framework/tool/validate_name_test.cc b/mediapipe/framework/tool/validate_name_test.cc index e47f77cb4..3eb9f9715 100644 --- a/mediapipe/framework/tool/validate_name_test.cc +++ b/mediapipe/framework/tool/validate_name_test.cc @@ -27,12 +27,12 @@ namespace mediapipe { namespace { TEST(ValidateNameTest, ValidateName) { - MEDIAPIPE_EXPECT_OK(tool::ValidateName("humphrey")); - MEDIAPIPE_EXPECT_OK(tool::ValidateName("humphrey_bogart")); - MEDIAPIPE_EXPECT_OK(tool::ValidateName("humphrey_bogart_1899")); - MEDIAPIPE_EXPECT_OK(tool::ValidateName("aa")); - MEDIAPIPE_EXPECT_OK(tool::ValidateName("b1")); - MEDIAPIPE_EXPECT_OK(tool::ValidateName("_1")); + MP_EXPECT_OK(tool::ValidateName("humphrey")); + MP_EXPECT_OK(tool::ValidateName("humphrey_bogart")); + MP_EXPECT_OK(tool::ValidateName("humphrey_bogart_1899")); + MP_EXPECT_OK(tool::ValidateName("aa")); + MP_EXPECT_OK(tool::ValidateName("b1")); + MP_EXPECT_OK(tool::ValidateName("_1")); EXPECT_FALSE(tool::ValidateName("").ok()); EXPECT_FALSE(tool::ValidateName("humphrey bogart").ok()); EXPECT_FALSE(tool::ValidateName("humphreyBogart").ok()); @@ -54,12 +54,12 @@ TEST(ValidateNameTest, ValidateName) { } TEST(ValidateNameTest, ValidateTag) { - MEDIAPIPE_EXPECT_OK(tool::ValidateTag("MALE")); - MEDIAPIPE_EXPECT_OK(tool::ValidateTag("MALE_ACTOR")); - MEDIAPIPE_EXPECT_OK(tool::ValidateTag("ACTOR_1899")); - MEDIAPIPE_EXPECT_OK(tool::ValidateTag("AA")); - MEDIAPIPE_EXPECT_OK(tool::ValidateTag("B1")); - MEDIAPIPE_EXPECT_OK(tool::ValidateTag("_1")); + MP_EXPECT_OK(tool::ValidateTag("MALE")); + MP_EXPECT_OK(tool::ValidateTag("MALE_ACTOR")); + MP_EXPECT_OK(tool::ValidateTag("ACTOR_1899")); + MP_EXPECT_OK(tool::ValidateTag("AA")); + MP_EXPECT_OK(tool::ValidateTag("B1")); + MP_EXPECT_OK(tool::ValidateTag("_1")); EXPECT_FALSE(tool::ValidateTag("").ok()); EXPECT_FALSE(tool::ValidateTag("MALE ACTOR").ok()); EXPECT_FALSE(tool::ValidateTag("MALEaCTOR").ok()); @@ -82,24 +82,22 @@ TEST(ValidateNameTest, ParseTagAndName) { std::string name; tag = "blah"; name = "blah"; - MEDIAPIPE_EXPECT_OK(tool::ParseTagAndName("MALE:humphrey", &tag, &name)); + MP_EXPECT_OK(tool::ParseTagAndName("MALE:humphrey", &tag, &name)); EXPECT_EQ("MALE", tag); EXPECT_EQ("humphrey", name); tag = "blah"; name = "blah"; - MEDIAPIPE_EXPECT_OK( - tool::ParseTagAndName("ACTOR:humphrey_bogart", &tag, &name)); + MP_EXPECT_OK(tool::ParseTagAndName("ACTOR:humphrey_bogart", &tag, &name)); EXPECT_EQ("ACTOR", tag); EXPECT_EQ("humphrey_bogart", name); tag = "blah"; name = "blah"; - MEDIAPIPE_EXPECT_OK( - tool::ParseTagAndName("ACTOR_1899:humphrey_1899", &tag, &name)); + MP_EXPECT_OK(tool::ParseTagAndName("ACTOR_1899:humphrey_1899", &tag, &name)); EXPECT_EQ("ACTOR_1899", tag); EXPECT_EQ("humphrey_1899", name); tag = "blah"; name = "blah"; - MEDIAPIPE_EXPECT_OK(tool::ParseTagAndName("humphrey_bogart", &tag, &name)); + MP_EXPECT_OK(tool::ParseTagAndName("humphrey_bogart", &tag, &name)); EXPECT_EQ("", tag); EXPECT_EQ("humphrey_bogart", name); @@ -122,7 +120,7 @@ TEST(ValidateNameTest, ParseTagAndName) { EXPECT_EQ("", name); tag = "blah"; name = "blah"; - MEDIAPIPE_EXPECT_OK(tool::ParseTagAndName("ACTOR:humphrey", &tag, &name)); + MP_EXPECT_OK(tool::ParseTagAndName("ACTOR:humphrey", &tag, &name)); EXPECT_EQ("ACTOR", tag); EXPECT_EQ("humphrey", name); @@ -166,8 +164,8 @@ void TestPassParseTagIndexName(const std::string& tag_index_name, std::string actual_tag = "UNTOUCHED"; int actual_index = -100; std::string actual_name = "untouched"; - MEDIAPIPE_ASSERT_OK(tool::ParseTagIndexName(tag_index_name, &actual_tag, - &actual_index, &actual_name)) + MP_ASSERT_OK(tool::ParseTagIndexName(tag_index_name, &actual_tag, + &actual_index, &actual_name)) << "With tag_index_name " << tag_index_name; EXPECT_EQ(expected_tag, actual_tag) << "With tag_index_name " << tag_index_name; @@ -280,8 +278,7 @@ void TestPassParseTagIndex(const std::string& tag_index, const int expected_index) { std::string actual_tag = "UNTOUCHED"; int actual_index = -100; - MEDIAPIPE_ASSERT_OK( - tool::ParseTagIndex(tag_index, &actual_tag, &actual_index)) + MP_ASSERT_OK(tool::ParseTagIndex(tag_index, &actual_tag, &actual_index)) << "With tag_index" << tag_index; EXPECT_EQ(expected_tag, actual_tag) << "With tag_index " << tag_index; EXPECT_EQ(expected_index, actual_index) << "With tag_index " << tag_index; @@ -360,22 +357,22 @@ TEST(ValidateNameTest, GetTagAndNameInfo) { fields.Clear(); fields.Add()->assign("transcoded_input_file"); tool::TagAndNameInfo info; - MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); + MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); ASSERT_EQ(0, info.tags.size()); ASSERT_EQ(1, info.names.size()); EXPECT_EQ(fields.Get(0), info.names[0]); - MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); + MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); EXPECT_THAT(node_config2, EqualsProto(node_config1)); // Single input using tags. fields.Clear(); fields.Add()->assign("FILE:transcoded_input_file"); - MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); + MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); ASSERT_EQ(1, info.tags.size()); ASSERT_EQ(1, info.names.size()); EXPECT_EQ("FILE", info.tags[0]); EXPECT_EQ("transcoded_input_file", info.names[0]); - MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); + MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); EXPECT_THAT(node_config2, EqualsProto(node_config1)); // Mixing indexes and tags. @@ -390,7 +387,7 @@ TEST(ValidateNameTest, GetTagAndNameInfo) { fields.Add()->assign("TAG2:input2"); fields.Add()->assign("TAG3:input3"); fields.Add()->assign("TAG4:input4"); - MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); + MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); ASSERT_EQ(4, info.tags.size()); ASSERT_EQ(4, info.names.size()); EXPECT_EQ("TAG1", info.tags[0]); @@ -401,7 +398,7 @@ TEST(ValidateNameTest, GetTagAndNameInfo) { EXPECT_EQ("input2", info.names[1]); EXPECT_EQ("input3", info.names[2]); EXPECT_EQ("input4", info.names[3]); - MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); + MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); EXPECT_THAT(node_config2, EqualsProto(node_config1)); // Valid configuration with more than one input using indexes. @@ -410,14 +407,14 @@ TEST(ValidateNameTest, GetTagAndNameInfo) { fields.Add()->assign("input2"); fields.Add()->assign("input3"); fields.Add()->assign("input4"); - MEDIAPIPE_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); + MP_ASSERT_OK(tool::GetTagAndNameInfo(fields, &info)); ASSERT_EQ(0, info.tags.size()); ASSERT_EQ(4, info.names.size()); EXPECT_EQ("input1", info.names[0]); EXPECT_EQ("input2", info.names[1]); EXPECT_EQ("input3", info.names[2]); EXPECT_EQ("input4", info.names[3]); - MEDIAPIPE_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); + MP_ASSERT_OK(tool::SetFromTagAndNameInfo(info, &fields_copy)); EXPECT_THAT(node_config2, EqualsProto(node_config1)); // Add an invalid character into the name. diff --git a/mediapipe/framework/tool/validate_type.cc b/mediapipe/framework/tool/validate_type.cc index 8f482bf5f..79a6e36e7 100644 --- a/mediapipe/framework/tool/validate_type.cc +++ b/mediapipe/framework/tool/validate_type.cc @@ -52,13 +52,13 @@ namespace tool { << " is not a registered packet generator."); CalculatorContract contract; - RETURN_IF_ERROR(contract.Initialize(config)); + MP_RETURN_IF_ERROR(contract.Initialize(config)); { LegacyCalculatorSupport::Scoped s(&contract); - RETURN_IF_ERROR(static_access->FillExpectations( - config.options(), &contract.InputSidePackets(), - &contract.OutputSidePackets())) + MP_RETURN_IF_ERROR(static_access->FillExpectations( + config.options(), &contract.InputSidePackets(), + &contract.OutputSidePackets())) .SetPrepend() << config.packet_generator() << "::FillExpectations failed: "; } @@ -89,30 +89,30 @@ namespace tool { PacketTypeSet output_side_packet_types(output_side_packets->TagMap()); // Fill the PacketTypeSets with type information. - RETURN_IF_ERROR(static_access->FillExpectations(extendable_options, - &input_side_packet_types, - &output_side_packet_types)) + MP_RETURN_IF_ERROR(static_access->FillExpectations(extendable_options, + &input_side_packet_types, + &output_side_packet_types)) .SetPrepend() << packet_generator_name << "::FillExpectations failed: "; // Check that the types were filled well. std::vector<::mediapipe::Status> statuses; statuses.push_back(ValidatePacketTypeSet(input_side_packet_types)); statuses.push_back(ValidatePacketTypeSet(output_side_packet_types)); - RETURN_IF_ERROR(tool::CombinedStatus( + MP_RETURN_IF_ERROR(tool::CombinedStatus( absl::StrCat(packet_generator_name, "::FillExpectations failed: "), statuses)); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( ValidatePacketSet(input_side_packet_types, input_side_packets)) .SetPrepend() << packet_generator_name << "::FillExpectations expected different input type than those given: "; - RETURN_IF_ERROR(static_access->Generate(extendable_options, - input_side_packets, - output_side_packets)) + MP_RETURN_IF_ERROR(static_access->Generate(extendable_options, + input_side_packets, + output_side_packets)) .SetPrepend() << packet_generator_name << "::Generate failed: "; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( ValidatePacketSet(output_side_packet_types, *output_side_packets)) .SetPrepend() << packet_generator_name diff --git a/mediapipe/framework/validated_graph_config.cc b/mediapipe/framework/validated_graph_config.cc index 414ed87a2..c9b2914ee 100644 --- a/mediapipe/framework/validated_graph_config.cc +++ b/mediapipe/framework/validated_graph_config.cc @@ -146,9 +146,10 @@ std::string DebugName(const CalculatorGraphConfig& config, const GraphRegistry* graph_registry, CalculatorGraphConfig* output_graph_config) { *output_graph_config = input_graph_config; - RETURN_IF_ERROR(tool::ExpandSubgraphs(output_graph_config, graph_registry)); + MP_RETURN_IF_ERROR( + tool::ExpandSubgraphs(output_graph_config, graph_registry)); - RETURN_IF_ERROR(AddPredefinedExecutorConfigs(output_graph_config)); + MP_RETURN_IF_ERROR(AddPredefinedExecutorConfigs(output_graph_config)); // Populate each node with the graph level input stream handler if a // stream handler wasn't explicitly provided. @@ -217,7 +218,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { const CalculatorGraphConfig::Node& node, int node_index) { node_.type = NodeType::CALCULATOR; node_.index = node_index; - RETURN_IF_ERROR(contract_.Initialize(node)); + MP_RETURN_IF_ERROR(contract_.Initialize(node)); contract_.SetNodeName( CanonicalNodeName(validated_graph.Config(), node_index)); @@ -228,7 +229,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { for (const auto& input_stream_info : node.input_stream_info()) { std::string tag; int index; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( tool::ParseTagIndex(input_stream_info.tag_index(), &tag, &index)); CollectionItemId id = contract_.Inputs().GetId(tag, index); if (!id.IsValid()) { @@ -260,8 +261,8 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { } #endif LegacyCalculatorSupport::Scoped s(&contract_); - RETURN_IF_ERROR(VerifyCalculatorWithContract(validated_graph.Package(), - node_class, &contract_)); + MP_RETURN_IF_ERROR(VerifyCalculatorWithContract(validated_graph.Package(), + node_class, &contract_)); // Validate result of FillExpectations or GetContract. std::vector<::mediapipe::Status> statuses; @@ -303,7 +304,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { const PacketGeneratorConfig& node, int node_index) { node_.type = NodeType::PACKET_GENERATOR; node_.index = node_index; - RETURN_IF_ERROR(contract_.Initialize(node)); + MP_RETURN_IF_ERROR(contract_.Initialize(node)); // Run FillExpectations. const std::string& node_class = node.packet_generator(); @@ -314,9 +315,9 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { _ << "Unable to find PacketGenerator \"" << node_class << "\""); { LegacyCalculatorSupport::Scoped s(&contract_); - RETURN_IF_ERROR(static_access->FillExpectations( - node.options(), &contract_.InputSidePackets(), - &contract_.OutputSidePackets())) + MP_RETURN_IF_ERROR(static_access->FillExpectations( + node.options(), &contract_.InputSidePackets(), + &contract_.OutputSidePackets())) .SetPrepend() << node_class << ": "; } @@ -345,7 +346,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { const StatusHandlerConfig& node, int node_index) { node_.type = NodeType::STATUS_HANDLER; node_.index = node_index; - RETURN_IF_ERROR(contract_.Initialize(node)); + MP_RETURN_IF_ERROR(contract_.Initialize(node)); // Run FillExpectations. const std::string& node_class = node.status_handler(); @@ -356,14 +357,14 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { _ << "Unable to find StatusHandler \"" << node_class << "\""); { LegacyCalculatorSupport::Scoped s(&contract_); - RETURN_IF_ERROR(static_access->FillExpectations( - node.options(), &contract_.InputSidePackets())) + MP_RETURN_IF_ERROR(static_access->FillExpectations( + node.options(), &contract_.InputSidePackets())) .SetPrepend() << node_class << ": "; } // Validate result of FillExpectations. - RETURN_IF_ERROR(ValidatePacketTypeSet(contract_.InputSidePackets())) + MP_RETURN_IF_ERROR(ValidatePacketTypeSet(contract_.InputSidePackets())) .SetPrepend() << node_class << "::FillExpectations failed to validate: "; return ::mediapipe::OkStatus(); @@ -380,13 +381,13 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { << input_config.DebugString(); #endif - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( PerformBasicTransforms(input_config, graph_registry, &config_)); // Initialize the basic node information. - RETURN_IF_ERROR(InitializeGeneratorInfo()); - RETURN_IF_ERROR(InitializeCalculatorInfo()); - RETURN_IF_ERROR(InitializeStatusHandlerInfo()); + MP_RETURN_IF_ERROR(InitializeGeneratorInfo()); + MP_RETURN_IF_ERROR(InitializeCalculatorInfo()); + MP_RETURN_IF_ERROR(InitializeStatusHandlerInfo()); sorted_nodes_.reserve(generators_.size() + calculators_.size()); // Initialize sorted_nodes_ to list generators before calculators. @@ -407,11 +408,11 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { // Initialize the side packet information. bool need_sorting = false; - RETURN_IF_ERROR(InitializeSidePacketInfo(&need_sorting)); + MP_RETURN_IF_ERROR(InitializeSidePacketInfo(&need_sorting)); // Initialize the stream information. - RETURN_IF_ERROR(InitializeStreamInfo(&need_sorting)); + MP_RETURN_IF_ERROR(InitializeStreamInfo(&need_sorting)); if (need_sorting) { - RETURN_IF_ERROR(TopologicalSortNodes()); + MP_RETURN_IF_ERROR(TopologicalSortNodes()); // Clear the information from the unsorted analysis. side_packet_to_producer_.clear(); @@ -424,26 +425,27 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { owned_packet_types_.clear(); // Recompute on sorted graph. - RETURN_IF_ERROR(InitializeSidePacketInfo(nullptr)); - RETURN_IF_ERROR(InitializeStreamInfo(nullptr)); + MP_RETURN_IF_ERROR(InitializeSidePacketInfo(nullptr)); + MP_RETURN_IF_ERROR(InitializeStreamInfo(nullptr)); } // Fill in all the upstream fields now that we are assured of having // things in the right order and all the output streams have been // created. - RETURN_IF_ERROR(FillUpstreamFieldForBackEdges()); + MP_RETURN_IF_ERROR(FillUpstreamFieldForBackEdges()); // Set Any types based on what they connect to. - RETURN_IF_ERROR(ResolveAnyTypes(&input_streams_, &output_streams_)); - RETURN_IF_ERROR(ResolveAnyTypes(&input_side_packets_, &output_side_packets_)); + MP_RETURN_IF_ERROR(ResolveAnyTypes(&input_streams_, &output_streams_)); + MP_RETURN_IF_ERROR( + ResolveAnyTypes(&input_side_packets_, &output_side_packets_)); // Validate consistency of side packets and streams. - RETURN_IF_ERROR(ValidateSidePacketTypes()); - RETURN_IF_ERROR(ValidateStreamTypes()); + MP_RETURN_IF_ERROR(ValidateSidePacketTypes()); + MP_RETURN_IF_ERROR(ValidateStreamTypes()); - RETURN_IF_ERROR(ComputeSourceDependence()); + MP_RETURN_IF_ERROR(ComputeSourceDependence()); - RETURN_IF_ERROR(ValidateExecutors()); + MP_RETURN_IF_ERROR(ValidateExecutors()); #if !defined(MEDIAPIPE_MOBILE) VLOG(1) << "ValidatedGraphConfig produced canonical config:\n" @@ -459,7 +461,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { graph_registry = graph_registry ? graph_registry : &GraphRegistry::global_graph_registry; auto status_or_config = graph_registry->CreateByName("", graph_type, options); - RETURN_IF_ERROR(status_or_config.status()); + MP_RETURN_IF_ERROR(status_or_config.status()); return Initialize(status_or_config.ValueOrDie(), graph_registry); } @@ -525,8 +527,8 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { ::mediapipe::Status ValidatedGraphConfig::InitializeSidePacketInfo( bool* need_sorting_ptr) { for (NodeTypeInfo* node_type_info : sorted_nodes_) { - RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info)); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info)); + MP_RETURN_IF_ERROR( AddOutputSidePacketsForNode(node_type_info, need_sorting_ptr)); } if (need_sorting_ptr && *need_sorting_ptr) { @@ -537,7 +539,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { RET_CHECK(node_type_info->Node().type == NodeTypeInfo::NodeType::STATUS_HANDLER); RET_CHECK_EQ(node_type_info->Node().index, index); - RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info)); + MP_RETURN_IF_ERROR(AddInputSidePacketsForNode(node_type_info)); } return ::mediapipe::OkStatus(); } @@ -616,7 +618,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { NodeTypeInfo::NodeRef virtual_node{ NodeTypeInfo::NodeType::GRAPH_INPUT_STREAM, index + config_.node_size()}; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( AddOutputStream(virtual_node, name, owned_packet_types_.back().get())); } @@ -624,12 +626,13 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { RET_CHECK(node_type_info.Node().type == NodeTypeInfo::NodeType::CALCULATOR); // Add input streams before outputs (so back edges from a node to // itself must be marked). - RETURN_IF_ERROR(AddInputStreamsForNode(&node_type_info, need_sorting_ptr)); - RETURN_IF_ERROR(AddOutputStreamsForNode(&node_type_info)); + MP_RETURN_IF_ERROR( + AddInputStreamsForNode(&node_type_info, need_sorting_ptr)); + MP_RETURN_IF_ERROR(AddOutputStreamsForNode(&node_type_info)); } // Validate tag-name-indexes for graph output streams. - RETURN_IF_ERROR(tool::TagMap::Create(config_.output_stream()).status()); + MP_RETURN_IF_ERROR(tool::TagMap::Create(config_.output_stream()).status()); return ::mediapipe::OkStatus(); } @@ -639,7 +642,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { node_type_info->SetOutputStreamBaseIndex(output_streams_.size()); const tool::TagMap& tag_map = *node_type_info->OutputStreamTypes().TagMap(); for (CollectionItemId id = tag_map.BeginId(); id < tag_map.EndId(); ++id) { - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( AddOutputStream(node_type_info->Node(), tag_map.Names()[id.value()], &node_type_info->OutputStreamTypes().Get(id))); } @@ -677,7 +680,7 @@ std::string NodeTypeInfo::NodeTypeToString(NodeType node_type) { if (input_stream_info.back_edge()) { std::string tag; int index; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( tool::ParseTagIndex(input_stream_info.tag_index(), &tag, &index)); CollectionItemId id = input_stream_types.GetId(tag, index); RET_CHECK(id.IsValid()); diff --git a/mediapipe/gpu/BUILD b/mediapipe/gpu/BUILD index 95e1959d7..46f2384e7 100644 --- a/mediapipe/gpu/BUILD +++ b/mediapipe/gpu/BUILD @@ -160,7 +160,6 @@ cc_library( "//conditions:default": [], "//mediapipe:apple": [ "-x objective-c++", - "-std=c++11", "-fobjc-arc", ], }), @@ -245,7 +244,6 @@ objc_library( srcs = ["pixel_buffer_pool_util.mm"], hdrs = ["pixel_buffer_pool_util.h"], copts = [ - "-std=c++11", "-Wno-shorten-64-to-32", ], sdk_frameworks = [ @@ -263,7 +261,6 @@ objc_library( hdrs = ["MPPGraphGPUData.h"], copts = [ "-x objective-c++", - "-std=c++11", "-Wno-shorten-64-to-32", ], sdk_frameworks = [ @@ -541,7 +538,6 @@ objc_library( srcs = HELPER_COMMON_SRCS + HELPER_IOS_SRCS, hdrs = HELPER_COMMON_HDRS, copts = [ - "-std=c++11", "-Wno-shorten-64-to-32", ], sdk_frameworks = HELPER_IOS_FRAMEWORKS, @@ -565,7 +561,6 @@ objc_library( srcs = ["MPPMetalHelper.mm"], hdrs = ["MPPMetalHelper.h"], copts = [ - "-std=c++11", "-Wno-shorten-64-to-32", ], sdk_frameworks = [ @@ -779,7 +774,6 @@ mediapipe_cc_proto_library( objc_library( name = "metal_copy_calculator", srcs = ["MetalCopyCalculator.mm"], - copts = ["-std=c++11"], sdk_frameworks = [ "CoreVideo", "Metal", @@ -797,7 +791,6 @@ objc_library( objc_library( name = "metal_rgb_weight_calculator", srcs = ["MetalRgbWeightCalculator.mm"], - copts = ["-std=c++11"], sdk_frameworks = [ "CoreVideo", "Metal", @@ -814,7 +807,6 @@ objc_library( objc_library( name = "metal_sobel_calculator", srcs = ["MetalSobelCalculator.mm"], - copts = ["-std=c++11"], sdk_frameworks = [ "CoreVideo", "Metal", @@ -831,7 +823,6 @@ objc_library( objc_library( name = "metal_sobel_compute_calculator", srcs = ["MetalSobelComputeCalculator.mm"], - copts = ["-std=c++11"], sdk_frameworks = [ "CoreVideo", "Metal", @@ -848,7 +839,6 @@ objc_library( objc_library( name = "mps_sobel_calculator", srcs = ["MPSSobelCalculator.mm"], - copts = ["-std=c++11"], sdk_frameworks = [ "CoreVideo", "Metal", @@ -882,7 +872,6 @@ objc_library( "gl_ios_test.mm", ], copts = [ - "-std=c++11", "-Wno-shorten-64-to-32", ], data = [ diff --git a/mediapipe/gpu/gl_context.cc b/mediapipe/gpu/gl_context.cc index a3e85b901..a6237f376 100644 --- a/mediapipe/gpu/gl_context.cc +++ b/mediapipe/gpu/gl_context.cc @@ -206,7 +206,7 @@ bool GlContext::ParseGlVersion(absl::string_view version_string, GLint* major, ::mediapipe::Status GlContext::FinishInitialization(bool create_thread) { if (create_thread) { thread_ = absl::make_unique(); - RETURN_IF_ERROR(thread_->Run([this] { return EnterContext(nullptr); })); + MP_RETURN_IF_ERROR(thread_->Run([this] { return EnterContext(nullptr); })); } return Run([this]() -> ::mediapipe::Status { @@ -294,7 +294,7 @@ void GlContext::SetProfilingContext( LogUncheckedGlErrors(had_gl_errors); } else { ContextBinding saved_context; - RETURN_IF_ERROR(EnterContext(&saved_context)); + MP_RETURN_IF_ERROR(EnterContext(&saved_context)); if (profiling_helper_) { profiling_helper_->MarkTimestamp(node_id, input_timestamp, /*is_finish=*/false); @@ -305,7 +305,7 @@ void GlContext::SetProfilingContext( /*is_finish=*/true); } LogUncheckedGlErrors(CheckForGlErrors()); - RETURN_IF_ERROR(ExitContext(&saved_context)); + MP_RETURN_IF_ERROR(ExitContext(&saved_context)); } return status; } @@ -371,7 +371,7 @@ std::weak_ptr& GlContext::CurrentContext() { // old one (we may be deliberately trying to exit it). // 2. We need to unset the old context before we unlock the old mutex, // Therefore, we first unset the old one before setting the new one. - RETURN_IF_ERROR(SetCurrentContextBinding({})); + MP_RETURN_IF_ERROR(SetCurrentContextBinding({})); old_context_obj->context_use_mutex_.Unlock(); CurrentContext().reset(); } diff --git a/mediapipe/gpu/gl_context_eagl.cc b/mediapipe/gpu/gl_context_eagl.cc index 34b1d0a2f..ed8ba11c1 100644 --- a/mediapipe/gpu/gl_context_eagl.cc +++ b/mediapipe/gpu/gl_context_eagl.cc @@ -48,8 +48,8 @@ GlContext::StatusOrGlContext GlContext::Create(EAGLContext* share_context, GlContext::StatusOrGlContext GlContext::Create(EAGLSharegroup* sharegroup, bool create_thread) { std::shared_ptr context(new GlContext()); - RETURN_IF_ERROR(context->CreateContext(sharegroup)); - RETURN_IF_ERROR(context->FinishInitialization(create_thread)); + MP_RETURN_IF_ERROR(context->CreateContext(sharegroup)); + MP_RETURN_IF_ERROR(context->FinishInitialization(create_thread)); return std::move(context); } diff --git a/mediapipe/gpu/gl_context_egl.cc b/mediapipe/gpu/gl_context_egl.cc index a8f12d7ec..5a57b32db 100644 --- a/mediapipe/gpu/gl_context_egl.cc +++ b/mediapipe/gpu/gl_context_egl.cc @@ -80,8 +80,8 @@ GlContext::StatusOrGlContext GlContext::Create(const GlContext& share_context, GlContext::StatusOrGlContext GlContext::Create(EGLContext share_context, bool create_thread) { std::shared_ptr context(new GlContext()); - RETURN_IF_ERROR(context->CreateContext(share_context)); - RETURN_IF_ERROR(context->FinishInitialization(create_thread)); + MP_RETURN_IF_ERROR(context->CreateContext(share_context)); + MP_RETURN_IF_ERROR(context->FinishInitialization(create_thread)); return std::move(context); } @@ -156,7 +156,7 @@ GlContext::StatusOrGlContext GlContext::Create(EGLContext share_context, LOG(WARNING) << "Fall back on OpenGL ES 2."; status = CreateContextInternal(external_context, 2); } - RETURN_IF_ERROR(status); + MP_RETURN_IF_ERROR(status); EGLint pbuffer_attr[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; diff --git a/mediapipe/gpu/gl_context_nsgl.cc b/mediapipe/gpu/gl_context_nsgl.cc index 8a43415ae..0f2244ca6 100644 --- a/mediapipe/gpu/gl_context_nsgl.cc +++ b/mediapipe/gpu/gl_context_nsgl.cc @@ -39,8 +39,8 @@ GlContext::StatusOrGlContext GlContext::Create(const GlContext& share_context, GlContext::StatusOrGlContext GlContext::Create(NSOpenGLContext* share_context, bool create_thread) { std::shared_ptr context(new GlContext()); - RETURN_IF_ERROR(context->CreateContext(share_context)); - RETURN_IF_ERROR(context->FinishInitialization(create_thread)); + MP_RETURN_IF_ERROR(context->CreateContext(share_context)); + MP_RETURN_IF_ERROR(context->FinishInitialization(create_thread)); return std::move(context); } diff --git a/mediapipe/gpu/gl_context_webgl.cc b/mediapipe/gpu/gl_context_webgl.cc index f0d6a58fc..6853b7a10 100644 --- a/mediapipe/gpu/gl_context_webgl.cc +++ b/mediapipe/gpu/gl_context_webgl.cc @@ -40,8 +40,8 @@ GlContext::StatusOrGlContext GlContext::Create(const GlContext& share_context, GlContext::StatusOrGlContext GlContext::Create( EMSCRIPTEN_WEBGL_CONTEXT_HANDLE share_context, bool create_thread) { std::shared_ptr context(new GlContext()); - RETURN_IF_ERROR(context->CreateContext(share_context)); - RETURN_IF_ERROR(context->FinishInitialization(create_thread)); + MP_RETURN_IF_ERROR(context->CreateContext(share_context)); + MP_RETURN_IF_ERROR(context->FinishInitialization(create_thread)); return std::move(context); } @@ -95,7 +95,7 @@ GlContext::StatusOrGlContext GlContext::Create( LOG(WARNING) << "Fall back on WebGL 1."; status = CreateContextInternal(external_context, 1); } - RETURN_IF_ERROR(status); + MP_RETURN_IF_ERROR(status); LOG(INFO) << "Successfully created a WebGL Context with major version " << gl_major_version_ << " and context " << context_; diff --git a/mediapipe/gpu/gl_scaler_calculator.cc b/mediapipe/gpu/gl_scaler_calculator.cc index 08c532150..d28cd4cfd 100644 --- a/mediapipe/gpu/gl_scaler_calculator.cc +++ b/mediapipe/gpu/gl_scaler_calculator.cc @@ -102,7 +102,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); if (cc->Inputs().HasTag("ROTATION")) { cc->Inputs().Tag("ROTATION").Set(); } - RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); if (cc->InputSidePackets().HasTag("OPTIONS")) { cc->InputSidePackets().Tag("OPTIONS").Set(); @@ -130,7 +130,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); cc->SetOffset(mediapipe::TimestampDiff(0)); // Let the helper access the GL context information. - RETURN_IF_ERROR(helper_.Open(cc)); + MP_RETURN_IF_ERROR(helper_.Open(cc)); int rotation_ccw = 0; const auto& options = @@ -171,7 +171,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); rotation_ccw = cc->InputSidePackets().Tag("ROTATION").Get(); } - RETURN_IF_ERROR(FrameRotationFromInt(&rotation_, rotation_ccw)); + MP_RETURN_IF_ERROR(FrameRotationFromInt(&rotation_, rotation_ccw)); return ::mediapipe::OkStatus(); } @@ -188,7 +188,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); input.format() == GpuBufferFormat::kBiPlanar420YpCbCr8FullRange) { if (!yuv_renderer_) { yuv_renderer_ = absl::make_unique(); - RETURN_IF_ERROR(yuv_renderer_->GlSetup( + MP_RETURN_IF_ERROR(yuv_renderer_->GlSetup( kYUV2TexToRGBFragmentShader, {"video_frame_y", "video_frame_uv"})); } renderer = yuv_renderer_.get(); @@ -202,7 +202,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); if (src1.target() == GL_TEXTURE_EXTERNAL_OES) { if (!ext_rgb_renderer_) { ext_rgb_renderer_ = absl::make_unique(); - RETURN_IF_ERROR(ext_rgb_renderer_->GlSetup( + MP_RETURN_IF_ERROR(ext_rgb_renderer_->GlSetup( kBasicTexturedFragmentShaderOES, {"video_frame"})); } renderer = ext_rgb_renderer_.get(); @@ -211,7 +211,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); { if (!rgb_renderer_) { rgb_renderer_ = absl::make_unique(); - RETURN_IF_ERROR(rgb_renderer_->GlSetup()); + MP_RETURN_IF_ERROR(rgb_renderer_->GlSetup()); } renderer = rgb_renderer_.get(); } @@ -221,7 +221,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); // Override input side packet if ROTATION input packet is provided. if (cc->Inputs().HasTag("ROTATION")) { int rotation_ccw = cc->Inputs().Tag("ROTATION").Get(); - RETURN_IF_ERROR(FrameRotationFromInt(&rotation_, rotation_ccw)); + MP_RETURN_IF_ERROR(FrameRotationFromInt(&rotation_, rotation_ccw)); } int dst_width; @@ -255,7 +255,7 @@ REGISTER_CALCULATOR(GlScalerCalculator); glBindTexture(src2.target(), src2.name()); } - RETURN_IF_ERROR(renderer->GlRender( + MP_RETURN_IF_ERROR(renderer->GlRender( src1.width(), src1.height(), dst.width(), dst.height(), scale_mode_, rotation_, horizontal_flip_output_, vertical_flip_output_, /*flip_texture*/ false)); diff --git a/mediapipe/gpu/gl_simple_calculator.cc b/mediapipe/gpu/gl_simple_calculator.cc index e654aa5ee..3d4219b84 100644 --- a/mediapipe/gpu/gl_simple_calculator.cc +++ b/mediapipe/gpu/gl_simple_calculator.cc @@ -38,7 +38,7 @@ namespace mediapipe { return RunInGlContext([this, cc]() -> ::mediapipe::Status { const auto& input = TagOrIndex(cc->Inputs(), "VIDEO", 0).Get(); if (!initialized_) { - RETURN_IF_ERROR(GlSetup()); + MP_RETURN_IF_ERROR(GlSetup()); initialized_ = true; } @@ -53,9 +53,9 @@ namespace mediapipe { glActiveTexture(GL_TEXTURE1); glBindTexture(src.target(), src.name()); - RETURN_IF_ERROR(GlBind()); + MP_RETURN_IF_ERROR(GlBind()); // Run core program. - RETURN_IF_ERROR(GlRender(src, dst)); + MP_RETURN_IF_ERROR(GlRender(src, dst)); glBindTexture(src.target(), 0); diff --git a/mediapipe/gpu/gl_surface_sink_calculator.cc b/mediapipe/gpu/gl_surface_sink_calculator.cc index e80bd29f9..6ab0b094f 100644 --- a/mediapipe/gpu/gl_surface_sink_calculator.cc +++ b/mediapipe/gpu/gl_surface_sink_calculator.cc @@ -94,7 +94,7 @@ REGISTER_CALCULATOR(GlSurfaceSinkCalculator); const auto& input = TagOrIndex(cc->Inputs(), "VIDEO", 0).Get(); if (!initialized_) { renderer_ = absl::make_unique(); - RETURN_IF_ERROR(renderer_->GlSetup()); + MP_RETURN_IF_ERROR(renderer_->GlSetup()); initialized_ = true; } @@ -124,7 +124,7 @@ REGISTER_CALCULATOR(GlSurfaceSinkCalculator); glActiveTexture(GL_TEXTURE1); glBindTexture(src.target(), src.name()); - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( renderer_->GlRender(src.width(), src.height(), dst_width, dst_height, scale_mode_, FrameRotation::kNone, /*flip_horizontal=*/false, /*flip_vertical=*/false, diff --git a/mediapipe/gpu/gpu_buffer_to_image_frame_calculator.cc b/mediapipe/gpu/gpu_buffer_to_image_frame_calculator.cc index 9732de5bd..aa40ae19a 100644 --- a/mediapipe/gpu/gpu_buffer_to_image_frame_calculator.cc +++ b/mediapipe/gpu/gpu_buffer_to_image_frame_calculator.cc @@ -51,7 +51,7 @@ REGISTER_CALCULATOR(GpuBufferToImageFrameCalculator); // Note: we call this method even on platforms where we don't use the helper, // to ensure the calculator's contract is the same. In particular, the helper // enables support for the legacy side packet, which several graphs still use. - RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); return ::mediapipe::OkStatus(); } @@ -61,7 +61,7 @@ REGISTER_CALCULATOR(GpuBufferToImageFrameCalculator); // as we receive a packet at. cc->SetOffset(TimestampDiff(0)); #if !MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER - RETURN_IF_ERROR(helper_.Open(cc)); + MP_RETURN_IF_ERROR(helper_.Open(cc)); #endif // MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER return ::mediapipe::OkStatus(); } diff --git a/mediapipe/gpu/image_frame_to_gpu_buffer_calculator.cc b/mediapipe/gpu/image_frame_to_gpu_buffer_calculator.cc index c3e4c13b7..8abb43d71 100644 --- a/mediapipe/gpu/image_frame_to_gpu_buffer_calculator.cc +++ b/mediapipe/gpu/image_frame_to_gpu_buffer_calculator.cc @@ -48,7 +48,7 @@ REGISTER_CALCULATOR(ImageFrameToGpuBufferCalculator); // Note: we call this method even on platforms where we don't use the helper, // to ensure the calculator's contract is the same. In particular, the helper // enables support for the legacy side packet, which several graphs still use. - RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); + MP_RETURN_IF_ERROR(GlCalculatorHelper::UpdateContract(cc)); return ::mediapipe::OkStatus(); } @@ -58,7 +58,7 @@ REGISTER_CALCULATOR(ImageFrameToGpuBufferCalculator); // as we receive a packet at. cc->SetOffset(TimestampDiff(0)); #if !MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER - RETURN_IF_ERROR(helper_.Open(cc)); + MP_RETURN_IF_ERROR(helper_.Open(cc)); #endif // !MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER return ::mediapipe::OkStatus(); } @@ -67,7 +67,7 @@ REGISTER_CALCULATOR(ImageFrameToGpuBufferCalculator); CalculatorContext* cc) { #if MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER CFHolder buffer; - RETURN_IF_ERROR(CreateCVPixelBufferForImageFramePacket( + MP_RETURN_IF_ERROR(CreateCVPixelBufferForImageFramePacket( cc->Inputs().Index(0).Value(), &buffer)); cc->Outputs().Index(0).Add(new GpuBuffer(buffer), cc->InputTimestamp()); #else diff --git a/mediapipe/util/BUILD b/mediapipe/util/BUILD index c0602d4e9..c7a4ba95b 100644 --- a/mediapipe/util/BUILD +++ b/mediapipe/util/BUILD @@ -52,7 +52,7 @@ mediapipe_cc_proto_library( name = "render_data_cc_proto", srcs = ["render_data.proto"], cc_deps = [":color_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":render_data_proto"], ) @@ -60,7 +60,7 @@ mediapipe_cc_proto_library( name = "audio_decoder_cc_proto", srcs = ["audio_decoder.proto"], cc_deps = ["//mediapipe/framework:calculator_cc_proto"], - visibility = ["//mediapipe:__subpackages__"], + visibility = ["//visibility:public"], deps = [":audio_decoder_proto"], ) @@ -181,7 +181,6 @@ cc_library( copts = select({ "//conditions:default": [], "//mediapipe:apple": [ - "-std=c++11", "-ObjC++", ], "//mediapipe:macos": [], diff --git a/mediapipe/util/android/asset_manager_util.cc b/mediapipe/util/android/asset_manager_util.cc index 1340657b4..dffff9b73 100644 --- a/mediapipe/util/android/asset_manager_util.cc +++ b/mediapipe/util/android/asset_manager_util.cc @@ -128,7 +128,7 @@ bool AssetManager::ReadFile(const std::string& filename, << "could not read asset: " << asset_path; std::string dir_path = File::StripBasename(file_path); - RETURN_IF_ERROR(file::RecursivelyCreateDir(dir_path, file::Defaults())); + MP_RETURN_IF_ERROR(file::RecursivelyCreateDir(dir_path, file::Defaults())); std::ofstream output_file(file_path); RET_CHECK(output_file.good()) << "could not open cache file: " << file_path; diff --git a/mediapipe/util/audio_decoder.cc b/mediapipe/util/audio_decoder.cc index 3cc8082a2..4f284f106 100644 --- a/mediapipe/util/audio_decoder.cc +++ b/mediapipe/util/audio_decoder.cc @@ -250,7 +250,7 @@ mediapipe::Status BasePacketProcessor::Flush() { // ProcessPacket increments num_frames_processed_ if it is able to // decode a frame. Not being able to decode a frame while being // flushed signals that the codec is completely done. - RETURN_IF_ERROR(ProcessPacket(av_packet.get())); + MP_RETURN_IF_ERROR(ProcessPacket(av_packet.get())); } while (last_num_frames_processed != num_frames_processed_); flushed_ = true; @@ -275,17 +275,17 @@ void BasePacketProcessor::Close() { mediapipe::Status BasePacketProcessor::Decode(const AVPacket& packet, bool ignore_decode_failures) { - RETURN_IF_ERROR(LogStatus(SendPacket(packet, avcodec_ctx_), *avcodec_ctx_, - packet, ignore_decode_failures)); + MP_RETURN_IF_ERROR(LogStatus(SendPacket(packet, avcodec_ctx_), *avcodec_ctx_, + packet, ignore_decode_failures)); while (true) { bool received; - RETURN_IF_ERROR( + MP_RETURN_IF_ERROR( LogStatus(ReceiveFrame(avcodec_ctx_, decoded_frame_, &received), *avcodec_ctx_, packet, ignore_decode_failures)); if (received) { // Successfully decoded a frame (i.e., received it from the decoder). Now // further process it. - RETURN_IF_ERROR(ProcessDecodedFrame(packet)); + MP_RETURN_IF_ERROR(ProcessDecodedFrame(packet)); } else { break; } @@ -359,7 +359,7 @@ mediapipe::Status AudioPacketProcessor::Open(int id, source_frame_rate_ = stream->r_frame_rate; last_frame_time_regression_detected_ = false; - RETURN_IF_ERROR(ValidateSampleFormat()); + MP_RETURN_IF_ERROR(ValidateSampleFormat()); bytes_per_sample_ = av_get_bytes_per_sample(avcodec_ctx_->sample_fmt); num_channels_ = avcodec_ctx_->channels; sample_rate_ = avcodec_ctx_->sample_rate; @@ -468,7 +468,7 @@ mediapipe::Status AudioPacketProcessor::ProcessDecodedFrame( } } - RETURN_IF_ERROR(AddAudioDataToBuffer( + MP_RETURN_IF_ERROR(AddAudioDataToBuffer( Timestamp(av_rescale_q(expected_sample_number_, sample_time_base_, output_time_base_)), data_ptr, buf_size_bytes)); @@ -653,7 +653,7 @@ AudioDecoder::~AudioDecoder() { << audio_processor_[stream_id].get(); } - RETURN_IF_ERROR(processor->Open(stream_id, stream)); + MP_RETURN_IF_ERROR(processor->Open(stream_id, stream)); audio_processor_.emplace(stream_id, std::move(processor)); CHECK(InsertIfNotPresent( &stream_index_to_stream_id_, @@ -732,10 +732,10 @@ AudioDecoder::~AudioDecoder() { } } if (flushed_) { - RETURN_IF_ERROR(Close()); + MP_RETURN_IF_ERROR(Close()); return tool::StatusStop(); } - RETURN_IF_ERROR(ProcessPacket()); + MP_RETURN_IF_ERROR(ProcessPacket()); } return ::mediapipe::OkStatus(); } @@ -761,7 +761,7 @@ AudioDecoder::~AudioDecoder() { FindOrDie(stream_index_to_stream_id_, stream_option.stream_index())); RET_CHECK(processor_ptr_ && *processor_ptr_) << "audio stream is not open."; - RETURN_IF_ERROR((*processor_ptr_)->FillHeader(header)); + MP_RETURN_IF_ERROR((*processor_ptr_)->FillHeader(header)); return ::mediapipe::OkStatus(); } @@ -779,7 +779,8 @@ AudioDecoder::~AudioDecoder() { if (audio_iterator != audio_processor_.end()) { // This stream_id is belongs to an audio stream we care about. if (audio_iterator->second) { - RETURN_IF_ERROR(audio_iterator->second->ProcessPacket(av_packet.get())); + MP_RETURN_IF_ERROR( + audio_iterator->second->ProcessPacket(av_packet.get())); } else { VLOG(3) << "processor for stream " << stream_id << " is nullptr."; } diff --git a/mediapipe/util/sequence/media_sequence_test.cc b/mediapipe/util/sequence/media_sequence_test.cc index 6844cda46..26bfb6fc0 100644 --- a/mediapipe/util/sequence/media_sequence_test.cc +++ b/mediapipe/util/sequence/media_sequence_test.cc @@ -600,7 +600,7 @@ TEST(MediaSequenceTest, RoundTripOpticalFlowTimestamp) { TEST(MediaSequenceTest, ReconcileMetadataOnEmptySequence) { tensorflow::SequenceExample sequence; - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); } TEST(MediaSequenceTest, ReconcileMetadataImagestoLabels) { @@ -616,7 +616,7 @@ TEST(MediaSequenceTest, ReconcileMetadataImagestoLabels) { AddImageTimestamp(4, &sequence); AddImageTimestamp(5, &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_THAT(GetSegmentStartIndex(sequence), testing::ElementsAreArray({2, 3})); ASSERT_THAT(GetSegmentEndIndex(sequence), testing::ElementsAreArray({3, 4})); @@ -633,7 +633,7 @@ TEST(MediaSequenceTest, ReconcileMetadataImages) { AddImageTimestamp(1000000, &sequence); AddImageTimestamp(2000000, &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetContext(sequence, kImageFormatKey).bytes_list().value(0), "JPEG"); ASSERT_EQ(GetContext(sequence, kImageChannelsKey).int64_list().value(0), 3); @@ -654,7 +654,7 @@ TEST(MediaSequenceTest, ReconcileMetadataImagesPNG) { AddImageTimestamp(1000000, &sequence); AddImageTimestamp(2000000, &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetContext(sequence, kImageFormatKey).bytes_list().value(0), "PNG"); ASSERT_EQ(GetContext(sequence, kImageChannelsKey).int64_list().value(0), 3); ASSERT_EQ(GetContext(sequence, kImageWidthKey).int64_list().value(0), 3); @@ -675,7 +675,7 @@ TEST(MediaSequenceTest, ReconcileMetadataFlowEncoded) { AddForwardFlowTimestamp(1000000, &sequence); AddForwardFlowTimestamp(2000000, &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetForwardFlowFormat(sequence), "JPEG"); ASSERT_EQ(GetForwardFlowChannels(sequence), 3); ASSERT_EQ(GetForwardFlowWidth(sequence), 3); @@ -692,7 +692,7 @@ TEST(MediaSequenceTest, ReconcileMetadataFloats) { AddFeatureTimestamp(feature_name, 1000000, &sequence); AddFeatureTimestamp(feature_name, 2000000, &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetFeatureDimensions(feature_name, sequence).size(), 1); ASSERT_EQ(GetFeatureDimensions(feature_name, sequence)[0], 3); ASSERT_EQ(GetFeatureRate(feature_name, sequence), 1.0); @@ -708,7 +708,7 @@ TEST(MediaSequenceTest, ReconcileMetadataFloatsDoesntOverwrite) { AddFeatureTimestamp(feature_name, 1000000, &sequence); AddFeatureTimestamp(feature_name, 2000000, &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetFeatureDimensions(feature_name, sequence).size(), 3); ASSERT_EQ(GetFeatureDimensions(feature_name, sequence)[0], 1); ASSERT_EQ(GetFeatureDimensions(feature_name, sequence)[1], 3); @@ -751,7 +751,7 @@ TEST(MediaSequenceTest, AddBBox(bboxes[1], &sequence); AddBBox(bboxes[2], &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetBBoxTimestampSize(sequence), 3); ASSERT_EQ(GetBBoxTimestampAt(sequence, 0), 10); @@ -769,7 +769,7 @@ TEST(MediaSequenceTest, ASSERT_EQ(GetUnmodifiedBBoxTimestampAt(sequence, 1), 21); // A second reconciliation should not corrupt unmodified bbox timestamps. - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetBBoxTimestampSize(sequence), 3); ASSERT_EQ(GetBBoxTimestampAt(sequence, 0), 10); @@ -804,7 +804,7 @@ TEST(MediaSequenceTest, ReconcileMetadataBoxAnnotationsFillsMissing) { AddBBox(bboxes[1], &sequence); AddBBox(bboxes[2], &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetBBoxTimestampSize(sequence), 5); ASSERT_EQ(GetBBoxIsAnnotatedSize(sequence), 5); @@ -873,7 +873,7 @@ TEST(MediaSequenceTest, ReconcileMetadataBoxAnnotationsUpdatesAllFeatures) { AddBBox(bboxes[0], &sequence); AddBBox(bboxes[1], &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetBBoxTimestampSize(sequence), 5); ASSERT_EQ(GetBBoxIsAnnotatedSize(sequence), 5); @@ -1003,7 +1003,7 @@ TEST(MediaSequenceTest, ReconcileMetadataBoxAnnotationsDoesNotAddFields) { AddBBox(bboxes[1], &sequence); AddBBox(bboxes[2], &sequence); - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(true, false, &sequence)); ASSERT_EQ(GetBBoxTimestampSize(sequence), 5); ASSERT_EQ(GetBBoxIsAnnotatedSize(sequence), 5); ASSERT_FALSE(HasBBoxClassIndex(sequence)); @@ -1031,7 +1031,7 @@ TEST(MediaSequenceTest, ReconcileMetadataRegionAnnotations) { AddBBoxTimestamp("PREFIX", 22, &sequence); // Expect both the default and "PREFIX"-ed keys to be reconciled. - MEDIAPIPE_ASSERT_OK(ReconcileMetadata(false, true, &sequence)); + MP_ASSERT_OK(ReconcileMetadata(false, true, &sequence)); ASSERT_EQ(GetBBoxTimestampSize(sequence), 3); ASSERT_EQ(GetBBoxIsAnnotatedSize(sequence), 3); ASSERT_EQ(GetBBoxTimestampSize("PREFIX", sequence), 3); diff --git a/mediapipe/util/time_series_test_util.h b/mediapipe/util/time_series_test_util.h index 0371ec42b..9c72fd9bf 100644 --- a/mediapipe/util/time_series_test_util.h +++ b/mediapipe/util/time_series_test_util.h @@ -503,7 +503,7 @@ class BasicTimeSeriesCalculatorTestBase AppendInputPacket(new Matrix(input_packets[i]), timestamp); } - MEDIAPIPE_ASSERT_OK(RunGraph()); + MP_ASSERT_OK(RunGraph()); ExpectOutputHeaderEquals(expected_output_header); EXPECT_EQ(input().packets.size(), output().packets.size()); diff --git a/mediapipe/util/time_series_util_test.cc b/mediapipe/util/time_series_util_test.cc index 5f3e119b9..dc8f3b917 100644 --- a/mediapipe/util/time_series_util_test.cc +++ b/mediapipe/util/time_series_util_test.cc @@ -52,8 +52,7 @@ TEST(TimeSeriesUtilTest, FillTimeSeriesHeaderIfValid) { valid_header->set_num_channels(3); Packet valid_packet = Adopt(valid_header.release()); TimeSeriesHeader packet_header; - MEDIAPIPE_EXPECT_OK( - FillTimeSeriesHeaderIfValid(valid_packet, &packet_header)); + MP_EXPECT_OK(FillTimeSeriesHeaderIfValid(valid_packet, &packet_header)); EXPECT_EQ(packet_header.sample_rate(), 1234.5); EXPECT_EQ(packet_header.num_channels(), 3); } @@ -106,7 +105,7 @@ TEST(TimeSeriesUtilTest, FillMultiStreamTimeSeriesHeaderIfValid) { valid_header->mutable_time_series_header()->set_num_channels(3); Packet valid_packet = Adopt(valid_header.release()); MultiStreamTimeSeriesHeader packet_header; - MEDIAPIPE_EXPECT_OK( + MP_EXPECT_OK( FillMultiStreamTimeSeriesHeaderIfValid(valid_packet, &packet_header)); EXPECT_EQ(packet_header.time_series_header().sample_rate(), 1234.5); EXPECT_EQ(packet_header.time_series_header().num_channels(), 3);