Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marton Balint <cus@passwd.hu>
To: ffmpeg-devel@ffmpeg.org
Cc: Marton Balint <cus@passwd.hu>
Subject: [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding
Date: Sun, 12 Jun 2022 19:18:40 +0200
Message-ID: <20220612171845.8122-2-cus@passwd.hu> (raw)
In-Reply-To: <20220612171845.8122-1-cus@passwd.hu>

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 108 +++++++++++++++++++++----------------------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 48ebe57100..c89440658f 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -50,10 +50,61 @@ static av_cold int decode_init(AVCodecContext *avctx)
     return 0;
 }
 
+static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, const int width,
+                       void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width))
+{
+    uint32_t val;
+    int w = (width / 12) * 12;
+
+    unpack_frame(src, y, u, v, w);
+
+    y += w;
+    u += w >> 1;
+    v += w >> 1;
+    src += (w << 1) / 3;
+
+    if (w < width - 5) {
+        READ_PIXELS(u, y, v);
+        READ_PIXELS(y, u, y);
+        READ_PIXELS(v, y, u);
+        READ_PIXELS(y, v, y);
+        w += 6;
+    }
+
+    if (w++ < width) {
+        READ_PIXELS(u, y, v);
+
+        if (w++ < width) {
+            val  = av_le2ne32(*src++);
+            *y++ =  val & 0x3FF;
+
+            if (w++ < width) {
+                *u++ = (val >> 10) & 0x3FF;
+                *y++ = (val >> 20) & 0x3FF;
+                val  = av_le2ne32(*src++);
+                *v++ =  val & 0x3FF;
+
+                if (w++ < width) {
+                    *y++ = (val >> 10) & 0x3FF;
+
+                    if (w++ < width) {
+                        *u++ = (val >> 20) & 0x3FF;
+                        val  = av_le2ne32(*src++);
+                        *y++ =  val & 0x3FF;
+                        *v++ = (val >> 10) & 0x3FF;
+
+                        if (w++ < width)
+                            *y++ = (val >> 20) & 0x3FF;
+                    }
+                }
+            }
+        }
+    }
+}
+
 static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 {
     V210DecContext *s = avctx->priv_data;
-    int h, w;
     ThreadData *td = arg;
     AVFrame *frame = td->frame;
     int stride = td->stride;
@@ -64,59 +115,8 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
     int16_t *pu = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
     int16_t *pv = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2;
 
-    for (h = slice_start; h < slice_end; h++) {
-        const uint32_t *src = (const uint32_t*)psrc;
-        uint32_t val;
-        uint16_t *y = py;
-        uint16_t *u = pu;
-        uint16_t *v = pv;
-
-        w = (avctx->width / 12) * 12;
-        s->unpack_frame(src, y, u, v, w);
-
-        y += w;
-        u += w >> 1;
-        v += w >> 1;
-        src += (w << 1) / 3;
-
-        if (w < avctx->width - 5) {
-            READ_PIXELS(u, y, v);
-            READ_PIXELS(y, u, y);
-            READ_PIXELS(v, y, u);
-            READ_PIXELS(y, v, y);
-            w += 6;
-        }
-
-        if (w++ < avctx->width) {
-            READ_PIXELS(u, y, v);
-
-            if (w++ < avctx->width) {
-                val  = av_le2ne32(*src++);
-                *y++ =  val & 0x3FF;
-
-                if (w++ < avctx->width) {
-                    *u++ = (val >> 10) & 0x3FF;
-                    *y++ = (val >> 20) & 0x3FF;
-                    val  = av_le2ne32(*src++);
-                    *v++ =  val & 0x3FF;
-
-                    if (w++ < avctx->width) {
-                        *y++ = (val >> 10) & 0x3FF;
-
-                        if (w++ < avctx->width) {
-                            *u++ = (val >> 20) & 0x3FF;
-                            val  = av_le2ne32(*src++);
-                            *y++ =  val & 0x3FF;
-                            *v++ = (val >> 10) & 0x3FF;
-
-                            if (w++ < avctx->width)
-                                *y++ = (val >> 20) & 0x3FF;
-                        }
-                    }
-                }
-            }
-        }
-
+    for (int h = slice_start; h < slice_end; h++) {
+        decode_row((const uint32_t *)psrc, py, pu, pv, avctx->width, s->unpack_frame);
         psrc += stride;
         py += frame->linesize[0] / 2;
         pu += frame->linesize[1] / 2;
-- 
2.34.1

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

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

  reply	other threads:[~2022-06-12 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
2022-06-12 17:18 ` Marton Balint [this message]
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 3/7] avcodec/v210dec: disallow negative custom stride Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 4/7] avcodec/v210dec: do not use accelerated code for the last pixels of a row Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 5/7] avcodec/v210dec: add support for invalid paddings up to 16 bytes Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 6/7] avcodec/v210dec: add support for strideless v210 as in BOXX files Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 7/7] doc/decoders: add docs for v210 decoder Marton Balint
2022-06-20 21:06 ` [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220612171845.8122-2-cus@passwd.hu \
    --to=cus@passwd.hu \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git