FFmpeg
Loading...
Searching...
No Matches
gain_map.c File Reference
#include <stdio.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/error.h"
#include "libavutil/gain_map.h"
#include "libavutil/mem.h"
#include "libavutil/rational.h"
#include "bytestream.h"
#include "gain_map.h"

Go to the source code of this file.

Macros

#define ISO21496_HEADER_SIZE   5
 
#define ISO21496_FLAG_MULTICHANNEL   (1 << 7)
 
#define ISO21496_FLAG_USE_BASE_CG   (1 << 6)
 
#define ISO21496_FLAG_RESERVED   0x3f
 
#define XMP_GAIN_MAP_TEMPLATE
 

Functions

static size_t iso21496_payload_size (int nb_channels)
 
static int make_q (int64_t num, uint32_t den, AVRational *out)
 
static int get_sq (GetByteContext *gb, AVRational *out)
 
static int get_uq (GetByteContext *gb, AVRational *out)
 
int ff_gain_map_params_from_iso21496 (AVGainMapParams *restrict p, const uint8_t *data, size_t size)
 
static void put_q (PutByteContext *pb, AVRational q)
 
int ff_gain_map_params_to_iso21496 (const AVGainMapParams *p, uint8_t *buf)
 Serialize an AVGainMapParams as an ISO 21496-1 gain map metadata blob.
 
int ff_gain_map_params_check_xmp (const AVGainMapParams *p)
 Returns 1 if the gain map parameters are compatible with the XMP-based encoding, or 0 otherwise.
 
int ff_gain_map_params_to_xmp (const AVGainMapParams *p, char *buf)
 Serialize an AVGainMapParams as an Ultra HDR XMP packet.
 

Macro Definition Documentation

◆ ISO21496_HEADER_SIZE

#define ISO21496_HEADER_SIZE   5

Definition at line 31 of file gain_map.c.

◆ ISO21496_FLAG_MULTICHANNEL

#define ISO21496_FLAG_MULTICHANNEL   (1 << 7)

Definition at line 33 of file gain_map.c.

Referenced by ff_gain_map_params_from_iso21496(), and ff_gain_map_params_to_iso21496().

◆ ISO21496_FLAG_USE_BASE_CG

#define ISO21496_FLAG_USE_BASE_CG   (1 << 6)

Definition at line 34 of file gain_map.c.

Referenced by ff_gain_map_params_from_iso21496(), and ff_gain_map_params_to_iso21496().

◆ ISO21496_FLAG_RESERVED

#define ISO21496_FLAG_RESERVED   0x3f

Definition at line 35 of file gain_map.c.

Referenced by ff_gain_map_params_from_iso21496().

◆ XMP_GAIN_MAP_TEMPLATE

#define XMP_GAIN_MAP_TEMPLATE
Value:
"<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"XMP Core 5.5.0\">\n" \
" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" \
" <rdf:Description rdf:about=\"\"\n" \
" xmlns:hdrgm=\"" FF_GAIN_MAP_XMP_NAMESPACE "\"\n" \
" hdrgm:Version=\"1.0\"\n" \
" hdrgm:GainMapMin=\"%g\"\n" \
" hdrgm:GainMapMax=\"%g\"\n" \
" hdrgm:Gamma=\"%g\"\n" \
" hdrgm:OffsetSDR=\"%g\"\n" \
" hdrgm:OffsetHDR=\"%g\"\n" \
" hdrgm:HDRCapacityMin=\"%g\"\n" \
" hdrgm:HDRCapacityMax=\"%g\"\n" \
" hdrgm:BaseRenditionIsHDR=\"%s\"/>\n" \
" </rdf:RDF>\n" \
"</x:xmpmeta>"
#define FF_GAIN_MAP_XMP_NAMESPACE
Definition gain_map.h:38

Definition at line 189 of file gain_map.c.

Referenced by ff_gain_map_params_to_xmp().

Function Documentation

◆ iso21496_payload_size()

static size_t iso21496_payload_size ( int nb_channels)
static

Definition at line 37 of file gain_map.c.

Referenced by ff_gain_map_params_from_iso21496().

◆ make_q()

static int make_q ( int64_t num,
uint32_t den,
AVRational * out )
static

Definition at line 42 of file gain_map.c.

Referenced by get_sq(), and get_uq().

◆ get_sq()

static int get_sq ( GetByteContext * gb,
AVRational * out )
static

Definition at line 52 of file gain_map.c.

Referenced by ff_gain_map_params_from_iso21496().

◆ get_uq()

static int get_uq ( GetByteContext * gb,
AVRational * out )
static

Definition at line 59 of file gain_map.c.

Referenced by ff_gain_map_params_from_iso21496().

◆ ff_gain_map_params_from_iso21496()

int ff_gain_map_params_from_iso21496 ( AVGainMapParams *restrict p,
const uint8_t * data,
size_t size )

While the spec does not require reserved bits to be 0, older versions of the ISO 21496-1 draft specification had extra flags that got removed from the final publication, so conservatively error out just in case; unless the writer version is >0 in which case these may be genuine additions to later revisions of the published spec, the validity of ignoring which is already guarded by the minimum_version check.

Definition at line 66 of file gain_map.c.

◆ put_q()

static void put_q ( PutByteContext * pb,
AVRational q )
static

Definition at line 126 of file gain_map.c.

Referenced by ff_gain_map_params_to_iso21496().

◆ ff_gain_map_params_to_iso21496()

int ff_gain_map_params_to_iso21496 ( const AVGainMapParams * p,
uint8_t * buf )

Serialize an AVGainMapParams as an ISO 21496-1 gain map metadata blob.

The output starts at the minimum_version field; the caller should prepend whatever identifier its container requires.

Parameters
pparameters to serialize
bufByte buffer to fill with the serialized data. Must contain at least FF_GAIN_MAP_MAX_PAYLOAD_SIZE bytes.
Returns
Number of bytes written on success, or a negative AVERROR on failure
Note
Always succeeds if av_gain_map_params_validate() returns >= 0, and p->version <= AV_ISO21496_VERSION.

Definition at line 132 of file gain_map.c.

Referenced by jpeg_put_comments().

◆ ff_gain_map_params_check_xmp()

int ff_gain_map_params_check_xmp ( const AVGainMapParams * p)

Returns 1 if the gain map parameters are compatible with the XMP-based encoding, or 0 otherwise.

Definition at line 173 of file gain_map.c.

Referenced by ff_gain_map_params_to_xmp(), ff_mjpeg_add_gain_map_size(), and want_gain_map_xmp().

◆ ff_gain_map_params_to_xmp()

int ff_gain_map_params_to_xmp ( const AVGainMapParams * p,
char * buf )

Serialize an AVGainMapParams as an Ultra HDR XMP packet.

Parameters
pparameters to serialize
bufByte buffer to fill with the serialized data. Must contain at least FF_GAIN_MAP_MAX_XMP_LEN bytes.
Returns
Number of bytes written on success, or a negative AVERROR on failure
Note
Always succeeds if ff_gain_map_params_check_xmp() returns 1.

Definition at line 209 of file gain_map.c.

Referenced by jpeg_put_comments().