From patchwork Sun Jun 11 16:05:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 3918 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.10.195 with SMTP id 186csp547912vsk; Sun, 11 Jun 2017 09:05:16 -0700 (PDT) X-Received: by 10.28.109.220 with SMTP id b89mr5318541wmi.97.1497197116095; Sun, 11 Jun 2017 09:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497197116; cv=none; d=google.com; s=arc-20160816; b=0cXJHY5cgHzePalkx/fMDHhecHee9of7k2KQdUSnVI3ugkkn+epEqx0fybqrFboMCS 8SnmZmjUHsUqf23DiBpY1aFcM07m2M5sMLeMVg53G2VgnpVijGIqB6A79s1GdRqwD5Dn Y2t9pxtFpBbGbRz+1jUlOfVeWN1hMn+AU63Wg+VHwkuuavXMREftdNjYcQgVTsdey7Bm dsAYXrL3YLfOKwcata8DcL3ewajWpNO32qwFmEogEl1IBgRW1L1Fn8nbBfKG17Es2+a0 6pJV+4u8N81gdCeTddGwIFsB6TIZHPH3cn9K7/+MCb81JzDtfjiHKMDLxXtrw8ets4Nx tCkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:user-agent:date:message-id:from:to :dkim-signature:delivered-to:arc-authentication-results; bh=KwD+aWO1hKpaVlPDbKd/xhTL6W1CCcANvMnrHqGeauo=; b=zb5qvk8XY37714ECqrbz2g+fA2C8eGDmlAP+kxyvlw4vl7ZfAKTiAfIwMVdtuWoHBr mt/ISMSKbew+VAqSH9oVR1qqWZ1WV/qtQfwtXV9xBrlXKP3Ke9/7dYVgFmCLcluukvFr kPYn9USJCyFIcNtlRxQZorXfsO0nC38G/cKp30eMTgJDcdzyYGJRMFfKOF872tEiCOeb MudMt2T9V2C82OS0IlWxRdZoAgJPMGdan8dxG7WVyAkpgiWyTe3BswJp51Asd5apkcK0 IHC+rBJ5RT992YX7LyrNfBez+vHnoZTInqGjt79Wv2pTfkW7PK/zZJ1Uh4CsrEPkqfDU bMbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.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 c49si7562549wrc.38.2017.06.11.09.05.15; Sun, 11 Jun 2017 09:05:16 -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; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.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 C6298689D7D; Sun, 11 Jun 2017 19:05:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF1CC689D7D for ; Sun, 11 Jun 2017 19:05:04 +0300 (EEST) Received: by mail-wr0-f171.google.com with SMTP id g76so73509165wrd.1 for ; Sun, 11 Jun 2017 09:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=qR8HWWcMbYEQqCx4o34tshHHsu/nxxn0Up2fGrQCASE=; b=Xzlih5t06WG4aLgU3QYAz/CCvDKJJdB8Qd17FR4iihhBkHmBE2nq5A23HxaRRIjGEy swI9kYGW3QeIHbM1Zu7MD+ggLzcFw8F19xCBc21Fdiod5O1RBKW50NQ3GN7Ip9Rh+Sw6 bqtPn1N0v8KDlzvk5jkgVje5ECwEPC50RKBiZLGqiCpMdvzHsSWZ39JdIH2RpufaeZc2 fD8qdcJCXtzbR6jIfSPYbTEVZU5OG5hwUiezXPSreXSgZbqlYREQOpMoigjrsAkkaHhZ nTnTUK6qrs1Hn/UMvc5RHTwMLKbRRB3gZTOOyl/xuCtnjBrX01UaC3zzOcBlyTQX5t10 md9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=qR8HWWcMbYEQqCx4o34tshHHsu/nxxn0Up2fGrQCASE=; b=H+MSzTdpSQw28r3KciACry2qTHUJOWAb9X54iqW0RcJUr7ABHvPfHbhoQiCzgd+SJG //plYhbB9Au1R6mR8QcKBNEBnBNOfuDOu8KfJWF65azjTDa3tnF3foJB862Rlh1LgQR4 3OAlITCbgmyr2YGLN+LO/wa3zMzr9PjAAWdC95ST4hobawrcUk4bVDbTAoZDmgsq8rcZ 8/wAs8Mnw+qG3UgyFqEftvkoanOb/8oKOmt+IshsFcLHCs3N3BaigsRVYKdUq3mTlZc+ uaPhz5hP4vHd2cyJoXGuRCwiO8nTRoQbHhIfnoDi2KG8mZyoD2AZ3iU9C+rqHW2DgDEL v90g== X-Gm-Message-State: AKS2vOwbrnMvU2d670JATghirSq3pyMPm0CPh+5b8gK/U+Xkta/QOtNF dY1z/9zGmY0kQf2SWuo= X-Received: by 10.28.12.1 with SMTP id 1mr5363981wmm.109.1497197105678; Sun, 11 Jun 2017 09:05:05 -0700 (PDT) Received: from [192.168.0.9] (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id o65sm4802329wmo.19.2017.06.11.09.05.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Jun 2017 09:05:05 -0700 (PDT) To: FFmpeg development discussions and patches From: Mark Thompson Message-ID: Date: Sun, 11 Jun 2017 17:05:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] h264_parse: Do not touch chroma weights at all if stream is monochrome 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Also return an error if the weight denominator is incorrect, rather than overriding it with zero and continuing. --- libavcodec/h264_parse.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index 3d20075f6a..96680640f5 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -34,17 +34,19 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, pwt->use_weight = 0; pwt->use_weight_chroma = 0; - pwt->luma_log2_weight_denom = get_ue_golomb(gb); - if (sps->chroma_format_idc) - pwt->chroma_log2_weight_denom = get_ue_golomb(gb); + pwt->luma_log2_weight_denom = get_ue_golomb(gb); if (pwt->luma_log2_weight_denom > 7U) { av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", pwt->luma_log2_weight_denom); - pwt->luma_log2_weight_denom = 0; + return AVERROR_INVALIDDATA; } - if (pwt->chroma_log2_weight_denom > 7U) { - av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", pwt->chroma_log2_weight_denom); - pwt->chroma_log2_weight_denom = 0; + + if (sps->chroma_format_idc) { + pwt->chroma_log2_weight_denom = get_ue_golomb(gb); + if (pwt->chroma_log2_weight_denom > 7U) { + av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", pwt->chroma_log2_weight_denom); + return AVERROR_INVALIDDATA; + } } luma_def = 1 << pwt->luma_log2_weight_denom; @@ -102,9 +104,11 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, if (picture_structure == PICT_FRAME) { pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0]; pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1]; - for (j = 0; j < 2; j++) { - pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0]; - pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1]; + if (sps->chroma_format_idc) { + for (j = 0; j < 2; j++) { + pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0]; + pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1]; + } } } }