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 6CA4E4A533 for ; Fri, 29 Mar 2024 15:18:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1E07868D627; Fri, 29 Mar 2024 17:18:13 +0200 (EET) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A163B68D597 for ; Fri, 29 Mar 2024 17:18:06 +0200 (EET) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e6082eab17so1821204b3a.1 for ; Fri, 29 Mar 2024 08:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711725484; x=1712330284; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=akToqBJgHy29UffW76QI7e/3tutlMjLHot36RJ9dHzI=; b=Is4zkqwuf55kYBwZjIu3uRT6PuZDLmCoKTJ/8HfOAujq9iCnhrrggk9sleV69t4peC xmb8Ja5iYgyEwWumJwbz830EdIplXO7RfFf/K9AbRAIvwobFcvpsVOREhvIxgJxOQghA 0f58QT4fJ5jPVfcHpEcpW9+pQ5OdlLVIpeKANvRtX1QoMdsiAghkhlPPrvX9Gg9SmF18 qG9LQSl0hUiNMGEbVCbqg9yKZRC8K9U+Ovuz1GSAj1pGuSPFHcUpzzp0AOg1OJOkV5iN t7Gk4hyy2IqEd73o25fPFSVzK3i+zXZBxjiuqiA7pcNlv+m5cBWTPYMmM1q7QAjxuuAE IjLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711725484; x=1712330284; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=akToqBJgHy29UffW76QI7e/3tutlMjLHot36RJ9dHzI=; b=qfzM7astKX+LahE3c6x9P2kyzWrZmo6h8b1nHIaOOHqi4oeLe5CZPgrIvYWTWtrYBi ZyyeJVNsWCuz8O8TVVuRM5+KhFO5EWtHBUIrJ6SXuvLlNN9O0CFGY3w44mHxaUCIg4Va iBVw+lzNIR+OQ3MPZ+r0VP05ZKZ1FCm+UPtqILvC1SPp9FFVQlQ1eo7NOsDvO526R8ya 4wL2oze0/3fPGYp0UHEkZZXEoSZ4haiaiyYbgxjHjfz7rjG/RGU7/utr7hfxCBlK52i7 5ZqXM2WU0gGCJtgyjwUu2RW4EYKQLXWsm33s5/X2JT30pNV575lNlQZdfhFtZVPRNXqR TGyQ== X-Gm-Message-State: AOJu0Yy/IBRBBGFAzuZ2NEvf98a/8E2SjC+1BMrvF3VJovKx4ot3wP7D kif5tkBXpqnwoHJIy65PSzkpoKnLm9Sc8HapGKRQC9Qt45svA9sLIN/pJwb1 X-Google-Smtp-Source: AGHT+IGnbCAZ/YDLFZghcoaUEsQS8l/DaaXrBjoMnAfRfbdzRVqRP/TU9kOuguogTZny/wjvaTXW4w== X-Received: by 2002:a05:6a00:1a8c:b0:6e5:9698:84a8 with SMTP id e12-20020a056a001a8c00b006e5969884a8mr2583008pfv.27.1711725483705; Fri, 29 Mar 2024 08:18:03 -0700 (PDT) Received: from [192.168.0.15] ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id g8-20020aa78188000000b006e694719fa0sm3224963pfi.147.2024.03.29.08.18.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Mar 2024 08:18:03 -0700 (PDT) Message-ID: <70fe9f52-183e-4dc2-9184-ea970e7986a1@gmail.com> Date: Fri, 29 Mar 2024 12:18:09 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20240329151307.659-1-tong1.wu@intel.com> Content-Language: en-US From: James Almer In-Reply-To: <20240329151307.659-1-tong1.wu@intel.com> Subject: Re: [FFmpeg-devel] [PATCH v2] avcodec/hevc_ps: fix the problem of memcmp losing effectiveness 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 3/29/2024 12:13 PM, tong1.wu-at-intel.com@ffmpeg.org wrote: > From: Tong Wu > > HEVCHdrParams* receives a pointer which points to a dynamically > allocated memory block. It causes the memcmp always returning 1. > Add a function to do the comparision. A condition is also added to > avoid malloc(0). > > Signed-off-by: Tong Wu > --- > libavcodec/hevc_ps.c | 22 ++++++++++++++++++---- > libavcodec/hevc_ps.h | 4 +++- > 2 files changed, 21 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c > index cbef3ef4cd..d3c589ec24 100644 > --- a/libavcodec/hevc_ps.c > +++ b/libavcodec/hevc_ps.c > @@ -449,6 +449,18 @@ static void uninit_vps(FFRefStructOpaque opaque, void *obj) > av_freep(&vps->hdr); > } > > +static int compare_vps(const HEVCVPS *vps1, const HEVCVPS *vps2) > +{ > + if (!vps1->hdr && !vps2->hdr && !memcmp(vps1, vps2, offsetof(HEVCVPS, hdr))) > + return 1; > + > + if (vps1->hdr && vps2->hdr && !memcmp(vps1, vps2, offsetof(HEVCVPS, hdr)) && > + !memcmp(vps1->hdr, vps2->hdr, vps1->vps_num_hrd_parameters * sizeof(*vps1->hdr))) > + return 1; > + > + return 0; > +} Something like this should be simpler > +static int compare_vps(const HEVCVPS *vps1, const HEVCVPS *vps2) > +{ > + if (!memcmp(vps1, vps2, offsetof(HEVCVPS, hdr))) > + return !vps1->vps_num_hrd_parameters || > + !memcmp(vps1->hdr, vps2->hdr, vps1->vps_num_hrd_parameters * sizeof(*vps1->hdr)); > + > + return 0; > +} If vps1 is equal to vps2 up to hdr, then vps_num_hrd_parameters will be the same in both and you can safely just go ahead with the memcmp for hdr. _______________________________________________ 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".