diff options
author | Clément Bœsch <ubitux@gmail.com> | 2011-11-24 04:30:09 +0100 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2011-11-24 16:55:45 +0100 |
commit | 573ffbb3b563d8ab9e4363acfad62d1a688f05c1 (patch) | |
tree | b1d0ce04a05ac493ed86a12c060dc8c412d5c4b2 /libavutil/samplefmt.c | |
parent | afb0470a2559c54ff41c9947f848ac7d58ac1003 (diff) | |
download | ffmpeg-573ffbb3b563d8ab9e4363acfad62d1a688f05c1.tar.gz |
lavu: add av_get_alt_sample_fmt().
Diffstat (limited to 'libavutil/samplefmt.c')
-rw-r--r-- | libavutil/samplefmt.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index fb9c46cab2..964a9f9c44 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -26,20 +26,21 @@ typedef struct SampleFmtInfo { char name[4]; int bits; int planar; + enum AVSampleFormat altform; ///< planar<->packed alternative form } SampleFmtInfo; /** this table gives more information about formats */ static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = { - [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8, .planar = 0 }, - [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16, .planar = 0 }, - [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32, .planar = 0 }, - [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32, .planar = 0 }, - [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64, .planar = 0 }, - [AV_SAMPLE_FMT_U8P] = { .name = "u8p", .bits = 8, .planar = 1 }, - [AV_SAMPLE_FMT_S16P] = { .name = "s16p", .bits = 16, .planar = 1 }, - [AV_SAMPLE_FMT_S32P] = { .name = "s32p", .bits = 32, .planar = 1 }, - [AV_SAMPLE_FMT_FLTP] = { .name = "fltp", .bits = 32, .planar = 1 }, - [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1 }, + [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8, .planar = 0, .altform = AV_SAMPLE_FMT_U8P }, + [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16, .planar = 0, .altform = AV_SAMPLE_FMT_S16P }, + [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_S32P }, + [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_FLTP }, + [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64, .planar = 0, .altform = AV_SAMPLE_FMT_DBLP }, + [AV_SAMPLE_FMT_U8P] = { .name = "u8p", .bits = 8, .planar = 1, .altform = AV_SAMPLE_FMT_U8 }, + [AV_SAMPLE_FMT_S16P] = { .name = "s16p", .bits = 16, .planar = 1, .altform = AV_SAMPLE_FMT_S16 }, + [AV_SAMPLE_FMT_S32P] = { .name = "s32p", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_S32 }, + [AV_SAMPLE_FMT_FLTP] = { .name = "fltp", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_FLT }, + [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1, .altform = AV_SAMPLE_FMT_DBL }, }; const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt) @@ -59,6 +60,15 @@ enum AVSampleFormat av_get_sample_fmt(const char *name) return AV_SAMPLE_FMT_NONE; } +enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar) +{ + if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) + return AV_SAMPLE_FMT_NONE; + if (sample_fmt_info[sample_fmt].planar == planar) + return sample_fmt; + return sample_fmt_info[sample_fmt].altform; +} + char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt) { /* print header */ |