def get_codestream(self, header_only=True):
with open(self.filename, '<STR_LIT:rb>') as fptr:<EOL><INDENT>if self._codec_format == opj2.CODEC_J2K:<EOL><INDENT>codestream = Codestream(fptr, self.length,<EOL>header_only=header_only)<EOL><DEDENT>else:<EOL><INDENT>box = [x for x in self.box if x.box_id == '<STR_LIT>']<EOL>fptr.seek(box[<NUM_LIT:0>].offset)<EOL>read_buffer = fptr.read(<NUM_LIT:8>)<EOL>(box_length, _) = struct.unpack('<STR_LIT>', read_buffer)<EOL>if box_length == <NUM_LIT:0>:<EOL><INDENT>box_length = os.path.getsize(fptr.name) - fptr.tell() + <NUM_LIT:8><EOL><DEDENT>elif box_length == <NUM_LIT:1>:<EOL><INDENT>read_buffer = fptr.read(<NUM_LIT:8>)<EOL>box_length, = struct.unpack('<STR_LIT>', read_buffer)<EOL><DEDENT>codestream = Codestream(fptr, box_length - <NUM_LIT:8>,<EOL>header_only=header_only)<EOL><DEDENT>return codestream<EOL><DEDENT>
Retrieve codestream.

        Parameters
        ----------
        header_only : bool, optional
            If True, only marker segments in the main header are parsed.
            Supplying False may impose a large performance penalty.

        Returns
        -------
        Codestream
            Object describing the codestream syntax.

        Examples
        --------
        >>> import glymur
        >>> jfile = glymur.data.nemo()
        >>> jp2 = glymur.Jp2k(jfile)
        >>> codestream = jp2.get_codestream()
        >>> print(codestream.segment[1])
        SIZ marker segment @ (3233, 47)
            Profile:  no profile
            Reference Grid Height, Width:  (1456 x 2592)
            Vertical, Horizontal Reference Grid Offset:  (0 x 0)
            Reference Tile Height, Width:  (1456 x 2592)
            Vertical, Horizontal Reference Tile Offset:  (0 x 0)
            Bitdepth:  (8, 8, 8)
            Signed:  (False, False, False)
            Vertical, Horizontal Subsampling:  ((1, 1), (1, 1), (1, 1))