1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

removed deprecated ffmpeg functions

This commit is contained in:
jojo61 2019-01-04 11:27:54 +01:00
parent 8b16c0b490
commit 33a3316344
2 changed files with 66 additions and 19 deletions

79
codec.c
View File

@ -1347,9 +1347,32 @@ int myavcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
if (!frame)
return AVERROR(ENOMEM);
#if 0
ret = avcodec_decode_audio4(avctx, frame, &got_frame, avpkt);
#else
// SUGGESTION
// Now that avcodec_decode_audio4 is deprecated and replaced
// by 2 calls (receive frame and send packet), this could be optimized
// into separate routines or separate threads.
// Also now that it always consumes a whole buffer some code
// in the caller may be able to be optimized.
ret = avcodec_receive_frame(avctx,frame);
if (ret == 0)
got_frame = true;
if (ret == AVERROR(EAGAIN))
ret = 0;
if (ret == 0)
ret = avcodec_send_packet(avctx, avpkt);
if (ret == AVERROR(EAGAIN))
ret = 0;
else if (ret < 0)
{
Debug(3, "codec/audio: audio decode error: %1 (%2)\n",av_make_error_string(error, sizeof(error), ret),got_frame);
return ret;
}
else
ret = avpkt->size;
#endif
if (ret >= 0 && got_frame) {
int i,ch;
int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
@ -1674,7 +1697,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
AVFrame *frame;
#endif
int got_frame;
int n;
int n,ret;
audio_ctx = audio_decoder->AudioCtx;
@ -1689,22 +1712,46 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
#endif
got_frame = 0;
n = avcodec_decode_audio4(audio_ctx, frame, &got_frame,
(AVPacket *) avpkt);
#if 0
n = avcodec_decode_audio4(audio_ctx, frame, &got_frame, (AVPacket *) avpkt);
#else
// SUGGESTION
// Now that avcodec_decode_audio4 is deprecated and replaced
// by 2 calls (receive frame and send packet), this could be optimized
// into separate routines or separate threads.
// Also now that it always consumes a whole buffer some code
// in the caller may be able to be optimized.
ret = avcodec_receive_frame(audio_ctx,frame);
if (ret == 0)
got_frame = 1;
if (ret == AVERROR(EAGAIN))
ret = 0;
if (ret == 0)
ret = avcodec_send_packet(audio_ctx, avpkt);
if (ret == AVERROR(EAGAIN))
ret = 0;
else if (ret < 0)
{
// Debug(3, "codec/audio: audio decode error: %1 (%2)\n",av_make_error_string(error, sizeof(error), ret),got_frame);
return;
}
else
ret = avpkt->size;
n = ret; //FIXME: why n and not ret??
#endif
if (n != avpkt->size) {
if (n == AVERROR(EAGAIN)) {
Error(_("codec/audio: latm\n"));
return;
}
if (n < 0) { // no audio frame could be decompressed
Error(_("codec/audio: bad audio frame\n"));
return;
}
Error(_("codec/audio: error more than one frame data\n"));
if (n == AVERROR(EAGAIN)) {
Error(_("codec/audio: latm\n"));
return;
}
if (n < 0) { // no audio frame could be decompressed
Error(_("codec/audio: bad audio frame\n"));
return;
}
Error(_("codec/audio: error more than one frame data\n"));
}
if (!got_frame) {
Error(_("codec/audio: no frame\n"));
Error(_("codec/audio: no frame\n"));
return;
}
// update audio clock

View File

@ -1399,7 +1399,7 @@ static void VideoPacketExit(VideoStream * stream)
atomic_set(&stream->PacketsFilled, 0);
for (i = 0; i < VIDEO_PACKET_MAX; ++i) {
av_free_packet(&stream->PacketRb[i]);
av_packet_unref(&stream->PacketRb[i]);
}
}
@ -3159,7 +3159,7 @@ void SoftHdDeviceExit(void)
MyAudioDecoder = NULL;
}
NewAudioStream = 0;
av_free_packet(AudioAvPkt);
av_packet_unref(AudioAvPkt);
StopVideo();
@ -3353,7 +3353,7 @@ void Suspend(int video, int audio, int dox11)
MyAudioDecoder = NULL;
}
NewAudioStream = 0;
av_free_packet(AudioAvPkt);
av_packet_unref(AudioAvPkt);
}
if (video) {
StopVideo();