comparison mov.c @ 3253:ab5585778359 libavformat

cosmetics, remove whitespaces in tags
author bcoudurier
date Fri, 25 Apr 2008 11:57:39 +0000
parents f4fcd39c5d7f
children 8fb1e55e0a66
comparison
equal deleted inserted replaced
3252:f4fcd39c5d7f 3253:ab5585778359
314 ((char *)&ctype)[2], ((char *)&ctype)[3], (int) ctype); 314 ((char *)&ctype)[2], ((char *)&ctype)[3], (int) ctype);
315 dprintf(c->fc, "stype= %c%c%c%c\n", 315 dprintf(c->fc, "stype= %c%c%c%c\n",
316 *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]); 316 *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
317 if(!ctype) 317 if(!ctype)
318 c->isom = 1; 318 c->isom = 1;
319 if(type == MKTAG('v', 'i', 'd', 'e')) 319 if (type == MKTAG('v','i','d','e'))
320 st->codec->codec_type = CODEC_TYPE_VIDEO; 320 st->codec->codec_type = CODEC_TYPE_VIDEO;
321 else if(type == MKTAG('s', 'o', 'u', 'n')) 321 else if(type == MKTAG('s','o','u','n'))
322 st->codec->codec_type = CODEC_TYPE_AUDIO; 322 st->codec->codec_type = CODEC_TYPE_AUDIO;
323 else if(type == MKTAG('m', '1', 'a', ' ')) 323 else if(type == MKTAG('m','1','a',' '))
324 st->codec->codec_id = CODEC_ID_MP2; 324 st->codec->codec_id = CODEC_ID_MP2;
325 else if(type == MKTAG('s', 'u', 'b', 'p')) { 325 else if(type == MKTAG('s','u','b','p')) {
326 st->codec->codec_type = CODEC_TYPE_SUBTITLE; 326 st->codec->codec_type = CODEC_TYPE_SUBTITLE;
327 } 327 }
328 get_be32(pb); /* component manufacture */ 328 get_be32(pb); /* component manufacture */
329 get_be32(pb); /* component flags */ 329 get_be32(pb); /* component flags */
330 get_be32(pb); /* component flags mask */ 330 get_be32(pb); /* component flags mask */
627 627
628 sc->chunk_count = entries; 628 sc->chunk_count = entries;
629 sc->chunk_offsets = av_malloc(entries * sizeof(int64_t)); 629 sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
630 if (!sc->chunk_offsets) 630 if (!sc->chunk_offsets)
631 return -1; 631 return -1;
632 if (atom.type == MKTAG('s', 't', 'c', 'o')) { 632 if (atom.type == MKTAG('s','t','c','o')) {
633 for(i=0; i<entries; i++) { 633 for(i=0; i<entries; i++) {
634 sc->chunk_offsets[i] = get_be32(pb); 634 sc->chunk_offsets[i] = get_be32(pb);
635 } 635 }
636 } else if (atom.type == MKTAG('c', 'o', '6', '4')) { 636 } else if (atom.type == MKTAG('c','o','6','4')) {
637 for(i=0; i<entries; i++) { 637 for(i=0; i<entries; i++) {
638 sc->chunk_offsets[i] = get_be64(pb); 638 sc->chunk_offsets[i] = get_be64(pb);
639 } 639 }
640 } else 640 } else
641 return -1; 641 return -1;
681 get_be16(pb); /* reserved */ 681 get_be16(pb); /* reserved */
682 dref_id = get_be16(pb); 682 dref_id = get_be16(pb);
683 683
684 if (st->codec->codec_tag && 684 if (st->codec->codec_tag &&
685 (c->fc->video_codec_id ? codec_get_id(codec_movvideo_tags, format) != c->fc->video_codec_id 685 (c->fc->video_codec_id ? codec_get_id(codec_movvideo_tags, format) != c->fc->video_codec_id
686 : st->codec->codec_tag != MKTAG('j', 'p', 'e', 'g')) 686 : st->codec->codec_tag != MKTAG('j','p','e','g'))
687 ){ 687 ){
688 /* Multiple fourcc, we skip JPEG. This is not correct, we should 688 /* Multiple fourcc, we skip JPEG. This is not correct, we should
689 * export it as a separate AVStream but this needs a few changes 689 * export it as a separate AVStream but this needs a few changes
690 * in the MOV demuxer, patch welcome. */ 690 * in the MOV demuxer, patch welcome. */
691 url_fskip(pb, size - (url_ftell(pb) - start_pos)); 691 url_fskip(pb, size - (url_ftell(pb) - start_pos));
694 sc->pseudo_stream_id= pseudo_stream_id; 694 sc->pseudo_stream_id= pseudo_stream_id;
695 sc->dref_id= dref_id; 695 sc->dref_id= dref_id;
696 696
697 st->codec->codec_tag = format; 697 st->codec->codec_tag = format;
698 id = codec_get_id(codec_movaudio_tags, format); 698 id = codec_get_id(codec_movaudio_tags, format);
699 if (id<=0 && (format&0xFFFF) == 'm' + ('s'<<8)) 699 if (id<=0 && (format&0xFFFF) == 'm'+('s'<<8))
700 id = codec_get_id(codec_wav_tags, bswap_32(format)&0xFFFF); 700 id = codec_get_id(codec_wav_tags, bswap_32(format)&0xFFFF);
701 701
702 if (st->codec->codec_type != CODEC_TYPE_VIDEO && id > 0) { 702 if (st->codec->codec_type != CODEC_TYPE_VIDEO && id > 0) {
703 st->codec->codec_type = CODEC_TYPE_AUDIO; 703 st->codec->codec_type = CODEC_TYPE_AUDIO;
704 } else if (st->codec->codec_type != CODEC_TYPE_AUDIO && /* do not overwrite codec type */ 704 } else if (st->codec->codec_type != CODEC_TYPE_AUDIO && /* do not overwrite codec type */
705 format && format != MKTAG('m', 'p', '4', 's')) { /* skip old asf mpeg4 tag */ 705 format && format != MKTAG('m','p','4','s')) { /* skip old asf mpeg4 tag */
706 id = codec_get_id(codec_movvideo_tags, format); 706 id = codec_get_id(codec_movvideo_tags, format);
707 if (id <= 0) 707 if (id <= 0)
708 id = codec_get_id(codec_bmp_tags, format); 708 id = codec_get_id(codec_bmp_tags, format);
709 if (id > 0) 709 if (id > 0)
710 st->codec->codec_type = CODEC_TYPE_VIDEO; 710 st->codec->codec_type = CODEC_TYPE_VIDEO;
1533 return 0; 1533 return 0;
1534 } 1534 }
1535 atom.type = get_le32(pb); 1535 atom.type = get_le32(pb);
1536 atom.offset += 8; 1536 atom.offset += 8;
1537 atom.size -= 8; 1537 atom.size -= 8;
1538 if (atom.type != MKTAG('m', 'd', 'a', 't')) { 1538 if (atom.type != MKTAG('m','d','a','t')) {
1539 url_fskip(pb, atom.size); 1539 url_fskip(pb, atom.size);
1540 return 0; 1540 return 0;
1541 } 1541 }
1542 err = mov_read_mdat(c, pb, atom); 1542 err = mov_read_mdat(c, pb, atom);
1543 return err; 1543 return err;
1551 uint8_t *moov_data; /* uncompressed data */ 1551 uint8_t *moov_data; /* uncompressed data */
1552 long cmov_len, moov_len; 1552 long cmov_len, moov_len;
1553 int ret; 1553 int ret;
1554 1554
1555 get_be32(pb); /* dcom atom */ 1555 get_be32(pb); /* dcom atom */
1556 if (get_le32(pb) != MKTAG( 'd', 'c', 'o', 'm' )) 1556 if (get_le32(pb) != MKTAG('d','c','o','m'))
1557 return -1; 1557 return -1;
1558 if (get_le32(pb) != MKTAG( 'z', 'l', 'i', 'b' )) { 1558 if (get_le32(pb) != MKTAG('z','l','i','b')) {
1559 av_log(NULL, AV_LOG_ERROR, "unknown compression for cmov atom !"); 1559 av_log(NULL, AV_LOG_ERROR, "unknown compression for cmov atom !");
1560 return -1; 1560 return -1;
1561 } 1561 }
1562 get_be32(pb); /* cmvd atom */ 1562 get_be32(pb); /* cmvd atom */
1563 if (get_le32(pb) != MKTAG( 'c', 'm', 'v', 'd' )) 1563 if (get_le32(pb) != MKTAG('c','m','v','d'))
1564 return -1; 1564 return -1;
1565 moov_len = get_be32(pb); /* uncompressed size */ 1565 moov_len = get_be32(pb); /* uncompressed size */
1566 cmov_len = atom.size - 6 * 4; 1566 cmov_len = atom.size - 6 * 4;
1567 1567
1568 cmov_data = av_malloc(cmov_len); 1568 cmov_data = av_malloc(cmov_len);
1576 get_buffer(pb, cmov_data, cmov_len); 1576 get_buffer(pb, cmov_data, cmov_len);
1577 if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) 1577 if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
1578 return -1; 1578 return -1;
1579 if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) 1579 if(init_put_byte(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
1580 return -1; 1580 return -1;
1581 atom.type = MKTAG( 'm', 'o', 'o', 'v' ); 1581 atom.type = MKTAG('m','o','o','v');
1582 atom.offset = 0; 1582 atom.offset = 0;
1583 atom.size = moov_len; 1583 atom.size = moov_len;
1584 #ifdef DEBUG 1584 #ifdef DEBUG
1585 // { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); } 1585 // { int fd = open("/tmp/uncompheader.mov", O_WRONLY | O_CREAT); write(fd, moov_data, moov_len); close(fd); }
1586 #endif 1586 #endif
1616 dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, sc->edit_count); 1616 dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, sc->edit_count);
1617 return 0; 1617 return 0;
1618 } 1618 }
1619 1619
1620 static const MOVParseTableEntry mov_default_parse_table[] = { 1620 static const MOVParseTableEntry mov_default_parse_table[] = {
1621 { MKTAG( 'c', 'o', '6', '4' ), mov_read_stco }, 1621 { MKTAG('c','o','6','4'), mov_read_stco },
1622 { MKTAG( 'c', 't', 't', 's' ), mov_read_ctts }, /* composition time to sample */ 1622 { MKTAG('c','t','t','s'), mov_read_ctts }, /* composition time to sample */
1623 { MKTAG( 'd', 'i', 'n', 'f' ), mov_read_default }, 1623 { MKTAG('d','i','n','f'), mov_read_default },
1624 { MKTAG( 'd', 'r', 'e', 'f' ), mov_read_dref }, 1624 { MKTAG('d','r','e','f'), mov_read_dref },
1625 { MKTAG( 'e', 'd', 't', 's' ), mov_read_default }, 1625 { MKTAG('e','d','t','s'), mov_read_default },
1626 { MKTAG( 'e', 'l', 's', 't' ), mov_read_elst }, 1626 { MKTAG('e','l','s','t'), mov_read_elst },
1627 { MKTAG( 'e', 'n', 'd', 'a' ), mov_read_enda }, 1627 { MKTAG('e','n','d','a'), mov_read_enda },
1628 { MKTAG( 'f', 'i', 'e', 'l' ), mov_read_extradata }, 1628 { MKTAG('f','i','e','l'), mov_read_extradata },
1629 { MKTAG( 'f', 't', 'y', 'p' ), mov_read_ftyp }, 1629 { MKTAG('f','t','y','p'), mov_read_ftyp },
1630 { MKTAG( 'g', 'l', 'b', 'l' ), mov_read_glbl }, 1630 { MKTAG('g','l','b','l'), mov_read_glbl },
1631 { MKTAG( 'h', 'd', 'l', 'r' ), mov_read_hdlr }, 1631 { MKTAG('h','d','l','r'), mov_read_hdlr },
1632 { MKTAG( 'j', 'p', '2', 'h' ), mov_read_extradata }, 1632 { MKTAG('j','p','2','h'), mov_read_extradata },
1633 { MKTAG( 'm', 'd', 'a', 't' ), mov_read_mdat }, 1633 { MKTAG('m','d','a','t'), mov_read_mdat },
1634 { MKTAG( 'm', 'd', 'h', 'd' ), mov_read_mdhd }, 1634 { MKTAG('m','d','h','d'), mov_read_mdhd },
1635 { MKTAG( 'm', 'd', 'i', 'a' ), mov_read_default }, 1635 { MKTAG('m','d','i','a'), mov_read_default },
1636 { MKTAG( 'm', 'i', 'n', 'f' ), mov_read_default }, 1636 { MKTAG('m','i','n','f'), mov_read_default },
1637 { MKTAG( 'm', 'o', 'o', 'f' ), mov_read_moof }, 1637 { MKTAG('m','o','o','f'), mov_read_moof },
1638 { MKTAG( 'm', 'o', 'o', 'v' ), mov_read_moov }, 1638 { MKTAG('m','o','o','v'), mov_read_moov },
1639 { MKTAG( 'm', 'v', 'e', 'x' ), mov_read_default }, 1639 { MKTAG('m','v','e','x'), mov_read_default },
1640 { MKTAG( 'm', 'v', 'h', 'd' ), mov_read_mvhd }, 1640 { MKTAG('m','v','h','d'), mov_read_mvhd },
1641 { MKTAG( 'S', 'M', 'I', ' ' ), mov_read_smi }, /* Sorenson extension ??? */ 1641 { MKTAG('S','M','I',' '), mov_read_smi }, /* Sorenson extension ??? */
1642 { MKTAG( 'a', 'l', 'a', 'c' ), mov_read_extradata }, /* alac specific atom */ 1642 { MKTAG('a','l','a','c'), mov_read_extradata }, /* alac specific atom */
1643 { MKTAG( 'a', 'v', 'c', 'C' ), mov_read_glbl }, 1643 { MKTAG('a','v','c','C'), mov_read_glbl },
1644 { MKTAG( 's', 't', 'b', 'l' ), mov_read_default }, 1644 { MKTAG('s','t','b','l'), mov_read_default },
1645 { MKTAG( 's', 't', 'c', 'o' ), mov_read_stco }, 1645 { MKTAG('s','t','c','o'), mov_read_stco },
1646 { MKTAG( 's', 't', 's', 'c' ), mov_read_stsc }, 1646 { MKTAG('s','t','s','c'), mov_read_stsc },
1647 { MKTAG( 's', 't', 's', 'd' ), mov_read_stsd }, /* sample description */ 1647 { MKTAG('s','t','s','d'), mov_read_stsd }, /* sample description */
1648 { MKTAG( 's', 't', 's', 's' ), mov_read_stss }, /* sync sample */ 1648 { MKTAG('s','t','s','s'), mov_read_stss }, /* sync sample */
1649 { MKTAG( 's', 't', 's', 'z' ), mov_read_stsz }, /* sample size */ 1649 { MKTAG('s','t','s','z'), mov_read_stsz }, /* sample size */
1650 { MKTAG( 's', 't', 't', 's' ), mov_read_stts }, 1650 { MKTAG('s','t','t','s'), mov_read_stts },
1651 { MKTAG( 't', 'k', 'h', 'd' ), mov_read_tkhd }, /* track header */ 1651 { MKTAG('t','k','h','d'), mov_read_tkhd }, /* track header */
1652 { MKTAG( 't', 'f', 'h', 'd' ), mov_read_tfhd }, /* track fragment header */ 1652 { MKTAG('t','f','h','d'), mov_read_tfhd }, /* track fragment header */
1653 { MKTAG( 't', 'r', 'a', 'k' ), mov_read_trak }, 1653 { MKTAG('t','r','a','k'), mov_read_trak },
1654 { MKTAG( 't', 'r', 'a', 'f' ), mov_read_default }, 1654 { MKTAG('t','r','a','f'), mov_read_default },
1655 { MKTAG( 't', 'r', 'e', 'x' ), mov_read_trex }, 1655 { MKTAG('t','r','e','x'), mov_read_trex },
1656 { MKTAG( 't', 'r', 'u', 'n' ), mov_read_trun }, 1656 { MKTAG('t','r','u','n'), mov_read_trun },
1657 { MKTAG( 'u', 'd', 't', 'a' ), mov_read_udta }, 1657 { MKTAG('u','d','t','a'), mov_read_udta },
1658 { MKTAG( 'w', 'a', 'v', 'e' ), mov_read_wave }, 1658 { MKTAG('w','a','v','e'), mov_read_wave },
1659 { MKTAG( 'e', 's', 'd', 's' ), mov_read_esds }, 1659 { MKTAG('e','s','d','s'), mov_read_esds },
1660 { MKTAG( 'w', 'i', 'd', 'e' ), mov_read_wide }, /* place holder */ 1660 { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */
1661 { MKTAG( 'c', 'm', 'o', 'v' ), mov_read_cmov }, 1661 { MKTAG('c','m','o','v'), mov_read_cmov },
1662 { 0, NULL } 1662 { 0, NULL }
1663 }; 1663 };
1664 1664
1665 static int mov_probe(AVProbeData *p) 1665 static int mov_probe(AVProbeData *p)
1666 { 1666 {
1675 if ((offset + 8) > (unsigned int)p->buf_size) 1675 if ((offset + 8) > (unsigned int)p->buf_size)
1676 return score; 1676 return score;
1677 tag = AV_RL32(p->buf + offset + 4); 1677 tag = AV_RL32(p->buf + offset + 4);
1678 switch(tag) { 1678 switch(tag) {
1679 /* check for obvious tags */ 1679 /* check for obvious tags */
1680 case MKTAG( 'j', 'P', ' ', ' ' ): /* jpeg 2000 signature */ 1680 case MKTAG('j','P',' ',' '): /* jpeg 2000 signature */
1681 case MKTAG( 'm', 'o', 'o', 'v' ): 1681 case MKTAG('m','o','o','v'):
1682 case MKTAG( 'm', 'd', 'a', 't' ): 1682 case MKTAG('m','d','a','t'):
1683 case MKTAG( 'p', 'n', 'o', 't' ): /* detect movs with preview pics like ew.mov and april.mov */ 1683 case MKTAG('p','n','o','t'): /* detect movs with preview pics like ew.mov and april.mov */
1684 case MKTAG( 'u', 'd', 't', 'a' ): /* Packet Video PVAuthor adds this and a lot of more junk */ 1684 case MKTAG('u','d','t','a'): /* Packet Video PVAuthor adds this and a lot of more junk */
1685 return AVPROBE_SCORE_MAX; 1685 return AVPROBE_SCORE_MAX;
1686 /* those are more common words, so rate then a bit less */ 1686 /* those are more common words, so rate then a bit less */
1687 case MKTAG( 'e', 'd', 'i', 'w' ): /* xdcam files have reverted first tags */ 1687 case MKTAG('e','d','i','w'): /* xdcam files have reverted first tags */
1688 case MKTAG( 'w', 'i', 'd', 'e' ): 1688 case MKTAG('w','i','d','e'):
1689 case MKTAG( 'f', 'r', 'e', 'e' ): 1689 case MKTAG('f','r','e','e'):
1690 case MKTAG( 'j', 'u', 'n', 'k' ): 1690 case MKTAG('j','u','n','k'):
1691 case MKTAG( 'p', 'i', 'c', 't' ): 1691 case MKTAG('p','i','c','t'):
1692 return AVPROBE_SCORE_MAX - 5; 1692 return AVPROBE_SCORE_MAX - 5;
1693 case MKTAG(0x82,0x82,0x7f,0x7d ): 1693 case MKTAG(0x82,0x82,0x7f,0x7d ):
1694 case MKTAG( 'f', 't', 'y', 'p' ): 1694 case MKTAG('f','t','y','p'):
1695 case MKTAG( 's', 'k', 'i', 'p' ): 1695 case MKTAG('s','k','i','p'):
1696 case MKTAG( 'u', 'u', 'i', 'd' ): 1696 case MKTAG('u','u','i','d'):
1697 case MKTAG( 'p', 'r', 'f', 'l' ): 1697 case MKTAG('p','r','f','l'):
1698 offset = AV_RB32(p->buf+offset) + offset; 1698 offset = AV_RB32(p->buf+offset) + offset;
1699 /* if we only find those cause probedata is too small at least rate them */ 1699 /* if we only find those cause probedata is too small at least rate them */
1700 score = AVPROBE_SCORE_MAX - 50; 1700 score = AVPROBE_SCORE_MAX - 50;
1701 break; 1701 break;
1702 default: 1702 default: