[FFmpeg-devel] [PATCH v1] lavc/libdavs2.c: optimize frame copy
mypopy at gmail.com
mypopy at gmail.com
Sun Jul 7 13:21:34 EEST 2019
On Fri, Jul 5, 2019 at 9:09 AM Song, Ruiling <ruiling.song at intel.com> wrote:
>
> > -----Original Message-----
> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf
> > Of hwrenx
> > Sent: Wednesday, July 3, 2019 11:24 AM
> > To: ffmpeg-devel at ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH v1] lavc/libdavs2.c: optimize frame copy
> >
>
> I think it's better to use "correct ..." or "fix ..." instead of "optimize" in the title.
> Maybe a short commit message here would be useful for reviewer.
>
> > Signed-off-by: hwrenx <hwrenx at 126.com>
> > ---
> > libavcodec/libdavs2.c | 15 ++++++++++-----
> > 1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
> > index 218f3ec..15ed3a1 100644
> > --- a/libavcodec/libdavs2.c
> > +++ b/libavcodec/libdavs2.c
> > @@ -62,7 +62,7 @@ static int davs2_dump_frames(AVCodecContext *avctx,
> > davs2_picture_t *pic, int *g
> > davs2_seq_info_t *headerset, int ret_type, AVFrame *frame)
> > {
> > DAVS2Context *cad = avctx->priv_data;
> > - int bytes_per_sample = pic->bytes_per_sample;
> > + int bytes_per_sample = pic->bytes_per_sample == 8 ? 1 : 2;
> > int plane = 0;
> > int line = 0;
> >
> > @@ -104,6 +104,7 @@ static int davs2_dump_frames(AVCodecContext
> > *avctx, davs2_picture_t *pic, int *g
> >
> > for (plane = 0; plane < 3; ++plane) {
> > int size_line = pic->widths[plane] * bytes_per_sample;
> > + void *dst, *src;
> > frame->buf[plane] = av_buffer_alloc(size_line * pic->lines[plane]);
> >
> > if (!frame->buf[plane]){
> > @@ -114,10 +115,14 @@ static int davs2_dump_frames(AVCodecContext
> > *avctx, davs2_picture_t *pic, int *g
> > frame->data[plane] = frame->buf[plane]->data;
> > frame->linesize[plane] = size_line;
> >
>
> Did you observe performance difference with only below lines of change?
> If it is just for code cleanup, it's better to split this into separate patch.
>
After talked with hwrenx offline, I think hwrenx will use the other
way for this type
performance issue like libdav1d.c wrapper, it's will reduce the memory copy from
davs2 decoder to FFmpeg.
> Thanks!
> Ruiling
> > - for (line = 0; line < pic->lines[plane]; ++line)
> > - memcpy(frame->data[plane] + line * size_line,
> > - pic->planes[plane] + line * pic->strides[plane],
> > - pic->widths[plane] * bytes_per_sample);
> > + dst = frame->data[plane];
> > + src = pic->planes[plane];
> > +
> > + for (line = 0; line < pic->lines[plane]; ++line) {
> > + memcpy(dst, src, size_line);
> > + dst += size_line;
> > + src += pic->strides[plane];
> > + }
> > }
> >
> > frame->width = cad->headerset.width;
> > --
> > 2.7.4
More information about the ffmpeg-devel
mailing list