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:
parent
8b16c0b490
commit
33a3316344
79
codec.c
79
codec.c
@ -1347,9 +1347,32 @@ int myavcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
|
|||||||
|
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
#if 0
|
||||||
ret = avcodec_decode_audio4(avctx, frame, &got_frame, avpkt);
|
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) {
|
if (ret >= 0 && got_frame) {
|
||||||
int i,ch;
|
int i,ch;
|
||||||
int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
|
int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
|
||||||
@ -1674,7 +1697,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
#endif
|
#endif
|
||||||
int got_frame;
|
int got_frame;
|
||||||
int n;
|
int n,ret;
|
||||||
|
|
||||||
audio_ctx = audio_decoder->AudioCtx;
|
audio_ctx = audio_decoder->AudioCtx;
|
||||||
|
|
||||||
@ -1689,22 +1712,46 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
got_frame = 0;
|
got_frame = 0;
|
||||||
n = avcodec_decode_audio4(audio_ctx, frame, &got_frame,
|
#if 0
|
||||||
(AVPacket *) avpkt);
|
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 != avpkt->size) {
|
||||||
if (n == AVERROR(EAGAIN)) {
|
if (n == AVERROR(EAGAIN)) {
|
||||||
Error(_("codec/audio: latm\n"));
|
Error(_("codec/audio: latm\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (n < 0) { // no audio frame could be decompressed
|
if (n < 0) { // no audio frame could be decompressed
|
||||||
Error(_("codec/audio: bad audio frame\n"));
|
Error(_("codec/audio: bad audio frame\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Error(_("codec/audio: error more than one frame data\n"));
|
Error(_("codec/audio: error more than one frame data\n"));
|
||||||
}
|
}
|
||||||
if (!got_frame) {
|
if (!got_frame) {
|
||||||
Error(_("codec/audio: no frame\n"));
|
Error(_("codec/audio: no frame\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// update audio clock
|
// update audio clock
|
||||||
|
@ -1399,7 +1399,7 @@ static void VideoPacketExit(VideoStream * stream)
|
|||||||
atomic_set(&stream->PacketsFilled, 0);
|
atomic_set(&stream->PacketsFilled, 0);
|
||||||
|
|
||||||
for (i = 0; i < VIDEO_PACKET_MAX; ++i) {
|
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;
|
MyAudioDecoder = NULL;
|
||||||
}
|
}
|
||||||
NewAudioStream = 0;
|
NewAudioStream = 0;
|
||||||
av_free_packet(AudioAvPkt);
|
av_packet_unref(AudioAvPkt);
|
||||||
|
|
||||||
StopVideo();
|
StopVideo();
|
||||||
|
|
||||||
@ -3353,7 +3353,7 @@ void Suspend(int video, int audio, int dox11)
|
|||||||
MyAudioDecoder = NULL;
|
MyAudioDecoder = NULL;
|
||||||
}
|
}
|
||||||
NewAudioStream = 0;
|
NewAudioStream = 0;
|
||||||
av_free_packet(AudioAvPkt);
|
av_packet_unref(AudioAvPkt);
|
||||||
}
|
}
|
||||||
if (video) {
|
if (video) {
|
||||||
StopVideo();
|
StopVideo();
|
||||||
|
Loading…
Reference in New Issue
Block a user