Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer authored on 2012/05/17 09:37:13... | ... |
@@ -21,6 +21,7 @@ |
21 | 21 |
|
22 | 22 |
#include "libavutil/eval.h" |
23 | 23 |
#include "libavutil/pixdesc.h" |
24 |
+#include "libavutil/parseutils.h" |
|
24 | 25 |
#include "libavutil/audioconvert.h" |
25 | 26 |
#include "avfilter.h" |
26 | 27 |
#include "internal.h" |
... | ... |
@@ -493,6 +494,17 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx) |
493 | 493 |
return 0; |
494 | 494 |
} |
495 | 495 |
|
496 |
+int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx) |
|
497 |
+{ |
|
498 |
+ AVRational r; |
|
499 |
+ if(av_parse_ratio(&r, arg, INT_MAX, 0, log_ctx) < 0 ||r.num<=0 ||r.den<=0) { |
|
500 |
+ av_log(log_ctx, AV_LOG_ERROR, "Invalid time base '%s'\n", arg); |
|
501 |
+ return AVERROR(EINVAL); |
|
502 |
+ } |
|
503 |
+ *ret = r; |
|
504 |
+ return 0; |
|
505 |
+} |
|
506 |
+ |
|
496 | 507 |
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx) |
497 | 508 |
{ |
498 | 509 |
char *tail; |
... | ... |
@@ -112,6 +112,16 @@ int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx) |
112 | 112 |
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx); |
113 | 113 |
|
114 | 114 |
/** |
115 |
+ * Parse a time base. |
|
116 |
+ * |
|
117 |
+ * @param ret unsigned AVRational pointer to where the value should be written |
|
118 |
+ * @param arg string to parse |
|
119 |
+ * @param log_ctx log context |
|
120 |
+ * @return 0 in case of success, a negative AVERROR code on error |
|
121 |
+ */ |
|
122 |
+int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx); |
|
123 |
+ |
|
124 |
+/** |
|
115 | 125 |
* Parse a sample format name or a corresponding integer representation. |
116 | 126 |
* |
117 | 127 |
* @param ret integer pointer to where the value should be written |