Add a seperate VLC table for progressive jpeg so we dont have to subtract 16 in the inner loop.
Originally committed as revision 25545 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
8870b25140
commit
5675a11f92
libavcodec
@ -69,6 +69,10 @@ static void build_basic_mjpeg_vlc(MJpegDecodeContext * s) {
|
|||||||
ff_mjpeg_val_ac_luminance, 251, 0, 1);
|
ff_mjpeg_val_ac_luminance, 251, 0, 1);
|
||||||
build_vlc(&s->vlcs[1][1], ff_mjpeg_bits_ac_chrominance,
|
build_vlc(&s->vlcs[1][1], ff_mjpeg_bits_ac_chrominance,
|
||||||
ff_mjpeg_val_ac_chrominance, 251, 0, 1);
|
ff_mjpeg_val_ac_chrominance, 251, 0, 1);
|
||||||
|
build_vlc(&s->vlcs[2][0], ff_mjpeg_bits_ac_luminance,
|
||||||
|
ff_mjpeg_val_ac_luminance, 251, 0, 0);
|
||||||
|
build_vlc(&s->vlcs[2][1], ff_mjpeg_bits_ac_chrominance,
|
||||||
|
ff_mjpeg_val_ac_chrominance, 251, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
|
||||||
@ -188,6 +192,9 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
|
|||||||
if(build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1, 0, class > 0) < 0){
|
if(build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1, 0, class > 0) < 0){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if(class>0 && build_vlc(&s->vlcs[2][index], bits_table, val_table, code_max + 1, 0, 0) < 0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -473,9 +480,8 @@ static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8
|
|||||||
{OPEN_READER(re, &s->gb)
|
{OPEN_READER(re, &s->gb)
|
||||||
for(i=ss;;i++) {
|
for(i=ss;;i++) {
|
||||||
UPDATE_CACHE(re, &s->gb);
|
UPDATE_CACHE(re, &s->gb);
|
||||||
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
|
GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2)
|
||||||
/* Progressive JPEG use AC coeffs from zero and this decoder sets offset 16 by default */
|
|
||||||
code -= 16;
|
|
||||||
run = ((unsigned) code) >> 4;
|
run = ((unsigned) code) >> 4;
|
||||||
code &= 0xF;
|
code &= 0xF;
|
||||||
if(code) {
|
if(code) {
|
||||||
@ -561,9 +567,8 @@ static int decode_block_refinement(MJpegDecodeContext *s, DCTELEM *block, uint8_
|
|||||||
else {
|
else {
|
||||||
for(;;i++) {
|
for(;;i++) {
|
||||||
UPDATE_CACHE(re, &s->gb);
|
UPDATE_CACHE(re, &s->gb);
|
||||||
GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
|
GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2)
|
||||||
/* Progressive JPEG use AC coeffs from zero and this decoder sets offset 16 by default */
|
|
||||||
code -= 16;
|
|
||||||
if(code & 0xF) {
|
if(code & 0xF) {
|
||||||
run = ((unsigned) code) >> 4;
|
run = ((unsigned) code) >> 4;
|
||||||
UPDATE_CACHE(re, &s->gb);
|
UPDATE_CACHE(re, &s->gb);
|
||||||
|
@ -44,7 +44,7 @@ typedef struct MJpegDecodeContext {
|
|||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
|
|
||||||
int16_t quant_matrixes[4][64];
|
int16_t quant_matrixes[4][64];
|
||||||
VLC vlcs[2][4];
|
VLC vlcs[3][4];
|
||||||
int qscale[4]; ///< quantizer scale calculated from quant_matrixes
|
int qscale[4]; ///< quantizer scale calculated from quant_matrixes
|
||||||
|
|
||||||
int org_height; /* size given at codec init */
|
int org_height; /* size given at codec init */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user