2
0

hwcontext.h 22 KB

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