diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2009-03-20 18:40:43 -0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-07-29 19:48:28 -0700 |
commit | 015f9540154b028c7dec47ac9511377d5f3f509c (patch) | |
tree | 3dc3bed1c0cb42772c8dc3fade7074a4e038f1eb | |
parent | 9ad94401a5ef7d8b37f7747e28c1a1f3ac8e6cc2 (diff) |
sbc: Fix misuse of 'frame.joint' when estimating the frame length.
'frame.joint' is not the flag for joint stereo mode, it is a set of bits which
show for which subbands channels joining was actually used.
-rw-r--r-- | sbc/sbc.c | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -1004,7 +1004,7 @@ int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output, sbc->bitpool = priv->frame.bitpool; priv->frame.codesize = sbc_get_codesize(sbc); - priv->frame.length = sbc_get_frame_length(sbc); + priv->frame.length = framelen; } if (!output) @@ -1136,30 +1136,25 @@ void sbc_finish(sbc_t *sbc) int sbc_get_frame_length(sbc_t *sbc) { int ret; - uint8_t subbands, channels, blocks, joint; + uint8_t subbands, channels, blocks, joint, bitpool; struct sbc_priv *priv; priv = sbc->priv; - if (!priv->init) { - subbands = sbc->subbands ? 8 : 4; - blocks = 4 + (sbc->blocks * 4); - channels = sbc->mode == SBC_MODE_MONO ? 1 : 2; - joint = sbc->mode == SBC_MODE_JOINT_STEREO ? 1 : 0; - } else { - subbands = priv->frame.subbands; - blocks = priv->frame.blocks; - channels = priv->frame.channels; - joint = priv->frame.joint; - } + if (priv->init) + return priv->frame.length; - ret = 4 + (4 * subbands * channels) / 8; + subbands = sbc->subbands ? 8 : 4; + blocks = 4 + (sbc->blocks * 4); + channels = sbc->mode == SBC_MODE_MONO ? 1 : 2; + joint = sbc->mode == SBC_MODE_JOINT_STEREO ? 1 : 0; + bitpool = sbc->bitpool; + ret = 4 + (4 * subbands * channels) / 8; /* This term is not always evenly divide so we round it up */ if (channels == 1) - ret += ((blocks * channels * sbc->bitpool) + 7) / 8; + ret += ((blocks * channels * bitpool) + 7) / 8; else - ret += (((joint ? subbands : 0) + blocks * sbc->bitpool) + 7) - / 8; + ret += (((joint ? subbands : 0) + blocks * bitpool) + 7) / 8; return ret; } |