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 3BA1848416 for ; Mon, 4 Dec 2023 00:52:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F164E68CCBE; Mon, 4 Dec 2023 02:52:48 +0200 (EET) Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A885368CA34 for ; Mon, 4 Dec 2023 02:52:42 +0200 (EET) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-9fa2714e828so534259466b.1 for ; Sun, 03 Dec 2023 16:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701651161; x=1702255961; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=kXrJ/9xvQgq0zjEYwDZiO7Tubs38HjbMr3sdTzHv6Fo=; b=aURBjIiPA6cxzps7TURC567HhyqVEh57KTFX1v7TuujFxj+NWAC09kJLuwaCxyTIhl 5TVhN5N9jbsaDfgPrJ7WHXyIZKoVy50BXH+MGmCITcLSoY09aF3CZGqnkosLF/Z1kHp+ f+u68FYAH8A1fLJx1hAr7IvBNCDsJsUI512wIB52vWrtFr8jyATbhhcaUZEewWydGU5k xnd2la9Y8I/SI6U0rBv/nLoaogy6rOMUAbaIPeCFlu+JT4/n+r8HOQ2a0MB1i06gMyFn ywbJtptzuo0PhmsLYc/w13bzTW9k42pKBtYp5reaNSAiTiZWVPQuC/sV3kdhg7TQpmON bG8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701651161; x=1702255961; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kXrJ/9xvQgq0zjEYwDZiO7Tubs38HjbMr3sdTzHv6Fo=; b=HTcWl+GAvKOLAD9tRyXdEmdwyQ2xQhoUYsjNklNfFLNLR1z5bQF+mQuj9Btuesmor4 YyimvR3CPEGt9LLBkdCRd2fGYf+0bYSaisLHlGlFmfyX1vr9e6fJafwOTzLkaVhrS5UR 8zkT8fW9hwD26C31JebhONXEy31rqryAPgoqKXlQ7VoexLDc2vcXa2cZhT8tFlX4NoXF Ek/yW3u0Tz3bNM1k1h4h16PNKrYsJx4ZuYZlIENybuyjmnUZwY3RlUrstwGq4N5vdhT9 9+PoNdMt0Eb0HfS3yfI88keSsmrLIkP+hRM7dwQx20W33GL9zdSdICa+YLhheL55+/HV BzbQ== X-Gm-Message-State: AOJu0YwfT7moybcn7tv+PsIemktFnWSIe3MfWX7iGv3mpAqHcNlsFKWZ L8jJcRXPsoVQYa4bq5ZAI0/bTzf8/Lc= X-Google-Smtp-Source: AGHT+IH1uLaFwbSulPyb97HeE5XZOpH5lQ+4CrQMyDSTxyp8hkSH00QJPjw5Nelx47HRyXDEh1uh3A== X-Received: by 2002:a17:906:2210:b0:a19:a19b:55ff with SMTP id s16-20020a170906221000b00a19a19b55ffmr2971414ejs.143.1701651161004; Sun, 03 Dec 2023 16:52:41 -0800 (PST) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id s19-20020a170906355300b00a0949d4f637sm4659469eja.222.2023.12.03.16.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:52:40 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 0C447BFCDA; Mon, 4 Dec 2023 01:52:38 +0100 (CET) Date: Mon, 4 Dec 2023 01:52:38 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches , Marton Balint References: <20231203002726.29683-1-cus@passwd.hu> <20231203002726.29683-4-cus@passwd.hu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231203002726.29683-4-cus@passwd.hu> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH 4/7] avutil/imgutils: add support for 32bit pixel format for av_image_fill_black() 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: On date Sunday 2023-12-03 01:27:23 +0100, Marton Balint wrote: > Signed-off-by: Marton Balint > --- > libavutil/imgutils.c | 32 ++++++++++++++++++++++---------- > tests/ref/fate/imgutils | 24 ++++++++++++------------ > 2 files changed, 34 insertions(+), 22 deletions(-) > > diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c > index 5e401139c8..26bb2f2c6f 100644 > --- a/libavutil/imgutils.c > +++ b/libavutil/imgutils.c > @@ -590,7 +590,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz > uint8_t clear_block[4][MAX_BLOCK_SIZE] = {{0}}; // clear padding with 0 > int clear_block_size[4] = {0}; > ptrdiff_t plane_line_bytes[4] = {0}; > - int rgb, xyz, pal, limited, alpha, bitstream; > + int rgb, xyz, pal, limited, alpha, bitstream, fltp; > int plane, c; > > if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) > @@ -602,6 +602,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz > limited = !rgb && !xyz && !pal && range != AVCOL_RANGE_JPEG; > alpha = !pal && !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA); > bitstream = !!(desc->flags & AV_PIX_FMT_FLAG_BITSTREAM); > + fltp = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT); > > for (c = 0; c < desc->nb_components; c++) { > const AVComponentDescriptor comp = desc->comp[c]; > @@ -621,11 +622,11 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz > int w = (bitstream ? 8 : 1) * clear_block_size[comp.plane] / comp.step; > uint8_t *c_data[4]; > const int c_linesize[4] = {0}; > - uint16_t src_array[MAX_BLOCK_SIZE]; > - uint16_t src = 0; > + uint32_t src_array[MAX_BLOCK_SIZE]; > + uint32_t src = 0; > int x; > > - if (comp.depth > 16) > + if (comp.depth > 32) > return AVERROR(EINVAL); > if (w < 1) > return AVERROR(EINVAL); > @@ -634,15 +635,26 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz > src = 1; > } else if (c + 1 == desc->nb_components && alpha) { > // (Assume even limited YUV uses full range alpha.) > - src = (1 << comp.depth) - 1; > + if (fltp && comp.depth != 16 && comp.depth != 32) > + return AVERROR(EINVAL); nit+: this might be merged in the if (fltp) branch below for clarity and to avoid a branch > + if (fltp) > + src = (comp.depth == 16 ? 0x3C00 : 0x3F800000); // 1.0 > + else > + src = (comp.depth == 32 ? 0 : (1 << comp.depth)) - 1; > } else if (c == 0 && limited && comp.depth > 1) { > - if (comp.depth < 8) > + if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32) nit: use () to group the right hand part of the or, or this might confuse the human reader > return AVERROR(EINVAL); > - src = 16 << (comp.depth - 8); > + if (fltp) > + src = (comp.depth == 16 ? 0x3000 : 0x3D800000); // 0.0625 > + else > + src = 16 << (comp.depth - 8); > } else if ((c == 1 || c == 2) && !rgb && !xyz) { > - if (comp.depth < 8) > + if (comp.depth < 8 || fltp && comp.depth != 16 && comp.depth != 32) > return AVERROR(EINVAL); > - src = 128 << (comp.depth - 8); > + if (fltp) > + src = (comp.depth == 16 ? 0x3800 : 0x3F000000); // 0.5 > + else > + src = 128 << (comp.depth - 8); > } > > for (x = 0; x < w; x++) > @@ -651,7 +663,7 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz > for (x = 0; x < 4; x++) > c_data[x] = &clear_block[x][0]; > > - av_write_image_line(src_array, c_data, c_linesize, desc, 0, 0, c, w); > + av_write_image_line2(src_array, c_data, c_linesize, desc, 0, 0, c, w, 4); > } > LGTM otherwise. _______________________________________________ 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".