From 76f221244448793c3ab0346bc94e77e8d5a3b666 Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Tue, 11 Sep 2018 08:54:27 +0000 Subject: [PATCH] VideoFrameLayout: Add offsets and aggregate strides and offsets as Plane VideoFrameLayout should have information about offset per plane, not only stride. The number of stride should be the same as the number of offsets. To guarantee this, they are stored in the vector of struct, Plane. BUG=chromium:876986, chromium:856562 TEST=VDA unittest and media_unittest Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel Change-Id: Ie9d9afa5db7dabaee2f48fbcd355c13d29be8035 Reviewed-on: https://chromium-review.googlesource.com/1188730 Commit-Queue: Hirokazu Honda Reviewed-by: Dale Curtis Cr-Commit-Position: refs/heads/master@{#590242} --- media/base/video_frame.cc | 9 +- media/base/video_frame.h | 7 +- media/base/video_frame_layout.cc | 50 +++++++--- media/base/video_frame_layout.h | 54 +++++++--- media/base/video_frame_layout_unittest.cc | 98 ++++++++++++++----- media/base/video_frame_unittest.cc | 47 +++++++++ media/cast/test/utility/video_utility.cc | 1 - media/gpu/v4l2/v4l2_image_processor.cc | 6 +- .../gpu/v4l2/v4l2_video_decode_accelerator.cc | 6 +- 9 files changed, 214 insertions(+), 64 deletions(-) diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 46a00b449066f0..2ab650500cec0c 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -382,13 +382,14 @@ scoped_refptr VideoFrame::WrapExternalYuvaData( #if defined(OS_LINUX) // static scoped_refptr VideoFrame::WrapExternalDmabufs( - VideoPixelFormat format, - const gfx::Size& coded_size, + const VideoFrameLayout& layout, const gfx::Rect& visible_rect, const gfx::Size& natural_size, std::vector dmabuf_fds, base::TimeDelta timestamp) { const StorageType storage = STORAGE_DMABUFS; + const VideoPixelFormat format = layout.format(); + const gfx::Size& coded_size = layout.coded_size(); if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { DLOG(ERROR) << __func__ << " Invalid config." << ConfigToString(format, storage, coded_size, visible_rect, @@ -403,8 +404,8 @@ scoped_refptr VideoFrame::WrapExternalDmabufs( } gpu::MailboxHolder mailbox_holders[kMaxPlanes]; - scoped_refptr frame = new VideoFrame( - format, storage, coded_size, visible_rect, natural_size, timestamp); + scoped_refptr frame = + new VideoFrame(layout, storage, visible_rect, natural_size, timestamp); if (!frame) { DLOG(ERROR) << __func__ << " Couldn't create VideoFrame instance."; return nullptr; diff --git a/media/base/video_frame.h b/media/base/video_frame.h index 3e691567f468c4..21bd15ee7e64ff 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -250,8 +250,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe { // mapped via mmap() for CPU access. // Returns NULL on failure. static scoped_refptr WrapExternalDmabufs( - VideoPixelFormat format, - const gfx::Size& coded_size, + const VideoFrameLayout& layout, const gfx::Rect& visible_rect, const gfx::Size& natural_size, std::vector dmabuf_fds, @@ -367,8 +366,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe { int stride(size_t plane) const { DCHECK(IsValidPlane(plane, format())); - DCHECK_LT(plane, layout_.num_strides()); - return layout_.strides()[plane]; + DCHECK_LT(plane, layout_.num_planes()); + return layout_.planes()[plane].stride; } // Returns the number of bytes per row and number of rows for a given plane. diff --git a/media/base/video_frame_layout.cc b/media/base/video_frame_layout.cc index 9a688c03c9581b..0c6451bfce9a5e 100644 --- a/media/base/video_frame_layout.cc +++ b/media/base/video_frame_layout.cc @@ -7,15 +7,24 @@ #include #include +namespace media { + namespace { +std::ostringstream& operator<<(std::ostringstream& ostrm, + const media::VideoFrameLayout::Plane& plane) { + ostrm << "(" << plane.stride << ", " << plane.offset << ")"; + return ostrm; +} + template std::string VectorToString(const std::vector& vec) { std::ostringstream result; std::string delim; result << "["; for (auto v : vec) { - result << delim << v; + result << delim; + result << v; if (delim.size() == 0) delim = ", "; } @@ -23,9 +32,16 @@ std::string VectorToString(const std::vector& vec) { return result.str(); } -} // namespace +std::vector PlanesFromStrides( + const std::vector strides) { + std::vector planes(strides.size()); + for (size_t i = 0; i < strides.size(); i++) { + planes[i].stride = strides[i]; + } + return planes; +} -namespace media { +} // namespace VideoFrameLayout::VideoFrameLayout(VideoPixelFormat format, const gfx::Size& coded_size, @@ -33,14 +49,22 @@ VideoFrameLayout::VideoFrameLayout(VideoPixelFormat format, std::vector buffer_sizes) : format_(format), coded_size_(coded_size), - strides_(std::move(strides)), + planes_(PlanesFromStrides(strides)), + buffer_sizes_(std::move(buffer_sizes)) {} + +VideoFrameLayout::VideoFrameLayout(VideoPixelFormat format, + const gfx::Size& coded_size, + std::vector planes, + std::vector buffer_sizes) + : format_(format), + coded_size_(coded_size), + planes_(std::move(planes)), buffer_sizes_(std::move(buffer_sizes)) {} VideoFrameLayout::VideoFrameLayout() : format_(PIXEL_FORMAT_UNKNOWN), - coded_size_(), - strides_({0, 0, 0, 0}), - buffer_sizes_({0, 0, 0, 0}) {} + planes_(kDefaultPlaneCount), + buffer_sizes_(kDefaultBufferCount, 0) {} VideoFrameLayout::~VideoFrameLayout() = default; VideoFrameLayout::VideoFrameLayout(const VideoFrameLayout&) = default; @@ -54,12 +78,12 @@ size_t VideoFrameLayout::GetTotalBufferSize() const { std::string VideoFrameLayout::ToString() const { std::ostringstream s; - s << "VideoFrameLayout format:" << VideoPixelFormatToString(format_) - << " coded_size:" << coded_size_.ToString() - << " num_buffers:" << num_buffers() - << " buffer_sizes:" << VectorToString(buffer_sizes_) - << " num_strides:" << num_strides() - << " strides:" << VectorToString(strides_); + s << "VideoFrameLayout format: " << VideoPixelFormatToString(format_) + << ", coded_size: " << coded_size_.ToString() + << ", num_buffers: " << num_buffers() + << ", buffer_sizes: " << VectorToString(buffer_sizes_) + << ", num_planes: " << num_planes() + << ", planes (stride, offset): " << VectorToString(planes_); return s.str(); } diff --git a/media/base/video_frame_layout.h b/media/base/video_frame_layout.h index a3cb70d88f6a07..ad8a15995d14f6 100644 --- a/media/base/video_frame_layout.h +++ b/media/base/video_frame_layout.h @@ -21,18 +21,46 @@ namespace media { // A class to describes how physical buffer is allocated for video frame. // In stores format, coded size of the frame and size of physical buffers // which can be used to allocate buffer(s) hardware expected. -// Also, it stores stride (bytes per line) per color plane to calculate each -// color plane's size (note that a buffer may contains multiple color planes.) +// It also stores stride (bytes per line) and offset per color plane as Plane. +// stride is to calculate each color plane's size (note that a buffer may +// contains multiple color planes.) +// offset is to describe a start point of each plane from buffer's dmabuf fd. // Note that it is copyable. class MEDIA_EXPORT VideoFrameLayout { public: + struct Plane { + // Strides of a plane, typically greater or equal to the + // width of the surface divided by the horizontal sampling period. Note that + // strides can be negative if the image layout is bottom-up. + int32_t stride = 0; + + // Offset of a plane, which stands for the offset of a start point of a + // color plane from a buffer fd. + size_t offset = 0; + }; + + enum { + kDefaultPlaneCount = 4, + kDefaultBufferCount = 4, + }; + // Constructor with strides and buffers' size. - // If strides and buffer_sizes are not assigned, their default value are - // {0, 0, 0, 0} for compatibility with video_frame.cc's original behavior. + // If strides and buffer_sizes are not assigned, strides, offsets and + // buffer_sizes are {0, 0, 0, 0}. + VideoFrameLayout(VideoPixelFormat format, + const gfx::Size& coded_size, + std::vector strides = + std::vector(kDefaultPlaneCount, 0), + std::vector buffer_sizes = + std::vector(kDefaultBufferCount, 0)); + + // Constructor with plane's stride/offset, and buffers' size. + // If buffer_sizes are not assigned, it is {0, 0, 0, 0}. VideoFrameLayout(VideoPixelFormat format, const gfx::Size& coded_size, - std::vector strides = {0, 0, 0, 0}, - std::vector buffer_sizes = {0, 0, 0, 0}); + std::vector planes, + std::vector buffer_sizes = + std::vector(kDefaultBufferCount)); VideoFrameLayout(); ~VideoFrameLayout(); @@ -43,13 +71,13 @@ class MEDIA_EXPORT VideoFrameLayout { VideoPixelFormat format() const { return format_; } const gfx::Size& coded_size() const { return coded_size_; } - // Return number of buffers. Note that num_strides >= num_buffers. + // Return number of buffers. Note that num_planes >= num_buffers. size_t num_buffers() const { return buffer_sizes_.size(); } - // Returns number of strides. Note that num_strides >= num_buffers. - size_t num_strides() const { return strides_.size(); } + // Returns number of planes. Note that num_planes >= num_buffers. + size_t num_planes() const { return planes_.size(); } - const std::vector& strides() const { return strides_; } + const std::vector& planes() const { return planes_; } const std::vector& buffer_sizes() const { return buffer_sizes_; } // Returns sum of bytes of all buffers. @@ -68,10 +96,8 @@ class MEDIA_EXPORT VideoFrameLayout { // the pixel data provided for the odd pixels. gfx::Size coded_size_; - // Vector of strides for each buffer, typically greater or equal to the - // width of the surface divided by the horizontal sampling period. Note that - // strides can be negative if the image layout is bottom-up. - std::vector strides_; + // Layout property for each color planes, e.g. stride and buffer offset. + std::vector planes_; // Vector of sizes for each buffer, typically greater or equal to the area of // |coded_size_|. diff --git a/media/base/video_frame_layout_unittest.cc b/media/base/video_frame_layout_unittest.cc index f6fcf6f2ab7ccb..5a46d08311ea54 100644 --- a/media/base/video_frame_layout_unittest.cc +++ b/media/base/video_frame_layout_unittest.cc @@ -10,12 +10,29 @@ #include #include +#include "base/logging.h" #include "media/base/video_types.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/geometry/size.h" namespace media { +namespace { + +std::vector CreatePlanes( + const std::vector& strides, + const std::vector& offsets) { + LOG_ASSERT(strides.size() == offsets.size()); + std::vector planes(strides.size()); + for (size_t i = 0; i < strides.size(); i++) { + planes[i].stride = strides[i]; + planes[i].offset = offsets[i]; + } + return planes; +} + +} // namespace + TEST(VideoFrameLayout, Constructor) { gfx::Size coded_size = gfx::Size(320, 180); std::vector strides = {384, 192, 192}; @@ -24,11 +41,32 @@ TEST(VideoFrameLayout, Constructor) { EXPECT_EQ(layout.format(), PIXEL_FORMAT_I420); EXPECT_EQ(layout.coded_size(), coded_size); - EXPECT_EQ(layout.num_strides(), 3u); + EXPECT_EQ(layout.num_planes(), 3u); EXPECT_EQ(layout.num_buffers(), 3u); EXPECT_EQ(layout.GetTotalBufferSize(), 110592u); for (size_t i = 0; i < 3; ++i) { - EXPECT_EQ(layout.strides()[i], strides[i]); + EXPECT_EQ(layout.planes()[i].stride, strides[i]); + EXPECT_EQ(layout.planes()[i].offset, 0u); + EXPECT_EQ(layout.buffer_sizes()[i], buffer_sizes[i]); + } +} + +TEST(VideoFrameLayout, ConstructorWithPlanes) { + gfx::Size coded_size = gfx::Size(320, 180); + std::vector strides = {384, 192, 192}; + std::vector offsets = {0, 100, 200}; + std::vector buffer_sizes = {73728, 18432, 18432}; + VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, + CreatePlanes(strides, offsets), buffer_sizes); + + EXPECT_EQ(layout.format(), PIXEL_FORMAT_I420); + EXPECT_EQ(layout.coded_size(), coded_size); + EXPECT_EQ(layout.num_planes(), 3u); + EXPECT_EQ(layout.num_buffers(), 3u); + EXPECT_EQ(layout.GetTotalBufferSize(), 110592u); + for (size_t i = 0; i < 3; ++i) { + EXPECT_EQ(layout.planes()[i].stride, strides[i]); + EXPECT_EQ(layout.planes()[i].offset, offsets[i]); EXPECT_EQ(layout.buffer_sizes()[i], buffer_sizes[i]); } } @@ -40,10 +78,11 @@ TEST(VideoFrameLayout, ConstructorNoStrideBufferSize) { EXPECT_EQ(layout.format(), PIXEL_FORMAT_I420); EXPECT_EQ(layout.coded_size(), coded_size); EXPECT_EQ(layout.GetTotalBufferSize(), 0u); - EXPECT_EQ(layout.num_strides(), 4u); + EXPECT_EQ(layout.num_planes(), 4u); EXPECT_EQ(layout.num_buffers(), 4u); for (size_t i = 0; i < 4u; ++i) { - EXPECT_EQ(layout.strides()[i], 0); + EXPECT_EQ(layout.planes()[i].stride, 0); + EXPECT_EQ(layout.planes()[i].offset, 0u); EXPECT_EQ(layout.buffer_sizes()[i], 0u); } } @@ -51,18 +90,21 @@ TEST(VideoFrameLayout, ConstructorNoStrideBufferSize) { TEST(VideoFrameLayout, CopyConstructor) { gfx::Size coded_size = gfx::Size(320, 180); std::vector strides = {384, 192, 192}; + std::vector offsets = {0, 100, 200}; std::vector buffer_sizes = {73728, 18432, 18432}; - VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, strides, buffer_sizes); + VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, + CreatePlanes(strides, offsets), buffer_sizes); VideoFrameLayout layout_clone(layout); EXPECT_EQ(layout_clone.format(), PIXEL_FORMAT_I420); EXPECT_EQ(layout_clone.coded_size(), coded_size); - EXPECT_EQ(layout_clone.num_strides(), 3u); + EXPECT_EQ(layout_clone.num_planes(), 3u); EXPECT_EQ(layout_clone.num_buffers(), 3u); EXPECT_EQ(layout_clone.GetTotalBufferSize(), 110592u); for (size_t i = 0; i < 3; ++i) { - EXPECT_EQ(layout_clone.strides()[i], strides[i]); + EXPECT_EQ(layout.planes()[i].stride, strides[i]); + EXPECT_EQ(layout.planes()[i].offset, offsets[i]); EXPECT_EQ(layout_clone.buffer_sizes()[i], buffer_sizes[i]); } } @@ -70,18 +112,21 @@ TEST(VideoFrameLayout, CopyConstructor) { TEST(VideoFrameLayout, AssignmentOperator) { gfx::Size coded_size = gfx::Size(320, 180); std::vector strides = {384, 192, 192}; + std::vector offsets = {0, 100, 200}; std::vector buffer_sizes = {73728, 18432, 18432}; - VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, strides, buffer_sizes); + VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, + CreatePlanes(strides, offsets), buffer_sizes); VideoFrameLayout layout_clone = layout; EXPECT_EQ(layout_clone.format(), PIXEL_FORMAT_I420); EXPECT_EQ(layout_clone.coded_size(), coded_size); - EXPECT_EQ(layout_clone.num_strides(), 3u); + EXPECT_EQ(layout_clone.num_planes(), 3u); EXPECT_EQ(layout_clone.num_buffers(), 3u); EXPECT_EQ(layout_clone.GetTotalBufferSize(), 110592u); for (size_t i = 0; i < 3; ++i) { - EXPECT_EQ(layout_clone.strides()[i], strides[i]); + EXPECT_EQ(layout_clone.planes()[i].stride, strides[i]); + EXPECT_EQ(layout_clone.planes()[i].offset, offsets[i]); EXPECT_EQ(layout_clone.buffer_sizes()[i], buffer_sizes[i]); } } @@ -89,25 +134,28 @@ TEST(VideoFrameLayout, AssignmentOperator) { TEST(VideoFrameLayout, MoveConstructor) { gfx::Size coded_size = gfx::Size(320, 180); std::vector strides = {384, 192, 192}; + std::vector offsets = {0, 100, 200}; std::vector buffer_sizes = {73728, 18432, 18432}; - VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, strides, buffer_sizes); + VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, + CreatePlanes(strides, offsets), buffer_sizes); VideoFrameLayout layout_move(std::move(layout)); EXPECT_EQ(layout_move.format(), PIXEL_FORMAT_I420); EXPECT_EQ(layout_move.coded_size(), coded_size); - EXPECT_EQ(layout_move.num_strides(), 3u); + EXPECT_EQ(layout_move.num_planes(), 3u); EXPECT_EQ(layout_move.num_buffers(), 3u); EXPECT_EQ(layout_move.GetTotalBufferSize(), 110592u); for (size_t i = 0; i < 3; ++i) { - EXPECT_EQ(layout_move.strides()[i], strides[i]); + EXPECT_EQ(layout_move.planes()[i].stride, strides[i]); + EXPECT_EQ(layout_move.planes()[i].offset, offsets[i]); EXPECT_EQ(layout_move.buffer_sizes()[i], buffer_sizes[i]); } // Members in object being moved are cleared except const members. EXPECT_EQ(layout.format(), PIXEL_FORMAT_I420); EXPECT_EQ(layout.coded_size(), coded_size); - EXPECT_EQ(layout.num_strides(), 0u); + EXPECT_EQ(layout.num_planes(), 0u); EXPECT_EQ(layout.num_buffers(), 0u); EXPECT_EQ(layout.GetTotalBufferSize(), 0u); } @@ -119,20 +167,24 @@ TEST(VideoFrameLayout, ToString) { VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, strides, buffer_sizes); EXPECT_EQ(layout.ToString(), - "VideoFrameLayout format:PIXEL_FORMAT_I420 coded_size:320x180 " - "num_buffers:3 buffer_sizes:[73728, 18432, 18432] num_strides:3 " - "strides:[384, 192, 192]"); + "VideoFrameLayout format: PIXEL_FORMAT_I420, coded_size: 320x180, " + "num_buffers: 3, buffer_sizes: [73728, 18432, 18432], " + "num_planes: 3, " + "planes (stride, offset): [(384, 0), (192, 0), (192, 0)]"); } TEST(VideoFrameLayout, ToStringOneBuffer) { gfx::Size coded_size = gfx::Size(320, 180); std::vector strides = {384}; + std::vector offsets = {100}; std::vector buffer_sizes = {122880}; - VideoFrameLayout layout(PIXEL_FORMAT_NV12, coded_size, strides, buffer_sizes); + VideoFrameLayout layout(PIXEL_FORMAT_NV12, coded_size, + CreatePlanes(strides, offsets), buffer_sizes); EXPECT_EQ(layout.ToString(), - "VideoFrameLayout format:PIXEL_FORMAT_NV12 coded_size:320x180 " - "num_buffers:1 buffer_sizes:[122880] num_strides:1 strides:[384]"); + "VideoFrameLayout format: PIXEL_FORMAT_NV12, coded_size: 320x180, " + "num_buffers: 1, buffer_sizes: [122880], " + "num_planes: 1, planes (stride, offset): [(384, 100)]"); } TEST(VideoFrameLayout, ToStringNoBufferInfo) { @@ -140,9 +192,9 @@ TEST(VideoFrameLayout, ToStringNoBufferInfo) { VideoFrameLayout layout(PIXEL_FORMAT_NV12, coded_size); EXPECT_EQ(layout.ToString(), - "VideoFrameLayout format:PIXEL_FORMAT_NV12 coded_size:320x180 " - "num_buffers:4 buffer_sizes:[0, 0, 0, 0] num_strides:4 " - "strides:[0, 0, 0, 0]"); + "VideoFrameLayout format: PIXEL_FORMAT_NV12, coded_size: 320x180, " + "num_buffers: 4, buffer_sizes: [0, 0, 0, 0], num_planes: 4, " + "planes (stride, offset): [(0, 0), (0, 0), (0, 0), (0, 0)]"); } } // namespace media diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index 7f1401fb90822d..4feadbf63fca57 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc @@ -17,6 +17,7 @@ #include "base/memory/shared_memory.h" #include "base/memory/unsafe_shared_memory_region.h" #include "base/strings/stringprintf.h" +#include "build/build_config.h" #include "gpu/command_buffer/common/mailbox_holder.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/libyuv/include/libyuv.h" @@ -387,6 +388,52 @@ TEST(VideoFrame, WrapExternalSharedMemory) { EXPECT_EQ(frame->data(media::VideoFrame::kYPlane)[0], 0xff); } +#if defined(OS_LINUX) +TEST(VideoFrame, WrapExternalDmabufs) { + gfx::Size coded_size = gfx::Size(256, 256); + gfx::Rect visible_rect(coded_size); + std::vector strides = {384, 192, 192}; + std::vector offsets = {0, 100, 200}; + std::vector buffer_sizes = {73728, 18432, 18432}; + std::vector planes(strides.size()); + + for (size_t i = 0; i < planes.size(); i++) { + planes[i].stride = strides[i]; + planes[i].offset = offsets[i]; + } + auto timestamp = base::TimeDelta::FromMilliseconds(1); + VideoFrameLayout layout(PIXEL_FORMAT_I420, coded_size, planes, buffer_sizes); + std::vector dummy_fds = {10, 11, 12}; + std::vector dmabuf_fds; + for (int fd : dummy_fds) { + dmabuf_fds.emplace_back(fd); + } + auto frame = + VideoFrame::WrapExternalDmabufs(layout, visible_rect, visible_rect.size(), + std::move(dmabuf_fds), timestamp); + + EXPECT_EQ(frame->layout().format(), PIXEL_FORMAT_I420); + EXPECT_EQ(frame->layout().coded_size(), coded_size); + EXPECT_EQ(frame->layout().num_planes(), 3u); + EXPECT_EQ(frame->layout().num_buffers(), 3u); + EXPECT_EQ(frame->layout().GetTotalBufferSize(), 110592u); + for (size_t i = 0; i < 3; ++i) { + EXPECT_EQ(frame->layout().planes()[i].stride, strides[i]); + EXPECT_EQ(frame->layout().planes()[i].offset, offsets[i]); + EXPECT_EQ(frame->layout().buffer_sizes()[i], buffer_sizes[i]); + } + EXPECT_TRUE(frame->HasDmaBufs()); + const auto& fds = frame->DmabufFds(); + EXPECT_EQ(fds.size(), dummy_fds.size()); + for (size_t i = 0; i < fds.size(); i++) { + EXPECT_EQ(fds[i].get(), dummy_fds[i]); + } + EXPECT_EQ(frame->coded_size(), coded_size); + EXPECT_EQ(frame->visible_rect(), visible_rect); + EXPECT_EQ(frame->timestamp(), timestamp); +} +#endif + // Ensure each frame is properly sized and allocated. Will trigger OOB reads // and writes as well as incorrect frame hashes otherwise. TEST(VideoFrame, CheckFrameExtents) { diff --git a/media/cast/test/utility/video_utility.cc b/media/cast/test/utility/video_utility.cc index ec656f2f8ae724..e957c684604592 100644 --- a/media/cast/test/utility/video_utility.cc +++ b/media/cast/test/utility/video_utility.cc @@ -69,7 +69,6 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) { // Set Y. const int height = frame_size.height(); - VLOG(1) << "frame num_strides: " << frame->layout().num_strides(); const int stride_y = frame->stride(VideoFrame::kYPlane); uint8_t* y_plane = frame->data(VideoFrame::kYPlane); for (int j = 0; j < height; ++j) { diff --git a/media/gpu/v4l2/v4l2_image_processor.cc b/media/gpu/v4l2/v4l2_image_processor.cc index 8804c1f1dc0f09..95f9a07dc2ccc8 100644 --- a/media/gpu/v4l2/v4l2_image_processor.cc +++ b/media/gpu/v4l2/v4l2_image_processor.cc @@ -292,9 +292,9 @@ bool V4L2ImageProcessor::Process(const scoped_refptr& frame, // Create the output frame job_record->output_frame = VideoFrame::WrapExternalDmabufs( - output_format_, output_allocated_size_, gfx::Rect(output_visible_size_), - output_visible_size_, std::move(output_dmabuf_fds), - job_record->input_frame->timestamp()); + VideoFrameLayout(output_format_, output_allocated_size_), + gfx::Rect(output_visible_size_), output_visible_size_, + std::move(output_dmabuf_fds), job_record->input_frame->timestamp()); if (!job_record->output_frame) return false; diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc index 4e09b19b75f6c1..0d05c9cd552dd4 100644 --- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc +++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc @@ -2485,8 +2485,10 @@ bool V4L2VideoDecodeAccelerator::ProcessFrame(int32_t bitstream_buffer_id, image_processor_bitstream_buffer_ids_.push(bitstream_buffer_id); scoped_refptr input_frame = VideoFrame::WrapExternalDmabufs( - V4L2Device::V4L2PixFmtToVideoPixelFormat(output_format_fourcc_), - coded_size_, gfx::Rect(visible_size_), visible_size_, + VideoFrameLayout( + V4L2Device::V4L2PixFmtToVideoPixelFormat(output_format_fourcc_), + coded_size_), + gfx::Rect(visible_size_), visible_size_, DuplicateFDs(output_record.processor_input_fds), base::TimeDelta()); if (!input_frame) {