annotate ffmpeg/libavutil/parseutils.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * This file is part of FFmpeg.
yading@11 3 *
yading@11 4 * FFmpeg is free software; you can redistribute it and/or
yading@11 5 * modify it under the terms of the GNU Lesser General Public
yading@11 6 * License as published by the Free Software Foundation; either
yading@11 7 * version 2.1 of the License, or (at your option) any later version.
yading@11 8 *
yading@11 9 * FFmpeg is distributed in the hope that it will be useful,
yading@11 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 12 * Lesser General Public License for more details.
yading@11 13 *
yading@11 14 * You should have received a copy of the GNU Lesser General Public
yading@11 15 * License along with FFmpeg; if not, write to the Free Software
yading@11 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 17 */
yading@11 18
yading@11 19 #ifndef AVUTIL_PARSEUTILS_H
yading@11 20 #define AVUTIL_PARSEUTILS_H
yading@11 21
yading@11 22 #include <time.h>
yading@11 23
yading@11 24 #include "rational.h"
yading@11 25
yading@11 26 /**
yading@11 27 * @file
yading@11 28 * misc parsing utilities
yading@11 29 */
yading@11 30
yading@11 31 /**
yading@11 32 * Parse str and store the parsed ratio in q.
yading@11 33 *
yading@11 34 * Note that a ratio with infinite (1/0) or negative value is
yading@11 35 * considered valid, so you should check on the returned value if you
yading@11 36 * want to exclude those values.
yading@11 37 *
yading@11 38 * The undefined value can be expressed using the "0:0" string.
yading@11 39 *
yading@11 40 * @param[in,out] q pointer to the AVRational which will contain the ratio
yading@11 41 * @param[in] str the string to parse: it has to be a string in the format
yading@11 42 * num:den, a float number or an expression
yading@11 43 * @param[in] max the maximum allowed numerator and denominator
yading@11 44 * @param[in] log_offset log level offset which is applied to the log
yading@11 45 * level of log_ctx
yading@11 46 * @param[in] log_ctx parent logging context
yading@11 47 * @return >= 0 on success, a negative error code otherwise
yading@11 48 */
yading@11 49 int av_parse_ratio(AVRational *q, const char *str, int max,
yading@11 50 int log_offset, void *log_ctx);
yading@11 51
yading@11 52 #define av_parse_ratio_quiet(rate, str, max) \
yading@11 53 av_parse_ratio(rate, str, max, AV_LOG_MAX_OFFSET, NULL)
yading@11 54
yading@11 55 /**
yading@11 56 * Parse str and put in width_ptr and height_ptr the detected values.
yading@11 57 *
yading@11 58 * @param[in,out] width_ptr pointer to the variable which will contain the detected
yading@11 59 * width value
yading@11 60 * @param[in,out] height_ptr pointer to the variable which will contain the detected
yading@11 61 * height value
yading@11 62 * @param[in] str the string to parse: it has to be a string in the format
yading@11 63 * width x height or a valid video size abbreviation.
yading@11 64 * @return >= 0 on success, a negative error code otherwise
yading@11 65 */
yading@11 66 int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
yading@11 67
yading@11 68 /**
yading@11 69 * Parse str and store the detected values in *rate.
yading@11 70 *
yading@11 71 * @param[in,out] rate pointer to the AVRational which will contain the detected
yading@11 72 * frame rate
yading@11 73 * @param[in] str the string to parse: it has to be a string in the format
yading@11 74 * rate_num / rate_den, a float number or a valid video rate abbreviation
yading@11 75 * @return >= 0 on success, a negative error code otherwise
yading@11 76 */
yading@11 77 int av_parse_video_rate(AVRational *rate, const char *str);
yading@11 78
yading@11 79 /**
yading@11 80 * Put the RGBA values that correspond to color_string in rgba_color.
yading@11 81 *
yading@11 82 * @param color_string a string specifying a color. It can be the name of
yading@11 83 * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
yading@11 84 * possibly followed by "@" and a string representing the alpha
yading@11 85 * component.
yading@11 86 * The alpha component may be a string composed by "0x" followed by an
yading@11 87 * hexadecimal number or a decimal number between 0.0 and 1.0, which
yading@11 88 * represents the opacity value (0x00/0.0 means completely transparent,
yading@11 89 * 0xff/1.0 completely opaque).
yading@11 90 * If the alpha component is not specified then 0xff is assumed.
yading@11 91 * The string "random" will result in a random color.
yading@11 92 * @param slen length of the initial part of color_string containing the
yading@11 93 * color. It can be set to -1 if color_string is a null terminated string
yading@11 94 * containing nothing else than the color.
yading@11 95 * @return >= 0 in case of success, a negative value in case of
yading@11 96 * failure (for example if color_string cannot be parsed).
yading@11 97 */
yading@11 98 int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
yading@11 99 void *log_ctx);
yading@11 100
yading@11 101 /**
yading@11 102 * Parse timestr and return in *time a corresponding number of
yading@11 103 * microseconds.
yading@11 104 *
yading@11 105 * @param timeval puts here the number of microseconds corresponding
yading@11 106 * to the string in timestr. If the string represents a duration, it
yading@11 107 * is the number of microseconds contained in the time interval. If
yading@11 108 * the string is a date, is the number of microseconds since 1st of
yading@11 109 * January, 1970 up to the time of the parsed date. If timestr cannot
yading@11 110 * be successfully parsed, set *time to INT64_MIN.
yading@11 111
yading@11 112 * @param timestr a string representing a date or a duration.
yading@11 113 * - If a date the syntax is:
yading@11 114 * @code
yading@11 115 * [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH:MM:SS[.m...]]]}|{HHMMSS[.m...]]]}}[Z]
yading@11 116 * now
yading@11 117 * @endcode
yading@11 118 * If the value is "now" it takes the current time.
yading@11 119 * Time is local time unless Z is appended, in which case it is
yading@11 120 * interpreted as UTC.
yading@11 121 * If the year-month-day part is not specified it takes the current
yading@11 122 * year-month-day.
yading@11 123 * - If a duration the syntax is:
yading@11 124 * @code
yading@11 125 * [-][HH:]MM:SS[.m...]
yading@11 126 * [-]S+[.m...]
yading@11 127 * @endcode
yading@11 128 * @param duration flag which tells how to interpret timestr, if not
yading@11 129 * zero timestr is interpreted as a duration, otherwise as a date
yading@11 130 * @return 0 in case of success, a negative value corresponding to an
yading@11 131 * AVERROR code otherwise
yading@11 132 */
yading@11 133 int av_parse_time(int64_t *timeval, const char *timestr, int duration);
yading@11 134
yading@11 135 /**
yading@11 136 * Parse the input string p according to the format string fmt and
yading@11 137 * store its results in the structure dt.
yading@11 138 * This implementation supports only a subset of the formats supported
yading@11 139 * by the standard strptime().
yading@11 140 *
yading@11 141 * In particular it actually supports the parameters:
yading@11 142 * - %H: the hour as a decimal number, using a 24-hour clock, in the
yading@11 143 * range '00' through '23'
yading@11 144 * - %J: hours as a decimal number, in the range '0' through INT_MAX
yading@11 145 * - %M: the minute as a decimal number, using a 24-hour clock, in the
yading@11 146 * range '00' through '59'
yading@11 147 * - %S: the second as a decimal number, using a 24-hour clock, in the
yading@11 148 * range '00' through '59'
yading@11 149 * - %Y: the year as a decimal number, using the Gregorian calendar
yading@11 150 * - %m: the month as a decimal number, in the range '1' through '12'
yading@11 151 * - %d: the day of the month as a decimal number, in the range '1'
yading@11 152 * through '31'
yading@11 153 * - %%: a literal '%'
yading@11 154 *
yading@11 155 * @return a pointer to the first character not processed in this
yading@11 156 * function call, or NULL in case the function fails to match all of
yading@11 157 * the fmt string and therefore an error occurred
yading@11 158 */
yading@11 159 char *av_small_strptime(const char *p, const char *fmt, struct tm *dt);
yading@11 160
yading@11 161 /**
yading@11 162 * Attempt to find a specific tag in a URL.
yading@11 163 *
yading@11 164 * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
yading@11 165 * Return 1 if found.
yading@11 166 */
yading@11 167 int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
yading@11 168
yading@11 169 /**
yading@11 170 * Convert the decomposed UTC time in tm to a time_t value.
yading@11 171 */
yading@11 172 time_t av_timegm(struct tm *tm);
yading@11 173
yading@11 174 #endif /* AVUTIL_PARSEUTILS_H */