This commit is contained in:
JPikachu 2025-04-10 02:39:07 +02:00 committed by GitHub
commit 2571069eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 6 deletions

View file

@ -227,8 +227,10 @@ bool DecoderContext::SendPacket(const Packet& packet) {
#ifndef ANDROID
if (!m_codec_context->hw_device_ctx && m_codec_context->codec_id == AV_CODEC_ID_H264) {
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));
return false;
}
@ -250,6 +252,7 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() {
#ifndef ANDROID
if (!m_codec_context->hw_device_ctx && m_codec_context->codec_id == AV_CODEC_ID_H264) {
m_decode_order = true;
auto* codec{ffcodec(m_decoder.GetCodec())};
int ret{0};
if (m_got_frame == 0) {
@ -257,7 +260,7 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() {
auto* pkt = packet.GetPacket();
pkt->data = nullptr;
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;
}
@ -303,8 +306,12 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() {
}
#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
return std::move(m_temp_frame);
}

View file

@ -106,7 +106,11 @@ public:
}
bool IsInterlaced() const {
return m_frame->interlaced_frame != 0;
#if defined(FF_API_INTERLACED_FRAME) || LIBAVUTIL_VERSION_MAJOR >= 59
return m_frame->flags & AV_FRAME_FLAG_INTERLACED;
#else
return m_frame->interlaced_frame;
#endif
}
bool IsHardwareDecoded() const {