From patchwork Fri Jun 26 13:33:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 20627 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E2B154495C8 for ; Fri, 26 Jun 2020 16:33:52 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BFC4E68AA89; Fri, 26 Jun 2020 16:33:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 21221687F65 for ; Fri, 26 Jun 2020 16:33:46 +0300 (EEST) Received: by mail-pl1-f195.google.com with SMTP id x11so4287647plo.7 for ; Fri, 26 Jun 2020 06:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zMJoH9l6CbAIIlin1+Uim2USTVPPFTI46NqTQtzt+qE=; b=PGWxAp1qmhc8RGTq4YirLTddC2Wy4OrfNNJGdvKBKnRNU/Yf87kLAF3p4ULRa8tZWc S4oF50/rMASvXri0KixyT09by6fXf+YSySncOLix6dgnAfXs+PVMEaCeA/T4J3fuYuB9 4+uekR9iDG2nHDsEYASWam3FuFUpezADEaxKJjiNFZtsJYJrZrQvRrl2VDGSsb8Txi+x 5He5X3XgiKObAworDOCatTXfESKMKPHVJ0/LxbI3pHte4ZL65uyNdYrZpzlRJOpEcvvp JalJSEp4/JvVC2zn0y2VH6vt/oonX5nglbSM1bjbU8LAr7Gv0euDepuhUQImTY9ygBqe gzrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zMJoH9l6CbAIIlin1+Uim2USTVPPFTI46NqTQtzt+qE=; b=cOLxq3KvmaFx28J7T5yccPm2wswzrN9x5dkLia89HTV4JZ4CQN9Mz3pm4j8jh9dg4D tWXgoz+KkZzV+3splkT2DoksSO3HdhS3G/nMP8K1nBz6OTEvmxXe3ubtPKXDAqzcnEUR YjBtHZTm5QgRyO+fpx4LJD+2gmtGwySf0s7Y3PUbTuaXTMm9vZRlH/E1U6pv2Y67j7LV LP1rWClbMAHq8s4aBS5zmEtZ9iQBDMw4B3/ZT/l1sgDcAfj1JCfijbbLPo1W6MRraZ6Y KJ33UFhYA+haYL/PSboJ0XmHSa8SgftxD/n4huJV6j2QJ+xIwKWvgjzKOtksZMG81+fS fTNg== X-Gm-Message-State: AOAM530gRS/wekfyjTvNvKxypDnQkPtW5tt4Bk5D23biOudS6t7ZgvtJ k1IVcoRfX+72DUKmHb18Hhl1SWQQ X-Google-Smtp-Source: ABdhPJzAhns6b1d28Xda8mIazEbWeUnU5mrE+K6Ij4nHXQy/4wWKTI6wnwa4w418xLz8Z2dBznuDcA== X-Received: by 2002:a17:902:6ac4:: with SMTP id i4mr2484990plt.252.1593178423856; Fri, 26 Jun 2020 06:33:43 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id a68sm1197518pje.35.2020.06.26.06.33.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2020 06:33:43 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Jun 2020 21:33:37 +0800 Message-Id: <1593178417-18133-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593132446-21202-3-git-send-email-lance.lmwang@gmail.com> References: <1593132446-21202-3-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 3/4] avcodec/dvbsubdec: Cosmetics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/dvbsubdec.c | 94 +++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 263ba59..eea920f 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -710,8 +710,8 @@ static void compute_default_clut(DVBSubContext *ctx, uint8_t *clut, AVSubtitleRe } count = FFMAX(i - 1, 1); - for (i--; i>=0; i--) { - int v = i*255/count; + for (i--; i >= 0; i--) { + int v = i * 255 / count; AV_WN32(clut + 4*list_inv[i], RGBA(v/2,v,v/2,v)); } } @@ -737,7 +737,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou } /* Not touching AVSubtitles again*/ - if(sub->num_rects) { + if (sub->num_rects) { avpriv_request_sample(ctx, "Different Version of Segment asked Twice"); return AVERROR_PATCHWELCOME; } @@ -747,7 +747,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou sub->num_rects++; } - if(ctx->compute_edt == 0) { + if (ctx->compute_edt == 0) { sub->end_display_time = ctx->time_out * 1000; *got_output = 1; } else if (ctx->prev_start != AV_NOPTS_VALUE) { @@ -851,7 +851,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; fail: if (sub->rects) { - for(i=0; inum_rects; i++) { + for (i=0; i < sub->num_rects; i++) { rect = sub->rects[i]; if (rect) { av_freep(&rect->data[0]); @@ -1088,53 +1088,53 @@ static int dvbsub_parse_clut_segment(AVCodecContext *avctx, if (clut->version != version) { - clut->version = version; + clut->version = version; - while (buf + 4 < buf_end) { - entry_id = *buf++; + while (buf + 4 < buf_end) { + entry_id = *buf++; - depth = (*buf) & 0xe0; + depth = (*buf) & 0xe0; - if (depth == 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); - } + if (depth == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); + } - full_range = (*buf++) & 1; + full_range = (*buf++) & 1; - if (full_range) { - y = *buf++; - cr = *buf++; - cb = *buf++; - alpha = *buf++; - } else { - y = buf[0] & 0xfc; - cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; - cb = (buf[1] << 2) & 0xf0; - alpha = (buf[1] << 6) & 0xc0; + if (full_range) { + y = *buf++; + cr = *buf++; + cb = *buf++; + alpha = *buf++; + } else { + y = buf[0] & 0xfc; + cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; + cb = (buf[1] << 2) & 0xf0; + alpha = (buf[1] << 6) & 0xc0; - buf += 2; - } + buf += 2; + } - if (y == 0) - alpha = 0xff; + if (y == 0) + alpha = 0xff; - YUV_TO_RGB1_CCIR(cb, cr); - YUV_TO_RGB2_CCIR(r, g, b, y); + YUV_TO_RGB1_CCIR(cb, cr); + YUV_TO_RGB2_CCIR(r, g, b, y); - ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); - if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) { - ff_dlog(avctx, "More than one bit level marked: %x\n", depth); - if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL) - return AVERROR_INVALIDDATA; - } + ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); + if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) { + ff_dlog(avctx, "More than one bit level marked: %x\n", depth); + if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL) + return AVERROR_INVALIDDATA; + } - if (depth & 0x80 && entry_id < 4) - clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); - else if (depth & 0x40 && entry_id < 16) - clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); - else if (depth & 0x20) - clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); - } + if (depth & 0x80 && entry_id < 4) + clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); + else if (depth & 0x40 && entry_id < 16) + clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); + else if (depth & 0x20) + clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); + } } return 0; @@ -1210,7 +1210,7 @@ static int dvbsub_parse_region_segment(AVCodecContext *avctx, } region->depth = 1 << (((*buf++) >> 2) & 7); - if(region->depth<2 || region->depth>8){ + if (region->depth < 2 || region->depth > 8) { av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth); region->depth= 4; } @@ -1318,7 +1318,7 @@ static int dvbsub_parse_page_segment(AVCodecContext *avctx, ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state); - if(ctx->compute_edt == 1) + if (ctx->compute_edt == 1) save_subtitle_set(avctx, sub, got_output); if (page_state == 1 || page_state == 2) { @@ -1601,7 +1601,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, { DVBSubContext *ctx = avctx->priv_data; - if(ctx->compute_edt == 0) + if (ctx->compute_edt == 0) save_subtitle_set(avctx, sub, got_output); #ifdef DEBUG save_display_set(ctx); @@ -1717,12 +1717,12 @@ static int dvbsub_decode(AVCodecContext *avctx, } end: - if(ret < 0) { + if (ret < 0) { *got_sub_ptr = 0; avsubtitle_free(sub); return ret; } else { - if(ctx->compute_edt == 1 ) + if (ctx->compute_edt == 1) FFSWAP(int64_t, ctx->prev_start, sub->pts); }