From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/hevc_ps: allocate only the required HEVCHdrParams within a VPS
Date: Thu, 21 Mar 2024 13:54:45 +0100
Message-ID: <DU0P250MB07470F7EBDB13D8E078565118F322@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240321122922.7643-1-jamrial@gmail.com>
James Almer:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> libavcodec/hevc_ps.c | 14 +++++++++++++-
> libavcodec/hevc_ps.h | 2 +-
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index fb997066d9..d29cf9f372 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -438,13 +438,20 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
> return 0;
> }
>
> +static void uninit_vps(FFRefStructOpaque opaque, void *obj)
> +{
> + HEVCVPS *vps = obj;
> +
> + av_freep(&vps->hdr);
> +}
> +
> int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
> HEVCParamSets *ps)
> {
> int i,j;
> int vps_id = 0;
> ptrdiff_t nal_size;
> - HEVCVPS *vps = ff_refstruct_allocz(sizeof(*vps));
> + HEVCVPS *vps = ff_refstruct_alloc_ext(sizeof(*vps), 0, NULL, uninit_vps);
>
> if (!vps)
> return AVERROR(ENOMEM);
> @@ -533,6 +540,11 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
> "vps_num_hrd_parameters %d is invalid\n", vps->vps_num_hrd_parameters);
> goto err;
> }
> +
> + vps->hdr = av_calloc(vps->vps_num_hrd_parameters, sizeof(*vps->hdr));
> + if (!vps->hdr)
> + goto err;
> +
> for (i = 0; i < vps->vps_num_hrd_parameters; i++) {
> int common_inf_present = 1;
>
> diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
> index 786c896709..87cea479e9 100644
> --- a/libavcodec/hevc_ps.h
> +++ b/libavcodec/hevc_ps.h
> @@ -152,7 +152,7 @@ typedef struct PTL {
>
> typedef struct HEVCVPS {
> unsigned int vps_id;
> - HEVCHdrParams hdr[HEVC_MAX_LAYER_SETS];
> + HEVCHdrParams *hdr;
>
> uint8_t vps_temporal_id_nesting_flag;
> int vps_max_layers;
That's what I had in mind.
- Andreas
_______________________________________________
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".
next prev parent reply other threads:[~2024-03-21 12:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 23:35 James Almer
2024-03-21 4:00 ` Michael Niedermayer
2024-03-21 11:15 ` Andreas Rheinhardt
2024-03-21 12:11 ` James Almer
2024-03-21 12:19 ` Andreas Rheinhardt
2024-03-21 12:29 ` James Almer
2024-03-21 12:54 ` Andreas Rheinhardt [this message]
2024-03-27 7:41 ` Wu, Tong1
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=DU0P250MB07470F7EBDB13D8E078565118F322@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--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