Commit ee01a825 authored by michael's avatar michael

Put codec_info_nb_frames back in AVStream and print its value.

This way streams with no or very few frames can be avoided during
auto selection


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21998 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 717b5111
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define AVFORMAT_AVFORMAT_H #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 #define LIBAVFORMAT_VERSION_MAJOR 52
#define LIBAVFORMAT_VERSION_MINOR 53 #define LIBAVFORMAT_VERSION_MINOR 54
#define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
...@@ -519,6 +519,11 @@ typedef struct AVStream { ...@@ -519,6 +519,11 @@ typedef struct AVStream {
* Average framerate * Average framerate
*/ */
AVRational avg_frame_rate; AVRational avg_frame_rate;
/**
* Number of frames that have been demuxed during av_find_stream_info()
*/
int codec_info_nb_frames;
} AVStream; } AVStream;
#define AV_PROGRAM_RUNNING 1 #define AV_PROGRAM_RUNNING 1
......
...@@ -2074,7 +2074,6 @@ int av_find_stream_info(AVFormatContext *ic) ...@@ -2074,7 +2074,6 @@ int av_find_stream_info(AVFormatContext *ic)
double (*duration_error)[MAX_STD_TIMEBASES]; double (*duration_error)[MAX_STD_TIMEBASES];
int64_t old_offset = url_ftell(ic->pb); int64_t old_offset = url_ftell(ic->pb);
int64_t codec_info_duration[MAX_STREAMS]={0}; int64_t codec_info_duration[MAX_STREAMS]={0};
int codec_info_nb_frames[MAX_STREAMS]={0};
duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error)); duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error));
if (!duration_error) return AVERROR(ENOMEM); if (!duration_error) return AVERROR(ENOMEM);
...@@ -2178,7 +2177,7 @@ int av_find_stream_info(AVFormatContext *ic) ...@@ -2178,7 +2177,7 @@ int av_find_stream_info(AVFormatContext *ic)
read_size += pkt->size; read_size += pkt->size;
st = ic->streams[pkt->stream_index]; st = ic->streams[pkt->stream_index];
if(codec_info_nb_frames[st->index]>1) { if(st->codec_info_nb_frames>1) {
if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration){ if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration){
av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n"); av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n");
break; break;
...@@ -2186,7 +2185,7 @@ int av_find_stream_info(AVFormatContext *ic) ...@@ -2186,7 +2185,7 @@ int av_find_stream_info(AVFormatContext *ic)
codec_info_duration[st->index] += pkt->duration; codec_info_duration[st->index] += pkt->duration;
} }
if (pkt->duration != 0) if (pkt->duration != 0)
codec_info_nb_frames[st->index]++; st->codec_info_nb_frames++;
{ {
int index= pkt->stream_index; int index= pkt->stream_index;
...@@ -2242,9 +2241,9 @@ int av_find_stream_info(AVFormatContext *ic) ...@@ -2242,9 +2241,9 @@ int av_find_stream_info(AVFormatContext *ic)
} }
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if(codec_info_nb_frames[i]>2 && !st->avg_frame_rate.num) if(st->codec_info_nb_frames>2 && !st->avg_frame_rate.num)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
(codec_info_nb_frames[i]-2)*(int64_t)st->time_base.den, (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
codec_info_duration[i] *(int64_t)st->time_base.num, 60000); codec_info_duration[i] *(int64_t)st->time_base.num, 60000);
if (st->codec->codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample) if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample)
...@@ -2937,7 +2936,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out ...@@ -2937,7 +2936,7 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out
av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
if (lang) if (lang)
av_log(NULL, AV_LOG_INFO, "(%s)", lang->value); av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g); av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames, st->time_base.num/g, st->time_base.den/g);
av_log(NULL, AV_LOG_INFO, ": %s", buf); av_log(NULL, AV_LOG_INFO, ": %s", buf);
if (st->sample_aspect_ratio.num && // default if (st->sample_aspect_ratio.num && // default
av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) { av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
......
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