From 8de3458a07376b0a96772e586b6dba5e93432f52 Mon Sep 17 00:00:00 2001 From: Ben Chang Date: Tue, 25 Apr 2017 14:57:56 -0700 Subject: avcodec/nvenc: surface allocation reduction This patch aims to reduce the number of input/output surfaces NVENC allocates per session. Previous default sets allocated surfaces to 32 (unless there is user specified param or lookahead involved). Having large number of surfaces consumes extra video memory (esp for higher resolution encoding). The patch changes the surfaces calculation for default, B-frames, lookahead scenario respectively. The other change involves surface selection. Previously, if a session allocates x surfaces, only x-1 surfaces are used (due to combination of output delay and lock toggle logic). To prevent unused surfaces, changing surface rotation to using predefined fifo. Signed-off-by: Timo Rothenpieler --- libavcodec/nvenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec/nvenc.h') diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 7dec5cc685..763647b283 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -44,7 +44,6 @@ typedef struct NvencSurface NV_ENC_OUTPUT_PTR output_surface; NV_ENC_BUFFER_FORMAT format; int size; - int lockCount; } NvencSurface; typedef struct NvencDynLoadFunctions @@ -110,6 +109,7 @@ typedef struct NvencContext int nb_surfaces; NvencSurface *surfaces; + AVFifoBuffer *unused_surface_queue; AVFifoBuffer *output_surface_queue; AVFifoBuffer *output_surface_ready_queue; AVFifoBuffer *timestamp_list; -- cgit v1.2.1