On Tue, 2 Feb 2016 16:57:45 +0100
Anton Khirnov <[email protected]> wrote:
> ---
> libavcodec/avcodec.h | 12 ++++++++++++
> libavcodec/utils.c | 13 +++++++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index fe3366b..12458ab 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2979,6 +2979,18 @@ typedef struct AVCodecContext {
> AVPacketSideData *coded_side_data;
> int nb_coded_side_data;
>
> + /**
> + * Encoding only.
> + *
> + * For hardware encoders configured to use a hwaccel pixel format, this
> + * field should be set by the caller to a reference to the
> AVHWFramesContext
> + * describing input frames. AVHWFramesContext.format must be equal to
> + * AVCodecContext.pix_fmt.
> + *
> + * This field should be set before avcodec_open2() is called and is
> + * afterwards owned and managed by libavcodec.
> + */
> + AVBufferRef *hw_frames_ctx;
> } AVCodecContext;
>
> /**
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index e06ee66..94ec1e8 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -32,6 +32,7 @@
> #include "libavutil/channel_layout.h"
> #include "libavutil/crc.h"
> #include "libavutil/frame.h"
> +#include "libavutil/hwcontext.h"
> #include "libavutil/internal.h"
> #include "libavutil/mathematics.h"
> #include "libavutil/pixdesc.h"
> @@ -1059,6 +1060,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
> avctx->time_base.den);
> goto free_and_end;
> }
> +
> + if (avctx->hw_frames_ctx) {
> + AVHWFramesContext *frames_ctx =
> (AVHWFramesContext*)avctx->hw_frames_ctx->data;
> + if (frames_ctx->format != avctx->pix_fmt) {
> + av_log(avctx, AV_LOG_ERROR,
> + "Mismatching AVCodecContext.pix_fmt and
> AVHWFramesContext.format\n");
> + ret = AVERROR(EINVAL);
> + goto free_and_end;
> + }
> + }
> }
>
> if (avctx->codec->init && !(avctx->active_thread_type &
> FF_THREAD_FRAME)) {
> @@ -1639,6 +1650,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
> av_freep(&avctx->coded_side_data);
> avctx->nb_coded_side_data = 0;
>
> + av_buffer_unref(&avctx->hw_frames_ctx);
> +
> if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
> av_opt_free(avctx->priv_data);
> av_opt_free(avctx);
Fine with me.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel