private static int packet_get_samples_per_frame(byte[] data, int fs) {
        int audiosize;
        if ((data[0]&0x80) != 0) {
            audiosize = ((data[0]>>3)&0x3);
            audiosize = (fs<<audiosize)/400;
        } else if ((data[0]&0x60) == 0x60) {
            audiosize = ((data[0]&0x08) != 0) ? fs/50 : fs/100;
        } else {
            audiosize = ((data[0]>>3)&0x3);
            if (audiosize == 3)
                audiosize = fs*60/1000;
            else
                audiosize = (fs<<audiosize)/100;
        }
        return audiosize;
    }