~ppsspp/ppsspp/ffmpeg

« back to all changes in this revision

Viewing changes to libavutil/channel_layout.c

  • Committer: Henrik Rydgård
  • Date: 2014-01-03 10:44:32 UTC
  • Revision ID: git-v1:87c6c126784b1718bfa448ecf2e6a9fef781eb4e
Update our ffmpeg snapshot to a clone of the official repository.

This is because Maxim's at3plus support has been officially merged!

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * audio channel layout utility functions
24
24
 */
25
25
 
 
26
#include <stdint.h>
 
27
 
26
28
#include "avstring.h"
27
29
#include "avutil.h"
28
30
#include "channel_layout.h"
103
105
    { "downmix",     2,  AV_CH_LAYOUT_STEREO_DOWNMIX, },
104
106
};
105
107
 
 
108
#if FF_API_GET_CHANNEL_LAYOUT_COMPAT
 
109
static uint64_t get_channel_layout_single(const char *name, int name_len, int compat)
 
110
#else
106
111
static uint64_t get_channel_layout_single(const char *name, int name_len)
 
112
#endif
107
113
{
108
114
    int i;
109
115
    char *end;
120
126
            !memcmp(channel_names[i].name, name, name_len))
121
127
            return (int64_t)1 << i;
122
128
    i = strtol(name, &end, 10);
123
 
    if (end - name == name_len ||
124
 
        (end + 1 - name == name_len && *end  == 'c'))
 
129
 
 
130
#if FF_API_GET_CHANNEL_LAYOUT_COMPAT
 
131
    if (compat) {
 
132
        if (end - name == name_len ||
 
133
            (end + 1 - name == name_len && *end  == 'c')) {
 
134
            layout = av_get_default_channel_layout(i);
 
135
            if (end - name == name_len) {
 
136
                av_log(NULL, AV_LOG_WARNING,
 
137
                       "Single channel layout '%.*s' is interpreted as a number of channels, "
 
138
                       "switch to the syntax '%.*sc' otherwise it will be interpreted as a "
 
139
                       "channel layout number in a later version\n",
 
140
                       name_len, name, name_len, name);
 
141
                return layout;
 
142
            }
 
143
        }
 
144
    } else {
 
145
#endif
 
146
    if ((end + 1 - name == name_len && *end  == 'c'))
125
147
        return av_get_default_channel_layout(i);
 
148
#if FF_API_GET_CHANNEL_LAYOUT_COMPAT
 
149
    }
 
150
#endif
 
151
 
126
152
    layout = strtoll(name, &end, 0);
127
153
    if (end - name == name_len)
128
154
        return FFMAX(layout, 0);
129
155
    return 0;
130
156
}
131
157
 
 
158
#if FF_API_GET_CHANNEL_LAYOUT_COMPAT
 
159
uint64_t ff_get_channel_layout(const char *name, int compat)
 
160
#else
132
161
uint64_t av_get_channel_layout(const char *name)
 
162
#endif
133
163
{
134
164
    const char *n, *e;
135
165
    const char *name_end = name + strlen(name);
137
167
 
138
168
    for (n = name; n < name_end; n = e + 1) {
139
169
        for (e = n; e < name_end && *e != '+' && *e != '|'; e++);
 
170
#if FF_API_GET_CHANNEL_LAYOUT_COMPAT
 
171
        layout_single = get_channel_layout_single(n, e - n, compat);
 
172
#else
140
173
        layout_single = get_channel_layout_single(n, e - n);
 
174
#endif
141
175
        if (!layout_single)
142
176
            return 0;
143
177
        layout |= layout_single;
145
179
    return layout;
146
180
}
147
181
 
 
182
#if FF_API_GET_CHANNEL_LAYOUT_COMPAT
 
183
uint64_t av_get_channel_layout(const char *name)
 
184
{
 
185
    return ff_get_channel_layout(name, 1);
 
186
}
 
187
#endif
 
188
 
148
189
void av_bprint_channel_layout(struct AVBPrint *bp,
149
190
                              int nb_channels, uint64_t channel_layout)
150
191
{