#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/capture/video/linux/v4l2_capture_delegate_gpu_helper.h"
#include "base/trace_event/trace_event.h"
#include "third_party/libyuv/include/libyuv.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace media {
namespace {
constexpr media::VideoPixelFormat kTargetPixelFormat = …;
constexpr gfx::BufferFormat kTargetBufferFormat = …;
libyuv::FourCC VideoCaptureFormatToLibyuvFourcc(
const VideoCaptureFormat& capture_format) { … }
libyuv::RotationMode TranslateRotation(int rotation_degrees) { … }
}
V4L2CaptureDelegateGpuHelper::V4L2CaptureDelegateGpuHelper(
std::unique_ptr<gpu::GpuMemoryBufferSupport> gmb_support)
: … { … }
V4L2CaptureDelegateGpuHelper::~V4L2CaptureDelegateGpuHelper() = default;
int V4L2CaptureDelegateGpuHelper::OnIncomingCapturedData(
VideoCaptureDevice::Client* client,
const uint8_t* sample,
size_t sample_size,
const VideoCaptureFormat& capture_format,
const gfx::ColorSpace& data_color_space,
int rotation,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
int frame_feedback_id) { … }
int V4L2CaptureDelegateGpuHelper::ConvertCaptureDataToNV12(
const uint8_t* sample,
size_t sample_size,
const VideoCaptureFormat& capture_format,
const gfx::Size& dimensions,
const gfx::ColorSpace& data_color_space,
int rotation,
uint8_t* dst_y,
uint8_t* dst_uv,
int dst_stride_y,
int dst_stride_uv) { … }
int V4L2CaptureDelegateGpuHelper::FastConvertToNV12(
const uint8_t* sample,
size_t sample_size,
const VideoCaptureFormat& capture_format,
uint8_t* dst_y,
uint8_t* dst_uv,
int dst_stride_y,
int dst_stride_uv) { … }
bool V4L2CaptureDelegateGpuHelper::IsNV12ConvertSupported(uint32_t fourcc) { … }
}