Skip to content

Commit 21db85e

Browse files
committed
キーフレーム生成を共通ではなくコーデック別に変更する
1 parent 77be93f commit 21db85e

1 file changed

Lines changed: 34 additions & 10 deletions

File tree

src/hwenc_amf/amf_video_encoder.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,40 @@ int32_t AMFVideoEncoderImpl::Encode(
297297
}
298298

299299
if (send_key_frame) {
300-
res = surface_->SetProperty(AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE,
301-
AMF_VIDEO_ENCODER_PICTURE_TYPE_IDR);
302-
RETURN_IF_FAILED(
303-
res, "Failed to SetProperty(AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE)");
304-
res = surface_->SetProperty(AMF_VIDEO_ENCODER_INSERT_SPS, true);
305-
RETURN_IF_FAILED(res,
306-
"Failed to SetProperty(AMF_VIDEO_ENCODER_INSERT_SPS)");
307-
res = surface_->SetProperty(AMF_VIDEO_ENCODER_INSERT_PPS, true);
308-
RETURN_IF_FAILED(res,
309-
"Failed to SetProperty(AMF_VIDEO_ENCODER_INSERT_PPS)");
300+
switch (codec_) {
301+
case webrtc::VideoCodecType::kVideoCodecH264:
302+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE,
303+
AMF_VIDEO_ENCODER_PICTURE_TYPE_IDR);
304+
RETURN_IF_FAILED(
305+
res, "Failed to SetProperty(AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE)");
306+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_INSERT_SPS, true);
307+
RETURN_IF_FAILED(res,
308+
"Failed to SetProperty(AMF_VIDEO_ENCODER_INSERT_SPS)");
309+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_INSERT_PPS, true);
310+
RETURN_IF_FAILED(res,
311+
"Failed to SetProperty(AMF_VIDEO_ENCODER_INSERT_PPS)");
312+
break;
313+
case webrtc::VideoCodecType::kVideoCodecH265:
314+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE,
315+
AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_IDR);
316+
RETURN_IF_FAILED(
317+
res, "Failed to SetProperty(AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE)");
318+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_HEVC_INSERT_HEADER, true);
319+
RETURN_IF_FAILED(res,
320+
"Failed to SetProperty(AMF_VIDEO_ENCODER_HEVC_INSERT_HEADER)");
321+
break;
322+
case webrtc::VideoCodecType::kVideoCodecAV1:
323+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_AV1_FORCE_FRAME_TYPE,
324+
AMF_VIDEO_ENCODER_AV1_FORCE_FRAME_TYPE_KEY);
325+
RETURN_IF_FAILED(
326+
res, "Failed to SetProperty(AMF_VIDEO_ENCODER_AV1_FORCE_FRAME_TYPE)");
327+
res = surface_->SetProperty(AMF_VIDEO_ENCODER_AV1_FORCE_INSERT_SEQUENCE_HEADER, true);
328+
RETURN_IF_FAILED(res,
329+
"Failed to SetProperty(AMF_VIDEO_ENCODER_AV1_FORCE_INSERT_SEQUENCE_HEADER)");
330+
break;
331+
default:
332+
break;
333+
}
310334
}
311335

312336
res = encoder_->SubmitInput(surface_);

0 commit comments

Comments
 (0)