[Ffmpeg-cvslog] CVS: ffmpeg/libavformat utils.c,1.152,1.153
Michael Niedermayer CVS
michael
Mon Jun 27 22:54:38 CEST 2005
Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv3263
Modified Files:
utils.c
Log Message:
dont open and close codec at every call of try_decode_frame() as this is not only slow but also fails if the previous frame is needed for setting some parameters correctly
Index: utils.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/utils.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- utils.c 27 Jun 2005 00:04:03 -0000 1.152
+++ utils.c 27 Jun 2005 20:54:36 -0000 1.153
@@ -1675,15 +1675,17 @@
{
int16_t *samples;
AVCodec *codec;
- int got_picture, ret;
+ int got_picture, ret=0;
AVFrame picture;
+ if(!st->codec.codec){
codec = avcodec_find_decoder(st->codec.codec_id);
if (!codec)
return -1;
ret = avcodec_open(&st->codec, codec);
if (ret < 0)
return ret;
+ }
if(!has_codec_parameters(&st->codec)){
switch(st->codec.codec_type) {
@@ -1704,7 +1706,6 @@
}
}
fail:
- avcodec_close(&st->codec);
return ret;
}
@@ -1842,7 +1843,7 @@
duration_sum[index] += duration;
duration_count[index]+= factor;
}
- if(st->codec_info_nb_frames == 0)
+ if(st->codec_info_nb_frames == 0 && 0)
st->codec_info_duration += duration;
}
last_dts[pkt->stream_index]= pkt->dts;
@@ -1883,6 +1884,12 @@
count++;
}
+ // close codecs which where opened in try_decode_frame()
+ for(i=0;i<ic->nb_streams;i++) {
+ st = ic->streams[i];
+ if(st->codec.codec)
+ avcodec_close(&st->codec);
+ }
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
More information about the ffmpeg-cvslog
mailing list