You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

611 lines
24KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVUTIL_HWCONTEXT_H
  19. #define AVUTIL_HWCONTEXT_H
  20. #include "buffer.h"
  21. #include "frame.h"
  22. #include "log.h"
  23. #include "pixfmt.h"
  24. enum AVHWDeviceType {
  25. AV_HWDEVICE_TYPE_NONE,
  26. AV_HWDEVICE_TYPE_VDPAU,
  27. AV_HWDEVICE_TYPE_CUDA,
  28. AV_HWDEVICE_TYPE_VAAPI,
  29. AV_HWDEVICE_TYPE_DXVA2,
  30. AV_HWDEVICE_TYPE_QSV,
  31. AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
  32. AV_HWDEVICE_TYPE_D3D11VA,
  33. AV_HWDEVICE_TYPE_DRM,
  34. AV_HWDEVICE_TYPE_OPENCL,
  35. AV_HWDEVICE_TYPE_MEDIACODEC,
  36. AV_HWDEVICE_TYPE_VULKAN,
  37. };
  38. typedef struct AVHWDeviceInternal AVHWDeviceInternal;
  39. /**
  40. * This struct aggregates all the (hardware/vendor-specific) "high-level" state,
  41. * i.e. state that is not tied to a concrete processing configuration.
  42. * E.g., in an API that supports hardware-accelerated encoding and decoding,
  43. * this struct will (if possible) wrap the state that is common to both encoding
  44. * and decoding and from which specific instances of encoders or decoders can be
  45. * derived.
  46. *
  47. * This struct is reference-counted with the AVBuffer mechanism. The
  48. * av_hwdevice_ctx_alloc() constructor yields a reference, whose data field
  49. * points to the actual AVHWDeviceContext. Further objects derived from
  50. * AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with
  51. * specific properties) will hold an internal reference to it. After all the
  52. * references are released, the AVHWDeviceContext itself will be freed,
  53. * optionally invoking a user-specified callback for uninitializing the hardware
  54. * state.
  55. */
  56. typedef struct AVHWDeviceContext {
  57. /**
  58. * A class for logging. Set by av_hwdevice_ctx_alloc().
  59. */
  60. const AVClass *av_class;
  61. /**
  62. * Private data used internally by libavutil. Must not be accessed in any
  63. * way by the caller.
  64. */
  65. AVHWDeviceInternal *internal;
  66. /**
  67. * This field identifies the underlying API used for hardware access.
  68. *
  69. * This field is set when this struct is allocated and never changed
  70. * afterwards.
  71. */
  72. enum AVHWDeviceType type;
  73. /**
  74. * The format-specific data, allocated and freed by libavutil along with
  75. * this context.
  76. *
  77. * Should be cast by the user to the format-specific context defined in the
  78. * corresponding header (hwcontext_*.h) and filled as described in the
  79. * documentation before calling av_hwdevice_ctx_init().
  80. *
  81. * After calling av_hwdevice_ctx_init() this struct should not be modified
  82. * by the caller.
  83. */
  84. void *hwctx;
  85. /**
  86. * This field may be set by the caller before calling av_hwdevice_ctx_init().
  87. *
  88. * If non-NULL, this callback will be called when the last reference to
  89. * this context is unreferenced, immediately before it is freed.
  90. *
  91. * @note when other objects (e.g an AVHWFramesContext) are derived from this
  92. * struct, this callback will be invoked after all such child objects
  93. * are fully uninitialized and their respective destructors invoked.
  94. */
  95. void (*free)(struct AVHWDeviceContext *ctx);
  96. /**
  97. * Arbitrary user data, to be used e.g. by the free() callback.
  98. */
  99. void *user_opaque;
  100. } AVHWDeviceContext;
  101. typedef struct AVHWFramesInternal AVHWFramesInternal;
  102. /**
  103. * This struct describes a set or pool of "hardware" frames (i.e. those with
  104. * data not located in normal system memory). All the frames in the pool are
  105. * assumed to be allocated in the same way and interchangeable.
  106. *
  107. * This struct is reference-counted with the AVBuffer mechanism and tied to a
  108. * given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor
  109. * yields a reference, whose data field points to the actual AVHWFramesContext
  110. * struct.
  111. */
  112. typedef struct AVHWFramesContext {
  113. /**
  114. * A class for logging.
  115. */
  116. const AVClass *av_class;
  117. /**
  118. * Private data used internally by libavutil. Must not be accessed in any
  119. * way by the caller.
  120. */
  121. AVHWFramesInternal *internal;
  122. /**
  123. * A reference to the parent AVHWDeviceContext. This reference is owned and
  124. * managed by the enclosing AVHWFramesContext, but the caller may derive
  125. * additional references from it.
  126. */
  127. AVBufferRef *device_ref;
  128. /**
  129. * The parent AVHWDeviceContext. This is simply a pointer to
  130. * device_ref->data provided for convenience.
  131. *
  132. * Set by libavutil in av_hwframe_ctx_init().
  133. */
  134. AVHWDeviceContext *device_ctx;
  135. /**
  136. * The format-specific data, allocated and freed automatically along with
  137. * this context.
  138. *
  139. * Should be cast by the user to the format-specific context defined in the
  140. * corresponding header (hwframe_*.h) and filled as described in the
  141. * documentation before calling av_hwframe_ctx_init().
  142. *
  143. * After any frames using this context are created, the contents of this
  144. * struct should not be modified by the caller.
  145. */
  146. void *hwctx;
  147. /**
  148. * This field may be set by the caller before calling av_hwframe_ctx_init().
  149. *
  150. * If non-NULL, this callback will be called when the last reference to
  151. * this context is unreferenced, immediately before it is freed.
  152. */
  153. void (*free)(struct AVHWFramesContext *ctx);
  154. /**
  155. * Arbitrary user data, to be used e.g. by the free() callback.
  156. */
  157. void *user_opaque;
  158. /**
  159. * A pool from which the frames are allocated by av_hwframe_get_buffer().
  160. * This field may be set by the caller before calling av_hwframe_ctx_init().
  161. * The buffers returned by calling av_buffer_pool_get() on this pool must
  162. * have the properties described in the documentation in the corresponding hw
  163. * type's header (hwcontext_*.h). The pool will be freed strictly before
  164. * this struct's free() callback is invoked.
  165. *
  166. * This field may be NULL, then libavutil will attempt to allocate a pool
  167. * internally. Note that certain device types enforce pools allocated at
  168. * fixed size (frame count), which cannot be extended dynamically. In such a
  169. * case, initial_pool_size must be set appropriately.
  170. */
  171. AVBufferPool *pool;
  172. /**
  173. * Initial size of the frame pool. If a device type does not support
  174. * dynamically resizing the pool, then this is also the maximum pool size.
  175. *
  176. * May be set by the caller before calling av_hwframe_ctx_init(). Must be
  177. * set if pool is NULL and the device type does not support dynamic pools.
  178. */
  179. int initial_pool_size;
  180. /**
  181. * The pixel format identifying the underlying HW surface type.
  182. *
  183. * Must be a hwaccel format, i.e. the corresponding descriptor must have the
  184. * AV_PIX_FMT_FLAG_HWACCEL flag set.
  185. *
  186. * Must be set by the user before calling av_hwframe_ctx_init().
  187. */
  188. enum AVPixelFormat format;
  189. /**
  190. * The pixel format identifying the actual data layout of the hardware
  191. * frames.
  192. *
  193. * Must be set by the caller before calling av_hwframe_ctx_init().
  194. *
  195. * @note when the underlying API does not provide the exact data layout, but
  196. * only the colorspace/bit depth, this field should be set to the fully
  197. * planar version of that format (e.g. for 8-bit 420 YUV it should be
  198. * AV_PIX_FMT_YUV420P, not AV_PIX_FMT_NV12 or anything else).
  199. */
  200. enum AVPixelFormat sw_format;
  201. /**
  202. * The allocated dimensions of the frames in this pool.
  203. *
  204. * Must be set by the user before calling av_hwframe_ctx_init().
  205. */
  206. int width, height;
  207. } AVHWFramesContext;
  208. /**
  209. * Look up an AVHWDeviceType by name.
  210. *
  211. * @param name String name of the device type (case-insensitive).
  212. * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if
  213. * not found.
  214. */
  215. enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name);
  216. /** Get the string name of an AVHWDeviceType.
  217. *
  218. * @param type Type from enum AVHWDeviceType.
  219. * @return Pointer to a static string containing the name, or NULL if the type
  220. * is not valid.
  221. */
  222. const char *av_hwdevice_get_type_name(enum AVHWDeviceType type);
  223. /**
  224. * Iterate over supported device types.
  225. *
  226. * @param prev AV_HWDEVICE_TYPE_NONE initially, then the previous type
  227. * returned by this function in subsequent iterations.
  228. * @return The next usable device type from enum AVHWDeviceType, or
  229. * AV_HWDEVICE_TYPE_NONE if there are no more.
  230. */
  231. enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev);
  232. /**
  233. * Allocate an AVHWDeviceContext for a given hardware type.
  234. *
  235. * @param type the type of the hardware device to allocate.
  236. * @return a reference to the newly created AVHWDeviceContext on success or NULL
  237. * on failure.
  238. */
  239. AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type);
  240. /**
  241. * Finalize the device context before use. This function must be called after
  242. * the context is filled with all the required information and before it is
  243. * used in any way.
  244. *
  245. * @param ref a reference to the AVHWDeviceContext
  246. * @return 0 on success, a negative AVERROR code on failure
  247. */
  248. int av_hwdevice_ctx_init(AVBufferRef *ref);
  249. /**
  250. * Open a device of the specified type and create an AVHWDeviceContext for it.
  251. *
  252. * This is a convenience function intended to cover the simple cases. Callers
  253. * who need to fine-tune device creation/management should open the device
  254. * manually and then wrap it in an AVHWDeviceContext using
  255. * av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
  256. *
  257. * The returned context is already initialized and ready for use, the caller
  258. * should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of
  259. * the created AVHWDeviceContext are set by this function and should not be
  260. * touched by the caller.
  261. *
  262. * @param device_ctx On success, a reference to the newly-created device context
  263. * will be written here. The reference is owned by the caller
  264. * and must be released with av_buffer_unref() when no longer
  265. * needed. On failure, NULL will be written to this pointer.
  266. * @param type The type of the device to create.
  267. * @param device A type-specific string identifying the device to open.
  268. * @param opts A dictionary of additional (type-specific) options to use in
  269. * opening the device. The dictionary remains owned by the caller.
  270. * @param flags currently unused
  271. *
  272. * @return 0 on success, a negative AVERROR code on failure.
  273. */
  274. int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type,
  275. const char *device, AVDictionary *opts, int flags);
  276. /**
  277. * Create a new device of the specified type from an existing device.
  278. *
  279. * If the source device is a device of the target type or was originally
  280. * derived from such a device (possibly through one or more intermediate
  281. * devices of other types), then this will return a reference to the
  282. * existing device of the same type as is requested.
  283. *
  284. * Otherwise, it will attempt to derive a new device from the given source
  285. * device. If direct derivation to the new type is not implemented, it will
  286. * attempt the same derivation from each ancestor of the source device in
  287. * turn looking for an implemented derivation method.
  288. *
  289. * @param dst_ctx On success, a reference to the newly-created
  290. * AVHWDeviceContext.
  291. * @param type The type of the new device to create.
  292. * @param src_ctx A reference to an existing AVHWDeviceContext which will be
  293. * used to create the new device.
  294. * @param flags Currently unused; should be set to zero.
  295. * @return Zero on success, a negative AVERROR code on failure.
  296. */
  297. int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx,
  298. enum AVHWDeviceType type,
  299. AVBufferRef *src_ctx, int flags);
  300. /**
  301. * Create a new device of the specified type from an existing device.
  302. *
  303. * This function performs the same action as av_hwdevice_ctx_create_derived,
  304. * however, it is able to set options for the new device to be derived.
  305. *
  306. * @param dst_ctx On success, a reference to the newly-created
  307. * AVHWDeviceContext.
  308. * @param type The type of the new device to create.
  309. * @param src_ctx A reference to an existing AVHWDeviceContext which will be
  310. * used to create the new device.
  311. * @param options Options for the new device to create, same format as in
  312. * av_hwdevice_ctx_create.
  313. * @param flags Currently unused; should be set to zero.
  314. * @return Zero on success, a negative AVERROR code on failure.
  315. */
  316. int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ctx,
  317. enum AVHWDeviceType type,
  318. AVBufferRef *src_ctx,
  319. AVDictionary *options, int flags);
  320. /**
  321. * Allocate an AVHWFramesContext tied to a given device context.
  322. *
  323. * @param device_ctx a reference to a AVHWDeviceContext. This function will make
  324. * a new reference for internal use, the one passed to the
  325. * function remains owned by the caller.
  326. * @return a reference to the newly created AVHWFramesContext on success or NULL
  327. * on failure.
  328. */
  329. AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ctx);
  330. /**
  331. * Finalize the context before use. This function must be called after the
  332. * context is filled with all the required information and before it is attached
  333. * to any frames.
  334. *
  335. * @param ref a reference to the AVHWFramesContext
  336. * @return 0 on success, a negative AVERROR code on failure
  337. */
  338. int av_hwframe_ctx_init(AVBufferRef *ref);
  339. /**
  340. * Allocate a new frame attached to the given AVHWFramesContext.
  341. *
  342. * @param hwframe_ctx a reference to an AVHWFramesContext
  343. * @param frame an empty (freshly allocated or unreffed) frame to be filled with
  344. * newly allocated buffers.
  345. * @param flags currently unused, should be set to zero
  346. * @return 0 on success, a negative AVERROR code on failure
  347. */
  348. int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags);
  349. /**
  350. * Copy data to or from a hw surface. At least one of dst/src must have an
  351. * AVHWFramesContext attached.
  352. *
  353. * If src has an AVHWFramesContext attached, then the format of dst (if set)
  354. * must use one of the formats returned by av_hwframe_transfer_get_formats(src,
  355. * AV_HWFRAME_TRANSFER_DIRECTION_FROM).
  356. * If dst has an AVHWFramesContext attached, then the format of src must use one
  357. * of the formats returned by av_hwframe_transfer_get_formats(dst,
  358. * AV_HWFRAME_TRANSFER_DIRECTION_TO)
  359. *
  360. * dst may be "clean" (i.e. with data/buf pointers unset), in which case the
  361. * data buffers will be allocated by this function using av_frame_get_buffer().
  362. * If dst->format is set, then this format will be used, otherwise (when
  363. * dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.
  364. *
  365. * The two frames must have matching allocated dimensions (i.e. equal to
  366. * AVHWFramesContext.width/height), since not all device types support
  367. * transferring a sub-rectangle of the whole surface. The display dimensions
  368. * (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but
  369. * also have to be equal for both frames. When the display dimensions are
  370. * smaller than the allocated dimensions, the content of the padding in the
  371. * destination frame is unspecified.
  372. *
  373. * @param dst the destination frame. dst is not touched on failure.
  374. * @param src the source frame.
  375. * @param flags currently unused, should be set to zero
  376. * @return 0 on success, a negative AVERROR error code on failure.
  377. */
  378. int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags);
  379. enum AVHWFrameTransferDirection {
  380. /**
  381. * Transfer the data from the queried hw frame.
  382. */
  383. AV_HWFRAME_TRANSFER_DIRECTION_FROM,
  384. /**
  385. * Transfer the data to the queried hw frame.
  386. */
  387. AV_HWFRAME_TRANSFER_DIRECTION_TO,
  388. };
  389. /**
  390. * Get a list of possible source or target formats usable in
  391. * av_hwframe_transfer_data().
  392. *
  393. * @param hwframe_ctx the frame context to obtain the information for
  394. * @param dir the direction of the transfer
  395. * @param formats the pointer to the output format list will be written here.
  396. * The list is terminated with AV_PIX_FMT_NONE and must be freed
  397. * by the caller when no longer needed using av_free().
  398. * If this function returns successfully, the format list will
  399. * have at least one item (not counting the terminator).
  400. * On failure, the contents of this pointer are unspecified.
  401. * @param flags currently unused, should be set to zero
  402. * @return 0 on success, a negative AVERROR code on failure.
  403. */
  404. int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx,
  405. enum AVHWFrameTransferDirection dir,
  406. enum AVPixelFormat **formats, int flags);
  407. /**
  408. * This struct describes the constraints on hardware frames attached to
  409. * a given device with a hardware-specific configuration. This is returned
  410. * by av_hwdevice_get_hwframe_constraints() and must be freed by
  411. * av_hwframe_constraints_free() after use.
  412. */
  413. typedef struct AVHWFramesConstraints {
  414. /**
  415. * A list of possible values for format in the hw_frames_ctx,
  416. * terminated by AV_PIX_FMT_NONE. This member will always be filled.
  417. */
  418. enum AVPixelFormat *valid_hw_formats;
  419. /**
  420. * A list of possible values for sw_format in the hw_frames_ctx,
  421. * terminated by AV_PIX_FMT_NONE. Can be NULL if this information is
  422. * not known.
  423. */
  424. enum AVPixelFormat *valid_sw_formats;
  425. /**
  426. * The minimum size of frames in this hw_frames_ctx.
  427. * (Zero if not known.)
  428. */
  429. int min_width;
  430. int min_height;
  431. /**
  432. * The maximum size of frames in this hw_frames_ctx.
  433. * (INT_MAX if not known / no limit.)
  434. */
  435. int max_width;
  436. int max_height;
  437. } AVHWFramesConstraints;
  438. /**
  439. * Allocate a HW-specific configuration structure for a given HW device.
  440. * After use, the user must free all members as required by the specific
  441. * hardware structure being used, then free the structure itself with
  442. * av_free().
  443. *
  444. * @param device_ctx a reference to the associated AVHWDeviceContext.
  445. * @return The newly created HW-specific configuration structure on
  446. * success or NULL on failure.
  447. */
  448. void *av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx);
  449. /**
  450. * Get the constraints on HW frames given a device and the HW-specific
  451. * configuration to be used with that device. If no HW-specific
  452. * configuration is provided, returns the maximum possible capabilities
  453. * of the device.
  454. *
  455. * @param ref a reference to the associated AVHWDeviceContext.
  456. * @param hwconfig a filled HW-specific configuration structure, or NULL
  457. * to return the maximum possible capabilities of the device.
  458. * @return AVHWFramesConstraints structure describing the constraints
  459. * on the device, or NULL if not available.
  460. */
  461. AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref,
  462. const void *hwconfig);
  463. /**
  464. * Free an AVHWFrameConstraints structure.
  465. *
  466. * @param constraints The (filled or unfilled) AVHWFrameConstraints structure.
  467. */
  468. void av_hwframe_constraints_free(AVHWFramesConstraints **constraints);
  469. /**
  470. * Flags to apply to frame mappings.
  471. */
  472. enum {
  473. /**
  474. * The mapping must be readable.
  475. */
  476. AV_HWFRAME_MAP_READ = 1 << 0,
  477. /**
  478. * The mapping must be writeable.
  479. */
  480. AV_HWFRAME_MAP_WRITE = 1 << 1,
  481. /**
  482. * The mapped frame will be overwritten completely in subsequent
  483. * operations, so the current frame data need not be loaded. Any values
  484. * which are not overwritten are unspecified.
  485. */
  486. AV_HWFRAME_MAP_OVERWRITE = 1 << 2,
  487. /**
  488. * The mapping must be direct. That is, there must not be any copying in
  489. * the map or unmap steps. Note that performance of direct mappings may
  490. * be much lower than normal memory.
  491. */
  492. AV_HWFRAME_MAP_DIRECT = 1 << 3,
  493. };
  494. /**
  495. * Map a hardware frame.
  496. *
  497. * This has a number of different possible effects, depending on the format
  498. * and origin of the src and dst frames. On input, src should be a usable
  499. * frame with valid buffers and dst should be blank (typically as just created
  500. * by av_frame_alloc()). src should have an associated hwframe context, and
  501. * dst may optionally have a format and associated hwframe context.
  502. *
  503. * If src was created by mapping a frame from the hwframe context of dst,
  504. * then this function undoes the mapping - dst is replaced by a reference to
  505. * the frame that src was originally mapped from.
  506. *
  507. * If both src and dst have an associated hwframe context, then this function
  508. * attempts to map the src frame from its hardware context to that of dst and
  509. * then fill dst with appropriate data to be usable there. This will only be
  510. * possible if the hwframe contexts and associated devices are compatible -
  511. * given compatible devices, av_hwframe_ctx_create_derived() can be used to
  512. * create a hwframe context for dst in which mapping should be possible.
  513. *
  514. * If src has a hwframe context but dst does not, then the src frame is
  515. * mapped to normal memory and should thereafter be usable as a normal frame.
  516. * If the format is set on dst, then the mapping will attempt to create dst
  517. * with that format and fail if it is not possible. If format is unset (is
  518. * AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate
  519. * format to use is (probably the sw_format of the src hwframe context).
  520. *
  521. * A return value of AVERROR(ENOSYS) indicates that the mapping is not
  522. * possible with the given arguments and hwframe setup, while other return
  523. * values indicate that it failed somehow.
  524. *
  525. * On failure, the destination frame will be left blank, except for the
  526. * hw_frames_ctx/format fields thay may have been set by the caller - those will
  527. * be preserved as they were.
  528. *
  529. * @param dst Destination frame, to contain the mapping.
  530. * @param src Source frame, to be mapped.
  531. * @param flags Some combination of AV_HWFRAME_MAP_* flags.
  532. * @return Zero on success, negative AVERROR code on failure.
  533. */
  534. int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags);
  535. /**
  536. * Create and initialise an AVHWFramesContext as a mapping of another existing
  537. * AVHWFramesContext on a different device.
  538. *
  539. * av_hwframe_ctx_init() should not be called after this.
  540. *
  541. * @param derived_frame_ctx On success, a reference to the newly created
  542. * AVHWFramesContext.
  543. * @param format The AVPixelFormat for the derived context.
  544. * @param derived_device_ctx A reference to the device to create the new
  545. * AVHWFramesContext on.
  546. * @param source_frame_ctx A reference to an existing AVHWFramesContext
  547. * which will be mapped to the derived context.
  548. * @param flags Some combination of AV_HWFRAME_MAP_* flags, defining the
  549. * mapping parameters to apply to frames which are allocated
  550. * in the derived device.
  551. * @return Zero on success, negative AVERROR code on failure.
  552. */
  553. int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
  554. enum AVPixelFormat format,
  555. AVBufferRef *derived_device_ctx,
  556. AVBufferRef *source_frame_ctx,
  557. int flags);
  558. #endif /* AVUTIL_HWCONTEXT_H */