[FFmpeg-devel] [PATCH] Fix printf usage in vhook

Stefano Sabatini stefano.sabatini-lala
Fri Sep 5 09:11:39 CEST 2008

On date Friday 2008-09-05 09:14:41 +0800, JonY encoded:
> Stefano Sabatini wrote:
>> On date Thursday 2008-09-04 12:54:48 +0800, JonY encoded:
>>> Stefano Sabatini wrote:
>>>> On date Wednesday 2008-09-03 19:04:27 +0800, JonY encoded:
>>>>> Patch fixes some undefined references to "please_use_av_log". Do change
>>>>> the AV_LOG levels if inappropriate.
>>>>> Any ideas fix fprintfs writing to files?
>>>>>> vhook/fish.c:369:                        fprintf(f, "P6 %d %d 255\n", width, height);
>>>>>> vhook/ppm.c:287:        fprintf( out, "P6\n%d %d\n255\n", width, height );
>>>> You have to redefine the av_log() behaviour, setting the av_log callback
>>>> function.
>>> Do you have any suggestions where the callback should be pointed to?
>> Now that I think at it that lines of code print to some file, but
>> they're not used for logging purpose so I think it makes no sense to
>> use av_log, it would make more sense to #undef fprintf in the files.
>> [...]
>>>> As you may know VHOOK is harshly *deprecated*, nonetheless since we
>>>> don't know how much time libavfilter will stay in the limbo, maybe it
>>>> would still make sense to apply this.
>>>> Regards.
>>> Thanks, I know its depreciated, but I don't know why the errors appeared
>>> now, just trying to correct it.
>> Look at libavutil/internal.h which is included in libavutil/common.h,
>> printing functions shouldn't be used in a library.
>> Regards.
> I meant to say that vhook hasn't changed in a while, but why did the  
> errors appear only recently? Anyway, I found the cause after checking up  
> internal.h.
> FFMPEG_FRAMEHOOK_H was changed to AVFORMAT_FRAMEHOOK_H recently in  
> libavformat/framehook.h but the ifdefs in libavutil/internal.h, hasn't  
> changed to reflect that.
> Patch attached.

> Index: libavutil/internal.h
> ===================================================================
> --- libavutil/internal.h	(revision 15214)
> +++ libavutil/internal.h	(working copy)
> @@ -242,7 +242,7 @@
>  #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat
>  #undef  exit
>  #define exit exit_is_forbidden
> -#if !(defined(LIBAVFORMAT_BUILD) || defined(FFMPEG_FRAMEHOOK_H))
> +#if !(defined(LIBAVFORMAT_BUILD) || defined(AVFORMAT_FRAMEHOOK_H))
>  #undef  printf
>  #define printf please_use_av_log
>  #undef  fprintf

That looks like an hack to quickly fix it, the correct solution seems
to me to *not use* f?printf but av_log as in your previous patch (and
#undef it when it is necessary to write to file), then maybe we can
remove that ifdeffery.

FFmpeg = Free and Fiendish MultiPurpose Erotic Geisha

More information about the ffmpeg-devel mailing list