[svn] / branches / release-1_3-branch / xvidextra / src / apps / miniconvert / cfourcc.cpp Repository:
ViewVC logotype

Annotation of /branches/release-1_3-branch/xvidextra/src/apps/miniconvert/cfourcc.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2096 - (view) (download)

1 : Isibaar 2096 /*
2 :     cfourcc.c - this is the main (and only) module.
3 :    
4 :     cfourcc - change the FOURCC code in the Microsoft RIFF AVI file.
5 :     Copyright (C) 2004-2005 mypapit <papit58@yahoo.com>
6 :    
7 :     This program is free software; you can redistribute it and/or modify
8 :     it under the terms of the GNU General Public License as published by
9 :     the Free Software Foundation; either version 2 of the License, or
10 :     (at your option) any later version.
11 :    
12 :     This program is distributed in the hope that it will be useful,
13 :     but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     GNU General Public License for more details.
16 :    
17 :     You should have received a copy of the GNU General Public License
18 :     along with this program; if not, write to the Free Software
19 :     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 :    
21 :     Project's web : http://sarovar.org/projects/gfourcc
22 :    
23 :    
24 :     Reworked for use with Xvid MiniConvert application on 26/03/2011
25 :     by Michael Militzer <michael@xvid.org>
26 :    
27 :     */
28 :    
29 :     #include "stdafx.h"
30 :    
31 :     #define AVILEN 224
32 :     typedef char AVIHDR[AVILEN];
33 :    
34 :     int
35 :     setDesc (AVIHDR header, const char *str)
36 :     {
37 :     memcpy (&header[0x70], str, 4);
38 :     return 0;
39 :     }
40 :    
41 :     int
42 :     setUsed (AVIHDR header, const char *str)
43 :     {
44 :     memcpy (&header[0xbc], str, 4);
45 :     return 0;
46 :     }
47 :    
48 :     int
49 :     fourcc_helper(TCHAR filename[MAX_PATH], char *ptrused, char *ptrdesc, int check_only)
50 :     {
51 :     AVIHDR avihdr;
52 :     FILE *fin;
53 :     char MAGIC[] = { 'R', 'I', 'F', 'F' };
54 :    
55 :     memset (&avihdr, 0, AVILEN); /* init avihdr just in case! */
56 :    
57 :     fin = _tfopen (filename, TEXT("rb"));
58 :     if (fin == NULL) {
59 :     OutputDebugString(TEXT("Error: Cannot open avi file!"));
60 :     return -1;
61 :     }
62 :    
63 :     if (fread (avihdr, sizeof (char), AVILEN, fin) < AVILEN) {
64 :     OutputDebugString(TEXT("Error: Read end unexpectedly, incomplete file?"));
65 :     return -1;
66 :     }
67 :     fclose (fin);
68 :    
69 :     if (check_only) {
70 :     /*lazy verifier! */
71 :     if (memcmp (avihdr, MAGIC, 4)) {
72 :     OutputDebugString(TEXT("Error: Probably not a supported avi file"));
73 :     return -1;
74 :     }
75 :     }
76 :     else {
77 :     fin = _tfopen (filename, TEXT("r+b"));
78 :     if (fin == NULL) {
79 :     OutputDebugString(TEXT("Error: Cannot open avi file for writing\n"));
80 :     return -1;
81 :     }
82 :    
83 :     setUsed (avihdr, ptrused);
84 :     setDesc (avihdr, ptrdesc);
85 :    
86 :     fseek (fin, 0, SEEK_SET);
87 :     fwrite (avihdr, sizeof (char), AVILEN, fin);
88 :     fflush (fin);
89 :     fclose (fin);
90 :     }
91 :    
92 :     return 0;
93 :     }

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4