aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOded Shimon <ods15@ods15.dyndns.org>2007-05-23 18:41:34 +0000
committerOded Shimon <ods15@ods15.dyndns.org>2007-05-23 18:41:34 +0000
commit8d641aedb94115fa5055f04db5001865bb541a1b (patch)
tree4a330ce57576f20ca05af008691fb04da25eface
parent82e605410abe661224029617787a88f33eb7d991 (diff)
downloadffmpeg-8d641aedb94115fa5055f04db5001865bb541a1b.tar.gz
fix mjpeg decoding with broken huffman table headers
Originally committed as revision 9111 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/mjpegdec.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7d64c2f210..9638604806 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -62,6 +62,17 @@ static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_tab
return init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2, use_static);
}
+static void build_basic_mjpeg_vlc(MJpegDecodeContext * s) {
+ build_vlc(&s->vlcs[0][0], ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc_luminance, 12, 0, 0);
+ build_vlc(&s->vlcs[0][1], ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc_chrominance, 12, 0, 0);
+ build_vlc(&s->vlcs[1][0], ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance, 251, 0, 1);
+ build_vlc(&s->vlcs[1][1], ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance, 251, 0, 1);
+}
+
int ff_mjpeg_decode_init(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
@@ -75,21 +86,16 @@ int ff_mjpeg_decode_init(AVCodecContext *avctx)
s->first_picture = 1;
s->org_height = avctx->coded_height;
- build_vlc(&s->vlcs[0][0], ff_mjpeg_bits_dc_luminance,
- ff_mjpeg_val_dc_luminance, 12, 0, 0);
- build_vlc(&s->vlcs[0][1], ff_mjpeg_bits_dc_chrominance,
- ff_mjpeg_val_dc_chrominance, 12, 0, 0);
- build_vlc(&s->vlcs[1][0], ff_mjpeg_bits_ac_luminance,
- ff_mjpeg_val_ac_luminance, 251, 0, 1);
- build_vlc(&s->vlcs[1][1], ff_mjpeg_bits_ac_chrominance,
- ff_mjpeg_val_ac_chrominance, 251, 0, 1);
+ build_basic_mjpeg_vlc(s);
if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
{
av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n");
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
- ff_mjpeg_decode_dht(s);
- /* should check for error - but dunno */
+ if (ff_mjpeg_decode_dht(s)) {
+ av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table, switching back to internal\n");
+ build_basic_mjpeg_vlc(s);
+ }
}
if (avctx->extradata_size > 9 &&
AV_RL32(avctx->extradata + 4) == MKTAG('f','i','e','l')) {