summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-02-24 17:05:11 +0000
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-02-24 17:05:11 +0000
commit7e49cdd12973ceea7545bf43966de563ce92bcf7 (patch)
treeb018d11ae7388ef6bec7bc91871bc6f1f09a321e
parentef9915a0e2435a6dc4562c6cf0727408e46c9172 (diff)
parent7b3214d0050613bd347a2e41c9f78ffb766da25e (diff)
downloadffmpeg-7e49cdd12973ceea7545bf43966de563ce92bcf7.tar.gz
Merge commit '7b3214d0050613bd347a2e41c9f78ffb766da25e'
* commit '7b3214d0050613bd347a2e41c9f78ffb766da25e': lavc: add a field for passing AVHWFramesContext to encoders Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r--doc/APIchanges3
-rw-r--r--libavcodec/avcodec.h12
-rw-r--r--libavcodec/utils.c13
-rw-r--r--libavcodec/version.h4
4 files changed, 30 insertions, 2 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 3c18454647..4e952a891d 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
API changes, most recent first:
+2016-xx-xx - lavc 57.25.0 - avcodec.h
+ Add AVCodecContext.hw_frames_ctx.
+
2016-xx-xx - lavfi 6.36.0 - avfilter.h
xxxxxxx avfilter.h - Add AVFilterLink.hw_frames_ctx.
xxxxxxx buffersrc.h - Add AVBufferSrcParameters and functions for handling it.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 80f8a66339..94d12ba5c8 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3361,6 +3361,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;
AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 9ef1e5dd2e..216e5439ea 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -34,6 +34,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/mem_internal.h"
@@ -1489,6 +1490,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;
+ }
+ }
}
avctx->pts_correction_num_faulty_pts =
@@ -2564,6 +2575,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);
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3580cf2ad7..52b8f2a51c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,8 +29,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 24
-#define LIBAVCODEC_VERSION_MICRO 106
+#define LIBAVCODEC_VERSION_MINOR 25
+#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \