Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-12-11 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Max
> Dmitrichenko
> Sent: Wednesday, November 20, 2019 3:04 PM
> To: FFmpeg development discussions and patches 
> Cc: Li, Zhong 
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> On Sun, Sep 29, 2019 at 3:19 AM Fu, Linjie  wrote:
> 
> > > -Original Message-
> > > From: Li, Zhong 
> > > Sent: Friday, September 13, 2019 00:05
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Cc: Fu, Linjie 
> > > Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > > vaMapBuffer returns multiple buffers
> > >
> > > > From: ffmpeg-devel  On Behalf Of
> > > Linjie Fu
> > > > Sent: Friday, May 31, 2019 8:35 AM
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Fu, Linjie 
> > > > Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > > > vaMapBuffer returns multiple buffers
> > > >
> > > > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> > > map
> > > > buffer for each slice.
The patch LGTM. But the above line of commit message seems not too much 
relevant.
Will remove this line of commit message and apply the patch if no objection.

Thanks!
Ruiling 

> > > >
> > > > Currently, assigning new buffer for pkt when multiple buffer returns
> > from
> > > > vaMapBuffer will cover the previous encoded pkt data and lead to encode
> > > issues.
> > > >
> > > > Iterate through the buf_list first to find out the total buffer size
> > needed for
> > > the
> > > > pkt, allocate the whole pkt to avoid repeated reallocation and memcpy,
> > > then copy
> > > > data from each buf to pkt.
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > > [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> > > >
> > > >  libavcodec/vaapi_encode.c | 18 +-
> > > >  1 file changed, 13 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > index
> > > > 2dda451..9c9e5dd 100644
> > > > --- a/libavcodec/vaapi_encode.c
> > > > +++ b/libavcodec/vaapi_encode.c
> > > > @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> > > *avctx,
> > > >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > > >  VACodedBufferSegment *buf_list, *buf;
> > > >  VAStatus vas;
> > > > +int total_size = 0;
> > > > +uint8_t *ptr;
> > > >  int err;
> > > >
> > > >  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static
> > int
> > > > vaapi_encode_output(AVCodecContext *avctx,
> > > >  goto fail;
> > > >  }
> > > >
> > > > +for (buf = buf_list; buf; buf = buf->next)
> > > > +total_size += buf->size;
> > > > +
> > > > +err = av_new_packet(pkt, total_size);
> > > > +ptr = pkt->data;
> > > > +
> > > > +if (err < 0)
> > > > +goto fail_mapped;
> > > > +
> > > >  for (buf = buf_list; buf; buf = buf->next) {
> > > >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > > > "(status %08x).\n", buf->size, buf->status);
> > > >
> > > > -err = av_new_packet(pkt, buf->size);
> > > > -if (err < 0)
> > > > -goto fail_mapped;
> > > > -
> > > > -memcpy(pkt->data, buf->buf, buf->size);
> > > > +memcpy(ptr, buf->buf, buf->size);
> > > > +ptr += buf->size;
> > > >  }
> > > >
> > > >  if (pic->type == PICTURE_TYPE_IDR)
> > > > --
> > > > 2.7.4
> > >
> > > LGTM
> >
> > Thanks for review.
> > A kindly ping.
> >
> > - linjie
> >
> 
> LGTM
> 
> regards
> Max
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-11-24 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Max Dmitrichenko
> Sent: Wednesday, November 20, 2019 15:04
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Li, Zhong 
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> On Sun, Sep 29, 2019 at 3:19 AM Fu, Linjie  wrote:
> 
> > > -Original Message-
> > > From: Li, Zhong 
> > > Sent: Friday, September 13, 2019 00:05
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Cc: Fu, Linjie 
> > > Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet
> if
> > > vaMapBuffer returns multiple buffers
> > >
> > > > From: ffmpeg-devel  On Behalf
> Of
> > > Linjie Fu
> > > > Sent: Friday, May 31, 2019 8:35 AM
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Fu, Linjie 
> > > > Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > > > vaMapBuffer returns multiple buffers
> > > >
> > > > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> > > map
> > > > buffer for each slice.
> > > >
> > > > Currently, assigning new buffer for pkt when multiple buffer returns
> > from
> > > > vaMapBuffer will cover the previous encoded pkt data and lead to
> encode
> > > issues.
> > > >
> > > > Iterate through the buf_list first to find out the total buffer size
> > needed for
> > > the
> > > > pkt, allocate the whole pkt to avoid repeated reallocation and memcpy,
> > > then copy
> > > > data from each buf to pkt.
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > > [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> > > >
> > > >  libavcodec/vaapi_encode.c | 18 +-
> > > >  1 file changed, 13 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > index
> > > > 2dda451..9c9e5dd 100644
> > > > --- a/libavcodec/vaapi_encode.c
> > > > +++ b/libavcodec/vaapi_encode.c
> > > > @@ -489,6 +489,8 @@ static int
> vaapi_encode_output(AVCodecContext
> > > *avctx,
> > > >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > > >  VACodedBufferSegment *buf_list, *buf;
> > > >  VAStatus vas;
> > > > +int total_size = 0;
> > > > +uint8_t *ptr;
> > > >  int err;
> > > >
> > > >  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static
> > int
> > > > vaapi_encode_output(AVCodecContext *avctx,
> > > >  goto fail;
> > > >  }
> > > >
> > > > +for (buf = buf_list; buf; buf = buf->next)
> > > > +total_size += buf->size;
> > > > +
> > > > +err = av_new_packet(pkt, total_size);
> > > > +ptr = pkt->data;
> > > > +
> > > > +if (err < 0)
> > > > +goto fail_mapped;
> > > > +
> > > >  for (buf = buf_list; buf; buf = buf->next) {
> > > >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > > > "(status %08x).\n", buf->size, buf->status);
> > > >
> > > > -err = av_new_packet(pkt, buf->size);
> > > > -if (err < 0)
> > > > -goto fail_mapped;
> > > > -
> > > > -memcpy(pkt->data, buf->buf, buf->size);
> > > > +memcpy(ptr, buf->buf, buf->size);
> > > > +ptr += buf->size;
> > > >  }
> > > >
> > > >  if (pic->type == PICTURE_TYPE_IDR)
> > > > --
> > > > 2.7.4
> > >
> > > LGTM
> >
> > Thanks for review.
> > A kindly ping.
> >
> > - linjie
> >
> 
> LGTM
> 
> regards
> Max

Thanks for the review.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-11-19 Thread Max Dmitrichenko
On Sun, Sep 29, 2019 at 3:19 AM Fu, Linjie  wrote:

> > -Original Message-
> > From: Li, Zhong 
> > Sent: Friday, September 13, 2019 00:05
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > vaMapBuffer returns multiple buffers
> >
> > > From: ffmpeg-devel  On Behalf Of
> > Linjie Fu
> > > Sent: Friday, May 31, 2019 8:35 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > > vaMapBuffer returns multiple buffers
> > >
> > > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> > map
> > > buffer for each slice.
> > >
> > > Currently, assigning new buffer for pkt when multiple buffer returns
> from
> > > vaMapBuffer will cover the previous encoded pkt data and lead to encode
> > issues.
> > >
> > > Iterate through the buf_list first to find out the total buffer size
> needed for
> > the
> > > pkt, allocate the whole pkt to avoid repeated reallocation and memcpy,
> > then copy
> > > data from each buf to pkt.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> > >
> > >  libavcodec/vaapi_encode.c | 18 +-
> > >  1 file changed, 13 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index
> > > 2dda451..9c9e5dd 100644
> > > --- a/libavcodec/vaapi_encode.c
> > > +++ b/libavcodec/vaapi_encode.c
> > > @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> > *avctx,
> > >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > >  VACodedBufferSegment *buf_list, *buf;
> > >  VAStatus vas;
> > > +int total_size = 0;
> > > +uint8_t *ptr;
> > >  int err;
> > >
> > >  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static
> int
> > > vaapi_encode_output(AVCodecContext *avctx,
> > >  goto fail;
> > >  }
> > >
> > > +for (buf = buf_list; buf; buf = buf->next)
> > > +total_size += buf->size;
> > > +
> > > +err = av_new_packet(pkt, total_size);
> > > +ptr = pkt->data;
> > > +
> > > +if (err < 0)
> > > +goto fail_mapped;
> > > +
> > >  for (buf = buf_list; buf; buf = buf->next) {
> > >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > > "(status %08x).\n", buf->size, buf->status);
> > >
> > > -err = av_new_packet(pkt, buf->size);
> > > -if (err < 0)
> > > -goto fail_mapped;
> > > -
> > > -memcpy(pkt->data, buf->buf, buf->size);
> > > +memcpy(ptr, buf->buf, buf->size);
> > > +ptr += buf->size;
> > >  }
> > >
> > >  if (pic->type == PICTURE_TYPE_IDR)
> > > --
> > > 2.7.4
> >
> > LGTM
>
> Thanks for review.
> A kindly ping.
>
> - linjie
>

