-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
- Loading branch information
1 parent
ee1d30e
commit 7110182
Showing
2 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
debian/patches/0050-revert-libplacebo-to-ad-hoc-mode.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
Index: jellyfin-ffmpeg/libavfilter/vf_libplacebo.c | ||
=================================================================== | ||
--- jellyfin-ffmpeg.orig/libavfilter/vf_libplacebo.c | ||
+++ jellyfin-ffmpeg/libavfilter/vf_libplacebo.c | ||
@@ -62,6 +62,7 @@ static const struct pl_tone_map_function | ||
typedef struct LibplaceboContext { | ||
/* lavfi vulkan*/ | ||
FFVulkanContext vkctx; | ||
+ int initialized; | ||
|
||
/* libplacebo */ | ||
pl_log log; | ||
@@ -258,25 +259,10 @@ static int init_vulkan(AVFilterContext * | ||
{ | ||
int err = 0; | ||
LibplaceboContext *s = avctx->priv; | ||
- const AVHWDeviceContext *avhwctx; | ||
- const AVVulkanDeviceContext *hwctx; | ||
+ const AVVulkanDeviceContext *hwctx = s->vkctx.hwctx; | ||
uint8_t *buf = NULL; | ||
size_t buf_len; | ||
|
||
- if (!avctx->hw_device_ctx) { | ||
- av_log(s, AV_LOG_ERROR, "Missing vulkan hwdevice for vf_libplacebo.\n"); | ||
- return AVERROR(EINVAL); | ||
- } | ||
- | ||
- avhwctx = (AVHWDeviceContext *) avctx->hw_device_ctx->data; | ||
- if (avhwctx->type != AV_HWDEVICE_TYPE_VULKAN) { | ||
- av_log(s, AV_LOG_ERROR, "Expected vulkan hwdevice for vf_libplacebo, got %s.\n", | ||
- av_hwdevice_get_type_name(avhwctx->type)); | ||
- return AVERROR(EINVAL); | ||
- } | ||
- | ||
- hwctx = avhwctx->hwctx; | ||
- | ||
/* Import libavfilter vulkan context into libplacebo */ | ||
s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params( | ||
.instance = hwctx->inst, | ||
@@ -325,6 +311,7 @@ static int init_vulkan(AVFilterContext * | ||
fail: | ||
if (buf) | ||
av_file_unmap(buf, buf_len); | ||
+ s->initialized = 1; | ||
return err; | ||
} | ||
|
||
@@ -340,6 +327,7 @@ static void libplacebo_uninit(AVFilterCo | ||
pl_vulkan_destroy(&s->vulkan); | ||
pl_log_destroy(&s->log); | ||
ff_vk_uninit(&s->vkctx); | ||
+ s->initialized = 0; | ||
s->gpu = NULL; | ||
} | ||
|
||
@@ -500,6 +488,8 @@ static int filter_frame(AVFilterLink *li | ||
} | ||
|
||
pl_log_level_update(s->log, get_log_level()); | ||
+ if (!s->initialized) | ||
+ RET(init_vulkan(ctx)); | ||
|
||
RET(av_frame_copy_props(out, in)); | ||
out->width = outlink->w; | ||
@@ -551,69 +541,6 @@ fail: | ||
return err; | ||
} | ||
|
||
-static int libplacebo_query_format(AVFilterContext *ctx) | ||
-{ | ||
- int err; | ||
- LibplaceboContext *s = ctx->priv; | ||
- const AVPixFmtDescriptor *desc = NULL; | ||
- AVFilterFormats *infmts = NULL, *outfmts = NULL; | ||
- | ||
- RET(init_vulkan(ctx)); | ||
- | ||
- while ((desc = av_pix_fmt_desc_next(desc))) { | ||
- enum AVPixelFormat pixfmt = av_pix_fmt_desc_get_id(desc); | ||
- | ||
-#if PL_API_VER < 232 | ||
- // Older libplacebo can't handle >64-bit pixel formats, so safe-guard | ||
- // this to prevent triggering an assertion | ||
- if (av_get_bits_per_pixel(desc) > 64) | ||
- continue; | ||
-#endif | ||
- | ||
- if (!pl_test_pixfmt(s->gpu, pixfmt)) | ||
- continue; | ||
- | ||
- RET(ff_add_format(&infmts, pixfmt)); | ||
- | ||
- /* Filter for supported output pixel formats */ | ||
- if (desc->flags & AV_PIX_FMT_FLAG_BE) | ||
- continue; /* BE formats are not supported by pl_download_avframe */ | ||
- | ||
- /* Mask based on user specified format */ | ||
- if (s->out_format != AV_PIX_FMT_NONE) { | ||
- if (pixfmt == AV_PIX_FMT_VULKAN && av_vkfmt_from_pixfmt(s->out_format)) { | ||
- /* OK */ | ||
- } else if (pixfmt == s->out_format) { | ||
- /* OK */ | ||
- } else { | ||
- continue; /* Not OK */ | ||
- } | ||
- } | ||
- | ||
- RET(ff_add_format(&outfmts, pixfmt)); | ||
- } | ||
- | ||
- if (!infmts || !outfmts) { | ||
- if (s->out_format) { | ||
- av_log(s, AV_LOG_ERROR, "Invalid output format '%s'!\n", | ||
- av_get_pix_fmt_name(s->out_format)); | ||
- } | ||
- err = AVERROR(EINVAL); | ||
- goto fail; | ||
- } | ||
- | ||
- RET(ff_formats_ref(infmts, &ctx->inputs[0]->outcfg.formats)); | ||
- RET(ff_formats_ref(outfmts, &ctx->outputs[0]->incfg.formats)); | ||
- return 0; | ||
- | ||
-fail: | ||
- if (infmts && !infmts->refcount) | ||
- ff_formats_unref(&infmts); | ||
- if (outfmts && !outfmts->refcount) | ||
- ff_formats_unref(&outfmts); | ||
- return err; | ||
-} | ||
- | ||
static int libplacebo_config_input(AVFilterLink *inlink) | ||
{ | ||
AVFilterContext *avctx = inlink->dst; | ||
@@ -881,7 +808,7 @@ const AVFilter ff_vf_libplacebo = { | ||
.process_command = &ff_filter_process_command, | ||
FILTER_INPUTS(libplacebo_inputs), | ||
FILTER_OUTPUTS(libplacebo_outputs), | ||
- FILTER_QUERY_FUNC(libplacebo_query_format), | ||
+ FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN), | ||
.priv_class = &libplacebo_class, | ||
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters