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 CC57D4783D for ; Thu, 26 Oct 2023 11:03:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E6D8568CAAF; Thu, 26 Oct 2023 14:03:16 +0300 (EEST) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2045.outbound.protection.outlook.com [40.92.48.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4127F68B460 for ; Thu, 26 Oct 2023 14:03:11 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jxYj78K2ypqXlYLo77hTkuFRZy9SvjSLoflxehWCN8d9/5W/FB9bQM7GMfrVCmPh/czfwZSA93KXRoODlic8JuBF2RSy4jdxTcJTxNFTN6IYSC2Ttl+XK58iUqhzJWib6pC8hz4tlQnhmYuRsbJv/GGST+H5miMHupFQiyGCOxe+Fgw0Zf2bI7oLnWADQGstL0PQv0D4wYtXNsLFLzELhy3AleblwOw6iLDgHIFfFsC9f5XfgUwAwo37sL7E9OM96jFgmsVtb2Goga8MB27vBlH+I6cb5D5Fg7DF/wVDDfqMD9idA3v3AxK2QtW2GwenS+TPesV0FQ+94Wba4bc6og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wzivWONklVSuvoTgLESe0SOxtRsOS5O/FemVRYwjZZc=; b=gGVhdAz7+vgkqCpYHY3DsZeACz3KtUUHxxxDwZRaD5fnF5S6BMCc1IROHvvhyQxVMrU/4sDSZHjN3+zIdPTDYxAt/nxSeVUuiwLQUbkq0KKvzdz+OT0+a6r1EiMNcgu/roBi8Gp24DF7YwArmZfY0BkSh1HqfoyaWDveKUqDRvwIEXRvZz1OQil8ed6P3ccN6Ml0QoVfNNUA3a4JBxUh9v7QnNb/6tEw6RNvfJTZDfTQ4Cb1AnWzdI6jG7qCcwSsxl1ErBZ8/m4STXF/lvYMQWD8qpGr/fSEijqovBU6vL+MZvK11HfXAW74VHPjl7m9Q9YJCm2JiMr6FPzsePr9Uw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wzivWONklVSuvoTgLESe0SOxtRsOS5O/FemVRYwjZZc=; b=t9l2hJET8k3A8hCn5M4ZEzY4iWEbI5iVP/0o7oNFToX6cwwByYHW/3Yn90aweRTFI+9+TK4yGZAm0mCiPusFiWG9HTtRAJIBBiNltupEJgq0Fu4s5YfBQSu4x5TmGn41yq0H7h1HzsC7vRItXjWjZwLWzwTB6QfYoW0h+4oraRN2p87k+EiSMuLejhEJnfrtGnuH/gdYvddohtR+ydAhBORc+uCxiS+xf2RftcHd5faa805xwMBYNjhVheRrFsXEvX6lA85/oEDskRuMslW9FSzdrRtW0PkRax50rjTVsDwsMa2k+YWKy5nRtebFMPmQ7wCs296EX8A3HmsdCLGaBQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0210.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:179::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Thu, 26 Oct 2023 11:03:06 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde%3]) with mapi id 15.20.6907.030; Thu, 26 Oct 2023 11:03:06 +0000 Message-ID: Date: Thu, 26 Oct 2023 13:04:23 +0200 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20231024111314.54717-1-leo.izen@gmail.com> From: Andreas Rheinhardt In-Reply-To: <20231024111314.54717-1-leo.izen@gmail.com> X-TMN: [PfMZeS9/MA9JhjRTDc54ENZ0bZnPOud1kfkkHtaS17Q=] X-ClientProxiedBy: ZR2P278CA0010.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::14) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0210:EE_ X-MS-Office365-Filtering-Correlation-Id: 4afdbbf1-1698-4738-4bb2-08dbd61321a9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hR5pzz7KFuojNcLckOL2fHnuzqDnAYZq3Uk3DAk1j6nzf64pAGcEn6IafuJ2BUTNDalO68IGddYTjDmB+hl8hcjpTsnExWOrY3fpYBGj4Rn7iPaThQ1FEtJIAL2LWAUjPefhdwq27ioYGQyE9S1gnI2Zuk5IimZy6YKYFpkDzd0oovhX347i/jjpNUD3l+hP3NtZnIiHrH5cBnThMqt9ZKYODJq+Fb7ZpTWt6CkDd/JKqEgcdU8bLK6+YIVY4wmcLyS7Cf4vrL5719YnP9O5t82x958KSvx3VgH1OLShdQU53bTBL9vpecfXngUAQVz7kMgQCdPRHJ90HIkj+Xwtn+M2Amtug+kN6k5wgsgNdwW4P8WzBR1REuZFSVdpoPPqD91ocYKc9YEPigShf4q48fwiInQqybdJaS4NMMjoO/VhrkhUhHsqSXXls/zR3EXJws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8?B?bDljRGRLcTRkRjF4bmJEdTJNLyszemxUOWRNdi9UMnBoVlcvZWNPdzgwVmdm?= =?utf-8?Q?/0au5KJgDA2LrECxoO+H?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4afdbbf1-1698-4738-4bb2-08dbd61321a9 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 11:03:06.3295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0210 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/pngdec: various stylistic changes 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 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: Leo Izen: > Various parts of this file are restructured slightly for readability, > such as spacing in arithmetic operations, and putting `if (ret < 0)` > clauses on separate lines. > > Signed-off-by: Leo Izen > --- > libavcodec/pngdec.c | 241 +++++++++++++++++++++++--------------------- > 1 file changed, 124 insertions(+), 117 deletions(-) > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c > index d812ffd348..93b067a9be 100644 > --- a/libavcodec/pngdec.c > +++ b/libavcodec/pngdec.c > @@ -128,7 +128,7 @@ static const uint8_t png_pass_dsp_ymask[NB_PASSES] = { > > /* Mask to determine which pixels to overwrite while displaying */ > static const uint8_t png_pass_dsp_mask[NB_PASSES] = { > - 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff > + 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff, > }; > > /* NOTE: we try to construct a good looking image at each pass. width > @@ -152,7 +152,7 @@ static void png_put_interlaced_row(uint8_t *dst, int width, > j = (x & 7); > if ((dsp_mask << j) & 0x80) { > b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1; > - dst[x >> 3] &= 0xFF7F>>j; > + dst[x >> 3] &= 0xff7f >> j; > dst[x >> 3] |= b << (7 - j); > } > if ((mask << j) & 0x80) > @@ -165,8 +165,8 @@ static void png_put_interlaced_row(uint8_t *dst, int width, > int j2 = 2 * (x & 3); > j = (x & 7); > if ((dsp_mask << j) & 0x80) { > - b = (src[src_x >> 2] >> (6 - 2*(src_x & 3))) & 3; > - dst[x >> 2] &= 0xFF3F>>j2; > + b = (src[src_x >> 2] >> (6 - 2 * (src_x & 3))) & 3; > + dst[x >> 2] &= 0xff3f >> j2; > dst[x >> 2] |= b << (6 - j2); > } > if ((mask << j) & 0x80) > @@ -176,11 +176,11 @@ static void png_put_interlaced_row(uint8_t *dst, int width, > case 4: > src_x = 0; > for (x = 0; x < width; x++) { > - int j2 = 4*(x&1); > + int j2 = 4 * (x & 1); > j = (x & 7); > if ((dsp_mask << j) & 0x80) { > - b = (src[src_x >> 1] >> (4 - 4*(src_x & 1))) & 15; > - dst[x >> 1] &= 0xFF0F>>j2; > + b = (src[src_x >> 1] >> (4 - 4 * (src_x & 1))) & 15; > + dst[x >> 1] &= 0xff0f >> j2; > dst[x >> 1] |= b << (4 - j2); > } > if ((mask << j) & 0x80) > @@ -191,15 +191,14 @@ static void png_put_interlaced_row(uint8_t *dst, int width, > bpp = bits_per_pixel >> 3; > d = dst; > s = src; > - for (x = 0; x < width; x++) { > - j = x & 7; > - if ((dsp_mask << j) & 0x80) { > - memcpy(d, s, bpp); > - } > - d += bpp; > - if ((mask << j) & 0x80) > - s += bpp; > - } > + for (x = 0; x < width; x++) { > + j = x & 7; > + if ((dsp_mask << j) & 0x80) > + memcpy(d, s, bpp); > + d += bpp; > + if ((mask << j) & 0x80) > + s += bpp; > + } > break; > } > } > @@ -207,8 +206,7 @@ static void png_put_interlaced_row(uint8_t *dst, int width, > void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, > int w, int bpp) > { > - int i; > - for (i = 0; i < w; i++) { > + for (int i = 0; i < w; i++) { > int a, b, c, p, pa, pb, pc; > > a = dst[i - bpp]; > @@ -233,7 +231,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, > } > > #define UNROLL1(bpp, op) \ > - { \ > + do { \ > r = dst[0]; \ > if (bpp >= 2) \ > g = dst[1]; \ > @@ -253,21 +251,21 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, > continue; \ > dst[i + 3] = a = op(a, src[i + 3], last[i + 3]); \ > } \ > - } > - > -#define UNROLL_FILTER(op) \ > - if (bpp == 1) { \ > - UNROLL1(1, op) \ > - } else if (bpp == 2) { \ > - UNROLL1(2, op) \ > - } else if (bpp == 3) { \ > - UNROLL1(3, op) \ > - } else if (bpp == 4) { \ > - UNROLL1(4, op) \ > - } \ > - for (; i < size; i++) { \ > + } while (0) > + > +#define UNROLL_FILTER(op) do { \ > + if (bpp == 1) \ > + UNROLL1(1, op); \ > + else if (bpp == 2) \ > + UNROLL1(2, op); \ > + else if (bpp == 3) \ > + UNROLL1(3, op); \ > + else if (bpp == 4) \ > + UNROLL1(4, op); \ > + \ > + for (; i < size; i++) \ > dst[i] = op(dst[i - bpp], src[i], last[i]); \ > - } > +} while (0) > > /* NOTE: 'dst' can be equal to 'last' */ > void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, > @@ -330,9 +328,8 @@ void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, > #define YUV2RGB(NAME, TYPE) \ > static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \ > { \ > - int i; \ > - for (i = 0; i < size - 2; i += 3 + alpha) { \ > - int g = dst [i + 1]; \ > + for (int i = 0; i < size - 2; i += 3 + alpha) { \ > + int g = dst[i + 1]; \ > dst[i + 0] += g; \ > dst[i + 2] += g; \ > } \ > @@ -343,11 +340,10 @@ YUV2RGB(rgb16, uint16_t) > > static int percent_missing(PNGDecContext *s) > { > - if (s->interlace_type) { > + if (s->interlace_type) > return 100 - 100 * s->pass / (NB_PASSES - 1); > - } else { > + else > return 100 - 100 * s->y / s->cur_h; > - } > } > > /* process exactly one decompressed row */ > @@ -367,30 +363,28 @@ static void png_handle_row(PNGDecContext *s, uint8_t *dst, ptrdiff_t dst_stride) > last_row, s->row_size, s->bpp); > /* loco lags by 1 row so that it doesn't interfere with top prediction */ > if (s->filter_type == PNG_FILTER_TYPE_LOCO && s->y > 0) { > - if (s->bit_depth == 16) { > + if (s->bit_depth == 16) > deloco_rgb16((uint16_t *)(ptr - dst_stride), s->row_size / 2, > s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); > - } else { > + else > deloco_rgb8(ptr - dst_stride, s->row_size, > s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); > - } > } > s->y++; > if (s->y == s->cur_h) { > s->pic_state |= PNG_ALLIMAGE; > if (s->filter_type == PNG_FILTER_TYPE_LOCO) { > - if (s->bit_depth == 16) { > + if (s->bit_depth == 16) > deloco_rgb16((uint16_t *)ptr, s->row_size / 2, > s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); > - } else { > + else > deloco_rgb8(ptr, s->row_size, > s->color_type == PNG_COLOR_TYPE_RGB_ALPHA); > - } > } > } > } else { > got_line = 0; > - for (;;) { > + while (1) { > ptr = dst + dst_stride * (s->y + s->y_offset) + s->x_offset * s->bpp; > if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) { > /* if we already read one row, it is time to stop to > @@ -403,17 +397,16 @@ static void png_handle_row(PNGDecContext *s, uint8_t *dst, ptrdiff_t dst_stride) > FFSWAP(unsigned int, s->last_row_size, s->tmp_row_size); > got_line = 1; > } > - if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) { > + if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) > png_put_interlaced_row(ptr, s->cur_w, s->bits_per_pixel, s->pass, > s->color_type, s->last_row); > - } > s->y++; > if (s->y == s->cur_h) { > memset(s->last_row, 0, s->row_size); > - for (;;) { > + while (1) { > if (s->pass == NB_PASSES - 1) { > s->pic_state |= PNG_ALLIMAGE; > - goto the_end; > + return; > } else { > s->pass++; > s->y = 0; > @@ -428,7 +421,6 @@ static void png_handle_row(PNGDecContext *s, uint8_t *dst, ptrdiff_t dst_stride) > } > } > } > -the_end:; > } > } > > @@ -448,18 +440,18 @@ static int png_decode_idat(PNGDecContext *s, GetByteContext *gb, > return AVERROR_EXTERNAL; > } > if (zstream->avail_out == 0) { > - if (!(s->pic_state & PNG_ALLIMAGE)) { > + if (!(s->pic_state & PNG_ALLIMAGE)) > png_handle_row(s, dst, dst_stride); > - } > zstream->avail_out = s->crow_size; > zstream->next_out = s->crow_buf; > } > if (ret == Z_STREAM_END && zstream->avail_in > 0) { > av_log(s->avctx, AV_LOG_WARNING, > "%d undecompressed bytes left in buffer\n", zstream->avail_in); > - return 0; > + break; > } > } > + > return 0; > } > > @@ -538,7 +530,7 @@ static int decode_text_chunk(PNGDecContext *s, GetByteContext *gb, int compresse > const char *keyword_end = memchr(keyword, 0, data_end - data); > char *kw_utf8 = NULL, *txt_utf8 = NULL; > const char *text; > - unsigned text_len; > + size_t text_len; > AVBPrint bp; > > if (!keyword_end) > @@ -551,7 +543,8 @@ static int decode_text_chunk(PNGDecContext *s, GetByteContext *gb, int compresse > method = *(data++); > if (method) > return AVERROR_INVALIDDATA; > - if ((ret = decode_zbuf(&bp, data, data_end, s->avctx)) < 0) > + ret = decode_zbuf(&bp, data, data_end, s->avctx); > + if (ret < 0) > return ret; > text = bp.str; > text_len = bp.len; > @@ -637,7 +630,7 @@ static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s, > avctx->sample_aspect_ratio.num = bytestream2_get_be32(gb); > avctx->sample_aspect_ratio.den = bytestream2_get_be32(gb); > if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0) > - avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; > + avctx->sample_aspect_ratio = av_make_q(0, 1); > bytestream2_skip(gb, 1); /* unit specifier */ > > return 0; > @@ -833,8 +826,8 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, > return ret; > } else { > /* The picture output this time and the reference to retain coincide. */ > - if ((ret = ff_thread_get_ext_buffer(avctx, &s->picture, > - AV_GET_BUFFER_FLAG_REF)) < 0) > + ret = ff_thread_get_ext_buffer(avctx, &s->picture, AV_GET_BUFFER_FLAG_REF); > + if (ret < 0) > return ret; > ret = av_frame_ref(p, s->picture.f); > if (ret < 0) > @@ -845,7 +838,8 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, > p->flags |= AV_FRAME_FLAG_KEY; > p->flags |= AV_FRAME_FLAG_INTERLACED * !!s->interlace_type; > > - if ((ret = populate_avctx_color_fields(avctx, p)) < 0) > + ret = populate_avctx_color_fields(avctx, p); > + if (ret < 0) > return ret; > ff_thread_finish_setup(avctx); > > @@ -992,7 +986,8 @@ static int decode_iccp_chunk(PNGDecContext *s, GetByteContext *gb) > goto fail; > } > > - if ((ret = decode_zbuf(&bp, gb->buffer, gb->buffer_end, s->avctx)) < 0) > + ret = decode_zbuf(&bp, gb->buffer, gb->buffer_end, s->avctx); > + if (ret < 0) > return ret; > > av_freep(&s->iccp_data); > @@ -1050,17 +1045,17 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) > for (j = 0; j < s->height; j++) { > i = s->width / 8; > for (k = 7; k >= 1; k--) > - if ((s->width&7) >= k) > - pd[8*i + k - 1] = (pd[i]>>8-k) & 1; > + if ((s->width & 7) >= k) > + pd[8*i + k - 1] = (pd[i] >> (8 - k)) & 1; > for (i--; i >= 0; i--) { > - pd[8*i + 7]= pd[i] & 1; > - pd[8*i + 6]= (pd[i]>>1) & 1; > - pd[8*i + 5]= (pd[i]>>2) & 1; > - pd[8*i + 4]= (pd[i]>>3) & 1; > - pd[8*i + 3]= (pd[i]>>4) & 1; > - pd[8*i + 2]= (pd[i]>>5) & 1; > - pd[8*i + 1]= (pd[i]>>6) & 1; > - pd[8*i + 0]= pd[i]>>7; > + pd[8*i + 7] = pd[i] & 1; > + pd[8*i + 6] = (pd[i] >> 1) & 1; > + pd[8*i + 5] = (pd[i] >> 2) & 1; > + pd[8*i + 4] = (pd[i] >> 3) & 1; > + pd[8*i + 3] = (pd[i] >> 4) & 1; > + pd[8*i + 2] = (pd[i] >> 5) & 1; > + pd[8*i + 1] = (pd[i] >> 6) & 1; > + pd[8*i + 0] = pd[i] >> 7; > } > pd += p->linesize[0]; > } > @@ -1070,24 +1065,24 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) > for (j = 0; j < s->height; j++) { > i = s->width / 4; > if (s->color_type == PNG_COLOR_TYPE_PALETTE) { > - if ((s->width&3) >= 3) pd[4*i + 2]= (pd[i] >> 2) & 3; > - if ((s->width&3) >= 2) pd[4*i + 1]= (pd[i] >> 4) & 3; > - if ((s->width&3) >= 1) pd[4*i + 0]= pd[i] >> 6; > + if ((s->width & 3) >= 3) pd[4*i + 2]= (pd[i] >> 2) & 3; > + if ((s->width & 3) >= 2) pd[4*i + 1]= (pd[i] >> 4) & 3; > + if ((s->width & 3) >= 1) pd[4*i + 0]= pd[i] >> 6; > for (i--; i >= 0; i--) { > - pd[4*i + 3]= pd[i] & 3; > - pd[4*i + 2]= (pd[i]>>2) & 3; > - pd[4*i + 1]= (pd[i]>>4) & 3; > - pd[4*i + 0]= pd[i]>>6; > + pd[4*i + 3]= pd[i] & 3; > + pd[4*i + 2]= (pd[i] >> 2) & 3; > + pd[4*i + 1]= (pd[i] >> 4) & 3; > + pd[4*i + 0]= pd[i] >> 6; > } > } else { > - if ((s->width&3) >= 3) pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55; > - if ((s->width&3) >= 2) pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55; > - if ((s->width&3) >= 1) pd[4*i + 0]= ( pd[i]>>6 )*0x55; > + if ((s->width & 3) >= 3) pd[4*i + 2]= ((pd[i] >> 2) & 3) * 0x55; > + if ((s->width & 3) >= 2) pd[4*i + 1]= ((pd[i] >> 4) & 3) * 0x55; > + if ((s->width & 3) >= 1) pd[4*i + 0]= ( pd[i] >> 6 ) * 0x55; > for (i--; i >= 0; i--) { > - pd[4*i + 3]= ( pd[i] & 3)*0x55; > - pd[4*i + 2]= ((pd[i]>>2) & 3)*0x55; > - pd[4*i + 1]= ((pd[i]>>4) & 3)*0x55; > - pd[4*i + 0]= ( pd[i]>>6 )*0x55; > + pd[4*i + 3]= ( pd[i] & 3) * 0x55; > + pd[4*i + 2]= ((pd[i] >> 2) & 3) * 0x55; > + pd[4*i + 1]= ((pd[i] >> 4) & 3) * 0x55; > + pd[4*i + 0]= ( pd[i] >> 6 ) * 0x55; > } > } > pd += p->linesize[0]; > @@ -1096,18 +1091,20 @@ static void handle_small_bpp(PNGDecContext *s, AVFrame *p) > int i, j; > uint8_t *pd = p->data[0]; > for (j = 0; j < s->height; j++) { > - i = s->width/2; > + i = s->width / 2; > if (s->color_type == PNG_COLOR_TYPE_PALETTE) { > - if (s->width&1) pd[2*i+0]= pd[i]>>4; > + if (s->width & 1) > + pd[2*i+0] = pd[i] >> 4; > for (i--; i >= 0; i--) { > - pd[2*i + 1] = pd[i] & 15; > + pd[2*i + 1] = pd[i] & 0xff; > pd[2*i + 0] = pd[i] >> 4; > } > } else { > - if (s->width & 1) pd[2*i + 0]= (pd[i] >> 4) * 0x11; > - for (i--; i >= 0; i--) { > - pd[2*i + 1] = (pd[i] & 15) * 0x11; > + if (s->width & 1) > pd[2*i + 0] = (pd[i] >> 4) * 0x11; > + for (i--; i >= 0; i--) { > + pd[2*i + 1] = (pd[i] & 0xff) * 0x11; > + pd[2*i + 0] = (pd[i] >> 4) * 0x11; > } > } > pd += p->linesize[0]; > @@ -1321,7 +1318,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, > int decode_next_dat = 0; > int i, ret; > > - for (;;) { > + while (1) { > GetByteContext gb_chunk; > > length = bytestream2_get_bytes_left(&s->gb); > @@ -1339,8 +1336,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, > goto exit_loop; > } > av_log(avctx, AV_LOG_ERROR, "%d bytes left\n", length); > - if ( s->pic_state & PNG_ALLIMAGE > - && avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL) > + if (s->pic_state & PNG_ALLIMAGE && avctx->strict_std_compliance <= FF_COMPLIANCE_NORMAL) > goto exit_loop; > ret = AVERROR_INVALIDDATA; > goto fail; > @@ -1405,7 +1401,8 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, > case MKTAG('f', 'c', 'T', 'L'): > if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG) > continue; > - if ((ret = decode_fctl_chunk(avctx, s, &gb_chunk)) < 0) > + ret = decode_fctl_chunk(avctx, s, &gb_chunk); > + if (ret < 0) > goto fail; > decode_next_dat = 1; > break; > @@ -1421,14 +1418,19 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, > case MKTAG('I', 'D', 'A', 'T'): > if (CONFIG_APNG_DECODER && avctx->codec_id == AV_CODEC_ID_APNG && !decode_next_dat) > continue; > - if ((ret = decode_idat_chunk(avctx, s, &gb_chunk, p)) < 0) > + ret = decode_idat_chunk(avctx, s, &gb_chunk, p); > + if (ret < 0) > goto fail; > break; > case MKTAG('P', 'L', 'T', 'E'): > - decode_plte_chunk(avctx, s, &gb_chunk); > + ret = decode_plte_chunk(avctx, s, &gb_chunk); > + if (ret < 0) > + goto fail; This is a non-stylistic change and should definitely not be mixed with stylistic stuff. > break; > case MKTAG('t', 'R', 'N', 'S'): > - decode_trns_chunk(avctx, s, &gb_chunk); > + ret = decode_trns_chunk(avctx, s, &gb_chunk); > + if (ret < 0) > + goto fail; Same here. > break; > case MKTAG('t', 'E', 'X', 't'): > if (decode_text_chunk(s, &gb_chunk, 0) < 0) > @@ -1468,7 +1470,8 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, > s->have_srgb = 1; > break; > case MKTAG('i', 'C', 'C', 'P'): { > - if ((ret = decode_iccp_chunk(s, &gb_chunk)) < 0) > + ret = decode_iccp_chunk(s, &gb_chunk); > + if (ret < 0) > goto fail; > break; > } > @@ -1487,22 +1490,24 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, > break; > } > case MKTAG('s', 'B', 'I', 'T'): > - if ((ret = decode_sbit_chunk(avctx, s, &gb_chunk)) < 0) > + ret = decode_sbit_chunk(avctx, s, &gb_chunk); > + if (ret < 0) > goto fail; > break; > case MKTAG('g', 'A', 'M', 'A'): { > AVBPrint bp; > - char *gamma_str; > + char *gamma_str = NULL; > s->gamma = bytestream2_get_be32(&gb_chunk); > > av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); > av_bprintf(&bp, "%i/%i", s->gamma, 100000); > ret = av_bprint_finalize(&bp, &gamma_str); > - if (ret < 0) > - return ret; > + if (ret < 0) { > + av_freep(&gamma_str); Unnecessary. > + goto fail; > + } > > av_dict_set(&s->frame_metadata, "gamma", gamma_str, AV_DICT_DONT_STRDUP_VAL); > - > break; > } > case MKTAG('I', 'E', 'N', 'D'): > @@ -1540,10 +1545,10 @@ exit_loop: > for (int x = s->width - 1; x >= 0; x--) { > const uint8_t idx = row[x]; > > - row[4*x+2] = s->palette[idx] & 0xFF; > - row[4*x+1] = (s->palette[idx] >> 8 ) & 0xFF; > - row[4*x+0] = (s->palette[idx] >> 16) & 0xFF; > - row[4*x+3] = s->palette[idx] >> 24; > + row[4*x + 2] = s->palette[idx] & 0xFF; > + row[4*x + 1] = (s->palette[idx] >> 8 ) & 0xFF; > + row[4*x + 0] = (s->palette[idx] >> 16) & 0xFF; > + row[4*x + 3] = s->palette[idx] >> 24; This (and the rest of the stylistic fixes) seem like unnecessary noise. > } > } > } > @@ -1572,7 +1577,7 @@ exit_loop: > uint8_t *rowp = &row[3 * s->width - 1]; > int tcolor = AV_RL24(s->transparent_color_be); > for (x = s->width; x > 0; --x) { > - *pixel-- = AV_RL24(rowp-2) == tcolor ? 0 : 0xff; > + *pixel-- = AV_RL24(rowp - 2) == tcolor ? 0 : 0xff; > *pixel-- = *rowp--; > *pixel-- = *rowp--; > *pixel-- = *rowp--; > @@ -1583,11 +1588,10 @@ exit_loop: > uint8_t *pixel = &row[s->bpp * (x - 1)]; > memmove(pixel, &row[raw_bpp * (x - 1)], raw_bpp); > > - if (!memcmp(pixel, s->transparent_color_be, raw_bpp)) { > + if (!memcmp(pixel, s->transparent_color_be, raw_bpp)) > memset(&pixel[raw_bpp], 0, byte_depth); > - } else { > + else > memset(&pixel[raw_bpp], 0xff, byte_depth); > - } > } > } > } > @@ -1689,7 +1693,8 @@ static int decode_frame_png(AVCodecContext *avctx, AVFrame *p, > if (ret != Z_OK) > return AVERROR_EXTERNAL; > > - if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0) > + ret = decode_frame_common(avctx, s, p, avpkt); > + if (ret < 0) > goto the_end; > > if (avctx->skip_frame == AVDISCARD_ALL) { > @@ -1729,20 +1734,22 @@ static int decode_frame_apng(AVCodecContext *avctx, AVFrame *p, > if (!avctx->extradata_size) > return AVERROR_INVALIDDATA; > > - if ((ret = inflateReset(&s->zstream.zstream)) != Z_OK) > + if (inflateReset(&s->zstream.zstream) != Z_OK) > return AVERROR_EXTERNAL; > bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size); > - if ((ret = decode_frame_common(avctx, s, NULL, avpkt)) < 0) > + ret = decode_frame_common(avctx, s, NULL, avpkt); > + if (ret < 0) > return ret; > } > > /* reset state for a new frame */ > - if ((ret = inflateReset(&s->zstream.zstream)) != Z_OK) > + if (inflateReset(&s->zstream.zstream) != Z_OK) > return AVERROR_EXTERNAL; > s->y = 0; > s->pic_state = 0; > bytestream2_init(&s->gb, avpkt->data, avpkt->size); > - if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0) > + ret = decode_frame_common(avctx, s, p, avpkt); > + if (ret < 0) > return ret; > > if (!(s->pic_state & PNG_ALLIMAGE)) _______________________________________________ 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".