[libav-devel] [PATCH 0/6] D3D11VA in avconv

2017-01-03 Thread Steve Lhomme
Update on this patchset with a lot of fixes that was discussed during the last
weeks. The patches have been split more.

The public structures in libavutil are more documented and require less things
set by the caller.

The GUIDs declared in the template are defined in a separate avconv_guid.c file
so that they are not twice in the same binary.

Steve Lhomme (6):
  libavutil: add support for AV_HWDEVICE_TYPE_D3D11VA
  avconv: dxva2: factorize some code that can be common with d3d11va
  avconv: dxva2: move the DXVA GUID definitions outside of the template
  avconv_dxva2: remove unused initial values
  avconv: add avconv_d3d11va
  avconv: use the typedefs more to make comparison between dxva2 and
d3d11va

 Changelog  |   1 +
 Makefile   |   3 +-
 avconv.h   |   2 +
 avconv_d3d11va.c   | 213 +++
 avconv_dxva.c  |  28 +++
 avconv_dxva2.c | 302 ++-
 avconv_dxva_template.c | 294 ++
 avconv_guid.c  |  20 ++
 avconv_opt.c   |   3 +
 configure  |   6 +
 doc/APIchanges |   3 +
 libavutil/Makefile |   3 +
 libavutil/hwcontext.c  |   3 +
 libavutil/hwcontext.h  |   1 +
 libavutil/hwcontext_d3d11va.c  | 460 +
 libavutil/hwcontext_d3d11va.h  |  70 +++
 libavutil/hwcontext_internal.h |   1 +
 libavutil/version.h|   2 +-
 18 files changed, 1170 insertions(+), 245 deletions(-)
 create mode 100644 avconv_d3d11va.c
 create mode 100644 avconv_dxva.c
 create mode 100644 avconv_dxva_template.c
 create mode 100644 avconv_guid.c
 create mode 100644 libavutil/hwcontext_d3d11va.c
 create mode 100644 libavutil/hwcontext_d3d11va.h

-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 5/6] avconv: add avconv_d3d11va

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

The code is similar to avconv_dxva2. The decoded output needs to be copied into
a staging texture that can be accessed by the CPU as the decoder texture can't
be accessed by the CPU.

edit: move the actual GUID definitions in a shared C file
---
 Changelog|   1 +
 Makefile |   1 +
 avconv.h |   2 +
 avconv_d3d11va.c | 213 +++
 avconv_dxva.c|  28 
 avconv_opt.c |   3 +
 configure|   6 ++
 7 files changed, 254 insertions(+)
 create mode 100644 avconv_d3d11va.c
 create mode 100644 avconv_dxva.c

diff --git a/Changelog b/Changelog
index e17ef20..6aa3f03 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Intel QSV-accelerated VP8 and VC-1 decoding
 - VAAPI-accelerated VP8 and HEVC decoding
 - VAAPI-accelerated deinterlacing
+- support for decoding through D3D11VA in avconv
 
 
 version 12:
diff --git a/Makefile b/Makefile
index 26c296f..6040131 100644
--- a/Makefile
+++ b/Makefile
@@ -85,6 +85,7 @@ OBJS-avconv   += avconv_opt.o avconv_filter.o
 OBJS-avconv-$(CONFIG_LIBMFX)  += avconv_qsv.o
 OBJS-avconv-$(CONFIG_VAAPI)   += avconv_vaapi.o
 OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o
+OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o avconv_guid.o
 OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o avconv_guid.o
 OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o
 
diff --git a/avconv.h b/avconv.h
index 6360f76..1919c66 100644
--- a/avconv.h
+++ b/avconv.h
@@ -56,6 +56,7 @@ enum HWAccelID {
 HWACCEL_VDA,
 HWACCEL_QSV,
 HWACCEL_VAAPI,
+HWACCEL_D3D11VA,
 };
 
 typedef struct HWAccel {
@@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
const AVFrame *frame);
 int avconv_parse_options(int argc, char **argv);
 
 int vdpau_init(AVCodecContext *s);
+int d3d11va_init(AVCodecContext *s);
 int dxva2_init(AVCodecContext *s);
 int vda_init(AVCodecContext *s);
 int qsv_init(AVCodecContext *s);
diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c
new file mode 100644
index 000..d7ec558
--- /dev/null
+++ b/avconv_d3d11va.c
@@ -0,0 +1,213 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#endif
+#define COBJMACROS
+
+#include 
+
+#include 
+
+#include "avconv.h"
+
+#include "libavcodec/d3d11va.h"
+
+#include "libavutil/avassert.h"
+#include "libavutil/buffer.h"
+#include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/pixfmt.h"
+
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_d3d11va.h"
+
+typedef struct D3D11VAContext {
+D3D11_VIDEO_DECODER_CONFIG   decoder_config;
+
+AVFrame *tmp_frame;
+
+AVBufferRef *hw_device_ctx;
+AVBufferRef *hw_frames_ctx;
+} D3D11VAContext;
+
+typedef D3D11_VIDEO_DECODER_CONFIG DXVA_DECODER_CONFIG;
+typedef DXGI_FORMATDXVA_SURFACE_FORMAT;
+typedef D3D11VAContext DXVA_CONTEXT;
+typedef AVD3D11VAContext   DXVA_AV_CONTEXT;
+typedef ID3D11VideoDevice  *DXVA_DECODER_SERVICE;
+#include "avconv_dxva_template.c"
+
+static int d3d11va_get_decoder_configuration(AVCodecContext *s,
+ const D3D11_VIDEO_DECODER_DESC 
*desc,
+ DXVA_DECODER_CONFIG *config)
+{
+InputStream  *ist = s->opaque;
+int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
AV_LOG_ERROR;
+unsigned cfg_count = 0;
+DXVA_DECODER_CONFIG *cfg_list = NULL;
+HRESULT hr;
+int i, ret;
+
+DXVA_CONTEXT *ctx= ist->hwaccel_ctx;
+AVHWDeviceContext*device_ctx = 
(AVHWDeviceContext*)ctx->hw_device_ctx->data;
+AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx;
+
+hr = 
ID3D11VideoDevice_GetVideoDecoderConfigCount(device_hwctx->video_device, desc, 
_count);
+if (FAILED(hr)) {
+av_log(NULL, loglevel, "Unable to retrieve decoder configurations\n");
+return AVERROR(EINVAL);
+}
+
+cfg_list = av_malloc(cfg_count * sizeof(DXVA_DECODER_CONFIG));
+if (cfg_list == NULL)
+ 

[libav-devel] [PATCH 3/6] avconv: dxva2: move the DXVA GUID definitions outside of the template

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

---
 Makefile   |  2 +-
 avconv_dxva2.c |  1 +
 avconv_dxva_template.c |  7 ++-
 avconv_guid.c  | 20 
 4 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 avconv_guid.c

diff --git a/Makefile b/Makefile
index a9f5f9a..26c296f 100644
--- a/Makefile
+++ b/Makefile
@@ -85,7 +85,7 @@ OBJS-avconv   += avconv_opt.o avconv_filter.o
 OBJS-avconv-$(CONFIG_LIBMFX)  += avconv_qsv.o
 OBJS-avconv-$(CONFIG_VAAPI)   += avconv_vaapi.o
 OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o
-OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o
+OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o avconv_guid.o
 OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o
 
 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
diff --git a/avconv_dxva2.c b/avconv_dxva2.c
index 442a0bd..4c6ef8d 100644
--- a/avconv_dxva2.c
+++ b/avconv_dxva2.c
@@ -63,6 +63,7 @@ typedef struct dxva_context DXVA_AV_CONTEXT;
 typedef IDirectXVideoDecoderService *DXVA_DECODER_SERVICE;
 #include "avconv_dxva_template.c"
 
+#include 
 DEFINE_GUID(IID_IDirectXVideoDecoderService, 
0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02);
 
 static void dxva2_uninit(AVCodecContext *s)
diff --git a/avconv_dxva_template.c b/avconv_dxva_template.c
index c6bd0c5..572a140 100644
--- a/avconv_dxva_template.c
+++ b/avconv_dxva_template.c
@@ -16,9 +16,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifndef INITGUID
+#include 
+#endif
+
 /* define all the GUIDs used directly here,
  to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and 
different MSVC version */
-#include 
 DEFINE_GUID(DXVA2_ModeMPEG2_VLD,  0xee27417f, 
0x5e28,0x4e65,0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9);
 DEFINE_GUID(DXVA2_ModeMPEG2and1_VLD,  0x86695f12, 
0x340e,0x4f04,0x9f,0xd3,0x92,0x53,0xdd,0x32,0x74,0x60);
 DEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 
0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
@@ -31,6 +34,7 @@ DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 
0xef1a,0x4d19,0xab,0xa8,0x67,0
 DEFINE_GUID(DXVA2_NoEncrypt,  0x1b81beD0, 
0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
 DEFINE_GUID(GUID_NULL,0x, 
0x,0x,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
 
+#ifndef INITGUID
 typedef struct dxva_mode {
 const GUID *guid;
 enum AVCodecID codec;
@@ -287,3 +291,4 @@ fail:
 dxva_uninit(s);
 return AVERROR(EINVAL);
 }
+#endif /* INITGUID */
diff --git a/avconv_guid.c b/avconv_guid.c
new file mode 100644
index 000..0093e33
--- /dev/null
+++ b/avconv_guid.c
@@ -0,0 +1,20 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "avconv_dxva_template.c"
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 4/6] avconv_dxva2: remove unused initial values

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

---
 avconv_dxva2.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/avconv_dxva2.c b/avconv_dxva2.c
index 4c6ef8d..0edfe55 100644
--- a/avconv_dxva2.c
+++ b/avconv_dxva2.c
@@ -125,8 +125,8 @@ static int dxva2_get_decoder_configuration(AVCodecContext 
*s, const GUID *device
 InputStream  *ist = s->opaque;
 int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
AV_LOG_ERROR;
 DXVA2Context *ctx = ist->hwaccel_ctx;
-unsigned cfg_count = 0;
-DXVA2_ConfigPictureDecode *cfg_list = NULL;
+unsigned cfg_count;
+DXVA2_ConfigPictureDecode *cfg_list;
 HRESULT hr;
 int ret;
 
@@ -145,7 +145,7 @@ static int 
dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, G
 {
 HRESULT hr;
 int ret = 0;
-unsigned j, target_count = 0;
+unsigned j, target_count;
 D3DFORMAT *target_list;
 hr = IDirectXVideoDecoderService_GetDecoderRenderTargets(decoder_service, 
, _count, _list);
 if (SUCCEEDED(hr)) {
@@ -167,9 +167,9 @@ static int dxva2_create_decoder(AVCodecContext *s)
 int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
AV_LOG_ERROR;
 DXVA2Context *ctx = ist->hwaccel_ctx;
 struct dxva_context *dxva_ctx = s->hwaccel_context;
-GUID *guid_list = NULL;
-unsigned guid_count = 0;
-GUID device_guid = GUID_NULL;
+GUID *guid_list;
+unsigned guid_count;
+GUID device_guid;
 const D3DFORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
  MKTAG('P', '0', '1', '0') : MKTAG('N', 
'V', '1', '2');
 DXVA2_VideoDesc desc = { 0 };
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/6] libavutil: add support for AV_HWDEVICE_TYPE_D3D11VA

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

---
 doc/APIchanges |   3 +
 libavutil/Makefile |   3 +
 libavutil/hwcontext.c  |   3 +
 libavutil/hwcontext.h  |   1 +
 libavutil/hwcontext_d3d11va.c  | 460 +
 libavutil/hwcontext_d3d11va.h  |  70 +++
 libavutil/hwcontext_internal.h |   1 +
 libavutil/version.h|   2 +-
 8 files changed, 542 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/hwcontext_d3d11va.c
 create mode 100644 libavutil/hwcontext_d3d11va.h

diff --git a/doc/APIchanges b/doc/APIchanges
index 7633c99..29d5113 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2017-xx-xx - xxx - lavu 55.30.0 - hwcontext.h
+  Add AV_HWDEVICE_TYPE_D3D11VA to decode using Direct3D11.
+
 2016-xx-xx - xxx - lavc 57.29.0 - avcodec.h
   Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
   information from containers.
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 60e180c..6fb24db 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -27,6 +27,7 @@ HEADERS = adler32.h   
  \
   hmac.h\
   hwcontext.h   \
   hwcontext_cuda.h  \
+  hwcontext_d3d11va.h   \
   hwcontext_dxva2.h \
   hwcontext_qsv.h   \
   hwcontext_vaapi.h \
@@ -112,6 +113,7 @@ OBJS = adler32.o
\
xtea.o   \
 
 OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
+OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
 OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o
 OBJS-$(CONFIG_LIBMFX)   += hwcontext_qsv.o
 OBJS-$(CONFIG_LZO)  += lzo.o
@@ -121,6 +123,7 @@ OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o
 OBJS += $(COMPAT_OBJS:%=../compat/%)
 
 SKIPHEADERS-$(CONFIG_CUDA) += hwcontext_cuda.h
+SKIPHEADERS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= hwcontext_dxva2.h
 SKIPHEADERS-$(CONFIG_LIBMFX)   += hwcontext_qsv.h
 SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 83f733e..ae27c51 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = {
 #if CONFIG_CUDA
 _hwcontext_type_cuda,
 #endif
+#if CONFIG_D3D11VA
+_hwcontext_type_d3d11va,
+#endif
 #if CONFIG_DXVA2
 _hwcontext_type_dxva2,
 #endif
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index 037ca64..d64b2da 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -30,6 +30,7 @@ enum AVHWDeviceType {
 AV_HWDEVICE_TYPE_VAAPI,
 AV_HWDEVICE_TYPE_DXVA2,
 AV_HWDEVICE_TYPE_QSV,
+AV_HWDEVICE_TYPE_D3D11VA,
 };
 
 typedef struct AVHWDeviceInternal AVHWDeviceInternal;
diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
new file mode 100644
index 000..a23a475
--- /dev/null
+++ b/libavutil/hwcontext_d3d11va.c
@@ -0,0 +1,460 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#endif
+#define COBJMACROS
+
+#include 
+#include 
+#include 
+
+#include "avassert.h"
+#include "common.h"
+#include "hwcontext.h"
+#include "hwcontext_d3d11va.h"
+#include "hwcontext_internal.h"
+#include "imgutils.h"
+#include "pixdesc.h"
+#include "pixfmt.h"
+
+typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void 
**ppFactory);
+
+typedef struct D3D11VAFramesContext {
+ID3D11VideoDecoderOutputView **surfaces_internal;
+int  nb_surfaces_used;
+
+ID3D11DeviceContext 

[libav-devel] [PATCH 6/6] avconv: use the typedefs more to make comparison between dxva2 and d3d11va

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

---
 avconv_dxva2.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/avconv_dxva2.c b/avconv_dxva2.c
index 0edfe55..99f608f 100644
--- a/avconv_dxva2.c
+++ b/avconv_dxva2.c
@@ -69,7 +69,7 @@ DEFINE_GUID(IID_IDirectXVideoDecoderService, 
0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,
 static void dxva2_uninit(AVCodecContext *s)
 {
 InputStream  *ist = s->opaque;
-DXVA2Context *ctx = ist->hwaccel_ctx;
+DXVA_CONTEXT *ctx = ist->hwaccel_ctx;
 
 if (ctx->decoder_service)
 IDirectXVideoDecoderService_Release(ctx->decoder_service);
@@ -81,7 +81,7 @@ static int dxva2_alloc(AVCodecContext *s)
 {
 InputStream  *ist = s->opaque;
 int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
AV_LOG_ERROR;
-DXVA2Context *ctx;
+DXVA_CONTEXT *ctx;
 HANDLE device_handle;
 HRESULT hr;
 
@@ -120,13 +120,13 @@ fail:
 
 static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID 
*device_guid,
const DXVA2_VideoDesc *desc,
-   DXVA2_ConfigPictureDecode *config)
+   DXVA_DECODER_CONFIG *config)
 {
 InputStream  *ist = s->opaque;
 int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
AV_LOG_ERROR;
-DXVA2Context *ctx = ist->hwaccel_ctx;
+DXVA_CONTEXT *ctx = ist->hwaccel_ctx;
 unsigned cfg_count;
-DXVA2_ConfigPictureDecode *cfg_list;
+DXVA_DECODER_CONFIG *cfg_list;
 HRESULT hr;
 int ret;
 
@@ -141,7 +141,7 @@ static int dxva2_get_decoder_configuration(AVCodecContext 
*s, const GUID *device
 return ret;
 }
 
-static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, 
GUID guid, D3DFORMAT surface_format)
+static int dxva2_validate_output(DXVA_DECODER_SERVICE decoder_service, GUID 
guid, DXVA_SURFACE_FORMAT surface_format)
 {
 HRESULT hr;
 int ret = 0;
@@ -165,15 +165,15 @@ static int dxva2_create_decoder(AVCodecContext *s)
 {
 InputStream  *ist = s->opaque;
 int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : 
AV_LOG_ERROR;
-DXVA2Context *ctx = ist->hwaccel_ctx;
-struct dxva_context *dxva_ctx = s->hwaccel_context;
+DXVA_CONTEXT *ctx = ist->hwaccel_ctx;
+DXVA_AV_CONTEXT *dxva_ctx = s->hwaccel_context;
 GUID *guid_list;
 unsigned guid_count;
 GUID device_guid;
-const D3DFORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
- MKTAG('P', '0', '1', '0') : MKTAG('N', 
'V', '1', '2');
+const DXVA_SURFACE_FORMAT surface_format = s->sw_pix_fmt == 
AV_PIX_FMT_YUV420P10 ?
+   MKTAG('P', '0', '1', '0') : 
MKTAG('N', 'V', '1', '2');
 DXVA2_VideoDesc desc = { 0 };
-DXVA2_ConfigPictureDecode config;
+DXVA_DECODER_CONFIG config;
 HRESULT hr;
 int ret;
 
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 4/4] dxva2: allow an empty array of ID3D11VideoDecoderOutputView

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

We can pick the correct slice index directly from the 
ID3D11VideoDecoderOutputView
casted from data[3].
---
 libavcodec/dxva2_internal.h | 4 ++--
 libavcodec/version.h| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 2e425f6..7667deb 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -73,7 +73,7 @@ typedef union {
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == 
AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : 
ctx->dxva2.cfg->ConfigResidDiffAccelerator)
 #define DXVA_CONTEXT_VALID(avctx, ctx)  (DXVA_CONTEXT_DECODER(avctx, 
ctx) && \
  DXVA_CONTEXT_CFG(avctx, ctx) 
&& \
- DXVA_CONTEXT_COUNT(avctx, 
ctx))
+ (avctx->pix_fmt == 
AV_PIX_FMT_D3D11VA_VLD || ctx->dxva2.surface_count))
 #elif CONFIG_DXVA2
 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
 #define DXVA_CONTEXT_COUNT(avctx, ctx)  (ctx->dxva2.surface_count)
@@ -93,7 +93,7 @@ typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  
(ctx->d3d11va.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) 
(ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) 
(ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
-#define DXVA_CONTEXT_VALID(avctx, ctx)  (ctx->d3d11va.decoder && 
ctx->d3d11va.cfg && ctx->d3d11va.surface_count)
+#define DXVA_CONTEXT_VALID(avctx, ctx)  (ctx->d3d11va.decoder && 
ctx->d3d11va.cfg)
 #endif
 
 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 5b6fb6c..7348a0c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 57
 #define LIBAVCODEC_VERSION_MINOR 30
-#define LIBAVCODEC_VERSION_MICRO  2
+#define LIBAVCODEC_VERSION_MICRO  3
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

No need to loop through the known surfaces, we'll use it anyway.

The loop is only done for DXVA2
---
 libavcodec/dxva2.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 6fc4f97..b0452b6 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -41,19 +41,19 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext 
*avctx,
 void *surface = get_surface(frame);
 unsigned i;
 
-for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
 #if CONFIG_D3D11VA
-if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && 
ctx->d3d11va.surface[i] == surface) {
-D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
-ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], 
);
-return viewDesc.Texture2D.ArraySlice;
-}
+if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
+D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
+ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) 
surface, );
+return viewDesc.Texture2D.ArraySlice;
+}
 #endif
 #if CONFIG_DXVA2
