Skip to content

Commit

Permalink
Apply patches from vdpau-video_0.7.4-7ubuntu1~ppa1~18.10.1.debian.tar…
Browse files Browse the repository at this point in the history
….xz and workaround compile issue: conflicting types for ‘vdpau_CreateSurfaceFromV4L2Buf’
  • Loading branch information
xtknight committed Dec 21, 2019
1 parent af8bef5 commit 1d22f93
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/object_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ object_heap_destroy(object_heap_p heap)
ASSERT(obj->next_free != ALLOCATED);
}

for (i = 0; i < heap->heap_size / heap->heap_increment; i++) {
free(heap->bucket[i]);
if (heap->bucket) {
for (i = 0; i < heap->heap_size / heap->heap_increment; i++) {
free(heap->bucket[i]);
}
}

pthread_mutex_destroy(&heap->mutex);
Expand Down
7 changes: 7 additions & 0 deletions src/utils_glx.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int
typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int);
#endif

#if GL_GLEXT_VERSION >= 85
/* XXX: PFNGLMULTITEXCOORD2FPROC got out of the GL_VERSION_1_3_DEPRECATED
block and is not defined if GL_VERSION_1_3 is defined in <GL/gl.h>
Redefine the type here as an interim solution */
typedef void (*PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
#endif

#ifndef GL_FRAMEBUFFER_BINDING
#define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/vdpau_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ vdpau_EndPicture(
driver_data,
obj_context->vdp_decoder,
obj_surface->vdp_surface,
(VdpPictureInfo)&obj_context->vdp_picture_info,
(VdpPictureInfo*)&obj_context->vdp_picture_info,
obj_context->vdp_bitstream_buffers_count,
obj_context->vdp_bitstream_buffers
);
Expand Down
13 changes: 9 additions & 4 deletions src/vdpau_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ vdpau_common_Terminate(vdpau_driver_data_t *driver_data)
}
vdpau_gate_exit(driver_data);

if (driver_data->vdp_dpy) {
if (!driver_data->x_fallback && driver_data->vdp_dpy) {
XCloseDisplay(driver_data->vdp_dpy);
driver_data->vdp_dpy = NULL;
}
Expand All @@ -187,9 +187,14 @@ vdpau_common_Initialize(vdpau_driver_data_t *driver_data)
/* Create a dedicated X11 display for VDPAU purposes */
const char * const x11_dpy_name = XDisplayString(driver_data->x11_dpy);
driver_data->vdp_dpy = XOpenDisplay(x11_dpy_name);
if (!driver_data->vdp_dpy)
return VA_STATUS_ERROR_UNKNOWN;

/* Fallback to existing X11 display */
driver_data->x_fallback = false;
if (!driver_data->vdp_dpy) {
driver_data->x_fallback = true;
driver_data->vdp_dpy = driver_data->x11_dpy;
printf("Failed to create dedicated X11 display!\n");
}

VdpStatus vdp_status;
driver_data->vdp_device = VDP_INVALID_HANDLE;
vdp_status = vdp_device_create_x11(
Expand Down
2 changes: 2 additions & 0 deletions src/vdpau_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef VDPAU_DRIVER_H
#define VDPAU_DRIVER_H

#include <stdbool.h>
#include <va/va_backend.h>
#include "vaapi_compat.h"
#include "vdpau_gate.h"
Expand Down Expand Up @@ -100,6 +101,7 @@ struct vdpau_driver_data {
uint64_t va_display_attrs_mtime[VDPAU_MAX_DISPLAY_ATTRIBUTES];
unsigned int va_display_attrs_count;
char va_vendor[256];
bool x_fallback;
};

typedef struct object_config *object_config_p;
Expand Down
8 changes: 8 additions & 0 deletions src/vdpau_driver_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ struct VA_DRIVER_VTABLE {
int *num_attribs /* out */
);

VAStatus (*vaQuerySurfaceAttributes) (
VADisplay dpy,
VAConfigID config_id,
VASurfaceAttrib *attrib_list, /* out */
unsigned int *num_attribs /* out */
);

VAStatus (*vaCreateSurfaces) (
VADriverContextP ctx,
int width,
Expand Down Expand Up @@ -589,6 +596,7 @@ static VAStatus FUNC(Initialize)(VA_DRIVER_CONTEXT_P ctx)
vtable->vaCreateConfig = vdpau_CreateConfig;
vtable->vaDestroyConfig = vdpau_DestroyConfig;
vtable->vaGetConfigAttributes = vdpau_GetConfigAttributes;
vtable->vaQuerySurfaceAttributes = vdpau_QuerySurfaceAttributes;
vtable->vaCreateSurfaces = vdpau_CreateSurfaces;
vtable->vaDestroySurfaces = vdpau_DestroySurfaces;
vtable->vaCreateContext = vdpau_CreateContext;
Expand Down
2 changes: 0 additions & 2 deletions src/vdpau_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ const char *string_of_VABufferType(VABufferType type)
_(VAEncSequenceParameterBufferType);
_(VAEncPictureParameterBufferType);
_(VAEncSliceParameterBufferType);
_(VAEncH264VUIBufferType);
_(VAEncH264SEIBufferType);
#endif
#if VA_CHECK_VERSION(0,31,1)
_(VAQMatrixBufferType);
Expand Down
48 changes: 48 additions & 0 deletions src/vdpau_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,54 @@ int surface_remove_association(
return -1;
}

// vaQuerySurfaceAttributes
VAStatus
vdpau_QuerySurfaceAttributes(
VADriverContextP ctx,
VAConfigID config_id,
VASurfaceAttrib *attrib_list,
unsigned int *num_attribs
)
{
VDPAU_DRIVER_DATA_INIT;

object_config_p obj_config;
if ((obj_config = VDPAU_CONFIG(config_id)) == NULL)
return VA_STATUS_ERROR_INVALID_CONFIG;

if (!attrib_list && !num_attribs)
return VA_STATUS_ERROR_INVALID_PARAMETER;

if (!attrib_list) {
*num_attribs = 2;
return VA_STATUS_SUCCESS;
}

if (*num_attribs < 2) {
*num_attribs = 2;
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
}

VdpDecoderProfile vdp_profile;
uint32_t max_width, max_height;
vdp_profile = get_VdpDecoderProfile(obj_config->profile);
if (!get_max_surface_size(driver_data, vdp_profile, &max_width, &max_height))
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;

if (attrib_list) {
attrib_list[0].type = VASurfaceAttribMaxWidth;
attrib_list[0].flags = VA_SURFACE_ATTRIB_GETTABLE;
attrib_list[0].value.type = VAGenericValueTypeInteger;
attrib_list[0].value.value.i = max_width;
attrib_list[1].type = VASurfaceAttribMaxHeight;
attrib_list[1].flags = VA_SURFACE_ATTRIB_GETTABLE;
attrib_list[1].value.type = VAGenericValueTypeInteger;
attrib_list[1].value.value.i = max_height;
}

return VA_STATUS_SUCCESS;
}

// vaDestroySurfaces
VAStatus
vdpau_DestroySurfaces(
Expand Down
14 changes: 12 additions & 2 deletions src/vdpau_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ vdpau_QueryConfigAttributes(
int *num_attribs
) attribute_hidden;

// vaQuerySurfaceAttributes
VAStatus
vdpau_QuerySurfaceAttributes(
VADriverContextP ctx,
VAConfigID config_id,
VASurfaceAttrib *attrib_list,
unsigned int *num_attribs
) attribute_hidden;

// vaCreateSurfaces
VAStatus
vdpau_CreateSurfaces(
Expand Down Expand Up @@ -270,14 +279,15 @@ vdpau_CreateSurfaceFromCIFrame(
) attribute_hidden;

// vaCreateSurfaceFromV4L2Buf
VAStatus
// XXX: compile problem?
/*VAStatus
vdpau_CreateSurfaceFromV4L2Buf(
VADriverContextP ctx,
int v4l2_fd,
struct v4l2_format *v4l2_fmt,
struct v4l2_buffer *v4l2_buf,
VASurfaceID *surface
) attribute_hidden;
) attribute_hidden;*/

// vaCopySurfaceToBuffer
VAStatus
Expand Down

0 comments on commit 1d22f93

Please sign in to comment.