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

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

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues Created 4 years, 8 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_VP8_DECODER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VP8_DECODER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <memory>
12
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "content/common/gpu/media/accelerated_video_decoder.h"
16 #include "content/common/gpu/media/vp8_picture.h"
17 #include "media/filters/vp8_parser.h"
18
19 namespace content {
20
21 // Clients of this class are expected to pass raw VP8 stream and are expected
22 // to provide an implementation of VP8Accelerator for offloading final steps
23 // of the decoding process.
24 //
25 // This class must be created, called and destroyed on a single thread, and
26 // does nothing internally on any other thread.
27 class CONTENT_EXPORT VP8Decoder : public AcceleratedVideoDecoder {
28 public:
29 class CONTENT_EXPORT VP8Accelerator {
30 public:
31 VP8Accelerator();
32 virtual ~VP8Accelerator();
33
34 // Create a new VP8Picture that the decoder client can use for decoding
35 // and pass back to this accelerator for decoding or reference.
36 // When the picture is no longer needed by decoder, it will just drop
37 // its reference to it, and it may do so at any time.
38 // Note that this may return nullptr if accelerator is not able to provide
39 // any new pictures at given time. The decoder is expected to handle
40 // this situation as normal and return from Decode() with kRanOutOfSurfaces.
41 virtual scoped_refptr<VP8Picture> CreateVP8Picture() = 0;
42
43 // Submit decode for |pic|, taking as arguments |frame_hdr| with parsed
44 // VP8 frame header information for current frame, and using |last_frame|,
45 // |golden_frame| and |alt_frame| as references, as per VP8 specification.
46 // Note that this runs the decode in hardware.
47 // Return true if successful.
48 virtual bool SubmitDecode(const scoped_refptr<VP8Picture>& pic,
49 const media::Vp8FrameHeader* frame_hdr,
50 const scoped_refptr<VP8Picture>& last_frame,
51 const scoped_refptr<VP8Picture>& golden_frame,
52 const scoped_refptr<VP8Picture>& alt_frame) = 0;
53
54 // Schedule output (display) of |pic|. Note that returning from this
55 // method does not mean that |pic| has already been outputted (displayed),
56 // but guarantees that all pictures will be outputted in the same order
57 // as this method was called for them. Decoder may drop its reference
58 // to |pic| after calling this method.
59 // Return true if successful.
60 virtual bool OutputPicture(const scoped_refptr<VP8Picture>& pic) = 0;
61
62 private:
63 DISALLOW_COPY_AND_ASSIGN(VP8Accelerator);
64 };
65
66 VP8Decoder(VP8Accelerator* accelerator);
67 ~VP8Decoder() override;
68
69 // content::AcceleratedVideoDecoder implementation.
70 bool Flush() override WARN_UNUSED_RESULT;
71 void Reset() override;
72 void SetStream(const uint8_t* ptr, size_t size) override;
73 DecodeResult Decode() override WARN_UNUSED_RESULT;
74 gfx::Size GetPicSize() const override;
75 size_t GetRequiredNumOfPictures() const override;
76
77 private:
78 bool DecodeAndOutputCurrentFrame();
79 void RefreshReferenceFrames();
80
81 enum State {
82 kNeedStreamMetadata, // After initialization, need a keyframe.
83 kDecoding, // Ready to decode from any point.
84 kAfterReset, // After Reset(), need a resume point.
85 kError, // Error in decode, can't continue.
86 };
87
88 State state_;
89
90 media::Vp8Parser parser_;
91
92 std::unique_ptr<media::Vp8FrameHeader> curr_frame_hdr_;
93 scoped_refptr<VP8Picture> curr_pic_;
94 scoped_refptr<VP8Picture> last_frame_;
95 scoped_refptr<VP8Picture> golden_frame_;
96 scoped_refptr<VP8Picture> alt_frame_;
97
98 const uint8_t* curr_frame_start_;
99 size_t frame_size_;
100
101 gfx::Size pic_size_;
102 int horizontal_scale_;
103 int vertical_scale_;
104
105 VP8Accelerator* accelerator_;
106
107 DISALLOW_COPY_AND_ASSIGN(VP8Decoder);
108 };
109
110 } // namespace content
111
112 #endif // CONTENT_COMMON_GPU_MEDIA_VP8_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698