#ifndef TENSORFLOW_LITE_SUPPORT_CC_TASK_VISION_UTILS_FRAME_BUFFER_COMMON_UTILS_H_
#define TENSORFLOW_LITE_SUPPORT_CC_TASK_VISION_UTILS_FRAME_BUFFER_COMMON_UTILS_H_
#include <memory>
#include "absl/status/status.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "tensorflow_lite_support/cc/port/integral_types.h"
#include "tensorflow_lite_support/cc/port/statusor.h"
#include "tensorflow_lite_support/cc/task/vision/core/frame_buffer.h"
namespace tflite {
namespace task {
namespace vision {
constexpr int kRgbaPixelBytes = …, kRgbPixelBytes = …, kGrayPixelBytes = …;
inline constexpr FrameBuffer::Stride kDefaultStride = …;
int GetFrameBufferByteSize(FrameBuffer::Dimension dimension,
FrameBuffer::Format format);
tflite::support::StatusOr<int> GetPixelStrides(FrameBuffer::Format format);
tflite::support::StatusOr<const uint8*> GetUvRawBuffer(
const FrameBuffer& buffer);
tflite::support::StatusOr<FrameBuffer::Dimension> GetUvPlaneDimension(
FrameBuffer::Dimension dimension, FrameBuffer::Format format);
FrameBuffer::Dimension GetCropDimension(int x0, int x1, int y0, int y1);
absl::Status ValidateBufferPlaneMetadata(const FrameBuffer& buffer);
absl::Status ValidateBufferFormat(const FrameBuffer& buffer);
absl::Status ValidateBufferFormats(const FrameBuffer& buffer1,
const FrameBuffer& buffer2);
absl::Status ValidateResizeBufferInputs(const FrameBuffer& buffer,
const FrameBuffer& output_buffer);
absl::Status ValidateRotateBufferInputs(const FrameBuffer& buffer,
const FrameBuffer& output_buffer,
int angle_deg);
absl::Status ValidateCropBufferInputs(const FrameBuffer& buffer,
const FrameBuffer& output_buffer, int x0,
int y0, int x1, int y1);
absl::Status ValidateFlipBufferInputs(const FrameBuffer& buffer,
const FrameBuffer& output_buffer);
absl::Status ValidateConvertFormats(FrameBuffer::Format from_format,
FrameBuffer::Format to_format);
std::unique_ptr<FrameBuffer> CreateFromRgbaRawBuffer(
const uint8* input, FrameBuffer::Dimension dimension,
FrameBuffer::Orientation orientation = FrameBuffer::Orientation::kTopLeft,
absl::Time timestamp = absl::Now(),
FrameBuffer::Stride stride = kDefaultStride);
std::unique_ptr<FrameBuffer> CreateFromRgbRawBuffer(
const uint8* input, FrameBuffer::Dimension dimension,
FrameBuffer::Orientation orientation = FrameBuffer::Orientation::kTopLeft,
absl::Time timestamp = absl::Now(),
FrameBuffer::Stride stride = kDefaultStride);
std::unique_ptr<FrameBuffer> CreateFromGrayRawBuffer(
const uint8* input, FrameBuffer::Dimension dimension,
FrameBuffer::Orientation orientation = FrameBuffer::Orientation::kTopLeft,
absl::Time timestamp = absl::Now(),
FrameBuffer::Stride stride = kDefaultStride);
tflite::support::StatusOr<std::unique_ptr<FrameBuffer>> CreateFromYuvRawBuffer(
const uint8* y_plane, const uint8* u_plane, const uint8* v_plane,
FrameBuffer::Format format, FrameBuffer::Dimension dimension,
int row_stride_y, int row_stride_uv, int pixel_stride_uv,
FrameBuffer::Orientation orientation = FrameBuffer::Orientation::kTopLeft,
absl::Time timestamp = absl::Now());
tflite::support::StatusOr<std::unique_ptr<FrameBuffer>> CreateFromRawBuffer(
const uint8* buffer, FrameBuffer::Dimension dimension,
FrameBuffer::Format target_format,
FrameBuffer::Orientation orientation = FrameBuffer::Orientation::kTopLeft,
absl::Time timestamp = absl::Now());
}
}
}
#endif