+for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == 
surface)
 return i;
-#endif
 }
+#endif
 
 assert(0);
 return 0;
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static and rename it

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

---
 libavcodec/dxva2.c  | 8 
 libavcodec/dxva2_internal.h | 2 --
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 6063993..6fc4f97 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -29,7 +29,7 @@
 #include "avcodec.h"
 #include "dxva2_internal.h"
 
-void *ff_dxva2_get_surface(const AVFrame *frame)
+static void *get_surface(const AVFrame *frame)
 {
 return frame->data[3];
 }
@@ -38,7 +38,7 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext 
*avctx,
 const AVDXVAContext *ctx,
 const AVFrame *frame)
 {
-void *surface = ff_dxva2_get_surface(frame);
+void *surface = get_surface(frame);
 unsigned i;
 
 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
@@ -158,14 +158,14 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, 
AVFrame *frame,
 if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
 WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, 
INFINITE, FALSE);
 hr = 
ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, 
D3D11VA_CONTEXT(ctx)->decoder,
-  
ff_dxva2_get_surface(frame),
+  get_surface(frame),
   0, NULL);
 }
 #endif
 #if CONFIG_DXVA2
 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
 hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->decoder,
- ff_dxva2_get_surface(frame),
+ get_surface(frame),
  NULL);
 #endif
 if (hr != E_PENDING || ++runs > 50)
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 499b37c..a2ebc2a 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -91,8 +91,6 @@ typedef union {
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) 
(ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
 #endif
 
-void *ff_dxva2_get_surface(const AVFrame *frame);
-
 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
 const AVDXVAContext *,
 const AVFrame *frame);
