|
1 | | -/* |
2 | | - This software module was originally developed by Apple Computer, Inc. |
3 | | - in the course of development of MPEG-4. |
4 | | - This software module is an implementation of a part of one or |
5 | | - more MPEG-4 tools as specified by MPEG-4. |
6 | | - ISO/IEC gives users of MPEG-4 free license to this |
7 | | - software module or modifications thereof for use in hardware |
8 | | - or software products claiming conformance to MPEG-4. |
9 | | - Those intending to use this software module in hardware or software |
10 | | - products are advised that its use may infringe existing patents. |
11 | | - The original developer of this software module and his/her company, |
12 | | - the subsequent editors and their companies, and ISO/IEC have no |
13 | | - liability for use of this software module or modifications thereof |
14 | | - in an implementation. |
15 | | - Copyright is not released for non MPEG-4 conforming |
16 | | - products. Apple Computer, Inc. retains full right to use the code for its own |
17 | | - purpose, assign or donate the code to a third party and to |
18 | | - inhibit third parties from using the code for non |
19 | | - MPEG-4 conforming products. |
20 | | - This copyright notice must be included in all copies or |
21 | | - derivative works. Copyright (c) 1999. |
| 1 | +/* This software module was originally developed by Apple Computer, Inc. in the course of |
| 2 | + * development of MPEG-4. This software module is an implementation of a part of one or more MPEG-4 |
| 3 | + * tools as specified by MPEG-4. ISO/IEC gives users of MPEG-4 free license to this software module |
| 4 | + * or modifications thereof for use in hardware or software products claiming conformance to MPEG-4. |
| 5 | + * Those intending to use this software module in hardware or software products are advised that its |
| 6 | + * use may infringe existing patents. The original developer of this software module and his/her |
| 7 | + * company, the subsequent editors and their companies, and ISO/IEC have no liability for use of |
| 8 | + * this software module or modifications thereof in an implementation. Copyright is not released for |
| 9 | + * non MPEG-4 conforming products. Apple Computer, Inc. retains full right to use the code for its |
| 10 | + * own purpose, assign or donate the code to a third party and to inhibit third parties from using |
| 11 | + * the code for non MPEG-4 conforming products. This copyright notice must be included in all copies |
| 12 | + * or derivative works. Copyright (c) 1999. |
22 | 13 | */ |
23 | 14 | /* |
24 | 15 | $Id: HEVCConfigurationAtom.c,v 1.1.1.1 2016/09/14 armin Exp $ |
|
29 | 20 | #include <stdlib.h> |
30 | 21 | #include <string.h> |
31 | 22 |
|
32 | | -static void destroy( MP4AtomPtr s ) |
| 23 | +static void destroy(MP4AtomPtr s) |
33 | 24 | { |
34 | | - MP4Err err; |
35 | | - ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr) s; |
36 | | - err = MP4NoErr; |
37 | | - |
38 | | - if ( self == NULL ) |
39 | | - BAILWITHERROR( MP4BadParamErr ) |
40 | | - |
41 | | - if ( self->super ) |
42 | | - self->super->destroy( s ); |
| 25 | + MP4Err err; |
| 26 | + ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr)s; |
| 27 | + err = MP4NoErr; |
| 28 | + |
| 29 | + if(self == NULL) BAILWITHERROR(MP4BadParamErr) |
| 30 | + |
| 31 | + if(self->super) self->super->destroy(s); |
43 | 32 | bail: |
44 | | - TEST_RETURN( err ); |
45 | | - |
46 | | - return; |
| 33 | + TEST_RETURN(err); |
| 34 | + |
| 35 | + return; |
47 | 36 | } |
48 | 37 |
|
49 | | -static MP4Err serialize( struct MP4Atom* s, char* buffer ) |
| 38 | +static MP4Err serialize(struct MP4Atom *s, char *buffer) |
50 | 39 | { |
51 | | - MP4Err err; |
52 | | - u32 configSize; |
53 | | - ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr) s; |
54 | | - err = MP4NoErr; |
55 | | - |
56 | | - err = MP4SerializeCommonBaseAtomFields( (MP4AtomPtr) s, buffer ); if (err) goto bail; |
57 | | - buffer += self->bytesWritten; |
58 | | - |
59 | | - err = MP4GetHandleSize(self->configRecordHandle, &configSize); if (err) goto bail; |
60 | | - |
61 | | - PUTBYTES(*self->configRecordHandle, configSize); |
62 | | - |
63 | | - assert( self->bytesWritten == self->size ); |
| 40 | + MP4Err err; |
| 41 | + u32 configSize; |
| 42 | + ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr)s; |
| 43 | + err = MP4NoErr; |
| 44 | + |
| 45 | + err = MP4SerializeCommonBaseAtomFields((MP4AtomPtr)s, buffer); |
| 46 | + if(err) goto bail; |
| 47 | + buffer += self->bytesWritten; |
| 48 | + |
| 49 | + err = MP4GetHandleSize(self->configRecordHandle, &configSize); |
| 50 | + if(err) goto bail; |
| 51 | + |
| 52 | + PUTBYTES(*self->configRecordHandle, configSize); |
| 53 | + |
| 54 | + assert(self->bytesWritten == self->size); |
64 | 55 | bail: |
65 | | - TEST_RETURN( err ); |
66 | | - |
67 | | - return err; |
| 56 | + TEST_RETURN(err); |
| 57 | + |
| 58 | + return err; |
68 | 59 | } |
69 | 60 |
|
70 | | -static MP4Err calculateSize( struct MP4Atom* s ) |
| 61 | +static MP4Err calculateSize(struct MP4Atom *s) |
71 | 62 | { |
72 | | - MP4Err err; |
73 | | - u32 configSize; |
74 | | - ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr) s; |
75 | | - err = MP4NoErr; |
76 | | - |
77 | | - err = MP4CalculateBaseAtomFieldSize( (MP4AtomPtr) s ); if (err) goto bail; |
| 63 | + MP4Err err; |
| 64 | + u32 configSize; |
| 65 | + ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr)s; |
| 66 | + err = MP4NoErr; |
78 | 67 |
|
79 | | - err = MP4GetHandleSize(self->configRecordHandle, &configSize); if (err) goto bail; |
80 | | - self->size += configSize; |
| 68 | + err = MP4CalculateBaseAtomFieldSize((MP4AtomPtr)s); |
| 69 | + if(err) goto bail; |
| 70 | + |
| 71 | + err = MP4GetHandleSize(self->configRecordHandle, &configSize); |
| 72 | + if(err) goto bail; |
| 73 | + self->size += configSize; |
81 | 74 |
|
82 | 75 | bail: |
83 | | - TEST_RETURN( err ); |
84 | | - |
85 | | - return err; |
| 76 | + TEST_RETURN(err); |
| 77 | + |
| 78 | + return err; |
86 | 79 | } |
87 | 80 |
|
88 | | -static MP4Err createFromInputStream( MP4AtomPtr s, MP4AtomPtr proto, MP4InputStreamPtr inputStream ) |
| 81 | +static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStreamPtr inputStream) |
89 | 82 | { |
90 | | - MP4Err err; |
91 | | - long bytesToRead; |
92 | | - ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr)s; |
| 83 | + MP4Err err; |
| 84 | + long bytesToRead; |
| 85 | + ISOIFF_HEVCConfigurationAtomPtr self = (ISOIFF_HEVCConfigurationAtomPtr)s; |
93 | 86 |
|
94 | | - err = MP4NoErr; |
95 | | - if (self == NULL) BAILWITHERROR(MP4BadParamErr) |
96 | | - err = self->super->createFromInputStream(s, proto, (char*)inputStream); if (err) goto bail; |
| 87 | + err = MP4NoErr; |
| 88 | + if(self == NULL) BAILWITHERROR(MP4BadParamErr) |
| 89 | + err = self->super->createFromInputStream(s, proto, (char *)inputStream); |
| 90 | + if(err) goto bail; |
97 | 91 |
|
98 | | - bytesToRead = s->size - s->bytesRead; |
99 | | - err = MP4NewHandle(bytesToRead, &self->configRecordHandle); if (err) goto bail; |
100 | | - GETBYTES_V(bytesToRead, *self->configRecordHandle); |
| 92 | + bytesToRead = s->size - s->bytesRead; |
| 93 | + err = MP4NewHandle(bytesToRead, &self->configRecordHandle); |
| 94 | + if(err) goto bail; |
| 95 | + GETBYTES_V(bytesToRead, *self->configRecordHandle); |
101 | 96 |
|
102 | | - err = ISOIFF_CreateHEVCDecConfRecFromHandle(self->configRecordHandle, &self->configRecord); if (err) goto bail; |
| 97 | + err = ISOIFF_CreateHEVCDecConfRecFromHandle(self->configRecordHandle, &self->configRecord); |
| 98 | + if(err) goto bail; |
103 | 99 |
|
104 | 100 | bail: |
105 | | - TEST_RETURN(err); |
| 101 | + TEST_RETURN(err); |
106 | 102 |
|
107 | | - return err; |
| 103 | + return err; |
108 | 104 | } |
109 | 105 |
|
110 | | -MP4Err ISOIFF_CreateHEVCConfigurationAtom( ISOIFF_HEVCConfigurationAtomPtr *outAtom, ISOIFF_HEVCDecoderConfigRecord configRecord) |
| 106 | +MP4Err ISOIFF_CreateHEVCConfigurationAtom(ISOIFF_HEVCConfigurationAtomPtr *outAtom, |
| 107 | + ISOIFF_HEVCDecoderConfigRecord configRecord) |
111 | 108 | { |
112 | | - MP4Err err; |
113 | | - ISOIFF_HEVCConfigurationAtomPtr self; |
114 | | - |
115 | | - self = (ISOIFF_HEVCConfigurationAtomPtr) calloc( 1, sizeof(ISOIFF_HEVCConfigurationAtom) ); |
116 | | - TESTMALLOC( self ); |
117 | | - |
118 | | - err = MP4CreateBaseAtom( (MP4AtomPtr) self ); if ( err ) goto bail; |
119 | | - |
120 | | - self->type = ISOIFF_4CC_hvcC; |
121 | | - self->name = "HEVC Configuration"; |
122 | | - self->createFromInputStream = (cisfunc) createFromInputStream; |
123 | | - self->destroy = destroy; |
124 | | - self->calculateSize = calculateSize; |
125 | | - self->serialize = serialize; |
126 | | - self->configRecord = configRecord; |
127 | | - |
128 | | - err = MP4NewHandle(0, &self->configRecordHandle); if (err) goto bail; |
129 | | - err = ISOIFF_PutHEVCDecConfRecordIntoHandle(configRecord, self->configRecordHandle); if (err) goto bail; |
130 | | - |
131 | | - *outAtom = self; |
| 109 | + MP4Err err; |
| 110 | + ISOIFF_HEVCConfigurationAtomPtr self; |
| 111 | + |
| 112 | + self = (ISOIFF_HEVCConfigurationAtomPtr)calloc(1, sizeof(ISOIFF_HEVCConfigurationAtom)); |
| 113 | + TESTMALLOC(self); |
| 114 | + |
| 115 | + err = MP4CreateBaseAtom((MP4AtomPtr)self); |
| 116 | + if(err) goto bail; |
| 117 | + |
| 118 | + self->type = ISOIFF_4CC_hvcC; |
| 119 | + self->name = "HEVC Configuration"; |
| 120 | + self->createFromInputStream = (cisfunc)createFromInputStream; |
| 121 | + self->destroy = destroy; |
| 122 | + self->calculateSize = calculateSize; |
| 123 | + self->serialize = serialize; |
| 124 | + self->configRecord = configRecord; |
| 125 | + |
| 126 | + err = MP4NewHandle(0, &self->configRecordHandle); |
| 127 | + if(err) goto bail; |
| 128 | + err = ISOIFF_PutHEVCDecConfRecordIntoHandle(configRecord, self->configRecordHandle); |
| 129 | + if(err) goto bail; |
| 130 | + |
| 131 | + *outAtom = self; |
132 | 132 | bail: |
133 | | - TEST_RETURN( err ); |
134 | | - |
135 | | - return err; |
| 133 | + TEST_RETURN(err); |
| 134 | + |
| 135 | + return err; |
136 | 136 | } |
0 commit comments