Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byteswap in all cases where bpp>1 ... #310

Open
kif opened this issue Apr 2, 2019 · 4 comments
Open

Byteswap in all cases where bpp>1 ... #310

kif opened this issue Apr 2, 2019 · 4 comments
Labels

Comments

@kif
Copy link
Member

kif commented Apr 2, 2019

Spotted in edfimage at least, by Peter Boesecke. Probably affects only "complex128" with swapped endianness.

@kif kif added the Easy label Apr 2, 2019
@boesecke
Copy link
Contributor

I do not understand why the bpp must be checked at all here. How to apply byte swapping for
items with a specific bpp (including 1 byte) should be implemented in the byte swapping function. If bpp is 1 it should be clear that the result is equal to the input.

boesecke added a commit to boesecke/fabio that referenced this issue Jun 12, 2019
- global variable ROOT removed

edfimage.py:
- get_data_rank etc. defined as static function of class EdfFrame
- function description strings updated with comment strings and latter removed
- _parseheader (parseheader) renamed to _create_header. It better describes it.
- _read_header_block returns a namedtuple
- There are some comments left in the code. Most of them should be removed
  in the final version. Concerning byteswapping, there was already an issue
  opened for updating it (Byteswap in all cases where bpp>1 ... silx-kit#310). When
  this is solved the internal comment should be removed.
@boesecke
Copy link
Contributor

I propose the following simplification:

    byte_order = self.header[capsHeader['BYTEORDER']]
    if ('Low' in byte_order):
         little_endian=True
    else:
         little_endian=False
    
    if ( little_endian==numpy.little_endian ):
         self._data_swap_needed = False
    else:
         self._data_swap_needed = True

Replacing:

    byte_order = self.header[capsHeader['BYTEORDER']]
    if ('Low' in byte_order and numpy.little_endian) or \
       ('High' in byte_order and not numpy.little_endian):
        self._data_swap_needed = False
    if ('High' in byte_order and numpy.little_endian) or \
       ('Low' in byte_order and not numpy.little_endian):
        if bpp in [2, 4, 8]:
            self._data_swap_needed = True
        else:
            self._data_swap_needed = False

@jonwright
Copy link
Collaborator

jonwright commented Jun 12, 2019 via email

@kif
Copy link
Member Author

kif commented Jun 13, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants