Skip to content

Commit

Permalink
Merge pull request #163 from nyanmisaka/dovi-range
Browse files Browse the repository at this point in the history
Fix the incorrect full to limit color range on DoVi tonemap.
  • Loading branch information
nyanmisaka committed Jun 24, 2022
2 parents 10ebdce + 94b878a commit 3106ae1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
jellyfin-ffmpeg (5.0.1-7) unstable; urgency=medium

* Switch to single precision fftw, enable neon for arm.
* Fix the incorrect full to limit color range on DoVi tonemap.

-- nyanmisaka <[email protected]> Thu, 23 Jun 2022 19:19:17 +0800

Expand Down
2 changes: 1 addition & 1 deletion debian/patches/0005-add-cuda-tonemap-impl.patch
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Index: jellyfin-ffmpeg/libavfilter/cuda/colorspace_common.h
+ float r = linearize(c.x);
+ float g = linearize(c.y);
+ float b = linearize(c.z);
+ return make_float3(r, g, b);
+ return lrgb2lrgb(make_float3(r, g, b));
+}
+
+static __inline__ __device__ float3 ycc2rgb(float y, float cb, float cr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,12 @@ Index: jellyfin-ffmpeg/libavfilter/opencl/colorspace_common.cl
+float inverse_eotf_st2084(float x) {
+ x *= REF_WHITE / ST2084_MAX_LUMINANCE;
+ return inverse_eotf_st2084_common(x);
}

-float inverse_eotf_bt1886(float c) {
- return c < 0.0f ? 0.0f : powr(c, 1.0f / 2.4f);
+}
+
+float ootf_1_2(float x) {
+ return x > 0.0f ? native_powr(x, 1.2f) : x;
}

-float oetf_bt709(float c) {
- c = c < 0.0f ? 0.0f : c;
- float r1 = 4.5f * c;
- float r2 = 1.099f * powr(c, 0.45f) - 0.099f;
- return c < 0.018f ? r1 : r2;
-}
-float inverse_oetf_bt709(float c) {
- float r1 = c / 4.5f;
- float r2 = powr((c + 0.099f) / 1.099f, 1.0f / 0.45f);
- return c < 0.081f ? r1 : r2;
+}
+
+float inverse_ootf_1_2(float x) {
+ return x > 0.0f ? native_powr(x, 1.0f / 1.2f) : x;
+}
Expand All @@ -204,13 +192,25 @@ Index: jellyfin-ffmpeg/libavfilter/opencl/colorspace_common.cl
+// linearizer for HLG/ARIB-B67
+float eotf_arib_b67(float x) {
+ return ootf_1_2(inverse_oetf_arib_b67(x));
+}
+
}

-float inverse_eotf_bt1886(float c) {
- return c < 0.0f ? 0.0f : powr(c, 1.0f / 2.4f);
+// delinearizer for HLG/ARIB-B67
+float inverse_eotf_arib_b67(float x) {
+ return oetf_arib_b67(inverse_ootf_1_2(x));
+}
+
}

-float oetf_bt709(float c) {
- c = c < 0.0f ? 0.0f : c;
- float r1 = 4.5f * c;
- float r2 = 1.099f * powr(c, 0.45f) - 0.099f;
- return c < 0.018f ? r1 : r2;
-}
-float inverse_oetf_bt709(float c) {
- float r1 = c / 4.5f;
- float r2 = powr((c + 0.099f) / 1.099f, 1.0f / 0.45f);
- return c < 0.081f ? r1 : r2;
+// delinearizer for BT709, BT2020-10
+float inverse_eotf_bt1886(float x) {
+ return x > 0.0f ? native_powr(x, 1.0f / 2.4f) : 0.0f;
Expand All @@ -224,14 +224,16 @@ Index: jellyfin-ffmpeg/libavfilter/opencl/colorspace_common.cl
-float3 ootf(float3 c, float peak) {
-#ifdef ootf_impl
- return ootf_impl(c, peak);
-#else
- return c;
+float3 rgb2lrgb(float3 c) {
+#ifdef linearize
+ float r = linearize(c.x);
+ float g = linearize(c.y);
+ float b = linearize(c.z);
+ return (float3)(r, g, b);
#else
return c;
+ return lrgb2lrgb((float3)(r, g, b));
+#else
+ return lrgb2lrgb((float3)(c.x, c.y, c.z))
#endif
}

Expand Down

0 comments on commit 3106ae1

Please sign in to comment.