OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains an implementation of a class that provides H264 decode | 5 // This file contains an implementation of a class that provides H264 decode |
6 // support for use with VAAPI hardware video decode acceleration on Intel | 6 // support for use with VAAPI hardware video decode acceleration on Intel |
7 // systems. | 7 // systems. |
8 | 8 |
9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ | 9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ |
10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ |
(...skipping 16 matching lines...) Expand all Loading... |
27 // picture management and other operations not supported by the HW codec. | 27 // picture management and other operations not supported by the HW codec. |
28 // | 28 // |
29 // Provides functionality to allow plugging VAAPI HW acceleration into the | 29 // Provides functionality to allow plugging VAAPI HW acceleration into the |
30 // VDA framework. | 30 // VDA framework. |
31 // | 31 // |
32 // Clients of this class are expected to pass H264 Annex-B byte stream and | 32 // Clients of this class are expected to pass H264 Annex-B byte stream and |
33 // will receive decoded surfaces via client-provided |OutputPicCB|. | 33 // will receive decoded surfaces via client-provided |OutputPicCB|. |
34 // | 34 // |
35 // This class must be created, called and destroyed on a single thread, and | 35 // This class must be created, called and destroyed on a single thread, and |
36 // does nothing internally on any other thread. | 36 // does nothing internally on any other thread. |
37 class VaapiH264Decoder { | 37 class CONTENT_EXPORT VaapiH264Decoder { |
38 public: | 38 public: |
39 // Callback invoked on the client when a surface is to be displayed. | 39 // Callback invoked on the client when a surface is to be displayed. |
40 // Arguments: input buffer id provided at the time of Decode() | 40 // Arguments: input buffer id provided at the time of Decode() |
41 // and VASurface to output. | 41 // and VASurface to output. |
42 typedef base::Callback< | 42 typedef base::Callback< |
43 void(int32, const scoped_refptr<VASurface>&)> OutputPicCB; | 43 void(int32, const scoped_refptr<VASurface>&)> OutputPicCB; |
44 | 44 |
45 enum VAVDAH264DecoderFailure { | 45 enum VAVDAH264DecoderFailure { |
46 FRAME_MBS_ONLY_FLAG_NOT_ONE = 0, | 46 FRAME_MBS_ONLY_FLAG_NOT_ONE = 0, |
47 GAPS_IN_FRAME_NUM = 1, | 47 GAPS_IN_FRAME_NUM = 1, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // To be called during decoding. | 85 // To be called during decoding. |
86 // Stop (pause) decoding, discarding all remaining inputs and outputs, | 86 // Stop (pause) decoding, discarding all remaining inputs and outputs, |
87 // but do not flush decoder state, so that the playback can be resumed later, | 87 // but do not flush decoder state, so that the playback can be resumed later, |
88 // possibly from a different location. | 88 // possibly from a different location. |
89 void Reset(); | 89 void Reset(); |
90 | 90 |
91 // Set current stream data pointer to |ptr| and |size|. Output surfaces | 91 // Set current stream data pointer to |ptr| and |size|. Output surfaces |
92 // that are decoded from data in this stream chunk are to be returned along | 92 // that are decoded from data in this stream chunk are to be returned along |
93 // with the given |input_id|. | 93 // with the given |input_id|. |
94 void SetStream(uint8* ptr, size_t size, int32 input_id); | 94 void SetStream(const uint8* ptr, size_t size, int32 input_id); |
95 | 95 |
96 // Try to decode more of the stream, returning decoded frames asynchronously | 96 // Try to decode more of the stream, returning decoded frames asynchronously |
97 // via output_pic_cb_. Return when more stream is needed, when we run out | 97 // via output_pic_cb_. Return when more stream is needed, when we run out |
98 // of free surfaces, when we need a new set of them, or when an error occurs. | 98 // of free surfaces, when we need a new set of them, or when an error occurs. |
99 DecResult Decode() WARN_UNUSED_RESULT; | 99 DecResult Decode() WARN_UNUSED_RESULT; |
100 | 100 |
101 // Return dimensions/required number of output surfaces that client should | 101 // Return dimensions/required number of output surfaces that client should |
102 // be ready to provide for the decoder to function properly. | 102 // be ready to provide for the decoder to function properly. |
103 // To be used after Decode() returns kNeedNewSurfaces. | 103 // To be used after Decode() returns kNeedNewSurfaces. |
104 gfx::Size GetPicSize() { return pic_size_; } | 104 gfx::Size GetPicSize() { return pic_size_; } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 // PicOrderCount of the previously outputted frame. | 284 // PicOrderCount of the previously outputted frame. |
285 int last_output_poc_; | 285 int last_output_poc_; |
286 | 286 |
287 DISALLOW_COPY_AND_ASSIGN(VaapiH264Decoder); | 287 DISALLOW_COPY_AND_ASSIGN(VaapiH264Decoder); |
288 }; | 288 }; |
289 | 289 |
290 } // namespace content | 290 } // namespace content |
291 | 291 |
292 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ | 292 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ |
OLD | NEW |