mp_msg.c: Avoid out-of-bounds read if empty string is printed
[mplayer/glamo.git] / TOOLS / dump_mp4.c
blobc5b1846a36864582919ca414037d077f43503775
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License along
13 * with this program; if not, write to the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #include <stdio.h>
19 int main(void){
20 int c;
21 unsigned int head=-1;
22 int pos=-3;
24 while((c=getchar())>=0){
25 head<<=8;
26 if(head==0x100){
27 int startcode=head|c;
28 printf("%08X 1%02X ",pos,c);
29 if (startcode<=0x11F) printf("Video Object Start");
30 else if(startcode<=0x12F) printf("Video Object Layer Start");
31 else if(startcode<=0x13F) printf("Reserved");
32 else if(startcode<=0x15F) printf("FGS bp start");
33 else if(startcode<=0x1AF) printf("Reserved");
34 else if(startcode==0x1B0) printf("Visual Object Seq Start");
35 else if(startcode==0x1B1) printf("Visual Object Seq End");
36 else if(startcode==0x1B2) printf("User Data");
37 else if(startcode==0x1B3) printf("Group of VOP start");
38 else if(startcode==0x1B4) printf("Video Session Error");
39 else if(startcode==0x1B5) printf("Visual Object Start");
40 else if(startcode==0x1B6) printf("Video Object Plane start");
41 else if(startcode==0x1B7) printf("slice start");
42 else if(startcode==0x1B8) printf("extension start");
43 else if(startcode==0x1B9) printf("fgs start");
44 else if(startcode==0x1BA) printf("FBA Object start");
45 else if(startcode==0x1BB) printf("FBA Object Plane start");
46 else if(startcode==0x1BC) printf("Mesh Object start");
47 else if(startcode==0x1BD) printf("Mesh Object Plane start");
48 else if(startcode==0x1BE) printf("Still Textutre Object start");
49 else if(startcode==0x1BF) printf("Textutre Spatial Layer start");
50 else if(startcode==0x1C0) printf("Textutre SNR Layer start");
51 else if(startcode==0x1C1) printf("Textutre Tile start");
52 else if(startcode==0x1C2) printf("Textutre Shape Layer start");
53 else if(startcode==0x1C3) printf("stuffing start");
54 else if(startcode<=0x1C5) printf("reserved");
55 else if(startcode<=0x1FF) printf("System start");
56 printf("\n");
58 head|=c;
59 ++pos;
62 return 0;