* picopng does not support big-endian CPUs
@ 2015-01-25 18:26 Antony Pavlov
2015-01-26 7:58 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Antony Pavlov @ 2015-01-25 18:26 UTC (permalink / raw)
To: barebox
Hi All!
Current lib/gui/picopng.c has problems on big-endian CPUs.
Here are two examples from PNG_readPngHeader():
if (*(uint64_t *) in != PNG_SIGNATURE) {
...
if (*(uint32_t *) &in[12] != CHUNK_IHDR) {
Using memcmp in this situation is much better, e.g.
+ uint8_t png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
...
+ if (memcmp(in, png_signature, 8)) {
+ uint8_t chunk_header[4] = {0x49, 0x48, 0x44, 0x52};
...
+ if (memcmp(&in[12], chunk_header, 4)) {
Current lodepng works fine on big-endian, but can we disable picopng
in Kconfig for big-endian CPUs?
On mips I have CPU_BIG_ENDIAN option, so I can add
'depends on !CPU_BIG_ENDIAN' to lib/gui/Kconfig, e.g.
config PICOPNG
+ depends on !CPU_BIG_ENDIAN
bool "picoPNG"
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: picopng does not support big-endian CPUs
2015-01-25 18:26 picopng does not support big-endian CPUs Antony Pavlov
@ 2015-01-26 7:58 ` Sascha Hauer
2015-01-26 9:06 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2015-01-26 7:58 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Sun, Jan 25, 2015 at 10:26:29PM +0400, Antony Pavlov wrote:
> Hi All!
>
> Current lib/gui/picopng.c has problems on big-endian CPUs.
>
> Here are two examples from PNG_readPngHeader():
>
> if (*(uint64_t *) in != PNG_SIGNATURE) {
> ...
> if (*(uint32_t *) &in[12] != CHUNK_IHDR) {
>
>
> Using memcmp in this situation is much better, e.g.
>
> + uint8_t png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
> ...
> + if (memcmp(in, png_signature, 8)) {
>
>
> + uint8_t chunk_header[4] = {0x49, 0x48, 0x44, 0x52};
> ...
> + if (memcmp(&in[12], chunk_header, 4)) {
>
>
> Current lodepng works fine on big-endian, but can we disable picopng
> in Kconfig for big-endian CPUs?
Can't we just fix it? Are there more difficult places than the ones
above? If it turns out to be difficult I'm fine with adding a dependency
to CPU_BIG_ENDIAN.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: picopng does not support big-endian CPUs
2015-01-26 7:58 ` Sascha Hauer
@ 2015-01-26 9:06 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-26 9:06 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
> On Jan 26, 2015, at 3:58 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> On Sun, Jan 25, 2015 at 10:26:29PM +0400, Antony Pavlov wrote:
>> Hi All!
>>
>> Current lib/gui/picopng.c has problems on big-endian CPUs.
>>
>> Here are two examples from PNG_readPngHeader():
>>
>> if (*(uint64_t *) in != PNG_SIGNATURE) {
>> ...
>> if (*(uint32_t *) &in[12] != CHUNK_IHDR) {
>>
>>
>> Using memcmp in this situation is much better, e.g.
>>
>> + uint8_t png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
>> ...
>> + if (memcmp(in, png_signature, 8)) {
>>
>>
>> + uint8_t chunk_header[4] = {0x49, 0x48, 0x44, 0x52};
>> ...
>> + if (memcmp(&in[12], chunk_header, 4)) {
>>
>>
>> Current lodepng works fine on big-endian, but can we disable picopng
>> in Kconfig for big-endian CPUs?
>
> Can't we just fix it? Are there more difficult places than the ones
> above? If it turns out to be difficult I'm fine with adding a dependency
> to CPU_BIG_ENDIAN.
>
IIRC the code this can be fixed easy as I run this code on a mac G5 in the past
I’ll take a if I still have the code
Best Regards,
J.
> Sascha
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-26 9:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-25 18:26 picopng does not support big-endian CPUs Antony Pavlov
2015-01-26 7:58 ` Sascha Hauer
2015-01-26 9:06 ` Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox