Commit Graph

17 Commits

Author SHA1 Message Date
James Almer 6b6a0fc53d avformat/iamf_writer: reject duplicated stream ids in a stream group
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-16 11:43:10 -03:00
James Almer 79c6ba9007 avformat/iamf_writer: constify some variables
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-05 11:39:17 -03:00
James Almer 988e3a061a avformat/iamf_writer: clear extradata_size on extradata allocation failure
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-05 11:23:41 -03:00
James Almer 56d630e6c2 avformat/iamf_writer: update extradata from packet side data
Some encoders, like flac, propagate updated extradata at the end of encoding
as packet side data. Use it to update the relevant codec_config.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-04 21:14:05 -03:00
James Almer f8caf388fb avformat/iamf_writer: constify some function parameters
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-02 21:41:09 -03:00
James Almer c95c8a0158 avformat/iamfenc: further split into shareable modules
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-19 20:53:36 -03:00
Andreas Rheinhardt 1f7cd5d434 avformat/iamf_writer: Fix leaks on error
Fixes Coverity issues #1559544 and #1559547.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:30:18 +01:00
Andreas Rheinhardt c5845afd09 avformat/iamf_writer: Return proper error codes
Surprisingly the return value of add_param_definition()
(a pointer) has only been used to check for success
and not to actually access the pointee; nonsuccess
was equated with ENOMEM, although there is a non-enomem
error path in this function.

Change this by returning an int.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:30:06 +01:00
Andreas Rheinhardt 18af922c53 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>
2024-02-19 23:30:00 +01:00
Andreas Rheinhardt e7c33c92d1 avformat/iamf_writer: Don't memset twice
This has been allocated via av_calloc() a few lines above.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:29:57 +01:00
Andreas Rheinhardt 840f192540 avformat/iamf_writer: Remove nonsense check
Checking whether a pointer to an element of an array is NULL
makes no sense, as the pointer addition involved in getting
the address would be undefined behaviour already if the array
were NULL.
In this case the array allocation has already been checked
a few lines before.
Fixes Coverity issue #1559548.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:29:49 +01:00
Andreas Rheinhardt 94fadd335b avformat/iamf_writer: Don't leak on error when adding ParamDefinition
Fix this by postponing the allocation.
Fixes Coverity issue #1559545.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:29:25 +01:00
Andreas Rheinhardt d50a246687 avformat/iamf*: Improve included headers
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-03 00:26:10 +01:00
Andreas Rheinhardt 8d4b22edc7 avformat/iamf_writer, iamfenc: Avoid allocations when using dyn buffers
Use avio_get_dyn_buf()+ffio_free_dyn_buf() instead of
avio_close_dyn_buf()+av_free(). This saves an allocation
(and memcpy) in case all the data fits in the AVIOContext's
write buffer.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-03 00:26:02 +01:00
Andreas Rheinhardt b9596daafb avformat/iamf_writer: Avoid using dynamic buffer
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-03 00:25:38 +01:00
James Almer 9813df77d6 avformat/iamf_writer: remove bogus check
Probably an artifact of a rebase, as this check is done below.

Fixes "Conditional jump or move depends on uninitialised value(s)" errors as
reported by Valgrind.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-01-23 10:14:10 -03:00
James Almer 25835e2593 avformat: Immersive Audio Model and Formats muxer
Signed-off-by: James Almer <jamrial@gmail.com>
2023-12-18 15:21:47 -03:00