Previously we would allocate a new one for every frame. This instead maintains an AVBufferPool of them to use as-needed. Also makes the maximum size of an output buffer adapt to the frame size - the fixed upper bound was a bit too easy to hit when encoding large pictures at high quality.
Showing the changes to libavcodec/vaapi_encode.h (1 of 2 files). Show all
Unified · Split
| @@ -39,7 +39,6 @@ enum { · 38 unmodified lines | |||
| 39 | MAX_PARAM_BUFFERS = 16, | 39 | MAX_PARAM_BUFFERS = 16, |
| 40 | MAX_REORDER_DELAY = 16, | 40 | MAX_REORDER_DELAY = 16, |
| 41 | MAX_PARAM_BUFFER_SIZE = 1024, | 41 | MAX_PARAM_BUFFER_SIZE = 1024, |
| 42 | MAX_OUTPUT_BUFFER_SIZE = 1024 * 1024, | ||
| 43 | }; | 42 | }; |
| 44 | 43 | ||
| 45 | enum { | 44 | enum { |
| @@ -84,6 +83,7 @@ typedef struct VAAPIEncodePicture { · 38 unmodified lines | |||
| 84 | int nb_param_buffers; | 83 | int nb_param_buffers; |
| 85 | VABufferID param_buffers[MAX_PARAM_BUFFERS]; | 84 | VABufferID param_buffers[MAX_PARAM_BUFFERS]; |
| 86 | 85 | ||
| 86 | AVBufferRef *output_buffer_ref; | ||
| 87 | VABufferID output_buffer; | 87 | VABufferID output_buffer; |
| 88 | 88 | ||
| 89 | void *priv_data; | 89 | void *priv_data; |
| @@ -130,6 +130,8 @@ typedef struct VAAPIEncodeContext { · 40 unmodified lines | |||
| 130 | AVBufferRef *recon_frames_ref; | 130 | AVBufferRef *recon_frames_ref; |
| 131 | AVHWFramesContext *recon_frames; | 131 | AVHWFramesContext *recon_frames; |
| 132 | 132 | ||
| 133 | AVBufferPool *output_buffer_pool; | ||
| 134 | |||
| 133 | VAConfigAttrib config_attributes[MAX_CONFIG_ATTRIBUTES]; | 135 | VAConfigAttrib config_attributes[MAX_CONFIG_ATTRIBUTES]; |
| 134 | int nb_config_attributes; | 136 | int nb_config_attributes; |
| 135 | 137 | ||