Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 2f0d54c

Browse files
author
Michael Fabian Dirks
committed
Add translation strings, reduce CPU usage during difficult scenes, reorder property settings (should apply correct Framesize and Framerate), copy line by line instead of full buffers.
1 parent ccfccda commit 2f0d54c

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

win-amf/Resources/locale/en-US.ini

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,24 @@ AMF.h264.LEVEL.41="4.1"
3636
AMF.h264.LEVEL.42="4.2"
3737
AMF.h264.LEVEL.50="5.0"
3838
AMF.h264.LEVEL.51="5.1"
39-
AMF.h264.LEVEL.52="5.2 (Experimental)"
39+
AMF.h264.LEVEL.52="5.2 (Experimental)"
40+
AMF.h264.RATE_CONTROL="Rate Control Method"
41+
AMF.h264.RATE_CONTROL.DEFAULT="<From Preset & Usage>"
42+
AMF.h264.RATE_CONTROL.CONSTRAINEDQP="Constrained QP"
43+
AMF.h264.RATE_CONTROL.CBR="Constant Bitrate"
44+
AMF.h264.RATE_CONTROL.PEAK_CONSTRAINED_VBR="VBR (Peak Constrained)"
45+
AMF.h264.RATE_CONTROL.LATENCY_CONSTRAINED_VBR="VBR (Latency Constrained)"
46+
AMF.h264.SKIP_FRAME="Frame Skipping"
47+
AMF.h264.SKIP_FRAME.DEFAULT="<From Preset & Usage>"
48+
AMF.h264.SKIP_FRAME.DISABLE="Disable"
49+
AMF.h264.SKIP_FRAME.ENABLE="Enable"
50+
AMF.h264.BITRATE.TARGET="Target Bitrate"
51+
AMF.h264.BITRATE.PEAK="Peak Bitrate"
52+
AMF.h264.VBV_BUFFER_SIZE="VBV Buffer Size"
53+
AMF.h264.QP.MIN="Minimum QP"
54+
AMF.h264.QP.MAX="Maximum QP"
55+
AMF.h264.QP.I="I-Frame QP"
56+
AMF.h264.QP.P="P-Frame QP"
57+
AMF.h264.QP.B="B-Frame QP"
58+
AMF.h264.FILLER_DATA="Enable Filler Data"
59+
AMF.h264.GOP_SIZE="GOP Size"

win-amf/Source/amf-h264.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ AMF_Encoder::h264::h264(obs_data_t* settings, obs_encoder_t* encoder) {
129129
}
130130

