diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-11 00:16:57 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-11 00:16:57 +0000 |
commit | c8b67c3ca0e35d71200e002ef33d5484763448eb (patch) | |
tree | 83bcbf2663890741a5257a996e4dbb14e184a98d /apps/recorder/jpeg_load.c | |
parent | b5c356be85564eed8a85768385d2ba3ad6219cc5 (diff) | |
download | rockbox-c8b67c3ca0e35d71200e002ef33d5484763448eb.tar.gz rockbox-c8b67c3ca0e35d71200e002ef33d5484763448eb.zip |
Flag EOF and empty buffer conditions as UNLIKELY in JPEG decoder.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20907 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/jpeg_load.c')
-rw-r--r-- | apps/recorder/jpeg_load.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c index 62bc1e332d..07b79f0b85 100644 --- a/apps/recorder/jpeg_load.c +++ b/apps/recorder/jpeg_load.c | |||
@@ -833,7 +833,7 @@ struct idct_entry idct_tbl[] = { | |||
833 | #ifdef JPEG_FROM_MEM | 833 | #ifdef JPEG_FROM_MEM |
834 | INLINE unsigned char *getc(struct jpeg* p_jpeg) | 834 | INLINE unsigned char *getc(struct jpeg* p_jpeg) |
835 | { | 835 | { |
836 | if (p_jpeg->len) | 836 | if (LIKELY(p_jpeg->len)) |
837 | { | 837 | { |
838 | p_jpeg->len--; | 838 | p_jpeg->len--; |
839 | return p_jpeg->data++; | 839 | return p_jpeg->data++; |
@@ -869,9 +869,9 @@ INLINE void fill_buf(struct jpeg* p_jpeg) | |||
869 | 869 | ||
870 | static unsigned char *getc(struct jpeg* p_jpeg) | 870 | static unsigned char *getc(struct jpeg* p_jpeg) |
871 | { | 871 | { |
872 | if (p_jpeg->buf_left < 1) | 872 | if (UNLIKELY(p_jpeg->buf_left < 1)) |
873 | fill_buf(p_jpeg); | 873 | fill_buf(p_jpeg); |
874 | if (p_jpeg->buf_left < 1) | 874 | if (UNLIKELY(p_jpeg->buf_left < 1)) |
875 | return NULL; | 875 | return NULL; |
876 | p_jpeg->buf_left--; | 876 | p_jpeg->buf_left--; |
877 | return (p_jpeg->buf_index++) + p_jpeg->buf; | 877 | return (p_jpeg->buf_index++) + p_jpeg->buf; |
@@ -879,7 +879,7 @@ static unsigned char *getc(struct jpeg* p_jpeg) | |||
879 | 879 | ||
880 | INLINE bool skip_bytes_seek(struct jpeg* p_jpeg) | 880 | INLINE bool skip_bytes_seek(struct jpeg* p_jpeg) |
881 | { | 881 | { |
882 | if (lseek(p_jpeg->fd, -p_jpeg->buf_left, SEEK_CUR) < 0) | 882 | if (UNLIKELY(lseek(p_jpeg->fd, -p_jpeg->buf_left, SEEK_CUR) < 0)) |
883 | return false; | 883 | return false; |
884 | p_jpeg->buf_left = 0; | 884 | p_jpeg->buf_left = 0; |
885 | return true; | 885 | return true; |
@@ -901,14 +901,14 @@ static void putc(struct jpeg* p_jpeg) | |||
901 | 901 | ||
902 | #define e_skip_bytes(jpeg, count) \ | 902 | #define e_skip_bytes(jpeg, count) \ |
903 | do {\ | 903 | do {\ |
904 | if (!skip_bytes((jpeg),(count))) \ | 904 | if (UNLIKELY(!skip_bytes((jpeg),(count)))) \ |
905 | return -1; \ | 905 | return -1; \ |
906 | } while (0) | 906 | } while (0) |
907 | 907 | ||
908 | #define e_getc(jpeg, code) \ | 908 | #define e_getc(jpeg, code) \ |
909 | ({ \ | 909 | ({ \ |
910 | unsigned char *c; \ | 910 | unsigned char *c; \ |
911 | if (!(c = getc(jpeg))) \ | 911 | if (UNLIKELY(!(c = getc(jpeg)))) \ |
912 | return (code); \ | 912 | return (code); \ |
913 | *c; \ | 913 | *c; \ |
914 | }) | 914 | }) |
@@ -916,7 +916,7 @@ do {\ | |||
916 | #define d_getc(jpeg, def) \ | 916 | #define d_getc(jpeg, def) \ |
917 | ({ \ | 917 | ({ \ |
918 | unsigned char *cp = getc(jpeg); \ | 918 | unsigned char *cp = getc(jpeg); \ |
919 | unsigned char c = cp ? *cp : (def); \ | 919 | unsigned char c = LIKELY(cp) ? *cp : (def); \ |
920 | c; \ | 920 | c; \ |
921 | }) | 921 | }) |
922 | 922 | ||
@@ -1547,7 +1547,7 @@ static void fill_bit_buffer(struct jpeg* p_jpeg) | |||
1547 | if (p_jpeg->marker_val) | 1547 | if (p_jpeg->marker_val) |
1548 | p_jpeg->marker_ind += 16; | 1548 | p_jpeg->marker_ind += 16; |
1549 | byte = d_getc(p_jpeg, 0); | 1549 | byte = d_getc(p_jpeg, 0); |
1550 | if (byte == 0xFF) /* legal marker can be byte stuffing or RSTm */ | 1550 | if (UNLIKELY(byte == 0xFF)) /* legal marker can be byte stuffing or RSTm */ |
1551 | { /* simplification: just skip the (one-byte) marker code */ | 1551 | { /* simplification: just skip the (one-byte) marker code */ |
1552 | marker = d_getc(p_jpeg, 0); | 1552 | marker = d_getc(p_jpeg, 0); |
1553 | if ((marker & ~7) == 0xD0) | 1553 | if ((marker & ~7) == 0xD0) |
@@ -1559,7 +1559,7 @@ static void fill_bit_buffer(struct jpeg* p_jpeg) | |||
1559 | p_jpeg->bitbuf = (p_jpeg->bitbuf << 8) | byte; | 1559 | p_jpeg->bitbuf = (p_jpeg->bitbuf << 8) | byte; |
1560 | 1560 | ||
1561 | byte = d_getc(p_jpeg, 0); | 1561 | byte = d_getc(p_jpeg, 0); |
1562 | if (byte == 0xFF) /* legal marker can be byte stuffing or RSTm */ | 1562 | if (UNLIKELY(byte == 0xFF)) /* legal marker can be byte stuffing or RSTm */ |
1563 | { /* simplification: just skip the (one-byte) marker code */ | 1563 | { /* simplification: just skip the (one-byte) marker code */ |
1564 | marker = d_getc(p_jpeg, 0); | 1564 | marker = d_getc(p_jpeg, 0); |
1565 | if ((marker & ~7) == 0xD0) | 1565 | if ((marker & ~7) == 0xD0) |