Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] vulkan_hevc: switch from a buffer pool to a simple malloc
Date: Fri, 15 Sep 2023 17:37:26 +0200 (CEST)
Message-ID: <NeOULNd--7-9@lynne.ee> (raw)
In-Reply-To: <GV1P250MB073701330271345501233A428FF6A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

Sep 15, 2023, 10:34 by andreas.rheinhardt@outlook.com:

> Lynne:
>
>> 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.
>>
>
> Ok, I now see that data_ptr is used for more than one line and in a way
> which makes it hard to avoid. So keep it, but make it char*.
>

Changed to uint8_t *, removed the manual
struct size calculations and pushed.

Thanks for the reviews
_______________________________________________
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".

      reply	other threads:[~2023-09-15 15:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 23:53 Lynne
2023-09-15  1:01 ` Andreas Rheinhardt
2023-09-15  4:42   ` Lynne
2023-09-15  8:34     ` Andreas Rheinhardt
2023-09-15 15:37       ` Lynne [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=NeOULNd--7-9@lynne.ee \
    --to=dev@lynne.ee \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git