diff options
author | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-07-12 21:41:43 +0200 |
---|---|---|
committer | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-07-12 21:41:43 +0200 |
commit | f194278d3ad402f9b2a6d45a6e32b2e18053af74 (patch) | |
tree | 45c674fa131ccceba39e9c37ee6a572ca7ed7dca /v4l2-apps/lib | |
parent | 58cfc4da3781701f2b8da0d4cb6618b6179f223e (diff) | |
download | mediapointer-dvb-s2-f194278d3ad402f9b2a6d45a6e32b2e18053af74.tar.gz mediapointer-dvb-s2-f194278d3ad402f9b2a6d45a6e32b2e18053af74.tar.bz2 |
libv4l release 0.3.5
From: Hans de Goede <j.w.r.degoede@hhs.nl>
* Make JPEG decoding more robust
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Diffstat (limited to 'v4l2-apps/lib')
-rw-r--r-- | v4l2-apps/lib/libv4l/ChangeLog | 5 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 16 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c | 29 |
3 files changed, 34 insertions, 16 deletions
diff --git a/v4l2-apps/lib/libv4l/ChangeLog b/v4l2-apps/lib/libv4l/ChangeLog index def38e046..f323b721d 100644 --- a/v4l2-apps/lib/libv4l/ChangeLog +++ b/v4l2-apps/lib/libv4l/ChangeLog @@ -1,3 +1,8 @@ +libv4l-0.3.5 +------------ +* Make JPEG decoding more robust + + libv4l-0.3.4 (the brownpaperbag release) ---------------------------------------- * The mmap64 support in 0.3.3, has caused a bug in libv4l1 when running on diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index cc733554c..6c6cb693d 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -289,12 +289,13 @@ int v4lconvert_convert(struct v4lconvert_data *data, result = tinyjpeg_decode(data->jdec, TINYJPEG_FMT_YUV420P); } - if (result) { - V4LCONVERT_ERR("decompressing JPEG: %s\n", + /* If the JPEG header checked out ok and we get an error during actual + decompression, log the error, but don't return an errorcode to the + application, so that the user gets what we managed to decompress */ + if (result) + fprintf(stderr, "libv4lconvert: Error decompressing JPEG: %s", tinyjpeg_get_errorstring(data->jdec)); - errno = EIO; - return -1; - } + break; case V4L2_PIX_FMT_SBGGR8: @@ -363,6 +364,11 @@ int v4lconvert_convert(struct v4lconvert_data *data, v4lconvert_yuv420_to_bgr24(src, dest, dest_fmt->fmt.pix.width, dest_fmt->fmt.pix.height); break; + + default: + V4LCONVERT_ERR("Unknown src format in conversion\n"); + errno = EINVAL; + return -1; } return needed; diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c b/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c index b544b1dfa..5c3b4e26d 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c @@ -244,8 +244,12 @@ static const unsigned char val_ac_chrominance[] = while (nbits_in_reservoir<nbits_wanted) \ { \ unsigned char c; \ - if (stream >= priv->stream_end) \ + if (stream >= priv->stream_end) { \ + snprintf(priv->error_string, sizeof(priv->error_string), \ + "fill_nbits error: need %d more bits\n", \ + nbits_wanted - nbits_in_reservoir); \ longjmp(priv->jump_state, -EIO); \ + } \ c = *stream++; \ reservoir <<= 8; \ if (c == 0xff && *stream == 0x00) \ @@ -1588,8 +1592,9 @@ static int parse_DQT(struct jdec_private *priv, const unsigned char *stream) #if SANITY_CHECK if (qi>>4) error("16 bits quantization table is not supported\n"); - if (qi>4) - error("No more 4 quantization table is supported (got %d)\n", qi); + if (qi >= COMPONENTS) + error("No more than %d quantization tables supported (got %d)\n", + COMPONENTS, qi + 1); #endif table = priv->Q_tables[qi]; build_quantization_table(table, stream); @@ -1664,10 +1669,12 @@ static int parse_SOS(struct jdec_private *priv, const unsigned char *stream) cid = *stream++; table = *stream++; #if SANITY_CHECK - if ((table&0xf)>=4) - error("We do not support more than 2 AC Huffman table\n"); - if ((table>>4)>=4) - error("We do not support more than 2 DC Huffman table\n"); + if ((table&0xf) >= HUFFMAN_TABLES) + error("We do not support more than %d AC Huffman table\n", + HUFFMAN_TABLES); + if ((table>>4) >= HUFFMAN_TABLES) + error("We do not support more than %d DC Huffman table\n", + HUFFMAN_TABLES); if (cid != priv->component_infos[i].cid) error("SOS cid order (%d:%d) isn't compatible with the SOF marker (%d:%d)\n", i, cid, i, priv->component_infos[i].cid); @@ -1709,7 +1716,7 @@ static int parse_DHT(struct jdec_private *priv, const unsigned char *stream) } #if SANITY_CHECK if (count > 1024) - error("No more than 1024 bytes is allowed to describe a huffman table"); + error("No more than 1024 bytes is allowed to describe a huffman table\n"); if ( (index &0xf) >= HUFFMAN_TABLES) error("No mode than %d Huffman tables is supported\n", HUFFMAN_TABLES); trace("Huffman table %s n%d\n", (index&0xf0)?"AC":"DC", index&0xf); @@ -1784,7 +1791,7 @@ static int find_next_rst_marker(struct jdec_private *priv) while (*stream++ != 0xff) { if (stream >= priv->stream_end) - error("EOF while search for a RST marker."); + error("EOF while search for a RST marker.\n"); } /* Skip any padding ff byte (this is normal) */ while (*stream == 0xff) @@ -1794,7 +1801,7 @@ static int find_next_rst_marker(struct jdec_private *priv) if ((RST+priv->last_rst_marker_seen) == marker) rst_marker_found = 1; else if (marker >= RST && marker <= RST7) - error("Wrong Reset marker found, abording"); + error("Wrong Reset marker found, abording\n"); else if (marker == EOI) return 0; } @@ -1874,7 +1881,7 @@ static int parse_JFIF(struct jdec_private *priv, const unsigned char *stream) || (priv->component_infos[cCr].Hfactor!=1) || (priv->component_infos[cCb].Vfactor!=1) || (priv->component_infos[cCr].Vfactor!=1)) - error("Sampling other than 1x1 for Cr and Cb is not supported"); + error("Sampling other than 1x1 for Cr and Cb is not supported\n"); #endif return 0; |