diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-03-30 23:30:55 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-03-30 23:30:55 +0000 |
commit | 72415b2adb2c25f95ceede49001bb97ed9247dbb (patch) | |
tree | 99247889aa61bb7621c966466ea4b84c100207d3 /libavformat/utils.c | |
parent | ca6e7708b42e7d33ba3053bcd447d52a077bca25 (diff) | |
download | ffmpeg-72415b2adb2c25f95ceede49001bb97ed9247dbb.tar.gz |
Define AVMediaType enum, and use it instead of enum CodecType, which
is deprecated and will be dropped at the next major bump.
Originally committed as revision 22735 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index b29e65d93c..8b57b39d59 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -254,8 +254,8 @@ AVOutputFormat *guess_stream_format(const char *short_name, const char *filename #endif 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){ + const char *filename, const char *mime_type, enum AVMediaType type){ + if(type == AVMEDIA_TYPE_VIDEO){ enum CodecID codec_id= CODEC_ID_NONE; #if CONFIG_IMAGE2_MUXER @@ -266,7 +266,7 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, if(codec_id == CODEC_ID_NONE) codec_id= fmt->video_codec; return codec_id; - }else if(type == CODEC_TYPE_AUDIO) + }else if(type == AVMEDIA_TYPE_AUDIO) return fmt->audio_codec; else return CODEC_ID_NONE; @@ -351,25 +351,25 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, AVProbeDa pd->buf_size, MAX_PROBE_PACKETS - st->probe_packets, fmt->name, score); if (!strcmp(fmt->name, "mp3")) { st->codec->codec_id = CODEC_ID_MP3; - st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; } else if (!strcmp(fmt->name, "ac3")) { st->codec->codec_id = CODEC_ID_AC3; - st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; } else if (!strcmp(fmt->name, "eac3")) { st->codec->codec_id = CODEC_ID_EAC3; - st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; } else if (!strcmp(fmt->name, "mpegvideo")) { st->codec->codec_id = CODEC_ID_MPEG2VIDEO; - st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(fmt->name, "m4v")) { st->codec->codec_id = CODEC_ID_MPEG4; - st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(fmt->name, "h264")) { st->codec->codec_id = CODEC_ID_H264; - st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(fmt->name, "dts")) { st->codec->codec_id = CODEC_ID_DTS; - st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; } } return !!fmt; @@ -646,13 +646,13 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt) st= s->streams[pkt->stream_index]; switch(st->codec->codec_type){ - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: if(s->video_codec_id) st->codec->codec_id= s->video_codec_id; break; - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id; break; - case CODEC_TYPE_SUBTITLE: + case AVMEDIA_TYPE_SUBTITLE: if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id; break; } @@ -729,7 +729,7 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, *pnum = 0; *pden = 0; switch(st->codec->codec_type) { - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: if(st->time_base.num*1000LL > st->time_base.den){ *pnum = st->time_base.num; *pden = st->time_base.den; @@ -741,7 +741,7 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, } } break; - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: frame_size = get_audio_frame_size(st->codec, pkt->size); if (frame_size < 0) break; @@ -754,9 +754,9 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, } static int is_intra_only(AVCodecContext *enc){ - if(enc->codec_type == CODEC_TYPE_AUDIO){ + if(enc->codec_type == AVMEDIA_TYPE_AUDIO){ return 1; - }else if(enc->codec_type == CODEC_TYPE_VIDEO){ + }else if(enc->codec_type == AVMEDIA_TYPE_VIDEO){ switch(enc->codec_id){ case CODEC_ID_MJPEG: case CODEC_ID_MJPEGB: @@ -1223,10 +1223,10 @@ int av_find_default_stream_index(AVFormatContext *s) return -1; for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; - if (st->codec->codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { return i; } - if (first_audio_index < 0 && st->codec->codec_type == CODEC_TYPE_AUDIO) + if (first_audio_index < 0 && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) first_audio_index = i; } return first_audio_index >= 0 ? first_audio_index : 0; @@ -1953,7 +1953,7 @@ static int has_codec_parameters(AVCodecContext *enc) { int val; switch(enc->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: val = enc->sample_rate && enc->channels && enc->sample_fmt != SAMPLE_FMT_NONE; if(!enc->frame_size && (enc->codec_id == CODEC_ID_VORBIS || @@ -1964,7 +1964,7 @@ static int has_codec_parameters(AVCodecContext *enc) enc->codec_id == CODEC_ID_SPEEX)) return 0; break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: val = enc->width && enc->pix_fmt != PIX_FMT_NONE; break; default: @@ -1992,12 +1992,12 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt) if(!has_codec_parameters(st->codec)){ switch(st->codec->codec_type) { - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: avcodec_get_frame_defaults(&picture); ret = avcodec_decode_video2(st->codec, &picture, &got_picture, avpkt); break; - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE); samples = av_malloc(data_size); if (!samples) @@ -2129,7 +2129,7 @@ int av_find_stream_info(AVFormatContext *ic) st->codec->frame_size = 0; st->codec->channels = 0; } - if(st->codec->codec_type == CODEC_TYPE_VIDEO){ + if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ /* if(!st->time_base.num) st->time_base= */ if(!st->codec->time_base.num) @@ -2171,7 +2171,7 @@ int av_find_stream_info(AVFormatContext *ic) break; /* variable fps and no guess at the real fps */ if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num) - && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO) + && duration_count[i]<20 && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) break; if(st->parser && st->parser->parser->split && !st->codec->extradata) break; @@ -2243,7 +2243,7 @@ int av_find_stream_info(AVFormatContext *ic) if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){ double dur= duration * av_q2d(st->time_base); -// if(st->codec->codec_type == CODEC_TYPE_VIDEO) +// if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); if(duration_count[index] < 2) memset(duration_error[index], 0, sizeof(*duration_error)); @@ -2293,7 +2293,7 @@ int av_find_stream_info(AVFormatContext *ic) av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den, codec_info_duration[i] *(int64_t)st->time_base.num, 60000); - if (st->codec->codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample) st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); @@ -2312,7 +2312,7 @@ int av_find_stream_info(AVFormatContext *ic) for(j=1; j<MAX_STD_TIMEBASES; j++){ double error= duration_error[i][j] * get_std_framerate(j); -// if(st->codec->codec_type == CODEC_TYPE_VIDEO) +// if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f %f\n", get_std_framerate(j) / 12.0/1001, error); if(error < best_error){ best_error= error; @@ -2334,7 +2334,7 @@ int av_find_stream_info(AVFormatContext *ic) st->r_frame_rate.den = st->time_base.num; } } - }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) { + }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if(!st->codec->bits_per_coded_sample) st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id); } @@ -2348,7 +2348,7 @@ int av_find_stream_info(AVFormatContext *ic) /* correct DTS for B-frame streams with no timestamps */ for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - if (st->codec->codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if(b-frames){ ppktl = &ic->packet_buffer; while(ppkt1){ @@ -2581,7 +2581,7 @@ int av_write_header(AVFormatContext *s) st = s->streams[i]; switch (st->codec->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: if(st->codec->sample_rate<=0){ av_log(s, AV_LOG_ERROR, "sample rate not set\n"); return -1; @@ -2590,7 +2590,7 @@ int av_write_header(AVFormatContext *s) st->codec->block_align = st->codec->channels * av_get_bits_per_sample(st->codec->codec_id) >> 3; break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ //FIXME audio too? av_log(s, AV_LOG_ERROR, "time base not set\n"); return -1; @@ -2658,10 +2658,10 @@ int av_write_header(AVFormatContext *s) st = s->streams[i]; switch (st->codec->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: den = (int64_t)st->time_base.num * st->codec->sample_rate; break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: den = (int64_t)st->time_base.num * st->codec->time_base.den; break; default: @@ -2732,7 +2732,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ /* update pts */ switch (st->codec->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: frame_size = get_audio_frame_size(st->codec, pkt->size); /* HACK/FIXME, we skip the initial 0 size packets as they are most @@ -2742,7 +2742,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); } break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num); break; default: @@ -2859,7 +2859,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ AVStream *st= s->streams[ pkt->stream_index]; //FIXME/XXX/HACK drop zero sized packets - if(st->codec->codec_type == CODEC_TYPE_AUDIO && pkt->size==0) + if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size==0) return 0; //av_log(NULL, AV_LOG_DEBUG, "av_interleaved_write_frame %d %"PRId64" %"PRId64"\n", pkt->size, pkt->dts, pkt->pts); @@ -2999,7 +2999,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } - if(st->codec->codec_type == CODEC_TYPE_VIDEO){ + if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ if(st->avg_frame_rate.den && st->avg_frame_rate.num) print_fps(av_q2d(st->avg_frame_rate), "fps"); if(st->r_frame_rate.den && st->r_frame_rate.num) |