コード例 #1
0
ファイル: adts.py プロジェクト: jason860306/pymp4
    def encode(self, bit_strm=None, offset=0):
        if bit_strm is None:
            bit_strm = BitStream()

        if not isinstance(bit_strm, BitStream):
            return None

        bit_strm.append(BitArray(uint=self.syncword, length=12))
        bit_strm.append(BitArray(int=self.ID, length=1))
        bit_strm.append(BitArray(int=self.layer, length=2))
        bit_strm.append(BitArray(int=self.protection_absent, length=1))
        bit_strm.append(BitArray(int=self.profile, length=2))
        bit_strm.append(BitArray(int=self.sampling_index, length=4))
        bit_strm.append(BitArray(int=self.private_bit, length=1))
        bit_strm.append(BitArray(int=self.chan_config, length=3))
        bit_strm.append(BitArray(int=self.original_copy, length=1))
        bit_strm.append(BitArray(int=self.home, length=1))
        bit_strm.append(BitArray(int=self.copyright_id_bit, length=1))
        bit_strm.append(BitArray(int=self.copyright_id_start, length=1))
        bit_strm.append(BitArray(uint=self.aac_frame_length, length=13))
        bit_strm.append(BitArray(uint=self.adts_buffer_fullness, length=11))
        bit_strm.append(BitArray(int=self.number_of_raw_data_blocks_in_frame, length=2))
        bit_strm.byteswap()

        return bit_strm