| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 MEDIA_GPU_D3D11_H264_ACCELERATOR_H_ |
| 6 #define MEDIA_GPU_D3D11_H264_ACCELERATOR_H_ |
| 7 |
| 8 #include <d3d11.h> |
| 9 #include <d3d9.h> |
| 10 #include <dxva.h> |
| 11 |
| 12 #include <vector> |
| 13 |
| 14 #include "base/win/scoped_comptr.h" |
| 15 #include "media/gpu/h264_decoder.h" |
| 16 #include "media/gpu/h264_dpb.h" |
| 17 #include "media/video/picture.h" |
| 18 #include "third_party/angle/include/EGL/egl.h" |
| 19 #include "third_party/angle/include/EGL/eglext.h" |
| 20 |
| 21 namespace media { |
| 22 class D3D11H264Accelerator; |
| 23 |
| 24 class D3D11PictureBuffer { |
| 25 public: |
| 26 D3D11PictureBuffer(PictureBuffer picture_buffer, size_t level); |
| 27 ~D3D11PictureBuffer(); |
| 28 |
| 29 bool Init(base::win::ScopedComPtr<ID3D11VideoDevice> video_device, |
| 30 base::win::ScopedComPtr<ID3D11Texture2D> texture, |
| 31 const GUID& decoder_guid); |
| 32 |
| 33 size_t level() const { return level_; } |
| 34 |
| 35 PictureBuffer& picture_buffer() { return picture_buffer_; } |
| 36 |
| 37 bool in_client_use() const { return in_client_use_; } |
| 38 bool in_picture_use() const { return in_picture_use_; } |
| 39 void set_in_client_use(bool use) { in_client_use_ = use; } |
| 40 void set_in_picture_use(bool use) { in_picture_use_ = use; } |
| 41 |
| 42 private: |
| 43 friend class D3D11H264Accelerator; |
| 44 |
| 45 PictureBuffer picture_buffer_; |
| 46 base::win::ScopedComPtr<ID3D11Texture2D> texture_; |
| 47 bool in_picture_use_ = false; |
| 48 bool in_client_use_ = false; |
| 49 size_t level_; |
| 50 base::win::ScopedComPtr<ID3D11VideoDecoderOutputView> output_view_; |
| 51 EGLStreamKHR stream_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(D3D11PictureBuffer); |
| 54 }; |
| 55 |
| 56 class D3D11VideoDecoderClient { |
| 57 public: |
| 58 virtual size_t input_buffer_id() const = 0; |
| 59 virtual D3D11PictureBuffer* GetPicture() = 0; |
| 60 virtual void OutputResult(D3D11PictureBuffer* picture, |
| 61 size_t input_buffer_id) = 0; |
| 62 }; |
| 63 |
| 64 class D3D11H264Accelerator : public H264Decoder::H264Accelerator { |
| 65 public: |
| 66 D3D11H264Accelerator( |
| 67 D3D11VideoDecoderClient* client, |
| 68 base::win::ScopedComPtr<ID3D11VideoDecoder> video_decoder, |
| 69 base::win::ScopedComPtr<ID3D11VideoDevice> video_device, |
| 70 base::win::ScopedComPtr<ID3D11VideoContext> video_context); |
| 71 ~D3D11H264Accelerator() override; |
| 72 |
| 73 // H264Decoder::H264Accelerator implementation. |
| 74 scoped_refptr<H264Picture> CreateH264Picture() override; |
| 75 bool SubmitFrameMetadata(const H264SPS* sps, |
| 76 const H264PPS* pps, |
| 77 const H264DPB& dpb, |
| 78 const H264Picture::Vector& ref_pic_listp0, |
| 79 const H264Picture::Vector& ref_pic_listb0, |
| 80 const H264Picture::Vector& ref_pic_listb1, |
| 81 const scoped_refptr<H264Picture>& pic) override; |
| 82 bool SubmitSlice(const H264PPS* pps, |
| 83 const H264SliceHeader* slice_hdr, |
| 84 const H264Picture::Vector& ref_pic_list0, |
| 85 const H264Picture::Vector& ref_pic_list1, |
| 86 const scoped_refptr<H264Picture>& pic, |
| 87 const uint8_t* data, |
| 88 size_t size) override; |
| 89 bool SubmitDecode(const scoped_refptr<H264Picture>& pic) override; |
| 90 void Reset() override {} |
| 91 bool OutputPicture(const scoped_refptr<H264Picture>& pic) override; |
| 92 |
| 93 private: |
| 94 void SubmitSliceData(); |
| 95 void RetrieveBitstreamBuffer(); |
| 96 |
| 97 D3D11VideoDecoderClient* client_; |
| 98 |
| 99 base::win::ScopedComPtr<ID3D11VideoDecoder> video_decoder_; |
| 100 base::win::ScopedComPtr<ID3D11VideoDevice> video_device_; |
| 101 base::win::ScopedComPtr<ID3D11VideoContext> video_context_; |
| 102 |
| 103 // This information set at the beginning of a frame and saved for processing |
| 104 // all the slices. |
| 105 DXVA_PicEntry_H264 ref_frame_list_[16]; |
| 106 H264SPS sps_; |
| 107 INT field_order_cnt_list_[16][2]; |
| 108 USHORT frame_num_list_[16]; |
| 109 UINT used_for_reference_flags_; |
| 110 USHORT non_existing_frame_flags_; |
| 111 |
| 112 // Information that's accumulated during slices and submitted at the end |
| 113 std::vector<DXVA_Slice_H264_Short> slice_info_; |
| 114 size_t current_offset_ = 0; |
| 115 size_t bitstream_buffer_size_; |
| 116 uint8_t* bitstream_buffer_bytes_; |
| 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(D3D11H264Accelerator); |
| 119 }; |
| 120 |
| 121 } // namespace media |
| 122 |
| 123 #endif // MEDIA_GPU_D3D11_H264_ACCELERATOR_H_ |
| OLD | NEW |