diff options
author | Mark Thompson <sw@jkqxz.net> | 2017-02-11 15:13:04 +0000 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2017-02-13 20:14:27 +0000 |
commit | 44f2eda39ff55c69d4d739fb12a42a10b7ce581c (patch) | |
tree | 8d4008c99ef8688c0318cbc49ee63e4d73e59241 /libavcodec | |
parent | 07b5136c481d394992c7e951967df0cfbb346c0b (diff) | |
download | ffmpeg-44f2eda39ff55c69d4d739fb12a42a10b7ce581c.tar.gz |
lavc: Add device context field to AVCodecContext
For use by codec implementations which can allocate frames internally.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 25 | ||||
-rw-r--r-- | libavcodec/utils.c | 1 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
3 files changed, 26 insertions, 2 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 8d8fa594aa..b7bf85a041 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3093,7 +3093,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 @@ -3139,6 +3140,28 @@ typedef struct AVCodecContext { * (with the display dimensions being determined by the crop_* fields). */ int apply_cropping; + + /** + * 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. + * + * This should be used if either the codec device does not require + * hardware frames or any that are used are to be 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. When hw_frames_ctx is set in get_format() for a decoder, this + * field will be ignored while decoding the associated stream segment, but + * may again be used on a following one after another get_format() call. + * + * For both encoders and decoders this field should be set before + * avcodec_open2() is called and must not be written to thereafter. + * + * Note that some decoders may require this field to be set initially in + * order to support hw_frames_ctx at all - in that case, all frames + * contexts used must be created on the same device. + */ + AVBufferRef *hw_device_ctx; } AVCodecContext; /** diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 06a5784046..ea4d5fa312 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -794,6 +794,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) avctx->nb_coded_side_data = 0; av_buffer_unref(&avctx->hw_frames_ctx); + av_buffer_unref(&avctx->hw_device_ctx); if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) av_opt_free(avctx->priv_data); diff --git a/libavcodec/version.h b/libavcodec/version.h index 2ade539c60..a6eda6a691 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 33 +#define LIBAVCODEC_VERSION_MINOR 34 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |