[FFmpeg-devel] [PATCH] add context to av_log() calls

Benoit Fouet benoit.fouet
Mon Feb 16 17:13:15 CET 2009


Hi,

On 02/16/2009 05:00 PM, Michael Niedermayer wrote:
> On Mon, Feb 16, 2009 at 02:35:23PM +0100, Benoit Fouet wrote:
>   
>> Hi,
>>
>> here are some patches to $subj in libavformat
>> (note: I had to add the context for avi and ape as a parameter to a
>> function)
>>
>> Ben
>>
>>     
>
> [...]
>   
>> Index: libavformat/asf.c
>> ===================================================================
>> --- libavformat/asf.c	(revision 17366)
>> +++ libavformat/asf.c	(working copy)
>>     
> [...]
>
> ok
>
>
>   

applied

>> Index: libavformat/avidec.c
>> ===================================================================
>> --- libavformat/avidec.c	(revision 17366)
>> +++ libavformat/avidec.c	(working copy)
>> @@ -87,7 +87,7 @@ static void print_tag(const char *str, u
>>  }
>>  #endif
>>  
>> -static int get_riff(AVIContext *avi, ByteIOContext *pb)
>> +static int get_riff(AVFormatContext *s, AVIContext *avi, ByteIOContext *pb)
>>     
>
> this seems redundant
>
>
>   

I'm not sure I understand. Is there an av_log()-friendly context already
available in one of the two parameters ?

>> Index: libavformat/flvdec.c
>> ===================================================================
>> --- libavformat/flvdec.c	(revision 17366)
>> +++ libavformat/flvdec.c	(working copy)
>>     
> [...]
>   
>> Index: libavformat/raw.c
>> ===================================================================
>> --- libavformat/raw.c	(revision 17366)
>> +++ libavformat/raw.c	(working copy)
>>     
> [...]
>
> ok
>
>   

applied

>> Index: libavformat/utils.c
>> ===================================================================
>> --- libavformat/utils.c	(revision 17366)
>> +++ libavformat/utils.c	(working copy)
>>     
> [...]
>   
>> @@ -2757,15 +2757,15 @@ static void dump_stream_format(AVFormatC
>>      AVStream *st = ic->streams[i];
>>      int g = av_gcd(st->time_base.num, st->time_base.den);
>>      avcodec_string(buf, sizeof(buf), st->codec, is_output);
>> -    av_log(NULL, AV_LOG_INFO, "    Stream #%d.%d", index, i);
>> +    av_log(ic, AV_LOG_INFO, "    Stream #%d.%d", index, i);
>>      /* the pid is an important information, so we display it */
>>      /* XXX: add a generic system */
>>      if (flags & AVFMT_SHOW_IDS)
>> -        av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
>> +        av_log(ic, AV_LOG_INFO, "[0x%x]", st->id);
>>      if (strlen(st->language) > 0)
>> -        av_log(NULL, AV_LOG_INFO, "(%s)", st->language);
>> -    av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g);
>> -    av_log(NULL, AV_LOG_INFO, ": %s", buf);
>> +        av_log(ic, AV_LOG_INFO, "(%s)", st->language);
>> +    av_log(ic, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g);
>> +    av_log(ic, AV_LOG_INFO, ": %s", buf);
>>      if (st->sample_aspect_ratio.num && // default
>>          av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
>>          AVRational display_aspect_ratio;
>> @@ -2773,19 +2773,19 @@ static void dump_stream_format(AVFormatC
>>                    st->codec->width*st->sample_aspect_ratio.num,
>>                    st->codec->height*st->sample_aspect_ratio.den,
>>                    1024*1024);
>> -        av_log(NULL, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d",
>> +        av_log(ic, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d",
>>                   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->r_frame_rate.den && st->r_frame_rate.num)
>> -            av_log(NULL, AV_LOG_INFO, ", %5.2f tb(r)", av_q2d(st->r_frame_rate));
>> +            av_log(ic, AV_LOG_INFO, ", %5.2f tb(r)", av_q2d(st->r_frame_rate));
>>  /*      else if(st->time_base.den && st->time_base.num)
>> -            av_log(NULL, AV_LOG_INFO, ", %5.2f tb(m)", 1/av_q2d(st->time_base));*/
>> +            av_log(ic, AV_LOG_INFO, ", %5.2f tb(m)", 1/av_q2d(st->time_base));*/
>>          else
>> -            av_log(NULL, AV_LOG_INFO, ", %5.2f tb(c)", 1/av_q2d(st->codec->time_base));
>> +            av_log(ic, AV_LOG_INFO, ", %5.2f tb(c)", 1/av_q2d(st->codec->time_base));
>>      }
>> -    av_log(NULL, AV_LOG_INFO, "\n");
>> +    av_log(ic, AV_LOG_INFO, "\n");
>>  }
>>     
>
> what effect does this have on the output of this function?
>
>
>   

