#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/chromeos/libyuv_image_processor_backend.h"
#include <sys/mman.h>
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/trace_event/trace_event.h"
#include "media/gpu/chromeos/fourcc.h"
#include "media/gpu/chromeos/video_frame_resource.h"
#include "media/gpu/macros.h"
#include "media/gpu/video_frame_mapper.h"
#include "media/gpu/video_frame_mapper_factory.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/libyuv/include/libyuv/convert_from.h"
#include "third_party/libyuv/include/libyuv/convert_from_argb.h"
#include "third_party/libyuv/include/libyuv/scale.h"
namespace media {
namespace {
enum class SupportResult { … };
enum class Transform { … };
static constexpr struct { … } kSupportFormatConversionArray[] = …;
SupportResult IsConversionSupported(Fourcc input_fourcc,
Fourcc output_fourcc,
Transform transform) { … }
}
std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create(
const PortConfig& input_config,
const PortConfig& output_config,
OutputMode output_mode,
ErrorCB error_cb) { … }
std::unique_ptr<ImageProcessorBackend>
LibYUVImageProcessorBackend::CreateWithTaskRunner(
const PortConfig& input_config,
const PortConfig& output_config,
OutputMode output_mode,
ErrorCB error_cb,
scoped_refptr<base::SequencedTaskRunner> backend_task_runner) { … }
LibYUVImageProcessorBackend::LibYUVImageProcessorBackend(
std::unique_ptr<VideoFrameMapper> input_frame_mapper,
std::unique_ptr<VideoFrameMapper> output_frame_mapper,
scoped_refptr<FrameResource> intermediate_frame,
scoped_refptr<FrameResource> crop_intermediate_frame,
const PortConfig& input_config,
const PortConfig& output_config,
OutputMode output_mode,
ErrorCB error_cb,
scoped_refptr<base::SequencedTaskRunner> backend_task_runner)
: … { … }
LibYUVImageProcessorBackend::~LibYUVImageProcessorBackend() { … }
std::string LibYUVImageProcessorBackend::type() const { … }
void LibYUVImageProcessorBackend::ProcessFrame(
scoped_refptr<FrameResource> input_frame,
scoped_refptr<FrameResource> output_frame,
FrameResourceReadyCB cb) { … }
int LibYUVImageProcessorBackend::DoConversion(const FrameResource* const input,
FrameResource* const output) { … }
bool LibYUVImageProcessorBackend::needs_linear_output_buffers() const { … }
std::vector<Fourcc> LibYUVImageProcessorBackend::GetSupportedOutputFormats(
Fourcc input_format) { … }
bool LibYUVImageProcessorBackend::supports_incoherent_buffers() const { … }
}