• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 // Note: ported from Chromium commit head: d264e47
5 
6 #ifndef PICTURE_H_
7 #define PICTURE_H_
8 
9 #include <stdint.h>
10 
11 #include <vector>
12 
13 #include "rect.h"
14 #include "size.h"
15 #include "video_pixel_format.h"
16 
17 namespace media {
18 
19 // A picture buffer that has size and pixel format information.
20 class PictureBuffer {
21  public:
22   PictureBuffer(int32_t id, const Size& size);
23   PictureBuffer(int32_t id,
24                 const Size& size,
25                 VideoPixelFormat pixel_format);
26   PictureBuffer(const PictureBuffer& other);
27   ~PictureBuffer();
28 
29   // Returns the client-specified id of the buffer.
id()30   int32_t id() const { return id_; }
31 
32   // Returns the size of the buffer.
size()33   Size size() const { return size_; }
34 
set_size(const Size & size)35   void set_size(const Size& size) { size_ = size; }
36 
pixel_format()37   VideoPixelFormat pixel_format() const { return pixel_format_; }
38 
39  private:
40   int32_t id_;
41   Size size_;
42   VideoPixelFormat pixel_format_ = PIXEL_FORMAT_UNKNOWN;
43 };
44 
45 // A decoded picture frame.
46 class Picture {
47  public:
48   Picture(int32_t picture_buffer_id,
49           int32_t bitstream_buffer_id,
50           const Rect& visible_rect,
51           bool allow_overlay);
52   Picture(const Picture&);
53   ~Picture();
54 
55   // Returns the id of the picture buffer where this picture is contained.
picture_buffer_id()56   int32_t picture_buffer_id() const { return picture_buffer_id_; }
57 
58   // Returns the id of the bitstream buffer from which this frame was decoded.
bitstream_buffer_id()59   int32_t bitstream_buffer_id() const { return bitstream_buffer_id_; }
60 
set_bitstream_buffer_id(int32_t bitstream_buffer_id)61   void set_bitstream_buffer_id(int32_t bitstream_buffer_id) {
62     bitstream_buffer_id_ = bitstream_buffer_id;
63   }
64 
65   // Returns the visible rectangle of the picture. Its size may be smaller
66   // than the size of the PictureBuffer, as it is the only visible part of the
67   // Picture contained in the PictureBuffer.
visible_rect()68   Rect visible_rect() const { return visible_rect_; }
69 
allow_overlay()70   bool allow_overlay() const { return allow_overlay_; }
71 
72  private:
73   int32_t picture_buffer_id_;
74   int32_t bitstream_buffer_id_;
75   Rect visible_rect_;
76   bool allow_overlay_;
77 };
78 
79 }  // namespace media
80 
81 #endif  // PICTURE_H_
82