[FFmpeg-devel] [PATCH] avdevice: add fbdev output device

Lukasz M lukasz.m.luki at gmail.com
Sat Oct 19 21:38:22 CEST 2013


>
> > +
> > +static av_cold int fbdev_write_header(AVFormatContext *h)
> > +{
> > +    FBDevContext *s = h->priv_data;
> > +    enum AVPixelFormat pix_fmt;
> > +    AVStream *st = NULL;
> > +    int ret, flags = O_RDWR;
> > +
> > +    for (int i = 0; i < h->nb_streams; i++) {
> > +        if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
> > +            s->stream_index = i;
> > +            st = h->streams[i];
> > +            break;
> > +        }
> > +    }
> > +    if (!st) {
> > +        av_log(h, AV_LOG_ERROR, "No video stream found.\n");
> > +        return AVERROR(EINVAL);
> > +    }
>
> You could add a check and an error or warning in case more than one
> video stream is sent to the device.
>

Added a warning. Other output devices could also be updated. Each treat
this problem in different way.


> > +    uint8_t *pin, *pout;
> > +    enum AVPixelFormat pix_fmt;
> > +    int disp_height;
> > +    int bytes_to_copy;
> > +    int src_line_size = s->width * s->bpp;
> > +
> > +    if (s->stream_index != pkt->stream_index)
> > +        return 0;
> > +
> > +    if (ioctl(s->fd, FBIOGET_VSCREENINFO, &s->varinfo) < 0)
> > +        av_log(h, AV_LOG_WARNING,
> > +               "Error refreshing variable info: %s\n", strerror(errno));
> > +
> > +    pix_fmt = get_pixfmt_from_fb_varinfo(&s->varinfo);
> > +
>
> > +    //TODO: add mapping between formats
>
> what do you exactly mean (this is useful for the archive)?


I edited this comment to "Consider"
I mean that fbdev_enc require the same pixel format as current
configuration of system framebuffer, which may vary even for the same
hardware.
This means there is few formats that can be valid, but there is only one at
a time.
Simple conversions like rgba -> bgra can be done by replacing memcpy with
copying byte by byte with proper mapping between input and output offsets.
I guess there is already pixel conversion inside ffmpeg binary and this
would be second one which is bad and I haven't do that yet, but on other
hand it may be helpful in some cases.

BTW, Wouldn't it be good idea to extend AVOutputFormat with information
about supported pixel/sample formats?
That would allow to guess correct formats without user interaction.

Rest of remarks fixed, updated patch in attachment.
Relevant fixes in new patches.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avdevice-add-fbdev-output-device.patch
Type: application/octet-stream
Size: 13932 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131019/e5aac09a/attachment.obj>


More information about the ffmpeg-devel mailing list