History

lavu/opt: add AV_OPT_SAMPLE_FMT option

Stefano Sabatini committed 14 years ago

Commit 481fdee1 parent 7be09a94 files · +33 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/opt.c +28 −0
  3. libavutil/opt.h +1 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2012-11-03 - xxxxxxx - lavu 52.3.100 - opt.h
19+ Add AV_OPT_TYPE_SAMPLE_FMT value to AVOptionType enum.
20+
1821 2012-10-21 - xxxxxxx - lavc 54.68.100 - avcodec.h
1922 lavfi 3.20.100 - avfilter.h
2023 Add AV_PKT_DATA_STRINGS_METADATA side data type, used to transmit key/value
libavutil/opt.c+28−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "parseutils.h"
3636 #include "pixdesc.h"
3737 #include "mathematics.h"
38+#include "samplefmt.h"
3839
3940 #if FF_API_FIND_OPT
4041 //FIXME order them and do a bin search
@@ -279,6 +280,22 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) · 238 unmodified lines
279280 }
280281 *(enum AVPixelFormat *)dst = ret;
281282 return 0;
283+ case AV_OPT_TYPE_SAMPLE_FMT:
284+ if (!val || !strcmp(val, "none")) {
285+ ret = AV_SAMPLE_FMT_NONE;
286+ } else {
287+ ret = av_get_sample_fmt(val);
288+ if (ret == AV_SAMPLE_FMT_NONE) {
289+ char *tail;
290+ ret = strtol(val, &tail, 0);
291+ if (*tail || (unsigned)ret >= AV_SAMPLE_FMT_NB) {
292+ av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", val);
293+ return AVERROR(EINVAL);
294+ }
295+ }
296+ }
297+ *(enum AVSampleFormat *)dst = ret;
298+ return 0;
282299 }
283300
284301 av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
@@ -467,6 +484,9 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) · 182 unmodified lines
467484 case AV_OPT_TYPE_PIXEL_FMT:
468485 ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_pix_fmt_name(*(enum AVPixelFormat *)dst), "none"));
469486 break;
487+ case AV_OPT_TYPE_SAMPLE_FMT:
488+ ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_sample_fmt_name(*(enum AVSampleFormat *)dst), "none"));
489+ break;
470490 default:
471491 return AVERROR(EINVAL);
472492 }
@@ -642,6 +662,9 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, · 169 unmodified lines
642662 case AV_OPT_TYPE_PIXEL_FMT:
643663 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<pix_fmt>");
644664 break;
665+ case AV_OPT_TYPE_SAMPLE_FMT:
666+ av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<sample_fmt>");
667+ break;
645668 case AV_OPT_TYPE_CONST:
646669 default:
647670 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "");
@@ -992,6 +1015,7 @@ typedef struct TestContext · 344 unmodified lines
9921015 AVRational rational;
9931016 int w, h;
9941017 enum AVPixelFormat pix_fmt;
1018+ enum AVSampleFormat sample_fmt;
9951019 } TestContext;
9961020
9971021 #define OFFSET(x) offsetof(TestContext, x)
@@ -1011,6 +1035,7 @@ static const AVOption test_options[]= { · 13 unmodified lines
10111035 {"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" },
10121036 {"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE,{0}, 0, 0 },
10131037 {"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT,{0}, 0, 0 },
1038+{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT,{0}, 0, 0 },
10141039 {NULL},
10151040 };
10161041
@@ -1058,6 +1083,9 @@ int main(void) · 41 unmodified lines
10581083 "pix_fmt=yuv420p",
10591084 "pix_fmt=2",
10601085 "pix_fmt=bogus",
1086+ "sample_fmt=s16",
1087+ "sample_fmt=2",
1088+ "sample_fmt=bogus",
10611089 };
10621090
10631091 test_ctx.class = &test_class;
libavutil/opt.h+1−0
@@ -227,6 +227,7 @@ enum AVOptionType{ · 226 unmodified lines
227227 AV_OPT_TYPE_CONST = 128,
228228 AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers
229229 AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'),
230+ AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
230231 #if FF_API_OLD_AVOPTIONS
231232 FF_OPT_TYPE_FLAGS = 0,
232233 FF_OPT_TYPE_INT,
libavutil/version.h+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
7575 */
7676
7777 #define LIBAVUTIL_VERSION_MAJOR 52
78−#define LIBAVUTIL_VERSION_MINOR 2
78+#define LIBAVUTIL_VERSION_MINOR 3
7979 #define LIBAVUTIL_VERSION_MICRO 100
8080
8181 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

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