-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 0/4] DXVA2 cleaning

2017-01-03 Thread Steve Lhomme
This patchset was already sent but various cleaning has been done and it has
been rebased to the latest master.

The main goal is to have patch 3/4 that allows more flexibility on the decoder
pool, which we need in VLC for better efficiency. Patch 4/4 is the one that
enables this flexibility.

Steve Lhomme (4):
  dxva2: make ff_dxva2_get_surface() static and rename it
  dxva2: use a single macro to test if the DXVA context is valid
  dxva2: get the slice number directly from the surface in D3D11VA
  dxva2: allow an empty array of ID3D11VideoDecoderOutputView

 libavcodec/dxva2.c  | 22 +++---
 libavcodec/dxva2_h264.c |  4 +---
 libavcodec/dxva2_hevc.c |  4 +---
 libavcodec/dxva2_internal.h |  7 +--
 libavcodec/dxva2_mpeg2.c|  4 +---
 libavcodec/dxva2_vc1.c  |  4 +---
 libavcodec/version.h|  2 +-
 7 files changed, 21 insertions(+), 26 deletions(-)

-- 
2.10.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 2/4] dxva2: use a single macro to test if the DXVA context is valid

2017-01-03 Thread Steve Lhomme
From: Steve Lhomme 

---
 libavcodec/dxva2_h264.c | 4 +---
 libavcodec/dxva2_hevc.c | 4 +---
 libavcodec/dxva2_internal.h | 5 +
 libavcodec/dxva2_mpeg2.c| 4 +---
 libavcodec/dxva2_vc1.c  | 4 +---
 5 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 5622c22..84959c5 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -445,9 +445,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
 AVDXVAContext *ctx = avctx->hwaccel_context;
 struct dxva2_picture_context *ctx_pic = 
h->cur_pic_ptr->hwaccel_picture_private;
 
-if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+if (!DXVA_CONTEXT_VALID(avctx, ctx))
 return -1;
 assert(ctx_pic);
 
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 673fada..17548d2 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -365,9 +365,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
 AVDXVAContext *ctx = avctx->hwaccel_context;
 struct hevc_dxva2_picture_context *ctx_pic = 
h->ref->hwaccel_picture_private;
 
-if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+if (!DXVA_CONTEXT_VALID(avctx, ctx))
 return -1;
 av_assert0(ctx_pic);
 
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index a2ebc2a..2e425f6 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -71,6 +71,9 @@ typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (avctx->pix_fmt == 
AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : 
ctx->dxva2.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == 
AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : 
ctx->dxva2.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == 
AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : 
ctx->dxva2.cfg->ConfigResidDiffAccelerator)
+#define DXVA_CONTEXT_VALID(avctx, ctx)  (DXVA_CONTEXT_DECODER(avctx, 
ctx) && \
+ DXVA_CONTEXT_CFG(avctx, ctx) 
&& \
+ DXVA_CONTEXT_COUNT(avctx, 
ctx))
 #elif CONFIG_DXVA2
 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround)
 #define DXVA_CONTEXT_COUNT(avctx, ctx)  (ctx->dxva2.surface_count)
@@ -80,6 +83,7 @@ typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  
(ctx->dxva2.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) 
(ctx->dxva2.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) 
(ctx->dxva2.cfg->ConfigResidDiffAccelerator)
+#define DXVA_CONTEXT_VALID(avctx, ctx)  (ctx->dxva2.decoder && 
ctx->dxva2.cfg && ctx->dxva2.surface_count)
 #elif CONFIG_D3D11VA
 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround)
 #define DXVA_CONTEXT_COUNT(avctx, ctx)  (ctx->d3d11va.surface_count)
@@ -89,6 +93,7 @@ typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  
(ctx->d3d11va.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) 
(ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) 
(ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
+#define DXVA_CONTEXT_VALID(avctx, ctx)  (ctx->d3d11va.decoder && 
ctx->d3d11va.cfg && ctx->d3d11va.surface_count)
 #endif
 
 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index 2d88f9b..a459049 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -263,9 +263,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
 struct dxva2_picture_context *ctx_pic =
 s->current_picture_ptr->hwaccel_picture_private;
 
-if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+if (!DXVA_CONTEXT_VALID(avctx, ctx))
 return -1;
 assert(ctx_pic);
 
diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index d170e18..0672c97 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -264,9 +264,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
 AVDXVAContext *ctx = avctx->hwaccel_context;
 struct dxva2_picture_context *ctx_pic = 
v->s.current_picture_ptr->hwaccel_picture_private;
 
-if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+if (!DXVA_CONTEXT_VALID(avctx, ctx))
 return -1;
 assert(ctx_pic);
 
