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. If I can at some time start spending efforts on FFmpeg again, I intend to use this pattern on things that need to be lightweight (no dynamic allocations) but extensible. Regards, -- Nicolas George _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".