]> git.pld-linux.org Git - packages/avifile.git/blob - avifile-wma2wav.patch
- workaround for struct name change in Linux 2.6 headers
[packages/avifile.git] / avifile-wma2wav.patch
1 diff -urN avifile-0.6.0.20011207/lib/common/util.cpp avifile-0.6.0.20011207-/lib/common/util.cpp
2 --- avifile-0.6.0.20011207/lib/common/util.cpp  Wed Nov 21 23:33:02 2001
3 +++ avifile-0.6.0.20011207-/lib/common/util.cpp Wed Dec 19 01:58:31 2001
4 @@ -440,7 +440,7 @@
5      }
6      fclose(f);
7  
8 -    printf("Available CPU flags: %s\n", flags);
9 +    fprintf(stderr, "Available CPU flags: %s\n", flags);
10      have_tsc = (strstr(flags, "tsc") != 0);
11      have_mmx = (strstr(flags, "mmx") != 0);
12      have_sse = (strstr(flags, "sse") != 0);
13 @@ -460,7 +460,7 @@
14      if (freq < 0)
15         freq = old_freq();
16      if (have_tsc)
17 -       printf("%f MHz %s processor detected\n", freq/1000., model);
18 +       fprintf(stderr, "%f MHz %s processor detected\n", freq/1000., model);
19  }
20  
21  
22 diff -urN avifile-0.6.0.20011207/samples/misc/Makefile.am avifile-0.6.0.20011207-/samples/misc/Makefile.am
23 --- avifile-0.6.0.20011207/samples/misc/Makefile.am     Mon Dec  3 11:38:01 2001
24 +++ avifile-0.6.0.20011207-/samples/misc/Makefile.am    Wed Dec 19 01:58:31 2001
25 @@ -8,6 +8,7 @@
26  avitype_SOURCES=avitype.cpp
27  
28  extractor_SOURCES=extractor.cpp
29 +wma2wav_SOURCES=wma2wav.cpp
30  test_SOURCES=test.cpp
31  #plustest_SOURCES=plustest.cpp
32  #imtest_SOURCES=imtest.cpp
33 @@ -24,6 +25,7 @@
34  avitype_LDADD = $(LIBRARY)
35  
36  extractor_LDADD = $(LIBRARY)
37 +wma2wav_LDADD = $(LIBRARY)
38  
39  if AMM_USE_JPEGLIB
40  avimake_SOURCES = avimake.cpp
41 @@ -33,7 +35,7 @@
42  PROG_AVIMAKE =
43  endif
44  
45 -bin_PROGRAMS = avibench avicat avitype $(PROG_AVIMAKE)
46 +bin_PROGRAMS = avibench avicat avitype $(PROG_AVIMAKE) wma2wav
47  check_PROGRAMS = asfdump asftest avitest extractor test
48  
49  EXTRA_DIST =  imtest.cpp plustest.cpp qualtest.cpp test.cpp
50 diff -urN avifile-0.6.0.20011207/samples/misc/wma2wav.cpp avifile-0.6.0.20011207-/samples/misc/wma2wav.cpp
51 --- avifile-0.6.0.20011207/samples/misc/wma2wav.cpp     Thu Jan  1 01:00:00 1970
52 +++ avifile-0.6.0.20011207-/samples/misc/wma2wav.cpp    Wed Dec 19 01:58:51 2001
53 @@ -0,0 +1,123 @@
54 +/*
55 + * Convert .wma files to .wav (so they can be treated with lame to produce
56 + * more reasonable output :^)
57 + * Copyright (c) 2001 Michal Moskal (malekith@pld.org.pl)
58 + *
59 + * I was motivated to write this simple cuple of lines by Piotr Modrzyk,
60 + * and I wish to thank him here ;)
61 + *
62 + * This program could be probably also used to extract soundtrack from 
63 + * movies, but I don't mind and hence the name...
64 + */
65 +
66 +#include <config.h>
67 +#include <default.h>
68 +#include <avifile.h>
69 +#include <stdio.h>
70 +#include <aviplay.h>
71 +#include <except.h>
72 +#include <version.h>
73 +#include <unistd.h>
74 +#include <fcntl.h>
75 +#include <string.h>
76 +
77 +#define __MODULE__ "wma2wav"
78 +
79 +using namespace std;
80 +
81 +int main(int argc, const char **argv)
82 +{
83 +       IAviReadFile *ac = 0;
84 +       IAviReadStream *as = 0;
85 +       uint8_t *zz = 0;
86 +       int out_fd;
87 +       const char *infile, *outfile;
88 +
89 +       if (argc != 2 && argc != 3) {
90 +               fprintf(stderr, "\n\nUSAGE: %s inputfile [outputfile]\n"
91 +                               "If outputfile is not present or is \"-\" "
92 +                               "stdout is used.\n\n",  argv[0]);
93 +               exit(1);
94 +       }
95 +
96 +       if (GetAvifileVersion() != AVIFILE_VERSION) {
97 +               fprintf(stderr,
98 +                       "This binary was compiled for Avifile ver. "
99 +                       "%f, but the but the library is ver. %f. Aborting.\n",
100 +                       AVIFILE_VERSION, GetAvifileVersion());
101 +               exit(1);
102 +       }
103 +
104 +       infile = argv[1];
105 +       outfile = argv[2];
106 +       
107 +       if (outfile && strcmp(outfile, "-") == 0)
108 +               outfile = NULL;
109 +       
110 +       if (outfile == NULL) {
111 +               // preserve stdout
112 +               out_fd = dup(1);
113 +               // copy messages to stderr
114 +               dup2(2, 1);
115 +       } else {
116 +               out_fd = open(outfile, O_WRONLY|O_TRUNC|O_CREAT, 0666);
117 +               if (out_fd < 0) {
118 +                       perror(outfile);
119 +                       exit(1);
120 +               }
121 +       }
122 +
123 +       try {
124 +               ac = CreateIAviReadFile(infile);
125 +               if (ac == NULL) {
126 +                       fprintf(stderr, "%s: can't read it\n", infile);
127 +                       exit(1);
128 +               }
129 +
130 +               as = ac->GetStream(0, AviStream::Audio);
131 +               if (ac == NULL) {
132 +                       fprintf(stderr, "%s: doesn't contains audio stream\n", 
133 +                               infile);
134 +                       exit(1);
135 +               }
136 +
137 +               const int buffer_size = 2 * 1024 * 1024;
138 +               zz = new uint8_t[buffer_size];
139 +               size_t samp_read, bytes_read, sz;
140 +               WAVEFORMATEX hdr;
141 +
142 +               memset(&hdr, 0, sizeof(hdr));
143 +               as->GetAudioFormatInfo(&hdr, NULL);
144 +
145 +               write(out_fd, "RIFF\x0f\xff\xff\xffWAVEfmt \x10\0\0\0", 20);
146 +               // override
147 +               hdr.wFormatTag = 1;
148 +               write(out_fd, &hdr, 16);
149 +               write(out_fd, "data\x0f\xff\xff\xff", 8);
150 +
151 +               as->StopStreaming();
152 +               as->StartStreaming();
153 +               while (!as->Eof()) {
154 +                       sz = as->GetFrameSize();
155 +                       if (sz > (size_t)buffer_size)
156 +                               sz = buffer_size;
157 +                       as->ReadFrames(zz, sz, sz, samp_read, bytes_read);
158 +                       if (write(out_fd, zz, bytes_read) != (int)bytes_read) {
159 +                               perror("write");
160 +                               exit(1);
161 +                       }
162 +               }
163 +
164 +               close(out_fd);
165 +       } catch(FatalError & error) {
166 +               fprintf(stderr, "Fatal error:\n");
167 +               error.Print();
168 +               exit(1);
169 +       }
170 +       if (ac)
171 +               delete ac;
172 +       if (zz)
173 +               delete zz;
174 +               
175 +       return 0;
176 +}
This page took 0.079347 seconds and 3 git commands to generate.