Quoting Rémi Denis-Courmont (2015-12-21 18:07:24)
> Le 2015-12-20 21:59, Anton Khirnov a écrit :
> > +
> > +static const VDPAUPixFmtMap pix_fmts_422[] = {
> > + { VDP_YCBCR_FORMAT_YV12, AV_PIX_FMT_YUV422P },
> > + { VDP_YCBCR_FORMAT_UYVY, AV_PIX_FMT_UYVY422 },
> > + { VDP_YCBCR_FORMAT_YUYV, AV_PIX_FMT_YUYV422 },
> > + { 0, AV_PIX_FMT_NONE, },
>
> NV12 really meaning NV16 is possible.
>
> > +};
> > +
> > +static const VDPAUPixFmtMap pix_fmts_444[] = {
> > + { VDP_YCBCR_FORMAT_YV12, AV_PIX_FMT_YUV444P },
> > + { 0, AV_PIX_FMT_NONE, },
> > +};
>
> Similarly, NV12 => NV24.
>
We don't seem to have that. Guess I'll have to add it then.
> > +static int vdpau_init_pixmfts(AVHWFramesContext *ctx)
> > +{
> > + AVVDPAUFramesContext *hwctx = ctx->hwctx;
> > + VDPAUFramesContext *priv = ctx->internal->priv;
> > + int i;
> > +
> > + for (i = 0; i < FF_ARRAY_ELEMS(priv->pix_fmts); i++) {
> > + const VDPAUPixFmtMap *map = vdpau_pix_fmts[i].map;
> > + int nb_pix_fmts;
> > +
> > + nb_pix_fmts = count_pixfmts(map);
> > + priv->pix_fmts[i] = av_malloc_array(nb_pix_fmts + 1,
> > sizeof(*priv->pix_fmts[i]));
> > + if (!priv->pix_fmts[i])
> > + return AVERROR(ENOMEM);
> > +
> > + nb_pix_fmts = 0;
> > + while (map->pix_fmt != AV_PIX_FMT_NONE) {
> > + VdpBool supported;
> > + VdpStatus err = priv->get_transfer_caps(hwctx->device,
> > vdpau_pix_fmts[i].chroma_type,
> > + map->vdpau_fmt,
> > &supported);
> > + if (err != VDP_STATUS_OK)
> > + return AVERROR_UNKNOWN;
>
> I'd just skip the format instead of failing.
>
changed locally
> > +static int vdpau_retrieve_data(AVHWFramesContext *ctx, AVFrame *dst,
> > + const AVFrame *src)
> > +{
> > + VDPAUFramesContext *priv = ctx->internal->priv;
> > + VdpVideoSurface surf =
> > (VdpVideoSurface)(uintptr_t)src->data[3];
> > +
> > + const VDPAUPixFmtMap *map;
> > + VdpChromaType chroma_type;
> > + VdpYCbCrFormat vdpau_format;
> > + VdpStatus err;
> > + uint32_t width, height;
> > + int i, idx;
> > +
> > + err = priv->get_surf_parameters(surf, &chroma_type, &width,
> > &height);
> > + if (err != VDP_STATUS_OK) {
> > + av_log(ctx, AV_LOG_ERROR, "Error querying the surface
> > parameters\n");
> > + return AVERROR_UNKNOWN;
> > + }
> > + for (i = 0; i < FF_ARRAY_ELEMS(vdpau_pix_fmts); i++) {
> > + if (vdpau_pix_fmts[i].chroma_type == chroma_type) {
> > + idx = i;
> > + break;
> > + }
> > + }
> > + if (idx < 0) {
> > + av_log(ctx, AV_LOG_ERROR, "Unsupported chroma type: %d\n",
> > chroma_type);
> > + return AVERROR(ENOSYS);
> > + }
> > + map = vdpau_pix_fmts[idx].map;
> > +
> > + for (i = 0; map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
> > + if (map[i].pix_fmt == dst->format) {
> > + vdpau_format = map[i].vdpau_fmt;
> > + break;
> > + }
> > + }
> > + if (map[i].pix_fmt == AV_PIX_FMT_NONE) {
> > + av_log(ctx, AV_LOG_ERROR,
> > + "Unsupported target pixel format: %s\n",
> > + av_get_pix_fmt_name(dst->format));
> > + return AVERROR(EINVAL);
> > + }
> > +
> > + err = priv->get_data(surf, vdpau_format, (void * const
> > *)dst->data,
>
> Suspicious cast.
>
> > + dst->linesize);
>
> I am not sure but that might be a bit naive w.r.t. potential alignment
> requirements.
Indeed, handled better locally.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel