History

libavfilter: add ff_parse_time_base()

Michael Niedermayer committed 14 years ago

Commit 34484041 parent 6579bc42 files · +22 −0Browse files

Unified · Split

2 files
  1. libavfilter/formats.c +12 −0
  2. libavfilter/internal.h +10 −0
libavfilter/formats.c+12−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/eval.h"
2323 #include "libavutil/pixdesc.h"
24+#include "libavutil/parseutils.h"
2425 #include "libavutil/audioconvert.h"
2526 #include "avfilter.h"
2627 #include "internal.h"
@@ -493,6 +494,17 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx) · 466 unmodified lines
493494 return 0;
494495 }
495496
497+int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx)
498+{
499+ AVRational r;
500+ if(av_parse_ratio(&r, arg, INT_MAX, 0, log_ctx) < 0 ||r.num<=0 ||r.den<=0) {
501+ av_log(log_ctx, AV_LOG_ERROR, "Invalid time base '%s'\n", arg);
502+ return AVERROR(EINVAL);
503+ }
504+ *ret = r;
505+ return 0;
506+}
507+
496508 int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
497509 {
498510 char *tail;
libavfilter/internal.h+10−0
@@ -111,6 +111,16 @@ int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx) · 110 unmodified lines
111111 */
112112 int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx);
113113
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+
114124 /**
115125 * Parse a sample format name or a corresponding integer representation.
116126 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t