On Thu, May 07, 2015 at 10:04:50PM +0200, Steve Lhomme wrote: > --- > configure | 31 +++++++- > libavcodec/Makefile | 7 ++ > libavcodec/allcodecs.c | 5 ++ > libavcodec/d3d11va.h | 98 +++++++++++++++++++++++++ > libavcodec/dxva2.c | 170 > ++++++++++++++++++++++++++++++++++++-------- > libavcodec/dxva2_h264.c | 140 +++++++++++++++++++++++++----------- > libavcodec/dxva2_hevc.c | 110 +++++++++++++++++++++------- > libavcodec/dxva2_internal.h | 32 +++++++-- > libavcodec/dxva2_mpeg2.c | 104 +++++++++++++++++++++------ > libavcodec/dxva2_vc1.c | 133 ++++++++++++++++++++++++++-------- > libavcodec/h264_slice.c | 3 + > libavcodec/hevc.c | 3 + > libavcodec/mpeg12dec.c | 3 + > libavcodec/vc1dec.c | 3 + > libavutil/pixdesc.c | 6 ++ > libavutil/pixfmt.h | 2 + > 16 files changed, 696 insertions(+), 154 deletions(-) > create mode 100644 libavcodec/d3d11va.h
https://www.libav.org/developer.html#New-codecs-or-formats-checklist > --- a/configure > +++ b/configure > @@ -134,6 +134,7 @@ Component options: > > Hardware accelerators: > --enable-dxva2 enable DXVA2 code > + --enable-d3d11va disable D3D11VA code [autodetect] Drop the autodetect, fix the alignment and move the entry up one line. Numbers come before letters in alphabetical order. > @@ -1207,6 +1208,7 @@ FEATURE_LIST=" > > HWACCEL_LIST=" > dxva2 > + d3d11va order > @@ -1397,6 +1399,7 @@ HEADERS_LIST=" > direct_h > dlfcn_h > dxva_h > + d3d11_h same > @@ -1552,6 +1555,8 @@ HAVE_LIST=" > atomics_native > dos_paths > dxva2_lib > + d3d11_cobj > + d3d11va_lib same > @@ -1966,6 +1971,7 @@ zmbv_encoder_deps="zlib" > > # hardware accelerators > dxva2_deps="dxva2api_h" > +d3d11va_deps="d3d11_h dxva_h" same > @@ -4157,6 +4172,7 @@ check_header direct.h > check_header dlfcn.h > check_header dxva.h > check_header dxva2api.h > +check_header d3d11.h order > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -3,6 +3,7 @@ NAME = avcodec > HEADERS = avcodec.h \ > avfft.h \ > dv_profile.h \ > + d3d11va.h \ same > --- /dev/null > +++ b/libavcodec/d3d11va.h > @@ -0,0 +1,98 @@ > + > +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 > +#undef _WIN32_WINNT > +#define _WIN32_WINNT 0x0600 > +#endif This stanza also appears in dxva2.h, maybe it could be shared. > --- a/libavcodec/dxva2.c > +++ b/libavcodec/dxva2.c > @@ -60,8 +61,20 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, > +#if CONFIG_D3D11VA > + if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { > + hr = > ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, > + > D3D11VA_CONTEXT(ctx)->decoder, > + type, > + &dxva_size, &dxva_data); > + } > +#endif > +#if CONFIG_DXVA2 > + if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { > + hr = IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder, > type, > + &dxva_data, &dxva_size); > + } > +#endif nit: pointless {}, more below > @@ -70,10 +83,24 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, > +#if CONFIG_D3D11VA > + if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { > + D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc; > + memset(dsc11, 0, sizeof(*dsc11)); You could zero-initialize instead of memsetting here. > +#if CONFIG_DXVA2 > + if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { > + DXVA2_DecodeBufferDesc *dsc2 = dsc; > + memset(dsc2, 0, sizeof(*dsc2)); same > @@ -154,17 +240,39 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, > AVFrame *frame, > > +#if CONFIG_DXVA2 > + if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { > + DXVA2_DecodeExecuteParams exec = { > + .NumCompBuffers = buffer_count, > + .pCompressedBuffers = buffer2, > + .pExtensionData = NULL, Please align the = for better readability. > --- a/libavcodec/dxva2_h264.c > +++ b/libavcodec/dxva2_h264.c > @@ -363,18 +379,45 @@ static int > commit_bitstream_and_slice_buffer(AVCodecContext *avctx, > +#if CONFIG_D3D11VA > + if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { > + D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs; > + memset(dsc11, 0, sizeof(*dsc11)); > +#endif > +#if CONFIG_DXVA2 > + if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { > + DXVA2_DecodeBufferDesc *dsc2 = bs; > + memset(dsc2, 0, sizeof(*dsc2)); see above about memset vs. '= { 0 }'. > @@ -393,18 +436,20 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx, > > - if (!ctx->decoder || !ctx->cfg || ctx->surface_count <= 0) > + if (DXVA_CONTEXT_DECODER(avctx, ctx)==NULL || > + DXVA_CONTEXT_CFG(avctx, ctx)==NULL || spaces around == > --- a/libavcodec/dxva2_hevc.c > +++ b/libavcodec/dxva2_hevc.c > @@ -284,23 +300,50 @@ static int > commit_bitstream_and_slice_buffer(AVCodecContext *avctx, > > - memset(bs, 0, sizeof(*bs)); > - bs->CompressedBufferType = DXVA2_BitStreamDateBufferType; > - bs->DataSize = current - dxva_data; > - bs->NumMBsInBuffer = 0; > +#if CONFIG_D3D11VA > + if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { > + D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs; > + memset(dsc11, 0, sizeof(*dsc11)); > +#if CONFIG_DXVA2 > + if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { > + DXVA2_DecodeBufferDesc *dsc2 = bs; > + memset(dsc2, 0, sizeof(*dsc2)); see above > --- a/libavcodec/dxva2_internal.h > +++ b/libavcodec/dxva2_internal.h > @@ -35,13 +36,34 @@ > + > +typedef union { > + struct av_d3d11va_context d3d11va; > + struct dxva_context dxva2; > +} av_dxva_context_t; The _t namespace is reserved by POSIX, you must not invade it. Diego _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
