[FFmpeg-devel] [PATCH 3/7] avutil/frame: add a param change side data type
Alexander Strasser
eclipse7 at gmx.net
Thu Jan 23 23:49:12 EET 2025
On 2025-01-22 21:18 +0100, Nicolas George wrote:
> James Almer (12025-01-22):
> > Ok, will implement a new struct.
>
> Thanks.
>
> I think this code would work:
>
> typedef struct AVSideDataParamChange
> …
> intmax_t end_padding;
> } AVSideDataSomethingType;
>
> static const AVSideDataParamChange default = { ... };
>
>
> AVSideDataParamChange pc;
> av_assert0(sd->size > sizeof(pc.end_padding));
> size_t s = FFMIN(sd->size - sizeof(pc.end_padding), sizeof(pc));
> memcpy(&pc, sd->data, s);
> memcpy((char *)&pc + s, (char *)&default + s, sizeof(pc) - s);
>
> After this code, pc contains the fields from the side data if they are
> present in the version known by the caller and the fields from default
> otherwise.
>
> I am rather sure this is valid C unless there we add a field with
> individual size greater than end_padding, hence intmax_t.
Sorry, couldn't really follow the problem and this solution idea yet.
Just think we shouldn't use intmax_t as I think it wasn't a good idea
to have it in the C standard at all.
Is it essential for your idea?
Alexander
More information about the ffmpeg-devel
mailing list