diff options
author | Francesco Lavra <francescolavra@interfree.it> | 2010-05-18 19:16:40 +0000 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@rainbow.studorg.tuwien.ac.at> | 2010-05-18 19:16:40 +0000 |
commit | 603a5f04b2da0622faab796307d7208ecde80603 (patch) | |
tree | 7995eda41969870c0a1fb0109bd18de4633340b0 | |
parent | b74f67eb17b3dae49cb42affa07b5c41ef09160e (diff) | |
download | ffmpeg-603a5f04b2da0622faab796307d7208ecde80603.tar.gz |
Factorize some code into the new function ff_toupper4().
Patch by Francesco Lavra, francescolavra interfree it
Originally committed as revision 23158 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/internal.h | 2 | ||||
-rw-r--r-- | libavcodec/mpegvideo.c | 13 | ||||
-rw-r--r-- | libavcodec/utils.c | 8 | ||||
-rw-r--r-- | libavformat/utils.c | 6 |
4 files changed, 16 insertions, 13 deletions
diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 97c0dcb3a6..67d5be7c3b 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -48,4 +48,6 @@ AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt); */ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); +unsigned int ff_toupper4(unsigned int x); + #endif /* AVCODEC_INTERNAL_H */ diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index e11fee8ffc..b5631cffc3 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -30,6 +30,7 @@ #include "libavutil/intmath.h" #include "avcodec.h" #include "dsputil.h" +#include "internal.h" #include "mpegvideo.h" #include "mpegvideo_common.h" #include "mjpegenc.h" @@ -530,15 +531,9 @@ av_cold int MPV_common_init(MpegEncContext *s) yc_size = y_size + 2 * c_size; /* convert fourcc to upper case */ - s->codec_tag= toupper( s->avctx->codec_tag &0xFF) - + (toupper((s->avctx->codec_tag>>8 )&0xFF)<<8 ) - + (toupper((s->avctx->codec_tag>>16)&0xFF)<<16) - + (toupper((s->avctx->codec_tag>>24)&0xFF)<<24); - - s->stream_codec_tag= toupper( s->avctx->stream_codec_tag &0xFF) - + (toupper((s->avctx->stream_codec_tag>>8 )&0xFF)<<8 ) - + (toupper((s->avctx->stream_codec_tag>>16)&0xFF)<<16) - + (toupper((s->avctx->stream_codec_tag>>24)&0xFF)<<24); + s->codec_tag = ff_toupper4(s->avctx->codec_tag); + + s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag); s->avctx->coded_frame= (AVFrame*)&s->current_picture; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 3badebe9bd..56d4dbd1dd 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1294,3 +1294,11 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) } return 0; } + +unsigned int ff_toupper4(unsigned int x) +{ + return toupper( x &0xFF) + + (toupper((x>>8 )&0xFF)<<8 ) + + (toupper((x>>16)&0xFF)<<16) + + (toupper((x>>24)&0xFF)<<24); +} diff --git a/libavformat/utils.c b/libavformat/utils.c index 1da1313e6e..73cecc9f0e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -20,6 +20,7 @@ */ #include "avformat.h" #include "internal.h" +#include "libavcodec/internal.h" #include "libavcodec/opt.h" #include "metadata.h" #include "libavutil/avstring.h" @@ -2041,10 +2042,7 @@ enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag) return tags[i].id; } for(i=0; tags[i].id != CODEC_ID_NONE; i++) { - if( toupper((tag >> 0)&0xFF) == toupper((tags[i].tag >> 0)&0xFF) - && toupper((tag >> 8)&0xFF) == toupper((tags[i].tag >> 8)&0xFF) - && toupper((tag >>16)&0xFF) == toupper((tags[i].tag >>16)&0xFF) - && toupper((tag >>24)&0xFF) == toupper((tags[i].tag >>24)&0xFF)) + if (ff_toupper4(tag) == ff_toupper4(tags[i].tag)) return tags[i].id; } return CODEC_ID_NONE; |