Re: [FFmpeg-devel] [PATCH] avcodec/exr/c Add support for applying a transfer characteristic curve to OpenEXR inputs.

2015-09-10 Thread Michael Niedermayer
On Tue, Sep 01, 2015 at 12:46:21PM +0100, Kevin Wheatley wrote:
> This actually marks up the buffers as having the state given by the applied 
> trc,
> 
> Kevin
> 
> On Tue, Sep 1, 2015 at 12:04 PM, Kevin Wheatley
>  wrote:
> > This adds the actual usage and allows for command lines similar to this:
> >
> > ffmpeg -apply_trc bt709 -i linear.exr bt709.png
> > ffmpeg -apply_trc smpte2084 -i linear.exr smpte2084.png
> > ffmpeg -apply_trc iec61966_2_1 -i linear.exr sRGB.png
> >
> >
> > Which assuming the correct primaries in the linear OpenEXR file will
> > generate the appropriate file.
> >
> > Kevin

>  exr.c |3 +++
>  1 file changed, 3 insertions(+)
> 366da9c44d8bcbe2f00090588fefd868ced6f441  
> 0007-Mark-up-the-decoded-buffer-as-the-appropriate-transf.patch
> From 0e6bd2437146dafef0e6a89c9db378ba534211bd Mon Sep 17 00:00:00 2001
> From: Kevin Wheatley 
> Date: Tue, 1 Sep 2015 12:35:55 +0100
> Subject: [PATCH 7/7] Mark up the decoded buffer as the appropriate transfer 
> characteristic when applying one

equivalent patches from github applied (i assume they match these)

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/exr/c Add support for applying a transfer characteristic curve to OpenEXR inputs.

2015-09-01 Thread Kevin Wheatley
This adds the actual usage and allows for command lines similar to this:

ffmpeg -apply_trc bt709 -i linear.exr bt709.png
ffmpeg -apply_trc smpte2084 -i linear.exr smpte2084.png
ffmpeg -apply_trc iec61966_2_1 -i linear.exr sRGB.png


Which assuming the correct primaries in the linear OpenEXR file will
generate the appropriate file.

Kevin
From 25aedae9dc873abcba3a6db3dff503c64cd9e066 Mon Sep 17 00:00:00 2001
From: Kevin Wheatley 
Date: Tue, 1 Sep 2015 11:02:53 +0100
Subject: [PATCH 5/5] Add support for applying a transfer characteristic curve to OpenEXR inputs.

Signed-off-by: Kevin Wheatley 
---
 libavcodec/exr.c |  123 ++
 1 files changed, 96 insertions(+), 27 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index b9de7c1..8794da5 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -37,6 +37,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/opt.h"
+#include "libavutil/color_utils.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
@@ -110,6 +111,7 @@ typedef struct EXRContext {
 
 const char *layer;
 
+enum AVColorTransferCharacteristic apply_trc_type;
 float gamma;
 uint16_t gamma_table[65536];
 } EXRContext;
@@ -842,6 +844,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
 int bxmin = s->xmin * 2 * s->desc->nb_components;
 int i, x, buf_size = s->buf_size;
 float one_gamma = 1.0f / s->gamma;
+avpriv_trc_function trc_func = avpriv_get_trc_function_from_trc(s->apply_trc_type);
 int ret;
 
 line_offset = AV_RL64(s->gb.buffer + jobnr * 8);
