]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/nvenc.h
lavc: document that avcodec_close() should not be used
[ffmpeg] / libavcodec / nvenc.h
index a0020377e6a436dcc33b3db18292b7da25b6271f..e7e6182196d4ed49554ac1af108f35933346b1eb 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef AVCODEC_NVENC_H
 #define AVCODEC_NVENC_H
 
-#include <cuda.h>
 #include <nvEncodeAPI.h>
 
 #include "config.h"
 
 #include "avcodec.h"
 
+#if CONFIG_CUDA
+#include <cuda.h>
+#else
+
+#if defined(_WIN32)
+#define CUDAAPI __stdcall
+#else
+#define CUDAAPI
+#endif
+
+typedef enum cudaError_enum {
+    CUDA_SUCCESS = 0
+} CUresult;
+typedef int CUdevice;
+typedef void* CUcontext;
+typedef void* CUdeviceptr;
+#endif
+
+#define MAX_REGISTERED_FRAMES 64
+
 typedef struct NVENCFrame {
     NV_ENC_INPUT_PTR  in;
+    AVFrame          *in_ref;
+    NV_ENC_MAP_INPUT_RESOURCE in_map;
+    int reg_idx;
+
     NV_ENC_OUTPUT_PTR out;
     NV_ENC_BUFFER_FORMAT format;
     int locked;
@@ -104,14 +127,26 @@ typedef struct NVENCContext {
     NV_ENC_CONFIG config;
 
     CUcontext cu_context;
+    CUcontext cu_context_internal;
 
     int nb_surfaces;
     NVENCFrame *frames;
     AVFifoBuffer *timestamps;
     AVFifoBuffer *pending, *ready;
 
+    struct {
+        CUdeviceptr ptr;
+        NV_ENC_REGISTERED_PTR regptr;
+        int mapped;
+    } registered_frames[MAX_REGISTERED_FRAMES];
+    int nb_registered_frames;
+
+    /* the actual data pixel format, different from
+     * AVCodecContext.pix_fmt when using hwaccel frames on input */
+    enum AVPixelFormat data_pix_fmt;
+
     /* timestamps of the first two frames, for computing the first dts
-     * when b-frames are present */
+     * when B-frames are present */
     int64_t initial_pts[2];
     int first_packet_output;
 
@@ -124,6 +159,7 @@ typedef struct NVENCContext {
     int rc;
     int device;
     int flags;
+    int async_depth;
 } NVENCContext;
 
 int ff_nvenc_encode_init(AVCodecContext *avctx);