LGTM

regards
Max
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-10-13 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu,
> Linjie
> Sent: Sunday, September 29, 2019 09:19
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> > -Original Message-
> > From: Li, Zhong 
> > Sent: Friday, September 13, 2019 00:05
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > vaMapBuffer returns multiple buffers
> >
> > > From: ffmpeg-devel  On Behalf Of
> > Linjie Fu
> > > Sent: Friday, May 31, 2019 8:35 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > > vaMapBuffer returns multiple buffers
> > >
> > > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> > map
> > > buffer for each slice.
> > >
> > > Currently, assigning new buffer for pkt when multiple buffer returns
> from
> > > vaMapBuffer will cover the previous encoded pkt data and lead to
> encode
> > issues.
> > >
> > > Iterate through the buf_list first to find out the total buffer size 
> > > needed
> for
> > the
> > > pkt, allocate the whole pkt to avoid repeated reallocation and memcpy,
> > then copy
> > > data from each buf to pkt.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> > >
> > >  libavcodec/vaapi_encode.c | 18 +-
> > >  1 file changed, 13 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index
> > > 2dda451..9c9e5dd 100644
> > > --- a/libavcodec/vaapi_encode.c
> > > +++ b/libavcodec/vaapi_encode.c
> > > @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> > *avctx,
> > >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > >  VACodedBufferSegment *buf_list, *buf;
> > >  VAStatus vas;
> > > +int total_size = 0;
> > > +uint8_t *ptr;
> > >  int err;
> > >
> > >  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static int
> > > vaapi_encode_output(AVCodecContext *avctx,
> > >  goto fail;
> > >  }
> > >
> > > +for (buf = buf_list; buf; buf = buf->next)
> > > +total_size += buf->size;
> > > +
> > > +err = av_new_packet(pkt, total_size);
> > > +ptr = pkt->data;
> > > +
> > > +if (err < 0)
> > > +goto fail_mapped;
> > > +
> > >  for (buf = buf_list; buf; buf = buf->next) {
> > >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > > "(status %08x).\n", buf->size, buf->status);
> > >
> > > -err = av_new_packet(pkt, buf->size);
> > > -if (err < 0)
> > > -goto fail_mapped;
> > > -
> > > -memcpy(pkt->data, buf->buf, buf->size);
> > > +memcpy(ptr, buf->buf, buf->size);
> > > +ptr += buf->size;
> > >  }
> > >
> > >  if (pic->type == PICTURE_TYPE_IDR)
> > > --
> > > 2.7.4
> >
> > LGTM
> 
> Thanks for review.
> A kindly ping.
> 
ping?

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-09-28 Thread Fu, Linjie
> -Original Message-
> From: Li, Zhong 
> Sent: Friday, September 13, 2019 00:05
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Fu, Linjie 
> Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> > From: ffmpeg-devel  On Behalf Of
> Linjie Fu
> > Sent: Friday, May 31, 2019 8:35 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> > vaMapBuffer returns multiple buffers
> >
> > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> map
> > buffer for each slice.
> >
> > Currently, assigning new buffer for pkt when multiple buffer returns from
> > vaMapBuffer will cover the previous encoded pkt data and lead to encode
> issues.
> >
> > Iterate through the buf_list first to find out the total buffer size needed 
> > for
> the
> > pkt, allocate the whole pkt to avoid repeated reallocation and memcpy,
> then copy
> > data from each buf to pkt.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> >
> >  libavcodec/vaapi_encode.c | 18 +-
> >  1 file changed, 13 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> > 2dda451..9c9e5dd 100644
> > --- a/libavcodec/vaapi_encode.c
> > +++ b/libavcodec/vaapi_encode.c
> > @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> *avctx,
> >  VAAPIEncodeContext *ctx = avctx->priv_data;
> >  VACodedBufferSegment *buf_list, *buf;
> >  VAStatus vas;
> > +int total_size = 0;
> > +uint8_t *ptr;
> >  int err;
> >
> >  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static int
> > vaapi_encode_output(AVCodecContext *avctx,
> >  goto fail;
> >  }
> >
> > +for (buf = buf_list; buf; buf = buf->next)
> > +total_size += buf->size;
> > +
> > +err = av_new_packet(pkt, total_size);
> > +ptr = pkt->data;
> > +
> > +if (err < 0)
> > +goto fail_mapped;
> > +
> >  for (buf = buf_list; buf; buf = buf->next) {
> >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > "(status %08x).\n", buf->size, buf->status);
> >
> > -err = av_new_packet(pkt, buf->size);
> > -if (err < 0)
> > -goto fail_mapped;
> > -
> > -memcpy(pkt->data, buf->buf, buf->size);
> > +memcpy(ptr, buf->buf, buf->size);
> > +ptr += buf->size;
> >  }
> >
> >  if (pic->type == PICTURE_TYPE_IDR)
> > --
> > 2.7.4
> 
> LGTM

Thanks for review.
A kindly ping.

- linjie

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-09-12 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Linjie Fu
> Sent: Friday, May 31, 2019 8:35 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to map
> buffer for each slice.
> 
> Currently, assigning new buffer for pkt when multiple buffer returns from
> vaMapBuffer will cover the previous encoded pkt data and lead to encode 
> issues.
> 
> Iterate through the buf_list first to find out the total buffer size needed 
> for the
> pkt, allocate the whole pkt to avoid repeated reallocation and memcpy, then 
> copy
> data from each buf to pkt.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> 
>  libavcodec/vaapi_encode.c | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> 2dda451..9c9e5dd 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext *avctx,
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>  VACodedBufferSegment *buf_list, *buf;
>  VAStatus vas;
> +int total_size = 0;
> +uint8_t *ptr;
>  int err;
> 
>  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static int
> vaapi_encode_output(AVCodecContext *avctx,
>  goto fail;
>  }
> 
> +for (buf = buf_list; buf; buf = buf->next)
> +total_size += buf->size;
> +
> +err = av_new_packet(pkt, total_size);
> +ptr = pkt->data;
> +
> +if (err < 0)
> +goto fail_mapped;
> +
>  for (buf = buf_list; buf; buf = buf->next) {
>  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> "(status %08x).\n", buf->size, buf->status);
> 
> -err = av_new_packet(pkt, buf->size);
> -if (err < 0)
> -goto fail_mapped;
> -
> -memcpy(pkt->data, buf->buf, buf->size);
> +memcpy(ptr, buf->buf, buf->size);
> +ptr += buf->size;
>  }
> 
>  if (pic->type == PICTURE_TYPE_IDR)
> --
> 2.7.4

LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-09-11 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Monday, August 19, 2019 10:04
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>; Mark Thompson 
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Fu, Linjie
> > Sent: Tuesday, August 6, 2019 16:12
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>; Mark Thompson 
> > Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet
> if
> > vaMapBuffer returns multiple buffers
> >
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > Of Fu, Linjie
> > > Sent: Tuesday, June 4, 2019 17:11
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Mark Thompson 
> > > Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow
> packet
> > if
> > > vaMapBuffer returns multiple buffers
> > >
> > > > -Original Message-
> > > > From: Fu, Linjie
> > > > Sent: Friday, May 31, 2019 08:35
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Fu, Linjie 
> > > > Subject: [PATCH,v2] lavc/vaapi_encode: grow packet if vaMapBuffer
> > > returns
> > > > multiple buffers
> > > >
> > > > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> > > map
> > > > buffer for each slice.
> > > >
> > > > Currently, assigning new buffer for pkt when multiple buffer returns
> > > > from vaMapBuffer will cover the previous encoded pkt data and lead
> > > > to encode issues.
> > > >
> > > > Iterate through the buf_list first to find out the total buffer size
> > > > needed for the pkt, allocate the whole pkt to avoid repeated
> reallocation
> > > > and memcpy, then copy data from each buf to pkt.
> > > >
> > > > Signed-off-by: Linjie Fu 
> > > > ---
> > > > [v2]: allocate the whole pkt to avoid repeated reallocation
> > > > and memcpy
> > > >
> > > >  libavcodec/vaapi_encode.c | 18 +-
> > > >  1 file changed, 13 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > > > index 2dda451..9c9e5dd 100644
> > > > --- a/libavcodec/vaapi_encode.c
> > > > +++ b/libavcodec/vaapi_encode.c
> > > > @@ -489,6 +489,8 @@ static int
> vaapi_encode_output(AVCodecContext
> > > > *avctx,
> > > >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > > >  VACodedBufferSegment *buf_list, *buf;
> > > >  VAStatus vas;
> > > > +int total_size = 0;
> > > > +uint8_t *ptr;
> > > >  int err;
> > > >
> > > >  err = vaapi_encode_wait(avctx, pic);
> > > > @@ -505,15 +507,21 @@ static int
> > vaapi_encode_output(AVCodecContext
> > > > *avctx,
> > > >  goto fail;
> > > >  }
> > > >
> > > > +for (buf = buf_list; buf; buf = buf->next)
> > > > +total_size += buf->size;
> > > > +
> > > > +err = av_new_packet(pkt, total_size);
> > > > +ptr = pkt->data;
> > > > +
> > > > +if (err < 0)
> > > > +goto fail_mapped;
> > > > +
> > > >  for (buf = buf_list; buf; buf = buf->next) {
> > > >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > > > "(status %08x).\n", buf->size, buf->status);
> > > >
> > > > -err = av_new_packet(pkt, buf->size);
> > > > -if (err < 0)
> > > > -goto fail_mapped;
> > > > -
> > > > -memcpy(pkt->data, buf->buf, buf->size);
> > > > +memcpy(ptr, buf->buf, buf->size);
> > > > +ptr += buf->size;
> > > >  }
> > > >
> > > >  if (pic->type == PICTURE_TYPE_IDR)
> > > > --
> > > > 2.7.4
> > >
> > > Ping?
> > > This can fix the encoding issue for vaapi_vp8:
> > > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -f
> > > rawvideo -pix_fmt yuv420p -s:v 1280x720 -i ./input_I420.yuv -vf
> > > 'format=nv12,hwupload' -c:v vp8_vaapi -rc_mode CQP -g 1 -
> global_quality
> > 14
> > > -loop_filter_sharpness 0 -loop_filter_level 0 -vframes 10 -y out.ivf
> >
> > Media driver will return 2 buffers in fact. The first buffer is
> > VACodedBufferSegment
> > buffer which includes encoded output. And the second buffer is extra
> > VACodedBufferVP9Status.
> > https://github.com/intel/media-driver/issues/624
> >
> > Fixes vp8 encoding issues for core platforms(Kaby Lake) and could be
> verified.
> > Ping?
> >
> Another ping?
> Had passed the regression patch check in https://github.com/intel-media-
> ci/ffmpeg/pull/44
> 
ping x 4?
This fixes  vp8/vp9 encoding.

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-08-18 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Tuesday, August 6, 2019 16:12
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>; Mark Thompson 
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Fu, Linjie
> > Sent: Tuesday, June 4, 2019 17:11
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Mark Thompson 
> > Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet
> if
> > vaMapBuffer returns multiple buffers
> >
> > > -Original Message-
> > > From: Fu, Linjie
> > > Sent: Friday, May 31, 2019 08:35
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [PATCH,v2] lavc/vaapi_encode: grow packet if vaMapBuffer
> > returns
> > > multiple buffers
> > >
> > > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> > map
> > > buffer for each slice.
> > >
> > > Currently, assigning new buffer for pkt when multiple buffer returns
> > > from vaMapBuffer will cover the previous encoded pkt data and lead
> > > to encode issues.
> > >
> > > Iterate through the buf_list first to find out the total buffer size
> > > needed for the pkt, allocate the whole pkt to avoid repeated reallocation
> > > and memcpy, then copy data from each buf to pkt.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > [v2]: allocate the whole pkt to avoid repeated reallocation
> > > and memcpy
> > >
> > >  libavcodec/vaapi_encode.c | 18 +-
> > >  1 file changed, 13 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > > index 2dda451..9c9e5dd 100644
> > > --- a/libavcodec/vaapi_encode.c
> > > +++ b/libavcodec/vaapi_encode.c
> > > @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> > > *avctx,
> > >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > >  VACodedBufferSegment *buf_list, *buf;
> > >  VAStatus vas;
> > > +int total_size = 0;
> > > +uint8_t *ptr;
> > >  int err;
> > >
> > >  err = vaapi_encode_wait(avctx, pic);
> > > @@ -505,15 +507,21 @@ static int
> vaapi_encode_output(AVCodecContext
> > > *avctx,
> > >  goto fail;
> > >  }
> > >
> > > +for (buf = buf_list; buf; buf = buf->next)
> > > +total_size += buf->size;
> > > +
> > > +err = av_new_packet(pkt, total_size);
> > > +ptr = pkt->data;
> > > +
> > > +if (err < 0)
> > > +goto fail_mapped;
> > > +
> > >  for (buf = buf_list; buf; buf = buf->next) {
> > >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > > "(status %08x).\n", buf->size, buf->status);
> > >
> > > -err = av_new_packet(pkt, buf->size);
> > > -if (err < 0)
> > > -goto fail_mapped;
> > > -
> > > -memcpy(pkt->data, buf->buf, buf->size);
> > > +memcpy(ptr, buf->buf, buf->size);
> > > +ptr += buf->size;
> > >  }
> > >
> > >  if (pic->type == PICTURE_TYPE_IDR)
> > > --
> > > 2.7.4
> >
> > Ping?
> > This can fix the encoding issue for vaapi_vp8:
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -f
> > rawvideo -pix_fmt yuv420p -s:v 1280x720 -i ./input_I420.yuv -vf
> > 'format=nv12,hwupload' -c:v vp8_vaapi -rc_mode CQP -g 1 -global_quality
> 14
> > -loop_filter_sharpness 0 -loop_filter_level 0 -vframes 10 -y out.ivf
> 
> Media driver will return 2 buffers in fact. The first buffer is
> VACodedBufferSegment
> buffer which includes encoded output. And the second buffer is extra
> VACodedBufferVP9Status.
> https://github.com/intel/media-driver/issues/624
> 
> Fixes vp8 encoding issues for core platforms(Kaby Lake) and could be verified.
> Ping?
> 
Another ping?
Had passed the regression patch check in 
https://github.com/intel-media-ci/ffmpeg/pull/44

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-08-06 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Tuesday, June 4, 2019 17:11
> To: ffmpeg-devel@ffmpeg.org
> Cc: Mark Thompson 
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> > -Original Message-
> > From: Fu, Linjie
> > Sent: Friday, May 31, 2019 08:35
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [PATCH,v2] lavc/vaapi_encode: grow packet if vaMapBuffer
> returns
> > multiple buffers
> >
> > It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to
> map
> > buffer for each slice.
> >
> > Currently, assigning new buffer for pkt when multiple buffer returns
> > from vaMapBuffer will cover the previous encoded pkt data and lead
> > to encode issues.
> >
> > Iterate through the buf_list first to find out the total buffer size
> > needed for the pkt, allocate the whole pkt to avoid repeated reallocation
> > and memcpy, then copy data from each buf to pkt.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > [v2]: allocate the whole pkt to avoid repeated reallocation
> > and memcpy
> >
> >  libavcodec/vaapi_encode.c | 18 +-
> >  1 file changed, 13 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > index 2dda451..9c9e5dd 100644
> > --- a/libavcodec/vaapi_encode.c
> > +++ b/libavcodec/vaapi_encode.c
> > @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> > *avctx,
> >  VAAPIEncodeContext *ctx = avctx->priv_data;
> >  VACodedBufferSegment *buf_list, *buf;
> >  VAStatus vas;
> > +int total_size = 0;
> > +uint8_t *ptr;
> >  int err;
> >
> >  err = vaapi_encode_wait(avctx, pic);
> > @@ -505,15 +507,21 @@ static int vaapi_encode_output(AVCodecContext
> > *avctx,
> >  goto fail;
> >  }
> >
> > +for (buf = buf_list; buf; buf = buf->next)
> > +total_size += buf->size;
> > +
> > +err = av_new_packet(pkt, total_size);
> > +ptr = pkt->data;
> > +
> > +if (err < 0)
> > +goto fail_mapped;
> > +
> >  for (buf = buf_list; buf; buf = buf->next) {
> >  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> > "(status %08x).\n", buf->size, buf->status);
> >
> > -err = av_new_packet(pkt, buf->size);
> > -if (err < 0)
> > -goto fail_mapped;
> > -
> > -memcpy(pkt->data, buf->buf, buf->size);
> > +memcpy(ptr, buf->buf, buf->size);
> > +ptr += buf->size;
> >  }
> >
> >  if (pic->type == PICTURE_TYPE_IDR)
> > --
> > 2.7.4
> 
> Ping?
> This can fix the encoding issue for vaapi_vp8:
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -f
> rawvideo -pix_fmt yuv420p -s:v 1280x720 -i ./input_I420.yuv -vf
> 'format=nv12,hwupload' -c:v vp8_vaapi -rc_mode CQP -g 1 -global_quality 14
> -loop_filter_sharpness 0 -loop_filter_level 0 -vframes 10 -y out.ivf

