Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2015-08-28 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2015-xx-xx - xxxxxxx - lavc 57.2.0 - d3d11va.h | |
| 17 | + Add av_d3d11va_alloc_context(). This function must from now on be used for | |
| 18 | + allocating AVD3D11VAContext. | |
| 19 | + | |
| 16 | 20 | 2015-xx-xx - lavu 55.0.0 |
| 17 | 21 | xxxxxxx - Change type of AVPixFmtDescriptor.flags from uint8_t to uint64_t. |
| 18 | 22 | xxxxxxx - Change type of AVComponentDescriptor fields from uint16_t to int |
| @@ -581,7 +581,7 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o adpcm_data.o · 580 unmodified lines | ||
| 581 | 581 | OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcmenc.o adpcm_data.o |
| 582 | 582 | |
| 583 | 583 | # hardware accelerators |
| 584 | −OBJS-$(CONFIG_D3D11VA) += dxva2.o | |
| 584 | +OBJS-$(CONFIG_D3D11VA) += d3d11va.o dxva2.o | |
| 585 | 585 | OBJS-$(CONFIG_DXVA2) += dxva2.o |
| 586 | 586 | OBJS-$(CONFIG_VAAPI) += vaapi.o |
| 587 | 587 | OBJS-$(CONFIG_VDA) += vda.o |
| @@ -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 | +} | |
| @@ -53,8 +53,10 @@ · 52 unmodified lines | ||
| 53 | 53 | * to the Direct3D11 Libav HWAccel implementation. |
| 54 | 54 | * |
| 55 | 55 | * The application must make it available as AVCodecContext.hwaccel_context. |
| 56 | + * | |
| 57 | + * Use av_d3d11va_alloc_context() exclusively to allocate an AVD3D11VAContext. | |
| 56 | 58 | */ |
| 57 | −struct AVD3D11VAContext { | |
| 59 | +typedef struct AVD3D11VAContext { | |
| 58 | 60 | /** |
| 59 | 61 | * D3D11 decoder object |
| 60 | 62 | */ |
| @@ -89,7 +91,19 @@ struct AVD3D11VAContext { · 28 unmodified lines | ||
| 89 | 91 | * Private to the Libav AVHWAccel implementation |
| 90 | 92 | */ |
| 91 | 93 | 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); | |
| 93 | 107 | |
| 94 | 108 | /** |
| 95 | 109 | * @} |
| @@ -144,10 +144,13 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 143 unmodified lines | ||
| 144 | 144 | |
| 145 | 145 | do { |
| 146 | 146 | #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); | |
| 148 | 150 | hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, |
| 149 | 151 | ff_dxva2_get_surface(frame), |
| 150 | 152 | 0, NULL); |
| 153 | + } | |
| 151 | 154 | #endif |
| 152 | 155 | #if CONFIG_DXVA2 |
| 153 | 156 | 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 | ||
| 161 | 164 | |
| 162 | 165 | if (FAILED(hr)) { |
| 163 | 166 | 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 | |
| 164 | 172 | return -1; |
| 165 | 173 | } |
| 166 | 174 | |
| @@ -260,8 +268,11 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, · 93 unmodified lines | ||
| 260 | 268 | |
| 261 | 269 | end: |
| 262 | 270 | #if CONFIG_D3D11VA |
| 263 | − if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) | |
| 271 | + if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { | |
| 264 | 272 | 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 | + } | |
| 265 | 276 | #endif |
| 266 | 277 | #if CONFIG_DXVA2 |
| 267 | 278 | if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/version.h" |
| 30 | 30 | |
| 31 | 31 | #define LIBAVCODEC_VERSION_MAJOR 57 |
| 32 | −#define LIBAVCODEC_VERSION_MINOR 1 | |
| 32 | +#define LIBAVCODEC_VERSION_MINOR 2 | |
| 33 | 33 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 34 | 34 | |
| 35 | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |