Mercurial > libavformat.hg
changeset 583:7793767ffe35 libavformat
move p*m from image/lavf -> image2/lavc
video/audio_codec_id in AVFormatParameters to override/help demuxer
av_guess_codec() to guess the default codecs based upon muxer + filename
author | michael |
---|---|
date | Thu, 11 Nov 2004 18:09:28 +0000 |
parents | c5ff083848b4 |
children | 4e3bab6555ae |
files | avformat.h img2.c utils.c |
diffstat | 3 files changed, 55 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/avformat.h Wed Nov 10 00:02:06 2004 +0000 +++ b/avformat.h Thu Nov 11 18:09:28 2004 +0000 @@ -5,7 +5,7 @@ extern "C" { #endif -#define LIBAVFORMAT_BUILD 4620 +#define LIBAVFORMAT_BUILD 4621 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT #define LIBAVFORMAT_VERSION FFMPEG_VERSION @@ -115,6 +115,8 @@ mpeg2ts_raw is TRUE */ int initial_pause:1; /* do not begin to play the stream immediately (RTSP only) */ + enum CodecID video_codec_id; + enum CodecID audio_codec_id; } AVFormatParameters; #define AVFMT_NOFILE 0x0001 /* no file should be opened */ @@ -358,6 +360,7 @@ void av_register_image_format(AVImageFormat *img_fmt); AVImageFormat *av_probe_image_format(AVProbeData *pd); AVImageFormat *guess_image_format(const char *filename); +enum CodecID av_guess_image2_codec(const char *filename); int av_read_image(ByteIOContext *pb, const char *filename, AVImageFormat *fmt, int (*alloc_cb)(void *, AVImageInfo *info), void *opaque); @@ -521,6 +524,8 @@ const char *filename, const char *mime_type); AVOutputFormat *guess_format(const char *short_name, const char *filename, const char *mime_type); +enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, + const char *filename, const char *mime_type, enum CodecType type); void av_hex_dump(FILE *f, uint8_t *buf, int size); void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
--- a/img2.c Wed Nov 10 00:02:06 2004 +0000 +++ b/img2.c Thu Nov 11 18:09:28 2004 +0000 @@ -38,6 +38,11 @@ { CODEC_ID_MJPEG , "jpg"}, { CODEC_ID_LJPEG , "ljpg"}, { CODEC_ID_PNG , "png"}, + { CODEC_ID_PPM , "ppm"}, + { CODEC_ID_PGM , "pgm"}, + { CODEC_ID_PGMYUV , "pgmyuv"}, + { CODEC_ID_PBM , "pbm"}, + { CODEC_ID_PAM , "pam"}, { CODEC_ID_MPEG1VIDEO, "mpg1-img"}, { CODEC_ID_MPEG2VIDEO, "mpg2-img"}, { CODEC_ID_MPEG4 , "mpg4-img"}, @@ -133,6 +138,10 @@ return 0; } +enum CodecID av_guess_image2_codec(const char *filename){ + return av_str2id(img_tags, filename); +} + static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) { VideoData *s = s1->priv_data; @@ -180,8 +189,16 @@ st->codec.frame_rate_base) / st->codec.frame_rate; } - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = av_str2id(img_tags, s->path); + if(ap->video_codec_id){ + st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec.codec_id = ap->video_codec_id; + }else if(ap->audio_codec_id){ + st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec.codec_id = ap->audio_codec_id; + }else{ + st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec.codec_id = av_str2id(img_tags, s->path); + } return 0;
--- a/utils.c Wed Nov 10 00:02:06 2004 +0000 +++ b/utils.c Thu Nov 11 18:09:28 2004 +0000 @@ -79,6 +79,11 @@ /* specific test for image sequences */ if (!short_name && filename && filename_number_test(filename) >= 0 && + av_guess_image2_codec(filename) != CODEC_ID_NONE) { + return guess_format("image2", NULL, NULL); + } + if (!short_name && filename && + filename_number_test(filename) >= 0 && guess_image_format(filename)) { return guess_format("image", NULL, NULL); } @@ -125,6 +130,26 @@ return fmt; } +/** + * guesses the codec id based upon muxer and filename. + */ +enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, + const char *filename, const char *mime_type, enum CodecType type){ + if(type == CODEC_TYPE_VIDEO){ + enum CodecID codec_id= CODEC_ID_NONE; + + if(!strcmp(fmt->name, "image2")){ + codec_id= av_guess_image2_codec(filename); + } + if(codec_id == CODEC_ID_NONE) + codec_id= fmt->video_codec; + return codec_id; + }else if(type == CODEC_TYPE_AUDIO) + return fmt->audio_codec; + else + return CODEC_ID_NONE; +} + AVInputFormat *av_find_input_format(const char *short_name) { AVInputFormat *fmt; @@ -1740,6 +1765,11 @@ st->codec.codec_id == CODEC_ID_VORBIS || st->codec.codec_id == CODEC_ID_MJPEG || st->codec.codec_id == CODEC_ID_PNG || + st->codec.codec_id == CODEC_ID_PAM || + st->codec.codec_id == CODEC_ID_PGM || + st->codec.codec_id == CODEC_ID_PGMYUV || + st->codec.codec_id == CODEC_ID_PBM || + st->codec.codec_id == CODEC_ID_PPM || (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))) try_decode_frame(st, pkt->data, pkt->size);