#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/gpu/test/raw_video.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "media/base/media.h"
#include "media/base/media_serializers.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/ffmpeg/scoped_av_packet.h"
#include "media/filters/ffmpeg_glue.h"
#include "media/filters/in_memory_url_protocol.h"
#include "media/filters/offloading_video_decoder.h"
#include "media/filters/vpx_video_decoder.h"
#include "media/gpu/test/video_frame_helpers.h"
#include "media/parsers/vp9_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/ffmpeg/libavformat/avformat.h"
#include "third_party/ffmpeg/libavutil/avutil.h"
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/libyuv/include/libyuv/planar_functions.h"
namespace media::test {
namespace {
constexpr const base::FilePath::CharType* kMetadataSuffix = …);
std::unique_ptr<base::MemoryMappedFile> CreateMemoryMappedFile(size_t size) { … }
std::unique_ptr<base::MemoryMappedFile> LoadRawData(
const base::FilePath& data_file_path,
size_t video_frame_size,
size_t num_read_frames) { … }
}
class RawVideo::VP9Decoder { … };
std::unique_ptr<RawVideo::VP9Decoder> RawVideo::VP9Decoder::Create(
const base::FilePath& vp9_webm_data_file_path,
const VideoFrameLayout& layout,
size_t num_read_frames) { … }
std::unique_ptr<RawVideo::VP9Decoder> RawVideo::VP9Decoder::Duplicate(
const VideoFrameLayout& layout,
const RawVideo::VP9Decoder& vp9_decoder) { … }
RawVideo::RawVideo(std::unique_ptr<VP9Decoder> vp9_decoder,
const Metadata& metadata,
size_t video_frame_size)
: … { … }
RawVideo::RawVideo(std::unique_ptr<base::MemoryMappedFile> memory_mapped_file,
const Metadata& metadata,
size_t video_frame_size)
: … { … }
RawVideo::~RawVideo() = default;
RawVideo::Metadata::Metadata() = default;
RawVideo::Metadata::~Metadata() = default;
RawVideo::Metadata::Metadata(const Metadata&) = default;
RawVideo::Metadata& RawVideo::Metadata::operator=(const Metadata&) = default;
RawVideo::FrameData::FrameData(const std::vector<const uint8_t*>& plane_addrs,
const std::vector<size_t>& strides,
std::vector<uint8_t> buffer)
: … { … }
RawVideo::FrameData::FrameData(FrameData&& frame_data)
: … { … }
RawVideo::FrameData::~FrameData() = default;
bool RawVideo::LoadMetadata(const base::FilePath& json_file_path,
Metadata& metadata,
bool& is_vp9_data) { … }
std::unique_ptr<RawVideo> RawVideo::Create(
const base::FilePath& file_path,
const base::FilePath& metadata_file_path,
bool read_all_frames) { … }
std::unique_ptr<RawVideo> RawVideo::CreateNV12Video() const { … }
std::unique_ptr<RawVideo> RawVideo::CreateExpandedVideo(
const gfx::Size& resolution,
const gfx::Rect& visible_rect) const { … }
RawVideo::FrameData RawVideo::GetFrame(size_t frame_index) const { … }
base::FilePath RawVideo::test_data_path_;
void RawVideo::SetTestDataPath(const base::FilePath& test_data_path) { … }
base::FilePath RawVideo::ResolveFilePath(const base::FilePath& file_path) { … }
}