mirror of
https://github.com/jellyfin/jellyfin-ffmpeg.git
synced 2026-09-02 21:03:08 +03:00
173 lines
6.5 KiB
Diff
173 lines
6.5 KiB
Diff
Index: FFmpeg/libavfilter/avfilter.h
|
|
===================================================================
|
|
--- FFmpeg.orig/libavfilter/avfilter.h
|
|
+++ FFmpeg/libavfilter/avfilter.h
|
|
@@ -417,6 +417,8 @@ struct AVFilterLink {
|
|
enum AVColorSpace colorspace; ///< agreed upon YUV color space
|
|
enum AVColorRange color_range; ///< agreed upon YUV color range
|
|
|
|
+ int fixed_pool_size; ///< fixed size of the frame pool for reverse hw mapping
|
|
+
|
|
/* These parameters apply only to audio */
|
|
int sample_rate; ///< samples per second
|
|
AVChannelLayout ch_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
|
|
Index: FFmpeg/libavfilter/opencl.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavfilter/opencl.c
|
|
+++ FFmpeg/libavfilter/opencl.c
|
|
@@ -78,6 +78,9 @@ int ff_opencl_filter_config_input(AVFilt
|
|
if (!ctx->output_height)
|
|
ctx->output_height = inlink->h;
|
|
|
|
+ if (avctx->nb_outputs > 0)
|
|
+ avctx->outputs[0]->fixed_pool_size = inlink->fixed_pool_size;
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -127,6 +130,9 @@ int ff_opencl_filter_config_output(AVFil
|
|
outlink->w = ctx->output_width;
|
|
outlink->h = ctx->output_height;
|
|
|
|
+ if (avctx->nb_inputs > 0)
|
|
+ outlink->fixed_pool_size = avctx->inputs[0]->fixed_pool_size;
|
|
+
|
|
return 0;
|
|
fail:
|
|
av_buffer_unref(&output_frames_ref);
|
|
Index: FFmpeg/libavfilter/vf_crop.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavfilter/vf_crop.c
|
|
+++ FFmpeg/libavfilter/vf_crop.c
|
|
@@ -152,6 +152,8 @@ static int config_input(AVFilterLink *li
|
|
if (pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
|
|
s->hsub = 1;
|
|
s->vsub = 1;
|
|
+ if (ctx->nb_outputs > 0)
|
|
+ ctx->outputs[0]->fixed_pool_size = link->fixed_pool_size;
|
|
} else {
|
|
s->hsub = pix_desc->log2_chroma_w;
|
|
s->vsub = pix_desc->log2_chroma_h;
|
|
@@ -238,6 +240,9 @@ static int config_output(AVFilterLink *l
|
|
if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
|
|
// Hardware frames adjust the cropping regions rather than
|
|
// changing the frame size.
|
|
+ AVFilterContext *ctx = link->src;
|
|
+ if (ctx->nb_inputs > 0)
|
|
+ link->fixed_pool_size = ctx->inputs[0]->fixed_pool_size;
|
|
} else {
|
|
link->w = s->w;
|
|
link->h = s->h;
|
|
Index: FFmpeg/libavfilter/vf_hwmap.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavfilter/vf_hwmap.c
|
|
+++ FFmpeg/libavfilter/vf_hwmap.c
|
|
@@ -22,6 +22,10 @@
|
|
#include "libavutil/opt.h"
|
|
#include "libavutil/pixdesc.h"
|
|
|
|
+#if CONFIG_D3D11VA
|
|
+#include "libavutil/hwcontext_d3d11va.h"
|
|
+#endif
|
|
+
|
|
#include "avfilter.h"
|
|
#include "filters.h"
|
|
#include "formats.h"
|
|
@@ -126,6 +130,12 @@ static int hwmap_config_output(AVFilterL
|
|
goto fail;
|
|
}
|
|
|
|
+ if (hwfc->initial_pool_size) {
|
|
+ outlink->fixed_pool_size = hwfc->initial_pool_size;
|
|
+ av_log(avctx, AV_LOG_DEBUG, "Saved the fixed_pool_size from "
|
|
+ "initial_pool_size: %d\n", outlink->fixed_pool_size);
|
|
+ }
|
|
+
|
|
} else if (inlink->format == hwfc->format &&
|
|
(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
|
|
ctx->reverse) {
|
|
@@ -148,8 +158,21 @@ static int hwmap_config_output(AVFilterL
|
|
frames->width = hwfc->width;
|
|
frames->height = hwfc->height;
|
|
|
|
- if (avctx->extra_hw_frames >= 0)
|
|
- frames->initial_pool_size = 2 + avctx->extra_hw_frames;
|
|
+ if (inlink->fixed_pool_size)
|
|
+ frames->initial_pool_size = inlink->fixed_pool_size;
|
|
+
|
|
+ if (frames->initial_pool_size == 0) {
|
|
+ // Dynamic allocation.
|
|
+ } else {
|
|
+ frames->initial_pool_size += (avctx->extra_hw_frames > 2 ? avctx->extra_hw_frames : 2);
|
|
+ }
|
|
+
|
|
+#if CONFIG_D3D11VA
|
|
+ if (frames->format == AV_PIX_FMT_D3D11) {
|
|
+ AVD3D11VAFramesContext *frames_d3d11 = frames->hwctx;
|
|
+ frames_d3d11->BindFlags = D3D11_BIND_DECODER;
|
|
+ }
|
|
+#endif
|
|
|
|
err = av_hwframe_ctx_init(ctx->hwframes_ref);
|
|
if (err < 0) {
|
|
Index: FFmpeg/libavfilter/vf_hwupload.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavfilter/vf_hwupload.c
|
|
+++ FFmpeg/libavfilter/vf_hwupload.c
|
|
@@ -23,6 +23,10 @@
|
|
#include "libavutil/pixdesc.h"
|
|
#include "libavutil/opt.h"
|
|
|
|
+#if CONFIG_D3D11VA
|
|
+#include "libavutil/hwcontext_d3d11va.h"
|
|
+#endif
|
|
+
|
|
#include "avfilter.h"
|
|
#include "filters.h"
|
|
#include "formats.h"
|
|
@@ -160,6 +164,13 @@ static int hwupload_config_output(AVFilt
|
|
if (avctx->extra_hw_frames >= 0)
|
|
ctx->hwframes->initial_pool_size = 2 + avctx->extra_hw_frames;
|
|
|
|
+#if CONFIG_D3D11VA
|
|
+ if (ctx->hwframes->format == AV_PIX_FMT_D3D11) {
|
|
+ AVD3D11VAFramesContext *frames_d3d11 = ctx->hwframes->hwctx;
|
|
+ frames_d3d11->BindFlags = D3D11_BIND_DECODER;
|
|
+ }
|
|
+#endif
|
|
+
|
|
err = av_hwframe_ctx_init(ctx->hwframes_ref);
|
|
if (err < 0)
|
|
goto fail;
|
|
Index: FFmpeg/libavutil/hwcontext_d3d11va.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavutil/hwcontext_d3d11va.c
|
|
+++ FFmpeg/libavutil/hwcontext_d3d11va.c
|
|
@@ -235,7 +235,7 @@ static AVBufferRef *d3d11va_alloc_single
|
|
.ArraySize = 1,
|
|
.Usage = D3D11_USAGE_DEFAULT,
|
|
.BindFlags = hwctx->BindFlags,
|
|
- .MiscFlags = hwctx->MiscFlags,
|
|
+ .MiscFlags = hwctx->MiscFlags | D3D11_RESOURCE_MISC_SHARED,
|
|
};
|
|
|
|
hr = ID3D11Device_CreateTexture2D(device_hwctx->device, &texDesc, NULL, &tex);
|
|
@@ -304,7 +304,7 @@ static int d3d11va_frames_init(AVHWFrame
|
|
.ArraySize = ctx->initial_pool_size,
|
|
.Usage = D3D11_USAGE_DEFAULT,
|
|
.BindFlags = hwctx->BindFlags,
|
|
- .MiscFlags = hwctx->MiscFlags,
|
|
+ .MiscFlags = hwctx->MiscFlags | D3D11_RESOURCE_MISC_SHARED,
|
|
};
|
|
|
|
if (hwctx->texture) {
|
|
@@ -321,7 +321,7 @@ static int d3d11va_frames_init(AVHWFrame
|
|
ctx->initial_pool_size = texDesc2.ArraySize;
|
|
hwctx->BindFlags = texDesc2.BindFlags;
|
|
hwctx->MiscFlags = texDesc2.MiscFlags;
|
|
- } else if (texDesc.ArraySize > 0) {
|
|
+ } else if (!(texDesc.BindFlags & D3D11_BIND_RENDER_TARGET) && texDesc.ArraySize > 0) {
|
|
hr = ID3D11Device_CreateTexture2D(device_hwctx->device, &texDesc, NULL, &hwctx->texture);
|
|
if (FAILED(hr)) {
|
|
av_log(ctx, AV_LOG_ERROR, "Could not create the texture (%lx)\n", (long)hr);
|