Commit 324726e2 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi: only use vlc_va_conn_t between vaapi.c and vaapi_x11.c

Put shared connection to libva into a separate headerfile, so it
can be shared between vaapi.c and vaapi_x11.c. This cleansup headerfile
includes in dxva2.c and video.c, which have no interest in private
communication between vaapi.c and vaapi_x11.c.
parent d6c4a284
......@@ -9,6 +9,7 @@ libavcodec_plugin_la_SOURCES = \
fourcc.c \
chroma.h \
chroma.c \
vaapi.h \
vaapi.c \
vaapi_x11.c \
dxva2.c \
......
......@@ -44,12 +44,6 @@
#endif
#include "avcodec.h"
#ifdef HAVE_AVCODEC_VAAPI
# include <vlc_xlib.h>
# include <libavcodec/vaapi.h>
# include <va/va.h>
# include <va/va_x11.h>
#endif
#include "va.h"
#include "copy.h"
......
......@@ -43,24 +43,17 @@
# include <va/va_x11.h>
#endif
#include "va.h"
#include "vaapi.h"
#ifdef HAVE_AVCODEC_VAAPI
#define VA_SHARED_CONN
/* Global VAAPI connection state */
#ifdef VA_SHARED_CONN
static vlc_va_conn_t vlc_va_conn = { NULL, 0, 0, 0, 0 };
#endif
/* */
static vlc_va_conn_t *vlc_va_get_conn( void )
{
#ifndef VA_SHARED_CONN
return (vlc_va_conn_t *) calloc(1, sizeof(vlc_va_conn_t));
#else
return (vlc_va_conn_t *) &vlc_va_conn;
#endif
}
vlc_va_conn_t *vlc_va_Initialize( const char *display_name )
......@@ -68,13 +61,12 @@ vlc_va_conn_t *vlc_va_Initialize( const char *display_name )
/* connect global to caller */
vlc_va_conn_t *conn = vlc_va_get_conn();
assert(conn);
#ifdef VA_SHARED_CONN
if (conn->i_ref_count > 0)
{
conn->i_ref_count++;
return conn;
}
#endif
/* Create a VA display */
conn->p_display_x11 = XOpenDisplay(display_name);
if( !conn->p_display_x11 )
......@@ -86,9 +78,8 @@ vlc_va_conn_t *vlc_va_Initialize( const char *display_name )
if( vaInitialize(conn->p_display, &conn->i_version_major, &conn->i_version_minor) )
goto error;
#ifdef VA_SHARED_CONN
conn->i_ref_count++;
#endif
return conn;
error:
......@@ -98,25 +89,22 @@ error:
void vlc_va_Terminate( vlc_va_conn_t *conn )
{
assert(conn);
#ifdef VA_SHARED_CONN
conn->i_ref_count--;
if (conn->i_ref_count > 0)
return;
#endif
if( conn->p_display )
vaTerminate( conn->p_display );
if( conn->p_display_x11 )
XCloseDisplay( conn->p_display_x11 );
#ifndef VA_SHARED_CONN
free(conn);
#else
/* Reset values */
conn->p_display = 0;
conn->p_display_x11 = NULL;
conn->i_version_major = conn->i_version_minor = 0;
conn->i_ref_count = 0;
conn = NULL;
#endif
}
#endif
......@@ -66,34 +66,5 @@ static inline void vlc_va_Delete(vlc_va_t *va)
vlc_va_t *vlc_va_NewVaapi(vlc_object_t *obj, int codec_id);
vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id);
#ifdef HAVE_AVCODEC_VAAPI
typedef struct vlc_va_conn_t vlc_va_conn_t;
struct vlc_va_conn_t
{
Display *p_display_x11;
VADisplay p_display;
int i_version_major;
int i_version_minor;
int i_ref_count; /* for internal use only */
};
vlc_va_conn_t *vlc_va_Initialize(const char *display_name);
void vlc_va_Terminate(vlc_va_conn_t *conn);
typedef struct
{
VASurfaceID i_id;
int i_refcount;
unsigned int i_order;
vlc_mutex_t lock;
} vlc_va_surface_t;
struct picture_sys_t
{
vlc_va_surface_t *surface;
};
#endif
#endif
......@@ -44,6 +44,7 @@
# include <va/va_x11.h>
#endif
#include "va.h"
#include "vaapi.h"
#include "copy.h"
#ifdef HAVE_AVCODEC_VAAPI
......
/*****************************************************************************
* Copyright © 2011, M2X BV
* Author: Jean-Paul Saman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
****************************************************************************/
#ifdef HAVE_AVCODEC_VAAPI
typedef struct vlc_va_conn_t vlc_va_conn_t;
struct vlc_va_conn_t
{
Display *p_display_x11;
VADisplay p_display;
int i_version_major;
int i_version_minor;
int i_ref_count; /* for internal use only */
};
vlc_va_conn_t *vlc_va_Initialize(const char *display_name);
void vlc_va_Terminate(vlc_va_conn_t *conn);
typedef struct
{
VASurfaceID i_id;
int i_refcount;
unsigned int i_order;
vlc_mutex_t lock;
} vlc_va_surface_t;
struct picture_sys_t
{
vlc_va_surface_t *surface;
};
#endif
......@@ -50,6 +50,7 @@
#include <va/va.h>
#include <va/va_x11.h>
#include "va.h"
#include "vaapi.h"
#include <X11/Xutil.h>
......
......@@ -52,11 +52,6 @@
#include "avcodec.h"
#ifdef HAVE_AVCODEC_VAAPI
# include <vlc_xlib.h>
# include <va/va.h>
#endif
#include "va.h"
#if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
# define HAVE_AVCODEC_VA
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment