summaryrefslogtreecommitdiff
path: root/chromium/media/base/video_frame.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/media/base/video_frame.cc')
-rw-r--r--chromium/media/base/video_frame.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/chromium/media/base/video_frame.cc b/chromium/media/base/video_frame.cc
index b3e63e70521..0bb025a1d5f 100644
--- a/chromium/media/base/video_frame.cc
+++ b/chromium/media/base/video_frame.cc
@@ -131,6 +131,7 @@ gfx::Size VideoFrame::SampleSize(VideoPixelFormat format, size_t plane) {
case PIXEL_FORMAT_P016LE:
return gfx::Size(2, 2);
+ case PIXEL_FORMAT_UYVY:
case PIXEL_FORMAT_UNKNOWN:
case PIXEL_FORMAT_YUY2:
case PIXEL_FORMAT_ARGB:
@@ -193,6 +194,7 @@ static bool RequiresEvenSizeAllocation(VideoPixelFormat format) {
case PIXEL_FORMAT_YUV422P12:
case PIXEL_FORMAT_YUV444P12:
case PIXEL_FORMAT_I420A:
+ case PIXEL_FORMAT_UYVY:
case PIXEL_FORMAT_P016LE:
return true;
case PIXEL_FORMAT_UNKNOWN:
@@ -732,8 +734,7 @@ scoped_refptr<VideoFrame> VideoFrame::WrapVideoFrame(
if (frame->storage_type() == STORAGE_SHMEM) {
DCHECK(frame->shm_region_ && frame->shm_region_->IsValid());
- wrapping_frame->BackWithSharedMemory(frame->shm_region_,
- frame->shared_memory_offset());
+ wrapping_frame->BackWithSharedMemory(frame->shm_region_);
}
wrapping_frame->wrapped_frame_ = std::move(frame);
@@ -864,6 +865,7 @@ int VideoFrame::BytesPerElement(VideoPixelFormat format, size_t plane) {
case PIXEL_FORMAT_RGB24:
return 3;
case PIXEL_FORMAT_Y16:
+ case PIXEL_FORMAT_UYVY:
case PIXEL_FORMAT_YUY2:
case PIXEL_FORMAT_YUV420P9:
case PIXEL_FORMAT_YUV422P9:
@@ -941,8 +943,7 @@ void VideoFrame::HashFrameForTesting(base::MD5Context* context,
}
}
-void VideoFrame::BackWithSharedMemory(base::UnsafeSharedMemoryRegion* region,
- size_t offset) {
+void VideoFrame::BackWithSharedMemory(base::UnsafeSharedMemoryRegion* region) {
DCHECK(!shm_region_);
DCHECK(!owned_shm_region_.IsValid());
// Either we should be backing a frame created with WrapExternal*, or we are
@@ -953,13 +954,11 @@ void VideoFrame::BackWithSharedMemory(base::UnsafeSharedMemoryRegion* region,
DCHECK(region && region->IsValid());
storage_type_ = STORAGE_SHMEM;
shm_region_ = region;
- shared_memory_offset_ = offset;
}
void VideoFrame::BackWithOwnedSharedMemory(
base::UnsafeSharedMemoryRegion region,
- base::WritableSharedMemoryMapping mapping,
- size_t offset) {
+ base::WritableSharedMemoryMapping mapping) {
DCHECK(!shm_region_);
DCHECK(!owned_shm_region_.IsValid());
// We should be backing a frame created with WrapExternal*. We cannot be
@@ -969,7 +968,6 @@ void VideoFrame::BackWithOwnedSharedMemory(
owned_shm_region_ = std::move(region);
shm_region_ = &owned_shm_region_;
owned_shm_mapping_ = std::move(mapping);
- shared_memory_offset_ = offset;
}
bool VideoFrame::IsMappable() const {
@@ -1006,6 +1004,17 @@ gfx::GpuMemoryBuffer* VideoFrame::GetGpuMemoryBuffer() const {
: gpu_memory_buffer_.get();
}
+bool VideoFrame::IsSameAllocation(VideoPixelFormat format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size) const {
+ // CreateFrameInternal() changes coded_size to new_coded_size. Match that
+ // behavior here.
+ const gfx::Size new_coded_size = DetermineAlignedSize(format, coded_size);
+ return this->format() == format && this->coded_size() == new_coded_size &&
+ visible_rect_ == visible_rect && natural_size_ == natural_size;
+}
+
gfx::ColorSpace VideoFrame::ColorSpace() const {
return color_space_;
}
@@ -1109,7 +1118,7 @@ gpu::SyncToken VideoFrame::UpdateReleaseSyncToken(SyncTokenClient* client) {
return release_sync_token_;
}
-std::string VideoFrame::AsHumanReadableString() {
+std::string VideoFrame::AsHumanReadableString() const {
if (metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM))
return "end of stream";
@@ -1201,7 +1210,7 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrameInternal(
// line up on sample boundaries. See discussion at http://crrev.com/1240833003
const gfx::Size new_coded_size = DetermineAlignedSize(format, coded_size);
auto layout = VideoFrameLayout::CreateWithStrides(
- format, new_coded_size, ComputeStrides(format, coded_size));
+ format, new_coded_size, ComputeStrides(format, new_coded_size));
if (!layout) {
DLOG(ERROR) << "Invalid layout.";
return nullptr;