#include "tensorflow_lite_support/cc/task/vision/utils/libyuv_frame_buffer_utils.h"
#include <stdint.h>
#include <memory>
#include <string>
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "libyuv.h"
#include "libyuv/convert_argb.h"
#include "libyuv/scale.h"
#include "tensorflow_lite_support/cc/common.h"
#include "tensorflow_lite_support/cc/port/integral_types.h"
#include "tensorflow_lite_support/cc/port/status_macros.h"
#include "tensorflow_lite_support/cc/port/statusor.h"
#include "tensorflow_lite_support/cc/task/vision/core/frame_buffer.h"
#include "tensorflow_lite_support/cc/task/vision/utils/frame_buffer_common_utils.h"
namespace tflite {
namespace task {
namespace vision {
StatusCode;
CreateStatusWithPayload;
TfLiteSupportStatus;
namespace {
absl::Status ConvertFromNv12(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ConvertFromNv21(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ConvertFromYv(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ResizeYv(
const FrameBuffer& buffer, FrameBuffer* output_buffer,
libyuv::FilterMode interpolation = libyuv::FilterMode::kFilterBilinear) { … }
absl::Status ResizeNv(
const FrameBuffer& buffer, FrameBuffer* output_buffer,
libyuv::FilterMode interpolation = libyuv::FilterMode::kFilterBilinear) { … }
absl::Status ConvertRgbToArgb(const FrameBuffer& buffer, uint8* dest_argb,
int dest_stride_argb) { … }
absl::Status ConvertArgbToRgb(uint8* src_argb, int src_stride_argb,
FrameBuffer* output_buffer) { … }
absl::Status ConvertRgbaToArgb(const FrameBuffer& buffer, uint8* dest_argb,
int dest_stride_argb) { … }
absl::Status ConvertFromRgb(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ConvertFromRgba(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
libyuv::RotationMode GetLibyuvRotationMode(int angle_deg) { … }
absl::Status RotateRgba(const FrameBuffer& buffer, int angle_deg,
FrameBuffer* output_buffer) { … }
absl::Status RotateRgb(const FrameBuffer& buffer, int angle_deg,
FrameBuffer* output_buffer) { … }
absl::Status RotateGray(const FrameBuffer& buffer, int angle_deg,
FrameBuffer* output_buffer) { … }
absl::Status RotateYv(const FrameBuffer& buffer, int angle_deg,
FrameBuffer* output_buffer) { … }
absl::Status RotateNv(const FrameBuffer& buffer, int angle_deg,
FrameBuffer* output_buffer) { … }
absl::Status FlipPlaneVertically(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status CropPlane(const FrameBuffer& buffer, int x0, int y0, int x1,
int y1, FrameBuffer* output_buffer) { … }
absl::Status CropNv(const FrameBuffer& buffer, int x0, int y0, int x1, int y1,
FrameBuffer* output_buffer) { … }
absl::Status CropYv(const FrameBuffer& buffer, int x0, int y0, int x1, int y1,
FrameBuffer* output_buffer) { … }
absl::Status CropResizeYuv(const FrameBuffer& buffer, int x0, int y0, int x1,
int y1, FrameBuffer* output_buffer) { … }
absl::Status FlipHorizontallyRgba(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FlipHorizontallyPlane(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ResizeRgb(
const FrameBuffer& buffer, FrameBuffer* output_buffer,
libyuv::FilterMode interpolation = libyuv::FilterMode::kFilterBilinear) { … }
absl::Status FlipHorizontallyRgb(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ResizeRgba(
const FrameBuffer& buffer, FrameBuffer* output_buffer,
libyuv::FilterMode interpolation = libyuv::FilterMode::kFilterBilinear) { … }
absl::Status FlipHorizontallyNv(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FlipHorizontallyYv(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FlipVerticallyNv(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FlipVerticallyYv(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status ResizeGray(
const FrameBuffer& buffer, FrameBuffer* output_buffer,
libyuv::FilterMode interpolation = libyuv::FilterMode::kFilterBilinear) { … }
absl::Status CropResize(const FrameBuffer& buffer, int x0, int y0, int x1,
int y1, FrameBuffer* output_buffer) { … }
}
absl::Status LibyuvFrameBufferUtils::Crop(const FrameBuffer& buffer, int x0,
int y0, int x1, int y1,
FrameBuffer* output_buffer) { … }
absl::Status LibyuvFrameBufferUtils::Resize(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status LibyuvFrameBufferUtils::ResizeNearestNeighbor(
const FrameBuffer& buffer, FrameBuffer* output_buffer) { … }
absl::Status LibyuvFrameBufferUtils::Rotate(const FrameBuffer& buffer,
int angle_deg,
FrameBuffer* output_buffer) { … }
absl::Status LibyuvFrameBufferUtils::FlipHorizontally(
const FrameBuffer& buffer, FrameBuffer* output_buffer) { … }
absl::Status LibyuvFrameBufferUtils::FlipVertically(
const FrameBuffer& buffer, FrameBuffer* output_buffer) { … }
absl::Status LibyuvFrameBufferUtils::Convert(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
}
}
}