hwaccel: Loading vdp functions

This commit is contained in:
Martin Piatka
2018-03-09 13:18:02 +01:00
parent fb82287da2
commit 0c26bbbaec
3 changed files with 46 additions and 0 deletions

View File

@@ -143,3 +143,29 @@ hw_vdpau_frame *hw_vdpau_frame_from_avframe(hw_vdpau_frame *dst, const AVFrame *
return dst;
}
void vdp_funcs_init(vdp_funcs *f){
memset(f, 0, sizeof(vdp_funcs));
}
static void load_func(void **f, VdpFuncId f_id, VdpDevice dev, VdpGetProcAddress *get_proc_address){
VdpStatus st;
st = get_proc_address(dev, f_id, f);
if(st != VDP_STATUS_OK){
error_msg("Error loading vdpau function id: %u\n", f_id);
}
}
void vdp_funcs_load(vdp_funcs *f, VdpDevice device, VdpGetProcAddress *get_proc_address){
#define LOAD(f_point, f_id) (load_func((void **) (f_point), (f_id), device, get_proc_address))
LOAD(&f->videoSurfaceGetParameters, VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS);
LOAD(&f->videoMixerCreate, VDP_FUNC_ID_VIDEO_MIXER_CREATE);
LOAD(&f->videoMixerDestroy, VDP_FUNC_ID_VIDEO_MIXER_DESTROY);
LOAD(&f->videoMixerRender, VDP_FUNC_ID_VIDEO_MIXER_RENDER);
LOAD(&f->outputSurfaceCreate, VDP_FUNC_ID_OUTPUT_SURFACE_CREATE);
LOAD(&f->outputSurfaceDestroy, VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY);
LOAD(&f->outputSurfaceGetParameters, VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS);
LOAD(&f->getErrorString, VDP_FUNC_ID_GET_ERROR_STRING);
}

View File

@@ -85,6 +85,16 @@ void *hw_vdpau_frame_data_cpy(void *dst, const void *src, size_t n);
hw_vdpau_frame *hw_vdpau_frame_from_avframe(hw_vdpau_frame *dst, const AVFrame *src);
typedef struct vdp_funcs{
VdpVideoSurfaceGetParameters *videoSurfaceGetParameters;
VdpVideoMixerCreate *videoMixerCreate;
VdpVideoMixerDestroy *videoMixerDestroy;
VdpVideoMixerRender *videoMixerRender;;
} vdp_funcs;
void vdp_funcs_init(vdp_funcs *);
void vdp_funcs_load(vdp_funcs *, VdpDevice, VdpGetProcAddress *);
#ifdef __cplusplus
}
#endif

View File

@@ -213,6 +213,8 @@ struct state_vdpau {
void uninitInterop();
void uninit();
vdp_funcs funcs;
};
struct state_gl {
@@ -1183,6 +1185,11 @@ static void gl_render_vdpau(struct state_gl *s, char *data)
s->vdp.checkInterop(frame->hwctx.device, frame->hwctx.get_proc_address);
uint32_t width, height;
VdpChromaType ct;
VdpStatus st = s->vdp.funcs.videoSurfaceGetParameters(frame->surface, &ct, &width, &height);
printf("width: %u height: %u\n", width, height);
s->vdp.VDPAUUnregisterSurfaceNV(s->vdp.surf);
s->vdp.surf = s->vdp.VDPAURegisterVideoSurfaceNV((void *) frame->surface,
@@ -1214,6 +1221,8 @@ void state_vdpau::initInterop(VdpDevice device, VdpGetProcAddress *get_proc_addr
VDPAUInitNV((void *) device, (void *) get_proc_address);
this->device = device;
this->get_proc_address = get_proc_address;
vdp_funcs_load(&funcs, device, get_proc_address);
interopInitialized = true;
}
@@ -1236,6 +1245,7 @@ bool state_vdpau::init(){
glGenTextures(4, textures);
hw_vdpau_frame_init(&lastFrame);
return true;
}