[Ffmpeg-devel] ffplay broken in latest svn

Nikns Siankin nikns
Mon Jan 8 19:06:37 CET 2007


On Mon, Jan 08, 2007 at 05:05:10PM +0100, Michael Niedermayer wrote:
>Hi
>
>On Mon, Jan 08, 2007 at 05:04:32PM +0200, Nikns Siankin wrote:
>> On Fri, Jan 05, 2007 at 03:55:27PM +0100, Michael Niedermayer wrote:
>> >Hi
>> >
>> >On Wed, Jan 03, 2007 at 11:31:46AM +0200, Nikns Siankin wrote:
>> >> ffplay seems broken in svn 20070102.
[...]
>> >
>> >try to av_mallocz() duration_error and if it fixes the issue submit a patch
>> 
>> It fixed.
>> Here is patch:
>> 
>> 
>> --- libavformat/utils.c.orig	Tue Jan  2 22:35:46 2007
>> +++ libavformat/utils.c	Mon Jan  8 16:55:12 2007
>> @@ -1778,14 +1778,19 @@ static int get_std_framerate(int i){
>>   */
>>  int av_find_stream_info(AVFormatContext *ic)
>>  {
>> -    int i, count, ret, read_size, j;
>> +    int i, count, ret, read_size, j, k;
>>      AVStream *st;
>>      AVPacket pkt1, *pkt;
>>      AVPacketList *pktl=NULL, **ppktl;
>>      int64_t last_dts[MAX_STREAMS];
>>      int duration_count[MAX_STREAMS]={0};
>> -    double duration_error[MAX_STREAMS][MAX_STD_TIMEBASES]={{0}}; //FIXME malloc()?
>> +    double **duration_error;
>>  
>> +    duration_error = (double **) av_mallocz(MAX_STREAMS* sizeof(double *));
>> +
>> +    for (k=0;k<MAX_STREAMS;k++)
>> +        duration_error[k] = (double *) av_mallocz(MAX_STD_TIMEBASES* sizeof(double));
>
>duration_error= av_mallocz(MAX_STREAMS * MAX_STD_TIMEBASES * sizeof(double));
>
>much simpler ...


--- libavformat/utils.c.orig	Tue Jan  2 22:35:46 2007
+++ libavformat/utils.c	Mon Jan  8 19:57:03 2007
@@ -1784,7 +1784,7 @@ int av_find_stream_info(AVFormatContext 
     AVPacketList *pktl=NULL, **ppktl;
     int64_t last_dts[MAX_STREAMS];
     int duration_count[MAX_STREAMS]={0};
-    double duration_error[MAX_STREAMS][MAX_STD_TIMEBASES]={{0}}; //FIXME malloc()?
+    double *duration_error = av_mallocz(MAX_STREAMS * MAX_STD_TIMEBASES * sizeof(duration_error));
 
     for(i=0;i<ic->nb_streams;i++) {
         st = ic->streams[i];
@@ -1896,12 +1896,12 @@ int av_find_stream_info(AVFormatContext 
 //                if(st->codec->codec_type == CODEC_TYPE_VIDEO)
 //                    av_log(NULL, AV_LOG_ERROR, "%f\n", dur);
                 if(duration_count[index] < 2)
-                    memset(duration_error, 0, sizeof(duration_error));
+                    memset(duration_error, 0, MAX_STREAMS * MAX_STD_TIMEBASES * sizeof(duration_error));
                 for(i=1; i<MAX_STD_TIMEBASES; i++){
                     int framerate= get_std_framerate(i);
                     int ticks= lrintf(dur*framerate/(1001*12));
                     double error= dur - ticks*1001*12/(double)framerate;
-                    duration_error[index][i] += error*error;
+                    duration_error[index*MAX_STREAMS+i] += error*error;
                 }
                 duration_count[index]++;
 
@@ -1968,7 +1968,7 @@ int av_find_stream_info(AVFormatContext 
                 best_error= best_error*best_error*duration_count[i]*1000*12*30;
 
                 for(j=1; j<MAX_STD_TIMEBASES; j++){
-                    double error= duration_error[i][j] * get_std_framerate(j);
+                    double error= duration_error[i*MAX_STREAMS+j] * get_std_framerate(j);
 //                    if(st->codec->codec_type == CODEC_TYPE_VIDEO)
 //                        av_log(NULL, AV_LOG_ERROR, "%f %f\n", get_std_framerate(j) / 12.0/1001, error);
                     if(error < best_error){
@@ -2016,6 +2016,9 @@ int av_find_stream_info(AVFormatContext 
         }
     }
 #endif
+
+    av_freep(&duration_error);
+
     return ret;
 }
 




More information about the ffmpeg-devel mailing list