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

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

Issue 2229353002: V4L2SVDA: Add a VP9Accelerator implementation utilizing the V4L2 VP9 frame API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compilation fixes Created 4 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 | « media/gpu/vaapi_video_decode_accelerator.cc ('k') | media/gpu/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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_GPU_VP9_DECODER_H_ 5 #ifndef MEDIA_GPU_VP9_DECODER_H_
6 #define MEDIA_GPU_VP9_DECODER_H_ 6 #define MEDIA_GPU_VP9_DECODER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_forward.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "media/filters/vp9_parser.h" 17 #include "media/filters/vp9_parser.h"
17 #include "media/gpu/accelerated_video_decoder.h" 18 #include "media/gpu/accelerated_video_decoder.h"
18 #include "media/gpu/vp9_picture.h" 19 #include "media/gpu/vp9_picture.h"
19 20
20 namespace media { 21 namespace media {
21 22
22 // This class implements an AcceleratedVideoDecoder for VP9 decoding. 23 // This class implements an AcceleratedVideoDecoder for VP9 decoding.
23 // Clients of this class are expected to pass raw VP9 stream and are expected 24 // Clients of this class are expected to pass raw VP9 stream and are expected
(...skipping 17 matching lines...) Expand all
41 // When a picture is no longer needed by the decoder, it will just drop 42 // When a picture is no longer needed by the decoder, it will just drop
42 // its reference to it, and it may do so at any time. 43 // its reference to it, and it may do so at any time.
43 // 44 //
44 // Note that this may return nullptr if the accelerator is not able to 45 // Note that this may return nullptr if the accelerator is not able to
45 // provide any new pictures at the given time. The decoder must handle this 46 // provide any new pictures at the given time. The decoder must handle this
46 // case and treat it as normal, returning kRanOutOfSurfaces from Decode(). 47 // case and treat it as normal, returning kRanOutOfSurfaces from Decode().
47 virtual scoped_refptr<VP9Picture> CreateVP9Picture() = 0; 48 virtual scoped_refptr<VP9Picture> CreateVP9Picture() = 0;
48 49
49 // Submit decode for |pic| to be run in accelerator, taking as arguments 50 // Submit decode for |pic| to be run in accelerator, taking as arguments
50 // information contained in it, as well as current segmentation and loop 51 // information contained in it, as well as current segmentation and loop
51 // filter state in |seg| and |lf|, respectively, and using pictures in 52 // filter state in |segm_params| and |lf_params|, respectively, and using
52 // |ref_pictures| for reference. 53 // pictures in |ref_pictures| for reference.
54 // If done_cb_ is not null, it will be run once decode is done in hardware.
53 // 55 //
54 // Note that returning from this method does not mean that the decode 56 // Note that returning from this method does not mean that the decode
55 // process is finished, but the caller may drop its references to |pic| 57 // process is finished, but the caller may drop its references to |pic|
56 // and |ref_pictures| immediately, and the data in |seg| and |lf| does not 58 // and |ref_pictures| immediately, and the data in |segm_params| and
57 // need to remain valid after this method returns. 59 // |lf_params| does not need to remain valid after this method returns.
58 // 60 //
59 // Return true when successful, false otherwise. 61 // Return true when successful, false otherwise.
60 virtual bool SubmitDecode( 62 virtual bool SubmitDecode(
61 const scoped_refptr<VP9Picture>& pic, 63 const scoped_refptr<VP9Picture>& pic,
62 const Vp9SegmentationParams& seg, 64 const Vp9SegmentationParams& segm_params,
63 const Vp9LoopFilterParams& lf, 65 const Vp9LoopFilterParams& lf_params,
64 const std::vector<scoped_refptr<VP9Picture>>& ref_pictures) = 0; 66 const std::vector<scoped_refptr<VP9Picture>>& ref_pictures,
67 const base::Closure& done_cb) = 0;
65 68
66 // Schedule output (display) of |pic|. 69 // Schedule output (display) of |pic|.
67 // 70 //
68 // Note that returning from this method does not mean that |pic| has already 71 // Note that returning from this method does not mean that |pic| has already
69 // been outputted (displayed), but guarantees that all pictures will be 72 // been outputted (displayed), but guarantees that all pictures will be
70 // outputted in the same order as this method was called for them, and that 73 // outputted in the same order as this method was called for them, and that
71 // they are decoded before outputting (assuming SubmitDecode() has been 74 // they are decoded before outputting (assuming SubmitDecode() has been
72 // called for them beforehand). Decoder may drop its references to |pic| 75 // called for them beforehand). Decoder may drop its references to |pic|
73 // immediately after calling this method. 76 // immediately after calling this method.
74 // 77 //
75 // Return true when successful, false otherwise. 78 // Return true when successful, false otherwise.
76 virtual bool OutputPicture(const scoped_refptr<VP9Picture>& pic) = 0; 79 virtual bool OutputPicture(const scoped_refptr<VP9Picture>& pic) = 0;
77 80
81 // Return true if the accelerator requires the client to provide frame
82 // context in order to decode. If so, the Vp9FrameHeader provided by the
83 // client must contain a valid compressed header and frame context data.
84 virtual bool IsFrameContextRequired() const = 0;
85
86 // Set |frame_ctx| to the state after decoding |pic|, returning true on
87 // success, false otherwise.
88 virtual bool GetFrameContext(const scoped_refptr<VP9Picture>& pic,
89 Vp9FrameContext* frame_ctx) = 0;
90
78 private: 91 private:
79 DISALLOW_COPY_AND_ASSIGN(VP9Accelerator); 92 DISALLOW_COPY_AND_ASSIGN(VP9Accelerator);
80 }; 93 };
81 94
82 VP9Decoder(VP9Accelerator* accelerator); 95 explicit VP9Decoder(VP9Accelerator* accelerator);
83 ~VP9Decoder() override; 96 ~VP9Decoder() override;
84 97
85 // AcceleratedVideoDecoder implementation. 98 // AcceleratedVideoDecoder implementation.
86 void SetStream(const uint8_t* ptr, size_t size) override; 99 void SetStream(const uint8_t* ptr, size_t size) override;
87 bool Flush() override WARN_UNUSED_RESULT; 100 bool Flush() override WARN_UNUSED_RESULT;
88 void Reset() override; 101 void Reset() override;
89 DecodeResult Decode() override WARN_UNUSED_RESULT; 102 DecodeResult Decode() override WARN_UNUSED_RESULT;
90 gfx::Size GetPicSize() const override; 103 gfx::Size GetPicSize() const override;
91 size_t GetRequiredNumOfPictures() const override; 104 size_t GetRequiredNumOfPictures() const override;
92 105
93 private: 106 private:
94 // Update ref_frames_ based on the information in current frame header. 107 // Update ref_frames_ based on the information in current frame header.
95 void RefreshReferenceFrames(const scoped_refptr<VP9Picture>& pic); 108 void RefreshReferenceFrames(const scoped_refptr<VP9Picture>& pic);
96 109
97 // Decode and possibly output |pic| (if the picture is to be shown). 110 // Decode and possibly output |pic| (if the picture is to be shown).
98 // Return true on success, false otherwise. 111 // Return true on success, false otherwise.
99 bool DecodeAndOutputPicture(scoped_refptr<VP9Picture> pic); 112 bool DecodeAndOutputPicture(scoped_refptr<VP9Picture> pic);
100 113
114 // Get frame context state after decoding |pic| from the accelerator, and call
115 // |context_refresh_cb| with the acquired state.
116 void UpdateFrameContext(
117 const scoped_refptr<VP9Picture>& pic,
118 const base::Callback<void(const Vp9FrameContext&)>& context_refresh_cb);
119
101 // Called on error, when decoding cannot continue. Sets state_ to kError and 120 // Called on error, when decoding cannot continue. Sets state_ to kError and
102 // releases current state. 121 // releases current state.
103 void SetError(); 122 void SetError();
104 123
105 enum State { 124 enum State {
106 kNeedStreamMetadata, // After initialization, need a keyframe. 125 kNeedStreamMetadata, // After initialization, need a keyframe.
107 kDecoding, // Ready to decode from any point. 126 kDecoding, // Ready to decode from any point.
108 kAfterReset, // After Reset(), need a resume point. 127 kAfterReset, // After Reset(), need a resume point.
109 kError, // Error in decode, can't continue. 128 kError, // Error in decode, can't continue.
110 }; 129 };
111 130
112 // Current decoder state. 131 // Current decoder state.
113 State state_; 132 State state_;
114 133
115 // Current frame header to be used in decoding the next picture. 134 // Current frame header to be used in decoding the next picture.
116 std::unique_ptr<Vp9FrameHeader> curr_frame_hdr_; 135 std::unique_ptr<Vp9FrameHeader> curr_frame_hdr_;
117 136
118 // Reference frames currently in use. 137 // Reference frames currently in use.
119 std::vector<scoped_refptr<VP9Picture>> ref_frames_; 138 std::vector<scoped_refptr<VP9Picture>> ref_frames_;
120 139
121 // Current coded resolution. 140 // Current coded resolution.
122 gfx::Size pic_size_; 141 gfx::Size pic_size_;
123 142
124 Vp9Parser parser_;
125
126 // VP9Accelerator instance owned by the client. 143 // VP9Accelerator instance owned by the client.
127 VP9Accelerator* accelerator_; 144 VP9Accelerator* accelerator_;
128 145
146 Vp9Parser parser_;
147
129 DISALLOW_COPY_AND_ASSIGN(VP9Decoder); 148 DISALLOW_COPY_AND_ASSIGN(VP9Decoder);
130 }; 149 };
131 150
132 } // namespace media 151 } // namespace media
133 152
134 #endif // MEDIA_GPU_VP9_DECODER_H_ 153 #endif // MEDIA_GPU_VP9_DECODER_H_
OLDNEW
« no previous file with comments | « media/gpu/vaapi_video_decode_accelerator.cc ('k') | media/gpu/vp9_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698