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

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

Issue 1345943009: Reland: Add accelerated VP9 decode infrastructure and an implementation for VA-API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « content/common/gpu/media/vaapi_wrapper.cc ('k') | content/common/gpu/media/vp9_decoder.cc » ('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 2015 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 #ifndef CONTENT_COMMON_GPU_MEDIA_VP9_DECODER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VP9_DECODER_H_
7
8 #include <vector>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/gpu/media/accelerated_video_decoder.h"
13 #include "content/common/gpu/media/vp9_picture.h"
14 #include "media/filters/vp9_parser.h"
15
16 namespace content {
17
18 // This class implements an AcceleratedVideoDecoder for VP9 decoding.
19 // Clients of this class are expected to pass raw VP9 stream and are expected
20 // to provide an implementation of VP9Accelerator for offloading final steps
21 // of the decoding process.
22 //
23 // This class must be created, called and destroyed on a single thread, and
24 // does nothing internally on any other thread.
25 class CONTENT_EXPORT VP9Decoder : public AcceleratedVideoDecoder {
26 public:
27 class CONTENT_EXPORT VP9Accelerator {
28 public:
29 VP9Accelerator();
30 virtual ~VP9Accelerator();
31
32 // Create a new VP9Picture that the decoder client can use for initial
33 // stages of the decoding process and pass back to this accelerator for
34 // final, accelerated stages of it, or for reference when decoding other
35 // pictures.
36 //
37 // When a picture is no longer needed by the decoder, it will just drop
38 // its reference to it, and it may do so at any time.
39 //
40 // Note that this may return nullptr if the accelerator is not able to
41 // provide any new pictures at the given time. The decoder must handle this
42 // case and treat it as normal, returning kRanOutOfSurfaces from Decode().
43 virtual scoped_refptr<VP9Picture> CreateVP9Picture() = 0;
44
45 // Submit decode for |pic| to be run in accelerator, taking as arguments
46 // information contained in it, as well as current segmentation and loop
47 // filter state in |seg| and |lf|, respectively, and using pictures in
48 // |ref_pictures| for reference.
49 //
50 // Note that returning from this method does not mean that the decode
51 // process is finished, but the caller may drop its references to |pic|
52 // and |ref_pictures| immediately, and the data in |seg| and |lf| does not
53 // need to remain valid after this method returns.
54 //
55 // Return true when successful, false otherwise.
56 virtual bool SubmitDecode(
57 const scoped_refptr<VP9Picture>& pic,
58 const media::Vp9Segmentation& seg,
59 const media::Vp9LoopFilter& lf,
60 const std::vector<scoped_refptr<VP9Picture>>& ref_pictures) = 0;
61
62 // Schedule output (display) of |pic|.
63 //
64 // Note that returning from this method does not mean that |pic| has already
65 // been outputted (displayed), but guarantees that all pictures will be
66 // outputted in the same order as this method was called for them, and that
67 // they are decoded before outputting (assuming SubmitDecode() has been
68 // called for them beforehand). Decoder may drop its references to |pic|
69 // immediately after calling this method.
70 //
71 // Return true when successful, false otherwise.
72 virtual bool OutputPicture(const scoped_refptr<VP9Picture>& pic) = 0;
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(VP9Accelerator);
76 };
77
78 VP9Decoder(VP9Accelerator* accelerator);
79 ~VP9Decoder() override;
80
81 // content::AcceleratedVideoDecoder implementation.
82 void SetStream(const uint8_t* ptr, size_t size) override;
83 bool Flush() override WARN_UNUSED_RESULT;
84 void Reset() override;
85 DecodeResult Decode() override WARN_UNUSED_RESULT;
86 gfx::Size GetPicSize() const override;
87 size_t GetRequiredNumOfPictures() const override;
88
89 private:
90 // Update ref_frames_ based on the information in current frame header.
91 void RefreshReferenceFrames(const scoped_refptr<VP9Picture>& pic);
92
93 // Decode and possibly output |pic| (if the picture is to be shown).
94 // Return true on success, false otherwise.
95 bool DecodeAndOutputPicture(scoped_refptr<VP9Picture> pic);
96
97 // Called on error, when decoding cannot continue. Sets state_ to kError and
98 // releases current state.
99 void SetError();
100
101 enum State {
102 kNeedStreamMetadata, // After initialization, need a keyframe.
103 kDecoding, // Ready to decode from any point.
104 kAfterReset, // After Reset(), need a resume point.
105 kError, // Error in decode, can't continue.
106 };
107
108 // Current decoder state.
109 State state_;
110
111 // Current frame header to be used in decoding the next picture.
112 scoped_ptr<media::Vp9FrameHeader> curr_frame_hdr_;
113
114 // Reference frames currently in use.
115 std::vector<scoped_refptr<VP9Picture>> ref_frames_;
116
117 // Current coded resolution.
118 gfx::Size pic_size_;
119
120 media::Vp9Parser parser_;
121
122 // VP9Accelerator instance owned by the client.
123 VP9Accelerator* accelerator_;
124
125 DISALLOW_COPY_AND_ASSIGN(VP9Decoder);
126 };
127
128 } // namespace content
129
130 #endif // CONTENT_COMMON_GPU_MEDIA_VP9_DECODER_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_wrapper.cc ('k') | content/common/gpu/media/vp9_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698