Media driver will return 2 buffers in fact. The first buffer is 
VACodedBufferSegment
buffer which includes encoded output. And the second buffer is extra 
VACodedBufferVP9Status.
https://github.com/intel/media-driver/issues/624

Fixes vp8 encoding issues for core platforms(Kaby Lake) and could be verified.
Ping?

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-06-04 Thread Fu, Linjie
> -Original Message-
> From: Fu, Linjie
> Sent: Friday, May 31, 2019 08:35
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH,v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns
> multiple buffers
> 
> It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to map
> buffer for each slice.
> 
> Currently, assigning new buffer for pkt when multiple buffer returns
> from vaMapBuffer will cover the previous encoded pkt data and lead
> to encode issues.
> 
> Iterate through the buf_list first to find out the total buffer size
> needed for the pkt, allocate the whole pkt to avoid repeated reallocation
> and memcpy, then copy data from each buf to pkt.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: allocate the whole pkt to avoid repeated reallocation
> and memcpy
> 
>  libavcodec/vaapi_encode.c | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 2dda451..9c9e5dd 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext
> *avctx,
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>  VACodedBufferSegment *buf_list, *buf;
>  VAStatus vas;
> +int total_size = 0;
> +uint8_t *ptr;
>  int err;
> 
>  err = vaapi_encode_wait(avctx, pic);
> @@ -505,15 +507,21 @@ static int vaapi_encode_output(AVCodecContext
> *avctx,
>  goto fail;
>  }
> 
> +for (buf = buf_list; buf; buf = buf->next)
> +total_size += buf->size;
> +
> +err = av_new_packet(pkt, total_size);
> +ptr = pkt->data;
> +
> +if (err < 0)
> +goto fail_mapped;
> +
>  for (buf = buf_list; buf; buf = buf->next) {
>  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> "(status %08x).\n", buf->size, buf->status);
> 
> -err = av_new_packet(pkt, buf->size);
> -if (err < 0)
> -goto fail_mapped;
> -
> -memcpy(pkt->data, buf->buf, buf->size);
> +memcpy(ptr, buf->buf, buf->size);
> +ptr += buf->size;
>  }
> 
>  if (pic->type == PICTURE_TYPE_IDR)
> --
> 2.7.4

