[mp4v2] r505 committed - Fix for issue 174: new API function to free memory that was allocated ...

17 views
Skip to first unread message

mp...@googlecode.com

unread,
Oct 16, 2014, 3:57:37 PM10/16/14
to mp...@googlegroups.com
Revision: 505
Author: Nicholas...@gmail.com
Date: Thu Oct 16 19:57:24 2014 UTC
Log: Fix for issue 174: new API function to free memory that was
allocated by API function MP4GetTrackH264SeqPictHeadres().
https://code.google.com/p/mp4v2/source/detail?r=505

Modified:
/trunk/include/mp4v2/track_prop.h
/trunk/src/mp4.cpp

=======================================
--- /trunk/include/mp4v2/track_prop.h Tue Apr 26 19:42:40 2011 UTC
+++ /trunk/include/mp4v2/track_prop.h Thu Oct 16 19:57:24 2014 UTC
@@ -214,6 +214,35 @@
uint32_t configSize );

/* h264 information routines */
+
+/** Frees the memory allocated by MP4GetTrackH264SeqPictHeaders.
+ *
+ * MP4FreeH264SeqPictHeaders frees the memory that was allocated by a
+ * call to the MP4GetTrackH264SeqPictHeaders function.
+ *
+ * When a client application wants to extract the H.264 video data from
+ * an MP4 file it will call MP4GetTrackH264SeqPictHeaders to obtain the
+ * sequence and picture parameter sets. These parameter sets are
+ * required for decoding a sequence of one, or more, coded slices. When
+ * the client application is done with the data it must free it. On the
+ * Windows platform this cannot be done directly by the client
+ * application because the C runtime of the client application and the C
+ * runtime of the mp4v2 DLL may be different, which will result in an
+ * error at runtime. This function allows the client application to let
+ * the mp4v2 DLL free the memory with the appropriate CRT heap manager.
+ *
+ * @param pSeqHeaders pointer to an array of SPS pointers.
+ * @param pSeqHeaderSize pointer to array of SPS sizes.
+ * @param pPictHeader pointer to an array of PPS pointers.
+ * @param pPictHeaderSize pointer to array of PPS sizes.
+ */
+MP4V2_EXPORT
+void MP4FreeH264SeqPictHeaders(
+ uint8_t** pSeqHeaders,
+ uint32_t* pSeqHeaderSize,
+ uint8_t** pPictHeader,
+ uint32_t* pPictHeaderSize );
+
MP4V2_EXPORT
bool MP4GetTrackH264ProfileLevel(
MP4FileHandle hFile,
=======================================
--- /trunk/src/mp4.cpp Fri Dec 28 16:45:40 2012 UTC
+++ /trunk/src/mp4.cpp Thu Oct 16 19:57:24 2014 UTC
@@ -2534,6 +2534,26 @@
}
return false;
}
+
+ void MP4FreeH264SeqPictHeaders(uint8_t** pSeqHeaders,
+ uint32_t* pSeqHeaderSize,
+ uint8_t** pPictHeader,
+ uint32_t* pPictHeaderSize )
+ {
+ uint32_t ix;
+
+ for (ix = 0; pSeqHeaderSize[ix] != 0; ++ix) {
+ free(pSeqHeaders[ix]);
+ }
+ free(pSeqHeaders);
+ free(pSeqHeaderSize);
+
+ for (ix = 0; pPictHeaderSize[ix] != 0; ++ix) {
+ free(pPictHeader[ix]);
+ }
+ free(pPictHeader);
+ free(pPictHeaderSize);
+ }

bool MP4GetTrackH264SeqPictHeaders (MP4FileHandle hFile,
MP4TrackId trackId,
Reply all
Reply to author
Forward
0 new messages