audioconvert: handle unpositioned channels

Refuse to convert between unpositioned layouts.
This commit is contained in:
Wim Taymans 2012-01-02 15:03:54 +01:00
parent ed6fd4eb2f
commit ff4efd075f
2 changed files with 21 additions and 1 deletions

View file

@ -606,6 +606,10 @@ audio_convert_prepare_context (AudioConvertCtx * ctx, GstAudioInfo * in,
/* first clean the existing context */
audio_convert_clean_context (ctx);
if ((GST_AUDIO_INFO_CHANNELS (in) != GST_AUDIO_INFO_CHANNELS (out)) &&
(GST_AUDIO_INFO_IS_UNPOSITIONED (in)
|| GST_AUDIO_INFO_IS_UNPOSITIONED (out)))
goto unpositioned;
ctx->in = *in;
ctx->out = *out;
@ -613,6 +617,8 @@ audio_convert_prepare_context (AudioConvertCtx * ctx, GstAudioInfo * in,
in_depth = GST_AUDIO_FORMAT_INFO_DEPTH (in->finfo);
out_depth = GST_AUDIO_FORMAT_INFO_DEPTH (out->finfo);
GST_INFO ("depth in %d, out %d", in_depth, out_depth);
/* Don't dither or apply noise shaping if target depth is bigger than 20 bits
* as DA converters only can do a SNR up to 20 bits in reality.
* Also don't dither or apply noise shaping if target depth is larger than
@ -621,9 +627,11 @@ audio_convert_prepare_context (AudioConvertCtx * ctx, GstAudioInfo * in,
|| in_depth >= out_depth)) {
ctx->dither = dither;
ctx->ns = ns;
GST_INFO ("using dither %d and noise shaping %d", dither, ns);
} else {
ctx->dither = DITHER_NONE;
ctx->ns = NOISE_SHAPING_NONE;
GST_INFO ("using no dither and noise shaping");
}
/* Use simple error feedback when output sample rate is smaller than
@ -639,6 +647,8 @@ audio_convert_prepare_context (AudioConvertCtx * ctx, GstAudioInfo * in,
idx_out = audio_convert_get_func_index (ctx, out->finfo);
ctx->pack = pack_funcs[idx_out];
GST_INFO ("func index in %d, out %d", idx_in, idx_out);
/* if both formats are float/double or we use noise shaping use double as
* intermediate format and switch mixing */
if (!DOUBLE_INTERMEDIATE_FORMAT (ctx)) {
@ -665,9 +675,18 @@ audio_convert_prepare_context (AudioConvertCtx * ctx, GstAudioInfo * in,
ctx->out_scale =
GST_AUDIO_FORMAT_INFO_IS_INTEGER (out->finfo) ? (32 - out_depth) : 0;
GST_INFO ("scale in %d, out %d", ctx->in_scale, ctx->out_scale);
gst_audio_quantize_setup (ctx);
return TRUE;
/* ERRORS */
unpositioned:
{
GST_WARNING ("unpositioned channels");
return FALSE;
}
}
gboolean

View file

@ -584,7 +584,8 @@ gst_channel_mix_fill_matrix (AudioConvertCtx * this)
gst_channel_mix_fill_identical (this);
if (!GST_AUDIO_INFO_HAS_DEFAULT_POSITIONS (&this->in)) {
if (!GST_AUDIO_INFO_HAS_DEFAULT_POSITIONS (&this->in) &&
!GST_AUDIO_INFO_IS_UNPOSITIONED (&this->in)) {
gst_channel_mix_fill_compatible (this);
gst_channel_mix_fill_others (this);
gst_channel_mix_fill_normalize (this);