| Index: media/gpu/dxva_video_decode_accelerator_win.cc
|
| diff --git a/content/common/gpu/media/dxva_video_decode_accelerator_win.cc b/media/gpu/dxva_video_decode_accelerator_win.cc
|
| similarity index 80%
|
| rename from content/common/gpu/media/dxva_video_decode_accelerator_win.cc
|
| rename to media/gpu/dxva_video_decode_accelerator_win.cc
|
| index 2f270108550b78b543d306c1a134cadc7bd902f8..dbaf5658f5f263d3e8d78952e709310217129c16 100644
|
| --- a/content/common/gpu/media/dxva_video_decode_accelerator_win.cc
|
| +++ b/media/gpu/dxva_video_decode_accelerator_win.cc
|
| @@ -2,13 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/common/gpu/media/dxva_video_decode_accelerator_win.h"
|
| +#include "media/gpu/dxva_video_decode_accelerator_win.h"
|
|
|
| #include <memory>
|
|
|
| #if !defined(OS_WIN)
|
| #error This file should only be built on Windows.
|
| -#endif // !defined(OS_WIN)
|
| +#endif // !defined(OS_WIN)
|
|
|
| #include <codecapi.h>
|
| #include <dxgi1_2.h>
|
| @@ -50,49 +50,45 @@ const wchar_t kVPXDecoderDLLPath[] = L"Intel\\Media SDK\\";
|
|
|
| const wchar_t kVP8DecoderDLLName[] =
|
| #if defined(ARCH_CPU_X86)
|
| - L"mfx_mft_vp8vd_32.dll";
|
| + L"mfx_mft_vp8vd_32.dll";
|
| #elif defined(ARCH_CPU_X86_64)
|
| - L"mfx_mft_vp8vd_64.dll";
|
| + L"mfx_mft_vp8vd_64.dll";
|
| #else
|
| #error Unsupported Windows CPU Architecture
|
| #endif
|
|
|
| const wchar_t kVP9DecoderDLLName[] =
|
| #if defined(ARCH_CPU_X86)
|
| - L"mfx_mft_vp9vd_32.dll";
|
| + L"mfx_mft_vp9vd_32.dll";
|
| #elif defined(ARCH_CPU_X86_64)
|
| - L"mfx_mft_vp9vd_64.dll";
|
| + L"mfx_mft_vp9vd_64.dll";
|
| #else
|
| #error Unsupported Windows CPU Architecture
|
| #endif
|
|
|
| const CLSID CLSID_WebmMfVp8Dec = {
|
| - 0x451e3cb7,
|
| - 0x2622,
|
| - 0x4ba5,
|
| - { 0x8e, 0x1d, 0x44, 0xb3, 0xc4, 0x1d, 0x09, 0x24 }
|
| -};
|
| + 0x451e3cb7,
|
| + 0x2622,
|
| + 0x4ba5,
|
| + {0x8e, 0x1d, 0x44, 0xb3, 0xc4, 0x1d, 0x09, 0x24}};
|
|
|
| const CLSID CLSID_WebmMfVp9Dec = {
|
| - 0x07ab4bd2,
|
| - 0x1979,
|
| - 0x4fcd,
|
| - { 0xa6, 0x97, 0xdf, 0x9a, 0xd1, 0x5b, 0x34, 0xfe }
|
| -};
|
| + 0x07ab4bd2,
|
| + 0x1979,
|
| + 0x4fcd,
|
| + {0xa6, 0x97, 0xdf, 0x9a, 0xd1, 0x5b, 0x34, 0xfe}};
|
|
|
| const CLSID MEDIASUBTYPE_VP80 = {
|
| - 0x30385056,
|
| - 0x0000,
|
| - 0x0010,
|
| - { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
|
| -};
|
| + 0x30385056,
|
| + 0x0000,
|
| + 0x0010,
|
| + {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
|
|
|
| const CLSID MEDIASUBTYPE_VP90 = {
|
| - 0x30395056,
|
| - 0x0000,
|
| - 0x0010,
|
| - { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 }
|
| -};
|
| + 0x30395056,
|
| + 0x0000,
|
| + 0x0010,
|
| + {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
|
|
|
| // The CLSID of the video processor media foundation transform which we use for
|
| // texture color conversion in DX11.
|
| @@ -100,8 +96,17 @@ const CLSID MEDIASUBTYPE_VP90 = {
|
| // to detect which SDK we are compiling with.
|
| #if VER_PRODUCTBUILD < 10011 // VER_PRODUCTBUILD for 10.0.10158.0 SDK.
|
| DEFINE_GUID(CLSID_VideoProcessorMFT,
|
| - 0x88753b26, 0x5b24, 0x49bd, 0xb2, 0xe7, 0xc, 0x44, 0x5c, 0x78,
|
| - 0xc9, 0x82);
|
| + 0x88753b26,
|
| + 0x5b24,
|
| + 0x49bd,
|
| + 0xb2,
|
| + 0xe7,
|
| + 0xc,
|
| + 0x44,
|
| + 0x5c,
|
| + 0x78,
|
| + 0xc9,
|
| + 0x82);
|
| #endif
|
|
|
| // MF_XVP_PLAYBACK_MODE
|
| @@ -109,57 +114,69 @@ DEFINE_GUID(CLSID_VideoProcessorMFT,
|
| // If this attribute is TRUE, the video processor will run in playback mode
|
| // where it allows callers to allocate output samples and allows last frame
|
| // regeneration (repaint).
|
| -DEFINE_GUID(MF_XVP_PLAYBACK_MODE, 0x3c5d293f, 0xad67, 0x4e29, 0xaf, 0x12,
|
| - 0xcf, 0x3e, 0x23, 0x8a, 0xcc, 0xe9);
|
| +DEFINE_GUID(MF_XVP_PLAYBACK_MODE,
|
| + 0x3c5d293f,
|
| + 0xad67,
|
| + 0x4e29,
|
| + 0xaf,
|
| + 0x12,
|
| + 0xcf,
|
| + 0x3e,
|
| + 0x23,
|
| + 0x8a,
|
| + 0xcc,
|
| + 0xe9);
|
|
|
| // Defines the GUID for the Intel H264 DXVA device.
|
| static const GUID DXVA2_Intel_ModeH264_E = {
|
| - 0x604F8E68, 0x4951, 0x4c54,{ 0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6}
|
| -};
|
| + 0x604F8E68,
|
| + 0x4951,
|
| + 0x4c54,
|
| + {0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6}};
|
|
|
| // R600, R700, Evergreen and Cayman AMD cards. These support DXVA via UVD3
|
| // or earlier, and don't handle resolutions higher than 1920 x 1088 well.
|
| static const DWORD g_AMDUVD3GPUList[] = {
|
| - 0x9400, 0x9401, 0x9402, 0x9403, 0x9405, 0x940a, 0x940b, 0x940f, 0x94c0,
|
| - 0x94c1, 0x94c3, 0x94c4, 0x94c5, 0x94c6, 0x94c7, 0x94c8, 0x94c9, 0x94cb,
|
| - 0x94cc, 0x94cd, 0x9580, 0x9581, 0x9583, 0x9586, 0x9587, 0x9588, 0x9589,
|
| - 0x958a, 0x958b, 0x958c, 0x958d, 0x958e, 0x958f, 0x9500, 0x9501, 0x9504,
|
| - 0x9505, 0x9506, 0x9507, 0x9508, 0x9509, 0x950f, 0x9511, 0x9515, 0x9517,
|
| - 0x9519, 0x95c0, 0x95c2, 0x95c4, 0x95c5, 0x95c6, 0x95c7, 0x95c9, 0x95cc,
|
| - 0x95cd, 0x95ce, 0x95cf, 0x9590, 0x9591, 0x9593, 0x9595, 0x9596, 0x9597,
|
| - 0x9598, 0x9599, 0x959b, 0x9610, 0x9611, 0x9612, 0x9613, 0x9614, 0x9615,
|
| - 0x9616, 0x9710, 0x9711, 0x9712, 0x9713, 0x9714, 0x9715, 0x9440, 0x9441,
|
| - 0x9442, 0x9443, 0x9444, 0x9446, 0x944a, 0x944b, 0x944c, 0x944e, 0x9450,
|
| - 0x9452, 0x9456, 0x945a, 0x945b, 0x945e, 0x9460, 0x9462, 0x946a, 0x946b,
|
| - 0x947a, 0x947b, 0x9480, 0x9487, 0x9488, 0x9489, 0x948a, 0x948f, 0x9490,
|
| - 0x9491, 0x9495, 0x9498, 0x949c, 0x949e, 0x949f, 0x9540, 0x9541, 0x9542,
|
| - 0x954e, 0x954f, 0x9552, 0x9553, 0x9555, 0x9557, 0x955f, 0x94a0, 0x94a1,
|
| - 0x94a3, 0x94b1, 0x94b3, 0x94b4, 0x94b5, 0x94b9, 0x68e0, 0x68e1, 0x68e4,
|
| - 0x68e5, 0x68e8, 0x68e9, 0x68f1, 0x68f2, 0x68f8, 0x68f9, 0x68fa, 0x68fe,
|
| - 0x68c0, 0x68c1, 0x68c7, 0x68c8, 0x68c9, 0x68d8, 0x68d9, 0x68da, 0x68de,
|
| - 0x68a0, 0x68a1, 0x68a8, 0x68a9, 0x68b0, 0x68b8, 0x68b9, 0x68ba, 0x68be,
|
| - 0x68bf, 0x6880, 0x6888, 0x6889, 0x688a, 0x688c, 0x688d, 0x6898, 0x6899,
|
| - 0x689b, 0x689e, 0x689c, 0x689d, 0x9802, 0x9803, 0x9804, 0x9805, 0x9806,
|
| - 0x9807, 0x9808, 0x9809, 0x980a, 0x9640, 0x9641, 0x9647, 0x9648, 0x964a,
|
| - 0x964b, 0x964c, 0x964e, 0x964f, 0x9642, 0x9643, 0x9644, 0x9645, 0x9649,
|
| - 0x6720, 0x6721, 0x6722, 0x6723, 0x6724, 0x6725, 0x6726, 0x6727, 0x6728,
|
| - 0x6729, 0x6738, 0x6739, 0x673e, 0x6740, 0x6741, 0x6742, 0x6743, 0x6744,
|
| - 0x6745, 0x6746, 0x6747, 0x6748, 0x6749, 0x674a, 0x6750, 0x6751, 0x6758,
|
| - 0x6759, 0x675b, 0x675d, 0x675f, 0x6840, 0x6841, 0x6842, 0x6843, 0x6849,
|
| - 0x6850, 0x6858, 0x6859, 0x6760, 0x6761, 0x6762, 0x6763, 0x6764, 0x6765,
|
| - 0x6766, 0x6767, 0x6768, 0x6770, 0x6771, 0x6772, 0x6778, 0x6779, 0x677b,
|
| - 0x6700, 0x6701, 0x6702, 0x6703, 0x6704, 0x6705, 0x6706, 0x6707, 0x6708,
|
| - 0x6709, 0x6718, 0x6719, 0x671c, 0x671d, 0x671f, 0x683D, 0x9900, 0x9901,
|
| - 0x9903, 0x9904, 0x9905, 0x9906, 0x9907, 0x9908, 0x9909, 0x990a, 0x990b,
|
| - 0x990c, 0x990d, 0x990e, 0x990f, 0x9910, 0x9913, 0x9917, 0x9918, 0x9919,
|
| - 0x9990, 0x9991, 0x9992, 0x9993, 0x9994, 0x9995, 0x9996, 0x9997, 0x9998,
|
| - 0x9999, 0x999a, 0x999b, 0x999c, 0x999d, 0x99a0, 0x99a2, 0x99a4,
|
| + 0x9400, 0x9401, 0x9402, 0x9403, 0x9405, 0x940a, 0x940b, 0x940f, 0x94c0,
|
| + 0x94c1, 0x94c3, 0x94c4, 0x94c5, 0x94c6, 0x94c7, 0x94c8, 0x94c9, 0x94cb,
|
| + 0x94cc, 0x94cd, 0x9580, 0x9581, 0x9583, 0x9586, 0x9587, 0x9588, 0x9589,
|
| + 0x958a, 0x958b, 0x958c, 0x958d, 0x958e, 0x958f, 0x9500, 0x9501, 0x9504,
|
| + 0x9505, 0x9506, 0x9507, 0x9508, 0x9509, 0x950f, 0x9511, 0x9515, 0x9517,
|
| + 0x9519, 0x95c0, 0x95c2, 0x95c4, 0x95c5, 0x95c6, 0x95c7, 0x95c9, 0x95cc,
|
| + 0x95cd, 0x95ce, 0x95cf, 0x9590, 0x9591, 0x9593, 0x9595, 0x9596, 0x9597,
|
| + 0x9598, 0x9599, 0x959b, 0x9610, 0x9611, 0x9612, 0x9613, 0x9614, 0x9615,
|
| + 0x9616, 0x9710, 0x9711, 0x9712, 0x9713, 0x9714, 0x9715, 0x9440, 0x9441,
|
| + 0x9442, 0x9443, 0x9444, 0x9446, 0x944a, 0x944b, 0x944c, 0x944e, 0x9450,
|
| + 0x9452, 0x9456, 0x945a, 0x945b, 0x945e, 0x9460, 0x9462, 0x946a, 0x946b,
|
| + 0x947a, 0x947b, 0x9480, 0x9487, 0x9488, 0x9489, 0x948a, 0x948f, 0x9490,
|
| + 0x9491, 0x9495, 0x9498, 0x949c, 0x949e, 0x949f, 0x9540, 0x9541, 0x9542,
|
| + 0x954e, 0x954f, 0x9552, 0x9553, 0x9555, 0x9557, 0x955f, 0x94a0, 0x94a1,
|
| + 0x94a3, 0x94b1, 0x94b3, 0x94b4, 0x94b5, 0x94b9, 0x68e0, 0x68e1, 0x68e4,
|
| + 0x68e5, 0x68e8, 0x68e9, 0x68f1, 0x68f2, 0x68f8, 0x68f9, 0x68fa, 0x68fe,
|
| + 0x68c0, 0x68c1, 0x68c7, 0x68c8, 0x68c9, 0x68d8, 0x68d9, 0x68da, 0x68de,
|
| + 0x68a0, 0x68a1, 0x68a8, 0x68a9, 0x68b0, 0x68b8, 0x68b9, 0x68ba, 0x68be,
|
| + 0x68bf, 0x6880, 0x6888, 0x6889, 0x688a, 0x688c, 0x688d, 0x6898, 0x6899,
|
| + 0x689b, 0x689e, 0x689c, 0x689d, 0x9802, 0x9803, 0x9804, 0x9805, 0x9806,
|
| + 0x9807, 0x9808, 0x9809, 0x980a, 0x9640, 0x9641, 0x9647, 0x9648, 0x964a,
|
| + 0x964b, 0x964c, 0x964e, 0x964f, 0x9642, 0x9643, 0x9644, 0x9645, 0x9649,
|
| + 0x6720, 0x6721, 0x6722, 0x6723, 0x6724, 0x6725, 0x6726, 0x6727, 0x6728,
|
| + 0x6729, 0x6738, 0x6739, 0x673e, 0x6740, 0x6741, 0x6742, 0x6743, 0x6744,
|
| + 0x6745, 0x6746, 0x6747, 0x6748, 0x6749, 0x674a, 0x6750, 0x6751, 0x6758,
|
| + 0x6759, 0x675b, 0x675d, 0x675f, 0x6840, 0x6841, 0x6842, 0x6843, 0x6849,
|
| + 0x6850, 0x6858, 0x6859, 0x6760, 0x6761, 0x6762, 0x6763, 0x6764, 0x6765,
|
| + 0x6766, 0x6767, 0x6768, 0x6770, 0x6771, 0x6772, 0x6778, 0x6779, 0x677b,
|
| + 0x6700, 0x6701, 0x6702, 0x6703, 0x6704, 0x6705, 0x6706, 0x6707, 0x6708,
|
| + 0x6709, 0x6718, 0x6719, 0x671c, 0x671d, 0x671f, 0x683D, 0x9900, 0x9901,
|
| + 0x9903, 0x9904, 0x9905, 0x9906, 0x9907, 0x9908, 0x9909, 0x990a, 0x990b,
|
| + 0x990c, 0x990d, 0x990e, 0x990f, 0x9910, 0x9913, 0x9917, 0x9918, 0x9919,
|
| + 0x9990, 0x9991, 0x9992, 0x9993, 0x9994, 0x9995, 0x9996, 0x9997, 0x9998,
|
| + 0x9999, 0x999a, 0x999b, 0x999c, 0x999d, 0x99a0, 0x99a2, 0x99a4,
|
| };
|
|
|
| // Legacy Intel GPUs (Second generation) which have trouble with resolutions
|
| // higher than 1920 x 1088
|
| static const DWORD g_IntelLegacyGPUList[] = {
|
| - 0x102, 0x106, 0x116, 0x126,
|
| + 0x102, 0x106, 0x116, 0x126,
|
| };
|
|
|
| // Provides scoped access to the underlying buffer in an IMFMediaBuffer
|
| @@ -180,13 +197,9 @@ class MediaBufferScopedPointer {
|
| CHECK(SUCCEEDED(hr));
|
| }
|
|
|
| - uint8_t* get() {
|
| - return buffer_;
|
| - }
|
| + uint8_t* get() { return buffer_; }
|
|
|
| - DWORD current_length() const {
|
| - return current_length_;
|
| - }
|
| + DWORD current_length() const { return current_length_; }
|
|
|
| private:
|
| base::win::ScopedComPtr<IMFMediaBuffer> media_buffer_;
|
| @@ -199,46 +212,40 @@ class MediaBufferScopedPointer {
|
|
|
| } // namespace
|
|
|
| -namespace content {
|
| +namespace media {
|
|
|
| static const media::VideoCodecProfile kSupportedProfiles[] = {
|
| - media::H264PROFILE_BASELINE,
|
| - media::H264PROFILE_MAIN,
|
| - media::H264PROFILE_HIGH,
|
| - media::VP8PROFILE_ANY,
|
| - media::VP9PROFILE_PROFILE0,
|
| - media::VP9PROFILE_PROFILE1,
|
| - media::VP9PROFILE_PROFILE2,
|
| - media::VP9PROFILE_PROFILE3
|
| -};
|
| -
|
| -CreateDXGIDeviceManager DXVAVideoDecodeAccelerator::create_dxgi_device_manager_
|
| - = NULL;
|
| -
|
| -#define RETURN_ON_FAILURE(result, log, ret) \
|
| - do { \
|
| - if (!(result)) { \
|
| - DLOG(ERROR) << log; \
|
| - return ret; \
|
| - } \
|
| + media::H264PROFILE_BASELINE, media::H264PROFILE_MAIN,
|
| + media::H264PROFILE_HIGH, media::VP8PROFILE_ANY,
|
| + media::VP9PROFILE_PROFILE0, media::VP9PROFILE_PROFILE1,
|
| + media::VP9PROFILE_PROFILE2, media::VP9PROFILE_PROFILE3};
|
| +
|
| +CreateDXGIDeviceManager
|
| + DXVAVideoDecodeAccelerator::create_dxgi_device_manager_ = NULL;
|
| +
|
| +#define RETURN_ON_FAILURE(result, log, ret) \
|
| + do { \
|
| + if (!(result)) { \
|
| + DLOG(ERROR) << log; \
|
| + return ret; \
|
| + } \
|
| } while (0)
|
|
|
| -#define RETURN_ON_HR_FAILURE(result, log, ret) \
|
| - RETURN_ON_FAILURE(SUCCEEDED(result), \
|
| - log << ", HRESULT: 0x" << std::hex << result, \
|
| - ret);
|
| -
|
| -#define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \
|
| - do { \
|
| - if (!(result)) { \
|
| - DVLOG(1) << log; \
|
| - StopOnError(error_code); \
|
| - return ret; \
|
| - } \
|
| +#define RETURN_ON_HR_FAILURE(result, log, ret) \
|
| + RETURN_ON_FAILURE(SUCCEEDED(result), \
|
| + log << ", HRESULT: 0x" << std::hex << result, ret);
|
| +
|
| +#define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \
|
| + do { \
|
| + if (!(result)) { \
|
| + DVLOG(1) << log; \
|
| + StopOnError(error_code); \
|
| + return ret; \
|
| + } \
|
| } while (0)
|
|
|
| -#define RETURN_AND_NOTIFY_ON_HR_FAILURE(result, log, error_code, ret) \
|
| - RETURN_AND_NOTIFY_ON_FAILURE(SUCCEEDED(result), \
|
| +#define RETURN_AND_NOTIFY_ON_HR_FAILURE(result, log, error_code, ret) \
|
| + RETURN_AND_NOTIFY_ON_FAILURE(SUCCEEDED(result), \
|
| log << ", HRESULT: 0x" << std::hex << result, \
|
| error_code, ret);
|
|
|
| @@ -284,9 +291,8 @@ static IMFSample* CreateEmptySampleWithBuffer(uint32_t buffer_length,
|
| // with the align argument being 0.
|
| hr = MFCreateMemoryBuffer(buffer_length, buffer.Receive());
|
| } else {
|
| - hr = MFCreateAlignedMemoryBuffer(buffer_length,
|
| - align - 1,
|
| - buffer.Receive());
|
| + hr =
|
| + MFCreateAlignedMemoryBuffer(buffer_length, align - 1, buffer.Receive());
|
| }
|
| RETURN_ON_HR_FAILURE(hr, "Failed to create memory buffer for sample", NULL);
|
|
|
| @@ -309,8 +315,8 @@ static IMFSample* CreateInputSample(const uint8_t* stream,
|
| CHECK(stream);
|
| CHECK_GT(size, 0U);
|
| base::win::ScopedComPtr<IMFSample> sample;
|
| - sample.Attach(CreateEmptySampleWithBuffer(std::max(min_size, size),
|
| - alignment));
|
| + sample.Attach(
|
| + CreateEmptySampleWithBuffer(std::max(min_size, size), alignment));
|
| RETURN_ON_FAILURE(sample.get(), "Failed to create empty sample", NULL);
|
|
|
| base::win::ScopedComPtr<IMFMediaBuffer> buffer;
|
| @@ -340,24 +346,24 @@ static IMFSample* CreateInputSample(const uint8_t* stream,
|
| // is to use the CoCreateInstance API which requires the COM apartment to be
|
| // initialized which is not the case on the GPU main thread. We want to avoid
|
| // initializing COM as it may have sideeffects.
|
| -HRESULT CreateCOMObjectFromDll(HMODULE dll, const CLSID& clsid, const IID& iid,
|
| +HRESULT CreateCOMObjectFromDll(HMODULE dll,
|
| + const CLSID& clsid,
|
| + const IID& iid,
|
| void** object) {
|
| if (!dll || !object)
|
| return E_INVALIDARG;
|
|
|
| - using GetClassObject = HRESULT (WINAPI*)(
|
| - const CLSID& clsid, const IID& iid, void** object);
|
| + using GetClassObject =
|
| + HRESULT(WINAPI*)(const CLSID& clsid, const IID& iid, void** object);
|
|
|
| GetClassObject get_class_object = reinterpret_cast<GetClassObject>(
|
| GetProcAddress(dll, "DllGetClassObject"));
|
| - RETURN_ON_FAILURE(
|
| - get_class_object, "Failed to get DllGetClassObject pointer", E_FAIL);
|
| + RETURN_ON_FAILURE(get_class_object, "Failed to get DllGetClassObject pointer",
|
| + E_FAIL);
|
|
|
| base::win::ScopedComPtr<IClassFactory> factory;
|
| - HRESULT hr = get_class_object(
|
| - clsid,
|
| - __uuidof(IClassFactory),
|
| - factory.ReceiveVoid());
|
| + HRESULT hr =
|
| + get_class_object(clsid, __uuidof(IClassFactory), factory.ReceiveVoid());
|
| RETURN_ON_HR_FAILURE(hr, "DllGetClassObject failed", hr);
|
|
|
| hr = factory->CreateInstance(NULL, iid, object);
|
| @@ -367,7 +373,7 @@ HRESULT CreateCOMObjectFromDll(HMODULE dll, const CLSID& clsid, const IID& iid,
|
| // Helper function to query the ANGLE device object. The template argument T
|
| // identifies the device interface being queried. IDirect3DDevice9Ex for d3d9
|
| // and ID3D11Device for dx11.
|
| -template<class T>
|
| +template <class T>
|
| base::win::ScopedComPtr<T> QueryDeviceObjectFromANGLE(int object_type) {
|
| base::win::ScopedComPtr<T> device_object;
|
|
|
| @@ -380,19 +386,16 @@ base::win::ScopedComPtr<T> QueryDeviceObjectFromANGLE(int object_type) {
|
| egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay();
|
| }
|
|
|
| - RETURN_ON_FAILURE(
|
| - gfx::GLSurfaceEGL::HasEGLExtension("EGL_EXT_device_query"),
|
| - "EGL_EXT_device_query missing",
|
| - device_object);
|
| + RETURN_ON_FAILURE(gfx::GLSurfaceEGL::HasEGLExtension("EGL_EXT_device_query"),
|
| + "EGL_EXT_device_query missing", device_object);
|
|
|
| PFNEGLQUERYDISPLAYATTRIBEXTPROC QueryDisplayAttribEXT = nullptr;
|
|
|
| {
|
| TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. eglGetProcAddress");
|
|
|
| - QueryDisplayAttribEXT =
|
| - reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>(eglGetProcAddress(
|
| - "eglQueryDisplayAttribEXT"));
|
| + QueryDisplayAttribEXT = reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>(
|
| + eglGetProcAddress("eglQueryDisplayAttribEXT"));
|
|
|
| RETURN_ON_FAILURE(
|
| QueryDisplayAttribEXT,
|
| @@ -405,9 +408,8 @@ base::win::ScopedComPtr<T> QueryDeviceObjectFromANGLE(int object_type) {
|
| {
|
| TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. eglGetProcAddress");
|
|
|
| - QueryDeviceAttribEXT =
|
| - reinterpret_cast<PFNEGLQUERYDEVICEATTRIBEXTPROC>(eglGetProcAddress(
|
| - "eglQueryDeviceAttribEXT"));
|
| + QueryDeviceAttribEXT = reinterpret_cast<PFNEGLQUERYDEVICEATTRIBEXTPROC>(
|
| + eglGetProcAddress("eglQueryDeviceAttribEXT"));
|
|
|
| RETURN_ON_FAILURE(
|
| QueryDeviceAttribEXT,
|
| @@ -424,19 +426,16 @@ base::win::ScopedComPtr<T> QueryDeviceObjectFromANGLE(int object_type) {
|
| device_object);
|
| }
|
|
|
| - RETURN_ON_FAILURE(
|
| - egl_device,
|
| - "Failed to get the EGL device",
|
| - device_object);
|
| + RETURN_ON_FAILURE(egl_device, "Failed to get the EGL device", device_object);
|
|
|
| {
|
| TRACE_EVENT0("gpu", "QueryDeviceObjectFromANGLE. QueryDisplayAttribEXT");
|
|
|
| RETURN_ON_FAILURE(
|
| - QueryDeviceAttribEXT(
|
| - reinterpret_cast<EGLDeviceEXT>(egl_device), object_type, &device),
|
| - "The eglQueryDeviceAttribEXT function failed to get the device",
|
| - device_object);
|
| + QueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(egl_device),
|
| + object_type, &device),
|
| + "The eglQueryDeviceAttribEXT function failed to get the device",
|
| + device_object);
|
|
|
| RETURN_ON_FAILURE(device, "Failed to get the ANGLE device", device_object);
|
| }
|
| @@ -449,11 +448,9 @@ H264ConfigChangeDetector::H264ConfigChangeDetector()
|
| : last_sps_id_(0),
|
| last_pps_id_(0),
|
| config_changed_(false),
|
| - pending_config_changed_(false) {
|
| -}
|
| + pending_config_changed_(false) {}
|
|
|
| -H264ConfigChangeDetector::~H264ConfigChangeDetector() {
|
| -}
|
| +H264ConfigChangeDetector::~H264ConfigChangeDetector() {}
|
|
|
| bool H264ConfigChangeDetector::DetectConfig(const uint8_t* stream,
|
| unsigned int size) {
|
| @@ -572,27 +569,18 @@ struct DXVAVideoDecodeAccelerator::DXVAPictureBuffer {
|
| // Copies the output sample data to the picture buffer provided by the
|
| // client.
|
| // The dest_surface parameter contains the decoded bits.
|
| - bool CopyOutputSampleDataToPictureBuffer(
|
| - DXVAVideoDecodeAccelerator* decoder,
|
| - IDirect3DSurface9* dest_surface,
|
| - ID3D11Texture2D* dx11_texture,
|
| - int input_buffer_id);
|
| + bool CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder,
|
| + IDirect3DSurface9* dest_surface,
|
| + ID3D11Texture2D* dx11_texture,
|
| + int input_buffer_id);
|
|
|
| - bool available() const {
|
| - return available_;
|
| - }
|
| + bool available() const { return available_; }
|
|
|
| - void set_available(bool available) {
|
| - available_ = available;
|
| - }
|
| + void set_available(bool available) { available_ = available; }
|
|
|
| - int id() const {
|
| - return picture_buffer_.id();
|
| - }
|
| + int id() const { return picture_buffer_.id(); }
|
|
|
| - gfx::Size size() const {
|
| - return picture_buffer_.size();
|
| - }
|
| + gfx::Size size() const { return picture_buffer_.size(); }
|
|
|
| bool waiting_to_reuse() const { return waiting_to_reuse_; }
|
|
|
| @@ -661,13 +649,15 @@ DXVAVideoDecodeAccelerator::DXVAPictureBuffer::Create(
|
| if (!picture_buffer->InitializeTexture(decoder, !!use_rgb))
|
| return linked_ptr<DXVAPictureBuffer>(nullptr);
|
|
|
| - EGLint attrib_list[] = {
|
| - EGL_WIDTH, buffer.size().width(),
|
| - EGL_HEIGHT, buffer.size().height(),
|
| - EGL_TEXTURE_FORMAT, use_rgb ? EGL_TEXTURE_RGB : EGL_TEXTURE_RGBA,
|
| - EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
|
| - EGL_NONE
|
| - };
|
| + EGLint attrib_list[] = {EGL_WIDTH,
|
| + buffer.size().width(),
|
| + EGL_HEIGHT,
|
| + buffer.size().height(),
|
| + EGL_TEXTURE_FORMAT,
|
| + use_rgb ? EGL_TEXTURE_RGB : EGL_TEXTURE_RGBA,
|
| + EGL_TEXTURE_TARGET,
|
| + EGL_TEXTURE_2D,
|
| + EGL_NONE};
|
|
|
| picture_buffer->decoding_surface_ = eglCreatePbufferFromClientBuffer(
|
| egl_display, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE,
|
| @@ -752,14 +742,9 @@ DXVAVideoDecodeAccelerator::DXVAPictureBuffer::~DXVAPictureBuffer() {
|
| if (decoding_surface_) {
|
| EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay();
|
|
|
| - eglReleaseTexImage(
|
| - egl_display,
|
| - decoding_surface_,
|
| - EGL_BACK_BUFFER);
|
| + eglReleaseTexImage(egl_display, decoding_surface_, EGL_BACK_BUFFER);
|
|
|
| - eglDestroySurface(
|
| - egl_display,
|
| - decoding_surface_);
|
| + eglDestroySurface(egl_display, decoding_surface_);
|
| decoding_surface_ = NULL;
|
| }
|
| }
|
| @@ -767,10 +752,7 @@ DXVAVideoDecodeAccelerator::DXVAPictureBuffer::~DXVAPictureBuffer() {
|
| bool DXVAVideoDecodeAccelerator::DXVAPictureBuffer::ReusePictureBuffer() {
|
| DCHECK(decoding_surface_);
|
| EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay();
|
| - eglReleaseTexImage(
|
| - egl_display,
|
| - decoding_surface_,
|
| - EGL_BACK_BUFFER);
|
| + eglReleaseTexImage(egl_display, decoding_surface_, EGL_BACK_BUFFER);
|
| decoder_surface_.Release();
|
| target_surface_.Release();
|
| decoder_dx11_texture_.Release();
|
| @@ -792,11 +774,10 @@ void DXVAVideoDecodeAccelerator::DXVAPictureBuffer::ResetReuseFence() {
|
| }
|
|
|
| bool DXVAVideoDecodeAccelerator::DXVAPictureBuffer::
|
| - CopyOutputSampleDataToPictureBuffer(
|
| - DXVAVideoDecodeAccelerator* decoder,
|
| - IDirect3DSurface9* dest_surface,
|
| - ID3D11Texture2D* dx11_texture,
|
| - int input_buffer_id) {
|
| + CopyOutputSampleDataToPictureBuffer(DXVAVideoDecodeAccelerator* decoder,
|
| + IDirect3DSurface9* dest_surface,
|
| + ID3D11Texture2D* dx11_texture,
|
| + int input_buffer_id) {
|
| DCHECK(dest_surface || dx11_texture);
|
| if (dx11_texture) {
|
| // Grab a reference on the decoder texture. This reference will be released
|
| @@ -874,10 +855,7 @@ bool DXVAVideoDecodeAccelerator::DXVAPictureBuffer::CopySurfaceComplete(
|
| }
|
|
|
| EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay();
|
| - eglBindTexImage(
|
| - egl_display,
|
| - decoding_surface_,
|
| - EGL_BACK_BUFFER);
|
| + eglBindTexImage(egl_display, decoding_surface_, EGL_BACK_BUFFER);
|
|
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
| glBindTexture(GL_TEXTURE_2D, current_texture);
|
| @@ -958,7 +936,8 @@ bool DXVAVideoDecodeAccelerator::Initialize(const Config& config,
|
| }
|
| if (!profile_supported) {
|
| RETURN_AND_NOTIFY_ON_FAILURE(false,
|
| - "Unsupported h.264, vp8, or vp9 profile", PLATFORM_FAILURE, false);
|
| + "Unsupported h.264, vp8, or vp9 profile",
|
| + PLATFORM_FAILURE, false);
|
| }
|
|
|
| // Not all versions of Windows 7 and later include Media Foundation DLLs.
|
| @@ -969,33 +948,32 @@ bool DXVAVideoDecodeAccelerator::Initialize(const Config& config,
|
| RETURN_ON_FAILURE(dxgi_manager_dll, "MFPlat.dll is required for decoding",
|
| false);
|
|
|
| - // On Windows 8+ mfplat.dll provides the MFCreateDXGIDeviceManager API.
|
| - // On Windows 7 mshtmlmedia.dll provides it.
|
| +// On Windows 8+ mfplat.dll provides the MFCreateDXGIDeviceManager API.
|
| +// On Windows 7 mshtmlmedia.dll provides it.
|
|
|
| - // TODO(ananta)
|
| - // The code below works, as in we can create the DX11 device manager for
|
| - // Windows 7. However the IMFTransform we use for texture conversion and
|
| - // copy does not exist on Windows 7. Look into an alternate approach
|
| - // and enable the code below.
|
| +// TODO(ananta)
|
| +// The code below works, as in we can create the DX11 device manager for
|
| +// Windows 7. However the IMFTransform we use for texture conversion and
|
| +// copy does not exist on Windows 7. Look into an alternate approach
|
| +// and enable the code below.
|
| #if defined(ENABLE_DX11_FOR_WIN7)
|
| if (base::win::GetVersion() == base::win::VERSION_WIN7) {
|
| dxgi_manager_dll = ::GetModuleHandle(L"mshtmlmedia.dll");
|
| RETURN_ON_FAILURE(dxgi_manager_dll,
|
| - "mshtmlmedia.dll is required for decoding", false);
|
| + "mshtmlmedia.dll is required for decoding", false);
|
| }
|
| #endif
|
| // If we don't find the MFCreateDXGIDeviceManager API we fallback to D3D9
|
| // decoding.
|
| if (dxgi_manager_dll && !create_dxgi_device_manager_) {
|
| create_dxgi_device_manager_ = reinterpret_cast<CreateDXGIDeviceManager>(
|
| - ::GetProcAddress(dxgi_manager_dll, "MFCreateDXGIDeviceManager"));
|
| + ::GetProcAddress(dxgi_manager_dll, "MFCreateDXGIDeviceManager"));
|
| }
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(
|
| gfx::g_driver_egl.ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle,
|
| "EGL_ANGLE_surface_d3d_texture_2d_share_handle unavailable",
|
| - PLATFORM_FAILURE,
|
| - false);
|
| + PLATFORM_FAILURE, false);
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(gfx::GLFence::IsSupported(),
|
| "GL fences are unsupported", PLATFORM_FAILURE,
|
| @@ -1003,15 +981,18 @@ bool DXVAVideoDecodeAccelerator::Initialize(const Config& config,
|
|
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE((state == kUninitialized),
|
| - "Initialize: invalid state: " << state, ILLEGAL_STATE, false);
|
| + "Initialize: invalid state: " << state,
|
| + ILLEGAL_STATE, false);
|
|
|
| media::InitializeMediaFoundation();
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(InitDecoder(config.profile),
|
| - "Failed to initialize decoder", PLATFORM_FAILURE, false);
|
| + "Failed to initialize decoder", PLATFORM_FAILURE,
|
| + false);
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(GetStreamsInfoAndBufferReqs(),
|
| - "Failed to get input/output stream info.", PLATFORM_FAILURE, false);
|
| + "Failed to get input/output stream info.",
|
| + PLATFORM_FAILURE, false);
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(
|
| SendMFTMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0),
|
| @@ -1055,8 +1036,8 @@ bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() {
|
|
|
| if (using_angle_device_) {
|
| hr = d3d9_device_ex_.QueryFrom(angle_device.get());
|
| - RETURN_ON_HR_FAILURE(hr,
|
| - "QueryInterface for IDirect3DDevice9Ex from angle device failed",
|
| + RETURN_ON_HR_FAILURE(
|
| + hr, "QueryInterface for IDirect3DDevice9Ex from angle device failed",
|
| false);
|
| } else {
|
| D3DPRESENT_PARAMETERS present_params = {0};
|
| @@ -1109,14 +1090,9 @@ bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() {
|
| // The ordering MUST be preserved. All applications are assumed to support
|
| // 9.1 unless otherwise stated by the application.
|
| D3D_FEATURE_LEVEL feature_levels[] = {
|
| - D3D_FEATURE_LEVEL_11_1,
|
| - D3D_FEATURE_LEVEL_11_0,
|
| - D3D_FEATURE_LEVEL_10_1,
|
| - D3D_FEATURE_LEVEL_10_0,
|
| - D3D_FEATURE_LEVEL_9_3,
|
| - D3D_FEATURE_LEVEL_9_2,
|
| - D3D_FEATURE_LEVEL_9_1
|
| - };
|
| + D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1,
|
| + D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2,
|
| + D3D_FEATURE_LEVEL_9_1};
|
|
|
| UINT flags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT;
|
|
|
| @@ -1125,16 +1101,10 @@ bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() {
|
| #endif
|
|
|
| D3D_FEATURE_LEVEL feature_level_out = D3D_FEATURE_LEVEL_11_0;
|
| - hr = D3D11CreateDevice(NULL,
|
| - D3D_DRIVER_TYPE_HARDWARE,
|
| - NULL,
|
| - flags,
|
| - feature_levels,
|
| - arraysize(feature_levels),
|
| - D3D11_SDK_VERSION,
|
| - d3d11_device_.Receive(),
|
| - &feature_level_out,
|
| - d3d11_device_context_.Receive());
|
| + hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags,
|
| + feature_levels, arraysize(feature_levels),
|
| + D3D11_SDK_VERSION, d3d11_device_.Receive(),
|
| + &feature_level_out, d3d11_device_context_.Receive());
|
| RETURN_ON_HR_FAILURE(hr, "Failed to create DX11 device", false);
|
|
|
| // Enable multithreaded mode on the device. This ensures that accesses to
|
| @@ -1152,20 +1122,16 @@ bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() {
|
| D3D11_QUERY_DESC query_desc;
|
| query_desc.Query = D3D11_QUERY_EVENT;
|
| query_desc.MiscFlags = 0;
|
| - hr = d3d11_device_->CreateQuery(
|
| - &query_desc,
|
| - d3d11_query_.Receive());
|
| + hr = d3d11_device_->CreateQuery(&query_desc, d3d11_query_.Receive());
|
| RETURN_ON_HR_FAILURE(hr, "Failed to create DX11 device query", false);
|
|
|
| HMODULE video_processor_dll = ::GetModuleHandle(L"msvproc.dll");
|
| RETURN_ON_FAILURE(video_processor_dll, "Failed to load video processor",
|
| false);
|
|
|
| - hr = CreateCOMObjectFromDll(
|
| - video_processor_dll,
|
| - CLSID_VideoProcessorMFT,
|
| - __uuidof(IMFTransform),
|
| - video_format_converter_mft_.ReceiveVoid());
|
| + hr = CreateCOMObjectFromDll(video_processor_dll, CLSID_VideoProcessorMFT,
|
| + __uuidof(IMFTransform),
|
| + video_format_converter_mft_.ReceiveVoid());
|
| if (FAILED(hr)) {
|
| base::debug::Alias(&hr);
|
| // TODO(ananta)
|
| @@ -1183,15 +1149,11 @@ bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() {
|
|
|
| hr = converter_attributes->SetUINT32(MF_XVP_PLAYBACK_MODE, TRUE);
|
| RETURN_ON_HR_FAILURE(
|
| - hr,
|
| - "Failed to set MF_XVP_PLAYBACK_MODE attribute on converter",
|
| - false);
|
| + hr, "Failed to set MF_XVP_PLAYBACK_MODE attribute on converter", false);
|
|
|
| hr = converter_attributes->SetUINT32(MF_LOW_LATENCY, FALSE);
|
| RETURN_ON_HR_FAILURE(
|
| - hr,
|
| - "Failed to set MF_LOW_LATENCY attribute on converter",
|
| - false);
|
| + hr, "Failed to set MF_LOW_LATENCY attribute on converter", false);
|
| return true;
|
| }
|
|
|
| @@ -1203,9 +1165,9 @@ void DXVAVideoDecodeAccelerator::Decode(
|
| base::SharedMemory shm(bitstream_buffer.handle(), true);
|
|
|
| State state = GetState();
|
| - RETURN_AND_NOTIFY_ON_FAILURE((state == kNormal || state == kStopped ||
|
| - state == kFlushing),
|
| - "Invalid state: " << state, ILLEGAL_STATE,);
|
| + RETURN_AND_NOTIFY_ON_FAILURE(
|
| + (state == kNormal || state == kStopped || state == kFlushing),
|
| + "Invalid state: " << state, ILLEGAL_STATE, );
|
| if (bitstream_buffer.id() < 0) {
|
| RETURN_AND_NOTIFY_ON_FAILURE(
|
| false, "Invalid bitstream_buffer, id: " << bitstream_buffer.id(),
|
| @@ -1224,13 +1186,13 @@ void DXVAVideoDecodeAccelerator::Decode(
|
| RETURN_AND_NOTIFY_ON_FAILURE(sample.get(), "Failed to create input sample",
|
| PLATFORM_FAILURE, );
|
|
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(sample->SetSampleTime(bitstream_buffer.id()),
|
| - "Failed to associate input buffer id with sample", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(
|
| + sample->SetSampleTime(bitstream_buffer.id()),
|
| + "Failed to associate input buffer id with sample", PLATFORM_FAILURE, );
|
|
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::DecodeInternal,
|
| - base::Unretained(this), sample));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::DecodeInternal,
|
| + base::Unretained(this), sample));
|
| }
|
|
|
| void DXVAVideoDecodeAccelerator::AssignPictureBuffers(
|
| @@ -1239,32 +1201,35 @@ void DXVAVideoDecodeAccelerator::AssignPictureBuffers(
|
|
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE((state != kUninitialized),
|
| - "Invalid state: " << state, ILLEGAL_STATE,);
|
| - RETURN_AND_NOTIFY_ON_FAILURE((kNumPictureBuffers >= buffers.size()),
|
| - "Failed to provide requested picture buffers. (Got " << buffers.size() <<
|
| - ", requested " << kNumPictureBuffers << ")", INVALID_ARGUMENT,);
|
| + "Invalid state: " << state, ILLEGAL_STATE, );
|
| + RETURN_AND_NOTIFY_ON_FAILURE(
|
| + (kNumPictureBuffers >= buffers.size()),
|
| + "Failed to provide requested picture buffers. (Got "
|
| + << buffers.size() << ", requested " << kNumPictureBuffers << ")",
|
| + INVALID_ARGUMENT, );
|
|
|
| // Copy the picture buffers provided by the client to the available list,
|
| // and mark these buffers as available for use.
|
| - for (size_t buffer_index = 0; buffer_index < buffers.size();
|
| - ++buffer_index) {
|
| + for (size_t buffer_index = 0; buffer_index < buffers.size(); ++buffer_index) {
|
| DCHECK_LE(1u, buffers[buffer_index].texture_ids().size());
|
| linked_ptr<DXVAPictureBuffer> picture_buffer =
|
| DXVAPictureBuffer::Create(*this, buffers[buffer_index], egl_config_);
|
| RETURN_AND_NOTIFY_ON_FAILURE(picture_buffer.get(),
|
| - "Failed to allocate picture buffer", PLATFORM_FAILURE,);
|
| + "Failed to allocate picture buffer",
|
| + PLATFORM_FAILURE, );
|
|
|
| - bool inserted = output_picture_buffers_.insert(std::make_pair(
|
| - buffers[buffer_index].id(), picture_buffer)).second;
|
| + bool inserted =
|
| + output_picture_buffers_
|
| + .insert(std::make_pair(buffers[buffer_index].id(), picture_buffer))
|
| + .second;
|
| DCHECK(inserted);
|
| }
|
|
|
| ProcessPendingSamples();
|
| if (pending_flush_) {
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| - base::Unretained(this)));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| + base::Unretained(this)));
|
| }
|
| }
|
|
|
| @@ -1273,7 +1238,7 @@ void DXVAVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_buffer_id) {
|
|
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE((state != kUninitialized),
|
| - "Invalid state: " << state, ILLEGAL_STATE,);
|
| + "Invalid state: " << state, ILLEGAL_STATE, );
|
|
|
| if (output_picture_buffers_.empty() && stale_output_picture_buffers_.empty())
|
| return;
|
| @@ -1289,7 +1254,8 @@ void DXVAVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_buffer_id) {
|
| if (!stale_output_picture_buffers_.empty()) {
|
| it = stale_output_picture_buffers_.find(picture_buffer_id);
|
| RETURN_AND_NOTIFY_ON_FAILURE(it != stale_output_picture_buffers_.end(),
|
| - "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,);
|
| + "Invalid picture id: " << picture_buffer_id,
|
| + INVALID_ARGUMENT, );
|
| main_thread_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&DXVAVideoDecodeAccelerator::DeferredDismissStaleBuffer,
|
| @@ -1353,9 +1319,8 @@ void DXVAVideoDecodeAccelerator::WaitForOutputBuffer(int32_t picture_buffer_id,
|
| ProcessPendingSamples();
|
| if (pending_flush_) {
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| - base::Unretained(this)));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| + base::Unretained(this)));
|
| }
|
| }
|
|
|
| @@ -1366,16 +1331,16 @@ void DXVAVideoDecodeAccelerator::Flush() {
|
|
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE((state == kNormal || state == kStopped),
|
| - "Unexpected decoder state: " << state, ILLEGAL_STATE,);
|
| + "Unexpected decoder state: " << state,
|
| + ILLEGAL_STATE, );
|
|
|
| SetState(kFlushing);
|
|
|
| pending_flush_ = true;
|
|
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| - base::Unretained(this)));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void DXVAVideoDecodeAccelerator::Reset() {
|
| @@ -1385,7 +1350,8 @@ void DXVAVideoDecodeAccelerator::Reset() {
|
|
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE((state == kNormal || state == kStopped),
|
| - "Reset: invalid state: " << state, ILLEGAL_STATE,);
|
| + "Reset: invalid state: " << state,
|
| + ILLEGAL_STATE, );
|
|
|
| decoder_thread_.Stop();
|
|
|
| @@ -1395,11 +1361,10 @@ void DXVAVideoDecodeAccelerator::Reset() {
|
| // frames and set the corresponding picture buffer as available.
|
| PendingOutputSamples::iterator index;
|
| for (index = pending_output_samples_.begin();
|
| - index != pending_output_samples_.end();
|
| - ++index) {
|
| + index != pending_output_samples_.end(); ++index) {
|
| if (index->picture_buffer_id != -1) {
|
| - OutputBuffers::iterator it = output_picture_buffers_.find(
|
| - index->picture_buffer_id);
|
| + OutputBuffers::iterator it =
|
| + output_picture_buffers_.find(index->picture_buffer_id);
|
| if (it != output_picture_buffers_.end()) {
|
| DXVAPictureBuffer* picture_buffer = it->second.get();
|
| picture_buffer->ReusePictureBuffer();
|
| @@ -1412,12 +1377,12 @@ void DXVAVideoDecodeAccelerator::Reset() {
|
| NotifyInputBuffersDropped();
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(SendMFTMessage(MFT_MESSAGE_COMMAND_FLUSH, 0),
|
| - "Reset: Failed to send message.", PLATFORM_FAILURE,);
|
| + "Reset: Failed to send message.",
|
| + PLATFORM_FAILURE, );
|
|
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::NotifyResetDone,
|
| - weak_this_factory_.GetWeakPtr()));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::NotifyResetDone,
|
| + weak_this_factory_.GetWeakPtr()));
|
|
|
| StartDecoderThread();
|
| SetState(kNormal);
|
| @@ -1443,7 +1408,7 @@ GLenum DXVAVideoDecodeAccelerator::GetSurfaceInternalFormat() const {
|
| media::VideoDecodeAccelerator::SupportedProfiles
|
| DXVAVideoDecodeAccelerator::GetSupportedProfiles() {
|
| TRACE_EVENT0("gpu,startup",
|
| - "DXVAVideoDecodeAccelerator::GetSupportedProfiles");
|
| + "DXVAVideoDecodeAccelerator::GetSupportedProfiles");
|
|
|
| // TODO(henryhsu): Need to ensure the profiles are actually supported.
|
| SupportedProfiles profiles;
|
| @@ -1479,8 +1444,7 @@ void DXVAVideoDecodeAccelerator::PreSandboxInitialization() {
|
| // static
|
| std::pair<int, int> DXVAVideoDecodeAccelerator::GetMinResolution(
|
| media::VideoCodecProfile profile) {
|
| - TRACE_EVENT0("gpu,startup",
|
| - "DXVAVideoDecodeAccelerator::GetMinResolution");
|
| + TRACE_EVENT0("gpu,startup", "DXVAVideoDecodeAccelerator::GetMinResolution");
|
| std::pair<int, int> min_resolution;
|
| if (profile >= media::H264PROFILE_BASELINE &&
|
| profile <= media::H264PROFILE_HIGH) {
|
| @@ -1499,8 +1463,7 @@ std::pair<int, int> DXVAVideoDecodeAccelerator::GetMinResolution(
|
| // static
|
| std::pair<int, int> DXVAVideoDecodeAccelerator::GetMaxResolution(
|
| const media::VideoCodecProfile profile) {
|
| - TRACE_EVENT0("gpu,startup",
|
| - "DXVAVideoDecodeAccelerator::GetMaxResolution");
|
| + TRACE_EVENT0("gpu,startup", "DXVAVideoDecodeAccelerator::GetMaxResolution");
|
| std::pair<int, int> max_resolution;
|
| if (profile >= media::H264PROFILE_BASELINE &&
|
| profile <= media::H264PROFILE_HIGH) {
|
| @@ -1539,7 +1502,7 @@ std::pair<int, int> DXVAVideoDecodeAccelerator::GetMaxH264Resolution() {
|
|
|
| {
|
| TRACE_EVENT0("gpu,startup",
|
| - "GetMaxH264Resolution. QueryDeviceObjectFromANGLE");
|
| + "GetMaxH264Resolution. QueryDeviceObjectFromANGLE");
|
|
|
| device = QueryDeviceObjectFromANGLE<ID3D11Device>(EGL_D3D11_DEVICE_ANGLE);
|
| if (!device.get())
|
| @@ -1547,7 +1510,7 @@ std::pair<int, int> DXVAVideoDecodeAccelerator::GetMaxH264Resolution() {
|
| }
|
|
|
| base::win::ScopedComPtr<ID3D11VideoDevice> video_device;
|
| - hr = device.QueryInterface(IID_ID3D11VideoDevice,
|
| + hr = device.QueryInterface(__uuidof(ID3D11VideoDevice),
|
| video_device.ReceiveVoid());
|
| if (FAILED(hr))
|
| return max_resolution;
|
| @@ -1563,9 +1526,8 @@ std::pair<int, int> DXVAVideoDecodeAccelerator::GetMaxH264Resolution() {
|
| for (UINT profile_idx = 0; profile_idx < profile_count; profile_idx++) {
|
| GUID profile_id = {};
|
| hr = video_device->GetVideoDecoderProfile(profile_idx, &profile_id);
|
| - if (SUCCEEDED(hr) &&
|
| - (profile_id == DXVA2_ModeH264_E ||
|
| - profile_id == DXVA2_Intel_ModeH264_E)) {
|
| + if (SUCCEEDED(hr) && (profile_id == DXVA2_ModeH264_E ||
|
| + profile_id == DXVA2_Intel_ModeH264_E)) {
|
| decoder_guid = profile_id;
|
| found = true;
|
| break;
|
| @@ -1584,20 +1546,17 @@ std::pair<int, int> DXVAVideoDecodeAccelerator::GetMaxH264Resolution() {
|
| // TODO(ananta)
|
| // Look into whether this list needs to be expanded.
|
| static std::pair<int, int> resolution_array[] = {
|
| - // Use 1088 to account for 16x16 macroblocks.
|
| - std::make_pair(1920, 1088),
|
| - std::make_pair(2560, 1440),
|
| - std::make_pair(3840, 2160),
|
| - std::make_pair(4096, 2160),
|
| - std::make_pair(4096, 2304),
|
| + // Use 1088 to account for 16x16 macroblocks.
|
| + std::make_pair(1920, 1088), std::make_pair(2560, 1440),
|
| + std::make_pair(3840, 2160), std::make_pair(4096, 2160),
|
| + std::make_pair(4096, 2304),
|
| };
|
|
|
| {
|
| TRACE_EVENT0("gpu,startup",
|
| "GetMaxH264Resolution. Resolution search begin");
|
|
|
| - for (size_t res_idx = 0; res_idx < arraysize(resolution_array);
|
| - res_idx++) {
|
| + for (size_t res_idx = 0; res_idx < arraysize(resolution_array); res_idx++) {
|
| D3D11_VIDEO_DECODER_DESC desc = {};
|
| desc.Guid = decoder_guid;
|
| desc.SampleWidth = resolution_array[res_idx].first;
|
| @@ -1615,7 +1574,7 @@ std::pair<int, int> DXVAVideoDecodeAccelerator::GetMaxH264Resolution() {
|
|
|
| base::win::ScopedComPtr<ID3D11VideoDecoder> video_decoder;
|
| hr = video_device->CreateVideoDecoder(&desc, &config,
|
| - video_decoder.Receive());
|
| + video_decoder.Receive());
|
| if (!video_decoder.get())
|
| return max_resolution;
|
|
|
| @@ -1659,7 +1618,7 @@ bool DXVAVideoDecodeAccelerator::IsLegacyGPU(ID3D11Device* device) {
|
| // the global list defined by the g_AMDUVD3GPUList and g_IntelLegacyGPUList
|
| // arrays above. If yes then the device is treated as a legacy device.
|
| if ((adapter_desc.VendorId == kAMDGPUId1) ||
|
| - adapter_desc.VendorId == kAMDGPUId2) {
|
| + adapter_desc.VendorId == kAMDGPUId2) {
|
| {
|
| TRACE_EVENT0("gpu,startup",
|
| "DXVAVideoDecodeAccelerator::IsLegacyGPU. AMD check");
|
| @@ -1671,7 +1630,7 @@ bool DXVAVideoDecodeAccelerator::IsLegacyGPU(ID3D11Device* device) {
|
| } else if (adapter_desc.VendorId == kIntelGPU) {
|
| {
|
| TRACE_EVENT0("gpu,startup",
|
| - "DXVAVideoDecodeAccelerator::IsLegacyGPU. Intel check");
|
| + "DXVAVideoDecodeAccelerator::IsLegacyGPU. Intel check");
|
| for (size_t i = 0; i < arraysize(g_IntelLegacyGPUList); i++) {
|
| if (adapter_desc.DeviceId == g_IntelLegacyGPUList[i])
|
| return legacy_gpu;
|
| @@ -1703,13 +1662,11 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
|
| // fall back to software decoding. See crbug/403440.
|
| std::unique_ptr<FileVersionInfo> version_info(
|
| FileVersionInfo::CreateFileVersionInfoForModule(decoder_dll));
|
| - RETURN_ON_FAILURE(version_info,
|
| - "unable to get version of msmpeg2vdec.dll",
|
| + RETURN_ON_FAILURE(version_info, "unable to get version of msmpeg2vdec.dll",
|
| false);
|
| base::string16 file_version = version_info->file_version();
|
| RETURN_ON_FAILURE(file_version.find(L"6.1.7140") == base::string16::npos,
|
| - "blacklisted version of msmpeg2vdec.dll 6.1.7140",
|
| - false);
|
| + "blacklisted version of msmpeg2vdec.dll 6.1.7140", false);
|
| codec_ = media::kCodecH264;
|
| clsid = __uuidof(CMSH264DecoderMFT);
|
| } else if (enable_accelerated_vpx_decode_ &&
|
| @@ -1726,7 +1683,7 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
|
|
|
| base::FilePath dll_path;
|
| RETURN_ON_FAILURE(PathService::Get(program_files_key, &dll_path),
|
| - "failed to get path for Program Files", false);
|
| + "failed to get path for Program Files", false);
|
|
|
| dll_path = dll_path.Append(kVPXDecoderDLLPath);
|
| if (profile == media::VP8PROFILE_ANY) {
|
| @@ -1739,16 +1696,14 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
|
| clsid = CLSID_WebmMfVp9Dec;
|
| }
|
| decoder_dll = ::LoadLibraryEx(dll_path.value().data(), NULL,
|
| - LOAD_WITH_ALTERED_SEARCH_PATH);
|
| + LOAD_WITH_ALTERED_SEARCH_PATH);
|
| RETURN_ON_FAILURE(decoder_dll, "vpx decoder dll is not loaded", false);
|
| } else {
|
| RETURN_ON_FAILURE(false, "Unsupported codec.", false);
|
| }
|
|
|
| - HRESULT hr = CreateCOMObjectFromDll(decoder_dll,
|
| - clsid,
|
| - __uuidof(IMFTransform),
|
| - decoder_.ReceiveVoid());
|
| + HRESULT hr = CreateCOMObjectFromDll(
|
| + decoder_dll, clsid, __uuidof(IMFTransform), decoder_.ReceiveVoid());
|
| RETURN_ON_HR_FAILURE(hr, "Failed to create decoder instance", false);
|
|
|
| RETURN_ON_FAILURE(CheckDecoderDxvaSupport(),
|
| @@ -1759,21 +1714,18 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
|
| CHECK(create_dxgi_device_manager_);
|
| RETURN_AND_NOTIFY_ON_FAILURE(CreateDX11DevManager(),
|
| "Failed to initialize DX11 device and manager",
|
| - PLATFORM_FAILURE,
|
| - false);
|
| - device_manager_to_use = reinterpret_cast<ULONG_PTR>(
|
| - d3d11_device_manager_.get());
|
| + PLATFORM_FAILURE, false);
|
| + device_manager_to_use =
|
| + reinterpret_cast<ULONG_PTR>(d3d11_device_manager_.get());
|
| } else {
|
| RETURN_AND_NOTIFY_ON_FAILURE(CreateD3DDevManager(),
|
| "Failed to initialize D3D device and manager",
|
| - PLATFORM_FAILURE,
|
| - false);
|
| + PLATFORM_FAILURE, false);
|
| device_manager_to_use = reinterpret_cast<ULONG_PTR>(device_manager_.get());
|
| }
|
|
|
| - hr = decoder_->ProcessMessage(
|
| - MFT_MESSAGE_SET_D3D_MANAGER,
|
| - device_manager_to_use);
|
| + hr = decoder_->ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER,
|
| + device_manager_to_use);
|
| if (use_dx11_) {
|
| RETURN_ON_HR_FAILURE(hr, "Failed to pass DX11 manager to decoder", false);
|
| } else {
|
| @@ -1782,24 +1734,18 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
|
|
|
| EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay();
|
|
|
| - EGLint config_attribs[] = {
|
| - EGL_BUFFER_SIZE, 32,
|
| - EGL_RED_SIZE, 8,
|
| - EGL_GREEN_SIZE, 8,
|
| - EGL_BLUE_SIZE, 8,
|
| - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
| - EGL_ALPHA_SIZE, 0,
|
| - EGL_NONE
|
| - };
|
| + EGLint config_attribs[] = {EGL_BUFFER_SIZE, 32,
|
| + EGL_RED_SIZE, 8,
|
| + EGL_GREEN_SIZE, 8,
|
| + EGL_BLUE_SIZE, 8,
|
| + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
| + EGL_ALPHA_SIZE, 0,
|
| + EGL_NONE};
|
|
|
| EGLint num_configs;
|
|
|
| - if (!eglChooseConfig(
|
| - egl_display,
|
| - config_attribs,
|
| - &egl_config_,
|
| - 1,
|
| - &num_configs))
|
| + if (!eglChooseConfig(egl_display, config_attribs, &egl_config_, 1,
|
| + &num_configs))
|
| return false;
|
|
|
| return SetDecoderMediaTypes();
|
| @@ -1922,8 +1868,8 @@ bool DXVAVideoDecodeAccelerator::GetStreamsInfoAndBufferReqs() {
|
| // The flags here should be the same and mean the same thing, except when
|
| // DXVA is enabled, there is an extra 0x100 flag meaning decoder will
|
| // allocate its own sample.
|
| - DVLOG(1) << "Flags: "
|
| - << std::hex << std::showbase << output_stream_info_.dwFlags;
|
| + DVLOG(1) << "Flags: " << std::hex << std::showbase
|
| + << output_stream_info_.dwFlags;
|
| if (codec_ == media::kCodecH264) {
|
| CHECK_EQ(output_stream_info_.dwFlags, 0x107u);
|
| }
|
| @@ -1939,15 +1885,14 @@ void DXVAVideoDecodeAccelerator::DoDecode() {
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE(
|
| (state == kNormal || state == kFlushing || state == kStopped),
|
| - "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE,);
|
| + "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, );
|
|
|
| MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0};
|
| DWORD status = 0;
|
|
|
| HRESULT hr = decoder_->ProcessOutput(0, // No flags
|
| 1, // # of out streams to pull from
|
| - &output_data_buffer,
|
| - &status);
|
| + &output_data_buffer, &status);
|
| IMFCollection* events = output_data_buffer.pEvents;
|
| if (events != NULL) {
|
| DVLOG(1) << "Got events from ProcessOuput, but discarding";
|
| @@ -1985,7 +1930,8 @@ void DXVAVideoDecodeAccelerator::DoDecode() {
|
| inputs_before_decode_ = 0;
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(ProcessOutputSample(output_data_buffer.pSample),
|
| - "Failed to process output sample.", PLATFORM_FAILURE,);
|
| + "Failed to process output sample.",
|
| + PLATFORM_FAILURE, );
|
| }
|
|
|
| bool DXVAVideoDecodeAccelerator::ProcessOutputSample(IMFSample* sample) {
|
| @@ -2021,11 +1967,8 @@ bool DXVAVideoDecodeAccelerator::ProcessOutputSample(IMFSample* sample) {
|
|
|
| // Go ahead and request picture buffers.
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - width,
|
| - height));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers,
|
| + weak_this_factory_.GetWeakPtr(), width, height));
|
|
|
| pictures_requested_ = true;
|
| return true;
|
| @@ -2044,8 +1987,7 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
|
| OutputBuffers::iterator index;
|
|
|
| for (index = output_picture_buffers_.begin();
|
| - index != output_picture_buffers_.end() &&
|
| - OutputSamplesPresent();
|
| + index != output_picture_buffers_.end() && OutputSamplesPresent();
|
| ++index) {
|
| if (index->second->available()) {
|
| PendingSampleInfo* pending_sample = NULL;
|
| @@ -2059,10 +2001,11 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
|
|
|
| int width = 0;
|
| int height = 0;
|
| - if (!GetVideoFrameDimensions(pending_sample->output_sample.get(),
|
| - &width, &height)) {
|
| - RETURN_AND_NOTIFY_ON_FAILURE(false,
|
| - "Failed to get D3D surface from output sample", PLATFORM_FAILURE,);
|
| + if (!GetVideoFrameDimensions(pending_sample->output_sample.get(), &width,
|
| + &height)) {
|
| + RETURN_AND_NOTIFY_ON_FAILURE(
|
| + false, "Failed to get D3D surface from output sample",
|
| + PLATFORM_FAILURE, );
|
| }
|
|
|
| if (width != index->second->size().width() ||
|
| @@ -2074,8 +2017,8 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
|
| base::win::ScopedComPtr<IMFMediaBuffer> output_buffer;
|
| HRESULT hr = pending_sample->output_sample->GetBufferByIndex(
|
| 0, output_buffer.Receive());
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to get buffer from output sample", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(
|
| + hr, "Failed to get buffer from output sample", PLATFORM_FAILURE, );
|
|
|
| base::win::ScopedComPtr<IDirect3DSurface9> surface;
|
| base::win::ScopedComPtr<ID3D11Texture2D> d3d11_texture;
|
| @@ -2083,8 +2026,9 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
|
| if (use_dx11_) {
|
| base::win::ScopedComPtr<IMFDXGIBuffer> dxgi_buffer;
|
| hr = dxgi_buffer.QueryFrom(output_buffer.get());
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to get DXGIBuffer from output sample", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(
|
| + hr, "Failed to get DXGIBuffer from output sample",
|
| + PLATFORM_FAILURE, );
|
| hr = dxgi_buffer->GetResource(
|
| __uuidof(ID3D11Texture2D),
|
| reinterpret_cast<void**>(d3d11_texture.Receive()));
|
| @@ -2092,18 +2036,16 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
|
| hr = MFGetService(output_buffer.get(), MR_BUFFER_SERVICE,
|
| IID_PPV_ARGS(surface.Receive()));
|
| }
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to get surface from output sample", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(
|
| + hr, "Failed to get surface from output sample", PLATFORM_FAILURE, );
|
|
|
| pending_sample->picture_buffer_id = index->second->id();
|
|
|
| RETURN_AND_NOTIFY_ON_FAILURE(
|
| index->second->CopyOutputSampleDataToPictureBuffer(
|
| - this,
|
| - surface.get(),
|
| - d3d11_texture.get(),
|
| + this, surface.get(), d3d11_texture.get(),
|
| pending_sample->input_buffer_id),
|
| - "Failed to copy output sample", PLATFORM_FAILURE,);
|
| + "Failed to copy output sample", PLATFORM_FAILURE, );
|
|
|
| index->second->set_available(false);
|
| }
|
| @@ -2111,13 +2053,11 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
|
| }
|
|
|
| void DXVAVideoDecodeAccelerator::StopOnError(
|
| - media::VideoDecodeAccelerator::Error error) {
|
| + media::VideoDecodeAccelerator::Error error) {
|
| if (!main_thread_task_runner_->BelongsToCurrentThread()) {
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::StopOnError,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - error));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::StopOnError,
|
| + weak_this_factory_.GetWeakPtr(), error));
|
| return;
|
| }
|
|
|
| @@ -2207,16 +2147,15 @@ void DXVAVideoDecodeAccelerator::RequestPictureBuffers(int width, int height) {
|
| }
|
| }
|
|
|
| -void DXVAVideoDecodeAccelerator::NotifyPictureReady(
|
| - int picture_buffer_id,
|
| - int input_buffer_id) {
|
| +void DXVAVideoDecodeAccelerator::NotifyPictureReady(int picture_buffer_id,
|
| + int input_buffer_id) {
|
| DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
|
| // This task could execute after the decoder has been torn down.
|
| if (GetState() != kUninitialized && client_) {
|
| // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use
|
| // coded size here so use (0, 0) intentionally to have the client choose.
|
| - media::Picture picture(picture_buffer_id, input_buffer_id,
|
| - gfx::Rect(0, 0), false);
|
| + media::Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0),
|
| + false);
|
| client_->PictureReady(picture);
|
| }
|
| }
|
| @@ -2230,7 +2169,7 @@ void DXVAVideoDecodeAccelerator::NotifyInputBuffersDropped() {
|
| it != pending_input_buffers_.end(); ++it) {
|
| LONGLONG input_buffer_id = 0;
|
| RETURN_ON_HR_FAILURE((*it)->GetSampleTime(&input_buffer_id),
|
| - "Failed to get buffer id associated with sample",);
|
| + "Failed to get buffer id associated with sample", );
|
| client_->NotifyEndOfBitstreamBuffer(input_buffer_id);
|
| }
|
| pending_input_buffers_.clear();
|
| @@ -2240,7 +2179,7 @@ void DXVAVideoDecodeAccelerator::DecodePendingInputBuffers() {
|
| DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
|
| State state = GetState();
|
| RETURN_AND_NOTIFY_ON_FAILURE((state != kUninitialized),
|
| - "Invalid state: " << state, ILLEGAL_STATE,);
|
| + "Invalid state: " << state, ILLEGAL_STATE, );
|
|
|
| if (pending_input_buffers_.empty() || OutputSamplesPresent())
|
| return;
|
| @@ -2268,11 +2207,10 @@ void DXVAVideoDecodeAccelerator::FlushInternal() {
|
| decoder_thread_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers,
|
| - base::Unretained(this)));
|
| + base::Unretained(this)));
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| - base::Unretained(this)));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| + base::Unretained(this)));
|
| return;
|
| }
|
|
|
| @@ -2281,7 +2219,7 @@ void DXVAVideoDecodeAccelerator::FlushInternal() {
|
| if (!sent_drain_message_) {
|
| RETURN_AND_NOTIFY_ON_FAILURE(SendMFTMessage(MFT_MESSAGE_COMMAND_DRAIN, 0),
|
| "Failed to send drain message",
|
| - PLATFORM_FAILURE,);
|
| + PLATFORM_FAILURE, );
|
| sent_drain_message_ = true;
|
| }
|
| }
|
| @@ -2296,9 +2234,8 @@ void DXVAVideoDecodeAccelerator::FlushInternal() {
|
| SetState(kFlushing);
|
|
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone,
|
| - weak_this_factory_.GetWeakPtr()));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone,
|
| + weak_this_factory_.GetWeakPtr()));
|
|
|
| SetState(kNormal);
|
| }
|
| @@ -2321,15 +2258,13 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
|
|
|
| HRESULT hr = CheckConfigChanged(sample.get(), &config_changed);
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to check video stream config",
|
| - PLATFORM_FAILURE,);
|
| + PLATFORM_FAILURE, );
|
|
|
| if (config_changed) {
|
| pending_input_buffers_.push_back(sample);
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::ConfigChanged,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - config_));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::ConfigChanged,
|
| + weak_this_factory_.GetWeakPtr(), config_));
|
| return;
|
| }
|
|
|
| @@ -2355,10 +2290,10 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
|
| // process any more input until that frame is copied to the target surface.
|
| if (!OutputSamplesPresent()) {
|
| State state = GetState();
|
| - RETURN_AND_NOTIFY_ON_FAILURE((state == kStopped || state == kNormal ||
|
| - state == kFlushing),
|
| + RETURN_AND_NOTIFY_ON_FAILURE(
|
| + (state == kStopped || state == kNormal || state == kFlushing),
|
| "Failed to process output. Unexpected decoder state: " << state,
|
| - PLATFORM_FAILURE,);
|
| + PLATFORM_FAILURE, );
|
| hr = decoder_->ProcessInput(0, sample.get(), 0);
|
| }
|
| // If we continue to get the MF_E_NOTACCEPTING error we do the following:-
|
| @@ -2375,24 +2310,25 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
|
| decoder_thread_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers,
|
| - base::Unretained(this)));
|
| + base::Unretained(this)));
|
| return;
|
| }
|
| }
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to process input sample",
|
| - PLATFORM_FAILURE,);
|
| + PLATFORM_FAILURE, );
|
|
|
| DoDecode();
|
|
|
| State state = GetState();
|
| - RETURN_AND_NOTIFY_ON_FAILURE((state == kStopped || state == kNormal ||
|
| - state == kFlushing),
|
| + RETURN_AND_NOTIFY_ON_FAILURE(
|
| + (state == kStopped || state == kNormal || state == kFlushing),
|
| "Failed to process output. Unexpected decoder state: " << state,
|
| - ILLEGAL_STATE,);
|
| + ILLEGAL_STATE, );
|
|
|
| LONGLONG input_buffer_id = 0;
|
| - RETURN_ON_HR_FAILURE(sample->GetSampleTime(&input_buffer_id),
|
| - "Failed to get input buffer id associated with sample",);
|
| + RETURN_ON_HR_FAILURE(
|
| + sample->GetSampleTime(&input_buffer_id),
|
| + "Failed to get input buffer id associated with sample", );
|
| // The Microsoft Media foundation decoder internally buffers up to 30 frames
|
| // before returning a decoded frame. We need to inform the client that this
|
| // input buffer is processed as it may stop sending us further input.
|
| @@ -2404,10 +2340,8 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
|
| // http://code.google.com/p/chromium/issues/detail?id=108121
|
| // http://code.google.com/p/chromium/issues/detail?id=150925
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::NotifyInputBufferRead,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - input_buffer_id));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::NotifyInputBufferRead,
|
| + weak_this_factory_.GetWeakPtr(), input_buffer_id));
|
| }
|
|
|
| void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width,
|
| @@ -2415,16 +2349,12 @@ void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width,
|
| dx11_video_format_converter_media_type_needs_init_ = true;
|
|
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers,
|
| - weak_this_factory_.GetWeakPtr(), false));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers,
|
| + weak_this_factory_.GetWeakPtr(), false));
|
|
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - width,
|
| - height));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers,
|
| + weak_this_factory_.GetWeakPtr(), width, height));
|
| }
|
|
|
| void DXVAVideoDecodeAccelerator::DismissStaleBuffers(bool force) {
|
| @@ -2435,8 +2365,7 @@ void DXVAVideoDecodeAccelerator::DismissStaleBuffers(bool force) {
|
| OutputBuffers::iterator index;
|
|
|
| for (index = output_picture_buffers_.begin();
|
| - index != output_picture_buffers_.end();
|
| - ++index) {
|
| + index != output_picture_buffers_.end(); ++index) {
|
| if (force || index->second->available()) {
|
| DVLOG(1) << "Dismissing picture id: " << index->second->id();
|
| client_->DismissPictureBuffer(index->second->id());
|
| @@ -2456,16 +2385,15 @@ void DXVAVideoDecodeAccelerator::DeferredDismissStaleBuffer(
|
| "Failed to make context current",
|
| PLATFORM_FAILURE, );
|
|
|
| - OutputBuffers::iterator it = stale_output_picture_buffers_.find(
|
| - picture_buffer_id);
|
| + OutputBuffers::iterator it =
|
| + stale_output_picture_buffers_.find(picture_buffer_id);
|
| DCHECK(it != stale_output_picture_buffers_.end());
|
| DVLOG(1) << "Dismissing picture id: " << it->second->id();
|
| client_->DismissPictureBuffer(it->second->id());
|
| stale_output_picture_buffers_.erase(it);
|
| }
|
|
|
| -DXVAVideoDecodeAccelerator::State
|
| -DXVAVideoDecodeAccelerator::GetState() {
|
| +DXVAVideoDecodeAccelerator::State DXVAVideoDecodeAccelerator::GetState() {
|
| static_assert(sizeof(State) == sizeof(long), "mismatched type sizes");
|
| State state = static_cast<State>(
|
| InterlockedAdd(reinterpret_cast<volatile long*>(&state_), 0));
|
| @@ -2475,16 +2403,13 @@ DXVAVideoDecodeAccelerator::GetState() {
|
| void DXVAVideoDecodeAccelerator::SetState(State new_state) {
|
| if (!main_thread_task_runner_->BelongsToCurrentThread()) {
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::SetState,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - new_state));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::SetState,
|
| + weak_this_factory_.GetWeakPtr(), new_state));
|
| return;
|
| }
|
|
|
| static_assert(sizeof(State) == sizeof(long), "mismatched type sizes");
|
| - ::InterlockedExchange(reinterpret_cast<volatile long*>(&state_),
|
| - new_state);
|
| + ::InterlockedExchange(reinterpret_cast<volatile long*>(&state_), new_state);
|
| DCHECK_EQ(state_, new_state);
|
| }
|
|
|
| @@ -2505,24 +2430,20 @@ void DXVAVideoDecodeAccelerator::CopySurface(IDirect3DSurface9* src_surface,
|
| int input_buffer_id) {
|
| if (!decoder_thread_task_runner_->BelongsToCurrentThread()) {
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::CopySurface,
|
| - base::Unretained(this),
|
| - src_surface,
|
| - dest_surface,
|
| - picture_buffer_id,
|
| - input_buffer_id));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::CopySurface,
|
| + base::Unretained(this), src_surface, dest_surface,
|
| + picture_buffer_id, input_buffer_id));
|
| return;
|
| }
|
|
|
| HRESULT hr = d3d9_device_ex_->StretchRect(src_surface, NULL, dest_surface,
|
| NULL, D3DTEXF_NONE);
|
| - RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed",);
|
| + RETURN_ON_HR_FAILURE(hr, "Colorspace conversion via StretchRect failed", );
|
|
|
| // Ideally, this should be done immediately before the draw call that uses
|
| // the texture. Flush it once here though.
|
| hr = query_->Issue(D3DISSUE_END);
|
| - RETURN_ON_HR_FAILURE(hr, "Failed to issue END",);
|
| + RETURN_ON_HR_FAILURE(hr, "Failed to issue END", );
|
|
|
| // If we are sharing the ANGLE device we don't need to wait for the Flush to
|
| // complete.
|
| @@ -2530,21 +2451,17 @@ void DXVAVideoDecodeAccelerator::CopySurface(IDirect3DSurface9* src_surface,
|
| main_thread_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&DXVAVideoDecodeAccelerator::CopySurfaceComplete,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - src_surface,
|
| - dest_surface,
|
| - picture_buffer_id,
|
| - input_buffer_id));
|
| + weak_this_factory_.GetWeakPtr(), src_surface, dest_surface,
|
| + picture_buffer_id, input_buffer_id));
|
| return;
|
| }
|
|
|
| // Flush the decoder device to ensure that the decoded frame is copied to the
|
| // target surface.
|
| decoder_thread_task_runner_->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushDecoder,
|
| - base::Unretained(this), 0, src_surface, dest_surface,
|
| - picture_buffer_id, input_buffer_id),
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushDecoder,
|
| + base::Unretained(this), 0, src_surface,
|
| + dest_surface, picture_buffer_id, input_buffer_id),
|
| base::TimeDelta::FromMilliseconds(kFlushDecoderSurfaceTimeoutMs));
|
| }
|
|
|
| @@ -2590,9 +2507,8 @@ void DXVAVideoDecodeAccelerator::CopySurfaceComplete(
|
|
|
| if (pending_flush_) {
|
| decoder_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| - base::Unretained(this)));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
|
| + base::Unretained(this)));
|
| return;
|
| }
|
| decoder_thread_task_runner_->PostTask(
|
| @@ -2633,7 +2549,7 @@ void DXVAVideoDecodeAccelerator::CopyTexture(
|
| source_desc.Height)) {
|
| RETURN_AND_NOTIFY_ON_FAILURE(
|
| false, "Failed to initialize media types for convesion.",
|
| - PLATFORM_FAILURE,);
|
| + PLATFORM_FAILURE, );
|
| }
|
|
|
| // The input to the video processor is the output sample.
|
| @@ -2675,22 +2591,21 @@ void DXVAVideoDecodeAccelerator::CopyTexture(
|
| base::win::ScopedComPtr<IMFSample> output_sample;
|
| hr = MFCreateSample(output_sample.Receive());
|
| if (FAILED(hr)) {
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to create output sample.", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to create output sample.",
|
| + PLATFORM_FAILURE, );
|
| }
|
|
|
| base::win::ScopedComPtr<IMFMediaBuffer> output_buffer;
|
| - hr = MFCreateDXGISurfaceBuffer(
|
| - __uuidof(ID3D11Texture2D), dest_texture, 0, FALSE,
|
| - output_buffer.Receive());
|
| + hr = MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), dest_texture, 0,
|
| + FALSE, output_buffer.Receive());
|
| if (FAILED(hr)) {
|
| base::debug::Alias(&hr);
|
| // TODO(ananta)
|
| // Remove this CHECK when the change to use DX11 for H/W decoding
|
| // stablizes.
|
| CHECK(false);
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to create output sample.", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to create output sample.",
|
| + PLATFORM_FAILURE, );
|
| }
|
|
|
| output_sample->AddBuffer(output_buffer.get());
|
| @@ -2698,18 +2613,17 @@ void DXVAVideoDecodeAccelerator::CopyTexture(
|
| hr = video_format_converter_mft_->ProcessInput(0, video_frame, 0);
|
| if (FAILED(hr)) {
|
| DCHECK(false);
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to convert output sample format.", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(
|
| + hr, "Failed to convert output sample format.", PLATFORM_FAILURE, );
|
| }
|
|
|
| DWORD status = 0;
|
| MFT_OUTPUT_DATA_BUFFER format_converter_output = {};
|
| format_converter_output.pSample = output_sample.get();
|
| hr = video_format_converter_mft_->ProcessOutput(
|
| - 0, // No flags
|
| - 1, // # of out streams to pull from
|
| - &format_converter_output,
|
| - &status);
|
| + 0, // No flags
|
| + 1, // # of out streams to pull from
|
| + &format_converter_output, &status);
|
|
|
| if (FAILED(hr)) {
|
| base::debug::Alias(&hr);
|
| @@ -2717,8 +2631,8 @@ void DXVAVideoDecodeAccelerator::CopyTexture(
|
| // Remove this CHECK when the change to use DX11 for H/W decoding
|
| // stablizes.
|
| CHECK(false);
|
| - RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to convert output sample format.", PLATFORM_FAILURE,);
|
| + RETURN_AND_NOTIFY_ON_HR_FAILURE(
|
| + hr, "Failed to convert output sample format.", PLATFORM_FAILURE, );
|
| }
|
|
|
| if (dest_keyed_mutex) {
|
| @@ -2744,12 +2658,11 @@ void DXVAVideoDecodeAccelerator::CopyTexture(
|
| }
|
| }
|
|
|
| -void DXVAVideoDecodeAccelerator::FlushDecoder(
|
| - int iterations,
|
| - IDirect3DSurface9* src_surface,
|
| - IDirect3DSurface9* dest_surface,
|
| - int picture_buffer_id,
|
| - int input_buffer_id) {
|
| +void DXVAVideoDecodeAccelerator::FlushDecoder(int iterations,
|
| + IDirect3DSurface9* src_surface,
|
| + IDirect3DSurface9* dest_surface,
|
| + int picture_buffer_id,
|
| + int input_buffer_id) {
|
| DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
|
|
|
| // The DXVA decoder has its own device which it uses for decoding. ANGLE
|
| @@ -2784,26 +2697,22 @@ void DXVAVideoDecodeAccelerator::FlushDecoder(
|
|
|
| if ((hr == S_FALSE) && (++iterations < kMaxIterationsForD3DFlush)) {
|
| decoder_thread_task_runner_->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::FlushDecoder,
|
| - base::Unretained(this), iterations, src_surface,
|
| - dest_surface, picture_buffer_id, input_buffer_id),
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushDecoder,
|
| + base::Unretained(this), iterations, src_surface,
|
| + dest_surface, picture_buffer_id, input_buffer_id),
|
| base::TimeDelta::FromMilliseconds(kFlushDecoderSurfaceTimeoutMs));
|
| return;
|
| }
|
|
|
| main_thread_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&DXVAVideoDecodeAccelerator::CopySurfaceComplete,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - src_surface,
|
| - dest_surface,
|
| - picture_buffer_id,
|
| - input_buffer_id));
|
| + FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::CopySurfaceComplete,
|
| + weak_this_factory_.GetWeakPtr(), src_surface,
|
| + dest_surface, picture_buffer_id, input_buffer_id));
|
| }
|
|
|
| bool DXVAVideoDecodeAccelerator::InitializeDX11VideoFormatConverterMediaType(
|
| - int width, int height) {
|
| + int width,
|
| + int height) {
|
| if (!dx11_video_format_converter_media_type_needs_init_)
|
| return true;
|
|
|
| @@ -2811,8 +2720,7 @@ bool DXVAVideoDecodeAccelerator::InitializeDX11VideoFormatConverterMediaType(
|
|
|
| HRESULT hr = video_format_converter_mft_->ProcessMessage(
|
| MFT_MESSAGE_SET_D3D_MANAGER,
|
| - reinterpret_cast<ULONG_PTR>(
|
| - d3d11_device_manager_.get()));
|
| + reinterpret_cast<ULONG_PTR>(d3d11_device_manager_.get()));
|
|
|
| if (FAILED(hr)) {
|
| base::debug::Alias(&hr);
|
| @@ -2822,27 +2730,28 @@ bool DXVAVideoDecodeAccelerator::InitializeDX11VideoFormatConverterMediaType(
|
| CHECK(false);
|
| }
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr,
|
| - "Failed to initialize video format converter", PLATFORM_FAILURE, false);
|
| + "Failed to initialize video format converter",
|
| + PLATFORM_FAILURE, false);
|
|
|
| - video_format_converter_mft_->ProcessMessage(
|
| - MFT_MESSAGE_NOTIFY_END_STREAMING, 0);
|
| + video_format_converter_mft_->ProcessMessage(MFT_MESSAGE_NOTIFY_END_STREAMING,
|
| + 0);
|
|
|
| base::win::ScopedComPtr<IMFMediaType> media_type;
|
| hr = MFCreateMediaType(media_type.Receive());
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "MFCreateMediaType failed",
|
| - PLATFORM_FAILURE, false);
|
| + PLATFORM_FAILURE, false);
|
|
|
| hr = media_type->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to set major input type",
|
| - PLATFORM_FAILURE, false);
|
| + PLATFORM_FAILURE, false);
|
|
|
| hr = media_type->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to set input sub type",
|
| - PLATFORM_FAILURE, false);
|
| + PLATFORM_FAILURE, false);
|
|
|
| hr = MFSetAttributeSize(media_type.get(), MF_MT_FRAME_SIZE, width, height);
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to set media type attributes",
|
| - PLATFORM_FAILURE, false);
|
| + PLATFORM_FAILURE, false);
|
|
|
| hr = video_format_converter_mft_->SetInputType(0, media_type.get(), 0);
|
| if (FAILED(hr)) {
|
| @@ -2853,22 +2762,16 @@ bool DXVAVideoDecodeAccelerator::InitializeDX11VideoFormatConverterMediaType(
|
| CHECK(false);
|
| }
|
| RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to set converter input type",
|
| - PLATFORM_FAILURE, false);
|
| + PLATFORM_FAILURE, false);
|
|
|
| // It appears that we fail to set MFVideoFormat_ARGB32 as the output media
|
| // type in certain configurations. Try to fallback to MFVideoFormat_RGB32
|
| // in such cases. If both fail, then bail.
|
| - bool media_type_set =
|
| - SetTransformOutputType(video_format_converter_mft_.get(),
|
| - MFVideoFormat_ARGB32,
|
| - width,
|
| - height);
|
| + bool media_type_set = SetTransformOutputType(
|
| + video_format_converter_mft_.get(), MFVideoFormat_ARGB32, width, height);
|
| if (!media_type_set) {
|
| - media_type_set =
|
| - SetTransformOutputType(video_format_converter_mft_.get(),
|
| - MFVideoFormat_RGB32,
|
| - width,
|
| - height);
|
| + media_type_set = SetTransformOutputType(video_format_converter_mft_.get(),
|
| + MFVideoFormat_RGB32, width, height);
|
| }
|
|
|
| if (!media_type_set) {
|
| @@ -2882,10 +2785,9 @@ bool DXVAVideoDecodeAccelerator::InitializeDX11VideoFormatConverterMediaType(
|
| return true;
|
| }
|
|
|
| -bool DXVAVideoDecodeAccelerator::GetVideoFrameDimensions(
|
| - IMFSample* sample,
|
| - int* width,
|
| - int* height) {
|
| +bool DXVAVideoDecodeAccelerator::GetVideoFrameDimensions(IMFSample* sample,
|
| + int* width,
|
| + int* height) {
|
| base::win::ScopedComPtr<IMFMediaBuffer> output_buffer;
|
| HRESULT hr = sample->GetBufferByIndex(0, output_buffer.Receive());
|
| RETURN_ON_HR_FAILURE(hr, "Failed to get buffer from output sample", false);
|
| @@ -2920,17 +2822,15 @@ bool DXVAVideoDecodeAccelerator::GetVideoFrameDimensions(
|
| return true;
|
| }
|
|
|
| -bool DXVAVideoDecodeAccelerator::SetTransformOutputType(
|
| - IMFTransform* transform,
|
| - const GUID& output_type,
|
| - int width,
|
| - int height) {
|
| +bool DXVAVideoDecodeAccelerator::SetTransformOutputType(IMFTransform* transform,
|
| + const GUID& output_type,
|
| + int width,
|
| + int height) {
|
| HRESULT hr = E_FAIL;
|
| base::win::ScopedComPtr<IMFMediaType> media_type;
|
|
|
| for (uint32_t i = 0;
|
| - SUCCEEDED(transform->GetOutputAvailableType(
|
| - 0, i, media_type.Receive()));
|
| + SUCCEEDED(transform->GetOutputAvailableType(0, i, media_type.Receive()));
|
| ++i) {
|
| GUID out_subtype = {0};
|
| hr = media_type->GetGUID(MF_MT_SUBTYPE, &out_subtype);
|
| @@ -2951,8 +2851,8 @@ bool DXVAVideoDecodeAccelerator::SetTransformOutputType(
|
| return false;
|
| }
|
|
|
| -HRESULT DXVAVideoDecodeAccelerator::CheckConfigChanged(
|
| - IMFSample* sample, bool* config_changed) {
|
| +HRESULT DXVAVideoDecodeAccelerator::CheckConfigChanged(IMFSample* sample,
|
| + bool* config_changed) {
|
| if (codec_ != media::kCodecH264)
|
| return S_FALSE;
|
|
|
| @@ -2963,17 +2863,15 @@ HRESULT DXVAVideoDecodeAccelerator::CheckConfigChanged(
|
| MediaBufferScopedPointer scoped_media_buffer(buffer.get());
|
|
|
| if (!config_change_detector_->DetectConfig(
|
| - scoped_media_buffer.get(),
|
| - scoped_media_buffer.current_length())) {
|
| + scoped_media_buffer.get(), scoped_media_buffer.current_length())) {
|
| RETURN_ON_HR_FAILURE(E_FAIL, "Failed to detect H.264 stream config",
|
| - E_FAIL);
|
| + E_FAIL);
|
| }
|
| *config_changed = config_change_detector_->config_changed();
|
| return S_OK;
|
| }
|
|
|
| -void DXVAVideoDecodeAccelerator::ConfigChanged(
|
| - const Config& config) {
|
| +void DXVAVideoDecodeAccelerator::ConfigChanged(const Config& config) {
|
| DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
|
|
|
| SetState(kConfigChange);
|
| @@ -2986,4 +2884,4 @@ void DXVAVideoDecodeAccelerator::ConfigChanged(
|
| base::Unretained(this)));
|
| }
|
|
|
| -} // namespace content
|
| +} // namespace media
|
|
|