[vlc-commits] avcodec: unify interface for video acceleration
Rémi Denis-Courmont
git at videolan.org
Fri Oct 12 10:38:15 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 10 19:29:15 2012 +0300| [6a258c9556eecbfad3541726fea389506252c3f2] | committer: Rémi Denis-Courmont
avcodec: unify interface for video acceleration
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6a258c9556eecbfad3541726fea389506252c3f2
---
modules/codec/avcodec/dxva2.c | 7 ++++++-
modules/codec/avcodec/va.h | 5 +----
modules/codec/avcodec/vaapi.c | 8 +++++++-
modules/codec/avcodec/vda.c | 13 +++++++------
modules/codec/avcodec/video.c | 26 +-------------------------
5 files changed, 22 insertions(+), 37 deletions(-)
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index b22b248..c4e3e00 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -496,8 +496,12 @@ static void Close(vlc_va_t *external)
free(va);
}
-vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id)
+vlc_va_t *vlc_va_New(vlc_object_t *log, int pixfmt, int codec_id,
+ const es_format_t *fmt)
{
+ if( pixfmt != PIX_FMT_DXVA2_VLD )
+ return NULL;
+
vlc_va_dxva2_t *va = calloc(1, sizeof(*va));
if (!va)
return NULL;
@@ -505,6 +509,7 @@ vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id)
/* */
va->log = log;
va->codec_id = codec_id;
+ (void) fmt;
/* Load dll*/
va->hd3d9_dll = LoadLibrary(TEXT("D3D9.DLL"));
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 8753212..8ed093d 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -58,9 +58,6 @@ static inline void vlc_va_Delete(vlc_va_t *va)
va->close(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);
-vlc_va_t *vlc_va_NewVDA( vlc_object_t *log, int i_codec_id,void *p_extra, int i_extra);
+vlc_va_t *vlc_va_New(vlc_object_t *, int pix, int codec, const es_format_t *);
#endif
-
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index cc7eaca..450f379 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -506,8 +506,13 @@ static void Delete( vlc_va_t *p_external )
}
/* */
-vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
+vlc_va_t *vlc_va_New( vlc_object_t *obj, int pixfmt, int i_codec_id,
+ const es_format_t *fmt )
{
+ /* Only VLD supported */
+ if( pixfmt != PIX_FMT_VAAPI_VLD )
+ return NULL;
+
if( !vlc_xlib_init( obj ) )
{
msg_Warn( obj, "Ignoring VA API" );
@@ -519,6 +524,7 @@ vlc_va_t *vlc_va_NewVaapi( vlc_object_t *obj, int i_codec_id )
return NULL;
p_va->log = obj;
+ (void) fmt;
if( Open( p_va, i_codec_id ) )
{
diff --git a/modules/codec/avcodec/vda.c b/modules/codec/avcodec/vda.c
index c8c0873..b8cb159 100644
--- a/modules/codec/avcodec/vda.c
+++ b/modules/codec/avcodec/vda.c
@@ -44,7 +44,7 @@ typedef struct
vlc_va_t va;
struct vda_context hw_ctx;
- uint8_t *p_extradata;
+ const uint8_t *p_extradata;
int i_extradata;
vlc_fourcc_t i_chroma;
@@ -242,12 +242,13 @@ static void Close( vlc_va_t *p_external )
free( p_va );
}
-vlc_va_t *vlc_va_NewVDA( vlc_object_t *p_log, int i_codec_id, void *p_extra, int i_extra )
+vlc_va_t *vlc_va_New( vlc_object_t *p_log, int pixfmt, int i_codec_id,
+ const es_format_t *fmt )
{
- if( i_codec_id != CODEC_ID_H264 )
+ if( pixfmt != PIX_FMT_VDA_VLD || i_codec_id != CODEC_ID_H264 )
return NULL;
- if( !p_extra || i_extra < 7 )
+ if( fmt->p_extra == NULL || fmt->i_extra < 7 )
{
msg_Warn( p_log, "VDA requires extradata." );
return NULL;
@@ -258,8 +259,8 @@ vlc_va_t *vlc_va_NewVDA( vlc_object_t *p_log, int i_codec_id, void *p_extra, int
return NULL;
p_va->p_log = p_log;
- p_va->p_extradata = p_extra;
- p_va->i_extradata = i_extra;
+ p_va->p_extradata = fmt->p_extra;
+ p_va->i_extradata = fmt->i_extra;
p_va->va.setup = Setup;
p_va->va.get = Get;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 738f69e..042764d 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1144,31 +1144,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
msg_Dbg( p_dec, "Available decoder output format %d (%s)", pi_fmt[i],
name ? name : "unknown" );
- vlc_va_t *p_va = NULL;
-#ifdef HAVE_AVCODEC_VAAPI
- /* Only VLD supported */
- if( pi_fmt[i] == PIX_FMT_VAAPI_VLD )
- {
- msg_Dbg( p_dec, "Trying VA API" );
- p_va = vlc_va_NewVaapi( VLC_OBJECT(p_dec), p_sys->i_codec_id );
- }
-#endif
-
-#ifdef HAVE_AVCODEC_DXVA2
- if( pi_fmt[i] == PIX_FMT_DXVA2_VLD )
- {
- msg_Dbg( p_dec, "Trying DXVA2" );
- p_va = vlc_va_NewDxva2( VLC_OBJECT(p_dec), p_sys->i_codec_id );
- }
-#endif
-
-#ifdef HAVE_AVCODEC_VDA
- if( pi_fmt[i] == PIX_FMT_VDA_VLD )
- {
- msg_Dbg( p_dec, "Trying VDA" );
- p_va = vlc_va_NewVDA( VLC_OBJECT(p_dec), p_sys->i_codec_id, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
- }
-#endif
+ vlc_va_t *p_va = vlc_va_New( VLC_OBJECT(p_dec), pi_fmt[i], p_sys->i_codec_id, &p_dec->fmt_in );
if( p_va == NULL )
{
msg_Dbg( p_dec, "acceleration not available" );
More information about the vlc-commits
mailing list