[FFmpeg-devel] [PATCH] libcaca output device

Stefano Sabatini stefasab at gmail.com
Thu Jul 19 22:20:21 CEST 2012


On date Thursday 2012-07-19 18:43:57 +0000, Paul B Mahol encoded:
> On 7/19/12, Stefano Sabatini <stefasab at gmail.com> wrote:
> > On date Thursday 2012-07-19 15:10:22 +0000, Paul B Mahol encoded:
> >>
> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> ---
> >>  configure                |   12 +++
> >>  libavdevice/Makefile     |    1 +
> >>  libavdevice/alldevices.c |    1 +
> >>  libavdevice/caca.c       |  191
> >> ++++++++++++++++++++++++++++++++++++++++++++++
> >>  4 files changed, 205 insertions(+), 0 deletions(-)
> >>  create mode 100644 libavdevice/caca.c
> >>
> [...]
> >> +
> >> +    if (encctx->pix_fmt != PIX_FMT_RGB24) {
> >> +        av_log(s, AV_LOG_ERROR,
> >> +               "Unsupported pixel format '%s', choose rgb24.\n",
> >> +               av_get_pix_fmt_name(encctx->pix_fmt));
> >> +        return AVERROR(EINVAL);
> >> +    }
> >> +
> >> +    c->canvas = caca_create_canvas(encctx->width, encctx->height);
> >> +    if (!c->canvas) {
> >> +        av_log(s, AV_LOG_ERROR, "Failed to create canvas.\n");
> >> +        return AVERROR(ENOMEM);
> >
> > Don't know if libcaca supports error messages, could be nice to add
> > them to improve the feedback.
> 
> It only sets errno.

OK, then maybe:
av_log(s, AV_LOG_ERROR, "Failed to create canvas: %s\n", av_err2str(AVERROR(errno)));

> >
> >> +    }
> >> +
> >> +    c->display = caca_create_display_with_driver(c->canvas, c->driver);
> >> +    if (!c->display) {
> >> +        const char *const *drivers = caca_get_display_driver_list();
> >> +
> >> +        av_log(s, AV_LOG_ERROR, "Failed to create display.\n");
> >
> > Nit: no need for the final dot (consistency reasons), here and below
> >
> >> +        av_log(s, AV_LOG_INFO, "Possible drivers:\n");
> >> +        for (i = 0; drivers[i]; i += 2)
> >> +            av_log(s, AV_LOG_INFO, "%s : %s\n", drivers[i], drivers[i +
> >> 1]);
> >> +        caca_free_canvas(c->canvas);
> >
> > Note: we could create a list driver|algorithm|antialias|color|... option
> > showing the supported stuff.
> 
> Could you elaborate this?

I mean:
void list_drivers(void *log_ctx)
{
    int i;
    const char *const *drivers = caca_get_display_driver_list();
    for (i = 0; drivers[i]; i += 2)
            av_log(s, AV_LOG_INFO, "%s : %s\n", drivers[i], drivers[i + 1]);
}

coupled with an option -list_drivers 0|1.

if (!c->display) {
    av_log(s, AV_LOG_ERROR, "Failed to create display.\n");
    av_log(s, AV_LOG_INFO, "Possible drivers:\n");
    list_drivers(s);
}

void list_dither(AVFormatContext *s, const char *option)
{
    if (!strcmp(option, "algorithm")
       ...
    else if
}

coupled with an option -list_dither option
-- 
FFmpeg = Forgiving Fantastic Most Ponderous Ecumenical Game


More information about the ffmpeg-devel mailing list