}
}
+int av_vdpau_get_surface_parameters(AVCodecContext *avctx,
+ VdpChromaType *type,
+ uint32_t *width, uint32_t *height)
+{
+ VdpChromaType t;
+ uint32_t w = avctx->coded_width;
+ uint32_t h = avctx->coded_height;
+
+ /* See <vdpau/vdpau.h> for per-type alignment constraints. */
+ switch (avctx->sw_pix_fmt) {
+ case AV_PIX_FMT_YUV420P:
+ case AV_PIX_FMT_YUVJ420P:
+ t = VDP_CHROMA_TYPE_420;
+ w = (w + 1) & ~1;
+ h = (h + 3) & ~3;
+ break;
+ case AV_PIX_FMT_YUV422P:
+ case AV_PIX_FMT_YUVJ422P:
+ t = VDP_CHROMA_TYPE_422;
+ w = (w + 1) & ~1;
+ h = (h + 1) & ~1;
+ break;
+ case AV_PIX_FMT_YUV444P:
+ case AV_PIX_FMT_YUVJ444P:
+ t = VDP_CHROMA_TYPE_444;
+ h = (h + 1) & ~1;
+ break;
+ default:
+ return AVERROR(ENOSYS);
+ }
+
+ if (type)
+ *type = t;
+ if (width)
+ *width = w;
+ if (height)
+ *height = h;
+ return 0;
+}
+
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
int level)
{
VdpStatus status;
VdpBool supported;
uint32_t max_level, max_mb, max_width, max_height;
- /* See vdpau/vdpau.h for alignment constraints. */
- uint32_t width = (avctx->coded_width + 1) & ~1;
- uint32_t height = (avctx->coded_height + 3) & ~3;
+ VdpChromaType type;
+ uint32_t width;
+ uint32_t height;
vdctx->width = UINT32_MAX;
vdctx->height = UINT32_MAX;
else if (level < 0)
return AVERROR(ENOTSUP);
+ if (av_vdpau_get_surface_parameters(avctx, &type, &width, &height))
+ return AVERROR(ENOSYS);
+
status = vdctx->get_proc_address(vdctx->device,
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
&func);
else
surface_query_caps = func;
- status = surface_query_caps(vdctx->device, VDP_CHROMA_TYPE_420, &supported,
+ status = surface_query_caps(vdctx->device, type, &supported,
&max_width, &max_height);
if (status != VDP_STATUS_OK)
return vdpau_error(status);
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device,
VdpGetProcAddress *get_proc_address, unsigned flags);
+/**
+ * Gets the parameters to create an adequate VDPAU video surface for the codec
+ * context using VDPAU hardware decoding acceleration.
+ *
+ * @note Behavior is undefined if the context was not successfully bound to a
+ * VDPAU device using av_vdpau_bind_context().
+ *
+ * @param avctx the codec context being used for decoding the stream
+ * @param type storage space for the VDPAU video surface chroma type
+ * (or NULL to ignore)
+ * @param width storage space for the VDPAU video surface pixel width
+ * (or NULL to ignore)
+ * @param height storage space for the VDPAU video surface pixel height
+ * (or NULL to ignore)
+ *
+ * @return 0 on success, a negative AVERROR code on failure.
+ */
+int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type,
+ uint32_t *width, uint32_t *height);
+
/**
* Allocate an AVVDPAUContext.
*