| 189 | } |
| 190 | |
| 191 | static 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 | |
| 220 | static int cuda_transfer_get_formats(AVHWFramesContext *ctx, |
| 221 | enum AVHWFrameTransferDirection dir, |
nothing calls this directly
no test coverage detected