-- 
2.10.2


Re: [libav-devel] [PATCH 2/5] libautil: add support for AV_HWDEVICE_TYPE_D3D11VA

2017-01-03 Thread Steve Lhomme
Hi,


On Mon, Dec 19, 2016 at 1:04 PM, Anton Khirnov  wrote:
> Quoting Steve Lhomme (2016-12-16 11:05:40)
>> From: Steve Lhomme 
>>
>> ---
>>  libavutil/Makefile |   3 +
>>  libavutil/hwcontext.c  |   3 +
>>  libavutil/hwcontext.h  |   1 +
>>  libavutil/hwcontext_d3d11va.c  | 456 
>> +
>>  libavutil/hwcontext_d3d11va.h  |  81 
>>  libavutil/hwcontext_internal.h |   1 +
>>  libavutil/version.h|   2 +-
>>  7 files changed, 546 insertions(+), 1 deletion(-)
>>  create mode 100644 libavutil/hwcontext_d3d11va.c
>>  create mode 100644 libavutil/hwcontext_d3d11va.h
>>
>> diff --git a/libavutil/Makefile b/libavutil/Makefile
>> index f34c799..962dcf2 100644
>> --- a/libavutil/Makefile
>> +++ b/libavutil/Makefile
>> @@ -26,6 +26,7 @@ HEADERS = adler32.h
>>  \
>>hmac.h\
>>hwcontext.h   \
>>hwcontext_cuda.h  \
>> +  hwcontext_d3d11va.h   \
>>hwcontext_dxva2.h \
>>hwcontext_qsv.h   \
>>hwcontext_vaapi.h \
>> @@ -111,6 +112,7 @@ OBJS = adler32.o 
>>\
>> xtea.o   \
>>
>>  OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
>> +OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
>>  OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o
>>  OBJS-$(CONFIG_LIBMFX)   += hwcontext_qsv.o
>>  OBJS-$(CONFIG_LZO)  += lzo.o
>> @@ -120,6 +122,7 @@ OBJS-$(CONFIG_VDPAU)+= 
>> hwcontext_vdpau.o
>>  OBJS += $(COMPAT_OBJS:%=../compat/%)
>>
>>  SKIPHEADERS-$(CONFIG_CUDA) += hwcontext_cuda.h
>> +SKIPHEADERS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.h
>>  SKIPHEADERS-$(CONFIG_DXVA2)+= hwcontext_dxva2.h
>>  SKIPHEADERS-$(CONFIG_LIBMFX)   += hwcontext_qsv.h
>>  SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h
>> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
>> index 83f733e..ae27c51 100644
>> --- a/libavutil/hwcontext.c
>> +++ b/libavutil/hwcontext.c
>> @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = {
>>  #if CONFIG_CUDA
>>  _hwcontext_type_cuda,
>>  #endif
>> +#if CONFIG_D3D11VA
>> +_hwcontext_type_d3d11va,
>> +#endif
>>  #if CONFIG_DXVA2
>>  _hwcontext_type_dxva2,
>>  #endif
>> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
>> index 037ca64..d64b2da 100644
>> --- a/libavutil/hwcontext.h
>> +++ b/libavutil/hwcontext.h
>> @@ -30,6 +30,7 @@ enum AVHWDeviceType {
>>  AV_HWDEVICE_TYPE_VAAPI,
>>  AV_HWDEVICE_TYPE_DXVA2,
>>  AV_HWDEVICE_TYPE_QSV,
>> +AV_HWDEVICE_TYPE_D3D11VA,
>>  };
>>
>>  typedef struct AVHWDeviceInternal AVHWDeviceInternal;
>> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
>> new file mode 100644
>> index 000..db5ec03
>> --- /dev/null
>> +++ b/libavutil/hwcontext_d3d11va.c
>> @@ -0,0 +1,456 @@
>> +/*
>> + * This file is part of Libav.
>> + *
>> + * Libav is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * Libav is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with Libav; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
>> USA
>> + */
>> +
>> +#include 
>> +
>> +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
>> +#undef _WIN32_WINNT
>> +#define _WIN32_WINNT 0x0600
>> +#endif
>> +#define COBJMACROS
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "avassert.h"
>> +#include "common.h"
>> +#include "hwcontext.h"
>> +#include "hwcontext_d3d11va.h"
>> +#include "hwcontext_internal.h"
>> +#include "imgutils.h"
>> +#include "pixdesc.h"
>> +#include "pixfmt.h"
>> +
>> +typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void 
>> **ppFactory);
>> +
>> +typedef struct D3D11VAFramesContext {
>> +ID3D11VideoDecoderOutputView **surfaces_internal;
>> +int  nb_surfaces_used;
>> +
>> +ID3D11DeviceContext 

Re: [libav-devel] [PATCH] avconv: Do not pass NULL to avio_tell

2017-01-03 Thread Vittorio Giovara
On Tue, Jan 3, 2017 at 1:41 PM, Vittorio Giovara
 wrote:
> On Tue, Jan 3, 2017 at 1:33 PM, Luca Barbato  wrote:
>> On 03/01/2017 11:51, Vittorio Giovara wrote:
>>> Should it? What happens here when you do pass NULL?
>>
>> It spams a pointless message on verbose.
>
> mention it in the commit log please
>
> total_size is used without being initialized below

I missed
+int64_t total_size = 0;

patch ok then (with message amended)
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avconv: Do not pass NULL to avio_tell

2017-01-03 Thread Vittorio Giovara
On Tue, Jan 3, 2017 at 1:33 PM, Luca Barbato  wrote:
> On 03/01/2017 11:51, Vittorio Giovara wrote:
>> Should it? What happens here when you do pass NULL?
>
> It spams a pointless message on verbose.

mention it in the commit log please

total_size is used without being initialized below
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avconv: Do not pass NULL to avio_tell

2017-01-03 Thread Luca Barbato
On 03/01/2017 11:51, Vittorio Giovara wrote:
> Should it? What happens here when you do pass NULL?

It spams a pointless message on verbose.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] crypto: consistently use size_t as type for length parameters

2017-01-03 Thread Diego Biurrun
size_t is the correct type to use for sizes.
---

Dropped the kind of pointless version bump.

 doc/APIchanges  | 4 
 libavutil/md5.c | 8 
 libavutil/md5.h | 8 +++-
 libavutil/sha.c | 6 +-
 libavutil/sha.h | 9 +++--
 libavutil/version.h | 3 +++
 6 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 7633c99..9423379 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2016-xx-xx - xxx
+  Change av_sha_update() and av_md5_sum()/av_md5_update() length
+  parameter type to size_t at next major bump.
+
 2016-xx-xx - xxx - lavc 57.29.0 - avcodec.h
   Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
   information from containers.
