Commit 17851b8b authored by glantau's avatar glantau

use default huffman tables if none given


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@40 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 3cb36353
...@@ -455,6 +455,18 @@ typedef struct MJpegDecodeContext { ...@@ -455,6 +455,18 @@ typedef struct MJpegDecodeContext {
UINT8 buffer[PICTURE_BUFFER_SIZE]; UINT8 buffer[PICTURE_BUFFER_SIZE];
} MJpegDecodeContext; } MJpegDecodeContext;
static void build_vlc(VLC *vlc, const UINT8 *bits_table, const UINT8 *val_table,
int nb_codes)
{
UINT8 huff_size[256];
UINT16 huff_code[256];
memset(huff_size, 0, sizeof(huff_size));
build_huffman_codes(huff_size, huff_code, bits_table, val_table);
init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2);
}
static int mjpeg_decode_init(AVCodecContext *avctx) static int mjpeg_decode_init(AVCodecContext *avctx)
{ {
MJpegDecodeContext *s = avctx->priv_data; MJpegDecodeContext *s = avctx->priv_data;
...@@ -465,6 +477,11 @@ static int mjpeg_decode_init(AVCodecContext *avctx) ...@@ -465,6 +477,11 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
account FF 00 case */ account FF 00 case */
s->start_code = -1; s->start_code = -1;
s->buf_ptr = s->buffer; s->buf_ptr = s->buffer;
build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);
build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);
build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);
return 0; return 0;
} }
...@@ -501,8 +518,6 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s, ...@@ -501,8 +518,6 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s,
int len, index, i, class, n, v, code_max; int len, index, i, class, n, v, code_max;
UINT8 bits_table[17]; UINT8 bits_table[17];
UINT8 val_table[256]; UINT8 val_table[256];
UINT8 huff_size[256];
UINT16 huff_code[256];
init_get_bits(&s->gb, buf, buf_size); init_get_bits(&s->gb, buf, buf_size);
...@@ -536,17 +551,11 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s, ...@@ -536,17 +551,11 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s,
} }
len -= n; len -= n;
/* now build size/code table */
memset(huff_size, 0, sizeof(huff_size));
build_huffman_codes(huff_size, huff_code, bits_table, val_table);
/* build VLC and flush previous vlc if present */ /* build VLC and flush previous vlc if present */
free_vlc(&s->vlcs[class][index]); free_vlc(&s->vlcs[class][index]);
dprintf("class=%d index=%d nb_codes=%d\n", dprintf("class=%d index=%d nb_codes=%d\n",
class, index, code_max + 1); class, index, code_max + 1);
init_vlc(&s->vlcs[class][index], 9, code_max + 1, build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1);
huff_size, 1, 1,
huff_code, 2, 2);
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment