getWithI32Buffer() public method

public getWithI32Buffer ( int bnum, bool get_then_del_in_buf = true ) : int
bnum int
get_then_del_in_buf bool
return int
        //used in decodeTable2 0:2 1:2
        static int MAPCDSF_decodeTable2_Route2(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint read_counter = chn_info.joint_chn_info.num_band_splited_used;
            if (mbr0.getWithI32Buffer(1) != 0)
            {
                read_counter = (uint)mbr0.getWithI32Buffer(5);
            }

            MaiAT3PlusCoreDecoderSearchTableDes huff_table_now0;
            MaiAT3PlusCoreDecoderSearchTableDes huff_table_now1;

            if (0 == chn_info.joint_chn_info.var90)
            {
                huff_table_now0 = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table2[0];
                huff_table_now1 = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table2[0];
            }
            else
            {
                huff_table_now0 = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table2[1];
                huff_table_now1 = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table2[2];
            }

            uint ptmp = 0;
            while (read_counter != 0)
            {
                if (chn_info.check_table0[0] == 1)
                {
                    chn_info.table2[0] = MAPCDSF_getHuffValue(huff_table_now0, mbr0);
                    ptmp = chn_info.table2[0];
                }
                else if (chn_info.check_table0[0] == 0) chn_info.table2[0] = 0;
                else if (chn_info.check_table0[0] == 2) chn_info.table2[0] = (uint)mbr0.getWithI32Buffer(1);
                else
                {
                    rs = -14;
                    break;
                }

                for (uint a0 = 1; a0 < read_counter; a0++)
                {
                    if (chn_info.check_table0[a0] == 1)
                    {
                        chn_info.table2[a0] = MAPCDSF_getHuffValue(huff_table_now1, mbr0);
                        chn_info.table2[a0] += ptmp;
                        chn_info.table2[a0] &= huff_table_now1.mask;
                        ptmp = chn_info.table2[a0];
                    }
                    else if (chn_info.check_table0[a0] == 0) chn_info.table2[a0] = 0;
                    else if (chn_info.check_table0[a0] == 2) chn_info.table2[a0] = (uint)mbr0.getWithI32Buffer(1);
                    else
                    {
                        rs = -15;
                        break;
                    }
                }

                break;
            }

            return rs;
        }
        static int MAPCDSF_decodeTable0DataNum(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            chn_info.table0_data_num0 =
                chn_info.joint_chn_info.num_band_splited_declared;

            chn_info.table0_data_num1 = 0;

            if (chn_info.table0_flag_data_num != 0)
            {
                chn_info.table0_data_num0 = (uint)mbr0.getWithI32Buffer(5);

                if (chn_info.table0_data_num0 > chn_info.joint_chn_info.num_band_splited_declared)
                {
                    return -5;
                }

                if (chn_info.table0_flag_data_num == 3)
                {
                    chn_info.table0_data_num1 = (uint)mbr0.getWithI32Buffer(2) + 1;
                    if (chn_info.chn_flag != 0) chn_info.table0_data_num1 = chn_info.table0_data_num1 - 1 + 3;
                }
            }

            return 0;
        }
        //used in decodeTable0 0:1
        static int MAPCDSF_decodeTable0_Route1(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            chn_info.table0_flag_ex = mbr0.getWithI32Buffer(2);
            chn_info.table0_flag_data_num = mbr0.getWithI32Buffer(2);

            if (0 != (rs = MAPCDSF_decodeTable0DataNum(mbr0, chn_info))) return rs;

            if (chn_info.table0_data_num0 != 0)
            {
                var uk1c6d0 = (uint)mbr0.getWithI32Buffer(5);
                var uk1c6d4 = (uint)mbr0.getWithI32Buffer(2);
                var uk1c6d8 = (uint)mbr0.getWithI32Buffer(3);

                for (uint a0 = 0; a0 < uk1c6d0; a0++)
                {
                    chn_info.table0[a0] = (uint)mbr0.getWithI32Buffer(3);
                }

                if (0 == uk1c6d4)
                {
                    for (uint a0 = uk1c6d0; a0 < chn_info.table0_data_num0; a0++)
                    {
                        chn_info.table0[a0] = uk1c6d8;
                    }
                }
                else
                {
                    for (uint a0 = uk1c6d0; a0 < chn_info.table0_data_num0; a0++)
                    {
                        chn_info.table0[a0] = (uint)mbr0.getWithI32Buffer((int)uk1c6d4) + uk1c6d8;
                    }
                }
            }

            if ((rs = MAPCDSF_padTable0(mbr0, chn_info)) != 0) return rs;

            if (chn_info.table0_flag_ex != 0)
            {
                MAPCDSF_exTable0Value(chn_info);
            }

            return rs;
        }
        //used in decodeACC2Main
        static int MAPCDSF_decodeACC2MainSub2(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            MAPCDSF_decodeACC2Main_func_list2[chn_info.chn_flag * 4 + mbr0.getWithI32Buffer(2)](mbr0, chn_info);

            //rep check

            for (int a0 = 0; a0 < 0x10; a0++)
            {
                for (int a1 = 0; a1 < 0x7; a1++)
                {
                    if ( (chn_info.acc_data_now.table[a0].data0[a1] < 0) || (chn_info.acc_data_now.table[a0].data0[a1] >= 0x20) )
                    {
                        rs = -1;
                        break;
                    }
                }

                if (rs != 0) break;

                for (int a1 = 0; a1 < (int)chn_info.acc_data_now.table[a0].num_acc - 1; a1++)
                {
                    if (chn_info.acc_data_now.table[a0].data0[a1]
                        >=
                        chn_info.acc_data_now.table[a0].data0[a1 + 1])
                    {
                        rs = -1;
                        break;
                    }
                }

                if (rs != 0) break;
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC6InnerSub0 0
        static int MAPCDSF_decodeACC6Inner1_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < (uint)chn_info.acc_table_now.inner.unk2; a0++)
            {
                if (chn_info.inner_pack_table0_check_table[a0] != 0)
                {
                    chn_info.acc_table_now.table[a0].num_uk = mbr0.getWithI32Buffer(4);
                }
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC2MainSub1 1:2
        static int MAPCDSF_decodeACC2Main1_Route5(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
            {
                if (chn_info.acc_data_now.table[a0].num_acc != 0)
                {
                    uint uk1b46c_x = (uint)mbr0.getWithI32Buffer(1);

                    if (uk1b46c_x != 0)
                    {
                        chn_info.acc_data_now.table[a0].data1[0] = MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_2[0], mbr0);

                        for (uint a1 = 1; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                        {
                            chn_info.acc_data_now.table[a0].data1[a1] =
                                chn_info.acc_data_now.table[a0].data1[a1 - 1]
                                + MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_3[0], mbr0);

                            chn_info.acc_data_now.table[a0].data1[a1] &= 0xF;
                        }
                    }
                    else
                    {
                        for (uint a1 = 0; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                        {
                            if (a1 < (uint)chn_info.chn_ref.acc_data_now.table[a0].num_acc)
                            {
                                chn_info.acc_data_now.table[a0].data1[a1] = chn_info.chn_ref.acc_data_now.table[a0].data1[a1];
                            }
                            else
                            {
                                chn_info.acc_data_now.table[a0].data1[a1] = 0x7;
                            }
                        }
                    }
                }
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC2MainSub2 1:2
        static int MAPCDSF_decodeACC2Main2_Route5(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
            {
                if (chn_info.acc_data_now.table[a0].num_acc != 0)
                {
                    if ( ( ((uint)chn_info.acc_data_now.table[a0].num_acc)
                        <= ((uint)chn_info.chn_ref.acc_data_now.table[a0].num_acc) )
                        && (0 == mbr0.getWithI32Buffer(1))
                        )
                    {
                        for (uint a1 = 0; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                        {
                            chn_info.acc_data_now.table[a0].data0[a1] =
                                chn_info.chn_ref.acc_data_now.table[a0].data0[a1];
                        }
                    }
                    else
                    {
                        MAPCDSF_parseACCDataMemberUsingHuffTable0(a0, mbr0, chn_info);
                    }
                }
            }

            return rs;
        }
        static int MAPCDSF_calcACCTableTableUnk3ByLastValue(MaiAT3PlusCoreDecoderChnACCTableTable table, MaiBitReader mbr0)
        {
            int rs = 0;

            for (int a0 = 0; a0 < (int)table.num_uk; a0++)
            {
                if (0 == a0)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0xA);
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x200)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0xA);
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x300)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x9) + 0x200;
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x380)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x8) + 0x300;
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x3C0)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x7) + 0x380;
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x3E0)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x6) + 0x3C0;
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x3F0)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x5) + 0x3E0;
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x3F8)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x4) + 0x3F0;
                }
                else if ( table.ptr0[a0 - 1].unk3 < 0x3FC)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x3) + 0x3F8;
                }
                else if (table.ptr0[a0 - 1].unk3 < 0x3FE)
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x2) + 0x3FC;
                }
                else
                {
                    table.ptr0[a0].unk3 = mbr0.getWithI32Buffer(0x1) + 0x3FE;
                }
            }

            return rs;
        }
        static int MAPCDSF_parseACCDataMemberUsingHuffTable0(uint a0, MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            if (chn_info.acc_data_now.table[a0].num_acc != 0)
            {
                chn_info.acc_data_now.table[a0].data0[0] =
                    mbr0.getWithI32Buffer(5);

                for (uint a1 = 1; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                {
                    MaiAT3PlusCoreDecoderSearchTableDes huff_table_now = null;

                    if ( ((int)chn_info.acc_data_now.table[a0].data1[a1])
                        - ((int)chn_info.acc_data_now.table[a0].data1[a1 - 1])
                        <= 0)
                    {
                        huff_table_now = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_6[0];
                    }
                    else
                    {
                        huff_table_now = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_7[0];
                    }

                    chn_info.acc_data_now.table[a0].data0[a1] = (int)(
                        chn_info.acc_data_now.table[a0].data0[a1 - 1]
                        + MAPCDSF_getHuffValue(huff_table_now, mbr0)
                    );
                }
            }

            return rs;
        }
        static int MAPCDSF_padTable0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            if (chn_info.table0_flag_data_num == 0)
            {
            }
            else if (chn_info.table0_flag_data_num == 1)
            {
                for (uint a0 = chn_info.table0_data_num0; a0 < chn_info.joint_chn_info.num_band_splited_declared; a0++)
                    chn_info.table0[a0] = 0;
            }
            else if (chn_info.table0_flag_data_num == 2)
            {
                if (0 == chn_info.chn_flag)
                {
                    for (uint a0 = chn_info.table0_data_num0; a0 < chn_info.joint_chn_info.num_band_splited_declared; a0++)
                        chn_info.table0[a0] = 1;
                }
                else
                {
                    for (uint a0 = chn_info.table0_data_num0; a0 < chn_info.joint_chn_info.num_band_splited_declared; a0++)
                        chn_info.table0[a0] = (uint)mbr0.getWithI32Buffer(1);
                }
            }
            else if (chn_info.table0_flag_data_num == 3)
            {
                if (0 == chn_info.chn_flag)
                {
                    for (uint a0 = chn_info.table0_data_num0; a0 < chn_info.joint_chn_info.num_band_splited_declared - chn_info.table0_data_num1; a0++)
                        chn_info.table0[a0] = 1;
                }
                else
                {
                    for (uint a0 = chn_info.table0_data_num0; a0 < chn_info.table0_data_num0 + chn_info.table0_data_num1; a0++)
                        chn_info.table0[a0] = 1;
                }
            }

            return 0;
        }
        static int MAPCDSF_parseACCDataMemberUsingBitRead(uint a0, uint a1, MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            if (a1 == 0)
            {
                chn_info.acc_data_now.table[a0].data0[0] = mbr0.getWithI32Buffer(5);
            }
            else
            {
                if ( ((uint)chn_info.acc_data_now.table[a0].data0[a1 - 1]) < 0xF)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] = mbr0.getWithI32Buffer(5);
                }
                else if ( ((uint)chn_info.acc_data_now.table[a0].data0[a1 - 1]) < 0x17)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] =
                        (chn_info.acc_data_now.table[a0].data0[a1 - 1])
                        + mbr0.getWithI32Buffer(4)
                        + 1;
                }
                else if ( ((uint)chn_info.acc_data_now.table[a0].data0[a1 - 1]) < 0x1B)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] =
                        (chn_info.acc_data_now.table[a0].data0[a1 - 1])
                        + mbr0.getWithI32Buffer(3)
                        + 1;
                }
                else if ( ((uint)chn_info.acc_data_now.table[a0].data0[a1 - 1]) < 0x1D)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] =
                        (chn_info.acc_data_now.table[a0].data0[a1 - 1])
                        + mbr0.getWithI32Buffer(2)
                        + 1;
                }
                else if ( ((uint)chn_info.acc_data_now.table[a0].data0[a1 - 1]) == 0x1D)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] =
                        (chn_info.acc_data_now.table[a0].data0[a1 - 1])
                        + mbr0.getWithI32Buffer(1)
                        + 1;
                }
                else if ( ((uint)chn_info.acc_data_now.table[a0].data0[a1 - 1]) == 0x1E)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] = 0x1F;
                }

            }

            return rs;
        }
 //ushort *table0, byte *table1, uint max_len,  MaiBitReader mbr0)
 static uint MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoderSearchTableDes huff_table, MaiBitReader mbr0)
 {
     uint value = (uint)mbr0.getWithI32Buffer((int)huff_table.max_bit_len, false);
     value = huff_table.table1[value];
     mbr0.getWithI32Buffer(huff_table.table0[value * 2 + 1]);
     return value;
 }
        //used in decodeTable3
        static int MAPCDSF_decodeTable3Sub0(MaiBitReader mbr0, ManagedPointer<short> buf_to_read, uint num_to_read, MaiAT3PlusCoreDecoderSearchTableDes huff_table_now)
        {
            int rs = 0;

            if (huff_table_now.uk3 == 1)
            {
                uint tcounter0 = 0;
                for (uint b0 = 0; b0 < (num_to_read >> (huff_table_now.uk4)); b0++)
                {
                    uint group_value = MAPCDSF_getHuffValue(huff_table_now, mbr0);

                    for (uint b1 = 0; b1 < huff_table_now.uk2; b1++)
                    {
                        uint value_now = (uint)(group_value >> (int)((huff_table_now.uk2 - b1 - 1) * huff_table_now.uk6));
                        value_now &= huff_table_now.mask;

                        if (0 == huff_table_now.uk5)
                        {
                            if ((value_now & ( 1 << (huff_table_now.uk6 - 1) )) != 0 )
                                buf_to_read[tcounter0++] = (short)(value_now | ( ~( ( 1 << (huff_table_now.uk6) ) - 1 ) ));
                            else
                                buf_to_read[tcounter0++] = (short)(value_now);
                        }
                        else
                        {
                            if ( ((value_now != 0) && (mbr0.getWithI32Buffer(1) != 0)) )
                                buf_to_read[tcounter0++] = (short)(((short)(value_now)) * (-1));
                            else
                                buf_to_read[tcounter0++] = (short)(value_now);
                        }
                    }
                }
            }
            else if (huff_table_now.uk3 > 1)
            {
                uint tcounter0 = 0;
                for (uint b0 = 0; b0 < (num_to_read >> (huff_table_now.uk4)); b0 += huff_table_now.uk3)
                {
                    uint l320 = (uint)mbr0.getWithI32Buffer(1);
                    if (0 == l320)
                    {
                        for (uint b1 = 0; b1 < huff_table_now.uk3 * huff_table_now.uk2; b1++)
                        {
                            buf_to_read[tcounter0++] = 0;
                        }
                    }
                    else for (uint b2 = 0; b2 < huff_table_now.uk3; b2++)
                    {
                        uint group_value = MAPCDSF_getHuffValue(huff_table_now, mbr0);

                        for (uint b1 = 0; b1 < huff_table_now.uk2; b1++)
                        {
                            uint value_now = (uint)(group_value >> (int)((huff_table_now.uk2 - b1 - 1) * huff_table_now.uk6));
                            value_now &= huff_table_now.mask;

                            if (0 == huff_table_now.uk5)
                            {
                                if ((value_now & ( 1 << (huff_table_now.uk6 - 1) )) != 0 )
                                    buf_to_read[tcounter0++] = (short)(value_now | ( ~( ( 1 << (huff_table_now.uk6) ) - 1 ) ));
                                else
                                    buf_to_read[tcounter0++] = (short)(value_now);
                            }
                            else
                            {
                                if ( ((value_now!= 0) && (mbr0.getWithI32Buffer(1)!= 0))  )
                                    buf_to_read[tcounter0++] = (short)(((short)(value_now)) * (-1));
                                else
                                    buf_to_read[tcounter0++] = (short)(value_now);
                            }
                        }
                    }
                }
            }
            else
            {
                rs = -20;
            }

            return rs;
        }
        //used in decodeTable2 1:3
        static int MAPCDSF_decodeTable2_Route4(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint read_counter = chn_info.joint_chn_info.num_band_splited_used;
            if (mbr0.getWithI32Buffer(1) != 0)
            {
                read_counter = (uint)mbr0.getWithI32Buffer(5);
            }

            for (uint a0 = 0; a0 < read_counter; a0++)
            {
                if (chn_info.check_table0[a0] == 1)
                {
                    chn_info.table2[a0] = MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table2_2[chn_info.joint_chn_info.var90], mbr0); //tmp4
                    chn_info.table2[a0] += chn_info.chn_ref.table2[a0];
                    chn_info.table2[a0] &= MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table2_2[chn_info.joint_chn_info.var90].mask;
                }
                else if (chn_info.check_table0[a0] == 0) chn_info.table2[a0] = 0;
                else if (chn_info.check_table0[a0] == 2) chn_info.table2[a0] = (uint)mbr0.getWithI32Buffer(1);
                else
                {
                    rs = -17;
                    break;
                }
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC2MainSub1 0:0 1:0
        static int MAPCDSF_decodeACC2Main1_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
            {
                for (uint a1 = 0; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                {
                    chn_info.acc_data_now.table[a0].data1[a1] =
                        (uint)mbr0.getWithI32Buffer(4);
                }
            }

            return rs;
        }
        static int MAPCDSF_parseACCDataMemberUsingHuffTable2(uint a0, MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            if (chn_info.acc_data_now.table[a0].num_acc != 0)
            {
                if (chn_info.chn_ref.acc_data_now.table[a0].num_acc != 0)
                {
                    chn_info.acc_data_now.table[a0].data0[0] = (int)(
                        chn_info.chn_ref.acc_data_now.table[a0].data0[0]
                        + MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_10[0], mbr0)
                    );

                    chn_info.acc_data_now.table[a0].data0[0] &= 0x1F;
                }
                else
                {
                    chn_info.acc_data_now.table[a0].data0[0] = (int)(
                        MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_10[0], mbr0)
                    );
                }

                for (uint a1 = 1; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                {
                    uint check_value0 = 0;
                    if (a1 >= (uint)chn_info.chn_ref.acc_data_now.table[a0].num_acc)
                        check_value0 = 1;

                    if ( ((int)chn_info.acc_data_now.table[a0].data1[a1])
                        - ((int)chn_info.acc_data_now.table[a0].data1[a1 - 1])
                        <= 0)
                    {
                        MaiAT3PlusCoreDecoderSearchTableDes huff_table_now = null;

                        if (check_value0 != 0)
                        {
                            huff_table_now = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_6[0];
                        }
                        else
                        {
                            huff_table_now = MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_10[0];
                        }

                        if (0 == check_value0)
                        {
                            chn_info.acc_data_now.table[a0].data0[a1] = (int)(
                                chn_info.chn_ref.acc_data_now.table[a0].data0[a1]
                                + MAPCDSF_getHuffValue(huff_table_now, mbr0)
                            );

                            chn_info.acc_data_now.table[a0].data0[a1] &= 0x1F;
                        }
                        else
                        {
                            chn_info.acc_data_now.table[a0].data0[a1] = (int)(
                                chn_info.acc_data_now.table[a0].data0[a1 - 1]
                                + MAPCDSF_getHuffValue(huff_table_now, mbr0)
                            );
                        }
                    }
                    else
                    {
                        if (0 == check_value0)
                        {
                            if (mbr0.getWithI32Buffer(1) != 0)
                            {
                                MAPCDSF_parseACCDataMemberUsingBitRead(a0, a1, mbr0, chn_info);
                            }
                            else
                            {
                                chn_info.acc_data_now.table[a0].data0[a1] =
                                    chn_info.chn_ref.acc_data_now.table[a0].data0[a1];
                            }
                        }
                        else
                        {
                            chn_info.acc_data_now.table[a0].data0[a1] = (int)(
                                chn_info.acc_data_now.table[a0].data0[a1 - 1]
                                + MAPCDSF_getHuffValue(MaiAT3PlusCoreDecoder_StaticData.MAPCDSD_huff_table_global_7[0], mbr0)
                            );
                        }
                    }
                }
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC2MainSub1 0:3
        static int MAPCDSF_decodeACC2Main1_Route3(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint uk1b464 = (uint)mbr0.getWithI32Buffer(2);
            uint uk1b468 = (uint)mbr0.getWithI32Buffer(4);

            if (uk1b464 != 0)
            {
                for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
                {
                    for (uint a1 = 0; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                    {
                        chn_info.acc_data_now.table[a0].data1[a1] = (uint)(uk1b468 + mbr0.getWithI32Buffer((int)uk1b464));
                    }
                }
            }
            else
            {
                for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
                {
                    for (uint a1 = 0; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                    {
                        chn_info.acc_data_now.table[a0].data1[a1] = uk1b468;
                    }
                }
            }

            return rs;
        }
        static int MAPCDSF_readPackTable0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderPackTable0 table, uint counter)
        {
            for (uint a0 = 0; a0 < 0x10; a0++) table.data[a0] = 0;

            table.check_data0 = mbr0.getWithI32Buffer(1);

            if (table.check_data0 != 0)
            {
                table.check_data1 = mbr0.getWithI32Buffer(1);
                if (table.check_data1 != 0)
                {
                    for (uint a0 = 0; a0 < counter; a0++) {
                        table.data[a0] = mbr0.getWithI32Buffer(1);
                    }
                }
                else
                {
                    for (uint a0 = 0; a0 < counter; a0++) {
                        table.data[a0] = 1;
                    }
                }
            }

            return 0;
        }
        //used in MAPCDSF_decodeACC2MainSub2 0:3
        static int MAPCDSF_decodeACC2Main2_Route3(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint uk1b4b0 = (uint)mbr0.getWithI32Buffer(2) + 1;
            uint uk1b4b4 = (uint)mbr0.getWithI32Buffer(5);

            for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
            {
                for (uint a1 = 0; a1 < (uint)chn_info.acc_data_now.table[a0].num_acc; a1++)
                {
                    chn_info.acc_data_now.table[a0].data0[a1] = (int)(
                        mbr0.getWithI32Buffer((int)uk1b4b0)
                        + uk1b4b4
                        + a1
                    );
                }
            }

            return rs;
        }
        static int MAPCDSF_splitePack(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            int atmp0 = 0;
            for (uint a0 = 0; a0 < (uint)chn_info.acc_table_now.inner.unk2; a0++)
            {
                chn_info.acc_table_now.table[a0].ptr0 = (atmp0) + chn_info.acc_table_now.inner.ptr_to_use_now;
                atmp0 += chn_info.acc_table_now.table[a0].num_uk;
            }

            chn_info.acc_table_now.inner.ptr_to_use_now += atmp0;

            uint tmp0 = 0;
            if (chn_info.chn_flag == 1)
            {
                tmp0 = (uint)mbr0.getWithI32Buffer(1);
            }

            MAPCDSF_splitePack_func_list0[tmp0](mbr0, chn_info);

            if (chn_info.chn_flag == 1)
            {
                MAPCDSF_makeTable11C(mbr0, chn_info);
            }

            uint tmp1 = (uint)mbr0.getWithI32Buffer(chn_info.chn_flag + 1);

            MAPCDSF_splitePack_func_list1[tmp1](mbr0, chn_info);

            if (chn_info.acc_table_now.inner.unk1 == 0)
            {
                uint tmp2 = (uint)mbr0.getWithI32Buffer(chn_info.chn_flag + 1);
                MAPCDSF_splitePack_func_list2[tmp2](mbr0, chn_info);
            }

            MAPCDSF_readSplitePackMemberNum(mbr0, chn_info);

            return rs;
        }
        //used in decodeACC2Main
        static int MAPCDSF_decodeACC2MainSub0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            MAPCDSF_decodeACC2Main_func_list0[chn_info.chn_flag * 4 + mbr0.getWithI32Buffer(2)]
                (mbr0, chn_info);

            for (uint a0 = 0; a0 < 0x10; a0++)
            {
                if (chn_info.acc_data_now.table[a0].num_acc > 0x7)
                {
                    rs = -21;
                    break;
                }
            }

            return rs;
        }
        //used in MAPCDSF_splitePack 0
        static int MAPCDSF_splitePack0_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint uk1c730;
            for (uint a0 = 0; a0 < (uint)chn_info.acc_table_now.inner.unk2; a0++)
            {
                if (chn_info.inner_pack_table0_check_table[a0] != 0)
                {
                    if ( ((uint)chn_info.acc_table_now.table[a0].num_uk) <= 1)
                    {
                        uk1c730 = 0;
                        MAPCDSF_calcACCTableTableUnk3ByLastValue(chn_info.acc_table_now.table[a0], mbr0);
                    }
                    else
                    {
                        uk1c730 = (uint)mbr0.getWithI32Buffer(1);
                        if (0 == uk1c730)
                        {
                            MAPCDSF_calcACCTableTableUnk3ByLastValue(chn_info.acc_table_now.table[a0], mbr0);
                        }
                        else
                        {
                            MAPCDSF_calcACCTableTableUnk3ByAfterValue(chn_info.acc_table_now.table[a0], mbr0);
                        }
                    }
                }
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC6InnerSub0 0
        static int MAPCDSF_decodeACC6Inner0_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < (uint)chn_info.acc_table_now.inner.unk2; a0++)
            {
                if (chn_info.inner_pack_table0_check_table[a0] != 0)
                {
                    chn_info.acc_table_now.table[a0].unk[4] =  mbr0.getWithI32Buffer(1);
                    if (chn_info.acc_table_now.table[a0].unk[4] != 0)
                    {
                        chn_info.acc_table_now.table[a0].unk[6] =  mbr0.getWithI32Buffer(5);
                    }
                    else
                    {
                        chn_info.acc_table_now.table[a0].unk[6] = -1;
                    }

                    chn_info.acc_table_now.table[a0].unk[5] = mbr0.getWithI32Buffer(1);

                    if (chn_info.acc_table_now.table[a0].unk[5] != 0)
                    {
                        chn_info.acc_table_now.table[a0].unk[7] = mbr0.getWithI32Buffer(5);
                    }
                    else
                    {
                        chn_info.acc_table_now.table[a0].unk[7] = 0x20;
                    }
                }
            }

            return rs;
        }
        //used in MAPCDSF_decodeACC2MainSub0 0:0 1:0
        static int MAPCDSF_decodeACC2Main0_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
            {
                chn_info.acc_data_now.table[a0].num_acc = mbr0.getWithI32Buffer(3);
            }

            return rs;
        }
        //used in decodeACC6Inner
        static int MAPCDSF_decodeACC6InnerSub0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            MAPCDSF_makeInnerPackTable0CheckTable(chn_info, 1);

            uint route_flag0 = 0;

            if (chn_info.chn_flag == 1) route_flag0 = (uint)mbr0.getWithI32Buffer(1);

            MAPCDSF_decodeACC6InnerSub0_func_list0[route_flag0](mbr0, chn_info);

            {
                uint route_flag1 = (uint)mbr0.getWithI32Buffer(chn_info.chn_flag + 1);
                MAPCDSF_decodeACC6InnerSub0_func_list1[route_flag1](mbr0, chn_info);
            }

            MAPCDSF_splitePack(mbr0, chn_info);

            return rs;
        }
        static int MAPCDSF_splitePack2_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            for (uint a0 = 0; a0 < (uint)chn_info.acc_table_now.inner.unk2; a0++)
            {
                if (chn_info.inner_pack_table0_check_table[a0] != 0)
                {
                    for (int a1 = 0; a1 < chn_info.acc_table_now.table[a0].num_uk; a1++)
                    {
                        chn_info.acc_table_now.table[a0].ptr0[a1].unk1 = mbr0.getWithI32Buffer(4);
                    }
                }
            }

            return rs;
        }
        //used in decodeTable0 0:0 1:0
        static int MAPCDSF_decodeTable0_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            for (uint a0 = 0; a0 < chn_info.joint_chn_info.num_band_splited_declared; a0++)
            {
                chn_info.table0[a0] = (uint)mbr0.getWithI32Buffer(3);
            }

            return 0;
        }
        //used in MAPCDSF_decodeACC2MainSub0 0:3
        static int MAPCDSF_decodeACC2Main0_Route3(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint uk1b458 = (uint)mbr0.getWithI32Buffer(2);
            uint uk1b45c = (uint)mbr0.getWithI32Buffer(3);

            if (uk1b458 != 0)
            {
                for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
                {
                    chn_info.acc_data_now.table[a0].num_acc = (int)(uk1b45c + mbr0.getWithI32Buffer((int)uk1b458));
                }
            }
            else
            {
                for (uint a0 = 0; a0 < chn_info.uk1b450; a0++)
                {
                    chn_info.acc_data_now.table[a0].num_acc = (int)uk1b45c;
                }
            }

            return rs;
        }
Example #29
0
        public int decodeFrame(byte* p_frame_data, int data_len, out int p_chns, out short[] pp_sample_buf)
        {
            int rs = 0;

            var mbr0 = new MaiBitReader(data_len + 0x10);
            mbr0.addData(p_frame_data, data_len);
            var Pad = stackalloc byte[0x10];
            mbr0.addData(Pad, 0x10);

            if (mbr0.getWithI32Buffer(1) != 0)
            {
                rs = -1;
            }

            int counter_substream = 0;
            int counter_chn = 0;
            while (rs == 0)
            {
                int substream_type = mbr0.getWithI32Buffer(2);
                uint joint_flag = 0;
                uint chns = 0;

                if (substream_type == 0)
                {
                    joint_flag = 0;
                    chns = 1;
                }
                else if (substream_type == 1)
                {
                    joint_flag = 1;
                    chns = 2;
                }
                else if (substream_type == 3)
                {
                    break;
                }
                else
                {
                    rs = -1;
                }

                if (cores[counter_substream] == null)
                    cores[counter_substream] = new MaiAT3PlusCoreDecoder();

                if (0 != (rs = cores[counter_substream].parseStream(mbr0, chns, joint_flag)))
                    break;

                if (0 != (rs = cores[counter_substream].decodeStream(chns)))
                    break;

                for (int a0 = 0; a0 < chns; a0++)
                    cores[counter_substream].getAudioSamplesI16((uint)a0, new ManagedPointer<short>(sample_buf_tmp, 0x800 * (counter_chn++)));

                counter_substream++;
            }

            for (int a0 = 0; a0 < 0x800; a0++)
            {
                for (int a1 = 0; a1 < counter_chn; a1++)
                {
                    sample_buf[a0 * counter_chn + a1] = sample_buf_tmp[a1 * 0x800 + a0];
                }
            }
            mbr0.Dispose();

            p_chns = counter_chn;
            pp_sample_buf = sample_buf;

            return rs;
        }
        //used in decodeTable2 0:0 1:0
        static int MAPCDSF_decodeTable2_Route0(MaiBitReader mbr0, MaiAT3PlusCoreDecoderChnInfo chn_info)
        {
            int rs = 0;

            uint read_counter = chn_info.joint_chn_info.num_band_splited_used;
            if (mbr0.getWithI32Buffer(1) != 0)
            {
                read_counter = (uint)mbr0.getWithI32Buffer(5);
            }

            for (uint a0 = 0; a0 < read_counter; a0++)
            {
                if (chn_info.check_table0[a0] == 1) chn_info.table2[a0] = (uint)mbr0.getWithI32Buffer( ( (chn_info.joint_chn_info.var90 != 0) ? 3 : 2 ) ); //tmp4
                else if (chn_info.check_table0[a0] == 0) chn_info.table2[a0] = 0;
                else if (chn_info.check_table0[a0] == 2) chn_info.table2[a0] = (uint)mbr0.getWithI32Buffer(1);
                else
                {
                    rs = -12;
                    break;
                }
            }

            return rs;
        }