diff --git a/libavutil/md5.c b/libavutil/md5.c
index 94f0681..1946d78 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -146,7 +146,11 @@ void av_md5_init(AVMD5 *ctx)
 ctx->ABCD[3] = 0x67452301;
 }
 
+#if FF_API_CRYPTO_SIZE_T
 void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len)
+#else
+void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
+#endif
 {
 int i, j;
 
@@ -177,7 +181,11 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst)
 AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]);
 }
 
+#if FF_API_CRYPTO_SIZE_T
 void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
+#else
+void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len)
+#endif
 {
 AVMD5 ctx;
 
diff --git a/libavutil/md5.h b/libavutil/md5.h
index c26318c..55e7c23 100644
--- a/libavutil/md5.h
+++ b/libavutil/md5.h
@@ -21,6 +21,7 @@
 #ifndef AVUTIL_MD5_H
 #define AVUTIL_MD5_H
 
+#include 
 #include 
 
 #include "attributes.h"
@@ -36,9 +37,14 @@ struct AVMD5;
 
 struct AVMD5 *av_md5_alloc(void);
 void av_md5_init(struct AVMD5 *ctx);
-void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
 void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
+#if FF_API_CRYPTO_SIZE_T
+void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
 void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
+#else
+void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len);
+void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len);
+#endif
 
 /**
  * @}
diff --git a/libavutil/sha.c b/libavutil/sha.c
index 404effa..e7ba919 100644
--- a/libavutil/sha.c
+++ b/libavutil/sha.c
@@ -290,7 +290,11 @@ av_cold int av_sha_init(AVSHA *ctx, int bits)
 return 0;
 }
 
-void av_sha_update(AVSHA* ctx, const uint8_t* data, unsigned int len)
+#if FF_API_CRYPTO_SIZE_T
+void av_sha_update(struct AVSHA* ctx, const uint8_t* data, unsigned int len)
+#else
+void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len)
+#endif
 {
 unsigned int i, j;
 
diff --git a/libavutil/sha.h b/libavutil/sha.h
index 86ea0b0..653d7d6 100644
--- a/libavutil/sha.h
+++ b/libavutil/sha.h
@@ -21,6 +21,7 @@
 #ifndef AVUTIL_SHA_H
 #define AVUTIL_SHA_H
 
+#include 
 #include 
 
 #include "attributes.h"
@@ -51,11 +52,15 @@ int av_sha_init(struct AVSHA* context, int bits);
 /**
  * Update hash value.
  *
- * @param context hash function context
+ * @param ctx hash function context
  * @param datainput data to update hash with
  * @param len input data length
  */
-void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int 
len);
+#if FF_API_CRYPTO_SIZE_T
+void av_sha_update(struct AVSHA* ctx, const uint8_t* data, unsigned int len);
+#else
+void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len);
+#endif
 
 /**
  * Finish hashing and output digest value.
diff --git a/libavutil/version.h b/libavutil/version.h
index f110231..3733fea 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -105,6 +105,9 @@
 #ifndef FF_API_PKT_PTS
 #define FF_API_PKT_PTS  (LIBAVUTIL_VERSION_MAJOR < 56)
 #endif
+#ifndef FF_API_CRYPTO_SIZE_T
+#define FF_API_CRYPTO_SIZE_T(LIBAVUTIL_VERSION_MAJOR < 56)
+#endif
 
 
 /**
-- 
2.1.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avconv: Do not pass NULL to avio_tell

2017-01-03 Thread Vittorio Giovara
On Thu, Dec 15, 2016 at 7:01 PM, Luca Barbato  wrote:
> The null demuxer does not have a backing AVIOContext.

Should it? What happens here when you do pass NULL?

> ---
>  avconv.c | 23 ---
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/avconv.c b/avconv.c
> index 5c31332..fe60625 100644
> --- a/avconv.c
> +++ b/avconv.c
> @@ -909,7 +909,7 @@ static void print_report(int is_last_report, int64_t 
> timer_start)
>  char buf[1024];
>  OutputStream *ost;
>  AVFormatContext *oc;
> -int64_t total_size;
> +int64_t total_size = 0;
>  AVCodecContext *enc;
>  int frame_number, vid, i;
>  double bitrate, ti1, pts;
> @@ -934,16 +934,17 @@ static void print_report(int is_last_report, int64_t 
> timer_start)
>
>
>  oc = output_files[0]->ctx;
> -
> -total_size = avio_size(oc->pb);
> -if (total_size <= 0) // FIXME improve avio_size() so it works with non 
> seekable output too
> -total_size = avio_tell(oc->pb);
> -if (total_size < 0) {
> -char errbuf[128];
> -av_strerror(total_size, errbuf, sizeof(errbuf));
> -av_log(NULL, AV_LOG_VERBOSE, "Bitrate not available, "
> -   "avio_tell() failed: %s\n", errbuf);
> -total_size = 0;
> +if (oc->pb) {
> +total_size = avio_size(oc->pb);
> +if (total_size <= 0) // FIXME improve avio_size() so it works with 
> non seekable output too
> +total_size = avio_tell(oc->pb);
> +if (total_size < 0) {
> +char errbuf[128];
> +av_strerror(total_size, errbuf, sizeof(errbuf));
> +av_log(NULL, AV_LOG_VERBOSE, "Bitrate not available, "
> +   "avio_tell() failed: %s\n", errbuf);
> +total_size = 0;
> +}
>  }
>
>  buf[0] = '\0';
> --
> 2.9.2
>
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel



-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/8] hevcdec: export cropping information instead of handling it internally

2017-01-03 Thread Vittorio Giovara
On Tue, Dec 27, 2016 at 7:31 PM, Anton Khirnov  wrote:
> ---
>  libavcodec/hevc_parser.c |  6 --
>  libavcodec/hevc_ps.c | 33 -
>  libavcodec/hevc_ps.h |  2 --
>  libavcodec/hevc_refs.c   | 19 ---
>  libavcodec/hevcdec.c |  7 ---
>  libavcodec/hevcdec.h |  2 --
>  6 files changed, 24 insertions(+), 45 deletions(-)
>

the behaviour of `apply_defdispwin` seems unchanged so this lgtm
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/8] lavc: add an option for exporting cropping information to the caller

2017-01-03 Thread Vittorio Giovara
On Tue, Dec 27, 2016 at 7:31 PM, Anton Khirnov  wrote:
> Also, add generic code for handling cropping, so the decoders can export
> just the cropping size and not bother with the rest.
> ---
>  doc/APIchanges |   4 ++
>  libavcodec/avcodec.h   |  22 +
>  libavcodec/decode.c| 112 
> -
>  libavcodec/internal.h  |   6 +++
>  libavcodec/options_table.h |   1 +
>  libavcodec/version.h   |   4 +-
>  6 files changed, 146 insertions(+), 3 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 10a2da4..a0ef198 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,10 @@ libavutil: 2015-08-28
>
>  API changes, most recent first:
>
> +2016-xx-xx - xxx - lavc 57.31.0 - avcodec.h
> +  Add AVCodecContext.apply_cropping to control whether cropping
> +  is handled by libavcodec or the caller.
> +
>  2016-xx-xx - xxx - lavu 55.30.0 - frame.h
>Add AVFrame.crop_left/right/top/bottom fields for attaching cropping
>information to video frames.
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 95da50b..524e06a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3112,6 +3112,28 @@ typedef struct AVCodecContext {
>   * This field should be set before avcodec_open2() is called.
>   */
>  AVBufferRef *hw_frames_ctx;
> +
> +/**
> + * Video decoding only. Certain video codecs support cropping, meaning 
> that
> + * only a sub-rectangle of the decoded frame is intended for display.  
> This
> + * option controls how cropping is handled by libavcodec.
> + *
> + * When set to 1 (the default), libavcodec will apply cropping 
> internally.
> + * I.e. it will modify the output frame width/height fields and offset 
> the
> + * data pointers (only by as much as possible while preserving 
> alignment, or
> + * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that
> + * the frames output by the decoder refer only to the cropped area. The
> + * crop_* fields of the output frames will be zero.
> + *
> + * When set to 0, the width/height fields of the output frames will be 
> set
> + * to the coded dimensions and the crop_* fields will describe the 
> cropping
> + * rectangle. Applying the cropping is left to the caller.
> + *
> + * When hardware acceleration with opaque output frames is used, the 
> actual
> + * value of this option is disregarded and libavcodec behaves as if it 
> was
> + * set to 0.
> + */
> +int apply_cropping;