it sucks ! :)

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x8d9fb60]Input #0, mov,mp4,m4a,3gp,3g2,mj2,
from '/home/fouet/tools/samples/test.3gp':
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x8d9fb60]  Duration: 00:01:41.76, start:
0.000000, bitrate: 734 kb/s
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x8d9fb60]    Stream #0.0(eng): Video: mpeg4,
yuv420p, 480x270 [PAR 1:1 DAR 16:9], 29.97 tb(r)
[3gp @ 0x8daf560]Output #0, 3gp, to 'out.3gp':
[3gp @ 0x8daf560]    Stream #0.0(eng): Video: mpeg4, yuv420p, 480x270
[PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.97 tb(c)

I guess we can forget that hunk then... and the following one, of course.
 
>>  void dump_format(AVFormatContext *ic,
>> @@ -2795,13 +2795,13 @@ void dump_format(AVFormatContext *ic,
>>  {
>>      int i;
>>  
>> -    av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
>> +    av_log(ic, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
>>              is_output ? "Output" : "Input",
>>              index,
>>              is_output ? ic->oformat->name : ic->iformat->name,
>>              is_output ? "to" : "from", url);
>>      if (!is_output) {
>> -        av_log(NULL, AV_LOG_INFO, "  Duration: ");
>> +        av_log(ic, AV_LOG_INFO, "  Duration: ");
>>          if (ic->duration != AV_NOPTS_VALUE) {
>>              int hours, mins, secs, us;
>>              secs = ic->duration / AV_TIME_BASE;
>> @@ -2810,31 +2810,31 @@ void dump_format(AVFormatContext *ic,
>>              secs %= 60;
>>              hours = mins / 60;
>>              mins %= 60;
>> -            av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
>> +            av_log(ic, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
>>                     (100 * us) / AV_TIME_BASE);
>>          } else {
>> -            av_log(NULL, AV_LOG_INFO, "N/A");
>> +            av_log(ic, AV_LOG_INFO, "N/A");
>>          }
>>          if (ic->start_time != AV_NOPTS_VALUE) {
>>              int secs, us;
>> -            av_log(NULL, AV_LOG_INFO, ", start: ");
>> +            av_log(ic, AV_LOG_INFO, ", start: ");
>>              secs = ic->start_time / AV_TIME_BASE;
>>              us = ic->start_time % AV_TIME_BASE;
>> -            av_log(NULL, AV_LOG_INFO, "%d.%06d",
>> +            av_log(ic, AV_LOG_INFO, "%d.%06d",
>>                     secs, (int)av_rescale(us, 1000000, AV_TIME_BASE));
>>          }
>> -        av_log(NULL, AV_LOG_INFO, ", bitrate: ");
>> +        av_log(ic, AV_LOG_INFO, ", bitrate: ");
>>          if (ic->bit_rate) {
>> -            av_log(NULL, AV_LOG_INFO,"%d kb/s", ic->bit_rate / 1000);
>> +            av_log(ic, AV_LOG_INFO,"%d kb/s", ic->bit_rate / 1000);
>>          } else {
>> -            av_log(NULL, AV_LOG_INFO, "N/A");
>> +            av_log(ic, AV_LOG_INFO, "N/A");
>>          }
>> -        av_log(NULL, AV_LOG_INFO, "\n");
>> +        av_log(ic, AV_LOG_INFO, "\n");
>>      }
>>      if(ic->nb_programs) {
>>          int j, k;
>>          for(j=0; j<ic->nb_programs; j++) {
>> -            av_log(NULL, AV_LOG_INFO, "  Program %d %s\n", ic->programs[j]->id,
>> +            av_log(ic, AV_LOG_INFO, "  Program %d %s\n", ic->programs[j]->id,
>>                     ic->programs[j]->name ? ic->programs[j]->name : "");
>>              for(k=0; k<ic->programs[j]->nb_stream_indexes; k++)
>>                  dump_stream_format(ic, ic->programs[j]->stream_index[k], index, is_output);
>>
>>     
>
> same
>
>
>   

see above

>> Index: libavformat/mm.c
>> ===================================================================
>> --- libavformat/mm.c	(revision 17366)
>> +++ libavformat/mm.c	(working copy)
>> @@ -168,7 +168,7 @@ static int mm_read_packet(AVFormatContex
>>              return 0;
>>  
>>          default :
>> -            av_log(NULL, AV_LOG_INFO, "mm: unknown chunk type 0x%x\n", type);
>> +            av_log(s, AV_LOG_INFO, "mm: unknown chunk type 0x%x\n", type);
>>     
>                                        ^^
> redundant
>
>   

how about that one ?

Index: libavformat/mm.c
===================================================================
--- libavformat/mm.c    (revision 17366)
+++ libavformat/mm.c    (working copy)
@@ -168,7 +168,7 @@ static int mm_read_packet(AVFormatContex
             return 0;
 
         default :
-            av_log(NULL, AV_LOG_INFO, "mm: unknown chunk type 0x%x\n",
type);
+            av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
             url_fseek(pb, length, SEEK_CUR);
         }
     }


>> Index: libavformat/rmdec.c
>> ===================================================================
>> --- libavformat/rmdec.c	(revision 17366)
>> +++ libavformat/rmdec.c	(working copy)
>>     
>
> ok
>
>   

applied

Ben





More information about the ffmpeg-devel mailing list