MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / cuda_get_buffer

Function cuda_get_buffer

libavutil/hwcontext_cuda.c:191–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
192{
193 CUDAFramesContext *priv = ctx->hwctx;
194 int res;
195
196 frame->buf[0] = av_buffer_pool_get(ctx->pool);
197 if (!frame->buf[0])
198 return AVERROR(ENOMEM);
199
200 res = av_image_fill_arrays(frame->data, frame->linesize, frame->buf[0]->data,
201 ctx->sw_format, ctx->width, ctx->height, priv->tex_alignment);
202 if (res < 0)
203 return res;
204
205 // YUV420P is a special case.
206 // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned
207 if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
208 frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
209 frame->data[2] = frame->data[1];
210 frame->data[1] = frame->data[2] + frame->linesize[2] * (ctx->height / 2);
211 }
212
213 frame->format = AV_PIX_FMT_CUDA;
214 frame->width = ctx->width;
215 frame->height = ctx->height;
216
217 return 0;
218}
219
220static int cuda_transfer_get_formats(AVHWFramesContext *ctx,
221 enum AVHWFrameTransferDirection dir,

Callers

nothing calls this directly

Calls 2

av_buffer_pool_getFunction · 0.85
av_image_fill_arraysFunction · 0.85

Tested by

no test coverage detected