Commit 35250dac95 for ffmpeg
commit 35250dac957dd20dfa4b3951ffe7bf5d7e87e483
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Wed Dec 2 19:16:31 2026 +0000
avformat/ogg/muxer: copy only the used payload when queuing a page
Partial pages currently copy the entire 65 KB payload array. Copy the page metadata and populated bytes and set the payload size separately. Both the page and the list link are initialized before use.
Assisted-by: Fairy
diff --git a/libavformat/ogg/muxer.c b/libavformat/ogg/muxer.c
index ee939b9623..4513f01396 100644
--- a/libavformat/ogg/muxer.c
+++ b/libavformat/ogg/muxer.c
@@ -149,13 +149,14 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
{
OGGContext *ogg = s->priv_data;
OGGPageList **p = &ogg->page_list;
- OGGPageList *l = av_mallocz(sizeof(*l));
+ OGGPageList *l = av_malloc(sizeof(*l));
if (!l) {
ogg_reset_cur_page(oggstream);
return AVERROR(ENOMEM);
}
- l->page = oggstream->page;
+ memcpy(&l->page, &oggstream->page, offsetof(OGGPage, data) + oggstream->page.size);
+ l->page.size = oggstream->page.size;
oggstream->page.start_granule = ogg_granule_to_timestamp(oggstream, oggstream->page.granule);
oggstream->page_count++;