Why is this a new field? As long as it is used to convey a boolean
state isn't a codec flag more efficient?

>  } AVCodecContext;
>
>  /**
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 0fd41ab..65ee8b0 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -29,6 +29,7 @@
>  #include "libavutil/frame.h"
>  #include "libavutil/hwcontext.h"
>  #include "libavutil/imgutils.h"
> +#include "libavutil/intmath.h"
>
>  #include "avcodec.h"
>  #include "bytestream.h"
> @@ -450,6 +451,106 @@ int attribute_align_arg 
> avcodec_send_packet(AVCodecContext *avctx, const AVPacke
>  return 0;
>  }
>
> +static int calc_cropping_offsets(size_t offsets[4], const AVFrame *frame,
> + const AVPixFmtDescriptor *desc)

IMO passing desc here is not ideal, deriving it from frame seems more
usual to me

> +{
> +int i, j;
> +
> +for (i = 0; frame->data[i]; i++) {
> +const AVComponentDescriptor *comp = NULL;
> +int shift_x = (i == 1 || i == 2) ? desc->log2_chroma_w : 0;
> +int shift_y = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
> +
> +if (desc->flags & (AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_PSEUDOPAL) 
> && i == 1) {
> +offsets[i] = 0;
> +break;
> +}
> +
> +/* find any component descriptor for this plane */
> +for (j = 0; j < desc->nb_components; j++) {
> +if (desc->comp[j].plane == i) {
> +comp = >comp[j];
> +break;
> +}
> +}
> +if (!comp)
> +return AVERROR_BUG;
> +
> +offsets[i] = (frame->crop_top  >> shift_y) * frame->linesize[i] +
> + (frame->crop_left >> shift_x) * comp->step;
> +}
> +
> +return 0;
> +}
> +
> +static int apply_cropping(AVCodecContext *avctx, AVFrame *frame)
> +{
> +const AVPixFmtDescriptor *desc;
> +size_t offsets[4];
> +int i;
> +
> +/* make sure we are noisy about decoders returning invalid cropping data 
> */
> +if (frame->crop_left >= INT_MAX - frame->crop_right||
> +frame->crop_top  >= INT_MAX - frame->crop_bottom   ||
> +(frame->crop_left + frame->crop_right) >= frame->width ||
> +(frame->crop_top + frame->crop_bottom) >= frame->height) {
> +av_log(avctx, AV_LOG_WARNING,
> +  

Re: [libav-devel] [PATCH 1/8] frame: add a cropping rectangle to AVFrame

2017-01-03 Thread Vittorio Giovara
On Tue, Dec 27, 2016 at 7:31 PM, Anton Khirnov  wrote:
> Extend the width/height doy to clarify that it should store coded
> values.

s/doy/documentation/ ?

> ---
>  doc/APIchanges  |  4 
>  libavutil/frame.c   |  4 
>  libavutil/frame.h   | 28 +++-
>  libavutil/version.h |  2 +-
>  4 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 7633c99..10a2da4 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,10 @@ libavutil: 2015-08-28
>
>  API changes, most recent first:
>
> +2016-xx-xx - xxx - lavu 55.30.0 - frame.h
> +  Add AVFrame.crop_left/right/top/bottom fields for attaching cropping
> +  information to video frames.
> +
>  2016-xx-xx - xxx - lavc 57.29.0 - avcodec.h
>Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
>information from containers.
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 1c14f5f..aafaa57 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -390,6 +390,10 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
>  dst->key_frame  = src->key_frame;
>  dst->pict_type  = src->pict_type;
>  dst->sample_aspect_ratio= src->sample_aspect_ratio;
> +dst->crop_top   = src->crop_top;
> +dst->crop_bottom= src->crop_bottom;
> +dst->crop_left  = src->crop_left;
> +dst->crop_right = src->crop_right;
>  dst->pts= src->pts;
>  dst->repeat_pict= src->repeat_pict;
>  dst->interlaced_frame   = src->interlaced_frame;
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 4052199..c718f7b 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -25,6 +25,7 @@
>  #ifndef AVUTIL_FRAME_H
>  #define AVUTIL_FRAME_H
>
> +#include 
>  #include 
>
>  #include "avutil.h"
> @@ -180,9 +181,18 @@ typedef struct AVFrame {
>  uint8_t **extended_data;
>
>  /**
> - * width and height of the video frame
> + * @name Video dimensions
> + * Video frames only. The coded dimensions (in pixels) of the video 
> frame,
> + * i.e. the size of the rectangle that contains some well-defined values.
> + *
> + * @note The part of the frame intended for display/presentation is 
> further
> + * restricted by the @ref cropping "Cropping rectangle".

Can you add a note mentioning the semantics of these fields are
different than the ones in avctx?

> + * @{
>   */
>  int width, height;
> +/**
> + * @}
> + */
>
>  /**
>   * number of audio samples (per channel) described by this frame
> @@ -369,6 +379,22 @@ typedef struct AVFrame {
>   * AVHWFramesContext describing the frame.
>   */
>  AVBufferRef *hw_frames_ctx;
> +
> +/**
> + * @anchor cropping
> + * @name Cropping
> + * Video frames only. The number of pixels to discard from the the
> + * top/bottom/left/right border of the frame to obtain the sub-rectangle 
> of
> + * the frame intended for presentation.
> + * @{
> + */
> +size_t crop_top;
> +size_t crop_bottom;
> +size_t crop_left;
> +size_t crop_right;

I think it makes sense to use size_t here, even though it creates a
precedent WRT older API. I would agree to a small overhaul to update
the type elsewhere.

> +/**
> + * @}
> + */
>  } AVFrame;
>
>  /**
> diff --git a/libavutil/version.h b/libavutil/version.h
> index f110231..e9940f2 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -54,7 +54,7 @@
>   */
>
>  #define LIBAVUTIL_VERSION_MAJOR 55
> -#define LIBAVUTIL_VERSION_MINOR 29
> +#define LIBAVUTIL_VERSION_MINOR 30
>  #define LIBAVUTIL_VERSION_MICRO  0
>
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> --

ok I guess
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 7/8] h264dec: export cropping information instead of handling it internally

2017-01-03 Thread Vittorio Giovara
On Tue, Dec 27, 2016 at 7:31 PM, Anton Khirnov  wrote:
> ---
>  libavcodec/h264_ps.c|  9 -
>  libavcodec/h264_slice.c | 21 +++--
>  libavcodec/h264dec.c| 26 +++---
>  libavcodec/h264dec.h|  5 +
>  4 files changed, 27 insertions(+), 34 deletions(-)

ok
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 4/8] h264dec: drop a redundant check

2017-01-03 Thread Vittorio Giovara
On Tue, Dec 27, 2016 at 7:31 PM, Anton Khirnov  wrote:
> Cropping parameters are already checked for validity during SPS parsing,
> no need to check them again.
> ---
>  libavcodec/h264_slice.c | 17 -
>  1 file changed, 17 deletions(-)

ok
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 4/4] h264_cavlc: check the value of run_before

