Commit 0dfbe2c2 authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Adrien Béraud

accel: fix hardware acceleration init for encoders

Change-Id: I89bc1c2f4012f84b86e5a12ee03dc40513a4f7a6
parent 60369a23
...@@ -379,7 +379,7 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number) ...@@ -379,7 +379,7 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number)
frame = input.pointer(); frame = input.pointer();
} }
} else { } else {
#else #elif !defined(__APPLE__)
std::unique_ptr<VideoFrame> framePtr; std::unique_ptr<VideoFrame> framePtr;
if (accel_ && accel_->isLinked() && isHardware) { if (accel_ && accel_->isLinked() && isHardware) {
// Fully accelerated pipeline, skip main memory // Fully accelerated pipeline, skip main memory
...@@ -409,6 +409,8 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number) ...@@ -409,6 +409,8 @@ MediaEncoder::encode(VideoFrame& input, bool is_keyframe, int64_t frame_number)
} }
frame = framePtr->pointer(); frame = framePtr->pointer();
} else { } else {
#else
{
#endif // defined(TARGET_OS_IOS) && TARGET_OS_IOS #endif // defined(TARGET_OS_IOS) && TARGET_OS_IOS
#endif #endif
libav_utils::fillWithBlack(scaledFrame_.pointer()); libav_utils::fillWithBlack(scaledFrame_.pointer());
...@@ -593,11 +595,14 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video) ...@@ -593,11 +595,14 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video)
// emit one intra frame every gop_size frames // emit one intra frame every gop_size frames
encoderCtx->max_b_frames = 0; encoderCtx->max_b_frames = 0;
encoderCtx->pix_fmt = AV_PIX_FMT_YUV420P; encoderCtx->pix_fmt = AV_PIX_FMT_YUV420P;
// Keep YUV format for macOS
#ifdef RING_ACCEL #ifdef RING_ACCEL
// Keep YUV format for macOS #if defined(TARGET_OS_IOS) && TARGET_OS_IOS
#if !(defined(__APPLE__) && !TARGET_OS_IOS)
if (accel_) if (accel_)
encoderCtx->pix_fmt = accel_->getSoftwareFormat(); encoderCtx->pix_fmt = accel_->getSoftwareFormat();
#elif !defined(__APPLE__)
if (accel_)
encoderCtx->pix_fmt = accel_->getFormat();
#endif #endif
#endif #endif
......
...@@ -51,14 +51,14 @@ static std::list<HardwareAPI> apiListDec = { ...@@ -51,14 +51,14 @@ static std::list<HardwareAPI> apiListDec = {
{AV_CODEC_ID_H264, AV_CODEC_ID_HEVC, AV_CODEC_ID_VP8, AV_CODEC_ID_MJPEG}, {AV_CODEC_ID_H264, AV_CODEC_ID_HEVC, AV_CODEC_ID_VP8, AV_CODEC_ID_MJPEG},
{{"default", DeviceState::NOT_TESTED}, {"1", DeviceState::NOT_TESTED}, {"2", DeviceState::NOT_TESTED}}, {{"default", DeviceState::NOT_TESTED}, {"1", DeviceState::NOT_TESTED}, {"2", DeviceState::NOT_TESTED}},
false}, false},
// {"vaapi", {"vaapi",
// AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_VAAPI,
// AV_PIX_FMT_VAAPI, AV_PIX_FMT_VAAPI,
// AV_PIX_FMT_NV12, AV_PIX_FMT_NV12,
// {AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4, AV_CODEC_ID_VP8}, {AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4, AV_CODEC_ID_VP8},
// {{"default", DeviceState::NOT_TESTED}, {"/dev/dri/renderD128", DeviceState::NOT_TESTED}, {{"default", DeviceState::NOT_TESTED}, {"/dev/dri/renderD128", DeviceState::NOT_TESTED},
// {"/dev/dri/renderD129", DeviceState::NOT_TESTED}, {":0", DeviceState::NOT_TESTED}}, {"/dev/dri/renderD129", DeviceState::NOT_TESTED}, {":0", DeviceState::NOT_TESTED}},
// false}, false},
{"vdpau", {"vdpau",
AV_HWDEVICE_TYPE_VDPAU, AV_HWDEVICE_TYPE_VDPAU,
AV_PIX_FMT_VDPAU, AV_PIX_FMT_VDPAU,
...@@ -90,15 +90,15 @@ static std::list<HardwareAPI> apiListEnc = { ...@@ -90,15 +90,15 @@ static std::list<HardwareAPI> apiListEnc = {
{AV_CODEC_ID_H264, AV_CODEC_ID_HEVC}, {AV_CODEC_ID_H264, AV_CODEC_ID_HEVC},
{{"default", DeviceState::NOT_TESTED}, {"1", DeviceState::NOT_TESTED}, {"2", DeviceState::NOT_TESTED}}, {{"default", DeviceState::NOT_TESTED}, {"1", DeviceState::NOT_TESTED}, {"2", DeviceState::NOT_TESTED}},
true}, true},
// {"vaapi", {"vaapi",
// AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_VAAPI,
// AV_PIX_FMT_VAAPI, AV_PIX_FMT_VAAPI,
// AV_PIX_FMT_NV12, AV_PIX_FMT_NV12,
// {AV_CODEC_ID_H264, AV_CODEC_ID_HEVC, AV_CODEC_ID_VP8}, {AV_CODEC_ID_H264, AV_CODEC_ID_HEVC, AV_CODEC_ID_VP8},
// {{"default", DeviceState::NOT_TESTED}, {"/dev/dri/renderD128", DeviceState::NOT_TESTED}, {{"default", DeviceState::NOT_TESTED}, {"/dev/dri/renderD128", DeviceState::NOT_TESTED},
// {"/dev/dri/renderD129", DeviceState::NOT_TESTED}, {"/dev/dri/renderD129", DeviceState::NOT_TESTED},
// {":0", DeviceState::NOT_TESTED}}, {":0", DeviceState::NOT_TESTED}},
// false}, false},
{"videotoolbox", {"videotoolbox",
AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
AV_PIX_FMT_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment