[codec,h264] ignore EAGAIN for FFMPEG

This commit is contained in:
akallabeth
2025-01-28 20:25:17 +01:00
committed by Armin Novak
parent 6c812548b2
commit 726add2a98
2 changed files with 20 additions and 14 deletions

View File

@@ -398,10 +398,9 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI
len = avcodec_send_packet(mdecoder->codec_context, &pkt);
if (len > 0)
{
do
{
len = avcodec_receive_frame(mdecoder->codec_context, mdecoder->frame);
} while (len == AVERROR(EAGAIN));
len = avcodec_receive_frame(mdecoder->codec_context, mdecoder->frame);
if (len == AVERROR(EAGAIN))
return TRUE;
}
#endif
}
@@ -541,10 +540,9 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
len = avcodec_send_packet(mdecoder->codec_context, &pkt);
if (len > 0)
{
do
{
len = avcodec_receive_frame(mdecoder->codec_context, decoded_frame);
} while (len == AVERROR(EAGAIN));
len = avcodec_receive_frame(mdecoder->codec_context, decoded_frame);
if (len == AVERROR(EAGAIN))
return TRUE;
}
#endif
@@ -677,11 +675,17 @@ static void tsmf_ffmpeg_free(ITSMFDecoder* decoder)
if (mdecoder->codec_context)
{
free(mdecoder->codec_context->extradata);
mdecoder->codec_context->extradata = NULL;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 69, 100)
avcodec_free_context(&mdecoder->codec_context);
#else
if (mdecoder->prepared)
avcodec_close(mdecoder->codec_context);
free(mdecoder->codec_context->extradata);
av_free(mdecoder->codec_context);
#endif
}
free(decoder);

View File

@@ -102,10 +102,10 @@ static void libavcodec_destroy_encoder_context(H264_CONTEXT* WINPR_RESTRICT h264
if (sys->codecEncoderContext)
{
avcodec_close(sys->codecEncoderContext);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 69, 100)
avcodec_free_context(&sys->codecEncoderContext);
#else
avcodec_close(sys->codecEncoderContext);
av_free(sys->codecEncoderContext);
#endif
}
@@ -293,15 +293,17 @@ static int libavcodec_decompress(H264_CONTEXT* WINPR_RESTRICT h264,
sys->videoFrame->format = AV_PIX_FMT_YUV420P;
do
{
#ifdef WITH_VAAPI
status = avcodec_receive_frame(sys->codecDecoderContext,
sys->hwctx ? sys->hwVideoFrame : sys->videoFrame);
#else
status = avcodec_receive_frame(sys->codecDecoderContext, sys->videoFrame);
#endif
} while (status == AVERROR(EAGAIN));
if (status == AVERROR(EAGAIN))
{
rc = 0;
goto fail;
}
gotFrame = (status == 0);
#else
@@ -594,10 +596,10 @@ static void libavcodec_uninit(H264_CONTEXT* h264)
if (sys->codecDecoderContext)
{
avcodec_close(sys->codecDecoderContext);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 69, 100)
avcodec_free_context(&sys->codecDecoderContext);
#else
avcodec_close(sys->codecDecoderContext);
av_free(sys->codecDecoderContext);
#endif
}