diff mbox series

[FFmpeg-devel] avcodec/qpeg: speed-up copy of bytes

Message ID 20200831213707.29145-1-onemda@gmail.com
State Accepted
Commit 97c73ba56505e180f6ab8f49b7b5642e0c09fa09
Headers show
Series [FFmpeg-devel] avcodec/qpeg: speed-up copy of bytes | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Paul B Mahol Aug. 31, 2020, 9:37 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/qpeg.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Anton Khirnov Sept. 1, 2020, 11:17 a.m. UTC | #1
Quoting Paul B Mahol (2020-08-31 23:37:07)
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/qpeg.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
> index 40931e3bdc..8bc710acfd 100644
> --- a/libavcodec/qpeg.c
> +++ b/libavcodec/qpeg.c
> @@ -101,8 +101,11 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
>          } else {
>              if (bytestream2_get_bytes_left(&qctx->buffer) < copy)
>                  copy = bytestream2_get_bytes_left(&qctx->buffer);
> -            for(i = 0; i < copy; i++) {
> -                dst[filled++] = bytestream2_get_byte(&qctx->buffer);
> +            while (copy > 0) {
> +                int step = FFMIN(copy, width - filled);
> +                bytestream2_get_bufferu(&qctx->buffer, dst + filled, step);
> +                filled += step;
> +                copy -= step;
>                  if (filled >= width) {
>                      filled = 0;
>                      dst -= stride;
> -- 
> 2.17.1

Looks ok.
diff mbox series

Patch

diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index 40931e3bdc..8bc710acfd 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -101,8 +101,11 @@  static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst,
         } else {
             if (bytestream2_get_bytes_left(&qctx->buffer) < copy)
                 copy = bytestream2_get_bytes_left(&qctx->buffer);
-            for(i = 0; i < copy; i++) {
-                dst[filled++] = bytestream2_get_byte(&qctx->buffer);
+            while (copy > 0) {
+                int step = FFMIN(copy, width - filled);
+                bytestream2_get_bufferu(&qctx->buffer, dst + filled, step);
+                filled += step;
+                copy -= step;
                 if (filled >= width) {
                     filled = 0;
                     dst -= stride;