[Ffmpeg-devel] [PATCH] nuv/MythTV Video/RTjpeg support

Reimar Döffinger Reimar.Doeffinger
Mon Mar 27 17:16:41 CEST 2006


Hi,
On Mon, Mar 27, 2006 at 02:06:52PM +0200, Michael Niedermayer wrote:
[...]
> > +/**
> > + * \brief copy frame data from buffer to AVFrame, handling stride.
> > + * \param f destination AVFrame
> > + * \param src source buffer, does not use any line-stride
> > + * \param width width of the video frame
> > + * \param height height of the video frame
> > + */
> > +static void copy_frame(AVFrame *f, uint8_t *src,
> > +                       int width, int height) {
> > +    int i;
> > +    uint8_t *dst = f->data[0];
> > +    for (i = height; i > 0; i--) {
> > +        memcpy(dst, src, width);
> > +        src += width;
> > +        dst += f->linesize[0];
> > +    }
> > +    width /= 2;
> > +    height /= 2;
> > +    dst = f->data[1];
> > +    for (i = height; i > 0; i--) {
> > +        memcpy(dst, src, width);
> > +        src += width;
> > +        dst += f->linesize[1];
> > +    }
> > +    dst = f->data[2];
> > +    for (i = height; i > 0; i--) {
> > +        memcpy(dst, src, width);
> > +        src += width;
> > +        dst += f->linesize[2];
> > +    }
> > +}
> 
> what about using avpicture_fill() and img_copy()

Ah, didn't know about avpicture_fill.
So does using this instead look right (I mean esp. because of the cast
from AVFrame * to AVPicture *, is this supposed to be done like that?):

static void copy_frame(AVFrame *f, uint8_t *src,
                       int width, in height) {
    AVPicture pic;
    avpicture_fill(&pic, src, PIX_FMT_YUV420P, width, height);
    img_copy((AVPicture *)f, &pic, PIX_FMT_YUV420P, width, height);
}

Greetings,
Reimar D?ffinger





More information about the ffmpeg-devel mailing list