@@ -921,24 +924,43 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
 ptr_x += s->xmin * s->desc->nb_components;
 if (s->pixel_type == EXR_FLOAT) {
 // 32-bit
-for (x = 0; x < xdelta; x++) {
-union av_intfloat32 t;
-t.i = bytestream_get_le32();
-if (t.f > 0.0f)  /* avoid negative values */
-t.f = powf(t.f, one_gamma);
-*ptr_x++ = exr_flt2uint(t.i);
-
-t.i = bytestream_get_le32();
-if (t.f > 0.0f)
-t.f = powf(t.f, one_gamma);
-*ptr_x++ = exr_flt2uint(t.i);
-
-t.i = bytestream_get_le32();
-if (t.f > 0.0f)
-t.f = powf(t.f, one_gamma);
-*ptr_x++ = exr_flt2uint(t.i);
-if (channel_buffer[3])
-*ptr_x++ = exr_flt2uint(bytestream_get_le32());
+if (trc_func) {
+for (x = 0; x < xdelta; x++) {
+union av_intfloat32 t;
+t.i = bytestream_get_le32();
+t.f = trc_func(t.f);
+*ptr_x++ = exr_flt2uint(t.i);
+
+t.i = bytestream_get_le32();
+t.f = trc_func(t.f);
+*ptr_x++ = exr_flt2uint(t.i);
+
+t.i = bytestream_get_le32();
+t.f = trc_func(t.f);
+*ptr_x++ = exr_flt2uint(t.i);
+if (channel_buffer[3])
+*ptr_x++ = exr_flt2uint(bytestream_get_le32());
+}
+} else {
+for (x = 0; x < xdelta; x++) {
+union av_intfloat32 t;
+t.i = bytestream_get_le32();
+if (t.f > 0.0f)  /* avoid negative values */
+t.f = powf(t.f, one_gamma);
+*ptr_x++ = exr_flt2uint(t.i);
+
+t.i = bytestream_get_le32();
+if (t.f > 0.0f)
+t.f = powf(t.f, one_gamma);
+*ptr_x++ = exr_flt2uint(t.i);
+
+t.i = bytestream_get_le32();
+if (t.f > 0.0f)
+t.f = powf(t.f, one_gamma);
+*ptr_x++ = exr_flt2uint(t.i);
+if (channel_buffer[3])
+*ptr_x++ = exr_flt2uint(bytestream_get_le32());
+}
 }
 } else {
 // 16-bit
@@ -1364,21 +1386,31 @@ static av_cold int decode_init(AVCodecContext *avctx)
 uint32_t i;
 union av_intfloat32 t;
 float one_gamma = 1.0f / s->gamma;
+avpriv_trc_function trc_func = NULL;
 
 s->avctx  = avctx;
 
-if (one_gamma > 0.f && one_gamma < 1.0001f) {
-for (i = 0; i < 65536; ++i)
-s->gamma_table[i] = exr_halflt2uint(i);
-} else {
+trc_func = avpriv_get_trc_function_from_trc(s->apply_trc_type);
+if (trc_func) {
 for (i = 0; i < 65536; ++i) {
 t = exr_half2float(i);
-/* If negative value we reuse half value */
-if (t.f <= 0.0f) {
+t.f = trc_func(t.f);
+s->gamma_table[i] = exr_flt2uint(t.i);
+}

Re: [FFmpeg-devel] [PATCH] avcodec/exr/c Add support for applying a transfer characteristic curve to OpenEXR inputs.

2015-09-01 Thread Kevin Wheatley
This actually marks up the buffers as having the state given by the applied trc,

Kevin

On Tue, Sep 1, 2015 at 12:04 PM, Kevin Wheatley
 wrote:
> This adds the actual usage and allows for command lines similar to this:
>
> ffmpeg -apply_trc bt709 -i linear.exr bt709.png
> ffmpeg -apply_trc smpte2084 -i linear.exr smpte2084.png
> ffmpeg -apply_trc iec61966_2_1 -i linear.exr sRGB.png
>
>
> Which assuming the correct primaries in the linear OpenEXR file will
> generate the appropriate file.
>
> Kevin
From 0e6bd2437146dafef0e6a89c9db378ba534211bd Mon Sep 17 00:00:00 2001
From: Kevin Wheatley 
Date: Tue, 1 Sep 2015 12:35:55 +0100
Subject: [PATCH 7/7] Mark up the decoded buffer as the appropriate transfer characteristic when applying one

---
 libavcodec/exr.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 8794da5..92f528a 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1308,6 +1308,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 av_log(avctx, AV_LOG_ERROR, "Missing channel list.\n");
 return AVERROR_INVALIDDATA;
 }
+
+if (s->apply_trc_type != AVCOL_TRC_UNSPECIFIED)
+avctx->color_trc = s->apply_trc_type;
 
 switch (s->compression) {
 case EXR_RAW:
-- 
1.7.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel