@@ -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
0 commit comments