Skip to content

Commit 0420be2

Browse files
committed
git subtree pull latest AMF shared code in preparation for x.x.x release
2 parents cd231d5 + 59eecc1 commit 0420be2

File tree

13 files changed

+416
-11
lines changed

13 files changed

+416
-11
lines changed

amf/public/common/AMFSTL.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern "C"
5050
extern int vscwprintf(const wchar_t* p_fmt, va_list p_args);
5151
extern int vscprintf(const char* p_fmt, va_list p_args);
5252
}
53-
#elif _MSC_VER <= 1910
53+
#elif _MSC_VER <= 1911
5454
#define snprintf _snprintf
5555
#define vscprintf _vscprintf
5656
#define vscwprintf _vscwprintf // Count chars without writing to string
@@ -741,17 +741,19 @@ static size_t amf_wprintfCore(outputStreamDelegateW p_outDelegate, void* p_conte
741741
const void* str = va_arg(p_args, const void*);
742742
if (str != NULL)
743743
{
744+
const wchar_t* str_wchar = nullptr;
744745
switch (*(fmt - 1))
745746
{
746747
case L'h':
747748
currentArgumentString = amf_from_utf8_to_unicode(reinterpret_cast<const char*>(str));
749+
str_wchar = currentArgumentString.c_str();
748750
break;
749751
case L'l':
750752
case L'w':
751-
currentArgumentString = reinterpret_cast<const wchar_t*>(str);
753+
currentArgumentString = str_wchar = reinterpret_cast<const wchar_t*>(str);
752754
break;
753755
default:
754-
currentArgumentString = reinterpret_cast<const wchar_t*>(str);
756+
currentArgumentString = str_wchar = reinterpret_cast<const wchar_t*>(str);
755757
}
756758
}
757759
else
@@ -796,7 +798,7 @@ static size_t amf_wprintfCore(outputStreamDelegateW p_outDelegate, void* p_conte
796798
switch (*(fmt - 1))
797799
{
798800
case L'l':
799-
if (*(fmt - 1) == L'l') // long long
801+
if (*(fmt - 2) == L'l') // long long
800802
{
801803
sprintf(tempBuffer, currentFormatMB.c_str(), va_arg(p_args, long long));
802804
}

amf/public/common/CurrentTime.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
//
22+
23+
#ifndef __AMFCurrentTime_h__
24+
#define __AMFCurrentTime_h__
25+
26+
#include "public/include/core/Platform.h"
27+
#include "public/include/core/Interface.h"
28+
29+
namespace amf
30+
{
31+
// Current time interface class. This interface object can be passed
32+
// as a property to components requiring synchronized timing. The
33+
// implementation is:
34+
// - first call to Get() starts time and returns 0
35+
// - subsequent calls to Get() returns values relative to 0
36+
// - Reset() puts time back at 0 at next Get() call
37+
//
38+
class AMF_NO_VTABLE AMFCurrentTime : public AMFInterface
39+
{
40+
public:
41+
virtual amf_pts AMF_STD_CALL Get() = 0;
42+
43+
virtual void AMF_STD_CALL Reset() = 0;
44+
};
45+
46+
//----------------------------------------------------------------------------------------------
47+
// smart pointer
48+
//----------------------------------------------------------------------------------------------
49+
typedef AMFInterfacePtr_T<AMFCurrentTime> AMFCurrentTimePtr;
50+
//----------------------------------------------------------------------------------------------}
51+
}
52+
#endif // __AMFCurrentTime_h__
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
//
22+
23+
#include "CurrentTimeImpl.h"
24+
25+
namespace amf
26+
{
27+
28+
//-------------------------------------------------------------------------------------------------
29+
AMFCurrentTimeImpl::AMFCurrentTimeImpl()
30+
: m_timeOfFirstCall(-1)
31+
{
32+
}
33+
34+
//-------------------------------------------------------------------------------------------------
35+
AMFCurrentTimeImpl::~AMFCurrentTimeImpl()
36+
{
37+
m_timeOfFirstCall = -1;
38+
}
39+
40+
//-------------------------------------------------------------------------------------------------
41+
amf_pts AMF_STD_CALL AMFCurrentTimeImpl::Get()
42+
{
43+
amf::AMFLock lock(&m_sync);
44+
45+
// We want pts time to start at 0 and subsequent
46+
// times to be relative to that
47+
if (m_timeOfFirstCall < 0)
48+
{
49+
m_timeOfFirstCall = amf_high_precision_clock();
50+
return 0;
51+
}
52+
return (amf_high_precision_clock() - m_timeOfFirstCall); // In nanoseconds
53+
}
54+
55+
//-------------------------------------------------------------------------------------------------
56+
void AMF_STD_CALL AMFCurrentTimeImpl::Reset()
57+
{
58+
m_timeOfFirstCall = -1;
59+
}
60+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
//
22+
23+
#ifndef __AMFCurrentTimeImpl_h__
24+
#define __AMFCurrentTimeImpl_h__
25+
26+
#include "public/common/CurrentTime.h"
27+
#include "public/common/InterfaceImpl.h"
28+
#include "public/common/Thread.h"
29+
30+
namespace amf
31+
{
32+
33+
class AMFCurrentTimeImpl : public AMFInterfaceImpl<AMFCurrentTime>
34+
{
35+
public:
36+
AMFCurrentTimeImpl();
37+
~AMFCurrentTimeImpl();
38+
39+
AMF_BEGIN_INTERFACE_MAP
40+
AMF_INTERFACE_ENTRY(AMFCurrentTime)
41+
AMF_END_INTERFACE_MAP
42+
43+
virtual amf_pts AMF_STD_CALL Get();
44+
45+
virtual void AMF_STD_CALL Reset();
46+
47+
private:
48+
amf_pts m_timeOfFirstCall;
49+
mutable AMFCriticalSection m_sync;
50+
};
51+
52+
//----------------------------------------------------------------------------------------------
53+
// smart pointer
54+
//----------------------------------------------------------------------------------------------
55+
typedef AMFInterfacePtr_T<AMFCurrentTime> AMFCurrentTimePtr;
56+
//----------------------------------------------------------------------------------------------}
57+
}
58+
#endif // __AMFCurrentTimeImpl_h__
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// Notice Regarding Standards. AMD does not provide a license or sublicense to
3+
// any Intellectual Property Rights relating to any standards, including but not
4+
// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
5+
// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
6+
// (collectively, the "Media Technologies"). For clarity, you will pay any
7+
// royalties due for such third party technologies, which may include the Media
8+
// Technologies that are owed as a result of AMD providing the Software to you.
9+
//
10+
// MIT license
11+
//
12+
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
13+
//
14+
// Permission is hereby granted, free of charge, to any person obtaining a copy
15+
// of this software and associated documentation files (the "Software"), to deal
16+
// in the Software without restriction, including without limitation the rights
17+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
// copies of the Software, and to permit persons to whom the Software is
19+
// furnished to do so, subject to the following conditions:
20+
//
21+
// The above copyright notice and this permission notice shall be included in
22+
// all copies or substantial portions of the Software.
23+
//
24+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30+
// THE SOFTWARE.
31+
//
32+
33+
//-------------------------------------------------------------------------------------------------
34+
// Audio session interface declaration
35+
//-------------------------------------------------------------------------------------------------
36+
#ifndef __AMFAudioCapture_h__
37+
#define __AMFAudioCapture_h__
38+
39+
#pragma once
40+
41+
#include "public/include/components/Component.h"
42+
43+
// Set to capture from either a microphone or desktop
44+
#define AUDIOCAPTURE_SOURCE L"AudioCaptureSource" // amf_bool true for microphone, false for desktop;
45+
46+
// In the case of capturing a microphone, the AUDIOCAPTURE_DEVICE_ACTIVE property
47+
// can be set to -1 so that the active input devices are looked up. If the initialization
48+
// is successful then the AUDIOCAPTURE_DEVICE_NAME and AUDIOCAPTURE_DEVICE_COUNT
49+
// properties will be set.
50+
#define AUDIOCAPTURE_DEVICE_ACTIVE L"AudioCaptureDeviceActive" // amf_int64
51+
#define AUDIOCAPTURE_DEVICE_COUNT L"AudioCaptureDeviceCount" // amf_int64
52+
#define AUDIOCAPTURE_DEVICE_NAME L"AudioCaptureDeviceName" // String
53+
54+
// Codec used for audio capture
55+
#define AUDIOCAPTURE_CODEC L"AudioCaptureCodec" // amf_int64, AV_CODEC_ID_PCM_F32LE
56+
// Sample rate used for audio capture
57+
#define AUDIOCAPTURE_SAMPLERATE L"AudioCaptureSampleRate" // amf_int64, 44100,def
58+
// Sample count used for audio capture
59+
#define AUDIOCAPTURE_SAMPLES L"AudioCaptureSampleCount" // amf_int64, 1024
60+
// Bitrate used for audio capture
61+
#define AUDIOCAPTURE_BITRATE L"AudioCaptureBitRate" // amf_int64, 1024
62+
// Channel count used for audio capture
63+
#define AUDIOCAPTURE_CHANNELS L"AudioCaptureChannelCount" // amf_int64, 2
64+
// Format used for audio capture
65+
#define AUDIOCAPTURE_FORMAT L"AudioCaptureFormat" // amf_int64, AMFAF_U8
66+
// Block alignment
67+
#define AUDIOCAPTURE_BLOCKALIGN L"AudioCaptureBlockAlign" // amf_int64, AMFAF_U8
68+
// Audio frame size
69+
#define AUDIOCAPTURE_FRAMESIZE L"AudioCaptureFrameSize" // amf_int64, AMFAF_U8
70+
// Audio low latency state
71+
#define AUDIOCAPTURE_LOWLATENCY L"AudioCaptureLowLatency" // amf_int64;
72+
73+
// Optional interface that provides current time
74+
#define AUDIOCAPTURE_CURRENT_TIME_INTERFACE L"CurrentTimeInterface" // interface to current time object
75+
76+
extern "C"
77+
{
78+
// Component that allows the recording of inputs such as microphones or the audio that is being
79+
// rendered. The direction that is captured is controlled by the AUDIOCAPTURE_CAPTURE property
80+
//
81+
AMF_RESULT AMF_CDECL_CALL AMFCreateComponentAudioCapture(amf::AMFContext* pContext, amf::AMFComponent** ppComponent);
82+
}
83+
84+
#endif
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// Notice Regarding Standards. AMD does not provide a license or sublicense to
3+
// any Intellectual Property Rights relating to any standards, including but not
4+
// limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4;
5+
// AVC/H.264; HEVC/H.265; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3
6+
// (collectively, the "Media Technologies"). For clarity, you will pay any
7+
// royalties due for such third party technologies, which may include the Media
8+
// Technologies that are owed as a result of AMD providing the Software to you.
9+
//
10+
// MIT license
11+
//
12+
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
13+
//
14+
// Permission is hereby granted, free of charge, to any person obtaining a copy
15+
// of this software and associated documentation files (the "Software"), to deal
16+
// in the Software without restriction, including without limitation the rights
17+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
// copies of the Software, and to permit persons to whom the Software is
19+
// furnished to do so, subject to the following conditions:
20+
//
21+
// The above copyright notice and this permission notice shall be included in
22+
// all copies or substantial portions of the Software.
23+
//
24+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30+
// THE SOFTWARE.
31+
//
32+
33+
//-------------------------------------------------------------------------------------------------
34+
// Desktop duplication interface declaration
35+
//-------------------------------------------------------------------------------------------------
36+
37+
#ifndef __AMFDISPLAYCAPTURE__
38+
#define __AMFDISPLAYCAPTURE__
39+
#pragma once
40+
41+
#include "public/include/components/Component.h"
42+
43+
#define AMFDisplayCapture L"AMFDisplayCapture"
44+
45+
// Static properties
46+
//
47+
// Index of the display monitor
48+
// - Monitor index is determined by using EnumAdapters() in DX11.
49+
#define AMF_DISPLAYCAPTURE_MONITOR_INDEX L"InMonitorIndex" // amf_int64 (default = 0)
50+
// Capture frame rate
51+
#define AMF_DISPLAYCAPTURE_FRAMERATE L"InFrameRate" // amf_int64 (default = 60)
52+
// Optional interface object for getting current time.
53+
#define AMF_DISPLAYCAPTURE_CURRENT_TIME_INTERFACE L"CurrentTimeInterface"
54+
// Capture format
55+
#define AMF_DISPLAYCAPTURE_FORMAT L"CurrentFormat"
56+
57+
extern "C"
58+
{
59+
// Component that allows the desktop to be captured:
60+
// - DX11 only and the device must be created with IDXGIFactory1 or later support
61+
// - The monitor display must not be rotated. See DDAPISource.cpp
62+
// - Component will fail to initialize on Windows 7 as the Desktop Duplication API
63+
// is not supported
64+
//
65+
AMF_RESULT AMF_CDECL_CALL AMFCreateComponentDisplayCapture(amf::AMFContext* pContext, amf::AMFComponent** ppComponent);
66+
}
67+
#endif // #ifndef __AMFDISPLAYCAPTURE__

0 commit comments

Comments
 (0)