History

hwcontext: add a function for opening devices

Anton Khirnov committed 10 years ago

Commit 1c9e8611 parent 24b5cff5 files · +71 −1Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavutil/hwcontext.c +36 −0
  3. libavutil/hwcontext.h +28 −0
  4. libavutil/hwcontext_internal.h +3 −0
  5. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2015-08-28 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162016-xx-xx - xxxxxxx - lavu 55.13.0 - hwcontext.h
17 Add av_hwdevice_ctx_create().
18
162016-xx-xx - xxxxxxx - lavc 57.19.1 - avcodec.h192016-xx-xx - xxxxxxx - lavc 57.19.1 - avcodec.h
17 Adjust values for JPEG 2000 profiles.20 Adjust values for JPEG 2000 profiles.
18 21
libavutil/hwcontext.c+36−0
@@ -452,3 +452,39 @@ void av_hwframe_constraints_free(AVHWFramesConstraints **constraints) · 451 unmodified lines
452 }452 }
453 av_freep(constraints);453 av_freep(constraints);
454}454}
455
456int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type,
457 const char *device, AVDictionary *opts, int flags)
458{
459 AVBufferRef *device_ref = NULL;
460 AVHWDeviceContext *device_ctx;
461 int ret = 0;
462
463 device_ref = av_hwdevice_ctx_alloc(type);
464 if (!device_ref) {
465 ret = AVERROR(ENOMEM);
466 goto fail;
467 }
468 device_ctx = (AVHWDeviceContext*)device_ref->data;
469
470 if (!device_ctx->internal->hw_type->device_create) {
471 ret = AVERROR(ENOSYS);
472 goto fail;
473 }
474
475 ret = device_ctx->internal->hw_type->device_create(device_ctx, device,
476 opts, flags);
477 if (ret < 0)
478 goto fail;
479
480 ret = av_hwdevice_ctx_init(device_ref);
481 if (ret < 0)
482 goto fail;
483
484 *pdevice_ref = device_ref;
485 return 0;
486fail:
487 av_buffer_unref(&device_ref);
488 *pdevice_ref = NULL;
489 return ret;
490}
libavutil/hwcontext.h+28−0
@@ -241,6 +241,34 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type); · 240 unmodified lines
241 */241 */
242int av_hwdevice_ctx_init(AVBufferRef *ref);242int av_hwdevice_ctx_init(AVBufferRef *ref);
243 243
244/**
245 * Open a device of the specified type and create an AVHWDeviceContext for it.
246 *
247 * This is a convenience function intended to cover the simple cases. Callers
248 * who need to fine-tune device creation/management should open the device
249 * manually and then wrap it in an AVHWDeviceContext using
250 * av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
251 *
252 * The returned context is already initialized and ready for use, the caller
253 * should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of
254 * the created AVHWDeviceContext are set by this function and should not be
255 * touched by the caller.
256 *
257 * @param device_ctx On success, a reference to the newly-created device context
258 * will be written here. The reference is owned by the caller
259 * and must be released with av_buffer_unref() when no longer
260 * needed. On failure, NULL will be written to this pointer.
261 * @param type The type of the device to create.
262 * @param device A type-specific string identifying the device to open.
263 * @param opts A dictionary of additional (type-specific) options to use in
264 * opening the device. The dictionary remains owned by the caller.
265 * @param flags currently unused
266 *
267 * @return 0 on success, a negative AVERROR code on failure.
268 */
269int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type,
270 const char *device, AVDictionary *opts, int flags);
271
244/**272/**
245 * Allocate an AVHWFramesContext tied to a given device context.273 * Allocate an AVHWFramesContext tied to a given device context.
246 *274 *
libavutil/hwcontext_internal.h+3−0
@@ -64,6 +64,9 @@ typedef struct HWContextType { · 63 unmodified lines
64 */64 */
65 size_t frames_priv_size;65 size_t frames_priv_size;
66 66
67 int (*device_create)(AVHWDeviceContext *ctx, const char *device,
68 AVDictionary *opts, int flags);
69
67 int (*device_init)(AVHWDeviceContext *ctx);70 int (*device_init)(AVHWDeviceContext *ctx);
68 void (*device_uninit)(AVHWDeviceContext *ctx);71 void (*device_uninit)(AVHWDeviceContext *ctx);
69 72
libavutil/version.h+1−1
@@ -54,7 +54,7 @@ · 53 unmodified lines
54 */54 */
55 55
56#define LIBAVUTIL_VERSION_MAJOR 5556#define LIBAVUTIL_VERSION_MAJOR 55
57#define LIBAVUTIL_VERSION_MINOR 1257#define LIBAVUTIL_VERSION_MINOR 13
58#define LIBAVUTIL_VERSION_MICRO 058#define LIBAVUTIL_VERSION_MICRO 0
59 59
60#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \60#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t