[libav-devel] [PATCH 2/2] Intel Media SDK, Quick Sync Video/QSV: Initial add of H.264 decoder infrastructure
--- Changelog |1 + configure |7 +++ libavcodec/Makefile|2 ++ libavcodec/allcodecs.c |1 + libavcodec/qsv.h |2 +- libavcodec/qsv_h264.c |9 - libavcodec/version.h |2 +- libavutil/pixfmt.h |1 + 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index f56c112..765b87f 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest. version 10: - av_strnstr - support ID3v2 tags in ASF files +- QSV decoder hardware acceleration version 9: diff --git a/configure b/configure index 1aae93b..dcd0c37 100755 --- a/configure +++ b/configure @@ -130,6 +130,7 @@ Component options: Hardware accelerators: --enable-dxva2 enable DXVA2 code + --enable-qsv enable QSV code --enable-vaapi enable VAAPI code --enable-vda enable VDA code --enable-vdpau enable VDPAU code @@ -1048,6 +1049,7 @@ EXTERNAL_LIBRARY_LIST=" HWACCEL_LIST=" dxva2 +qsv vaapi vda vdpau @@ -1624,6 +1626,8 @@ zmbv_encoder_select="zlib" # hardware accelerators dxva2_deps="dxva2api_h" +qsv_deps="mfx_mfxvideo_h" +qsv_extralibs="-lmfx -lstdc++" vaapi_deps="va_va_h" vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" @@ -1635,6 +1639,8 @@ h263_vdpau_hwaccel_deps="vdpau" h263_vdpau_hwaccel_select="h263_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" +h264_qsv_decoder_deps="qsv" +h264_qsv_decoder_select="h264_decoder" h264_vaapi_hwaccel_deps="vaapi" h264_vaapi_hwaccel_select="h264_decoder" h264_vda_hwaccel_deps="vda" @@ -3468,6 +3474,7 @@ check_header sys/resource.h check_header sys/select.h check_header sys/time.h check_header unistd.h +check_header mfx/mfxvideo.h check_header vdpau/vdpau.h check_header vdpau/vdpau_x11.h check_header VideoDecodeAcceleration/VDADecoder.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 262d2eb..d0b6166 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -5,6 +5,7 @@ HEADERS = avcodec.h \ avfft.h \ dxva2.h \ old_codec_ids.h \ + qsv.h \ vaapi.h \ vda.h \ vdpau.h \ @@ -199,6 +200,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264.o \ cabac.o h264_sei.o h264_ps.o \ h264_refs.o h264_cavlc.o h264_cabac.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o +OBJS-$(CONFIG_H264_QSV_DECODER)+= qsv.o qsv_h264.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_H264_VDA_HWACCEL)+= vda_h264.o OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 8bfa603..a4f8643 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -150,6 +150,7 @@ void avcodec_register_all(void) REGISTER_DECODER(H263I, h263i); REGISTER_ENCODER(H263P, h263p); REGISTER_DECODER(H264, h264); +REGISTER_DECODER(H264_QSV, h264_qsv); REGISTER_DECODER(H264_VDPAU,h264_vdpau); REGISTER_ENCDEC (HUFFYUV, huffyuv); REGISTER_DECODER(IDCIN, idcin); diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h index cfbf75c..fc16fea 100644 --- a/libavcodec/qsv.h +++ b/libavcodec/qsv.h @@ -335,7 +335,7 @@ typedef struct av_qsv_config { /** * Distance between I- or P- key frames; if it is zero, the GOP structure is unspecified. - * Note: If GopRefDist = 1, there are no B-frames used. + * Note: If GopRefDist = 1 no B-frames are used. * * - encoding: Set by user. * - decoding: unused diff --git a/libavcodec/qsv_h264.c b/libavcodec/qsv_h264.c index fbd3aa7..51122c2 100644 --- a/libavcodec/qsv_h264.c +++ b/libavcodec/qsv_h264.c @@ -267,8 +267,8 @@ int ff_qsv_decode_init(AVCodecContext *avctx) "Using default config for QSV decode\n"); avctx->hwaccel_context = &av_qsv_default_config; } else { -if ((*qsv_config_context)->io_pattern != MFX_IOPATTERN_OUT_OPAQUE_MEMORY -&& (*qsv_config_context)->io_pattern != MFX_IOPATTERN_OUT_SYSTEM_MEMORY) { +if ((*qsv_config_context)->io_pattern != MFX_IOPATTERN_OUT_OPAQUE_MEMORY && +(*qs
[libav-devel] [PATCH 2/2] Intel Media SDK, Quick Sync Video/QSV: Initial add of H.264 decoder infrastructure
From: Maxym Dmytrychenko --- Changelog |1 + configure |7 +++ libavcodec/Makefile|2 ++ libavcodec/allcodecs.c |1 + libavcodec/qsv.h |2 +- libavcodec/qsv_h264.c |9 - libavcodec/version.h |2 +- libavutil/pixfmt.h |1 + 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index f56c112..765b87f 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest. version 10: - av_strnstr - support ID3v2 tags in ASF files +- QSV decoder hardware acceleration version 9: diff --git a/configure b/configure index 1aae93b..dcd0c37 100755 --- a/configure +++ b/configure @@ -130,6 +130,7 @@ Component options: Hardware accelerators: --enable-dxva2 enable DXVA2 code + --enable-qsv enable QSV code --enable-vaapi enable VAAPI code --enable-vda enable VDA code --enable-vdpau enable VDPAU code @@ -1048,6 +1049,7 @@ EXTERNAL_LIBRARY_LIST=" HWACCEL_LIST=" dxva2 +qsv vaapi vda vdpau @@ -1624,6 +1626,8 @@ zmbv_encoder_select="zlib" # hardware accelerators dxva2_deps="dxva2api_h" +qsv_deps="mfx_mfxvideo_h" +qsv_extralibs="-lmfx -lstdc++" vaapi_deps="va_va_h" vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" @@ -1635,6 +1639,8 @@ h263_vdpau_hwaccel_deps="vdpau" h263_vdpau_hwaccel_select="h263_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" +h264_qsv_decoder_deps="qsv" +h264_qsv_decoder_select="h264_decoder" h264_vaapi_hwaccel_deps="vaapi" h264_vaapi_hwaccel_select="h264_decoder" h264_vda_hwaccel_deps="vda" @@ -3468,6 +3474,7 @@ check_header sys/resource.h check_header sys/select.h check_header sys/time.h check_header unistd.h +check_header mfx/mfxvideo.h check_header vdpau/vdpau.h check_header vdpau/vdpau_x11.h check_header VideoDecodeAcceleration/VDADecoder.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 262d2eb..d0b6166 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -5,6 +5,7 @@ HEADERS = avcodec.h \ avfft.h \ dxva2.h \ old_codec_ids.h \ + qsv.h \ vaapi.h \ vda.h \ vdpau.h \ @@ -199,6 +200,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264.o \ cabac.o h264_sei.o h264_ps.o \ h264_refs.o h264_cavlc.o h264_cabac.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o +OBJS-$(CONFIG_H264_QSV_DECODER)+= qsv.o qsv_h264.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_H264_VDA_HWACCEL)+= vda_h264.o OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 8bfa603..a4f8643 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -150,6 +150,7 @@ void avcodec_register_all(void) REGISTER_DECODER(H263I, h263i); REGISTER_ENCODER(H263P, h263p); REGISTER_DECODER(H264, h264); +REGISTER_DECODER(H264_QSV, h264_qsv); REGISTER_DECODER(H264_VDPAU,h264_vdpau); REGISTER_ENCDEC (HUFFYUV, huffyuv); REGISTER_DECODER(IDCIN, idcin); diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h index cfbf75c..fc16fea 100644 --- a/libavcodec/qsv.h +++ b/libavcodec/qsv.h @@ -335,7 +335,7 @@ typedef struct av_qsv_config { /** * Distance between I- or P- key frames; if it is zero, the GOP structure is unspecified. - * Note: If GopRefDist = 1, there are no B-frames used. + * Note: If GopRefDist = 1 no B-frames are used. * * - encoding: Set by user. * - decoding: unused diff --git a/libavcodec/qsv_h264.c b/libavcodec/qsv_h264.c index fbd3aa7..51122c2 100644 --- a/libavcodec/qsv_h264.c +++ b/libavcodec/qsv_h264.c @@ -267,8 +267,8 @@ int ff_qsv_decode_init(AVCodecContext *avctx) "Using default config for QSV decode\n"); avctx->hwaccel_context = &av_qsv_default_config; } else { -if ((*qsv_config_conte
Re: [libav-devel] [PATCH] Intel Media SDK, Quick Sync Video/QSV: Initial add of H.264 decoder infrastructure
On 13-02-27 19:50:51, Diego Biurrun wrote: > On Wed, Feb 27, 2013 at 06:39:57PM +0100, maxd wrote: > > On 13-02-21 16:03:30, Diego Biurrun wrote: > > > On Mon, Feb 04, 2013 at 08:49:35PM +0100, Maxym Dmytrychenko wrote: > > > > From: Maxym Dmytrychenko > > > > > > > Does your patch pass "make check"? I suspect at least the checkheaders > > > target will not pass. > > > > my latest patch from > > http://lists.libav.org/pipermail/libav-devel/2013-February/043882.html > > should be fine, > > including make checkheaders on MinGW and MSVC > > It only passes checkheaders if the mxf headers are available. > Fixed in the changes I sent you. got it and appriciated! > > > > --- /dev/null > > > > +++ b/libavcodec/qsv.c > > > > @@ -0,0 +1,556 @@ > > > > +void av_qsv_stage_clean(av_qsv_stage ** stage) > > > > +{ > > > > + > > > > +if ((*stage)->out.p_sync) { > > > > +*(*stage)->out.p_sync = 0; > > > > +(*stage)->out.p_sync = 0; > > > > +} > > > > +av_freep(stage); > > > > > > Here a variable indirection would make things more readable. > > > > if you have any sample that you can show to follow, I can change it. > > av_qsv_stage *stage_ptr = *stage; > > Maybe use a better variable name. ok, will change in the next patch > > > > +av_qsv_stage *av_qsv_get_by_mask(av_qsv_list * list, int mask, > > > > av_qsv_stage ** prev, > > > > + av_qsv_list ** this_pipe) > > > > +{ > > > > +av_qsv_list *item = 0; > > > > +av_qsv_stage *stage = 0; > > > > +av_qsv_stage *prev_stage = 0; > > > > +int i = 0; > > > > +int a = 0; > > > > +*this_pipe = 0; > > > > +*prev = 0; > > > > +for (i = 0; i < av_qsv_list_count(list); i++) { > > > > +item = av_qsv_list_item(list, i); > > > > +for (a = 0; a < av_qsv_list_count(item); a++) { > > > > +stage = av_qsv_list_item(item, a); > > > > +if (!stage) > > > > +return stage; > > > > +if (stage->type & mask) { > > > > +*prev = prev_stage; > > > > +*this_pipe = item; > > > > +return stage; > > > > +} > > > > +prev_stage = stage; > > > > +} > > > > +} > > > > +return 0; > > > > +} > > > > > > prev and this_pipe are only used dereferenced, so why not pass them as > > > simple pointers? > > > > this way looks to be better for the final application that would use it > > Why? ok , let's make it easy - I've removed this function completely. > > > > --- /dev/null > > > > +++ b/libavcodec/qsv.h > > > > @@ -0,0 +1,469 @@ > > > You start the sentence with "As ..." but then you do not say what follows > > > from the ability to use hw acceleration. > > > > > > > +#ifdef HAVE_AV_CONFIG_H > > > > +#include "config.h" > > > > +#endif > > > > > > No such inclusion guard is necessary. > > it looks that might help to the final application ( dependency point as > > it was last time ) > > I can check more here if needed. > > If I will remove it from this file - will be a transparent change > > for QSV implementation inside libav and final application. > > You cannot include config.h in an installed header, with or without the > inclusion guards. ok, if to move into qsv.c - will it be fine ? if so, next patch will move lines: #ifdef HAVE_AV_CONFIG_H #include "config.h" #endif #if HAVE_THREADS #if defined (__GNUC__) #include #define ff_qsv_atomic_inc(ptr) __sync_add_and_fetch(ptr,1) #define ff_qsv_atomic_dec(ptr) __sync_sub_and_fetch (ptr,1) #elif HAVE_WINDOWS_H// MSVC case #include #if HAVE_PTHREADS #include #elif HAVE_W32THREADS #include "w32pthreads.h" #endif #define ff_qsv_atomic_inc(ptr) InterlockedIncrement(ptr) #define ff_qsv_atomic_dec(ptr) InterlockedDecrement (ptr) #else // targeting only for MinGW or MSVC #endif #else #define ff_qsv_atomic_inc(ptr) ((*ptr)++) #define ff_qsv_atomic_dec(ptr) ((*ptr)--) #endif into qsv.c > > > > +#define AV_QSV_ZERO_MEMORY(VAR){memset(&VAR, 0, > > > > sizeof(VAR));} > > > > +
Re: [libav-devel] [PATCH] Intel Media SDK, Quick Sync Video/QSV: Initial add of H.264 decoder infrastructure
On Thu, Feb 28, 2013 at 6:27 PM, Diego Biurrun wrote: > On Thu, Feb 28, 2013 at 05:53:49PM +0100, Max Dm wrote: > > On Thu, Feb 28, 2013 at 3:16 PM, Diego Biurrun wrote: > > > On Thu, Feb 28, 2013 at 02:47:39PM +0100, Max Dm wrote: > > > > On Thu, Feb 28, 2013 at 11:38 AM, Diego Biurrun > > > wrote: > > > > > On Wed, Feb 27, 2013 at 11:46:45PM +0100, Maxym Dmytrychenko wrote: > > > > > > On 13-02-27 19:50:51, Diego Biurrun wrote: > > > > > > > On Wed, Feb 27, 2013 at 06:39:57PM +0100, maxd wrote: > > > > > > > > On 13-02-21 16:03:30, Diego Biurrun wrote: > > > > > > > > > On Mon, Feb 04, 2013 at 08:49:35PM +0100, Maxym > Dmytrychenko > > > wrote: > > > > > > > > > > --- /dev/null > > > > > > > > > > +++ b/libavcodec/qsv.h > > > > > > > > > > @@ -0,0 +1,469 @@ > > > > > > > > > You start the sentence with "As ..." but then you do not > say > > > what > > > > > follows > > > > > > > > > from the ability to use hw acceleration. > > > > > > > > > > > > > > > > > > > +#ifdef HAVE_AV_CONFIG_H > > > > > > > > > > +#include "config.h" > > > > > > > > > > +#endif > > > > > > > > > > > > > > > > > > No such inclusion guard is necessary. > > > > > > > > it looks that might help to the final application ( > dependency > > > point > > > > > as > > > > > > > > it was last time ) > > > > > > > > I can check more here if needed. > > > > > > > > If I will remove it from this file - will be a transparent > change > > > > > > > > for QSV implementation inside libav and final application. > > > > > > > > > > > > > > You cannot include config.h in an installed header, with or > > > without the > > > > > > > inclusion guards. > > > > > > > > > > > > ok, if to move into qsv.c - will it be fine ? > > > > > > if so, next patch will move lines: > > > > > > > > > > > > #ifdef HAVE_AV_CONFIG_H > > > > > > #include "config.h" > > > > > > #endif > > > > > > > > > > Again - no such inclusion guard is necessary. > > > > > > > > > > right - it was just to show the idea and what is moved, > > > > #ifdef HAVE_AV_CONFIG_H will be dropped while in qsv.c > > > > > > It has to be and had to be dropped anywhere. > > > > > > > Again, will such move help to solve the question? > > > > > > Not sure which question you are referring to. > > > > > > question about having config.h included > > I think we have the agreement : if moved to qsv.c with no > HAVE_AV_CONFIG_H > > - fine, > > correct? > > Probably yes. > > > > > you can have a look on MediaSDK samples and definitions been used > there, > > > > files like sample_common\include\sample_defs.h > > > > > > URL? > > > > > Homepage of MediaSDK is > > http://software.intel.com/en-us/vcsource/tools/media-sdk > > I can recommend to download and install MediaSDK to see this file. > > I cannot be bothered to be honest. There is no git/whatever tree directly > visible online? > > there is only one way to download MediaSDK, you can see it at provided link, > please note: > > regardless the fact that this, an initial patch provides QSV-based decode > > only - it has already "looking forward" structure and implementation. > > > > QSV based acceleration (and MediaSDK API ) goes beyond decode and only, > > it covers filters/VPP cases and encode - meaning: full video transcode > > scenario. > > I would encourage to read more from : > > http://software.intel.com/en-us/vcsource/tools/media-sdk > > and provided together with MediaSDK documentations. > > > > if an application does video transcode or any decode/encode : for best > > performance with QSV - we have to recommend to use not only libav/QSV > > decode but QSV based encode/filters as well. > > Such, fully HW accelerated, approach probably something new for libav but > > provided patch and its definitions and structures is a start to build > such > > possibility as within libav and up to the final application. > > Note, it goes beyond libav at the level of final application. > > This is what I mean by "looking forward". > > > > About possible concern: to have only needed definitions etc - just > believe > > that it will stay so but just extended in the future. > > Let's add the extra parts when we have a need for them, not earlier. > We have had a long history of features added for future use and then > left to rot. > > this patch is shared under BSD license, feel free to adjust it as for libav projects requirements. > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel > ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel