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

Side by Side Diff: content/common/gpu/media/va_surface.h

Issue 14914009: VAVDA: Redesign stage 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add CONTENT_EXPORT to VaapiWrapper Created 7 years, 6 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
« no previous file with comments | « content/common/gpu/media/h264_dpb.cc ('k') | content/common/gpu/media/vaapi_h264_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 //
5 // This file contains the definition of VASurface class, used for decoding by
6 // VaapiVideoDecodeAccelerator and VaapiH264Decoder.
7
8 #ifndef CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_
9 #define CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_
10
11 #include "third_party/libva/va/va.h"
12
13 namespace content {
14
15 // A VA-API-specific decode surface used by VaapiH264Decoder to decode into
16 // and use as reference for decoding other surfaces. It is also handed by the
17 // decoder to VaapiVideoDecodeAccelerator when the contents of the surface are
18 // ready and should be displayed. VAVDA converts the surface contents into an
19 // X Pixmap bound to a texture for display and releases its reference to it.
20 // Decoder releases its references to the surface when it's done decoding and
21 // using it as reference. Note that a surface may still be used for reference
22 // after it's been sent to output and also after it is no longer used by VAVDA.
23 // Thus, the surface can be in use by both VAVDA and the Decoder at the same
24 // time, or by either of them, with the restriction that VAVDA will never get
25 // the surface until the contents are ready, and it is guaranteed that the
26 // contents will not change after that.
27 // When both the decoder and VAVDA release their references to the surface,
28 // it is freed and the release callback is executed to put the surface back
29 // into available surfaces pool, which is managed externally.
30 //
31 // VASurfaceID is allocated in VaapiWrapper.
32 // |
33 // +----->|
34 // | v
35 // | VASurfaceID is put onto VaapiVideoDecodeAccelerator::available_va_surfaces_
36 // | | list.
37 // | v
38 // | VASurfaceID is taken off of the VVDA:available_va_surfaces_ when
39 // | | VaapiH264Decoder requests more output surfaces, is wrapped into
40 // | | a VASurface and passed to VaapiH264Decoder.
41 // | v
42 // | VASurface is put onto VaapiH264Decoder::available_va_surfaces_, keeping
43 // | | the only reference to it until it's needed for decoding.
44 // | v
45 // | VaapiH264Decoder starts decoding a new frame. It takes a VASurface off of
46 // | | VHD::available_va_surfaces_ and assigns it to a DecodeSurface,
47 // | | which now keeps the only reference.
48 // | v
49 // | DecodeSurface is used for decoding, putting data into associated VASurface.
50 // | |
51 // | |--------------------------------------------------+
52 // | | |
53 // | v v
54 // | DecodeSurface is to be output. VaapiH264Decoder uses the
55 // | VaapiH264Decoder passes the associated DecodeSurface and associated
56 // | VASurface to VaapiVideoDecodeAccelerator, VASurface as reference for
57 // | which stores it (taking a ref) on decoding more frames.
58 // | pending_output_cbs_ queue until an output |
59 // | TFPPicture becomes available. v
60 // | | Once the DecodeSurface is not
61 // | | needed as reference anymore,
62 // | v it is released, releasing the
63 // | A TFPPicture becomes available after associated VASurface reference.
64 // | the client of VVDA returns |
65 // | a PictureBuffer associated with it. VVDA |
66 // | puts the contents of the VASurface into |
67 // | it and releases the reference to VASurface. |
68 // | | |
69 // | '---------------------------------------'
70 // | |
71 // | v
72 // | Neither VVDA nor VHD hold a reference to VASurface. VASurface is released,
73 // | ReleaseCB gets called in its destructor, which puts the associated
74 // | VASurfaceID back onto VVDA::available_va_surfaces_.
75 // | |
76 // '-------------------------------------|
77 // |
78 // v
79 // VaapiWrapper frees VASurfaceID.
80 //
81 class VASurface : public base::RefCountedThreadSafe<VASurface> {
82 public:
83 // Provided by user, will be called when all references to the surface
84 // are released.
85 typedef base::Callback<void(VASurfaceID)> ReleaseCB;
86
87 VASurface(VASurfaceID va_surface_id, const ReleaseCB& release_cb);
88
89 VASurfaceID id() {
90 return va_surface_id_;
91 }
92
93 private:
94 friend class base::RefCountedThreadSafe<VASurface>;
95 ~VASurface();
96
97 const VASurfaceID va_surface_id_;
98 ReleaseCB release_cb_;
99
100 DISALLOW_COPY_AND_ASSIGN(VASurface);
101 };
102
103 } // namespace content
104
105 #endif // CONTENT_COMMON_GPU_MEDIA_VA_SURFACE_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/h264_dpb.cc ('k') | content/common/gpu/media/vaapi_h264_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698