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

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

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

Powered by Google App Engine
This is Rietveld 408576698