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 755C447630 for ; Fri, 15 Sep 2023 04:42:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BEA8568C85E; Fri, 15 Sep 2023 07:42:39 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 97E8568C750 for ; Fri, 15 Sep 2023 07:42:32 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id EB95510602D1 for ; Fri, 15 Sep 2023 04:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1694752951; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=ZyShCXR0NQSklPu4jA/K7/0ZSHXiXlV3lvdNBOw8y/k=; b=fPdo9R9TFTWsFggAs732oghgWTUoAU4NvpAVU603GiVkV9pY4jSpt4Gf7I0203rG H6NLgPk/PwYI6sc++VHnNe2ZjH7ODFStRYqF1wX9zxrJFxsego24WOLSl5M7JtOhYVZ wMtxTENQJbWkcM4lbPZasYgLrpL7BgR+kdUp1s0U/co+us5KJH1YOGbNFN0Fhp00TaB /4XpWbgvoUTb12oEp6lAv6qWcNCdjDPIwHV0y5nGYhAWy1GYW5/LPuMwGYBVLrUJfLl b6akoiLB/lmjbB/YNCy+LbNhnXpr85AauC/eflPPLDefRE0plST8+SoWc+PdBSWA7g3 qm+tpTZHJw== Date: Fri, 15 Sep 2023 06:42:31 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] vulkan_hevc: switch from a buffer pool to a simple malloc 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: Sep 15, 2023, 03:00 by andreas.rheinhardt@outlook.com: > Lynne: > >> -static int get_data_set_buf(FFVulkanDecodeContext *s, AVBufferRef **data_buf, >> - int nb_vps, AVBufferRef * const vps_list[HEVC_MAX_VPS_COUNT]) >> +static int alloc_hevc_header_structs(FFVulkanDecodeContext *s, >> + int nb_vps, >> + AVBufferRef * const vps_list[HEVC_MAX_VPS_COUNT]) >> { >> - uint8_t *data_ptr; >> + uintptr_t data_ptr; >> HEVCHeaderSet *hdr; >> >> size_t base_size = sizeof(StdVideoH265SequenceParameterSet)*HEVC_MAX_SPS_COUNT + >> @@ -93,22 +94,18 @@ static int get_data_set_buf(FFVulkanDecodeContext *s, AVBufferRef **data_buf, >> buf_size += sizeof(HEVCHeaderVPSSet)*vps->vps_num_hrd_parameters; >> } >> >> - if (buf_size > s->tmp_pool_ele_size) { >> - av_buffer_pool_uninit(&s->tmp_pool); >> - s->tmp_pool_ele_size = 0; >> - s->tmp_pool = av_buffer_pool_init(buf_size, NULL); >> - if (!s->tmp_pool) >> + if (buf_size > s->hevc_headers_size) { >> + av_freep(&s->hevc_headers); >> + s->hevc_headers_size = 0; >> + s->hevc_headers = av_mallocz(buf_size); >> > > The earlier code did not zero-initialize the buffer. I thought the > set_[vsp]ps functions were enough to initialize them. > Better to be on the safe side, in case I've forgotten to set a reserved field (or better yet, I should remove references to them in case they're renamed. >> + if (!s->hevc_headers) >> return AVERROR(ENOMEM); >> - s->tmp_pool_ele_size = buf_size; >> + s->hevc_headers_size = buf_size; >> } >> >> - *data_buf = av_buffer_pool_get(s->tmp_pool); >> - if (!(*data_buf)) >> - return AVERROR(ENOMEM); >> - >> /* Setup pointers */ >> - data_ptr = (*data_buf)->data; >> - hdr = (HEVCHeaderSet *)data_ptr; >> + hdr = s->hevc_headers; >> + data_ptr = (uintptr_t)hdr; >> hdr->hvps = (HEVCHeaderVPS *)(data_ptr + base_size); >> > > The standard way to get pointer that is at a certain byte offset from a > given pointer is by casting said pointer to char* and applying the > offset; casting to uintptr_t and back will work, but is actually not > guaranteed. In fact, the whole data_ptr variable seems unnecessary. > You may use FF_FIELD_AT from lavu/internal.h if you think that it is > helpful for this. (I don't think so.) > Couldn't really think of a way to remove the data_ptr field. Do you have any ideas? If not, I'll push this later today. _______________________________________________ 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".