} vlc_va_surface_t;
#define VA_DXVA2_MAX_SURFACE_COUNT (64)
-typedef struct
+struct vlc_va_sys_t
{
- /* */
- vlc_va_t va;
-
- /* */
vlc_object_t *log;
int codec_id;
int width;
vlc_va_surface_t surface[VA_DXVA2_MAX_SURFACE_COUNT];
LPDIRECT3DSURFACE9 hw_surface[VA_DXVA2_MAX_SURFACE_COUNT];
-} vlc_va_dxva2_t;
+};
+typedef struct vlc_va_sys_t vlc_va_dxva2_t;
/* */
-static vlc_va_dxva2_t *vlc_va_dxva2_Get(void *external)
+static vlc_va_dxva2_t *vlc_va_dxva2_Get(vlc_va_t *external)
{
- assert(external == (void*)(&((vlc_va_dxva2_t*)external)->va));
- return external;
+ vlc_va_dxva2_t *va = external->sys;
+ assert(VLC_OBJECT(external) == va->log);
+ return va;
}
/* */
if (va->hd3d9_dll)
FreeLibrary(va->hd3d9_dll);
- free(va->va.description);
+ free(external->description);
free(va);
}
-vlc_va_t *vlc_va_New(vlc_object_t *log, int pixfmt, int codec_id,
- const es_format_t *fmt)
+int vlc_va_New(vlc_va_t *log, int pixfmt, int codec_id,
+ const es_format_t *fmt)
{
if( pixfmt != PIX_FMT_DXVA2_VLD )
return NULL;
if (!va)
return NULL;
+ external->sys = va;
/* */
- va->log = log;
+ va->log = VLC_OBJECT(external);
va->codec_id = codec_id;
(void) fmt;
}
/* TODO print the hardware name/vendor for debugging purposes */
- va->va.description = DxDescribe(va);
- va->va.setup = Setup;
- va->va.get = Get;
- va->va.release = Release;
- va->va.extract = Extract;
- va->va.close = Close;
- return &va->va;
+ external->description = DxDescribe(va);
+ external->setup = Setup;
+ external->get = Get;
+ external->release = Release;
+ external->extract = Extract;
+ external->close = Close;
+ return VLC_SUCCESS;
error:
- Close(&va->va);
- return NULL;
+ Close(va);
+ return VLC_EGENERIC;
}
/* */
} vlc_va_surface_t;
-typedef struct
+struct vlc_va_sys_t
{
- vlc_va_t va;
-
- vlc_object_t *log;
-
- /* */
Display *p_display_x11;
VADisplay p_display;
VAImage image;
copy_cache_t image_cache;
-} vlc_va_vaapi_t;
-
-static vlc_va_vaapi_t *vlc_va_vaapi_Get( void *p_va )
-{
- return p_va;
-}
+};
/* */
-static int Open( vlc_va_vaapi_t *p_va, int i_codec_id )
+static int Open( vlc_va_t *p_external, int i_codec_id )
{
+ vlc_va_sys_t *p_va = calloc( 1, sizeof(*p_va) );
+ if ( unlikely(p_va == NULL) )
+ return VLC_ENOMEM;
+
VAProfile i_profile, *p_profiles_list;
bool b_supported_profile = false;
int i_profiles_nb = 0;
p_va->p_display_x11 = XOpenDisplay(NULL);
if( !p_va->p_display_x11 )
{
- msg_Err( p_va->log, "Could not connect to X server" );
+ msg_Err( p_external, "Could not connect to X server" );
goto error;
}
p_va->p_display = vaGetDisplay( p_va->p_display_x11 );
if( !p_va->p_display )
{
- msg_Err( p_va->log, "Could not get a VAAPI device" );
+ msg_Err( p_external, "Could not get a VAAPI device" );
goto error;
}
if( vaInitialize( p_va->p_display, &p_va->i_version_major, &p_va->i_version_minor ) )
{
- msg_Err( p_va->log, "Failed to initialize the VAAPI device" );
+ msg_Err( p_external, "Failed to initialize the VAAPI device" );
goto error;
}
free( p_profiles_list );
if ( !b_supported_profile )
{
- msg_Dbg( p_va->log, "Codec and profile not supported by the hardware" );
+ msg_Dbg( p_external, "Codec and profile not supported by the hardware" );
goto error;
}
p_va->i_surface_count = i_surface_count;
- if( asprintf( &p_va->va.description, "VA API version %d.%d",
+ if( asprintf( &p_external->description, "VA API version %d.%d",
p_va->i_version_major, p_va->i_version_minor ) < 0 )
- p_va->va.description = NULL;
+ p_external->description = NULL;
+ p_external->sys = p_va;
return VLC_SUCCESS;
error:
return VLC_EGENERIC;
}
-static void DestroySurfaces( vlc_va_vaapi_t *p_va )
+static void DestroySurfaces( vlc_va_sys_t *p_va )
{
if( p_va->image.image_id != VA_INVALID_ID )
{
p_va->i_surface_width = 0;
p_va->i_surface_height = 0;
}
-static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
+static int CreateSurfaces( vlc_va_sys_t *p_va, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
int i_width, int i_height )
{
assert( i_width > 0 && i_height > 0 );
static int Setup( vlc_va_t *p_external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
int i_width, int i_height )
{
- vlc_va_vaapi_t *p_va = vlc_va_vaapi_Get(p_external);
+ vlc_va_sys_t *p_va = p_external->sys;
if( p_va->i_surface_width == i_width &&
p_va->i_surface_height == i_height )
}
static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff )
{
- vlc_va_vaapi_t *p_va = vlc_va_vaapi_Get(p_external);
+ vlc_va_sys_t *p_va = p_external->sys;
if( !p_va->image_cache.buffer )
return VLC_EGENERIC;
}
static int Get( vlc_va_t *p_external, AVFrame *p_ff )
{
- vlc_va_vaapi_t *p_va = vlc_va_vaapi_Get(p_external);
+ vlc_va_sys_t *p_va = p_external->sys;
int i_old;
int i;
}
static void Release( vlc_va_t *p_external, AVFrame *p_ff )
{
- vlc_va_vaapi_t *p_va = vlc_va_vaapi_Get(p_external);
+ vlc_va_sys_t *p_va = p_external->sys;
VASurfaceID i_surface_id = (VASurfaceID)(uintptr_t)p_ff->data[3];
}
}
-static void Close( vlc_va_vaapi_t *p_va )
+static void Close( vlc_va_sys_t *p_va )
{
if( p_va->i_surface_width || p_va->i_surface_height )
DestroySurfaces( p_va );
}
static void Delete( vlc_va_t *p_external )
{
- vlc_va_vaapi_t *p_va = vlc_va_vaapi_Get(p_external);
+ vlc_va_sys_t *p_va = p_external->sys;
Close( p_va );
- free( p_va->va.description );
+ free( p_external->description );
free( p_va );
}
/* */
-vlc_va_t *vlc_va_New( vlc_object_t *obj, int pixfmt, int i_codec_id,
- const es_format_t *fmt )
+int vlc_va_New( vlc_va_t *p_va, int pixfmt, int i_codec_id,
+ const es_format_t *fmt )
{
/* Only VLD supported */
if( pixfmt != PIX_FMT_VAAPI_VLD )
- return NULL;
+ return VLC_EGENERIC;
- if( !vlc_xlib_init( obj ) )
+ if( !vlc_xlib_init( VLC_OBJECT(p_va) ) )
{
- msg_Warn( obj, "Ignoring VA API" );
- return NULL;
+ msg_Warn( p_va, "Ignoring VA API" );
+ return VLC_EGENERIC;
}
- vlc_va_vaapi_t *p_va = calloc( 1, sizeof(*p_va) );
- if( !p_va )
- return NULL;
-
- p_va->log = obj;
(void) fmt;
- if( Open( p_va, i_codec_id ) )
- {
- free( p_va );
- return NULL;
- }
+ int err = Open( p_va, i_codec_id );
+ if( err )
+ return err;
/* */
- p_va->va.setup = Setup;
- p_va->va.get = Get;
- p_va->va.release = Release;
- p_va->va.extract = Extract;
- p_va->va.close = Delete;
- return &p_va->va;
+ p_va->setup = Setup;
+ p_va->get = Get;
+ p_va->release = Release;
+ p_va->extract = Extract;
+ p_va->close = Delete;
+ return VLC_SUCCESS;
}
#include <libavcodec/vda.h>
#include <VideoDecodeAcceleration/VDADecoder.h>
-typedef struct
+struct vlc_va_sys_t
{
- vlc_va_t va;
struct vda_context hw_ctx;
const uint8_t *p_extradata;
vlc_object_t *p_log;
-} vlc_va_vda_t;
+};
-static vlc_va_vda_t *vlc_va_vda_Get( void *p_va )
+typedef struct vlc_va_sys_t vlc_va_vda_t;
+
+static vlc_va_vda_t *vlc_va_vda_Get( vlc_va_t *p_va )
{
- return p_va;
+ return p_va->sys;
}
/*****************************************************************************
free( p_va );
}
-vlc_va_t *vlc_va_New( vlc_object_t *p_log, int pixfmt, int i_codec_id,
- const es_format_t *fmt )
+int vlc_va_New( vlc_va_t *external, int pixfmt, int i_codec_id,
+ const es_format_t *fmt )
{
if( pixfmt != PIX_FMT_VDA_VLD || i_codec_id != CODEC_ID_H264 )
return NULL;
if( !p_va )
return NULL;
- p_va->p_log = p_log;
+ p_va->p_log = VLC_OBJECT(external);
p_va->p_extradata = fmt->p_extra;
p_va->i_extradata = fmt->i_extra;
- p_va->va.setup = Setup;
- p_va->va.get = Get;
- p_va->va.release = Release;
- p_va->va.extract = Extract;
- p_va->va.close = Close;
+ external->sys = p_va;
+ external->description = (char *)"VDA";
+ external->setup = Setup;
+ external->get = Get;
+ external->release = Release;
+ external->extract = Extract;
+ external->close = Close;
- return &p_va->va;
+ return VLC_SUCCESS;
}