Mercurial > libavcodec.hg
changeset 832:ff66fdb1d092 libavcodec
fixed some bugs in app parser - some jfif and adobe jpgs fixed
author | al3x |
---|---|
date | Sat, 02 Nov 2002 22:49:13 +0000 |
parents | 14f4598ec793 |
children | 61b558602549 |
files | mjpeg.c |
diffstat | 1 files changed, 45 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mjpeg.c Sat Nov 02 18:47:51 2002 +0000 +++ b/mjpeg.c Sat Nov 02 22:49:13 2002 +0000 @@ -608,13 +608,14 @@ UINT8 *current_picture[MAX_COMPONENTS]; /* picture structure */ int linesize[MAX_COMPONENTS]; DCTELEM block[64] __align8; + ScanTable scantable; + void (*idct_put)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); - int buggy_avid; int restart_interval; int restart_count; + + int buggy_avid; int interlace_polarity; - ScanTable scantable; - void (*idct_put)(UINT8 *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); } MJpegDecodeContext; static int mjpeg_decode_dht(MJpegDecodeContext *s); @@ -1032,7 +1033,9 @@ } } } - if ((s->restart_interval <= 8) && !--s->restart_count) { + /* (< 1350) buggy workaround for Spectralfan.mov, should be fixed */ + + if ((s->restart_interval < 1350) && !--s->restart_count) { align_get_bits(&s->gb); skip_bits(&s->gb, 16); /* skip RSTn */ for (j=0; j<nb_components; j++) /* reset dc */ @@ -1073,8 +1076,8 @@ len -= 6; /* buggy AVID, it puts EOI only at every 10th frame */ - /* also this fourcc is used by non-avid files too, it means - interleaving, but it's always present in AVID files */ + /* also this fourcc is used by non-avid files too, it holds some + informations, but it's always present in AVID creates files */ if (id == ff_get_fourcc("AVI1")) { /* structure: @@ -1099,10 +1102,11 @@ goto out; } - len -= 2; +// len -= 2; if (id == ff_get_fourcc("JFIF")) { + int t_w, t_h; skip_bits(&s->gb, 8); /* the trailing zero-byte */ printf("mjpeg: JFIF header found (version: %x.%x)\n", get_bits(&s->gb, 8), get_bits(&s->gb, 8)); @@ -1117,8 +1121,26 @@ skip_bits(&s->gb, 16); skip_bits(&s->gb, 16); } - skip_bits(&s->gb, 8); - skip_bits(&s->gb, 8); + t_w = get_bits(&s->gb, 8); + t_h = get_bits(&s->gb, 8); + if (t_w && t_h) + { + /* skip thumbnail */ + if (len-10-(t_w*t_h*3) > 0) + len -= t_w*t_h*3; + } + len -= 10; + goto out; + } + + if (id == ff_get_fourcc("Adob") && (get_bits(&s->gb, 8) == 'e')) + { + printf("mjpeg: Adobe header found\n"); + skip_bits(&s->gb, 16); /* version */ + skip_bits(&s->gb, 16); /* flags0 */ + skip_bits(&s->gb, 16); /* flags1 */ + skip_bits(&s->gb, 8); /* transform */ + len -= 7; goto out; } @@ -1146,6 +1168,12 @@ } out: + /* slow but needed for extreme adobe jpegs */ + if (len < 0) + printf("mjpeg: error, decode_app parser read over the end\n"); + while(--len > 0) + skip_bits(&s->gb, 8); + return 0; } @@ -1280,7 +1308,11 @@ while (src<buf_end) { UINT8 x = *(src++); - + +#if 0 + if (x == 0xff && *src == 0xff) + break; +#endif *(dst++) = x; if (x == 0xff) { @@ -1292,6 +1324,9 @@ } } init_get_bits(&s->gb, s->buffer, dst - s->buffer); + + dprintf("escaping removed %d bytes\n", + (buf_end - buf_ptr) - (dst - s->buffer)); } else init_get_bits(&s->gb, buf_ptr, buf_end - buf_ptr);