示例#1
0
文件: d3d11va.c 项目: DZW314/mpv
static struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view,
                                        int w, int h)
{
    if (!view)
        return NULL;
    struct d3d11va_surface *surface = talloc_zero(NULL, struct d3d11va_surface);

    surface->surface = view;
    ID3D11VideoDecoderOutputView_AddRef(surface->surface);
    ID3D11VideoDecoderOutputView_GetResource(
        surface->surface, (ID3D11Resource **)&surface->texture);

    D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC surface_desc;
    ID3D11VideoDecoderOutputView_GetDesc(surface->surface, &surface_desc);
    surface->subindex = surface_desc.Texture2D.ArraySlice;

    struct mp_image *mpi =
        mp_image_new_custom_ref(NULL, surface, d3d11va_release_img);
    if (!mpi)
        abort();

    mp_image_setfmt(mpi, IMGFMT_D3D11VA);
    mp_image_set_size(mpi, w, h);
    mpi->planes[0] = NULL;
    mpi->planes[1] = (void *)surface->texture;
    mpi->planes[2] = (void *)(intptr_t)surface->subindex;
    mpi->planes[3] = (void *)surface->surface;

    return mpi;
}
示例#2
0
static void DxDestroySurfaces(vlc_va_t *va)
{
    directx_sys_t *dx_sys = &va->sys->dx_sys;
    if (dx_sys->surface_count) {
        ID3D11Resource *p_texture;
        ID3D11VideoDecoderOutputView_GetResource( (ID3D11VideoDecoderOutputView*) dx_sys->hw_surface[0], &p_texture );
        ID3D11Resource_Release(p_texture);
        ID3D11Resource_Release(p_texture);
    }
}
示例#3
0
文件: d3d11va.c 项目: CarlOlson/mpv
struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view,
                                 int w, int h)
{
    if (!view)
        return NULL;
    struct d3d11va_surface *surface = talloc_zero(NULL, struct d3d11va_surface);

    surface->d3d11_dll = LoadLibrary(L"d3d11.dll");
    if (!surface->d3d11_dll)
        goto fail;

    surface->surface = view;
    ID3D11VideoDecoderOutputView_AddRef(surface->surface);
    ID3D11VideoDecoderOutputView_GetResource(
        surface->surface, (ID3D11Resource **)&surface->texture);

    struct mp_image *mpi = mp_image_new_custom_ref(
        &(struct mp_image){0}, surface, d3d11va_release_img);
示例#4
0
static picture_t *DxAllocPicture(vlc_va_t *va, const video_format_t *fmt, unsigned index)
{
    video_format_t src_fmt = *fmt;
    src_fmt.i_chroma = VLC_CODEC_D3D11_OPAQUE;
    picture_sys_t *pic_sys = calloc(1, sizeof(*pic_sys));
    if (unlikely(pic_sys == NULL))
        return NULL;

    pic_sys->decoder  = (ID3D11VideoDecoderOutputView*) va->sys->dx_sys.hw_surface[index];
    ID3D11VideoDecoderOutputView_GetResource(pic_sys->decoder, (ID3D11Resource**) &pic_sys->texture);
    pic_sys->context  = va->sys->d3dctx;

    picture_resource_t res = {
        .p_sys      = pic_sys,
        .pf_destroy = DestroyPicture,
    };
    picture_t *pic = picture_NewFromResource(&src_fmt, &res);
    if (unlikely(pic == NULL))
    {
        free(pic_sys);
        return NULL;
    }
    return pic;
}