|
|
@ -227,8 +227,10 @@ bool DecoderContext::SendPacket(const Packet& packet) { |
|
|
#ifndef ANDROID
|
|
|
#ifndef ANDROID
|
|
|
if (!m_codec_context->hw_device_ctx && m_codec_context->codec_id == AV_CODEC_ID_H264) { |
|
|
if (!m_codec_context->hw_device_ctx && m_codec_context->codec_id == AV_CODEC_ID_H264) { |
|
|
m_decode_order = true; |
|
|
m_decode_order = true; |
|
|
const int ret = avcodec_send_frame(m_codec_context, m_temp_frame->GetFrame()); |
|
|
|
|
|
if (ret < 0) { |
|
|
|
|
|
|
|
|
auto* codec{ffcodec(m_decoder.GetCodec())}; |
|
|
|
|
|
if (const int ret = codec->cb.decode(m_codec_context, m_temp_frame->GetFrame(), |
|
|
|
|
|
&m_got_frame, packet.GetPacket()); |
|
|
|
|
|
ret < 0) { |
|
|
LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", AVError(ret)); |
|
|
LOG_DEBUG(Service_NVDRV, "avcodec_send_packet error {}", AVError(ret)); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
@ -250,6 +252,7 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() { |
|
|
#ifndef ANDROID
|
|
|
#ifndef ANDROID
|
|
|
if (!m_codec_context->hw_device_ctx && m_codec_context->codec_id == AV_CODEC_ID_H264) { |
|
|
if (!m_codec_context->hw_device_ctx && m_codec_context->codec_id == AV_CODEC_ID_H264) { |
|
|
m_decode_order = true; |
|
|
m_decode_order = true; |
|
|
|
|
|
auto* codec{ffcodec(m_decoder.GetCodec())}; |
|
|
int ret{0}; |
|
|
int ret{0}; |
|
|
|
|
|
|
|
|
if (m_got_frame == 0) { |
|
|
if (m_got_frame == 0) { |
|
|
@ -257,7 +260,7 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() { |
|
|
auto* pkt = packet.GetPacket(); |
|
|
auto* pkt = packet.GetPacket(); |
|
|
pkt->data = nullptr; |
|
|
pkt->data = nullptr; |
|
|
pkt->size = 0; |
|
|
pkt->size = 0; |
|
|
ret = avcodec_receive_packet(m_codec_context, pkt); |
|
|
|
|
|
|
|
|
ret = codec->cb.decode(m_codec_context, m_temp_frame->GetFrame(), &m_got_frame, pkt); |
|
|
m_codec_context->has_b_frames = 0; |
|
|
m_codec_context->has_b_frames = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -303,8 +306,12 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if defined(FF_API_INTERLACED_FRAME) || LIBAVUTIL_VERSION_MAJOR >= 59
|
|
|
#if defined(FF_API_INTERLACED_FRAME) || LIBAVUTIL_VERSION_MAJOR >= 59
|
|
|
m_temp_frame->GetFrame()->interlaced_frame = |
|
|
|
|
|
(m_temp_frame->GetFrame()->flags & AV_FRAME_FLAG_INTERLACED) != 0; |
|
|
|
|
|
|
|
|
if (m_temp_frame->GetFrame()->flags & AV_FRAME_FLAG_INTERLACED) |
|
|
|
|
|
m_temp_frame->GetFrame()->flags &= ~AV_FRAME_FLAG_INTERLACED; |
|
|
|
|
|
else |
|
|
|
|
|
m_temp_frame->GetFrame()->flags |= AV_FRAME_FLAG_INTERLACED; |
|
|
|
|
|
#else
|
|
|
|
|
|
m_temp_frame->GetFrame()->interlaced_frame = !m_temp_frame->GetFrame()->interlaced_frame; |
|
|
#endif
|
|
|
#endif
|
|
|
return std::move(m_temp_frame); |
|
|
return std::move(m_temp_frame); |
|
|
} |
|
|
} |
|
|
|