History

Merge commit 'e3d4784eb31b3ea4a97f2d4c698a75fab9bf3d86'

* commit 'e3d4784eb31b3ea4a97f2d4c698a75fab9bf3d86': d3d11va: WindowsPhone requires a mutex around ID3D11VideoContext

Hendrik Leppkes committed 11 years ago

Commit 7c46f242 parents 695ff5d e3d47846 files · +68 −6Browse files

Unified · Split

6 files
  1. doc/APIchanges +4 −0
  2. libavcodec/Makefile +1 −1
  3. libavcodec/d3d11va.c +33 −0
  4. libavcodec/d3d11va.h +16 −2
  5. libavcodec/dxva2.c +13 −2
  6. libavcodec/version.h +1 −1
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2015-09-17 - xxxxxxx - lavc 57.3.100 / lavc 57.2.0 - d3d11va.h
19+ Add av_d3d11va_alloc_context(). This function must from now on be used for
20+ allocating AVD3D11VAContext.
21+
1822 2015-09-15 - lavf 57.2.100 - avformat.h
1923 probesize and max_analyze_duration switched to 64bit, both
2024 are only accessible through AVOptions
libavcodec/Makefile+1−1
@@ -697,7 +697,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o adpcm_data.o · 696 unmodified lines
697697 OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcmenc.o adpcm_data.o
698698
699699 # hardware accelerators
700−OBJS-$(CONFIG_D3D11VA) += dxva2.o
700+OBJS-$(CONFIG_D3D11VA) += d3d11va.o dxva2.o
701701 OBJS-$(CONFIG_DXVA2) += dxva2.o
702702 OBJS-$(CONFIG_VAAPI) += vaapi.o
703703 OBJS-$(CONFIG_VDA) += vda.o videotoolbox.o
libavcodec/d3d11va.c+33−0
@@ -0,0 +1,33 @@
1+/*
2+ * Direct3D11 HW acceleration
3+ *
4+ * copyright (c) 2015 Steve Lhomme
5+ *
6+ * This file is part of Libav.
7+ *
8+ * Libav is free software; you can redistribute it and/or
9+ * modify it under the terms of the GNU Lesser General Public
10+ * License as published by the Free Software Foundation; either
11+ * version 2.1 of the License, or (at your option) any later version.
12+ *
13+ * Libav is distributed in the hope that it will be useful,
14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+ * Lesser General Public License for more details.
17+ *
18+ * You should have received a copy of the GNU Lesser General Public
19+ * License along with Libav; if not, write to the Free Software
20+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+ */
22+
23+#include "config.h"
24+#include "libavutil/mem.h"
25+
26+#include "d3d11va.h"
27+
28+AVD3D11VAContext *av_d3d11va_alloc_context(void)
29+{
30+ AVD3D11VAContext* res = av_mallocz(sizeof(AVD3D11VAContext));
31+ res->context_mutex = INVALID_HANDLE_VALUE;
32+ return res;
33+}
libavcodec/d3d11va.h+16−2
@@ -53,8 +53,10 @@ · 52 unmodified lines
5353 * to the Direct3D11 FFmpeg HWAccel implementation.
5454 *
5555 * The application must make it available as AVCodecContext.hwaccel_context.
56+ *
57+ * Use av_d3d11va_alloc_context() exclusively to allocate an AVD3D11VAContext.
5658 */
57−struct AVD3D11VAContext {
59+typedef struct AVD3D11VAContext {
5860 /**
5961 * D3D11 decoder object
6062 */
@@ -89,7 +91,19 @@ struct AVD3D11VAContext { · 28 unmodified lines
8991 * Private to the FFmpeg AVHWAccel implementation
9092 */
9193 unsigned report_id;
92−};
94+
95+ /**
96+ * Mutex to access video_context
97+ */
98+ HANDLE context_mutex;
99+} AVD3D11VAContext;
100+
101+/**
102+ * Allocate an AVD3D11VAContext.
103+ *
104+ * @return Newly-allocated AVD3D11VAContext or NULL on failure.
105+ */
106+AVD3D11VAContext *av_d3d11va_alloc_context(void);
93107
94108 /**
95109 * @}
libavcodec/dxva2.c+13−2
@@ -144,10 +144,13 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 143 unmodified lines
144144
145145 do {
146146 #if CONFIG_D3D11VA
147− if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
147+ if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
148+ if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
149+ WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE);
148150 hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder,
149151 ff_dxva2_get_surface(frame),
150152 0, NULL);
153+ }
151154 #endif
152155 #if CONFIG_DXVA2
153156 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
@@ -161,6 +164,11 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 7 unmodified lines
161164
162165 if (FAILED(hr)) {
163166 av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr);
167+#if CONFIG_D3D11VA
168+ if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
169+ if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
170+ ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
171+#endif
164172 return -1;
165173 }
166174
@@ -260,8 +268,11 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 93 unmodified lines
260268
261269 end:
262270 #if CONFIG_D3D11VA
263− if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
271+ if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
264272 hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder);
273+ if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
274+ ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
275+ }
265276 #endif
266277 #if CONFIG_DXVA2
267278 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #define LIBAVCODEC_VERSION_MAJOR 57
32−#define LIBAVCODEC_VERSION_MINOR 2
32+#define LIBAVCODEC_VERSION_MINOR 3
3333 #define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t