vf_vavpp: use libavutil hw frames API for frame pool and upload

Another step to get rid of the legacy crap in vaapi.c. (Most is still
kept, because it's in use by vo_vaapi.c.)
This commit is contained in:
wm4
2017-09-29 17:54:21 +02:00
parent 1f79b26529
commit d462a2a321
5 changed files with 121 additions and 51 deletions

View File

@@ -309,3 +309,37 @@ struct mp_image *mp_image_hw_download(struct mp_image *src,
}
return dst;
}
bool mp_image_hw_upload(struct mp_image *hw_img, struct mp_image *src)
{
if (hw_img->w != src->w || hw_img->h != src->h)
return false;
if (!hw_img->hwctx || src->hwctx)
return false;
bool ok = false;
AVFrame *dstav = NULL;
AVFrame *srcav = NULL;
// This means the destination image will not be "writable", which would be
// a pain if Libav enforced this - fortunately it doesn't care. We can
// transfer data to it even if there are multiple refs.
dstav = mp_image_to_av_frame(hw_img);
if (!dstav)
goto done;
srcav = mp_image_to_av_frame(src);
if (!srcav)
goto done;
ok = av_hwframe_transfer_data(dstav, srcav, 0) >= 0;
done:
av_frame_unref(srcav);
av_frame_unref(dstav);
if (ok)
mp_image_copy_attributes(hw_img, src);
return ok;
}