Mercurial > audlegacy
annotate Plugins/Input/aac/src/mp4_utils.c @ 250:b9e6cdce7219 trunk
[svn] Reduce code duplication and add a return statement.
author | chainsaw |
---|---|
date | Sat, 03 Dec 2005 09:27:11 -0800 |
parents | 0a2ad94e8607 |
children | e1630c75175b |
rev | line source |
---|---|
61 | 1 /* |
2 ** some function for MP4 file based on libmp4v2 from mpeg4ip project | |
3 */ | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
4 #include <gtk/gtk.h> |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
5 #include "mp4.h" |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
6 #include "faad.h" |
61 | 7 |
8 const char *mp4AudioNames[]= | |
9 { | |
10 "MPEG-1 Audio Layers 1,2 or 3", | |
11 "MPEG-2 low biterate (MPEG-1 extension) - MP3", | |
12 "MPEG-2 AAC Main Profile", | |
13 "MPEG-2 AAC Low Complexity profile", | |
14 "MPEG-2 AAC SSR profile", | |
15 "MPEG-4 audio (MPEG-4 AAC)", | |
16 0 | |
17 }; | |
18 | |
19 const u_int8_t mp4AudioTypes[] = | |
20 { | |
21 MP4_MPEG1_AUDIO_TYPE, // 0x6B | |
22 MP4_MPEG2_AUDIO_TYPE, // 0x69 | |
23 MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66 | |
24 MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67 | |
25 MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68 | |
26 MP4_MPEG4_AUDIO_TYPE, // 0x40 | |
27 0 | |
28 }; | |
29 | |
30 /* MPEG-4 Audio types from 14496-3 Table 1.5.1 (from mp4.h)*/ | |
31 const char *mpeg4AudioNames[]= | |
32 { | |
33 "!!!!MPEG-4 Audio track Invalid !!!!!!!", | |
34 "MPEG-4 AAC Main profile", | |
35 "MPEG-4 AAC Low Complexity profile", | |
36 "MPEG-4 AAC SSR profile", | |
37 "MPEG-4 AAC Long Term Prediction profile", | |
38 "MPEG-4 AAC Scalable", | |
39 "MPEG-4 CELP", | |
40 "MPEG-4 HVXC", | |
41 "MPEG-4 Text To Speech", | |
42 "MPEG-4 Main Synthetic profile", | |
43 "MPEG-4 Wavetable Synthesis profile", | |
44 "MPEG-4 MIDI Profile", | |
45 "MPEG-4 Algorithmic Synthesis and Audio FX profile" | |
46 }; | |
47 | |
48 int getAACTrack(MP4FileHandle file) | |
49 { | |
50 int numTracks = MP4GetNumberOfTracks(file, NULL, 0); | |
51 int i=0; | |
52 | |
53 for(i=0;i<numTracks;i++){ | |
54 MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0); | |
55 const char *trackType = MP4GetTrackType(file, trackID); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
56 |
61 | 57 if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track ! |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
58 u_int8_t audiotype = MP4GetTrackAudioMpeg4Type(file, trackID); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
59 g_print("%s\n", mpeg4AudioNames[audiotype]); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
60 if(audiotype !=0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
61 return(trackID); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
62 else |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
63 return(-1); |
61 | 64 } |
65 } | |
66 return(-1); | |
67 } | |
68 | |
69 int getAudioTrack(MP4FileHandle file) | |
70 { | |
71 int numTracks = MP4GetNumberOfTracks(file, NULL,0); | |
72 int i=0; | |
73 | |
74 for(i=0;i<numTracks;i++){ | |
75 MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0); | |
76 const char *trackType = MP4GetTrackType(file, trackID); | |
77 if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){ | |
78 return(trackID); | |
79 } | |
80 } | |
81 return(-1); | |
82 } | |
83 | |
84 int getVideoTrack(MP4FileHandle file) | |
85 { | |
86 int numTracks = MP4GetNumberOfTracks(file, NULL, 0); | |
87 int i=0; | |
88 | |
89 for(i=0;i<numTracks; i++){ | |
90 MP4TrackId trackID = MP4FindTrackId(file, i, NULL, 0); | |
91 const char *trackType = MP4GetTrackType(file, trackID); | |
92 if(!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)){ | |
93 return (trackID); | |
94 } | |
95 } | |
96 return(-1); | |
97 } | |
98 | |
99 void getMP4info(char* file) | |
100 { | |
101 MP4FileHandle mp4file; | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
102 //MP4Duration trackDuration; |
61 | 103 int numTracks; |
104 int i=0; | |
105 | |
106 if(!(mp4file = MP4Read(file,0))) | |
107 return; | |
108 //MP4Dump(mp4file, 0, 0); | |
109 numTracks = MP4GetNumberOfTracks(mp4file, NULL, 0); | |
110 g_print("there are %d track(s)\n", numTracks); | |
111 for(i=0;i<numTracks;i++){ | |
112 MP4TrackId trackID = MP4FindTrackId(mp4file, i, NULL, 0); | |
113 const char *trackType = MP4GetTrackType(mp4file, trackID); | |
114 printf("Track %d, %s", trackID, trackType); | |
115 if(!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)){//we found audio track ! | |
116 int j=0; | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
117 u_int8_t audiotype = MP4GetTrackAudioMpeg4Type(mp4file, trackID); |
61 | 118 while(mp4AudioTypes[j]){ // what kind of audio is ? |
119 if(mp4AudioTypes[j] == audiotype){ | |
120 if(mp4AudioTypes[j] == MP4_MPEG4_AUDIO_TYPE){ | |
121 audiotype = MP4GetTrackAudioMpeg4Type(mp4file, trackID); | |
122 g_print(" %s", mpeg4AudioNames[audiotype]); | |
123 } | |
124 else{ | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
125 g_print(" %s", mp4AudioNames[j]); |
61 | 126 } |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
127 g_print(" duration : %d", |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
128 (int)MP4ConvertFromTrackDuration(mp4file, trackID, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
129 MP4GetTrackDuration(mp4file, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
130 trackID), |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
131 MP4_MSECS_TIME_SCALE)); |
61 | 132 } |
133 j++; | |
134 } | |
135 } | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
136 g_print("\n"); |
61 | 137 } |
138 MP4Close(mp4file); | |
139 } |