comparison utils.c @ 2243:639597604897 libavformat

Move public API functions av_codec_get_tag() and av_codec_get_id() into a file which is compiled un-conditionally (utils.c).
author aurel
date Wed, 11 Jul 2007 12:45:14 +0000
parents 824d41f03283
children 3677c1667194
comparison
equal deleted inserted replaced
2242:2ec2d6dca26e 2243:639597604897
20 */ 20 */
21 #include "avformat.h" 21 #include "avformat.h"
22 #include "allformats.h" 22 #include "allformats.h"
23 #include "opt.h" 23 #include "opt.h"
24 #include "avstring.h" 24 #include "avstring.h"
25 #include "riff.h"
25 26
26 #undef NDEBUG 27 #undef NDEBUG
27 #include <assert.h> 28 #include <assert.h>
28 29
29 /** 30 /**
1652 st->codec->codec_id = CODEC_ID_MP3; 1653 st->codec->codec_id = CODEC_ID_MP3;
1653 else if (strncmp(fmt->name, "ac3", 3) == 0) 1654 else if (strncmp(fmt->name, "ac3", 3) == 0)
1654 st->codec->codec_id = CODEC_ID_AC3; 1655 st->codec->codec_id = CODEC_ID_AC3;
1655 } 1656 }
1656 return !!fmt; 1657 return !!fmt;
1658 }
1659
1660 unsigned int codec_get_tag(const AVCodecTag *tags, int id)
1661 {
1662 while (tags->id != CODEC_ID_NONE) {
1663 if (tags->id == id)
1664 return tags->tag;
1665 tags++;
1666 }
1667 return 0;
1668 }
1669
1670 enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
1671 {
1672 while (tags->id != CODEC_ID_NONE) {
1673 if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
1674 && toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
1675 && toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
1676 && toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
1677 return tags->id;
1678 tags++;
1679 }
1680 return CODEC_ID_NONE;
1681 }
1682
1683 unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
1684 {
1685 int i;
1686 for(i=0; tags && tags[i]; i++){
1687 int tag= codec_get_tag(tags[i], id);
1688 if(tag) return tag;
1689 }
1690 return 0;
1691 }
1692
1693 enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
1694 {
1695 int i;
1696 for(i=0; tags && tags[i]; i++){
1697 enum CodecID id= codec_get_id(tags[i], tag);
1698 if(id!=CODEC_ID_NONE) return id;
1699 }
1700 return CODEC_ID_NONE;
1657 } 1701 }
1658 1702
1659 /* absolute maximum size we read until we abort */ 1703 /* absolute maximum size we read until we abort */
1660 #define MAX_READ_SIZE 5000000 1704 #define MAX_READ_SIZE 5000000
1661 1705