Ping?
This can fix the encoding issue for vaapi_vp8:
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose -f rawvideo 
-pix_fmt yuv420p -s:v 1280x720 -i ./input_I420.yuv -vf 'format=nv12,hwupload' 
-c:v vp8_vaapi -rc_mode CQP -g 1 -global_quality 14 -loop_filter_sharpness 0 
-loop_filter_level 0 -vframes 10 -y out.ivf
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-05-30 Thread Linjie Fu
It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to map
buffer for each slice.

Currently, assigning new buffer for pkt when multiple buffer returns
from vaMapBuffer will cover the previous encoded pkt data and lead
to encode issues.

Iterate through the buf_list first to find out the total buffer size
needed for the pkt, allocate the whole pkt to avoid repeated reallocation
and memcpy, then copy data from each buf to pkt.

Signed-off-by: Linjie Fu 
---
[v2]: allocate the whole pkt to avoid repeated reallocation
and memcpy

 libavcodec/vaapi_encode.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 2dda451..9c9e5dd 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext *avctx,
 VAAPIEncodeContext *ctx = avctx->priv_data;
 VACodedBufferSegment *buf_list, *buf;
 VAStatus vas;
+int total_size = 0;
+uint8_t *ptr;
 int err;
 
 err = vaapi_encode_wait(avctx, pic);
@@ -505,15 +507,21 @@ static int vaapi_encode_output(AVCodecContext *avctx,
 goto fail;
 }
 
+for (buf = buf_list; buf; buf = buf->next)
+total_size += buf->size;
+
+err = av_new_packet(pkt, total_size);
+ptr = pkt->data;
+
+if (err < 0)
+goto fail_mapped;
+
 for (buf = buf_list; buf; buf = buf->next) {
 av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
"(status %08x).\n", buf->size, buf->status);
 
-err = av_new_packet(pkt, buf->size);
-if (err < 0)
-goto fail_mapped;
-
-memcpy(pkt->data, buf->buf, buf->size);
+memcpy(ptr, buf->buf, buf->size);
+ptr += buf->size;
 }
 
 if (pic->type == PICTURE_TYPE_IDR)
-- 
2.7.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".