Gitweb links:
...log
http://git.netsurf-browser.org/libnsbmp.git/shortlog/091d1a1f15aab463054f637d6830808bbe893af8
...commit
http://git.netsurf-browser.org/libnsbmp.git/commit/091d1a1f15aab463054f637d6830808bbe893af8
...tree
http://git.netsurf-browser.org/libnsbmp.git/tree/091d1a1f15aab463054f637d6830808bbe893af8
The branch, master has been updated
via 091d1a1f15aab463054f637d6830808bbe893af8 (commit)
via b017792feaa0c28ef22d0d60e11612846e8e1db5 (commit)
via b0e4d39dc3be430670148262efbc0226b97448a6 (commit)
from a44819c36f45f3a0a2d387210d0c2f6b5eb577d9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=091d1a1f15aab463054f637d6830808bbe893af8
commit 091d1a1f15aab463054f637d6830808bbe893af8
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
Improve test runner and prevent generation of excessively large output
diff --git a/test/decode_bmp.c b/test/decode_bmp.c
index e5dc572..e90515a 100644
--- a/test/decode_bmp.c
+++ b/test/decode_bmp.c
@@ -70,6 +70,11 @@ int main(int argc, char *argv[])
res = 1;
goto cleanup;
}
+ /* skip if the decoded image would be ridiculously large */
+ if ((bmp.width * bmp.height) > 2000000) {
+ res = 1;
+ goto cleanup;
+ }
}
printf("P3\n");
diff --git a/test/runtest.sh b/test/runtest.sh
index 23d792e..c3e504c 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,33 +1,88 @@
#!/bin/sh
+# run test images through libnsbmp and count results
+
TEST_PATH=$1
TEST_OUT=${TEST_PATH}/ppm
+TEST_LOG=${TEST_PATH}/test.log
mkdir -p ${TEST_OUT}
+# bitmap test directories
+
+# standard bitmap suite
+BMPTESTS="test/bmpsuite/*.bmp"
+
+# netsurf test bitmaps
+BMPTESTS="${BMPTESTS} test/bmp/*.bmp"
+
+# icon test directories
+ICOTESTS="test/icons/*.ico"
+
bmpdecode()
{
OUTF=$(basename ${1} .bmp)
- ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm
+ echo "Bitmap:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm 2>> ${TEST_LOG}
+ ECODE=$?
+ echo "Exit code:${ECODE}" >> ${TEST_LOG}
+ return ${ECODE}
}
icodecode()
{
OUTF=$(basename ${1} .ico)
- ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm
+ echo "Icon:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm 2>> ${TEST_LOG}
}
-# standard bitmap suite
-for BMP in $(ls test/bmpsuite/*.bmp);do
+# bitmap tests
+
+BMPTESTTOTC=0
+BMPTESTPASSC=0
+BMPTESTERRC=0
+
+for BMP in $(ls ${BMPTESTS});do
+ BMPTESTTOTC=$((BMPTESTTOTC+1))
bmpdecode ${BMP}
+ ECODE=$?
+ if [ "${ECODE}" -gt 128 ];then
+ BMPTESTERRC=$((BMPTESTERRC+1))
+ else
+ BMPTESTPASSC=$((BMPTESTPASSC+1))
+ fi
done
-# test bitmaps
-for ICO in $(ls test/bmp/*.bmp);do
- bmpdecode ${ICO}
-done
+echo "Test bitmap decode"
+echo "Tests:${BMPTESTTOTC} Pass:${BMPTESTPASSC} Error:${BMPTESTERRC}"
+
+
+# icon tests
-# test icons
-for ICO in $(ls test/icons/*.ico);do
+ICOTESTTOTC=0
+ICOTESTPASSC=0
+ICOTESTERRC=0
+
+# netsurf test icons
+for ICO in $(ls ${ICOTESTS});do
+ ICOTESTTOTC=$((BMPTESTTOTC+1))
icodecode ${ICO}
+ ECODE=$?
+ if [ "${ECODE}" -gt 128 ];then
+ ICOTESTERRC=$((ICOTESTERRC+1))
+ else
+ ICOTESTPASSC=$((ICOTESTPASSC+1))
+ fi
done
+
+echo "Test icon decode"
+echo "Tests:${ICOTESTTOTC} Pass:${ICOTESTPASSC} Error:${ICOTESTERRC}"
+
+
+
+# exit code
+if [ "${BMPTESTERRC}" -gt 0 -o "${ICOTESTERRC}" -gt 0 ]; then
+ exit 1
+fi
+
+exit 0
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=b017792feaa0c28ef22d0d60e11612846e8e1db5
commit b017792feaa0c28ef22d0d60e11612846e8e1db5
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
add tests for problematic bitmaps
mantis 2446 has a problematic bitmap we can use to test with
diff --git a/test/bmp/mantis-2446.bmp b/test/bmp/mantis-2446.bmp
new file mode 100644
index 0000000..d1e8886
Binary files /dev/null and b/test/bmp/mantis-2446.bmp differ
diff --git a/test/runtest.sh b/test/runtest.sh
index 4ac3302..23d792e 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -17,10 +17,17 @@ icodecode()
${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm
}
+# standard bitmap suite
for BMP in $(ls test/bmpsuite/*.bmp);do
bmpdecode ${BMP}
done
+# test bitmaps
+for ICO in $(ls test/bmp/*.bmp);do
+ bmpdecode ${ICO}
+done
+
+# test icons
for ICO in $(ls test/icons/*.ico);do
icodecode ${ICO}
done
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=b0e4d39dc3be430670148262efbc0226b97448a6
commit b0e4d39dc3be430670148262efbc0226b97448a6
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
move library usage documentation into a README file
diff --git a/src/README b/src/README
new file mode 100644
index 0000000..19b75e7
--- /dev/null
+++ b/src/README
@@ -0,0 +1,57 @@
+NetSurf bitmap decoding library
+===============================
+
+The functions provided by this library allow for the decoding of
+Microsoft's BMP and ICO image file formats.
+
+READING BMP FILES
+=================
+
+To begin decoding a BMP, the caller should initialise a
+'bmp_bitmap_callback_vt' structure with the appropriate values necessary
+to handle bitmap images. Next, a 'bmp_image' structure should be
+initialised by calling bmp_create(). This structure should then be
+passed to bmp_analyse() along with the BMP data to process and the size
+of this data.
+
+Once the analysis has begun, the decoder completes the width and height
+variables.
+
+To decode the image, the caller must use bmp_decode() which selects the
+proper decoding method based on the BMP info header and assigns the
+decoded bitmap image to the 'bitmap' member of the 'bmp_image'
+structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
+format.
+
+It should be noted that bmp_finalise() should always be called, even if
+the image was never decoded. It is also the responsibility of the
+caller to free 'bmp_data'.
+
+READING ICO FILES
+=================
+
+To begin decoding an ICO, the caller should initialise a
+'bmp_bitmap_callback_vt' structure with the appropriate values necessary
+to handle bitmap images. Next, an 'ico_collection' structure should be
+initialised by calling ico_create(). This structure should then be
+passed to ico_analyse() along with the ICO data to process and the size
+of this data.
+
+Once the analysis has begun, the decoder completes the width and height
+variables. Because ICO collections contain multiple bitmap images, the
+width and height will contain the values of the largest available image.
+
+The caller then obtains a BMP from the ICO collection by calling
+ico_find() with the requested width and height.
+
+To decode the image, the caller must use bmp_decode() which selects the
+proper decoding method based on the BMP info header and assigns the
+decoded bitmap image to the 'bitmap' member of the 'bmp_image'
+structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
+format.
+
+It should be noted that ico_finalise() should always be called, even if
+no images were decoded. Because ico_finalise() calls bmp_finalise() for
+each bitmap within the collection, the caller is not required to perform
+this function. However, it is the responsibility of the caller to free
+'ico_data'.
\ No newline at end of file
diff --git a/src/libnsbmp.c b/src/libnsbmp.c
index 123ed9e..d4e4b08 100644
--- a/src/libnsbmp.c
+++ b/src/libnsbmp.c
@@ -7,6 +7,11 @@
* http://www.opensource.org/licenses/mit-license.php
*/
+/**
+ * \file
+ * BMP decoding implementation
+ */
+
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
@@ -18,64 +23,6 @@
#include "utils/log.h"
-/* The functions provided by this file allow for the decoding of
- Microsoft's BMP and ICO image file formats.
-
- READING BMP FILES
- =================
-
- To begin decoding a BMP, the caller should initialise a
- 'bmp_bitmap_callback_vt' structure with the appropriate values necessary
- to handle bitmap images. Next, a 'bmp_image' structure should be
- initialised by calling bmp_create(). This structure should then be
- passed to bmp_analyse() along with the BMP data to process and the size
- of this data.
-
- Once the analysis has begun, the decoder completes the width and height
- variables.
-
- To decode the image, the caller must use bmp_decode() which selects the
- proper decoding method based on the BMP info header and assigns the
- decoded bitmap image to the 'bitmap' member of the 'bmp_image'
- structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
- format.
-
- It should be noted that bmp_finalise() should always be called, even if
- the image was never decoded. It is also the responsibility of the
- caller to free 'bmp_data'.
-
- READING ICO FILES
- =================
-
- To begin decoding an ICO, the caller should initialise a
- 'bmp_bitmap_callback_vt' structure with the appropriate values necessary
- to handle bitmap images. Next, an 'ico_collection' structure should be
- initialised by calling ico_create(). This structure should then be
- passed to ico_analyse() along with the ICO data to process and the size
- of this data.
-
- Once the analysis has begun, the decoder completes the width and height
- variables. Because ICO collections contain multiple bitmap images, the
- width and height will contain the values of the largest available image.
-
- The caller then obtains a BMP from the ICO collection by calling
- ico_find() with the requested width and height.
-
- To decode the image, the caller must use bmp_decode() which selects the
- proper decoding method based on the BMP info header and assigns the
- decoded bitmap image to the 'bitmap' member of the 'bmp_image'
- structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
- format.
-
- It should be noted that ico_finalise() should always be called, even if
- no images were decoded. Because ico_finalise() calls bmp_finalise() for
- each bitmap within the collection, the caller is not required to perform
- this function. However, it is the responsibility of the caller to free
- 'ico_data'.
-
- [dynis] - Tue 1st July 2008
-*/
-
/* squashes unused variable compiler warnings */
#define UNUSED(x) ((x)=(x))
-----------------------------------------------------------------------
Summary of changes:
src/README | 57 +++++++++++++++++++++++++++++++++++++
src/libnsbmp.c | 63 ++++-------------------------------------
test/bmp/mantis-2446.bmp | Bin 0 -> 1684 bytes
test/decode_bmp.c | 5 ++++
test/runtest.sh | 70 +++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 133 insertions(+), 62 deletions(-)
create mode 100644 src/README
create mode 100644 test/bmp/mantis-2446.bmp
diff --git a/src/README b/src/README
new file mode 100644
index 0000000..19b75e7
--- /dev/null
+++ b/src/README
@@ -0,0 +1,57 @@
+NetSurf bitmap decoding library
+===============================
+
+The functions provided by this library allow for the decoding of
+Microsoft's BMP and ICO image file formats.
+
+READING BMP FILES
+=================
+
+To begin decoding a BMP, the caller should initialise a
+'bmp_bitmap_callback_vt' structure with the appropriate values necessary
+to handle bitmap images. Next, a 'bmp_image' structure should be
+initialised by calling bmp_create(). This structure should then be
+passed to bmp_analyse() along with the BMP data to process and the size
+of this data.
+
+Once the analysis has begun, the decoder completes the width and height
+variables.
+
+To decode the image, the caller must use bmp_decode() which selects the
+proper decoding method based on the BMP info header and assigns the
+decoded bitmap image to the 'bitmap' member of the 'bmp_image'
+structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
+format.
+
+It should be noted that bmp_finalise() should always be called, even if
+the image was never decoded. It is also the responsibility of the
+caller to free 'bmp_data'.
+
+READING ICO FILES
+=================
+
+To begin decoding an ICO, the caller should initialise a
+'bmp_bitmap_callback_vt' structure with the appropriate values necessary
+to handle bitmap images. Next, an 'ico_collection' structure should be
+initialised by calling ico_create(). This structure should then be
+passed to ico_analyse() along with the ICO data to process and the size
+of this data.
+
+Once the analysis has begun, the decoder completes the width and height
+variables. Because ICO collections contain multiple bitmap images, the
+width and height will contain the values of the largest available image.
+
+The caller then obtains a BMP from the ICO collection by calling
+ico_find() with the requested width and height.
+
+To decode the image, the caller must use bmp_decode() which selects the
+proper decoding method based on the BMP info header and assigns the
+decoded bitmap image to the 'bitmap' member of the 'bmp_image'
+structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
+format.
+
+It should be noted that ico_finalise() should always be called, even if
+no images were decoded. Because ico_finalise() calls bmp_finalise() for
+each bitmap within the collection, the caller is not required to perform
+this function. However, it is the responsibility of the caller to free
+'ico_data'.
\ No newline at end of file
diff --git a/src/libnsbmp.c b/src/libnsbmp.c
index 123ed9e..d4e4b08 100644
--- a/src/libnsbmp.c
+++ b/src/libnsbmp.c
@@ -7,6 +7,11 @@
* http://www.opensource.org/licenses/mit-license.php
*/
+/**
+ * \file
+ * BMP decoding implementation
+ */
+
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
@@ -18,64 +23,6 @@
#include "utils/log.h"
-/* The functions provided by this file allow for the decoding of
- Microsoft's BMP and ICO image file formats.
-
- READING BMP FILES
- =================
-
- To begin decoding a BMP, the caller should initialise a
- 'bmp_bitmap_callback_vt' structure with the appropriate values necessary
- to handle bitmap images. Next, a 'bmp_image' structure should be
- initialised by calling bmp_create(). This structure should then be
- passed to bmp_analyse() along with the BMP data to process and the size
- of this data.
-
- Once the analysis has begun, the decoder completes the width and height
- variables.
-
- To decode the image, the caller must use bmp_decode() which selects the
- proper decoding method based on the BMP info header and assigns the
- decoded bitmap image to the 'bitmap' member of the 'bmp_image'
- structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
- format.
-
- It should be noted that bmp_finalise() should always be called, even if
- the image was never decoded. It is also the responsibility of the
- caller to free 'bmp_data'.
-
- READING ICO FILES
- =================
-
- To begin decoding an ICO, the caller should initialise a
- 'bmp_bitmap_callback_vt' structure with the appropriate values necessary
- to handle bitmap images. Next, an 'ico_collection' structure should be
- initialised by calling ico_create(). This structure should then be
- passed to ico_analyse() along with the ICO data to process and the size
- of this data.
-
- Once the analysis has begun, the decoder completes the width and height
- variables. Because ICO collections contain multiple bitmap images, the
- width and height will contain the values of the largest available image.
-
- The caller then obtains a BMP from the ICO collection by calling
- ico_find() with the requested width and height.
-
- To decode the image, the caller must use bmp_decode() which selects the
- proper decoding method based on the BMP info header and assigns the
- decoded bitmap image to the 'bitmap' member of the 'bmp_image'
- structure. The bitmap image is stored with 4 bytes-per-pixel in RGBA
- format.
-
- It should be noted that ico_finalise() should always be called, even if
- no images were decoded. Because ico_finalise() calls bmp_finalise() for
- each bitmap within the collection, the caller is not required to perform
- this function. However, it is the responsibility of the caller to free
- 'ico_data'.
-
- [dynis] - Tue 1st July 2008
-*/
-
/* squashes unused variable compiler warnings */
#define UNUSED(x) ((x)=(x))
diff --git a/test/bmp/mantis-2446.bmp b/test/bmp/mantis-2446.bmp
new file mode 100644
index 0000000..d1e8886
Binary files /dev/null and b/test/bmp/mantis-2446.bmp differ
diff --git a/test/decode_bmp.c b/test/decode_bmp.c
index e5dc572..e90515a 100644
--- a/test/decode_bmp.c
+++ b/test/decode_bmp.c
@@ -70,6 +70,11 @@ int main(int argc, char *argv[])
res = 1;
goto cleanup;
}
+ /* skip if the decoded image would be ridiculously large */
+ if ((bmp.width * bmp.height) > 2000000) {
+ res = 1;
+ goto cleanup;
+ }
}
printf("P3\n");
diff --git a/test/runtest.sh b/test/runtest.sh
index 4ac3302..c3e504c 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,26 +1,88 @@
#!/bin/sh
+# run test images through libnsbmp and count results
+
TEST_PATH=$1
TEST_OUT=${TEST_PATH}/ppm
+TEST_LOG=${TEST_PATH}/test.log
mkdir -p ${TEST_OUT}
+# bitmap test directories
+
+# standard bitmap suite
+BMPTESTS="test/bmpsuite/*.bmp"
+
+# netsurf test bitmaps
+BMPTESTS="${BMPTESTS} test/bmp/*.bmp"
+
+# icon test directories
+ICOTESTS="test/icons/*.ico"
+
bmpdecode()
{
OUTF=$(basename ${1} .bmp)
- ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm
+ echo "Bitmap:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm 2>> ${TEST_LOG}
+ ECODE=$?
+ echo "Exit code:${ECODE}" >> ${TEST_LOG}
+ return ${ECODE}
}
icodecode()
{
OUTF=$(basename ${1} .ico)
- ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm
+ echo "Icon:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm 2>> ${TEST_LOG}
}
-for BMP in $(ls test/bmpsuite/*.bmp);do
+# bitmap tests
+
+BMPTESTTOTC=0
+BMPTESTPASSC=0
+BMPTESTERRC=0
+
+for BMP in $(ls ${BMPTESTS});do
+ BMPTESTTOTC=$((BMPTESTTOTC+1))
bmpdecode ${BMP}
+ ECODE=$?
+ if [ "${ECODE}" -gt 128 ];then
+ BMPTESTERRC=$((BMPTESTERRC+1))
+ else
+ BMPTESTPASSC=$((BMPTESTPASSC+1))
+ fi
done
-for ICO in $(ls test/icons/*.ico);do
+echo "Test bitmap decode"
+echo "Tests:${BMPTESTTOTC} Pass:${BMPTESTPASSC} Error:${BMPTESTERRC}"
+
+
+# icon tests
+
+ICOTESTTOTC=0
+ICOTESTPASSC=0
+ICOTESTERRC=0
+
+# netsurf test icons
+for ICO in $(ls ${ICOTESTS});do
+ ICOTESTTOTC=$((BMPTESTTOTC+1))
icodecode ${ICO}
+ ECODE=$?
+ if [ "${ECODE}" -gt 128 ];then
+ ICOTESTERRC=$((ICOTESTERRC+1))
+ else
+ ICOTESTPASSC=$((ICOTESTPASSC+1))
+ fi
done
+
+echo "Test icon decode"
+echo "Tests:${ICOTESTTOTC} Pass:${ICOTESTPASSC} Error:${ICOTESTERRC}"
+
+
+
+# exit code
+if [ "${BMPTESTERRC}" -gt 0 -o "${ICOTESTERRC}" -gt 0 ]; then
+ exit 1
+fi
+
+exit 0
--
NetSurf BMP Decoder
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org