chromium/third_party/tflite_support/src/tensorflow_lite_support/cc/task/vision/utils/frame_buffer_common_utils.cc

/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow_lite_support/cc/task/vision/utils/frame_buffer_common_utils.h"

#include <string>
#include <vector>

#include "absl/strings/str_cat.h"  // from @com_google_absl
#include "absl/strings/str_format.h"  // from @com_google_absl
#include "tensorflow_lite_support/cc/port/status_macros.h"

namespace tflite {
namespace task {
namespace vision {
namespace {

StatusOr;

constexpr int kRgbaChannels =;
constexpr int kRgbChannels =;
constexpr int kGrayChannel =;

// Creates a FrameBuffer from one plane raw NV21/NV12 buffer and passing
// arguments.
StatusOr<std::unique_ptr<FrameBuffer>> CreateFromOnePlaneNVRawBuffer(
    const uint8* input, FrameBuffer::Dimension dimension,
    FrameBuffer::Format format, FrameBuffer::Orientation orientation,
    const absl::Time timestamp) {}

// Indicates whether the given buffers have the same dimensions.
bool AreBufferDimsEqual(const FrameBuffer& buffer1,
                        const FrameBuffer& buffer2) {}

// Indicates whether the given buffers formats are compatible. Same formats are
// compatible and all YUV family formats (e.g. NV21, NV12, YV12, YV21, etc) are
// compatible.
bool AreBufferFormatsCompatible(const FrameBuffer& buffer1,
                                const FrameBuffer& buffer2) {}

}  // namespace

// Miscellaneous Methods
// -----------------------------------------------------------------
int GetFrameBufferByteSize(FrameBuffer::Dimension dimension,
                           FrameBuffer::Format format) {}

StatusOr<int> GetPixelStrides(FrameBuffer::Format format) {}

StatusOr<const uint8*> GetUvRawBuffer(const FrameBuffer& buffer) {}

StatusOr<FrameBuffer::Dimension> GetUvPlaneDimension(
    FrameBuffer::Dimension dimension, FrameBuffer::Format format) {}

FrameBuffer::Dimension GetCropDimension(int x0, int x1, int y0, int y1) {}

// Validation Methods
// -----------------------------------------------------------------

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) {}

// Creation Methods
// -----------------------------------------------------------------

// Creates a FrameBuffer from raw RGBA buffer and passing arguments.
std::unique_ptr<FrameBuffer> CreateFromRgbaRawBuffer(
    const uint8* input, FrameBuffer::Dimension dimension,
    FrameBuffer::Orientation orientation, const absl::Time timestamp,
    FrameBuffer::Stride stride) {}

// Creates a FrameBuffer from raw RGB buffer and passing arguments.
std::unique_ptr<FrameBuffer> CreateFromRgbRawBuffer(
    const uint8* input, FrameBuffer::Dimension dimension,
    FrameBuffer::Orientation orientation, const absl::Time timestamp,
    FrameBuffer::Stride stride) {}

// Creates a FrameBuffer from raw grayscale buffer and passing arguments.
std::unique_ptr<FrameBuffer> CreateFromGrayRawBuffer(
    const uint8* input, FrameBuffer::Dimension dimension,
    FrameBuffer::Orientation orientation, const absl::Time timestamp,
    FrameBuffer::Stride stride) {}

// Creates a FrameBuffer from raw YUV buffer and passing arguments.
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, const absl::Time timestamp) {}

StatusOr<std::unique_ptr<FrameBuffer>> CreateFromRawBuffer(
    const uint8* buffer, FrameBuffer::Dimension dimension,
    const FrameBuffer::Format target_format,
    FrameBuffer::Orientation orientation, absl::Time timestamp) {}

}  // namespace vision
}  // namespace task
}  // namespace tflite