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

Function av_hwdevice_ctx_alloc

libavutil/hwcontext.c:176–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
177{
178 FFHWDeviceContext *ctxi;
179 AVHWDeviceContext *ctx;
180 AVBufferRef *buf;
181 const HWContextType *hw_type = NULL;
182 int i;
183
184 for (i = 0; hw_table[i]; i++) {
185 if (hw_table[i]->type == type) {
186 hw_type = hw_table[i];
187 break;
188 }
189 }
190 if (!hw_type)
191 return NULL;
192
193 ctxi = av_mallocz(sizeof(*ctxi));
194 if (!ctxi)
195 return NULL;
196 ctx = &ctxi->p;
197
198 if (hw_type->device_hwctx_size) {
199 ctx->hwctx = av_mallocz(hw_type->device_hwctx_size);
200 if (!ctx->hwctx)
201 goto fail;
202 }
203
204 buf = av_buffer_create((uint8_t*)ctx, sizeof(*ctx),
205 hwdevice_ctx_free, NULL,
206 AV_BUFFER_FLAG_READONLY);
207 if (!buf)
208 goto fail;
209
210 ctx->type = type;
211 ctx->av_class = &hwdevice_ctx_class;
212
213 ctxi->hw_type = hw_type;
214
215 return buf;
216
217fail:
218 av_freep(&ctx->hwctx);
219 av_freep(&ctx);
220 return NULL;
221}
222
223int av_hwdevice_ctx_init(AVBufferRef *ref)
224{

Callers 5

av_hwdevice_ctx_createFunction · 0.85
qsv_init_child_ctxFunction · 0.85
create_vk_by_placeboFunction · 0.85
rkmpp_init_decoderFunction · 0.85

Calls 3

av_buffer_createFunction · 0.85
av_freepFunction · 0.85
av_malloczFunction · 0.70

Tested by

no test coverage detected