[FFmpeg-devel] [PATCH] lavc: Add device context field to AVCodecContext
Mark Thompson
sw at jkqxz.net
Wed Feb 1 23:47:53 EET 2017
For use by codec implementations which can allocate frames internally.
---
On 01/02/17 14:03, Timo Rothenpieler wrote:
> Am 17.01.2017 um 23:28 schrieb Mark Thompson:
>> For use by codec implementations which require a device to operation
>> but will allocate frames internally.
>> ---
>> The following patches make use of it for qsv. Is this definition appropriate to solve the issues with cuvid device setup as well?
>>
>>
>> doc/APIchanges | 3 +++
>> libavcodec/avcodec.h | 38 ++++++++++++++++++++++++++++++++++++--
>> libavcodec/utils.c | 1 +
>> libavcodec/version.h | 2 +-
>> 4 files changed, 41 insertions(+), 3 deletions(-)
>
> ping about this.
> I'd really like to use it for cuvid and get rid of some hackery.
This got more discussion in libav, see below for a patch expressing the currently-proposed semantics.
(See also <https://lists.libav.org/pipermail/libav-devel/2017-February/082084.html> for a full implementation for VAAPI, I haven't ported it here yet.)
Thanks,
- Mark
libavcodec/avcodec.h | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1e681e989b..cd83e6b27f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3533,7 +3533,8 @@ typedef struct AVCodecContext {
/**
* A reference to the AVHWFramesContext describing the input (for encoding)
* or output (decoding) frames. The reference is set by the caller and
- * afterwards owned (and freed) by libavcodec.
+ * afterwards owned (and freed) by libavcodec - it should never be read by
+ * the caller after being set.
*
* - decoding: This field should be set by the caller from the get_format()
* callback. The previous reference (if any) will always be
@@ -3583,6 +3584,25 @@ typedef struct AVCodecContext {
*/
int64_t max_pixels;
+ /**
+ * A reference to the AVHWDeviceContext describing the device which will
+ * be used by a hardware encoder/decoder. The reference is set by the
+ * caller and afterwards owned (and freed) by libavcodec - it should never
+ * be read by the caller after being set.
+ *
+ * This should only be used if either the codec device does not require
+ * hardware frames or any that are used are allocated internally by
+ * libavcodec. If the user wishes to supply any of the frames used as
+ * encoder input or decoder output then hw_frames_ctx should be used
+ * instead.
+ *
+ * - decoding: This field should be set by the caller from the get_format()
+ * callback. The previous reference (if any) will always be
+ * unreffed by libavcodec before the get_format() call.
+ *
+ * - encoding: This field should be set before avcodec_open2() is called.
+ */
+ AVBufferRef *hw_device_ctx;
} AVCodecContext;
AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
--
2.11.0
More information about the ffmpeg-devel
mailing list