Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: media/base/video_frame.cc

Issue 591313008: Add support for Rec709 color space videos in software YUV convert path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add enum to mojom Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/yuv_convert.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 case VideoFrame::kVPlane: 50 case VideoFrame::kVPlane:
51 switch (format) { 51 switch (format) {
52 case VideoFrame::YV24: 52 case VideoFrame::YV24:
53 return gfx::Size(1, 1); 53 return gfx::Size(1, 1);
54 54
55 case VideoFrame::YV16: 55 case VideoFrame::YV16:
56 return gfx::Size(2, 1); 56 return gfx::Size(2, 1);
57 57
58 case VideoFrame::YV12: 58 case VideoFrame::YV12:
59 case VideoFrame::YV12J: 59 case VideoFrame::YV12J:
60 case VideoFrame::YV12HD:
60 case VideoFrame::I420: 61 case VideoFrame::I420:
61 case VideoFrame::YV12A: 62 case VideoFrame::YV12A:
62 case VideoFrame::NV12: 63 case VideoFrame::NV12:
63 return gfx::Size(2, 2); 64 return gfx::Size(2, 2);
64 65
65 case VideoFrame::UNKNOWN: 66 case VideoFrame::UNKNOWN:
66 #if defined(VIDEO_HOLE) 67 #if defined(VIDEO_HOLE)
67 case VideoFrame::HOLE: 68 case VideoFrame::HOLE:
68 #endif // defined(VIDEO_HOLE) 69 #endif // defined(VIDEO_HOLE)
69 case VideoFrame::NATIVE_TEXTURE: 70 case VideoFrame::NATIVE_TEXTURE:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const gfx::Rect& visible_rect, 117 const gfx::Rect& visible_rect,
117 const gfx::Size& natural_size, 118 const gfx::Size& natural_size,
118 base::TimeDelta timestamp) { 119 base::TimeDelta timestamp) {
119 switch (format) { 120 switch (format) {
120 case VideoFrame::YV12: 121 case VideoFrame::YV12:
121 case VideoFrame::YV16: 122 case VideoFrame::YV16:
122 case VideoFrame::I420: 123 case VideoFrame::I420:
123 case VideoFrame::YV12A: 124 case VideoFrame::YV12A:
124 case VideoFrame::YV12J: 125 case VideoFrame::YV12J:
125 case VideoFrame::YV24: 126 case VideoFrame::YV24:
127 case VideoFrame::YV12HD:
126 break; 128 break;
127 129
128 case VideoFrame::UNKNOWN: 130 case VideoFrame::UNKNOWN:
129 case VideoFrame::NV12: 131 case VideoFrame::NV12:
130 case VideoFrame::NATIVE_TEXTURE: 132 case VideoFrame::NATIVE_TEXTURE:
131 #if defined(VIDEO_HOLE) 133 #if defined(VIDEO_HOLE)
132 case VideoFrame::HOLE: 134 case VideoFrame::HOLE:
133 #endif // defined(VIDEO_HOLE) 135 #endif // defined(VIDEO_HOLE)
134 case VideoFrame::ARGB: 136 case VideoFrame::ARGB:
135 NOTIMPLEMENTED(); 137 NOTIMPLEMENTED();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 case VideoFrame::YV12A: 176 case VideoFrame::YV12A:
175 return "YV12A"; 177 return "YV12A";
176 case VideoFrame::YV12J: 178 case VideoFrame::YV12J:
177 return "YV12J"; 179 return "YV12J";
178 case VideoFrame::NV12: 180 case VideoFrame::NV12:
179 return "NV12"; 181 return "NV12";
180 case VideoFrame::YV24: 182 case VideoFrame::YV24:
181 return "YV24"; 183 return "YV24";
182 case VideoFrame::ARGB: 184 case VideoFrame::ARGB:
183 return "ARGB"; 185 return "ARGB";
186 case VideoFrame::YV12HD:
187 return "YV12HD";
184 } 188 }
185 NOTREACHED() << "Invalid videoframe format provided: " << format; 189 NOTREACHED() << "Invalid videoframe format provided: " << format;
186 return ""; 190 return "";
187 } 191 }
188 192
189 // static 193 // static
190 bool VideoFrame::IsValidConfig(VideoFrame::Format format, 194 bool VideoFrame::IsValidConfig(VideoFrame::Format format,
191 const gfx::Size& coded_size, 195 const gfx::Size& coded_size,
192 const gfx::Rect& visible_rect, 196 const gfx::Rect& visible_rect,
193 const gfx::Size& natural_size) { 197 const gfx::Size& natural_size) {
(...skipping 22 matching lines...) Expand all
216 case VideoFrame::HOLE: 220 case VideoFrame::HOLE:
217 #endif // defined(VIDEO_HOLE) 221 #endif // defined(VIDEO_HOLE)
218 return true; 222 return true;
219 223
220 case VideoFrame::YV24: 224 case VideoFrame::YV24:
221 case VideoFrame::YV12: 225 case VideoFrame::YV12:
222 case VideoFrame::YV12J: 226 case VideoFrame::YV12J:
223 case VideoFrame::I420: 227 case VideoFrame::I420:
224 case VideoFrame::YV12A: 228 case VideoFrame::YV12A:
225 case VideoFrame::NV12: 229 case VideoFrame::NV12:
230 case VideoFrame::YV12HD:
226 case VideoFrame::YV16: 231 case VideoFrame::YV16:
227 case VideoFrame::ARGB: 232 case VideoFrame::ARGB:
228 // Check that software-allocated buffer formats are aligned correctly and 233 // Check that software-allocated buffer formats are aligned correctly and
229 // not empty. 234 // not empty.
230 const gfx::Size alignment = CommonAlignment(format); 235 const gfx::Size alignment = CommonAlignment(format);
231 return RoundUp(visible_rect.right(), alignment.width()) <= 236 return RoundUp(visible_rect.right(), alignment.width()) <=
232 static_cast<size_t>(coded_size.width()) && 237 static_cast<size_t>(coded_size.width()) &&
233 RoundUp(visible_rect.bottom(), alignment.height()) <= 238 RoundUp(visible_rect.bottom(), alignment.height()) <=
234 static_cast<size_t>(coded_size.height()) && 239 static_cast<size_t>(coded_size.height()) &&
235 !coded_size.IsEmpty() && !visible_rect.IsEmpty() && 240 !coded_size.IsEmpty() && !visible_rect.IsEmpty() &&
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 #endif // defined(VIDEO_HOLE) 553 #endif // defined(VIDEO_HOLE)
549 return 0; 554 return 0;
550 case VideoFrame::ARGB: 555 case VideoFrame::ARGB:
551 return 1; 556 return 1;
552 case VideoFrame::NV12: 557 case VideoFrame::NV12:
553 return 2; 558 return 2;
554 case VideoFrame::YV12: 559 case VideoFrame::YV12:
555 case VideoFrame::YV16: 560 case VideoFrame::YV16:
556 case VideoFrame::I420: 561 case VideoFrame::I420:
557 case VideoFrame::YV12J: 562 case VideoFrame::YV12J:
563 case VideoFrame::YV12HD:
558 case VideoFrame::YV24: 564 case VideoFrame::YV24:
559 return 3; 565 return 3;
560 case VideoFrame::YV12A: 566 case VideoFrame::YV12A:
561 return 4; 567 return 4;
562 case VideoFrame::UNKNOWN: 568 case VideoFrame::UNKNOWN:
563 break; 569 break;
564 } 570 }
565 NOTREACHED() << "Unsupported video frame format: " << format; 571 NOTREACHED() << "Unsupported video frame format: " << format;
566 return 0; 572 return 0;
567 } 573 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 627 }
622 628
623 // Release data allocated by AllocateYUV(). 629 // Release data allocated by AllocateYUV().
624 static void ReleaseData(uint8* data) { 630 static void ReleaseData(uint8* data) {
625 DCHECK(data); 631 DCHECK(data);
626 base::AlignedFree(data); 632 base::AlignedFree(data);
627 } 633 }
628 634
629 void VideoFrame::AllocateYUV() { 635 void VideoFrame::AllocateYUV() {
630 DCHECK(format_ == YV12 || format_ == YV16 || format_ == YV12A || 636 DCHECK(format_ == YV12 || format_ == YV16 || format_ == YV12A ||
631 format_ == I420 || format_ == YV12J || format_ == YV24); 637 format_ == I420 || format_ == YV12J || format_ == YV24 ||
638 format_ == YV12HD);
632 static_assert(0 == kYPlane, "y plane data must be index 0"); 639 static_assert(0 == kYPlane, "y plane data must be index 0");
633 640
634 size_t data_size = 0; 641 size_t data_size = 0;
635 size_t offset[kMaxPlanes]; 642 size_t offset[kMaxPlanes];
636 for (size_t plane = 0; plane < VideoFrame::NumPlanes(format_); ++plane) { 643 for (size_t plane = 0; plane < VideoFrame::NumPlanes(format_); ++plane) {
637 // The *2 in alignment for height is because some formats (e.g. h264) allow 644 // The *2 in alignment for height is because some formats (e.g. h264) allow
638 // interlaced coding, and then the size needs to be a multiple of two 645 // interlaced coding, and then the size needs to be a multiple of two
639 // macroblocks (vertically). See 646 // macroblocks (vertically). See
640 // libavcodec/utils.c:avcodec_align_dimensions2(). 647 // libavcodec/utils.c:avcodec_align_dimensions2().
641 const size_t height = RoundUp(rows(plane), kFrameSizeAlignment * 2); 648 const size_t height = RoundUp(rows(plane), kFrameSizeAlignment * 2);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { 815 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) {
809 for (int row = 0; row < rows(plane); ++row) { 816 for (int row = 0; row < rows(plane); ++row) {
810 base::MD5Update(context, base::StringPiece( 817 base::MD5Update(context, base::StringPiece(
811 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 818 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
812 row_bytes(plane))); 819 row_bytes(plane)));
813 } 820 }
814 } 821 }
815 } 822 }
816 823
817 } // namespace media 824 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/yuv_convert.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698