[FFmpeg-devel] [PATCH] drawtext: fix hard dependency to lavc (timecode).
Stefano Sabatini
stefasab at gmail.com
Mon Jan 2 12:57:52 CET 2012
On date Monday 2012-01-02 09:57:26 +0100, Clément Bœsch encoded:
> On Wed, Dec 28, 2011 at 01:28:42PM +0100, Stefano Sabatini wrote:
> [...]
> > Alternatively you may consider a run-time error issued in case one of
> > those options is called and CONFIG_AVCODEC was not enabled.
> >
>
> New version attached. I'll push it in the next days if I see no objection.
>
> --
> Clément B.
> From 1b79dbd7ba175471183aaea113fc80daaf8553d0 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <clement.boesch at smartjog.com>
> Date: Wed, 28 Dec 2011 10:09:45 +0100
> Subject: [PATCH] drawtext: fix hard dependency to lavc (timecode).
>
> ---
> libavfilter/vf_drawtext.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> index 9f85586..0de5b9f 100644
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -29,6 +29,7 @@
> #include <sys/time.h>
> #include <time.h>
>
> +#include "config.h"
> #include "libavcodec/timecode.h"
> #include "libavutil/avstring.h"
> #include "libavutil/colorspace.h"
> @@ -341,10 +342,16 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> }
>
> if (dtext->tc.str) {
> +#if CONFIG_AVCODEC
> if (avpriv_init_smpte_timecode(ctx, &dtext->tc) < 0)
> return AVERROR(EINVAL);
> if (!dtext->text)
> dtext->text = av_strdup("");
> +#else
> + av_log(ctx, AV_LOG_ERROR,
> + "Timecode options are only available if libavfilter is built with libavcodec enabled.\n");
> + return AVERROR(EINVAL);
> +#endif
> }
>
> if (!dtext->text) {
> @@ -722,11 +729,13 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
> buf_size *= 2;
> } while ((buf = av_realloc(buf, buf_size)));
>
> +#if CONFIG_AVCODEC
> if (dtext->tc.str) {
> char tcbuf[sizeof("hh:mm:ss.ff")];
> avpriv_timecode_to_string(tcbuf, &dtext->tc, dtext->frame_id++);
> buf = av_asprintf("%s%s", dtext->text, tcbuf);
> }
> +#endif
LGTM, you may add a note in the documentation regarding the fact that
those options are available only if libavfilter was compiled against
libavcodec (or alternatively, that they are *not* effective if FFmpeg
was compiled with --disable-avcodec).
--
FFmpeg = Frightening & Forgiving Mastodontic Pitiless Egregious Geisha
More information about the ffmpeg-devel
mailing list