From patchwork Wed Nov 18 13:05:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gil Pedersen X-Patchwork-Id: 23688 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:c00a:0:0:0:0:0 with SMTP id c10csp248460ybf; Wed, 18 Nov 2020 05:06:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLkhwNl5VimXMjvtTQ6DfftXbC8xpNI2tv8chvckp3RmtAZgVrVkMwquN9RzScQXpEUPl3 X-Received: by 2002:a1c:5605:: with SMTP id k5mr4085474wmb.99.1605704777182; Wed, 18 Nov 2020 05:06:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605704777; cv=none; d=google.com; s=arc-20160816; b=K+WPkBk5Vc+ErpaVjaCWpgG92hFmN3HnAJQj0eIa6I4Ykc1QynCJk8zFkzug8I0P1n FgfZEnqOpwgMo+hLRhU3dSgpB1aYtdr5ArDLSQh3Bf5F0XPojAoXMhCaekLACdgt46UE PJgKa3ToYWQNIpRs7zoNJbOsbmqLrWyYGxoULfTnEzXQVwLlYkpFcPHAp5OWz5rdoNMS 0UWf2uFQ/MDGF3LvSUxTC+TsXzYEY1sEetC0DFOtcxnI403YwtX2ypiAGRxGFdjAmmjW iafJ3R01ddPfsWw4JPMvFj6Sp4cD/bcvJ5b0qcLjqx9e8DtPUaHlAvlaleRFpiVj1BiV uUyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=JW5oye4J7Vq9FQfz2VrS12WoQb80VI+1uFWF6cqGRuA=; b=TzGOSiAv3SJQN6I/BeLuSdX+4atrv+8aaxW2fENCssL+xz/BI8iNhxgpBNFZjeUJR9 DXvap0Yghc7HR+Vv8t51+o0ha6aMCNJAnthT6crL5U56qAlFiuO3FuOtqIyKQAuhFBbG pL1Gj2hUFh0PsSqEs/UxBHmNkoxqQQx23nmbiI91J7LGUD5q7KVyfEUOUEJGBp887aat HnnDSyofgt2/ApOXXfeyRybDqmeq8axVWVVjCgIDrACFvabhVt8rBmb24MaiEf2mKihD 3k69IMRJGmzbVQKwkS2HDlf1rC5FnNFYcvoJb7q5+KoJnr3LYddqLCzS3Q51IVK9DLil xQ+A== ARC-Authentication-Results: i=1; mx.google.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 l9si1888076wmf.122.2020.11.18.05.06.16; Wed, 18 Nov 2020 05:06:17 -0800 (PST) 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; 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 BF00468B5C3; Wed, 18 Nov 2020 15:05:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1609E6897F4 for ; Wed, 18 Nov 2020 15:05:46 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id m6so2122242wrg.7 for ; Wed, 18 Nov 2020 05:05:46 -0800 (PST) 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=hy6LsDa/RcbYhnseDz9Ai4oBCxmJMAgHH2UnZyIJXuM=; b=nB09BGdYh9+ewjJpUmbceP4l7XQ6La1CxxYNdHTZt8CmhAkj9Wn4Rg5RA1AHBItHYW /2bYF1Q3hqD7e0Dw6DrkACUPn+xT4Wn9qpiz/ksW+o5L0cUc1NC5f1f5T5bDebZFbqbg xZg4G7RgYba0H0N5rTUzLGjazymXu9Zz3X9p2QIDzHiYGJ0lG66u1PpI4lCJcc+pew6c tksGrVJaX/pTgSPs/I9sCQUIamhJH124npgOz3bvrzuIwEjDDR7cKYX7qFQu2Fdt4tgq fnQd5pDUuhsqowYhZfW9Mgkg1DMs9jVJ0Wbp9GV0Gm2CN9tmv6B9ZWMVufNK2DI3hUgx sU7A== X-Gm-Message-State: AOAM532bEsG38b7Z3dcIz5V1AZQ4Z13jzhpBJws7QVSNOyDjaZB/6JTF vucpv2G4MHsbaurPdU985rwIqPrQs2fUVOVF X-Received: by 2002:adf:f2d2:: with SMTP id d18mr5046975wrp.302.1605704745236; Wed, 18 Nov 2020 05:05:45 -0800 (PST) Received: from ov04.ovh.net ([2001:41d0:303:c09e::]) by smtp.gmail.com with ESMTPSA id y16sm31757320wrt.25.2020.11.18.05.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 05:05:44 -0800 (PST) From: Gil Pedersen To: ffmpeg-devel@ffmpeg.org Date: Wed, 18 Nov 2020 13:05:15 +0000 Message-Id: <20201118130517.585-5-git@gpost.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201118130517.585-1-git@gpost.dk> References: <20201118130517.585-1-git@gpost.dk> Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/h264_slice: use av_buffer_replace() to simplify code 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: Gil Pedersen MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ox1OHG7qVI5u Content-Length: 1581 Signed-off-by: Gil Pedersen --- libavcodec/h264_slice.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index fa7a639053..b937ebebcf 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1018,11 +1018,11 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl int needs_reinit = 0, must_reinit, ret; if (first_slice) { - av_buffer_unref(&h->ps.pps_ref); - h->ps.pps = NULL; - h->ps.pps_ref = av_buffer_ref(h->ps.pps_list[sl->pps_id]); - if (!h->ps.pps_ref) - return AVERROR(ENOMEM); + ret = av_buffer_replace(&h->ps.pps_ref, h->ps.pps_list[sl->pps_id]); + if (ret < 0) { + h->ps.pps = NULL; + return ret; + } h->ps.pps = (const PPS*)h->ps.pps_ref->data; }