| 36 | #include "replaygain.h" |
| 37 | |
| 38 | static int32_t parse_value(const char *value, int32_t min) |
| 39 | { |
| 40 | char *fraction; |
| 41 | int scale = 10000; |
| 42 | int32_t mb = 0; |
| 43 | int sign = 1; |
| 44 | int db; |
| 45 | |
| 46 | if (!value) |
| 47 | return min; |
| 48 | |
| 49 | value += strspn(value, " \t"); |
| 50 | |
| 51 | if (*value == '-') |
| 52 | sign = -1; |
| 53 | |
| 54 | db = strtol(value, &fraction, 0); |
| 55 | if (*fraction++ == '.') { |
| 56 | while (av_isdigit(*fraction) && scale) { |
| 57 | mb += scale * (*fraction - '0'); |
| 58 | scale /= 10; |
| 59 | fraction++; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if (llabs(db) > (INT32_MAX - mb) / 100000) |
| 64 | return min; |
| 65 | |
| 66 | return db * 100000 + sign * mb; |
| 67 | } |
| 68 | |
| 69 | int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp, |
| 70 | int32_t ag, uint32_t ap) |
no test coverage detected