@@ -188,11 +188,37 @@ typedef struct ALSChannelData {
188188} ALSChannelData ;
189189
190190
191+ typedef struct DiffFloatData {
192+ int use_acf ;
193+ int acf_flag [1000 ];
194+ int acf_mantissa [1000 ];
195+ int highest_byte [1000 ];
196+ int partA_flag [1000 ];
197+ int shift_amp [1000 ];
198+ int shift_value [1000 ];
199+ int last_acf_mantissa [1000 ];
200+ int last_shift_value [1000 ];
201+ } DiffFloatData ;
202+
203+ typedef struct DiffMantissa {
204+ int int_zero [1000 ][1000 ];
205+ int mantissa [1000 ][1000 ];
206+ int compressed_flag [1000 ];
207+ int nchars ;
208+ int float_data [1000 ][1000 ];
209+ int nbits [1000 ][1000 ];
210+ int d [1000 ][1000 ];
211+ int f [1000 ][1000 ];
212+ } DiffMantissa ;
213+
214+
191215typedef struct ALSDecContext {
192216 AVCodecContext * avctx ;
193217 ALSSpecificConfig sconf ;
194218 GetBitContext gb ;
195219 BswapDSPContext bdsp ;
220+ DiffFloatData df ;
221+ DiffMantissa dm ;
196222 const AVCRC * crc_table ;
197223 uint32_t crc_org ; ///< CRC value of the original input data
198224 uint32_t crc ; ///< CRC value calculated from decoded data
@@ -1318,6 +1344,223 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
13181344}
13191345
13201346
1347+ int static int_float_con (ALSDecContext * ctx ,int c )
1348+ {
1349+ ALSSpecificConfig * sconf = & ctx -> sconf ;
1350+ DiffFloatData * df = & ctx -> df ;
1351+ DiffMantissa * dm = & ctx -> dm ;
1352+ unsigned int n ;
1353+ long long multi ;
1354+ if (df -> acf_mantissa [c ] == 0 ) {
1355+ for (n = 0 ; n < sconf -> frame_length ; n ++ ){
1356+ if (dm -> int_zero [c ][n ]) {
1357+ dm -> f [c ][n ] = dm -> float_data [c ][n ];
1358+ }
1359+ else {
1360+ if (df -> shift_amp [c ]) {
1361+ dm -> f [c ][n ]= (float )((1 << df -> shift_value [c ])/(1 << 23 ));
1362+ dm -> f [c ][n ]= (0x0800000 | dm -> f [c ][n ]) + dm -> d [c ][n ];
1363+ }
1364+ }
1365+ }
1366+ }
1367+
1368+ else {
1369+ for (n = 0 ; n < sconf -> frame_length ; n ++ ){
1370+ if (dm -> int_zero [c ][n ]) {
1371+ dm -> f [c ][n ] = dm -> float_data [c ][n ];
1372+ }
1373+ else {
1374+ if (df -> shift_amp [c ]) {
1375+ dm -> f [c ][n ]= (float )((1 << df -> shift_value [c ])/(1 << 23 ));
1376+ multi = ( df -> acf_mantissa [c ] | 0x0800000 )* ( dm -> f [c ][n ] | 0x0800000 );
1377+ dm -> f [c ][n ]= multi >> 41 ;
1378+ dm -> f [c ][n ]= dm -> f [c ][n ] + 0xb000000 ;
1379+ dm -> f [c ][n ]= (0x0800000 | dm -> f [c ][n ]) + dm -> d [c ][n ];
1380+ }
1381+ }
1382+ }
1383+
1384+ }
1385+ return 0 ;
1386+ }
1387+
1388+
1389+ static int read_diff_mantissa (ALSDecContext * ctx ,int c )
1390+ {
1391+ ALSSpecificConfig * sconf = & ctx -> sconf ;
1392+ DiffFloatData * df = & ctx -> df ;
1393+ DiffMantissa * dm = & ctx -> dm ;
1394+ unsigned int n ;
1395+ unsigned int nchars ;
1396+ unsigned int wordlen ;
1397+ if (df -> acf_mantissa [c ]== 0 ) {
1398+ if (df -> partA_flag [c ] != 0 ) {
1399+ if (dm -> compressed_flag [c ] == 0 ) {
1400+ for (n = 0 ; n < sconf -> frame_length ; n ++ ) {
1401+ if (dm -> int_zero [c ][n ]) {
1402+ dm -> f [c ][n ] = dm -> float_data [c ][n ];
1403+ }
1404+ }
1405+ }
1406+ else {
1407+ nchars = 0 ;
1408+ for (n = 0 ; n < sconf -> frame_length ; n ++ ){
1409+ if (dm -> int_zero [c ][n ]){
1410+ nchars += 4 ;
1411+ wordlen = 23 - n ;
1412+ if (wordlen > df -> highest_byte [c ]* 8 ) {
1413+ dm -> nbits [c ][n ]= df -> highest_byte [c ]* 8 ;
1414+ }
1415+ else {
1416+ dm -> nbits [c ][n ]= wordlen ;
1417+ }
1418+ }
1419+
1420+ }
1421+
1422+ // TODO: decompression if compressed_flag=1;
1423+
1424+ }
1425+
1426+ }
1427+ if (df -> highest_byte [c ] != 0 ){
1428+ if (dm -> compressed_flag [c ] == 0 ) {
1429+ for (n = 0 ; n < sconf -> frame_length ; n ++ ) {
1430+ if (dm -> int_zero [c ][n ]== 0 ) {
1431+ dm -> d [c ][n ] = dm -> mantissa [c ][n ];
1432+ int_float_con (ctx ,c );
1433+ }
1434+
1435+ }
1436+ }
1437+ else {
1438+ nchars = 0 ;
1439+ for (n = 0 ; n < sconf -> frame_length ; n ++ ) {
1440+ if (dm -> int_zero [c ][n ]== 0 ) {
1441+ nchars += (int )dm -> nbits [c ][n ]/8 ;
1442+ if ((dm -> nbits [c ][n ] % 8 )> 0 )
1443+ nchars ++ ;
1444+ wordlen = 23 - n ;
1445+ if (wordlen > df -> highest_byte [c ]* 8 ) {
1446+ dm -> nbits [c ][n ]= df -> highest_byte [c ]* 8 ;
1447+ }
1448+ else {
1449+ dm -> nbits [c ][n ]= wordlen ;
1450+ }
1451+ }
1452+ }
1453+ // TODO: decompression if compressed_flag=1;
1454+ }
1455+
1456+ }
1457+ }
1458+ else {
1459+ if (df -> partA_flag [c ] != 0 ) {
1460+ if (dm -> compressed_flag [c ] == 0 ) {
1461+ for (n = 0 ; n < sconf -> frame_length ; n ++ ) {
1462+ if (dm -> int_zero [c ][n ]) {
1463+ dm -> f [c ][n ] = dm -> float_data [c ][n ];
1464+ }
1465+ }
1466+ }
1467+ else {
1468+ nchars = 0 ;
1469+ for (n = 0 ; n < sconf -> frame_length ; n ++ ){
1470+ if (dm -> int_zero [c ][n ]){
1471+ nchars += 4 ;
1472+ wordlen = 23 ;
1473+ if (wordlen > df -> highest_byte [c ]* 8 ) {
1474+ dm -> nbits [c ][n ]= df -> highest_byte [c ]* 8 ;
1475+ }
1476+ else {
1477+ dm -> nbits [c ][n ]= wordlen ;
1478+ }
1479+ }
1480+ }
1481+ // TODO: decompression if compressed_flag=1;
1482+ }
1483+ }
1484+ if (df -> highest_byte [c ] != 0 ){
1485+ if (dm -> compressed_flag [c ] == 0 ) {
1486+ for (n = 0 ; n < sconf -> frame_length ; n ++ ) {
1487+ if (dm -> int_zero [c ][n ]== 0 ) {
1488+ dm -> d [c ][n ] = dm -> mantissa [c ][n ];
1489+ int_float_con (ctx ,c );
1490+ }
1491+
1492+ }
1493+ }
1494+ else {
1495+ nchars = 0 ;
1496+ for (n = 0 ; n < sconf -> frame_length ; n ++ ) {
1497+ if (dm -> int_zero [c ][n ]== 0 ) {
1498+ nchars += (int )dm -> nbits [c ][n ]/8 ;
1499+ if ((dm -> nbits [c ][n ] % 8 )> 0 )
1500+ nchars ++ ;
1501+ wordlen = 23 ;
1502+ if (wordlen > df -> highest_byte [c ]* 8 ) {
1503+ dm -> nbits [c ][n ]= df -> highest_byte [c ]* 8 ;
1504+ }
1505+ else {
1506+ dm -> nbits [c ][n ]= wordlen ;
1507+ }
1508+ }
1509+ }
1510+ // TODO: decompression if compressed_flag=1;
1511+ }
1512+
1513+ }
1514+
1515+
1516+
1517+ }
1518+ return 0 ;
1519+
1520+ }
1521+
1522+
1523+ static int read_diff_float_data (ALSDecContext * ctx )
1524+ {
1525+ ALSSpecificConfig * sconf = & ctx -> sconf ;
1526+ AVCodecContext * avctx = ctx -> avctx ;
1527+ DiffFloatData * df = & ctx -> df ;
1528+ unsigned int c ;
1529+ if (sconf -> ra_distance ) {
1530+ for (c = 0 ; c < avctx -> channels ; c ++ ) {
1531+ df -> last_acf_mantissa [c ]= 0 ;
1532+ df -> last_shift_value [c ]= 0 ;
1533+ }
1534+ }
1535+ for (c = 0 ; c < avctx -> channels ; c ++ ) {
1536+ if (df -> use_acf ) {
1537+ if (df -> acf_flag [c ]) {
1538+ df -> last_acf_mantissa [c ] = df -> acf_mantissa [c ];
1539+ }
1540+
1541+ else {
1542+ df -> acf_mantissa [c ] = df -> last_acf_mantissa [c ];
1543+ }
1544+ }
1545+ else {
1546+ df -> acf_mantissa [c ] = 0 ;
1547+ df -> last_acf_mantissa [c ] = 0 ;
1548+ }
1549+ if (df -> shift_amp ) {
1550+ df -> last_shift_value [c ] = df -> shift_value [c ];
1551+ }
1552+ else {
1553+ df -> shift_value [c ] = df -> last_shift_value [c ];
1554+ }
1555+ read_diff_mantissa (ctx ,c );
1556+ df -> last_acf_mantissa [c ] = df -> acf_mantissa [c ];
1557+ df -> last_shift_value [c ] = df -> shift_value [c ];
1558+ }
1559+ return 0 ;
1560+
1561+ }
1562+
1563+
13211564/** Read the frame data.
13221565 */
13231566static int read_frame_data (ALSDecContext * ctx , unsigned int ra_frame )
@@ -1460,7 +1703,9 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
14601703 }
14611704
14621705 // TODO: read_diff_float_data
1463-
1706+ if (sconf -> floating ) {
1707+ read_diff_float_data (ctx );
1708+ }
14641709 return 0 ;
14651710}
14661711
0 commit comments