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

Function set_hwframe_ctx

doc/examples/vaapi_encode.c:41–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39static AVBufferRef *hw_device_ctx = NULL;
40
41static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx)
42{
43 AVBufferRef *hw_frames_ref;
44 AVHWFramesContext *frames_ctx = NULL;
45 int err = 0;
46
47 if (!(hw_frames_ref = av_hwframe_ctx_alloc(hw_device_ctx))) {
48 fprintf(stderr, "Failed to create VAAPI frame context.\n");
49 return -1;
50 }
51 frames_ctx = (AVHWFramesContext *)(hw_frames_ref->data);
52 frames_ctx->format = AV_PIX_FMT_VAAPI;
53 frames_ctx->sw_format = AV_PIX_FMT_NV12;
54 frames_ctx->width = width;
55 frames_ctx->height = height;
56 frames_ctx->initial_pool_size = 20;
57 if ((err = av_hwframe_ctx_init(hw_frames_ref)) < 0) {
58 fprintf(stderr, "Failed to initialize VAAPI frame context."
59 "Error code: %s\n",av_err2str(err));
60 av_buffer_unref(&hw_frames_ref);
61 return err;
62 }
63 ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ref);
64 if (!ctx->hw_frames_ctx)
65 err = AVERROR(ENOMEM);
66
67 av_buffer_unref(&hw_frames_ref);
68 return err;
69}
70
71static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
72{

Callers 1

mainFunction · 0.85

Calls 4

av_hwframe_ctx_allocFunction · 0.85
av_hwframe_ctx_initFunction · 0.85
av_buffer_unrefFunction · 0.85
av_buffer_refFunction · 0.85

Tested by

no test coverage detected