| Index: content/common/gpu/media/dxva_video_decode_accelerator.h
|
| ===================================================================
|
| --- content/common/gpu/media/dxva_video_decode_accelerator.h (revision 0)
|
| +++ content/common/gpu/media/dxva_video_decode_accelerator.h (revision 0)
|
| @@ -0,0 +1,118 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_COMMON_GPU_MEDIA_DVX_VIDEO_DECODE_ACCELERATOR_H_
|
| +#define CONTENT_COMMON_GPU_MEDIA_DVX_VIDEO_DECODE_ACCELERATOR_H_
|
| +
|
| +#include <d3d9.h>
|
| +#include <dxva2api.h>
|
| +#include <map>
|
| +#include <mfidl.h>
|
| +#include <vector>
|
| +
|
| +#include "base/message_loop.h"
|
| +#include "base/win/scoped_comptr.h"
|
| +#include "media/video/video_decode_accelerator.h"
|
| +#include "third_party/angle/include/EGL/egl.h"
|
| +#include "third_party/angle/include/EGL/eglext.h"
|
| +
|
| +interface IMFSample;
|
| +interface IDirect3DSurface9;
|
| +
|
| +// Class to provide a DXVA 2.0 based accelerator behind VideoDecodeAccelerator
|
| +// interface.
|
| +// This class lives on a single thread and DCHECKs that it is never accessed
|
| +// from any other.
|
| +class DXVAVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
|
| + public:
|
| + typedef enum {
|
| + kUninitialized, // un-initialized.
|
| + kNormal, // normal playing state.
|
| + kResetting, // upon received Reset(), before ResetDone()
|
| + kEosDrain, // upon input EOS received.
|
| + kStopped, // upon output EOS received.
|
| + } State;
|
| +
|
| + struct DXVAPictureBuffer {
|
| + DXVAPictureBuffer()
|
| + : picture_buffer(0, gfx::Size(), 0) {
|
| + available = false;
|
| + }
|
| + bool available;
|
| + media::PictureBuffer picture_buffer;
|
| + };
|
| +
|
| + // Does not take ownership of |client| which must outlive |*this|.
|
| + explicit DXVAVideoDecodeAccelerator(
|
| + media::VideoDecodeAccelerator::Client* client);
|
| + virtual ~DXVAVideoDecodeAccelerator();
|
| +
|
| + // media::VideoDecodeAccelerator implementation.
|
| + bool Initialize(Profile profile) OVERRIDE;
|
| + void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
|
| + virtual void AssignPictureBuffers(
|
| + const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
|
| + void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
|
| + void Flush() OVERRIDE;
|
| + void Reset() OVERRIDE;
|
| + void Destroy() OVERRIDE;
|
| +
|
| + void SetEglState(EGLDisplay egl_display, EGLContext egl_context);
|
| +
|
| + private:
|
| + bool CreateD3DDevManager();
|
| + bool InitDecoder();
|
| + bool CheckDecoderDxvaSupport();
|
| + bool SetDecoderMediaTypes();
|
| + bool SetDecoderInputMediaType();
|
| + bool SetDecoderOutputMediaType(const GUID& subtype);
|
| + bool SendMFTMessage(MFT_MESSAGE_TYPE msg);
|
| + bool GetStreamsInfoAndBufferReqs();
|
| + bool DoDecode();
|
| + bool ProcessOutputSample(IMFSample* sample);
|
| + bool CopyOutputSampleDataToPictureBuffer(IMFSample* sample,
|
| + IDirect3DSurface9* surface,
|
| + media::PictureBuffer buffer);
|
| +
|
| + private:
|
| + MessageLoop* message_loop_;
|
| + // To expose client callbacks from VideoDecodeAccelerator.
|
| + // NOTE: all calls to this object *MUST* be executed in message_loop_.
|
| + media::VideoDecodeAccelerator::Client* client_;
|
| +
|
| + EGLDisplay egl_display_;
|
| + EGLContext egl_context_;
|
| + base::win::ScopedComPtr<IDirect3D9> d3d9_;
|
| + base::win::ScopedComPtr<IDirect3DDevice9> device_;
|
| + base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_;
|
| + base::win::ScopedComPtr<IMFTransform> decoder_;
|
| +
|
| + UINT32 surface_width_;
|
| + UINT32 surface_height_;
|
| +
|
| + State state_;
|
| +
|
| + // Encoded bitstream buffers awaiting decode.
|
| + typedef std::vector<media::BitstreamBuffer> BitstreamBufferList;
|
| + BitstreamBufferList queued_bitstream_buffers_;
|
| +
|
| + // Available output picture buffers released during Reset() and awaiting
|
| + // re-use once Reset is done. Is empty most of the time and drained right
|
| + // before NotifyResetDone is sent.
|
| + std::vector<int> queued_picture_buffer_ids_;
|
| + int input_buffers_at_component_;
|
| +
|
| + MFT_INPUT_STREAM_INFO input_stream_info_;
|
| + MFT_OUTPUT_STREAM_INFO output_stream_info_;
|
| +
|
| + typedef std::vector<base::win::ScopedComPtr<IMFSample> >
|
| + PendingOutputSamples;
|
| + PendingOutputSamples pending_output_samples_;
|
| +
|
| + typedef std::map<int32, DXVAPictureBuffer> OutputBuffers;
|
| + OutputBuffers available_pictures_;
|
| +};
|
| +
|
| +#endif // CONTENT_COMMON_GPU_MEDIA_DVX_VIDEO_DECODE_ACCELERATOR_H_
|
| +
|
|
|