131131
// Pre Initialization
132+
///Quality Preset & Usage
133+
res = amf_encoder->SetProperty(AMF_VIDEO_ENCODER_QUALITY_PRESET, obs_data_get_int(settings, "AMF_VIDEO_ENCODER_QUALITY_PRESET"));
134+
res = amf_encoder->SetProperty(AMF_VIDEO_ENCODER_USAGE, obs_data_get_int(settings, "AMF_VIDEO_ENCODER_USAGE_ENUM"));
135+
132136
///Framesize & Framerate
133137
res = amf_encoder->SetProperty(AMF_VIDEO_ENCODER_FRAMESIZE, ::AMFConstructSize(s_Width, s_Height)); // Take from OBS
134138
AMF_LOG_INFO("Create: AMF_VIDEO_ENCODER_FRAMESIZE = %dx%d", s_Width, s_Height);
@@ -138,10 +142,6 @@ AMF_Encoder::h264::h264(obs_data_t* settings, obs_encoder_t* encoder) {
138142
AMF_LOG_INFO("Create: AMF_VIDEO_ENCODER_FRAMERATE = %d/%d", s_FPS_num, s_FPS_den);
139143
if (res != AMF_OK) AMF_LOG_ERROR("Create: AMF_VIDEO_ENCODER_FRAMERATE, error code %d: %s.", res, amf::AMFGetResultText(res));
140144

141-
///Quality Preset & Usage
142-
res = amf_encoder->SetProperty(AMF_VIDEO_ENCODER_QUALITY_PRESET, obs_data_get_int(settings, "AMF_VIDEO_ENCODER_QUALITY_PRESET"));
143-
res = amf_encoder->SetProperty(AMF_VIDEO_ENCODER_USAGE, obs_data_get_int(settings, "AMF_VIDEO_ENCODER_USAGE_ENUM"));
144-
145145
///Profile & Profile Level
146146
int64_t t_profile = obs_data_get_int(settings, "AMF_VIDEO_ENCODER_PROFILE_ENUM");
147147
if (t_profile != -1)
@@ -250,9 +250,23 @@ void AMF_Encoder::h264::queue_frame(encoder_frame* frame) {
250250
for (uint8_t i = 0; i < iMax; i++) {
251251
amf::AMFPlane* plane = surfaceIn->GetPlaneAt(i);
252252
void* plane_nat = plane->GetNative();
253-
253+
254+
/*AMF_LOG_INFO("Plane Information for %d", i);
255+
AMF_LOG_INFO("Size: %d, %d", plane->GetWidth(), plane->GetHeight());
256+
AMF_LOG_INFO("Offset: %d, %d", plane->GetOffsetX(), plane->GetOffsetY());
257+
AMF_LOG_INFO("Pitch: %d, %d", plane->GetHPitch(), plane->GetVPitch());
258+
AMF_LOG_INFO("PixelSize: %d", plane->GetPixelSizeInBytes());*/
259+
260+
for (uint32_t py = 0; py < plane->GetHeight(); py++) {
261+
size_t plane_off = py * plane->GetHPitch();
262+
size_t frame_off = py * frame->linesize[i];
263+
264+
//AMF_LOG_INFO("Line: %d, %d, %d", py, plane_off, frame_off);
265+
std::memcpy(static_cast<void*>(static_cast<uint8_t*>(plane_nat) + plane_off), static_cast<void*>(frame->data[i] + frame_off), frame->linesize[i]);
266+
}
267+
254268
// Copy to target buffer. Strangely distorted, perhaps not the right way?
255-
std::memcpy(plane_nat, frame->data[i], plane->GetVPitch() * plane->GetHeight());
269+
// std::memcpy(plane_nat, frame->data[i], plane->GetVPitch() * plane->GetHeight());
256270
// else
257271
// std::memcpy(plane_nat, frame->data[i], plane->GetVPitch() * plane->GetHeight());
258272
}
@@ -389,7 +403,7 @@ bool AMF_Encoder::h264::encode(struct encoder_frame * frame, struct encoder_pack
389403

390404
// Output
391405
dequeue_frame(packet, received_packet);
392-
406+
393407
return true;
394408
}
395409

win-amf/win-amf.vcxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,30 @@
7171
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
7272
<IncludePath>$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\components;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\core;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc;$(SolutionDir)#ThirdParty;$(ProjectDir)Include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
7373
<SourcePath>$(ProjectDir)Source;$(VC_SourcePath)</SourcePath>
74-
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build\libobs\RelWithDebInfo\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86_64\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
75-
<OutDir>$(ProjectDir)\#Build\$(Platform)-$(Configuration)\obs-plugins\64bit\</OutDir>
76-
<IntDir>$(ProjectDir)\#Intermediate\$(Platform)-$(Configuration)\</IntDir>
74+
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build64\libobs\$(Configuration)\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86_64\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
75+
<OutDir>$(ProjectDir)\#Build\$(PlatformShortName)-$(Configuration)\obs-plugins\64bit\</OutDir>
76+
<IntDir>$(ProjectDir)\#Intermediate\$(PlatformShortName)-$(Configuration)\</IntDir>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7979
<IncludePath>$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\components;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\core;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc;$(SolutionDir)#ThirdParty;$(ProjectDir)Include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
8080
<SourcePath>$(ProjectDir)Source;$(VC_SourcePath)</SourcePath>
81-
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build\libobs\RelWithDebInfo\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86_64\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
82-
<OutDir>$(ProjectDir)\#Build\$(Platform)-$(Configuration)\obs-plugins\64bit\</OutDir>
83-
<IntDir>$(ProjectDir)\#Intermediate\$(Platform)-$(Configuration)\</IntDir>
81+
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build64\libobs\$(Configuration)\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86_64\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
82+
<OutDir>$(ProjectDir)\#Build\$(PlatformShortName)-$(Configuration)\obs-plugins\64bit\</OutDir>
83+
<IntDir>$(ProjectDir)\#Intermediate\$(PlatformShortName)-$(Configuration)\</IntDir>
8484
</PropertyGroup>
8585
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8686
<IncludePath>$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\components;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\core;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc;$(SolutionDir)#ThirdParty;$(ProjectDir)Include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
8787
<SourcePath>$(ProjectDir)Source;$(VC_SourcePath)</SourcePath>
88-
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build\libobs\RelWithDebInfo\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
89-
<OutDir>$(ProjectDir)\#Build\$(Platform)-$(Configuration)\obs-plugins\32bit\</OutDir>
90-
<IntDir>$(ProjectDir)\#Intermediate\$(Platform)-$(Configuration)\</IntDir>
88+
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build32\libobs\$(Configuration)\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
89+
<OutDir>$(ProjectDir)\#Build\$(PlatformShortName)-$(Configuration)\obs-plugins\32bit\</OutDir>
90+
<IntDir>$(ProjectDir)\#Intermediate\$(PlatformShortName)-$(Configuration)\</IntDir>
9191
</PropertyGroup>
9292
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
9393
<IncludePath>$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\components;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf\core;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc\amf;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\inc;$(SolutionDir)#ThirdParty;$(ProjectDir)Include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
9494
<SourcePath>$(ProjectDir)Source;$(VC_SourcePath)</SourcePath>
95-
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build\libobs\RelWithDebInfo\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
96-
<OutDir>$(ProjectDir)\#Build\$(Platform)-$(Configuration)\obs-plugins\32bit\</OutDir>
97-
<IntDir>$(ProjectDir)\#Intermediate\$(Platform)-$(Configuration)\</IntDir>
95+
<LibraryPath>$(SolutionDir)#ThirdParty\OBS-Studio\build32\libobs\$(Configuration)\;$(SolutionDir)#ThirdParty\AMD-Media-SDK\1.1\lib\amf\x86\$(Configuration)\vs12;$(LibraryPath)</LibraryPath>
96+
<OutDir>$(ProjectDir)\#Build\$(PlatformShortName)-$(Configuration)\obs-plugins\32bit\</OutDir>
97+
<IntDir>$(ProjectDir)\#Intermediate\$(PlatformShortName)-$(Configuration)\</IntDir>
9898
</PropertyGroup>
9999
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
100100
<ClCompile>

0 commit comments

Comments
 (0)