cellVdec: replace deprecated ffmpeg function

avcodec_decode_video2() is deprecated, now replaced with
avcodec_send_packet() and avcodec_receive_frame().
This commit is contained in:
Emmanuel Gil Peyrot 2019-10-25 17:19:12 +02:00 committed by Nekotekina
parent f1241c572c
commit 1a702de9e4

View file

@ -260,37 +260,38 @@ struct vdec_context final
break; break;
} }
vdec_frame frame; if (int ret = avcodec_send_packet(ctx, &packet); ret < 0)
frame.avf.reset(av_frame_alloc());
if (!frame.avf)
{
fmt::throw_exception("av_frame_alloc() failed" HERE);
}
int got_picture = 0;
int decode = avcodec_decode_video2(ctx, frame.avf.get(), &got_picture, &packet);
if (decode < 0)
{ {
char av_error[AV_ERROR_MAX_STRING_SIZE]; char av_error[AV_ERROR_MAX_STRING_SIZE];
av_make_error_string(av_error, AV_ERROR_MAX_STRING_SIZE, decode); av_make_error_string(av_error, AV_ERROR_MAX_STRING_SIZE, ret);
fmt::throw_exception("AU decoding error(0x%x): %s" HERE, decode, av_error); fmt::throw_exception("AU queuing error(0x%x): %s" HERE, ret, av_error);
} }
if (got_picture == 0) while (true)
{ {
break; // Keep receiving frames
} vdec_frame frame;
frame.avf.reset(av_frame_alloc());
if (decode != packet.size) if (!frame.avf)
{ {
cellVdec.error("Incorrect AU size (0x%x, decoded 0x%x)", packet.size, decode); fmt::throw_exception("av_frame_alloc() failed" HERE);
} }
if (int ret = avcodec_receive_frame(ctx, frame.avf.get()); ret < 0)
{
if (ret == AVERROR(EAGAIN))
{
break;
}
else
{
char av_error[AV_ERROR_MAX_STRING_SIZE];
av_make_error_string(av_error, AV_ERROR_MAX_STRING_SIZE, ret);
fmt::throw_exception("AU decoding error(0x%x): %s" HERE, ret, av_error);
}
}
if (got_picture)
{
if (frame->interlaced_frame) if (frame->interlaced_frame)
{ {
// NPEB01838, NPUB31260 // NPEB01838, NPUB31260