MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / set_hwframe_ctx

Function set_hwframe_ctx

src/FFmpegWriter.cpp:45–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43AVFrame *hw_frame = NULL;
44
45static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx, int64_t width, int64_t height)
46{
47 AVBufferRef *hw_frames_ref;
48 AVHWFramesContext *frames_ctx = NULL;
49 int err = 0;
50
51 if (!(hw_frames_ref = av_hwframe_ctx_alloc(hw_device_ctx))) {
52 std::clog << "Failed to create HW frame context.\n";
53 return -1;
54 }
55 frames_ctx = (AVHWFramesContext *)(hw_frames_ref->data);
56 frames_ctx->format = hw_en_av_pix_fmt;
57 frames_ctx->sw_format = AV_PIX_FMT_NV12;
58 frames_ctx->width = width;
59 frames_ctx->height = height;
60 frames_ctx->initial_pool_size = 20;
61 if ((err = av_hwframe_ctx_init(hw_frames_ref)) < 0) {
62 std::clog << "Failed to initialize HW frame context. " <<
63 "Error code: " << av_err2string(err) << "\n";
64 av_buffer_unref(&hw_frames_ref);
65 return err;
66 }
67 ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ref);
68 if (!ctx->hw_frames_ctx)
69 err = AVERROR(ENOMEM);
70
71 av_buffer_unref(&hw_frames_ref);
72 return err;
73}
74#endif // USE_HW_ACCEL
75
76FFmpegWriter::FFmpegWriter(const std::string& path) :

Callers 1

FFmpegWriter.cppFile · 0.85

Calls 1

av_err2stringFunction · 0.85

Tested by

no test coverage detected