diff options
author | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-01-17 20:44:33 +0100 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-01-17 20:44:33 +0100 |
commit | a1a707f7280a08d6686732e1ab911dd44663889c (patch) | |
tree | ddcfa0aba483313a242199756ade82fd4d803737 /libavformat/utils.c | |
parent | 8fdd24455e9793d8b72c63fe06059e20ec267c9f (diff) | |
download | ffmpeg-a1a707f7280a08d6686732e1ab911dd44663889c.tar.gz |
Add a new function av_codec_get_tag2().
av_codec_get_tag() may return 0 both in case a codec_tag was
found and if no codec_tag was found.
The new function does not have this ambiguity.
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index d43e1c0adc..576713adfd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2584,10 +2584,25 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags) unsigned int av_codec_get_tag(const AVCodecTag * const *tags, enum AVCodecID id) { + unsigned int tag; + if (!av_codec_get_tag2(tags, id, &tag)) + return 0; + return tag; +} + +int av_codec_get_tag2(const AVCodecTag * const *tags, enum AVCodecID id, + unsigned int *tag) +{ int i; for(i=0; tags && tags[i]; i++){ - int tag= ff_codec_get_tag(tags[i], id); - if(tag) return tag; + const AVCodecTag *codec_tags = tags[i]; + while (codec_tags->id != AV_CODEC_ID_NONE) { + if (codec_tags->id == id) { + *tag = codec_tags->tag; + return 1; + } + codec_tags++; + } } return 0; } |