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 * replaygain tags parsing
22 */
23
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include <string.h>
27
34
38
40 {
41 char *fraction;
42 int scale = 10000;
44 int sign = 1;
45 int db;
46
47 if (!value)
49
50 value += strspn(value, " \t");
51
52 if (*value == '-')
53 sign = -1;
54
55 db = strtol(value, &fraction, 0);
56 if (*fraction++ == '.') {
58 mb += scale * (*fraction - '0');
59 scale /= 10;
60 fraction++;
61 }
62 }
63
64 if (abs(db) > (INT32_MAX -
mb) / 100000)
66
67 return db * 100000 + sign *
mb;
68 }
69
72 {
74
75 if (tg == INT32_MIN && ag == INT32_MIN)
76 return 0;
77
79 sizeof(*replaygain));
80 if (!replaygain)
82
87
88 return 0;
89 }
90
92 {
94
99
105 }
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
memory handling functions
static int32_t parse_value(const char *value, int32_t min)
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
int32_t album_gain
Same as track_gain, but for the whole album.
GLsizei GLboolean const GLfloat * value
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
This side data should be associated with an audio stream and contains ReplayGain information in form ...
int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp, int32_t ag, uint32_t ap)
Export already decoded replaygain values as per-stream side data.
uint32_t album_peak
Same as track_peak, but for the whole album,.
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification).