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

Michael Niedermayer michaelni
Mon Feb 16 17:00:04 CET 2009


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


> 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


[...]


> 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

> 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?


>  
>  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


> 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


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

ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090216/e55e0493/attachment.pgp>



More information about the ffmpeg-devel mailing list