[FFmpeg-devel] [PATCH 15/35] lavc/cuviddec: convert to the new FIFO API
Anton Khirnov
anton at khirnov.net
Tue Jan 11 22:45:50 EET 2022
---
libavcodec/cuviddec.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index b1a3d674ab..5121fdb6a4 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -363,13 +363,13 @@ static int CUDAAPI cuvid_handle_picture_display(void *opaque, CUVIDPARSERDISPINF
parsed_frame.dispinfo.progressive_frame = ctx->progressive_sequence;
if (ctx->deint_mode_current == cudaVideoDeinterlaceMode_Weave) {
- av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
+ av_fifo_write(ctx->frame_queue, &parsed_frame, 1);
} else {
parsed_frame.is_deinterlacing = 1;
- av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
+ av_fifo_write(ctx->frame_queue, &parsed_frame, 1);
if (!ctx->drop_second_field) {
parsed_frame.second_field = 1;
- av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
+ av_fifo_write(ctx->frame_queue, &parsed_frame, 1);
}
}
@@ -384,7 +384,7 @@ static int cuvid_is_buffer_full(AVCodecContext *avctx)
if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave && !ctx->drop_second_field)
delay *= 2;
- return (av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + delay >= ctx->nb_surfaces;
+ return av_fifo_can_read(ctx->frame_queue) + delay >= ctx->nb_surfaces;
}
static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)
@@ -487,7 +487,7 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
if (ret < 0)
return ret;
- if (av_fifo_size(ctx->frame_queue)) {
+ if (av_fifo_can_read(ctx->frame_queue)) {
const AVPixFmtDescriptor *pixdesc;
CuvidParsedFrame parsed_frame;
CUVIDPROCPARAMS params;
@@ -495,7 +495,7 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
int offset = 0;
int i;
- av_fifo_generic_read(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
+ av_fifo_read(ctx->frame_queue, &parsed_frame, 1);
memset(¶ms, 0, sizeof(params));
params.progressive_frame = parsed_frame.dispinfo.progressive_frame;
@@ -834,7 +834,7 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
goto error;
}
- ctx->frame_queue = av_fifo_alloc(ctx->nb_surfaces * sizeof(CuvidParsedFrame));
+ ctx->frame_queue = av_fifo_alloc2(ctx->nb_surfaces, sizeof(CuvidParsedFrame), 0);
if (!ctx->frame_queue) {
ret = AVERROR(ENOMEM);
goto error;
--
2.33.0
More information about the ffmpeg-devel
mailing list