From b6a47abf019881e419cc416a0dbc00fd28f670e5 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Fri, 23 Oct 2020 06:54:36 +0000 Subject: [PATCH] PtrBefore/PtrBoth/PtrAfter --- .../libtiff/example/main_sandboxed.cc | 12 ++++++------ .../libtiff/test/defer_strile_writing.cc | 4 ++-- oss-internship-2020/libtiff/test/long_tag.cc | 2 +- oss-internship-2020/libtiff/test/raw_decode.cc | 8 ++++---- oss-internship-2020/libtiff/test/short_tag.cc | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/oss-internship-2020/libtiff/example/main_sandboxed.cc b/oss-internship-2020/libtiff/example/main_sandboxed.cc index 5529f63..11e8a9e 100644 --- a/oss-internship-2020/libtiff/example/main_sandboxed.cc +++ b/oss-internship-2020/libtiff/example/main_sandboxed.cc @@ -196,7 +196,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) { sapi::v::UShort v; SAPI_ASSIGN_OR_RETURN(int return_value, api.TIFFGetField2(&tif, TIFFTAG_YCBCRSUBSAMPLING, - h.PtrBoth(), v.PtrBoth())); + h.PtrAfter(), v.PtrAfter())); if (return_value == 0 || h.GetValue() != 2 || v.GetValue() != 2) { return absl::InternalError("Could not retrieve subsampling tag"); } @@ -212,7 +212,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) { // Read a tile in decompressed form, but still YCbCr subsampled SAPI_ASSIGN_OR_RETURN( tsize_t new_sz, - api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrBoth(), sz)); + api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrAfter(), sz)); if (new_sz != sz) { return absl::InternalError(absl::StrCat( "Did not get expected result code from TIFFReadEncodedTile(): ", new_sz, @@ -246,10 +246,10 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) { kChannelsInPixel * kImageSize, " bytes")); } - sapi::v::Array buffer2_(sz); + sapi::v::Array buffer2(sz); SAPI_ASSIGN_OR_RETURN( new_sz, - api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2_.PtrBoth(), sz)); + api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2.PtrAfter(), sz)); if (new_sz != sz) { return absl::InternalError(absl::StrCat( "Did not get expected result code from TIFFReadEncodedTile(): ", new_sz, @@ -258,7 +258,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) { bool pixel_status_ok = true; for (const auto& [id, data] : kLimits) { - if (status = CheckRgbPixel(id, data, buffer2_); !status.ok()) { + if (status = CheckRgbPixel(id, data, buffer2); !status.ok()) { LOG(ERROR) << "CheckRgbPixel failed:\n" << status.ToString() << '\n'; } pixel_status_ok &= status.ok(); @@ -279,7 +279,7 @@ absl::Status LibTIFFMain(const absl::string_view srcfile) { // read as rgba SAPI_ASSIGN_OR_RETURN( return_value, - api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrBoth())); + api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrAfter())); if (return_value == 0) { return absl::InternalError("TIFFReadRGBATile() returned failure code"); } diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index e3b9847..017c2a8 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -216,7 +216,7 @@ void TestWriting(const char* mode, int tiled, int height) { tilebuffer.size()); status_or_int = api.TIFFWriteEncodedTile( - &tif, i, tilebuffer_sapi.PtrBoth(), kTileBufferSize); + &tif, i, tilebuffer_sapi.PtrBefore(), kTileBufferSize); ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteEncodedTile fatal error"; EXPECT_THAT(status_or_int.value(), Eq(kTileBufferSize)) << "line " << i << ": expected " << kTileBufferSize << ", got " @@ -225,7 +225,7 @@ void TestWriting(const char* mode, int tiled, int height) { } else { for (int i = 0; i < height; ++i) { sapi::v::UChar c(i); - status_or_long = api.TIFFWriteEncodedStrip(&tif, i, c.PtrBoth(), 1); + status_or_long = api.TIFFWriteEncodedStrip(&tif, i, c.PtrBefore(), 1); ASSERT_THAT(status_or_long, IsOk()) << "TIFFWriteEncodedStrip fatal error"; EXPECT_THAT(status_or_int.value(), Eq(1)) diff --git a/oss-internship-2020/libtiff/test/long_tag.cc b/oss-internship-2020/libtiff/test/long_tag.cc index c9f465e..5843e35 100644 --- a/oss-internship-2020/libtiff/test/long_tag.cc +++ b/oss-internship-2020/libtiff/test/long_tag.cc @@ -106,7 +106,7 @@ TEST(SandboxTest, LongTag) { std::array buffer = {0, 127, 255}; sapi::v::Array buffer_sapi(buffer.data(), buffer.size()); - status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBoth(), 0, 0); + status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBefore(), 0, 0); ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteScanline fatal error"; ASSERT_THAT(status_or_int.value(), Ne(-1)) << "Can't write image data"; diff --git a/oss-internship-2020/libtiff/test/raw_decode.cc b/oss-internship-2020/libtiff/test/raw_decode.cc index 2cea127..83b7edc 100644 --- a/oss-internship-2020/libtiff/test/raw_decode.cc +++ b/oss-internship-2020/libtiff/test/raw_decode.cc @@ -125,7 +125,7 @@ TEST(SandboxTest, RawDecode) { sapi::v::UShort h; sapi::v::UShort v; absl::StatusOr status_or_int = api.TIFFGetField2( - &tif, TIFFTAG_YCBCRSUBSAMPLING, h.PtrBoth(), v.PtrBoth()); + &tif, TIFFTAG_YCBCRSUBSAMPLING, h.PtrAfter(), v.PtrAfter()); ASSERT_THAT(status_or_int, IsOk()) << "TIFFGetField2 fatal error"; EXPECT_THAT( status_or_int.value() == 0 || h.GetValue() != 2 || v.GetValue() != 2, @@ -143,7 +143,7 @@ TEST(SandboxTest, RawDecode) { sapi::v::Array buffer(sz); // Read a tile in decompressed form, but still YCbCr subsampled status_or_long = - api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrBoth(), sz); + api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer.PtrAfter(), sz); ASSERT_THAT(status_or_long, IsOk()) << "TIFFReadEncodedTile fatal error"; EXPECT_THAT(status_or_long.value(), Eq(sz)) << "Did not get expected result code from TIFFReadEncodedTile()(" @@ -169,7 +169,7 @@ TEST(SandboxTest, RawDecode) { sapi::v::Array buffer2(sz); status_or_long = - api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2.PtrBoth(), sz); + api.TIFFReadEncodedTile(&tif, kRawTileNumber, buffer2.PtrAfter(), sz); ASSERT_THAT(status_or_long, IsOk()) << "TIFFReadEncodedTile fatal error"; EXPECT_THAT(status_or_long.value(), Eq(sz)) << "Did not get expected result code from TIFFReadEncodedTile()(" @@ -190,7 +190,7 @@ TEST(SandboxTest, RawDecode) { sapi::v::Array rgba_buffer(kImageSize); status_or_int = - api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrBoth()); + api.TIFFReadRGBATile(&tif2, 1 * 128, 2 * 128, rgba_buffer.PtrAfter()); ASSERT_THAT(status_or_int, IsOk()) << "TIFFReadRGBATile fatal error"; EXPECT_THAT(status_or_int.value(), IsTrue()) << "TIFFReadRGBATile() returned failure code"; diff --git a/oss-internship-2020/libtiff/test/short_tag.cc b/oss-internship-2020/libtiff/test/short_tag.cc index f9da1ba..f2c1d6b 100644 --- a/oss-internship-2020/libtiff/test/short_tag.cc +++ b/oss-internship-2020/libtiff/test/short_tag.cc @@ -135,7 +135,7 @@ TEST(SandboxTest, ShortTag) { std::array buffer = {0, 127, 255}; sapi::v::Array buffer_sapi(buffer.data(), buffer.size()); - status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBoth(), 0, 0); + status_or_int = api.TIFFWriteScanline(&tif, buffer_sapi.PtrBefore(), 0, 0); ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteScanline fatal error"; ASSERT_THAT(status_or_int.value(), Ne(-1)) << "Can't write image data";