Commit 5b6d5596 authored by Michael Niedermayer's avatar Michael Niedermayer

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

Originally committed as revision 3668 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 6c3890b6
......@@ -255,6 +255,9 @@ static int nb_frames_dup = 0;
static int nb_frames_drop = 0;
static int input_sync;
static int pgmyuv_compatibility_hack=0;
#define DEFAULT_PASS_LOGFILENAME "ffmpeg2pass"
typedef struct AVOutputStream {
......@@ -2015,8 +2018,9 @@ static void opt_format(const char *arg)
{
/* compatibility stuff for pgmyuv */
if (!strcmp(arg, "pgmyuv")) {
pgmyuv_compatibility_hack=1;
opt_image_format(arg);
arg = "image";
arg = "image2";
}
file_iformat = av_find_input_format(arg);
......@@ -2782,6 +2786,10 @@ static void opt_input_file(const char *filename)
ap->device = grab_device;
ap->channel = video_channel;
ap->standard = video_standard;
ap->video_codec_id = video_codec_id;
ap->audio_codec_id = audio_codec_id;
if(pgmyuv_compatibility_hack)
ap->video_codec_id= CODEC_ID_PGMYUV;
/* open the input file with generic libav function */
err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
......@@ -3004,7 +3012,7 @@ static void opt_output_file(const char *filename)
int i;
AVCodec *codec;
codec_id = file_oformat->video_codec;
codec_id = av_guess_codec(file_oformat, NULL, filename, NULL, CODEC_TYPE_VIDEO);
if (video_codec_id != CODEC_ID_NONE)
codec_id = video_codec_id;
......@@ -3253,7 +3261,7 @@ static void opt_output_file(const char *filename)
st->stream_copy = 1;
audio_enc->channels = audio_channels;
} else {
codec_id = file_oformat->audio_codec;
codec_id = av_guess_codec(file_oformat, NULL, filename, NULL, CODEC_TYPE_AUDIO);
if (audio_codec_id != CODEC_ID_NONE)
codec_id = audio_codec_id;
audio_enc->codec_id = codec_id;
......
......@@ -21,7 +21,7 @@ OBJS= common.o utils.o mem.o allcodecs.o \
msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o faandct.o 8bps.o \
smc.o parser.o flicvideo.o truemotion1.o vmdav.o lcl.o qtrle.o g726.o \
flac.o vp3dsp.o integer.o snow.o tscc.o sonic.o ulti.o h264idct.o \
qdrw.o xl.o rangecoder.o png.o
qdrw.o xl.o rangecoder.o png.o pnm.o
ifeq ($(AMR_NB),yes)
ifeq ($(AMR_NB_FIXED),yes)
......
......@@ -77,6 +77,11 @@ void avcodec_register_all(void)
#ifdef CONFIG_ZLIB
register_avcodec(&png_encoder);
#endif
register_avcodec(&ppm_encoder);
register_avcodec(&pgm_encoder);
register_avcodec(&pgmyuv_encoder);
register_avcodec(&pbm_encoder);
register_avcodec(&pam_encoder);
register_avcodec(&huffyuv_encoder);
register_avcodec(&asv1_encoder);
register_avcodec(&asv2_encoder);
......
......@@ -154,6 +154,11 @@ enum CodecID {
CODEC_ID_XVID,
CODEC_ID_PNG,
CODEC_ID_PPM,
CODEC_ID_PBM,
CODEC_ID_PGM,
CODEC_ID_PGMYUV,
CODEC_ID_PAM,
};
/* CODEC_ID_MP3LAME is absolete */
......@@ -1798,6 +1803,11 @@ extern AVCodec dvvideo_encoder;
extern AVCodec mjpeg_encoder;
extern AVCodec ljpeg_encoder;
extern AVCodec png_encoder;
extern AVCodec ppm_encoder;
extern AVCodec pgm_encoder;
extern AVCodec pgmyuv_encoder;
extern AVCodec pbm_encoder;
extern AVCodec pam_encoder;
extern AVCodec mpeg4_encoder;
extern AVCodec msmpeg4v1_encoder;
extern AVCodec msmpeg4v2_encoder;
......
This diff is collapsed.
......@@ -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 @@ typedef struct AVFormatParameters {
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 @@ typedef struct AVImageFormat {
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 @@ AVOutputFormat *guess_stream_format(const char *short_name,
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);
......
......@@ -38,6 +38,11 @@ static const IdStrMap img_tags[] = {
{ 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 @@ static int image_probe(AVProbeData *p)
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 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
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;
......
......@@ -77,6 +77,11 @@ AVOutputFormat *guess_format(const char *short_name, const char *filename,
int score_max, score;
/* 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)) {
......@@ -125,6 +130,26 @@ AVOutputFormat *guess_stream_format(const char *short_name, const char *filename
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 @@ int av_find_stream_info(AVFormatContext *ic)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment