sbcparse: Fix frame length calculation

SBC frame length calculation wasn't being rounded up to the nearest byte
(as specified in the A2DP 1.0 specification, section 12.9). This could
cause 'stereo' and 'joint stereo' mode SBC streams to have incorrectly
calculated frame lengths.

Incorrect frame length calculation causes frame coalescing to fail, as
subsequent frames in the stream aren't found in the expected locations.

https://bugzilla.gnome.org/show_bug.cgi?id=742446
This commit is contained in:
Tim Sheridan 2016-01-11 16:29:55 +00:00 committed by Tim-Philipp Müller
parent 0bb8000874
commit 205565ccd9

View file

@ -423,13 +423,13 @@ gst_sbc_calc_framelen (guint subbands, GstSbcChannelMode ch_mode,
{ {
switch (ch_mode) { switch (ch_mode) {
case GST_SBC_CHANNEL_MODE_MONO: case GST_SBC_CHANNEL_MODE_MONO:
return 4 + (subbands * 1) / 2 + (blocks * 1 * bitpool) / 8; return 4 + (subbands * 1) / 2 + ((blocks * 1 * bitpool) + 7) / 8;
case GST_SBC_CHANNEL_MODE_DUAL: case GST_SBC_CHANNEL_MODE_DUAL:
return 4 + (subbands * 2) / 2 + (blocks * 2 * bitpool) / 8; return 4 + (subbands * 2) / 2 + ((blocks * 2 * bitpool) + 7) / 8;
case GST_SBC_CHANNEL_MODE_STEREO: case GST_SBC_CHANNEL_MODE_STEREO:
return 4 + (subbands * 2) / 2 + (blocks * bitpool) / 8; return 4 + (subbands * 2) / 2 + ((blocks * bitpool) + 7) / 8;
case GST_SBC_CHANNEL_MODE_JOINT_STEREO: case GST_SBC_CHANNEL_MODE_JOINT_STEREO:
return 4 + (subbands * 2) / 2 + (subbands + blocks * bitpool) / 8; return 4 + (subbands * 2) / 2 + ((subbands + blocks * bitpool) + 7) / 8;
default: default:
break; break;
} }