avformat/iamf_parse: use the public iamf helpers to allocate structs
Should fix memory leaks from non-freed fields due to missing AVClass in the allocated structs. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -763,7 +763,7 @@ static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int le
|
|||||||
FFIOContext b;
|
FFIOContext b;
|
||||||
AVIOContext *pbc;
|
AVIOContext *pbc;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
unsigned mix_presentation_id;
|
unsigned nb_submixes, mix_presentation_id;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
buf = av_malloc(len);
|
buf = av_malloc(len);
|
||||||
@@ -834,35 +834,24 @@ static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int le
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
mix->nb_submixes = ffio_read_leb(pbc);
|
nb_submixes = ffio_read_leb(pbc);
|
||||||
mix->submixes = av_calloc(mix->nb_submixes, sizeof(*mix->submixes));
|
for (int i = 0; i < nb_submixes; i++) {
|
||||||
if (!mix->submixes) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < mix->nb_submixes; i++) {
|
|
||||||
AVIAMFSubmix *sub_mix;
|
AVIAMFSubmix *sub_mix;
|
||||||
|
unsigned nb_elements, nb_layouts;
|
||||||
|
|
||||||
sub_mix = mix->submixes[i] = av_mallocz(sizeof(*sub_mix));
|
sub_mix = av_iamf_mix_presentation_add_submix(mix);
|
||||||
if (!sub_mix) {
|
if (!sub_mix) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_mix->nb_elements = ffio_read_leb(pbc);
|
nb_elements = ffio_read_leb(pbc);
|
||||||
sub_mix->elements = av_calloc(sub_mix->nb_elements, sizeof(*sub_mix->elements));
|
for (int j = 0; j < nb_elements; j++) {
|
||||||
if (!sub_mix->elements) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < sub_mix->nb_elements; j++) {
|
|
||||||
AVIAMFSubmixElement *submix_element;
|
AVIAMFSubmixElement *submix_element;
|
||||||
IAMFAudioElement *audio_element = NULL;
|
IAMFAudioElement *audio_element = NULL;
|
||||||
unsigned int rendering_config_extension_size;
|
unsigned int rendering_config_extension_size;
|
||||||
|
|
||||||
submix_element = sub_mix->elements[j] = av_mallocz(sizeof(*submix_element));
|
submix_element = av_iamf_submix_add_element(sub_mix);
|
||||||
if (!submix_element) {
|
if (!submix_element) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -912,19 +901,13 @@ static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int le
|
|||||||
goto fail;
|
goto fail;
|
||||||
sub_mix->default_mix_gain = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
|
sub_mix->default_mix_gain = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
|
||||||
|
|
||||||
sub_mix->nb_layouts = ffio_read_leb(pbc);
|
nb_layouts = ffio_read_leb(pbc);
|
||||||
sub_mix->layouts = av_calloc(sub_mix->nb_layouts, sizeof(*sub_mix->layouts));
|
for (int j = 0; j < nb_layouts; j++) {
|
||||||
if (!sub_mix->layouts) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < sub_mix->nb_layouts; j++) {
|
|
||||||
AVIAMFSubmixLayout *submix_layout;
|
AVIAMFSubmixLayout *submix_layout;
|
||||||
int info_type;
|
int info_type;
|
||||||
int byte = avio_r8(pbc);
|
int byte = avio_r8(pbc);
|
||||||
|
|
||||||
submix_layout = sub_mix->layouts[j] = av_mallocz(sizeof(*submix_layout));
|
submix_layout = av_iamf_submix_add_layout(sub_mix);
|
||||||
if (!submix_layout) {
|
if (!submix_layout) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Reference in New Issue
Block a user