[FFmpeg-devel] [PATCH] Add a gamma flag to exr loader to avoid banding

Michael Niedermayer michaelni at gmx.at
Sun Apr 27 18:04:33 CEST 2014


On Sun, Apr 27, 2014 at 10:43:09AM -0300, Gonzalo Garramuno wrote:
> Attached is a patch to add a gamma flag to the exr loader.  This is
> needed to avoid banding artifacts when gammaing the picture.
> Currently, if done with a video filter, the process is done on uints
> instead of full float.

>  Changelog        |    1 
>  libavcodec/exr.c |  138 ++++++++++++++++++++++++++++++++++++++++++++++---------
>  2 files changed, 117 insertions(+), 22 deletions(-)
> 828c54dedd21b004de00e049b4fa4b2f72ae78b1  exr_gamma.patch
> diff --git a/Changelog b/Changelog
> index daaa1ea..a726823 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release,
>  releases are sorted from youngest to oldest.
>  
>  version <next>:
> +- EXR loader supports a gamma flag
>  - AC3 fixed-point decoding
>  - shuffleplanes filter
>  - subfile protocol
> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> index 084025a..8c2425c 100644
> --- a/libavcodec/exr.c
> +++ b/libavcodec/exr.c
> @@ -31,6 +31,7 @@
>   */
>  
>  #include <zlib.h>
> +#include <float.h>
>  
>  #include "libavutil/imgutils.h"
>  #include "libavutil/opt.h"
> @@ -106,8 +107,30 @@ typedef struct EXRContext {
>      EXRThreadData *thread_data;
>  
>      const char *layer;
> +
> +    float gamma;
> +
>  } EXRContext;
>  

> +union FP32 {
> +    uint32_t u;
> +    float f;
> +    struct {
> +        unsigned int Mantissa : 23;
> +        unsigned int Exponent : 8;
> +        unsigned int Sign : 1;
> +    };
> +} FP32;
> +
> +union FP16 {
> +    uint16_t u;
> +    struct {
> +        unsigned int Mantissa : 10;
> +        unsigned int Exponent : 5;
> +        unsigned int Sign : 1;
> +     };
> +} FP16;

that way to access parts of a float is not portable

see libavutil/intfloat.h

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140427/40c70c7b/attachment.asc>


More information about the ffmpeg-devel mailing list