comparison mjpeg.c @ 1906:caee9c21b0b1 libavcodec

always parse APP* as it sometimes contains startcodes which confuse the decoder otherwise
author michael
date Fri, 26 Mar 2004 02:06:34 +0000
parents 5ac49e7a1b8f
children 5b379ba0a577
comparison
equal deleted inserted replaced
1905:2761950695cc 1906:caee9c21b0b1
1530 1530
1531 if (id == ff_get_fourcc("JFIF")) 1531 if (id == ff_get_fourcc("JFIF"))
1532 { 1532 {
1533 int t_w, t_h; 1533 int t_w, t_h;
1534 skip_bits(&s->gb, 8); /* the trailing zero-byte */ 1534 skip_bits(&s->gb, 8); /* the trailing zero-byte */
1535 av_log(s->avctx, AV_LOG_INFO, "mjpeg: JFIF header found (version: %x.%x)\n", 1535 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
1536 av_log(s->avctx, AV_LOG_INFO, "mjpeg: JFIF header found (version: %x.%x)\n",
1536 get_bits(&s->gb, 8), get_bits(&s->gb, 8)); 1537 get_bits(&s->gb, 8), get_bits(&s->gb, 8));
1537 skip_bits(&s->gb, 8); 1538 skip_bits(&s->gb, 8);
1538 1539
1539 s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 16); 1540 s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 16);
1540 s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 16); 1541 s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 16);
1551 goto out; 1552 goto out;
1552 } 1553 }
1553 1554
1554 if (id == ff_get_fourcc("Adob") && (get_bits(&s->gb, 8) == 'e')) 1555 if (id == ff_get_fourcc("Adob") && (get_bits(&s->gb, 8) == 'e'))
1555 { 1556 {
1556 av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found\n"); 1557 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
1558 av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found\n");
1557 skip_bits(&s->gb, 16); /* version */ 1559 skip_bits(&s->gb, 16); /* version */
1558 skip_bits(&s->gb, 16); /* flags0 */ 1560 skip_bits(&s->gb, 16); /* flags0 */
1559 skip_bits(&s->gb, 16); /* flags1 */ 1561 skip_bits(&s->gb, 16); /* flags1 */
1560 skip_bits(&s->gb, 8); /* transform */ 1562 skip_bits(&s->gb, 8); /* transform */
1561 len -= 7; 1563 len -= 7;
1562 goto out; 1564 goto out;
1563 } 1565 }
1564 1566
1565 if (id == ff_get_fourcc("LJIF")){ 1567 if (id == ff_get_fourcc("LJIF")){
1566 av_log(s->avctx, AV_LOG_INFO, "Pegasus lossless jpeg header found\n"); 1568 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
1569 av_log(s->avctx, AV_LOG_INFO, "Pegasus lossless jpeg header found\n");
1567 skip_bits(&s->gb, 16); /* version ? */ 1570 skip_bits(&s->gb, 16); /* version ? */
1568 skip_bits(&s->gb, 16); /* unknwon always 0? */ 1571 skip_bits(&s->gb, 16); /* unknwon always 0? */
1569 skip_bits(&s->gb, 16); /* unknwon always 0? */ 1572 skip_bits(&s->gb, 16); /* unknwon always 0? */
1570 skip_bits(&s->gb, 16); /* unknwon always 0? */ 1573 skip_bits(&s->gb, 16); /* unknwon always 0? */
1571 switch( get_bits(&s->gb, 8)){ 1574 switch( get_bits(&s->gb, 8)){
1600 skip_bits(&s->gb, 32); /* huff off */ 1603 skip_bits(&s->gb, 32); /* huff off */
1601 skip_bits(&s->gb, 32); /* image off */ 1604 skip_bits(&s->gb, 32); /* image off */
1602 skip_bits(&s->gb, 32); /* scan off */ 1605 skip_bits(&s->gb, 32); /* scan off */
1603 skip_bits(&s->gb, 32); /* data off */ 1606 skip_bits(&s->gb, 32); /* data off */
1604 #endif 1607 #endif
1605 if (s->first_picture) 1608 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
1606 av_log(s->avctx, AV_LOG_INFO, "mjpeg: Apple MJPEG-A header found\n"); 1609 av_log(s->avctx, AV_LOG_INFO, "mjpeg: Apple MJPEG-A header found\n");
1607 } 1610 }
1608 } 1611 }
1609 1612
1610 out: 1613 out:
1777 } 1780 }
1778 1781
1779 /* process markers */ 1782 /* process markers */
1780 if (start_code >= 0xd0 && start_code <= 0xd7) { 1783 if (start_code >= 0xd0 && start_code <= 0xd7) {
1781 dprintf("restart marker: %d\n", start_code&0x0f); 1784 dprintf("restart marker: %d\n", start_code&0x0f);
1782 } else if (s->first_picture) {
1783 /* APP fields */ 1785 /* APP fields */
1784 if (start_code >= 0xe0 && start_code <= 0xef) 1786 } else if (start_code >= APP0 && start_code <= APP15) {
1785 mjpeg_decode_app(s); 1787 mjpeg_decode_app(s);
1786 /* Comment */ 1788 /* Comment */
1787 else if (start_code == COM) 1789 } else if (start_code == COM){
1788 mjpeg_decode_com(s); 1790 mjpeg_decode_com(s);
1789 } 1791 }
1790 1792
1791 switch(start_code) { 1793 switch(start_code) {
1792 case SOI: 1794 case SOI:
1793 s->restart_interval = 0; 1795 s->restart_interval = 0;