aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2018-07-25 17:02:45 +0200
committerVittorio Giovara <vittorio.giovara@gmail.com>2018-08-06 18:35:52 +0200
commit572ef567a5288d36b8bc2531309710a0e891d35c (patch)
treed0aa0e8610c475a533cdc606f07bd6a1f717897c
parente467179cfbe270c4b59b10f859b6925668d59583 (diff)
downloadffmpeg-572ef567a5288d36b8bc2531309710a0e891d35c.tar.gz
vf_tonemap_opencl: Move update_metadata() to a shared file
-rw-r--r--libavfilter/colorspace.c17
-rw-r--r--libavfilter/colorspace.h1
-rw-r--r--libavfilter/vf_tonemap_opencl.c19
3 files changed, 19 insertions, 18 deletions
diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index d6f6055401..c6682216d6 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -118,3 +118,20 @@ double ff_determine_signal_peak(AVFrame *in)
return peak;
}
+
+void ff_update_hdr_metadata(AVFrame *in, double peak)
+{
+ AVFrameSideData *sd = av_frame_get_side_data(in, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
+
+ if (sd) {
+ AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data;
+ clm->MaxCLL = (unsigned)(peak * REFERENCE_WHITE);
+ }
+
+ sd = av_frame_get_side_data(in, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
+ if (sd) {
+ AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;
+ if (metadata->has_luminance)
+ metadata->max_luminance = av_d2q(peak * REFERENCE_WHITE, 10000);
+ }
+}
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index 75705ecfc7..936681815a 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -45,5 +45,6 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
double rgb2xyz[3][3]);
double ff_determine_signal_peak(AVFrame *in);
+void ff_update_hdr_metadata(AVFrame *in, double peak);
#endif
diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 7455ebb9fb..5da2333169 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -21,7 +21,6 @@
#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
-#include "libavutil/mastering_display_metadata.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
@@ -342,22 +341,6 @@ fail:
return err;
}
-static void update_metadata(AVFrame *in, double peak) {
- AVFrameSideData *sd = av_frame_get_side_data(in, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
-
- if (sd) {
- AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data;
- clm->MaxCLL = (unsigned)(peak * REFERENCE_WHITE);
- }
-
- sd = av_frame_get_side_data(in, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
- if (sd) {
- AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;
- if (metadata->has_luminance)
- metadata->max_luminance =av_d2q(peak * REFERENCE_WHITE, 10000);
- }
-}
-
static int tonemap_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
{
AVFilterContext *avctx = inlink->dst;
@@ -444,7 +427,7 @@ static int tonemap_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
av_frame_free(&input);
- update_metadata(output, ctx->target_peak);
+ ff_update_hdr_metadata(output, ctx->target_peak);
av_log(ctx, AV_LOG_DEBUG, "Tone-mapping output: %s, %ux%u (%"PRId64").\n",
av_get_pix_fmt_name(output->format),