Unified · Split
| @@ -13,6 +13,9 @@ libavutil: 2015-08-28 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2016-xx-xx - xxxxxxx - lavu 55.13.0 - hwcontext.h | |
| 17 | + Add av_hwdevice_ctx_create(). | |
| 18 | + | |
| 16 | 19 | 2016-xx-xx - xxxxxxx - lavc 57.19.1 - avcodec.h |
| 17 | 20 | Adjust values for JPEG 2000 profiles. |
| 18 | 21 | |
| @@ -452,3 +452,39 @@ void av_hwframe_constraints_free(AVHWFramesConstraints **constraints) · 451 unmodified lines | ||
| 452 | 452 | } |
| 453 | 453 | av_freep(constraints); |
| 454 | 454 | } |
| 455 | + | |
| 456 | +int 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; | |
| 486 | +fail: | |
| 487 | + av_buffer_unref(&device_ref); | |
| 488 | + *pdevice_ref = NULL; | |
| 489 | + return ret; | |
| 490 | +} | |
| @@ -241,6 +241,34 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type); · 240 unmodified lines | ||
| 241 | 241 | */ |
| 242 | 242 | int 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 | + */ | |
| 269 | +int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type, | |
| 270 | + const char *device, AVDictionary *opts, int flags); | |
| 271 | + | |
| 244 | 272 | /** |
| 245 | 273 | * Allocate an AVHWFramesContext tied to a given device context. |
| 246 | 274 | * |
| @@ -64,6 +64,9 @@ typedef struct HWContextType { · 63 unmodified lines | ||
| 64 | 64 | */ |
| 65 | 65 | size_t frames_priv_size; |
| 66 | 66 | |
| 67 | + int (*device_create)(AVHWDeviceContext *ctx, const char *device, | |
| 68 | + AVDictionary *opts, int flags); | |
| 69 | + | |
| 67 | 70 | int (*device_init)(AVHWDeviceContext *ctx); |
| 68 | 71 | void (*device_uninit)(AVHWDeviceContext *ctx); |
| 69 | 72 | |
| @@ -54,7 +54,7 @@ · 53 unmodified lines | ||
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | 56 | #define LIBAVUTIL_VERSION_MAJOR 55 |
| 57 | −#define LIBAVUTIL_VERSION_MINOR 12 | |
| 57 | +#define LIBAVUTIL_VERSION_MINOR 13 | |
| 58 | 58 | #define LIBAVUTIL_VERSION_MICRO 0 |
| 59 | 59 | |
| 60 | 60 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |