mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
nvenc: Refactoring internal buffer pool structure
To support rc-lookahead and bframe encoding, nvenc needs one more staging queue, because NvEncEncodePicture can return NV_ENC_ERR_NEED_MORE_INPUT but which was not considered so far. As documented by NVENC programming guide, pending buffers should wait other inputs until NvEncEncodePicture returns success. New encoding flow is - Submit raw picture buffer to encoder with NvEncEncodePicture - The submitted input/output buffer pair will be queued to pending_queue - If NvEncEncodePicture returned success, then move all pair in pending_queue to final stage - Otherwise, wait more input raw pictures. Another change is dropping NV_ENC_LOCK_INPUT_BUFFER usage. So now nvenc always uses CUDA memory input buffer. As a result, both opengl and system memory handling are unified.
This commit is contained in:
parent
e73acbaa5c
commit
94f2843774
2 changed files with 417 additions and 475 deletions
File diff suppressed because it is too large
Load diff
|
@ -104,25 +104,30 @@ typedef struct {
|
|||
volatile gint reconfig; /* ATOMIC */
|
||||
gboolean gl_input;
|
||||
|
||||
/* allocated buffers */
|
||||
gpointer *input_bufs; /* array of n_allocs input buffers */
|
||||
NV_ENC_OUTPUT_PTR *output_bufs; /* array of n_allocs output buffers */
|
||||
/* array of allocated input/output buffers (GstNvEncFrameState),
|
||||
* and hold the ownership of the GstNvEncFrameState. */
|
||||
GArray *items;
|
||||
guint n_bufs;
|
||||
|
||||
/* input and output buffers currently available */
|
||||
GAsyncQueue *in_bufs_pool;
|
||||
GAsyncQueue *bitstream_pool;
|
||||
/* (GstNvEncFrameState) available empty items which could be submitted
|
||||
* to encoder */
|
||||
GAsyncQueue *available_queue;
|
||||
|
||||
/* output bufs in use (input bufs in use are tracked via the codec frames) */
|
||||
GAsyncQueue *bitstream_queue;
|
||||
/* (GstNvEncFrameState) submitted to encoder but not ready to finish
|
||||
* (due to bframe or lookhead operation) */
|
||||
GAsyncQueue *pending_queue;
|
||||
|
||||
/* (GstNvEncFrameState) submitted to encoder and ready to finish.
|
||||
* finished items will go back to available item queue */
|
||||
GAsyncQueue *bitstream_queue;
|
||||
|
||||
/* we spawn a thread that does the (blocking) waits for output buffers
|
||||
* to become available, so we can continue to feed data to the encoder
|
||||
* while we wait */
|
||||
GThread *bitstream_thread;
|
||||
|
||||
void *display; /* GstGLDisplay */
|
||||
void *other_context; /* GstGLContext */
|
||||
GstObject *display; /* GstGLDisplay */
|
||||
GstObject *other_context; /* GstGLContext */
|
||||
|
||||
GstVideoInfo input_info; /* buffer configuration for buffers sent to NVENC */
|
||||
|
||||
|
|
Loading…
Reference in a new issue