Skip to content

Commit

Permalink
fix seg faults if back channels are used instead of side
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwinEsch committed Oct 30, 2016
1 parent 34f5040 commit 12a5b0c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 31 deletions.
2 changes: 1 addition & 1 deletion adsp.freesurround/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="adsp.freesurround"
version="0.2.1"
version="0.2.2"
name="Free Surround Processor"
provider-name="Team KODI">
<requires>
Expand Down
62 changes: 43 additions & 19 deletions src/ChannelMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2854,25 +2854,49 @@ bool init_maps() {
chn_alloc[cs_5stereo].push_back(std::vector<float*>(&map_5stereo_rcf[0],&map_5stereo_rcf[21]));
chn_alloc[cs_5stereo].push_back(std::vector<float*>(&map_5stereo_rf[0],&map_5stereo_rf[21]));
chn_alloc[cs_5stereo].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));
chn_angle[cs_4point1] = std::vector<float>(&map_4point1_ang[0],&map_4point1_ang[sizeof(map_4point1_ang)/sizeof(map_4point1_ang[0])]);
chn_xsf[cs_4point1] = std::vector<float>(&map_4point1_xsf[0],&map_4point1_xsf[sizeof(map_4point1_xsf)/sizeof(map_4point1_xsf[0])]);
chn_ysf[cs_4point1] = std::vector<float>(&map_4point1_ysf[0],&map_4point1_ysf[sizeof(map_4point1_ysf)/sizeof(map_4point1_ysf[0])]);
chn_id[cs_4point1] = std::vector<AE_DSP_CHANNEL_PRESENT>(&map_4point1_id[0],&map_4point1_id[sizeof(map_4point1_id)/sizeof(map_4point1_id[0])]);
chn_alloc[cs_4point1].push_back(std::vector<float*>(&map_4point1_lf[0],&map_4point1_lf[21]));
chn_alloc[cs_4point1].push_back(std::vector<float*>(&map_4point1_rf[0],&map_4point1_rf[21]));
chn_alloc[cs_4point1].push_back(std::vector<float*>(&map_4point1_ls[0],&map_4point1_ls[21]));
chn_alloc[cs_4point1].push_back(std::vector<float*>(&map_4point1_rs[0],&map_4point1_rs[21]));
chn_alloc[cs_4point1].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));
chn_angle[cs_5point1] = std::vector<float>(&map_5point1_ang[0],&map_5point1_ang[sizeof(map_5point1_ang)/sizeof(map_5point1_ang[0])]);
chn_xsf[cs_5point1] = std::vector<float>(&map_5point1_xsf[0],&map_5point1_xsf[sizeof(map_5point1_xsf)/sizeof(map_5point1_xsf[0])]);
chn_ysf[cs_5point1] = std::vector<float>(&map_5point1_ysf[0],&map_5point1_ysf[sizeof(map_5point1_ysf)/sizeof(map_5point1_ysf[0])]);
chn_id[cs_5point1] = std::vector<AE_DSP_CHANNEL_PRESENT>(&map_5point1_id[0],&map_5point1_id[sizeof(map_5point1_id)/sizeof(map_5point1_id[0])]);
chn_alloc[cs_5point1].push_back(std::vector<float*>(&map_5point1_lf[0],&map_5point1_lf[21]));
chn_alloc[cs_5point1].push_back(std::vector<float*>(&map_5point1_cf[0],&map_5point1_cf[21]));
chn_alloc[cs_5point1].push_back(std::vector<float*>(&map_5point1_rf[0],&map_5point1_rf[21]));
chn_alloc[cs_5point1].push_back(std::vector<float*>(&map_5point1_ls[0],&map_5point1_ls[21]));
chn_alloc[cs_5point1].push_back(std::vector<float*>(&map_5point1_rs[0],&map_5point1_rs[21]));
chn_alloc[cs_5point1].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));

chn_angle[cs_4point1_Side] = std::vector<float>(&map_4point1_ang[0],&map_4point1_ang[sizeof(map_4point1_ang)/sizeof(map_4point1_ang[0])]);
chn_xsf[cs_4point1_Side] = std::vector<float>(&map_4point1_xsf[0],&map_4point1_xsf[sizeof(map_4point1_xsf)/sizeof(map_4point1_xsf[0])]);
chn_ysf[cs_4point1_Side] = std::vector<float>(&map_4point1_ysf[0],&map_4point1_ysf[sizeof(map_4point1_ysf)/sizeof(map_4point1_ysf[0])]);
chn_id[cs_4point1_Side] = std::vector<AE_DSP_CHANNEL_PRESENT>(&map_4point1_id[0],&map_4point1_id[sizeof(map_4point1_id)/sizeof(map_4point1_id[0])]);
chn_alloc[cs_4point1_Side].push_back(std::vector<float*>(&map_4point1_lf[0],&map_4point1_lf[21]));
chn_alloc[cs_4point1_Side].push_back(std::vector<float*>(&map_4point1_rf[0],&map_4point1_rf[21]));
chn_alloc[cs_4point1_Side].push_back(std::vector<float*>(&map_4point1_ls[0],&map_4point1_ls[21]));
chn_alloc[cs_4point1_Side].push_back(std::vector<float*>(&map_4point1_rs[0],&map_4point1_rs[21]));
chn_alloc[cs_4point1_Side].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));

chn_angle[cs_4point1_Back] = std::vector<float>(&map_4point1_ang[0],&map_4point1_ang[sizeof(map_4point1_ang)/sizeof(map_4point1_ang[0])]);
chn_xsf[cs_4point1_Back] = std::vector<float>(&map_4point1_xsf[0],&map_4point1_xsf[sizeof(map_4point1_xsf)/sizeof(map_4point1_xsf[0])]);
chn_ysf[cs_4point1_Back] = std::vector<float>(&map_4point1_ysf[0],&map_4point1_ysf[sizeof(map_4point1_ysf)/sizeof(map_4point1_ysf[0])]);
chn_id[cs_4point1_Back] = std::vector<AE_DSP_CHANNEL_PRESENT>(&map_4point1_id[0],&map_4point1_id[sizeof(map_4point1_id)/sizeof(map_4point1_id[0])]);
chn_alloc[cs_4point1_Back].push_back(std::vector<float*>(&map_4point1_lf[0],&map_4point1_lf[21]));
chn_alloc[cs_4point1_Back].push_back(std::vector<float*>(&map_4point1_rf[0],&map_4point1_rf[21]));
chn_alloc[cs_4point1_Back].push_back(std::vector<float*>(&map_4point1_ls[0],&map_4point1_ls[21]));
chn_alloc[cs_4point1_Back].push_back(std::vector<float*>(&map_4point1_rs[0],&map_4point1_rs[21]));
chn_alloc[cs_4point1_Back].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));

chn_angle[cs_5point1_Side] = std::vector<float>(&map_5point1_ang[0],&map_5point1_ang[sizeof(map_5point1_ang)/sizeof(map_5point1_ang[0])]);
chn_xsf[cs_5point1_Side] = std::vector<float>(&map_5point1_xsf[0],&map_5point1_xsf[sizeof(map_5point1_xsf)/sizeof(map_5point1_xsf[0])]);
chn_ysf[cs_5point1_Side] = std::vector<float>(&map_5point1_ysf[0],&map_5point1_ysf[sizeof(map_5point1_ysf)/sizeof(map_5point1_ysf[0])]);
chn_id[cs_5point1_Side] = std::vector<AE_DSP_CHANNEL_PRESENT>(&map_5point1_id[0],&map_5point1_id[sizeof(map_5point1_id)/sizeof(map_5point1_id[0])]);
chn_alloc[cs_5point1_Side].push_back(std::vector<float*>(&map_5point1_lf[0],&map_5point1_lf[21]));
chn_alloc[cs_5point1_Side].push_back(std::vector<float*>(&map_5point1_cf[0],&map_5point1_cf[21]));
chn_alloc[cs_5point1_Side].push_back(std::vector<float*>(&map_5point1_rf[0],&map_5point1_rf[21]));
chn_alloc[cs_5point1_Side].push_back(std::vector<float*>(&map_5point1_ls[0],&map_5point1_ls[21]));
chn_alloc[cs_5point1_Side].push_back(std::vector<float*>(&map_5point1_rs[0],&map_5point1_rs[21]));
chn_alloc[cs_5point1_Side].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));

chn_angle[cs_5point1_Back] = std::vector<float>(&map_5point1_ang[0],&map_5point1_ang[sizeof(map_5point1_ang)/sizeof(map_5point1_ang[0])]);
chn_xsf[cs_5point1_Back] = std::vector<float>(&map_5point1_xsf[0],&map_5point1_xsf[sizeof(map_5point1_xsf)/sizeof(map_5point1_xsf[0])]);
chn_ysf[cs_5point1_Back] = std::vector<float>(&map_5point1_ysf[0],&map_5point1_ysf[sizeof(map_5point1_ysf)/sizeof(map_5point1_ysf[0])]);
chn_id[cs_5point1_Back] = std::vector<AE_DSP_CHANNEL_PRESENT>(&map_5point1_id[0],&map_5point1_id[sizeof(map_5point1_id)/sizeof(map_5point1_id[0])]);
chn_alloc[cs_5point1_Back].push_back(std::vector<float*>(&map_5point1_lf[0],&map_5point1_lf[21]));
chn_alloc[cs_5point1_Back].push_back(std::vector<float*>(&map_5point1_cf[0],&map_5point1_cf[21]));
chn_alloc[cs_5point1_Back].push_back(std::vector<float*>(&map_5point1_rf[0],&map_5point1_rf[21]));
chn_alloc[cs_5point1_Back].push_back(std::vector<float*>(&map_5point1_ls[0],&map_5point1_ls[21]));
chn_alloc[cs_5point1_Back].push_back(std::vector<float*>(&map_5point1_rs[0],&map_5point1_rs[21]));
chn_alloc[cs_5point1_Back].push_back(std::vector<float*>(&map_lfe_lfe[0],&map_lfe_lfe[21]));

chn_angle[cs_6point1] = std::vector<float>(&map_6point1_ang[0],&map_6point1_ang[sizeof(map_6point1_ang)/sizeof(map_6point1_ang[0])]);
chn_xsf[cs_6point1] = std::vector<float>(&map_6point1_xsf[0],&map_6point1_xsf[sizeof(map_6point1_xsf)/sizeof(map_6point1_xsf[0])]);
chn_ysf[cs_6point1] = std::vector<float>(&map_6point1_ysf[0],&map_6point1_ysf[sizeof(map_6point1_ysf)/sizeof(map_6point1_ysf[0])]);
Expand Down
41 changes: 33 additions & 8 deletions src/DSPProcessFreeSurround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ unsigned int CDSPProcess_FreeSurround::StreamProcess(float **array_in, float **a
array_out[AE_DSP_CH_LFE][pos] = outputs[5][m_ProcessBufferPos];
break;
}
case cs_4point1:
case cs_4point1_Side:
{
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
array_out[AE_DSP_CH_FR][pos] = outputs[1][m_ProcessBufferPos];
Expand All @@ -216,7 +216,16 @@ unsigned int CDSPProcess_FreeSurround::StreamProcess(float **array_in, float **a
array_out[AE_DSP_CH_LFE][pos] = outputs[4][m_ProcessBufferPos];
break;
}
case cs_5point1:
case cs_4point1_Back:
{
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
array_out[AE_DSP_CH_FR][pos] = outputs[1][m_ProcessBufferPos];
array_out[AE_DSP_CH_BL][pos] = outputs[2][m_ProcessBufferPos];
array_out[AE_DSP_CH_BR][pos] = outputs[3][m_ProcessBufferPos];
array_out[AE_DSP_CH_LFE][pos] = outputs[4][m_ProcessBufferPos];
break;
}
case cs_5point1_Side:
{
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
array_out[AE_DSP_CH_FC][pos] = outputs[1][m_ProcessBufferPos];
Expand All @@ -226,6 +235,16 @@ unsigned int CDSPProcess_FreeSurround::StreamProcess(float **array_in, float **a
array_out[AE_DSP_CH_LFE][pos] = outputs[5][m_ProcessBufferPos];
break;
}
case cs_5point1_Back:
{
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
array_out[AE_DSP_CH_FC][pos] = outputs[1][m_ProcessBufferPos];
array_out[AE_DSP_CH_FR][pos] = outputs[2][m_ProcessBufferPos];
array_out[AE_DSP_CH_BL][pos] = outputs[3][m_ProcessBufferPos];
array_out[AE_DSP_CH_BR][pos] = outputs[4][m_ProcessBufferPos];
array_out[AE_DSP_CH_LFE][pos] = outputs[5][m_ProcessBufferPos];
break;
}
case cs_6point1:
{
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
Expand Down Expand Up @@ -372,12 +391,18 @@ unsigned int CDSPProcess_FreeSurround::StreamProcess(float **array_in, float **a
case cs_legacy:
default:
{
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
array_out[AE_DSP_CH_FC][pos] = outputs[1][m_ProcessBufferPos];
array_out[AE_DSP_CH_FR][pos] = outputs[2][m_ProcessBufferPos];
array_out[AE_DSP_CH_BL][pos] = outputs[3][m_ProcessBufferPos];
array_out[AE_DSP_CH_BR][pos] = outputs[4][m_ProcessBufferPos];
array_out[AE_DSP_CH_LFE][pos] = outputs[5][m_ProcessBufferPos];
if (array_out[AE_DSP_CH_FL])
array_out[AE_DSP_CH_FL][pos] = outputs[0][m_ProcessBufferPos];
if (array_out[AE_DSP_CH_FC])
array_out[AE_DSP_CH_FC][pos] = outputs[1][m_ProcessBufferPos];
if (array_out[AE_DSP_CH_FR])
array_out[AE_DSP_CH_FR][pos] = outputs[2][m_ProcessBufferPos];
if (array_out[AE_DSP_CH_BL])
array_out[AE_DSP_CH_BL][pos] = outputs[3][m_ProcessBufferPos];
if (array_out[AE_DSP_CH_BR])
array_out[AE_DSP_CH_BR][pos] = outputs[4][m_ProcessBufferPos];
if (array_out[AE_DSP_CH_LFE])
array_out[AE_DSP_CH_LFE][pos] = outputs[5][m_ProcessBufferPos];
break;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/FreeSurroundDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ typedef enum {
cs_stereo = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_LFE,
cs_3stereo = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_LFE,
cs_5stereo = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FLOC | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FROC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_LFE,
cs_4point1 = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_SL | AE_DSP_PRSNT_CH_SR | AE_DSP_PRSNT_CH_LFE,
cs_5point1 = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_SL | AE_DSP_PRSNT_CH_SR | AE_DSP_PRSNT_CH_LFE,
cs_4point1_Side = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_SL | AE_DSP_PRSNT_CH_SR | AE_DSP_PRSNT_CH_LFE,
cs_4point1_Back = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_BL | AE_DSP_PRSNT_CH_BR | AE_DSP_PRSNT_CH_LFE,
cs_5point1_Side = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_SL | AE_DSP_PRSNT_CH_SR | AE_DSP_PRSNT_CH_LFE,
cs_5point1_Back = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_BL | AE_DSP_PRSNT_CH_BR | AE_DSP_PRSNT_CH_LFE,
cs_6point1 = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_SL | AE_DSP_PRSNT_CH_SR | AE_DSP_PRSNT_CH_BC | AE_DSP_PRSNT_CH_LFE,
cs_7point1 = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FR | AE_DSP_PRSNT_CH_SL | AE_DSP_PRSNT_CH_SR | AE_DSP_PRSNT_CH_BL | AE_DSP_PRSNT_CH_BR | AE_DSP_PRSNT_CH_LFE,
cs_7point1_panorama = AE_DSP_PRSNT_CH_FL | AE_DSP_PRSNT_CH_FLOC | AE_DSP_PRSNT_CH_FC | AE_DSP_PRSNT_CH_FROC | AE_DSP_PRSNT_CH_FR |
Expand Down Expand Up @@ -83,7 +85,7 @@ class CFreeSurroundDecoder
* than 5ms to 20ms since the granularity at which locations are decoded
* changes with this.
*/
CFreeSurroundDecoder(channel_setup setup=cs_5point1, unsigned blocksize=4096, unsigned int samplerate=48000);
CFreeSurroundDecoder(channel_setup setup=cs_5point1_Side, unsigned blocksize=4096, unsigned int samplerate=48000);
~CFreeSurroundDecoder();

float ** getOutputBuffers();
Expand Down

0 comments on commit 12a5b0c

Please sign in to comment.