[FFmpeg-cvslog] libavfilter: add ff_parse_time_base()
Michael Niedermayer
git at videolan.org
Thu May 17 04:12:58 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu May 17 02:37:13 2012 +0200| [3448404a707b6e236a2ffa7b0453b3300de41b7b] | committer: Michael Niedermayer
libavfilter: add ff_parse_time_base()
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3448404a707b6e236a2ffa7b0453b3300de41b7b
---
libavfilter/formats.c | 12 ++++++++++++
libavfilter/internal.h | 10 ++++++++++
2 files changed, 22 insertions(+)
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 3534d64..5564d03 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -21,6 +21,7 @@
#include "libavutil/eval.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/parseutils.h"
#include "libavutil/audioconvert.h"
#include "avfilter.h"
#include "internal.h"
@@ -493,6 +494,17 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx)
return 0;
}
+int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx)
+{
+ AVRational r;
+ if(av_parse_ratio(&r, arg, INT_MAX, 0, log_ctx) < 0 ||r.num<=0 ||r.den<=0) {
+ av_log(log_ctx, AV_LOG_ERROR, "Invalid time base '%s'\n", arg);
+ return AVERROR(EINVAL);
+ }
+ *ret = r;
+ return 0;
+}
+
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
{
char *tail;
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index f06151f..bb45274 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -112,6 +112,16 @@ int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx)
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx);
/**
+ * Parse a time base.
+ *
+ * @param ret unsigned AVRational pointer to where the value should be written
+ * @param arg string to parse
+ * @param log_ctx log context
+ * @return 0 in case of success, a negative AVERROR code on error
+ */
+int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx);
+
+/**
* Parse a sample format name or a corresponding integer representation.
*
* @param ret integer pointer to where the value should be written
More information about the ffmpeg-cvslog
mailing list