aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/iamf.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-02-19 20:22:22 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-02-19 23:30:00 +0100
commit18af922c536ad7c89e74a3326c58b6c93254a50f (patch)
tree5f35903630108c2dce7f90a080a7156f0e7b25a8 /libavformat/iamf.h
parente7c33c92d1eb04669553a89f8e69c64d4d77d9f4 (diff)
downloadffmpeg-18af922c536ad7c89e74a3326c58b6c93254a50f.tar.gz
avformat/iamf: Don't mix ownership and non-ownership pointers
IAMFAudioElement and IAMFMixPresentation currently contain pointers to independently allocated objects that are sometimes owned by said structures and sometimes not. More precisely, upon success the demuxer transfers ownership of these other objects newly created AVStreamGroups, but it keeps its pointers. iamf_read_close() therefore always resets these pointers (because the cleanup code always treats them as ownership pointers). This leads to memory leaks in case iamf_read_header() without having attached all of these objects to stream groups. The muxer has a similar issue: It also clears these pointers (pointing to objects owned by stream groups created by the user) in its deinit function. This commit fixes this memleak by explicitly adding non-ownership pointers; this also allows to remove the code to reset the ownership pointers. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/iamf.h')
-rw-r--r--libavformat/iamf.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/iamf.h b/libavformat/iamf.h
index d88a24c435..0cb0902e86 100644
--- a/libavformat/iamf.h
+++ b/libavformat/iamf.h
@@ -86,6 +86,11 @@ typedef struct IAMFSubStream {
} IAMFSubStream;
typedef struct IAMFAudioElement {
+ const AVIAMFAudioElement *celement;
+ /**
+ * element backs celement iff the AVIAMFAudioElement
+ * is owned by this structure.
+ */
AVIAMFAudioElement *element;
unsigned int audio_element_id;
@@ -100,6 +105,11 @@ typedef struct IAMFAudioElement {
} IAMFAudioElement;
typedef struct IAMFMixPresentation {
+ const AVIAMFMixPresentation *cmix;
+ /**
+ * mix backs cmix iff the AVIAMFMixPresentation
+ * is owned by this structure.
+ */
AVIAMFMixPresentation *mix;
unsigned int mix_presentation_id;