2017-01-03 Thread Vittorio Giovara
On Wed, Dec 28, 2016 at 1:15 PM, Anton Khirnov  wrote:
> Section 9.2.3.2 of the spec implies that run_before must not be larger
> than zeros_left.
>
> Fixes invalid reads with corrupted files.
>
> CC: libav-sta...@libav.org
> Bug-Id: 1000
> Found-By: Kamil Frankowicz
> ---
>  libavcodec/h264_cavlc.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

ok
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/4] h2645_parse: use the bytestream2 API for packet splitting

2017-01-03 Thread Vittorio Giovara
On Wed, Dec 28, 2016 at 1:15 PM, Anton Khirnov  wrote:
> The code does some nontrivial jumping around in the buffer, so it is
> safer to use a checked API rather than do everything manually.
>
> Fixes a bug in nalff parsing, where the length field is currently not
> counted in the buffer size check, resulting in possible overreads with
> invalid files.
>
> CC: libav-sta...@libav.org
> Bug-Id: 1002
> Found-By: Kamil Frankowicz
> ---
>  libavcodec/h2645_parse.c | 43 +--
>  1 file changed, 21 insertions(+), 22 deletions(-)
>

should be ok
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 8/8] theora: export cropping information instead of handling it internally

2017-01-03 Thread Vittorio Giovara
On Tue, Dec 27, 2016 at 7:31 PM, Anton Khirnov  wrote:
> ---
>  libavcodec/vp3.c | 23 +--
>  1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 26374cc..cb8925b 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -1983,6 +1983,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
>  void *data, int *got_frame,
>  AVPacket *avpkt)
>  {
> +AVFrame *frame  = data;
>  const uint8_t *buf  = avpkt->data;
>  int buf_size= avpkt->size;
>  Vp3DecodeContext *s = avctx->priv_data;
> @@ -2122,12 +2123,12 @@ static int vp3_decode_frame(AVCodecContext *avctx,
>  /* output frame, offset as needed */
>  if ((ret = av_frame_ref(data, s->current_frame.f)) < 0)
>  return ret;
> -for (i = 0; i < 3; i++) {
> -AVFrame *dst = data;
> -int off = (s->offset_x >> (i && s->chroma_y_shift)) +
> -  (s->offset_y >> (i && s->chroma_y_shift)) * 
> dst->linesize[i];
> -dst->data[i] += off;
> -}
> +
> +frame->crop_left   = s->offset_x;
> +frame->crop_right  = avctx->coded_width - avctx->width - s->offset_x;
> +frame->crop_top= s->offset_y;
> +frame->crop_bottom = avctx->coded_height - avctx->height - s->offset_y;
> +
>  *got_frame = 1;
>
>  if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
> @@ -2290,13 +2291,6 @@ static int theora_decode_header(AVCodecContext *avctx, 
> GetBitContext *gb)
>  // to normal axis ([0,0] upper left)
>  s->offset_x = offset_x;
>  s->offset_y = s->height - visible_height - offset_y;
> -
> -if ((s->offset_x & 0x1F) && !(avctx->flags & 
> AV_CODEC_FLAG_UNALIGNED)) {
> -s->offset_x &= ~0x1F;
> -av_log(avctx, AV_LOG_WARNING, "Reducing offset_x from %d to %d"
> -   "chroma samples to preserve alignment.\n",
> -   offset_x, s->offset_x);
> -}
>  }
>
>  if (colorspace == 1)
> @@ -2499,7 +2493,8 @@ AVCodec ff_theora_decoder = {
>   AV_CODEC_CAP_FRAME_THREADS,
>  .flush = vp3_decode_flush,
>  .init_thread_copy  = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
> -.update_thread_context = 
> ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
> +.update_thread_context = 
> ONLY_IF_THREADS_ENABLED(vp3_update_thread_context),
> +.caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING,
>  };
>  #endif
>
> --

lgtm
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/4] h264dec: initialize field_started to 0 on each decode call

2017-01-03 Thread Vittorio Giovara
On Wed, Dec 28, 2016 at 1:15 PM, Anton Khirnov  wrote:
> It might be incorrectly set to 1 if the previous call exited with an
> error.
>
> CC: libav-sta...@libav.org
> ---
>  libavcodec/h264dec.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index 54ded03..c308274 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -520,6 +520,7 @@ static int decode_nal_units(H264Context *h, const uint8_t 
> *buf, int buf_size)
>
>  if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
>  h->current_slice = 0;
> +h->field_started = 0;
>  if (!h->first_field)
>  h->cur_pic_ptr = NULL;
>  ff_h264_sei_uninit(>sei);
> --

ok
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel