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

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

Issue 406893002: Fix DCHECKs in V4l2VideoDevice. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comments of IsValidPlane Created 6 years, 4 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 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_ 6 #define MEDIA_BASE_VIDEO_FRAME_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 // Returns the required allocation size for a (tightly packed) plane of the 213 // Returns the required allocation size for a (tightly packed) plane of the
214 // given coded size and format. 214 // given coded size and format.
215 static size_t PlaneAllocationSize(Format format, 215 static size_t PlaneAllocationSize(Format format,
216 size_t plane, 216 size_t plane,
217 const gfx::Size& coded_size); 217 const gfx::Size& coded_size);
218 218
219 // Returns horizontal bits per pixel for given |plane| and |format|. 219 // Returns horizontal bits per pixel for given |plane| and |format|.
220 static int PlaneHorizontalBitsPerPixel(Format format, size_t plane); 220 static int PlaneHorizontalBitsPerPixel(Format format, size_t plane);
221 221
222 // Returns the number of bytes per row for the given plane, format, and width.
223 // This refers to the bytes representing frame data scanlines without stride
Pawel Osciak 2014/08/18 07:52:03 We do align the given width though in the impl...
wuchengli 2014/08/18 09:09:00 It refers only to the stride. The original functio
Pawel Osciak 2014/08/20 10:46:06 The issue is that it used to not take width, so it
wuchengli 2014/08/22 05:32:05 Done.
224 // padding.
225 static int RowBytes(size_t plane, Format format, int width);
226
222 Format format() const { return format_; } 227 Format format() const { return format_; }
223 228
224 const gfx::Size& coded_size() const { return coded_size_; } 229 const gfx::Size& coded_size() const { return coded_size_; }
225 const gfx::Rect& visible_rect() const { return visible_rect_; } 230 const gfx::Rect& visible_rect() const { return visible_rect_; }
226 const gfx::Size& natural_size() const { return natural_size_; } 231 const gfx::Size& natural_size() const { return natural_size_; }
227 232
228 int stride(size_t plane) const; 233 int stride(size_t plane) const;
229 234
230 // Returns the number of bytes per row and number of rows for a given plane. 235 // Returns the number of bytes per row and number of rows for a given plane.
231 // 236 //
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // VideoFrame. 282 // VideoFrame.
278 // This method is thread safe. Both blink and compositor threads can call it. 283 // This method is thread safe. Both blink and compositor threads can call it.
279 void UpdateReleaseSyncPoint(SyncPointClient* client); 284 void UpdateReleaseSyncPoint(SyncPointClient* client);
280 285
281 // Used to keep a running hash of seen frames. Expects an initialized MD5 286 // Used to keep a running hash of seen frames. Expects an initialized MD5
282 // context. Calls MD5Update with the context and the contents of the frame. 287 // context. Calls MD5Update with the context and the contents of the frame.
283 void HashFrameForTesting(base::MD5Context* context); 288 void HashFrameForTesting(base::MD5Context* context);
284 289
285 private: 290 private:
286 friend class base::RefCountedThreadSafe<VideoFrame>; 291 friend class base::RefCountedThreadSafe<VideoFrame>;
292
293 // Returns true if |plane| is less than the number of planes for the given
294 // format. This can be used to DCHECK() plane parameters.
295 static bool IsValidPlane(size_t plane, VideoFrame::Format format);
296
287 // Clients must use the static CreateFrame() method to create a new frame. 297 // Clients must use the static CreateFrame() method to create a new frame.
288 VideoFrame(Format format, 298 VideoFrame(Format format,
289 const gfx::Size& coded_size, 299 const gfx::Size& coded_size,
290 const gfx::Rect& visible_rect, 300 const gfx::Rect& visible_rect,
291 const gfx::Size& natural_size, 301 const gfx::Size& natural_size,
292 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 302 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
293 base::TimeDelta timestamp, 303 base::TimeDelta timestamp,
294 bool end_of_stream); 304 bool end_of_stream);
295 virtual ~VideoFrame(); 305 virtual ~VideoFrame();
296 306
297 void AllocateYUV(); 307 void AllocateYUV();
298 308
299 // Used to DCHECK() plane parameters.
300 bool IsValidPlane(size_t plane) const;
301
302 // Frame format. 309 // Frame format.
303 const Format format_; 310 const Format format_;
304 311
305 // Width and height of the video frame, in pixels. This must include pixel 312 // Width and height of the video frame, in pixels. This must include pixel
306 // data for the whole image; i.e. for YUV formats with subsampled chroma 313 // data for the whole image; i.e. for YUV formats with subsampled chroma
307 // planes, in the case that the visible portion of the image does not line up 314 // planes, in the case that the visible portion of the image does not line up
308 // on a sample boundary, |coded_size_| must be rounded up appropriately and 315 // on a sample boundary, |coded_size_| must be rounded up appropriately and
309 // the pixel data provided for the odd pixels. 316 // the pixel data provided for the odd pixels.
310 const gfx::Size coded_size_; 317 const gfx::Size coded_size_;
311 318
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 uint32 release_sync_point_; 355 uint32 release_sync_point_;
349 356
350 const bool end_of_stream_; 357 const bool end_of_stream_;
351 358
352 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 359 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
353 }; 360 };
354 361
355 } // namespace media 362 } // namespace media
356 363
357 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 364 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698