mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
vdpau: store vdpau function pointers in a local structure
This commit is contained in:
parent
29d0c5bdd8
commit
584b000583
4 changed files with 43 additions and 61 deletions
|
@ -12,7 +12,6 @@ libgstvdpau_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
gstvdpaudecoder.h \
|
gstvdpaudecoder.h \
|
||||||
vdpauvariables.h \
|
|
||||||
gstvdpaumpegdecoder.h \
|
gstvdpaumpegdecoder.h \
|
||||||
mpegutil.h
|
mpegutil.h
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <vdpau/vdpau_x11.h>
|
#include <vdpau/vdpau_x11.h>
|
||||||
|
|
||||||
#include "vdpauvariables.h"
|
|
||||||
#include "gstvdpaudecoder.h"
|
#include "gstvdpaudecoder.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_vdpaudecoder_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_vdpaudecoder_debug);
|
||||||
|
@ -71,6 +70,10 @@ gboolean
|
||||||
gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec,
|
gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec,
|
||||||
VdpVideoSurface surface)
|
VdpVideoSurface surface)
|
||||||
{
|
{
|
||||||
|
VdpauFunctions *f;
|
||||||
|
|
||||||
|
f = dec->functions;
|
||||||
|
|
||||||
switch (dec->format) {
|
switch (dec->format) {
|
||||||
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
|
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
|
||||||
{
|
{
|
||||||
|
@ -92,7 +95,7 @@ gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec,
|
||||||
data[2] = data[1] + dec->height * dec->width / 4;
|
data[2] = data[1] + dec->height * dec->width / 4;
|
||||||
|
|
||||||
status =
|
status =
|
||||||
vdp_video_surface_get_bits_ycbcr (surface, VDP_YCBCR_FORMAT_YV12,
|
f->vdp_video_surface_get_bits_ycbcr (surface, VDP_YCBCR_FORMAT_YV12,
|
||||||
(void *) data, NULL);
|
(void *) data, NULL);
|
||||||
if (G_UNLIKELY (status != VDP_STATUS_OK))
|
if (G_UNLIKELY (status != VDP_STATUS_OK))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -151,9 +154,12 @@ static VdpauFormats formats[6] = {
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_vdpaudecoder_get_vdpau_support (GstVdpauDecoder * dec)
|
gst_vdpaudecoder_get_vdpau_support (GstVdpauDecoder * dec)
|
||||||
{
|
{
|
||||||
|
VdpauFunctions *f;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
f = dec->functions;
|
||||||
|
|
||||||
caps = gst_caps_new_empty ();
|
caps = gst_caps_new_empty ();
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
|
@ -161,7 +167,8 @@ gst_vdpaudecoder_get_vdpau_support (GstVdpauDecoder * dec)
|
||||||
VdpBool is_supported;
|
VdpBool is_supported;
|
||||||
guint32 max_w, max_h;
|
guint32 max_w, max_h;
|
||||||
|
|
||||||
status = vdp_video_surface_query_capabilities (dec->device, chroma_types[i],
|
status =
|
||||||
|
f->vdp_video_surface_query_capabilities (dec->device, chroma_types[i],
|
||||||
&is_supported, &max_w, &max_h);
|
&is_supported, &max_w, &max_h);
|
||||||
|
|
||||||
if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_CHROMA_TYPE) {
|
if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_CHROMA_TYPE) {
|
||||||
|
@ -179,7 +186,7 @@ gst_vdpaudecoder_get_vdpau_support (GstVdpauDecoder * dec)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
status =
|
status =
|
||||||
vdp_video_surface_query_ycbcr_capabilities (dec->device,
|
f->vdp_video_surface_query_ycbcr_capabilities (dec->device,
|
||||||
formats[j].chroma_type, formats[j].format, &is_supported);
|
formats[j].chroma_type, formats[j].format, &is_supported);
|
||||||
if (status != VDP_STATUS_OK
|
if (status != VDP_STATUS_OK
|
||||||
&& status != VDP_STATUS_INVALID_Y_CB_CR_FORMAT) {
|
&& status != VDP_STATUS_INVALID_Y_CB_CR_FORMAT) {
|
||||||
|
@ -215,6 +222,7 @@ gst_vdpaudecoder_init_vdpau (GstVdpauDecoder * dec)
|
||||||
{
|
{
|
||||||
Display *display;
|
Display *display;
|
||||||
int screen;
|
int screen;
|
||||||
|
VdpauFunctions *f;
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
|
@ -226,10 +234,12 @@ gst_vdpaudecoder_init_vdpau (GstVdpauDecoder * dec)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f = dec->functions;
|
||||||
|
|
||||||
screen = DefaultScreen (display);
|
screen = DefaultScreen (display);
|
||||||
status =
|
status =
|
||||||
vdp_device_create_x11 (display, screen, &dec->device,
|
vdp_device_create_x11 (display, screen, &dec->device,
|
||||||
&vdp_get_proc_address);
|
&f->vdp_get_proc_address);
|
||||||
if (status != VDP_STATUS_OK) {
|
if (status != VDP_STATUS_OK) {
|
||||||
GST_ELEMENT_ERROR (dec, RESOURCE, READ, ("Could not initialise VDPAU"),
|
GST_ELEMENT_ERROR (dec, RESOURCE, READ, ("Could not initialise VDPAU"),
|
||||||
("Could not create VDPAU device"));
|
("Could not create VDPAU device"));
|
||||||
|
@ -239,21 +249,21 @@ gst_vdpaudecoder_init_vdpau (GstVdpauDecoder * dec)
|
||||||
}
|
}
|
||||||
XCloseDisplay (display);
|
XCloseDisplay (display);
|
||||||
|
|
||||||
vdp_get_proc_address (dec->device,
|
f->vdp_get_proc_address (dec->device,
|
||||||
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
|
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
|
||||||
(void **) &vdp_video_surface_query_capabilities);
|
(void **) &f->vdp_video_surface_query_capabilities);
|
||||||
vdp_get_proc_address (dec->device,
|
f->vdp_get_proc_address (dec->device,
|
||||||
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
|
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
|
||||||
(void **) &vdp_video_surface_query_ycbcr_capabilities);
|
(void **) &f->vdp_video_surface_query_ycbcr_capabilities);
|
||||||
vdp_get_proc_address (dec->device,
|
f->vdp_get_proc_address (dec->device,
|
||||||
VDP_FUNC_ID_DEVICE_DESTROY, (void **) &vdp_device_destroy);
|
VDP_FUNC_ID_DEVICE_DESTROY, (void **) &f->vdp_device_destroy);
|
||||||
vdp_get_proc_address (dec->device,
|
f->vdp_get_proc_address (dec->device,
|
||||||
VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR,
|
VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR,
|
||||||
(void **) &vdp_video_surface_get_bits_ycbcr);
|
(void **) &f->vdp_video_surface_get_bits_ycbcr);
|
||||||
|
|
||||||
caps = gst_vdpaudecoder_get_vdpau_support (dec);
|
caps = gst_vdpaudecoder_get_vdpau_support (dec);
|
||||||
if (!caps) {
|
if (!caps) {
|
||||||
vdp_device_destroy (dec->device);
|
f->vdp_device_destroy (dec->device);
|
||||||
dec->device = 0;
|
dec->device = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -402,6 +412,8 @@ gst_vdpaudecoder_init (GstVdpauDecoder * dec, GstVdpauDecoderClass * klass)
|
||||||
dec->width = 0;
|
dec->width = 0;
|
||||||
dec->format = 0;
|
dec->format = 0;
|
||||||
|
|
||||||
|
dec->functions = g_slice_new0 (VdpauFunctions);
|
||||||
|
|
||||||
dec->src = gst_pad_new_from_static_template (&src_template, "src");
|
dec->src = gst_pad_new_from_static_template (&src_template, "src");
|
||||||
gst_pad_set_getcaps_function (dec->src, gst_vdpaudecoder_src_getcaps);
|
gst_pad_set_getcaps_function (dec->src, gst_vdpaudecoder_src_getcaps);
|
||||||
gst_element_add_pad (GST_ELEMENT (dec), dec->src);
|
gst_element_add_pad (GST_ELEMENT (dec), dec->src);
|
||||||
|
|
|
@ -38,6 +38,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstVdpauDecoder GstVdpauDecoder;
|
typedef struct _GstVdpauDecoder GstVdpauDecoder;
|
||||||
typedef struct _GstVdpauDecoderClass GstVdpauDecoderClass;
|
typedef struct _GstVdpauDecoderClass GstVdpauDecoderClass;
|
||||||
|
typedef struct _VdpauFunctions VdpauFunctions;
|
||||||
|
|
||||||
struct _GstVdpauDecoder {
|
struct _GstVdpauDecoder {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
@ -45,6 +46,8 @@ struct _GstVdpauDecoder {
|
||||||
gchar *display;
|
gchar *display;
|
||||||
VdpDevice device;
|
VdpDevice device;
|
||||||
|
|
||||||
|
VdpauFunctions *functions;
|
||||||
|
|
||||||
GstPad *src;
|
GstPad *src;
|
||||||
GstPad *sink;
|
GstPad *sink;
|
||||||
|
|
||||||
|
@ -62,6 +65,20 @@ struct _GstVdpauDecoderClass {
|
||||||
gboolean (*set_caps) (GstVdpauDecoder *dec, GstCaps *caps);
|
gboolean (*set_caps) (GstVdpauDecoder *dec, GstCaps *caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _VdpauFunctions {
|
||||||
|
VdpGetProcAddress *vdp_get_proc_address;
|
||||||
|
|
||||||
|
VdpVideoSurfaceQueryCapabilities *vdp_video_surface_query_capabilities;
|
||||||
|
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *vdp_video_surface_query_ycbcr_capabilities;
|
||||||
|
VdpVideoSurfaceGetBitsYCbCr *vdp_video_surface_get_bits_ycbcr;
|
||||||
|
|
||||||
|
VdpDeviceDestroy *vdp_device_destroy;
|
||||||
|
|
||||||
|
VdpDecoderCreate *vdp_decoder_create;
|
||||||
|
VdpDecoderDestroy *vdp_decoder_destroy;
|
||||||
|
VdpDecoderRender *vdp_decoder_render;
|
||||||
|
};
|
||||||
|
|
||||||
GType gst_vdpaudecoder_get_type (void);
|
GType gst_vdpaudecoder_get_type (void);
|
||||||
|
|
||||||
gboolean gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec, VdpVideoSurface surface);
|
gboolean gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec, VdpVideoSurface surface);
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
#include <vdpau/vdpau.h>
|
|
||||||
|
|
||||||
static VdpVideoSurfaceQueryCapabilities *vdp_video_surface_query_capabilities;
|
|
||||||
static VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *vdp_video_surface_query_ycbcr_capabilities;
|
|
||||||
static VdpVideoSurfaceGetBitsYCbCr *vdp_video_surface_get_bits_ycbcr;
|
|
||||||
|
|
||||||
static VdpGetProcAddress *vdp_get_proc_address;
|
|
||||||
static VdpDeviceDestroy *vdp_device_destroy;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static VdpVideoSurfaceCreate *vdp_video_surface_create;
|
|
||||||
static VdpVideoSurfaceDestroy *vdp_video_surface_destroy;
|
|
||||||
|
|
||||||
static VdpGetErrorString *vdp_get_error_string;
|
|
||||||
|
|
||||||
static VdpVideoSurfacePutBitsYCbCr *vdp_video_surface_put_bits_y_cb_cr;
|
|
||||||
static VdpOutputSurfacePutBitsNative *vdp_output_surface_put_bits_native;
|
|
||||||
|
|
||||||
static VdpOutputSurfaceCreate *vdp_output_surface_create;
|
|
||||||
static VdpOutputSurfaceDestroy *vdp_output_surface_destroy;
|
|
||||||
|
|
||||||
static VdpVideoMixerCreate *vdp_video_mixer_create;
|
|
||||||
static VdpVideoMixerDestroy *vdp_video_mixer_destroy;
|
|
||||||
static VdpVideoMixerRender *vdp_video_mixer_render;
|
|
||||||
static VdpVideoMixerSetFeatureEnables *vdp_video_mixer_set_feature_enables;
|
|
||||||
static VdpVideoMixerSetAttributeValues *vdp_video_mixer_set_attribute_values;
|
|
||||||
|
|
||||||
static VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy;
|
|
||||||
static VdpPresentationQueueCreate *vdp_presentation_queue_create;
|
|
||||||
static VdpPresentationQueueDestroy *vdp_presentation_queue_destroy;
|
|
||||||
static VdpPresentationQueueDisplay *vdp_presentation_queue_display;
|
|
||||||
static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle;
|
|
||||||
static VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11;
|
|
||||||
|
|
||||||
static VdpOutputSurfaceRenderOutputSurface *vdp_output_surface_render_output_surface;
|
|
||||||
static VdpOutputSurfacePutBitsIndexed *vdp_output_surface_put_bits_indexed;
|
|
||||||
static VdpOutputSurfaceRenderBitmapSurface *vdp_output_surface_render_bitmap_surface;
|
|
||||||
|
|
||||||
static VdpBitmapSurfaceCreate *vdp_bitmap_surface_create;
|
|
||||||
static VdpBitmapSurfaceDestroy *vdp_bitmap_surface_destroy;
|
|
||||||
static VdpBitmapSurfacePutBitsNative *vdp_bitmap_surface_putbits_native;
|
|
||||||
|
|
||||||
static VdpDecoderCreate *vdp_decoder_create;
|
|
||||||
static VdpDecoderDestroy *vdp_decoder_destroy;
|
|
||||||
static VdpDecoderRender *vdp_decoder_render;
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue