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 40C85457B7 for ; Sun, 23 Apr 2023 22:21:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 489E468BE6F; Mon, 24 Apr 2023 01:21:34 +0300 (EEST) Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63F0668BF32 for ; Mon, 24 Apr 2023 01:21:27 +0300 (EEST) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-b9941f4a652so146645276.0 for ; Sun, 23 Apr 2023 15:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682288486; x=1684880486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xOC8Fpu/ZX8R1K3kLJ0J71RKCSJEwz+obMF8BmU/0T0=; b=qPT8TgKGjKHBNGvw+TdJypi+hqUYlnPu1MyIj6K0G7IiyIJy/NhaOlgBepU5zr1d2e p5KcRKmW7CYm1EPdVjp354odjIuLq4Y/OnHm6ob1S2ksr++fX/qL3VYPuSaQgGMTaJgP Qujra4gQQ0XYTkoz3mokae0mFVBYPvAHQvwSri5psIbf5DcNnE4IuVilurFDxqmV0IhB En19TUFs2AXuw/5H2sjzaRWhsX52LDGwKB61f2KhmwJC6NvhC6LlnJFy3zXnbI2Eyt/h A6amML9KkwhCpCVnsPsgwtbNMcmo5DH8NCELmhJPj/dPkAP2b5j5zISGWjdfSAyWNwva 3QbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682288486; x=1684880486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xOC8Fpu/ZX8R1K3kLJ0J71RKCSJEwz+obMF8BmU/0T0=; b=fZFW6sbGK4fhvFU9tf1ndcgR7XAB6sverq8x/+TG32LO6gvzNgJ61+Vw4wS4o3+f6Q VWatPyi1zbagWiDGLu20lw/n+8lnVuN1QzK3LYRjPn92h8h75Zxnd9W+2kDzxnuh1MoE 09ut0kS6wkyf+EtN3fE2NezudJrpJTT6zKlHlitcYNpRX3jWA6wlbPXZZy3kUy1Uh2/m 4Vu8a4ztYtxGUmREo6n0eHLSAXkhmycB+0OmbWAmxoAbGwwQmPA29p28mDHNfjX/eiS5 y/yKlumrRDC78RhhHrQzJ5Q5OnjcVqjfx3vYTO4iWxwvpfFxqKyURkSn2sg2RJT8TPvt Ed1w== X-Gm-Message-State: AAQBX9fXVorOLHpmqXqcxPWkz+7SEKhu0BFuORDHA1HQKZCgwCXBXnid z2R4pX9sdl7306nUXui/HFjjghgGUEU= X-Google-Smtp-Source: AKy350blN/hBp5qXmru5IoFFnGNAvkjUJRof0Sc0XEFbpwZTKch8HGq94a7ULicRNLu6I4XC4wmDKQ== X-Received: by 2002:a81:593:0:b0:54c:c7a:5c8a with SMTP id 141-20020a810593000000b0054c0c7a5c8amr8409314ywf.1.1682288485967; Sun, 23 Apr 2023 15:21:25 -0700 (PDT) Received: from gauss.local (c-98-224-219-15.hsd1.mi.comcast.net. [98.224.219.15]) by smtp.gmail.com with ESMTPSA id h190-20020a0dc5c7000000b00545a08184f8sm2544425ywd.136.2023.04.23.15.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 15:21:25 -0700 (PDT) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Apr 2023 18:21:06 -0400 Message-Id: <20230423222106.41220-2-leo.izen@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230423222106.41220-1-leo.izen@gmail.com> References: <20230423222106.41220-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/1] avcodec/mjpegdec: support more pixel formats 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: ceffmpeg@gmail.com, leo.izen@gmail.com 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: From: Carl Eugen Hoyos Support pixel formats 0x11412100, 0x11311100, and 0x41211100, and add logic to perform 4x horizontal upsampling. This should fix various JPEG files found in Ticket #8930. Co-authored-by: --- libavcodec/mjpegdec.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 9b55002c4b..72d654080d 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -545,6 +545,18 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) } av_assert0(s->nb_components == 4); break; + case 0x11412100: + if (s->bits > 8) + goto unk_pixfmt; + if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') { + s->avctx->pix_fmt = AV_PIX_FMT_GBRP; + s->upscale_h[0] = 4; + s->upscale_h[1] = 0; + s->upscale_h[2] = 1; + } else { + goto unk_pixfmt; + } + break; case 0x22111122: case 0x22111111: if (s->adobe_transform == 0 && s->bits <= 8) { @@ -626,6 +638,15 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } break; + case 0x11311100: + if (s->bits > 8) + goto unk_pixfmt; + if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') + s->avctx->pix_fmt = AV_PIX_FMT_GBRP; + else + goto unk_pixfmt; + s->upscale_h[0] = s->upscale_h[2] = 2; + break; case 0x31111100: if (s->bits > 8) goto unk_pixfmt; @@ -635,6 +656,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) break; case 0x22121100: case 0x22111200: + case 0x41211100: if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P; else goto unk_pixfmt; @@ -2605,6 +2627,8 @@ the_end: avctx->pix_fmt == AV_PIX_FMT_YUVJ440P || avctx->pix_fmt == AV_PIX_FMT_YUV440P || avctx->pix_fmt == AV_PIX_FMT_YUVA444P || + avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || + avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16|| @@ -2654,6 +2678,24 @@ the_end: for (index = w - 3; index > 0; index--) { line[index] = (line[index / 3] + line[(index + 1) / 3] + line[(index + 2) / 3] + 1) / 3; } + } else if (s->upscale_h[p] == 4){ + if (is16bit) { + uint16_t *line16 = (uint16_t *) line; + line16[w - 1] = line16[(w - 1) >> 2]; + if (w > 1) + line16[w - 2] = (line16[(w - 1) >> 2] * 3 + line16[(w - 2) >> 2]) >> 2; + if (w > 2) + line16[w - 3] = (line16[(w - 1) >> 2] + line16[(w - 2) >> 2]) >> 1; + } else { + line[w - 1] = line[(w - 1) >> 2]; + if (w > 1) + line[w - 2] = (line[(w - 1) >> 2] * 3 + line[(w - 2) >> 2]) >> 2; + if (w > 2) + line[w - 3] = (line[(w - 1) >> 2] + line[(w - 2) >> 2]) >> 1; + } + for (index = w - 4; index > 0; index--) + line[index] = (line[(index + 3) >> 2] + line[(index + 2) >> 2] + + line[(index + 1) >> 2] + line[index >> 2]) >> 2; } line += s->linesize[p]; } -- 2.40.0 _______________________________________________ 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".