Commit e0028dbf authored by Laurent Aimar's avatar Laurent Aimar

Added DXVA2 support to our avcodec wrapper.

It is not yet activated (the build system part is missing).
parent 670ef981
...@@ -9,6 +9,7 @@ libavcodec_plugin_la_SOURCES = \ ...@@ -9,6 +9,7 @@ libavcodec_plugin_la_SOURCES = \
fourcc.c \ fourcc.c \
chroma.c \ chroma.c \
vaapi.c \ vaapi.c \
dxva2.c \
va.h \ va.h \
$(NULL) $(NULL)
if ENABLE_SOUT if ENABLE_SOUT
......
...@@ -136,7 +136,7 @@ vlc_module_begin () ...@@ -136,7 +136,7 @@ vlc_module_begin ()
add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT, add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT,
true ) true )
#ifdef HAVE_AVCODEC_VAAPI #if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
add_bool( "ffmpeg-hw", true, NULL, HW_TEXT, HW_LONGTEXT, true ) add_bool( "ffmpeg-hw", true, NULL, HW_TEXT, HW_LONGTEXT, true )
#endif #endif
......
...@@ -265,6 +265,7 @@ void EndSubtitleDec( decoder_t *p_dec ); ...@@ -265,6 +265,7 @@ void EndSubtitleDec( decoder_t *p_dec );
# define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c)) # define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))
#endif #endif
/* Uncomment it to enable compilation with vaapi (you also must change the build /* Uncomment it to enable compilation with vaapi/dxva2 (you also must change the build
* system) */ * system) */
//#define HAVE_AVCODEC_VAAPI 1 //#define HAVE_AVCODEC_VAAPI 1
//#define HAVE_AVCODEC_DXVA2 1
This diff is collapsed.
...@@ -59,6 +59,7 @@ static inline void vlc_va_Delete(vlc_va_t *va) ...@@ -59,6 +59,7 @@ static inline void vlc_va_Delete(vlc_va_t *va)
} }
vlc_va_t *vlc_va_NewVaapi(int codec_id); vlc_va_t *vlc_va_NewVaapi(int codec_id);
vlc_va_t *vlc_va_NewDxva2(vlc_object_t *log, int codec_id);
#endif #endif
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
# ifdef HAVE_AVCODEC_VAAPI # ifdef HAVE_AVCODEC_VAAPI
# include <libavcodec/vaapi.h> # include <libavcodec/vaapi.h>
# endif # endif
# ifdef HAVE_AVCODEC_DXVA2
# include <libavcodec/dxva2.h>
# endif
#elif defined(HAVE_FFMPEG_AVCODEC_H) #elif defined(HAVE_FFMPEG_AVCODEC_H)
# include <ffmpeg/avcodec.h> # include <ffmpeg/avcodec.h>
#else #else
...@@ -49,6 +52,9 @@ ...@@ -49,6 +52,9 @@
#include "avcodec.h" #include "avcodec.h"
#include "va.h" #include "va.h"
#if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
# define HAVE_AVCODEC_VA
#endif
/***************************************************************************** /*****************************************************************************
* decoder_sys_t : decoder descriptor * decoder_sys_t : decoder descriptor
...@@ -105,7 +111,7 @@ static int ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * ); ...@@ -105,7 +111,7 @@ static int ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * );
static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * ); static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * );
static void ffmpeg_NextPts( decoder_t * ); static void ffmpeg_NextPts( decoder_t * );
#ifdef HAVE_AVCODEC_VAAPI #ifdef HAVE_AVCODEC_VA
static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *, static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *,
const enum PixelFormat * ); const enum PixelFormat * );
#endif #endif
...@@ -320,7 +326,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -320,7 +326,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf; p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf;
p_sys->p_context->opaque = p_dec; p_sys->p_context->opaque = p_dec;
#ifdef HAVE_AVCODEC_VAAPI #ifdef HAVE_AVCODEC_VA
if( var_CreateGetBool( p_dec, "ffmpeg-hw" ) ) if( var_CreateGetBool( p_dec, "ffmpeg-hw" ) )
p_sys->p_context->get_format = ffmpeg_GetFormat; p_sys->p_context->get_format = ffmpeg_GetFormat;
#endif #endif
...@@ -897,13 +903,13 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, ...@@ -897,13 +903,13 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,
if( p_sys->p_va ) if( p_sys->p_va )
{ {
#ifdef HAVE_AVCODEC_VAAPI #ifdef HAVE_AVCODEC_VA
/* hwaccel_context is not present in old fffmpeg version */ /* hwaccel_context is not present in old fffmpeg version */
if( vlc_va_Setup( p_sys->p_va, if( vlc_va_Setup( p_sys->p_va,
&p_sys->p_context->hwaccel_context, &p_dec->fmt_out.video.i_chroma, &p_sys->p_context->hwaccel_context, &p_dec->fmt_out.video.i_chroma,
p_sys->p_context->width, p_sys->p_context->height ) ) p_sys->p_context->width, p_sys->p_context->height ) )
{ {
msg_Err( p_dec, "VaSetup failed" ); msg_Err( p_dec, "vlc_va_Setup failed" );
return -1; return -1;
} }
#else #else
...@@ -1086,7 +1092,7 @@ static void ffmpeg_NextPts( decoder_t *p_dec ) ...@@ -1086,7 +1092,7 @@ static void ffmpeg_NextPts( decoder_t *p_dec )
} }
} }
#ifdef HAVE_AVCODEC_VAAPI #ifdef HAVE_AVCODEC_VA
static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_codec, static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_codec,
const enum PixelFormat *pi_fmt ) const enum PixelFormat *pi_fmt )
{ {
...@@ -1115,20 +1121,41 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_codec, ...@@ -1115,20 +1121,41 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_codec,
/* Only VLD supported */ /* Only VLD supported */
if( pi_fmt[i] == PIX_FMT_VAAPI_VLD ) if( pi_fmt[i] == PIX_FMT_VAAPI_VLD )
{ {
#ifdef HAVE_AVCODEC_VAAPI
msg_Dbg( p_dec, "Trying VA API" ); msg_Dbg( p_dec, "Trying VA API" );
p_sys->p_va = vlc_va_NewVaapi( p_sys->i_codec_id ); p_sys->p_va = vlc_va_NewVaapi( p_sys->i_codec_id );
if( p_sys->p_va ) if( !p_sys->p_va )
{ msg_Warn( p_dec, "Failed to open VA API" );
/* FIXME this will disabled direct rendering #else
* even if a new pixel format is renegociated continue;
* #endif
* FIXME Try to call VaSetup when possible }
* to detect errors when possible (later is too late) */ if( pi_fmt[i] == PIX_FMT_DXVA2_VLD )
p_sys->b_direct_rendering = false; {
p_sys->p_context->draw_horiz_band = NULL; #ifdef HAVE_AVCODEC_DXVA2
return pi_fmt[i]; msg_Dbg( p_dec, "Trying DXVA2" );
} p_sys->p_va = vlc_va_NewDxva2( VLC_OBJECT(p_dec), p_sys->i_codec_id );
msg_Warn( p_dec, "Failed to open VA API" ); if( !p_sys->p_va )
msg_Warn( p_dec, "Failed to open DXVA2" );
#else
continue;
#endif
}
else
{
continue;
}
if( p_sys->p_va )
{
/* FIXME this will disabled direct rendering
* even if a new pixel format is renegociated
*
* FIXME Try to call vlc_va_Setup when possible
* to detect errors when possible (later is too late) */
p_sys->b_direct_rendering = false;
p_sys->p_context->draw_horiz_band = NULL;
return pi_fmt[i];
} }
} }
......
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