History

swresample: Check channel layouts and channels against each other and print human readable error messages

Michael Niedermayer committed 11 years ago

Commit 3c77bb51 parent 80a28c71 file · +12 −3Browse files

Unified · Split

libswresample/swresample.c+12−3
@@ -152,6 +152,7 @@ av_cold void swr_close(SwrContext *s){ · 151 unmodified lines
152152
153153 av_cold int swr_init(struct SwrContext *s){
154154 int ret;
155+ char l1[1024], l2[1024];
155156
156157 clear_context(s);
157158
@@ -277,10 +278,18 @@ av_cold int swr_init(struct SwrContext *s){ · 119 unmodified lines
277278 return -1;
278279 }
279280
281+ av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
282+ av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
283+ if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
284+ av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
285+ return AVERROR(EINVAL);
286+ }
287+ if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
288+ av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
289+ return AVERROR(EINVAL);
290+ }
291+
280292 if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
281− char l1[1024], l2[1024];
282− av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
283− av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
284293 av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
285294 "but there is not enough information to do it\n", l1, l2);
286295 return -1;

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