-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avfilter/tonemap-videotoolbox: properly set hdr attachements
- Loading branch information
Showing
1 changed file
with
47 additions
and
42 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,30 +1,22 @@ | ||
Subject: [PATCH] avfilter: add vf_tonemap_videotoolbox | ||
--- | ||
Index: configure | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
Index: FFmpeg/configure | ||
=================================================================== | ||
diff --git a/configure b/configure | ||
--- a/configure (revision 2e3649a10ff797e360eb9fd5d389dfa6611dea59) | ||
+++ b/configure (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
@@ -3748,6 +3748,7 @@ | ||
--- FFmpeg.orig/configure | ||
+++ FFmpeg/configure | ||
@@ -3772,6 +3772,7 @@ tinterlace_pad_test_deps="tinterlace_fil | ||
tonemap_filter_deps="const_nan" | ||
tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" | ||
tonemap_opencl_filter_deps="opencl const_nan" | ||
+tonemap_videotoolbox_filter_deps="metal corevideo videotoolbox const_nan" | ||
transpose_opencl_filter_deps="opencl" | ||
transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" | ||
transpose_vulkan_filter_deps="vulkan spirv_compiler" | ||
Index: libavfilter/Makefile | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
Index: FFmpeg/libavfilter/Makefile | ||
=================================================================== | ||
diff --git a/libavfilter/Makefile b/libavfilter/Makefile | ||
--- a/libavfilter/Makefile (revision 2e3649a10ff797e360eb9fd5d389dfa6611dea59) | ||
+++ b/libavfilter/Makefile (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
@@ -510,6 +510,9 @@ | ||
--- FFmpeg.orig/libavfilter/Makefile | ||
+++ FFmpeg/libavfilter/Makefile | ||
@@ -521,6 +521,9 @@ OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) | ||
OBJS-$(CONFIG_TONEMAP_CUDA_FILTER) += vf_tonemap_cuda.o cuda/tonemap.ptx.o \ | ||
cuda/host_util.o | ||
OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER) += vf_tonemap_vaapi.o vaapi_vpp.o | ||
|
@@ -34,32 +26,22 @@ diff --git a/libavfilter/Makefile b/libavfilter/Makefile | |
OBJS-$(CONFIG_TPAD_FILTER) += vf_tpad.o | ||
OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o | ||
OBJS-$(CONFIG_TRANSPOSE_CUDA_FILTER) += vf_transpose_cuda.o vf_transpose_cuda.ptx.o \ | ||
cuda/load_helper.o | ||
Index: libavfilter/allfilters.c | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
Index: FFmpeg/libavfilter/allfilters.c | ||
=================================================================== | ||
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c | ||
--- a/libavfilter/allfilters.c (revision 2e3649a10ff797e360eb9fd5d389dfa6611dea59) | ||
+++ b/libavfilter/allfilters.c (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
@@ -480,6 +480,7 @@ | ||
--- FFmpeg.orig/libavfilter/allfilters.c | ||
+++ FFmpeg/libavfilter/allfilters.c | ||
@@ -487,6 +487,7 @@ extern const AVFilter ff_vf_tonemap; | ||
extern const AVFilter ff_vf_tonemap_cuda; | ||
extern const AVFilter ff_vf_tonemap_opencl; | ||
extern const AVFilter ff_vf_tonemap_vaapi; | ||
+extern const AVFilter ff_vf_tonemap_videotoolbox; | ||
extern const AVFilter ff_vf_tpad; | ||
extern const AVFilter ff_vf_transpose; | ||
extern const AVFilter ff_vf_transpose_cuda; | ||
Index: libavfilter/metal/vf_tonemap_videotoolbox.metal | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
Index: FFmpeg/libavfilter/metal/vf_tonemap_videotoolbox.metal | ||
=================================================================== | ||
diff --git a/libavfilter/metal/vf_tonemap_videotoolbox.metal b/libavfilter/metal/vf_tonemap_videotoolbox.metal | ||
new file mode 100644 | ||
--- /dev/null (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
+++ b/libavfilter/metal/vf_tonemap_videotoolbox.metal (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
--- /dev/null | ||
+++ FFmpeg/libavfilter/metal/vf_tonemap_videotoolbox.metal | ||
@@ -0,0 +1,688 @@ | ||
+/* | ||
+ * Copyright (c) 2024 Gnattu OC <[email protected]> | ||
|
@@ -749,16 +731,11 @@ new file mode 100644 | |
+ dst2.write(float4(chroma.y, chroma.z, 0.0f, 1.0f), uint2(xi, yi)); | ||
+ } | ||
+} | ||
Index: libavfilter/vf_tonemap_videotoolbox.m | ||
IDEA additional info: | ||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||
<+>UTF-8 | ||
Index: FFmpeg/libavfilter/vf_tonemap_videotoolbox.m | ||
=================================================================== | ||
diff --git a/libavfilter/vf_tonemap_videotoolbox.m b/libavfilter/vf_tonemap_videotoolbox.m | ||
new file mode 100644 | ||
--- /dev/null (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
+++ b/libavfilter/vf_tonemap_videotoolbox.m (revision bcb63879b775fef8085a5311f045dc1cc4960a98) | ||
@@ -0,0 +1,1106 @@ | ||
--- /dev/null | ||
+++ FFmpeg/libavfilter/vf_tonemap_videotoolbox.m | ||
@@ -0,0 +1,1134 @@ | ||
+/* | ||
+ * Copyright (c) 2024 Gnattu OC <[email protected]> | ||
+ * | ||
|
@@ -1777,6 +1754,34 @@ new file mode 100644 | |
+ if (ctx->trc_out != AVCOL_TRC_SMPTE2084) { | ||
+ av_frame_remove_side_data(output, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); | ||
+ av_frame_remove_side_data(output, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); | ||
+ } else { | ||
+ CGColorSpaceRef colorspace = NULL; | ||
+ CFStringRef colormatrix = kCVImageBufferYCbCrMatrix_ITU_R_2020; | ||
+ CFStringRef colorpri = kCVImageBufferColorPrimaries_ITU_R_2020; | ||
+ CFStringRef colortrc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ; | ||
+ CFMutableDictionaryRef attachments = CFDictionaryCreateMutable(NULL, 4, | ||
+ &kCFTypeDictionaryKeyCallBacks, | ||
+ &kCFTypeDictionaryValueCallBacks); | ||
+ if (!attachments) { | ||
+ err = AVERROR(ENOMEM); | ||
+ goto fail; | ||
+ } | ||
+ CFDictionarySetValue(attachments, kCVImageBufferYCbCrMatrixKey, colormatrix); | ||
+ CFDictionarySetValue(attachments, kCVImageBufferColorPrimariesKey, colorpri); | ||
+ CFDictionarySetValue(attachments, kCVImageBufferTransferFunctionKey, colortrc); | ||
+ colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments); | ||
+ if (colorspace) { | ||
+ CFDictionarySetValue(attachments, kCVImageBufferCGColorSpaceKey, colorspace); | ||
+ CFRelease(colorspace); | ||
+ } else { | ||
+ av_log(avctx, AV_LOG_WARNING, "Unable to set proper colorspace for the CVImageBuffer.\n"); | ||
+ } | ||
+ CVBufferSetAttachments( | ||
+ (CVPixelBufferRef)output->data[3], | ||
+ attachments, | ||
+ kCVAttachmentMode_ShouldPropagate); | ||
+ CFRelease(attachments); | ||
+ ff_update_hdr_metadata(output, 100.0f); | ||
+ } | ||
+ | ||
+ av_frame_remove_side_data(output, AV_FRAME_DATA_DOVI_RPU_BUFFER); | ||
|