Skip to content

Commit

Permalink
codec_specific_parameters as defined in ISOBMFF
Browse files Browse the repository at this point in the history
  • Loading branch information
podborski committed Nov 11, 2023
1 parent 774e982 commit adf0c6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 37 deletions.
2 changes: 1 addition & 1 deletion IsoLib/libisomediafile/src/MP4Atoms.h
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ typedef struct MP4SubSampleInformationAtom
u32 **subsample_size;
u32 **subsample_priority;
u32 **discardable;
u32 **reserved;
u32 **codec_specific_parameters;
} MP4SubSampleInformationAtom, *MP4SubSampleInformationAtomPtr;

typedef struct MP4SyncSampleAtom
Expand Down
52 changes: 16 additions & 36 deletions IsoLib/libisomediafile/src/SubSampleInformationAtom.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
/*
This software module was originally developed by Apple Computer, Inc.
in the course of development of MPEG-4.
This software module is an implementation of a part of one or
more MPEG-4 tools as specified by MPEG-4.
ISO/IEC gives users of MPEG-4 free license to this
software module or modifications thereof for use in hardware
or software products claiming conformance to MPEG-4.
Those intending to use this software module in hardware or software
products are advised that its use may infringe existing patents.
The original developer of this software module and his/her company,
the subsequent editors and their companies, and ISO/IEC have no
liability for use of this software module or modifications thereof
in an implementation.
Copyright is not released for non MPEG-4 conforming
products. Apple Computer, Inc. retains full right to use the code for its own
purpose, assign or donate the code to a third party and to
inhibit third parties from using the code for non
MPEG-4 conforming products.
This copyright notice must be included in all copies or
derivative works. Copyright (c) 1999.
/* This software module was originally developed by Apple Computer, Inc. in the course of development of MPEG-4. This software module is an implementation of a part of one or more MPEG-4 tools as specified by MPEG-4. ISO/IEC gives users of MPEG-4 free license to this software module or modifications thereof for use in hardware or software products claiming conformance to MPEG-4. Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-4 conforming products. Apple Computer, Inc. retains full right to use the code for its own purpose, assign or donate the code to a third party and to inhibit third parties from using the code for non MPEG-4 conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1999.
*/

/* Created for Nokia FAVS project by Tampere University of Technology */

#include "MP4Atoms.h"
Expand All @@ -43,8 +24,8 @@ static void destroy(MP4AtomPtr s)
self->subsample_priority[i] = NULL;
free(self->discardable[i]);
self->discardable[i] = NULL;
free(self->reserved[i]);
self->reserved[i] = NULL;
free(self->codec_specific_parameters[i]);
self->codec_specific_parameters[i] = NULL;
}
}
free(self->subsample_size);
Expand All @@ -53,8 +34,8 @@ static void destroy(MP4AtomPtr s)
self->subsample_priority = NULL;
free(self->discardable);
self->discardable = NULL;
free(self->reserved);
self->reserved = NULL;
free(self->codec_specific_parameters);
self->codec_specific_parameters = NULL;

free(self->subsample_count);
self->subsample_count = NULL;
Expand Down Expand Up @@ -91,7 +72,7 @@ static MP4Err serialize(struct MP4Atom *s, char *buffer)
}
PUT8(subsample_priority[i][j]);
PUT8(discardable[i][j]);
PUT32(reserved[i][j]);
PUT32(codec_specific_parameters[i][j]);
}
}
assert(self->bytesWritten == self->size);
Expand Down Expand Up @@ -159,10 +140,10 @@ static MP4Err addEntry(MP4SubSampleInformationAtom *s, u32 sample_delta, u32 sub
self->discardable[current_entry] = (u32 *)calloc(subsample_count, sizeof(u32));
TESTMALLOC(self->discardable[current_entry]);

self->reserved = (u32 **)realloc(self->reserved, (self->entry_count + 1) * sizeof(u32 *));
TESTMALLOC(self->reserved);
self->reserved[current_entry] = (u32 *)calloc(subsample_count, sizeof(u32));
TESTMALLOC(self->reserved[current_entry]);
self->codec_specific_parameters = (u32 **)realloc(self->codec_specific_parameters, (self->entry_count + 1) * sizeof(u32 *));
TESTMALLOC(self->codec_specific_parameters);
self->codec_specific_parameters[current_entry] = (u32 *)calloc(subsample_count, sizeof(u32));
TESTMALLOC(self->codec_specific_parameters[current_entry]);

self->sample_delta[current_entry] = sample_delta;
self->subsample_count[current_entry] = subsample_count;
Expand All @@ -175,7 +156,7 @@ static MP4Err addEntry(MP4SubSampleInformationAtom *s, u32 sample_delta, u32 sub
self->subsample_size[current_entry][i] = ((u32 *)*subsample_size_array)[i];
self->subsample_priority[current_entry][i] = ((u32 *)*subsample_priority_array)[i];
self->discardable[current_entry][i] = ((u32 *)*subsample_discardable_array)[i];
self->reserved[current_entry][i] = 0;
self->codec_specific_parameters[current_entry][i] = 0;
}

self->entry_count++;
Expand Down Expand Up @@ -209,8 +190,8 @@ static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStre
TESTMALLOC(self->subsample_priority);
self->discardable = (u32 **)calloc(self->entry_count, sizeof(u32 *));
TESTMALLOC(self->discardable);
self->reserved = (u32 **)calloc(self->entry_count, sizeof(u32 *));
TESTMALLOC(self->reserved);
self->codec_specific_parameters = (u32 **)calloc(self->entry_count, sizeof(u32 *));
TESTMALLOC(self->codec_specific_parameters);

for(i = 0; i < self->entry_count; i++)
{
Expand All @@ -222,7 +203,7 @@ static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStre
TESTMALLOC(self->subsample_count[i]);
self->discardable[i] = (u32 *)calloc(self->subsample_count[i], sizeof(u32));
TESTMALLOC(self->subsample_count[i]);
self->reserved[i] = (u32 *)calloc(self->subsample_count[i], sizeof(u32));
self->codec_specific_parameters[i] = (u32 *)calloc(self->subsample_count[i], sizeof(u32));
TESTMALLOC(self->subsample_count[i]);
for(j = 0; j < self->subsample_count[i]; j++)
{
Expand All @@ -236,7 +217,7 @@ static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStre
}
GET8(subsample_priority[i][j]);
GET8(discardable[i][j]);
GET32(reserved[i][j]);
GET32(codec_specific_parameters[i][j]);
}
}
bail:
Expand Down Expand Up @@ -267,6 +248,5 @@ MP4Err MP4CreateSubSampleInformationAtom(MP4SubSampleInformationAtomPtr *outAtom

bail:
TEST_RETURN(err);

return err;
}

0 comments on commit adf0c6f

Please sign in to comment.