FFmpeg
Loading...
Searching...
No Matches
gain_map.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20 * @file
21 * Serialization of AVGainMapParams into the metadata blobs that image formats
22 * carry it in, and back. Kept separate from the codecs so that an encoder
23 * writing the blob and a bitstream filter splicing it into an existing
24 * bitstream can share the same code.
25 */
26
27#ifndef AVCODEC_GAIN_MAP_H
28#define AVCODEC_GAIN_MAP_H
29
30#include "libavutil/gain_map.h"
31
32/* May differ from AV_ISO21496_VERSION if libraries are not in sync */
33#define FF_GAIN_MAP_VERSION 0
34#define FF_GAIN_MAP_MAX_PAYLOAD_SIZE 141 /* = 5 + 2*8 + 3*5*8 */
35
36/* For XMP-based encoding */
37#define FF_GAIN_MAP_XMP_IDENT "http://ns.adobe.com/xap/1.0/"
38#define FF_GAIN_MAP_XMP_NAMESPACE "http://ns.adobe.com/hdr-gain-map/1.0/"
39#define FF_GAIN_MAP_XMP_MAX_LEN 1024
40
41/**
42 * Parse the payload of an ISO 21496-1 gain map metadata blob.
43 *
44 * @param p struct to fill; overwritten on success, untouched on failure
45 * @param data payload, excluding container-specific identifiers
46 * @param size size of `data` in bytes
47 *
48 * @return >= 0 on success, or a negative AVERROR on failure
49 */
51 size_t size);
52
53/**
54 * Serialize an AVGainMapParams as an ISO 21496-1 gain map metadata blob.
55 *
56 * The output starts at the minimum_version field; the caller should prepend
57 * whatever identifier its container requires.
58 *
59 * @param p parameters to serialize
60 * @param buf Byte buffer to fill with the serialized data. Must contain at
61 * least FF_GAIN_MAP_MAX_PAYLOAD_SIZE bytes.
62 *
63 * @return Number of bytes written on success, or a negative AVERROR on failure
64 *
65 * @note Always succeeds if av_gain_map_params_validate() returns >= 0, and
66 * p->version <= AV_ISO21496_VERSION.
67 */
68int ff_gain_map_params_to_iso21496(const AVGainMapParams *p, uint8_t *buf);
69
70/**
71 * Returns 1 if the gain map parameters are compatible with the XMP-based
72 * encoding, or 0 otherwise.
73 */
75
76/**
77 * Serialize an AVGainMapParams as an Ultra HDR XMP packet.
78 *
79 * @param p parameters to serialize
80 * @param buf Byte buffer to fill with the serialized data. Must contain at
81 * least FF_GAIN_MAP_MAX_XMP_LEN bytes.
82 *
83 * @return Number of bytes written on success, or a negative AVERROR on failure
84 *
85 * @note Always succeeds if ff_gain_map_params_check_xmp() returns 1.
86 */
87int ff_gain_map_params_to_xmp(const AVGainMapParams *p, char *buf);
88
89#endif /* AVCODEC_GAIN_MAP_H */
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 gain_map.c:173
int ff_gain_map_params_to_xmp(const AVGainMapParams *p, char *buf)
Serialize an AVGainMapParams as an Ultra HDR XMP packet.
Definition gain_map.c:209
int ff_gain_map_params_from_iso21496(AVGainMapParams *p, const uint8_t *data, size_t size)
Parse the payload of an ISO 21496-1 gain map metadata blob.
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.
Definition gain_map.c:132
const char data[16]
Definition mxf.c:149
Parameters describing how to combine a gain map rendition with its base rendition to recover the alte...
Definition gain_map.h:39
int size