From patchwork Sun Jun 12 17:18:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 36176 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp97001pzb; Sun, 12 Jun 2022 10:19:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/DjI4KGtD8GkQaNDBcqPx+52uc7re/ppHbhR2StzhC7P7gbd/y9nWb5ddvl5icKHq2od5 X-Received: by 2002:a05:6402:84a:b0:423:fe99:8c53 with SMTP id b10-20020a056402084a00b00423fe998c53mr60569138edz.195.1655054346508; Sun, 12 Jun 2022 10:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655054346; cv=none; d=google.com; s=arc-20160816; b=T/Q9XX20KzyiRLXcCpR+EXEdsrUPgAyL5Ut6H8SSMAYlkh7yOWpwsdzdp64Y9ChIYH hAQg/pBkJDmtdi143FtZTpDif7JRViW4jZtByo+Uf03hH5aKyx7zyts1EWcMp4c4rvkv Y3DgY8vxRIn8IHvO1yo2pXI6tjTQvat9pVRDajzKCet3mNzlu2xcltPyM7Y9LVJO2Ezh ckpiPNluwFZnnbc0CLjTeDCojE3zy6lKFk22eRIzrHaEPA+oWPrJiCS98GNhHkG80oiO eeqpa8HzUFEkwZQSKwNq161okEUc4c37zs74AbU2z6ZgXFOTR8Rf51cDGyqDRub8nM0T F3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=aYvG9pbhdJ3gET5VF/FRsfe6bf17f/so35NjAk1XYLU=; b=PP5zvXnSNnqSKfzcJaR989gcWMRXcXD+C1gERqB2q3y/US/3mNtewyVw6bUQ8TnPV5 9MUYuDbT+uZptBRgcGeVTp1Oovq+7AmoQijHWDRjxpn6wkRQNaJIG2Acwdls7vvyh1YR KBNaByGsdC7swG00etxxX4FRSv+lm0++ZhbXRj+8QUwKwsJGcKPf2QFimBgk9+u6/th5 uHNXdFMjeIQPzWz3A4fgK7AgwDO5wcgH0PaB3yjbruiOmIyG/72vA8MbsxwI+vGPKytY Ik0bV0k349q+EMoWIMIO2mNttHTAJGUKlum+cu6OEIHE9iBYMxMFn2e0BJ3JbugILqRv htgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y5-20020a056402358500b004314951d63esi6389720edc.518.2022.06.12.10.19.05; Sun, 12 Jun 2022 10:19:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 72CEE68B4C5; Sun, 12 Jun 2022 20:19:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D08C56881AC 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 0BE2EE70F7; Sun, 12 Jun 2022 19:18:51 +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 zM1LqBr6dntr; Sun, 12 Jun 2022 19:18:49 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 914AAE6B25; Sun, 12 Jun 2022 19:18:49 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Jun 2022 19:18:39 +0200 Message-Id: <20220612171845.8122-1-cus@passwd.hu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ag2l15wkZpYc Fixes ticket #5195. Signed-off-by: Marton Balint --- libavcodec/v210dec.c | 49 +++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index 6c10ef6a7c..48ebe57100 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -60,14 +60,16 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th int slice_start = (avctx->height * jobnr) / s->thread_count; int slice_end = (avctx->height * (jobnr+1)) / s->thread_count; uint8_t *psrc = td->buf + stride * slice_start; - uint16_t *y, *u, *v; + int16_t *py = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2; + 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; - y = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2; - u = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2; - v = (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); @@ -85,25 +87,40 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th w += 6; } - if (w < avctx->width - 1) { + if (w++ < avctx->width) { READ_PIXELS(u, y, v); - val = av_le2ne32(*src++); - *y++ = val & 0x3FF; - if (w < avctx->width - 3) { - *u++ = (val >> 10) & 0x3FF; - *y++ = (val >> 20) & 0x3FF; - + if (w++ < avctx->width) { val = av_le2ne32(*src++); - *v++ = val & 0x3FF; - *y++ = (val >> 10) & 0x3FF; + *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; + } + } + } } } psrc += stride; - y += frame->linesize[0] / 2 - avctx->width + (avctx->width & 1); - u += frame->linesize[1] / 2 - avctx->width / 2; - v += frame->linesize[2] / 2 - avctx->width / 2; + py += frame->linesize[0] / 2; + pu += frame->linesize[1] / 2; + pv += frame->linesize[2] / 2; } return 0;