From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A7D9742AF6 for ; Sun, 12 Jun 2022 17:19:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E55C68B546; Sun, 12 Jun 2022 20:19:04 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D4C1868B4B8 for ; Sun, 12 Jun 2022 20:18:56 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7E4E8E7254; Sun, 12 Jun 2022 19:18:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AsppboHGuMoe; Sun, 12 Jun 2022 19:18:51 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EF177E72B5; Sun, 12 Jun 2022 19:18:50 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Jun 2022 19:18:40 +0200 Message-Id: <20220612171845.8122-2-cus@passwd.hu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220612171845.8122-1-cus@passwd.hu> References: <20220612171845.8122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Marton Balint --- 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".