diff --git a/doc/APIchanges b/doc/APIchanges index 7757227d8b..01510493c4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2014-08-09 API changes, most recent first: +2014-09-xx - xxxxxxx - lavc 56.2.0 - vdpau.h + Add av_vdpau_bind_context(). This function should now be used for creating + (or resetting) a AVVDPAUContext instead of av_vdpau_alloc_context(). + 2014-10-02 - xxxxxxx - lavc 56.2.100 - avcodec.h 2014-10-02 - xxxxxxx - lavu 54.9.100 - frame.h Add AV_FRAME_DATA_SKIP_SAMPLES. Add lavc CODEC_FLAG2_SKIP_MANUAL and diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 93fbc92a6b..875c331b54 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -85,6 +85,7 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, vdctx->width = UINT32_MAX; vdctx->height = UINT32_MAX; + hwctx->reset = 0; if (!hwctx) { vdctx->device = VDP_INVALID_HANDLE; @@ -151,12 +152,13 @@ int ff_vdpau_common_uninit(AVCodecContext *avctx) static int ff_vdpau_common_reinit(AVCodecContext *avctx) { + VDPAUHWContext *hwctx = avctx->hwaccel_context; VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data; if (vdctx->device == VDP_INVALID_HANDLE) return 0; /* Decoder created by user */ if (avctx->coded_width == vdctx->width && - avctx->coded_height == vdctx->height) + avctx->coded_height == vdctx->height && !hwctx->reset) return 0; avctx->hwaccel->uninit(avctx); @@ -639,4 +641,22 @@ AVVDPAUContext *av_vdpau_alloc_context(void) return av_mallocz(sizeof(AVVDPAUContext)); } +int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, + VdpGetProcAddress *get_proc, unsigned flags) +{ + VDPAUHWContext *hwctx; + + if (av_reallocp(&avctx->hwaccel_context, sizeof(*hwctx))) + return AVERROR(ENOMEM); + + hwctx = avctx->hwaccel_context; + + memset(hwctx, 0, sizeof(*hwctx)); + hwctx->context.decoder = VDP_INVALID_HANDLE; + hwctx->device = device; + hwctx->get_proc_address = get_proc; + hwctx->reset = 1; + return 0; +} + /* @}*/ diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h index e25cc42d7e..a8483d77f3 100644 --- a/libavcodec/vdpau.h +++ b/libavcodec/vdpau.h @@ -149,6 +149,26 @@ AVVDPAUContext *av_alloc_vdpaucontext(void); AVVDPAU_Render2 av_vdpau_hwaccel_get_render2(const AVVDPAUContext *); void av_vdpau_hwaccel_set_render2(AVVDPAUContext *, AVVDPAU_Render2); +/** + * Associate a VDPAU device with a codec context for hardware acceleration. + * This function is meant to be called from the get_format() codec callback, + * or earlier. It can also be called after avcodec_flush_buffers() to change + * the underlying VDPAU device mid-stream (e.g. to recover from non-transparent + * display preemption). + * + * @note get_format() must return AV_PIX_FMT_VDPAU if this function completes + * succesfully. + * + * @param avctx decoding context whose get_format() callback is invoked + * @param device VDPAU device handle to use for hardware acceleration + * @param get_proc_address VDPAU device driver + * @param flags for future use, must be zero + * + * @return 0 on success, an AVERROR code on failure. + */ +int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, + VdpGetProcAddress *get_proc_address, unsigned flags); + /** * Allocate an AVVDPAUContext. * diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h index 7b40865b6a..825da7dcd3 100644 --- a/libavcodec/vdpau_internal.h +++ b/libavcodec/vdpau_internal.h @@ -59,6 +59,7 @@ typedef struct VDPAUHWContext { AVVDPAUContext context; VdpDevice device; VdpGetProcAddress *get_proc_address; + char reset; } VDPAUHWContext; typedef struct VDPAUContext { diff --git a/libavcodec/version.h b/libavcodec/version.h index 0bbf453689..9520ba6c06 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 56 -#define LIBAVCODEC_VERSION_MINOR 2 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 3 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \