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

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

Issue 10704175: Add config change support to FFmpegVideoDecoder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_piece.h" 8 #include "base/string_piece.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/video_util.h" 10 #include "media/base/video_util.h"
11 #if !defined(OS_ANDROID) 11 #if !defined(OS_ANDROID)
12 #include "media/ffmpeg/ffmpeg_common.h" 12 #include "media/ffmpeg/ffmpeg_common.h"
13 #endif 13 #endif
14 14
15 #include <algorithm> 15 #include <algorithm>
16 16
17 namespace media { 17 namespace media {
18 18
19 // static 19 // static
20 scoped_refptr<VideoFrame> VideoFrame::CreateFrame( 20 scoped_refptr<VideoFrame> VideoFrame::CreateFrame(
21 VideoFrame::Format format, 21 VideoFrame::Format format,
22 size_t width, 22 size_t width,
23 size_t height, 23 size_t height,
24 base::TimeDelta timestamp, 24 base::TimeDelta timestamp,
25 base::TimeDelta duration) { 25 base::TimeDelta duration) {
26 return VideoFrame::CreateFrame(format, width, height, width, height,
27 timestamp, duration);
28 }
29
30 scoped_refptr<VideoFrame> VideoFrame::CreateFrame(
31 VideoFrame::Format format,
32 size_t width,
33 size_t height,
34 size_t natural_width,
35 size_t natural_height,
36 base::TimeDelta timestamp,
37 base::TimeDelta duration) {
26 DCHECK(IsValidConfig(format, width, height)); 38 DCHECK(IsValidConfig(format, width, height));
27 scoped_refptr<VideoFrame> frame(new VideoFrame( 39 scoped_refptr<VideoFrame> frame(new VideoFrame(
28 format, width, height, timestamp, duration)); 40 format, width, height, natural_width, natural_height,
41 timestamp, duration));
29 switch (format) { 42 switch (format) {
30 case VideoFrame::RGB32: 43 case VideoFrame::RGB32:
31 frame->AllocateRGB(4u); 44 frame->AllocateRGB(4u);
32 break; 45 break;
33 case VideoFrame::YV12: 46 case VideoFrame::YV12:
34 case VideoFrame::YV16: 47 case VideoFrame::YV16:
35 frame->AllocateYUV(); 48 frame->AllocateYUV();
36 break; 49 break;
37 default: 50 default:
38 LOG(FATAL) << "Unsupported frame format: " << format; 51 LOG(FATAL) << "Unsupported frame format: " << format;
(...skipping 12 matching lines...) Expand all
51 width <= limits::kMaxDimension && height <= limits::kMaxDimension && 64 width <= limits::kMaxDimension && height <= limits::kMaxDimension &&
52 width * height <= limits::kMaxCanvas); 65 width * height <= limits::kMaxCanvas);
53 } 66 }
54 67
55 // static 68 // static
56 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( 69 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture(
57 uint32 texture_id, 70 uint32 texture_id,
58 uint32 texture_target, 71 uint32 texture_target,
59 size_t width, 72 size_t width,
60 size_t height, 73 size_t height,
74 size_t natural_width,
75 size_t natural_height,
61 base::TimeDelta timestamp, 76 base::TimeDelta timestamp,
62 base::TimeDelta duration, 77 base::TimeDelta duration,
63 const base::Closure& no_longer_needed) { 78 const base::Closure& no_longer_needed) {
64 scoped_refptr<VideoFrame> frame( 79 scoped_refptr<VideoFrame> frame(
65 new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration)); 80 new VideoFrame(NATIVE_TEXTURE, width, height,
81 natural_width, natural_height,
82 timestamp, duration));
66 frame->texture_id_ = texture_id; 83 frame->texture_id_ = texture_id;
67 frame->texture_target_ = texture_target; 84 frame->texture_target_ = texture_target;
68 frame->texture_no_longer_needed_ = no_longer_needed; 85 frame->texture_no_longer_needed_ = no_longer_needed;
69 return frame; 86 return frame;
70 } 87 }
71 88
72 // static 89 // static
73 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { 90 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() {
74 return new VideoFrame( 91 return new VideoFrame(
75 VideoFrame::EMPTY, 0, 0, base::TimeDelta(), base::TimeDelta()); 92 VideoFrame::EMPTY, 0, 0, 0, 0, base::TimeDelta(), base::TimeDelta());
76 } 93 }
77 94
78 // static 95 // static
79 scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(int width, int height) { 96 scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(int width, int height) {
80 DCHECK_GT(width, 0); 97 DCHECK_GT(width, 0);
81 DCHECK_GT(height, 0); 98 DCHECK_GT(height, 0);
82 99
83 // Create our frame. 100 // Create our frame.
84 const base::TimeDelta kZero; 101 const base::TimeDelta kZero;
85 scoped_refptr<VideoFrame> frame = 102 scoped_refptr<VideoFrame> frame =
86 VideoFrame::CreateFrame(VideoFrame::YV12, width, height, kZero, kZero); 103 VideoFrame::CreateFrame(VideoFrame::YV12, width, height, width, height,
104 kZero, kZero);
87 105
88 // Now set the data to YUV(0,128,128). 106 // Now set the data to YUV(0,128,128).
89 const uint8 kBlackY = 0x00; 107 const uint8 kBlackY = 0x00;
90 const uint8 kBlackUV = 0x80; 108 const uint8 kBlackUV = 0x80;
91 FillYUV(frame, kBlackY, kBlackUV, kBlackUV); 109 FillYUV(frame, kBlackY, kBlackUV, kBlackUV);
92 return frame; 110 return frame;
93 } 111 }
94 112
95 static inline size_t RoundUp(size_t value, size_t alignment) { 113 static inline size_t RoundUp(size_t value, size_t alignment) {
96 // Check that |alignment| is a power of 2. 114 // Check that |alignment| is a power of 2.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 data_[VideoFrame::kUPlane] = data + y_bytes; 171 data_[VideoFrame::kUPlane] = data + y_bytes;
154 data_[VideoFrame::kVPlane] = data + y_bytes + uv_bytes; 172 data_[VideoFrame::kVPlane] = data + y_bytes + uv_bytes;
155 strides_[VideoFrame::kYPlane] = y_stride; 173 strides_[VideoFrame::kYPlane] = y_stride;
156 strides_[VideoFrame::kUPlane] = uv_stride; 174 strides_[VideoFrame::kUPlane] = uv_stride;
157 strides_[VideoFrame::kVPlane] = uv_stride; 175 strides_[VideoFrame::kVPlane] = uv_stride;
158 } 176 }
159 177
160 VideoFrame::VideoFrame(VideoFrame::Format format, 178 VideoFrame::VideoFrame(VideoFrame::Format format,
161 size_t width, 179 size_t width,
162 size_t height, 180 size_t height,
181 size_t natural_width,
182 size_t natural_height,
163 base::TimeDelta timestamp, 183 base::TimeDelta timestamp,
164 base::TimeDelta duration) 184 base::TimeDelta duration)
165 : format_(format), 185 : format_(format),
166 width_(width), 186 width_(width),
167 height_(height), 187 height_(height),
188 natural_width_(natural_width),
189 natural_height_(natural_height),
168 texture_id_(0), 190 texture_id_(0),
169 texture_target_(0), 191 texture_target_(0),
170 timestamp_(timestamp), 192 timestamp_(timestamp),
171 duration_(duration) { 193 duration_(duration) {
172 memset(&strides_, 0, sizeof(strides_)); 194 memset(&strides_, 0, sizeof(strides_));
173 memset(&data_, 0, sizeof(data_)); 195 memset(&data_, 0, sizeof(data_));
174 } 196 }
175 197
176 VideoFrame::~VideoFrame() { 198 VideoFrame::~VideoFrame() {
177 if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) { 199 if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 break; 309 break;
288 for(int row = 0; row < rows(plane); row++) { 310 for(int row = 0; row < rows(plane); row++) {
289 base::MD5Update(context, base::StringPiece( 311 base::MD5Update(context, base::StringPiece(
290 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 312 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
291 row_bytes(plane))); 313 row_bytes(plane)));
292 } 314 }
293 } 315 }
294 } 316 }
295 317
296 } // namespace media 318 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698