[FFmpeg-devel] lavfi: a minor fix to tonemap peak detection.

Submitted by Ruiling Song on May 21, 2018, 6:58 a.m.

Details

Message ID 1526885913-13260-1-git-send-email-ruiling.song@intel.com
State New
Headers show

Commit Message

Ruiling Song May 21, 2018, 6:58 a.m.
If the transfer was SMPTE2084, use the peak of 10000 even if not tagged.
Otherwise, we would assume it is HLG with a peak of 1200.
Based on suggestion by Niklas Haas.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 libavfilter/vf_tonemap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Vittorio Giovara May 21, 2018, 7:11 p.m.
On Mon, May 21, 2018 at 2:58 AM, Ruiling Song <ruiling.song@intel.com>
wrote:

> If the transfer was SMPTE2084, use the peak of 10000 even if not tagged.
> Otherwise, we would assume it is HLG with a peak of 1200.
> Based on suggestion by Niklas Haas.
>
> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
> ---
>  libavfilter/vf_tonemap.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
> index 10308bd..ab45f2e 100644
> --- a/libavfilter/vf_tonemap.c
> +++ b/libavfilter/vf_tonemap.c
> @@ -131,10 +131,9 @@ static double determine_signal_peak(AVFrame *in)
>              peak = av_q2d(metadata->max_luminance) / REFERENCE_WHITE;
>      }
>
> -    /* smpte2084 needs the side data above to work correctly
> -     * if missing, assume that the original transfer was arib-std-b67 */
> +    /* if not SMPTE2084, we would assume HLG */
>      if (!peak)
> -        peak = 12;
> +        peak = in->color_trc == AVCOL_TRC_SMPTE2084 ? 100 : 12;
>
>      return peak;
>  }
> --
> 2.7.4
>
>
seems reasonable

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
index 10308bd..ab45f2e 100644
--- a/libavfilter/vf_tonemap.c
+++ b/libavfilter/vf_tonemap.c
@@ -131,10 +131,9 @@  static double determine_signal_peak(AVFrame *in)
             peak = av_q2d(metadata->max_luminance) / REFERENCE_WHITE;
     }
 
-    /* smpte2084 needs the side data above to work correctly
-     * if missing, assume that the original transfer was arib-std-b67 */
+    /* if not SMPTE2084, we would assume HLG */
     if (!peak)
-        peak = 12;
+        peak = in->color_trc == AVCOL_TRC_SMPTE2084 ? 100 : 12;
 
     return peak;
 }