Debian Codegraph @

encodedv/encodedv.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * encodedv.c
3 *
4 * Copyright (C) James Bowman - July 2000
5 * Peter Schlaile - Jan 2001
6 *
7 * This file is part of libdv, a free DV (IEC 61834/SMPTE 314M)
8 * codec.
9 *
10 * libdv is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser Public License as published by
12 * the Free Software Foundation; either version 2.1, or (at your
13 * option) any later version.
14 *
15 * libdv is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser Public License
21 * along with libdv; see the file COPYING. If not, write to
22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * The libdv homepage is http://libdv.sourceforge.net/.
25 */
26
•27 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:412:9`!
28 #include <config.h>cxx . . $ `<file>/config.h`/
29 #endif
30
31 #include <string.h>
32 #include "libdv/dv_types.h"cxx . . $ `<file>/libdv/dv_types.h`/
33 #include "libdv/dv.h"cxx . . $ `<file>/libdv/dv.h`/
34 #include "libdv/encode.h"cxx . . $ `<file>/libdv/encode.h`/
35 #include "libdv/enc_input.h"cxx . . $ `<file>/libdv/enc_input.h`/
36 #include "libdv/enc_output.h"cxx . . $ `<file>/libdv/enc_output.h`/
37 #include "libdv/headers.h"cxx . . $ `<file>/libdv/headers.h`/
38
39 #define DV_ENCODER_OPT_VERSIONcxx . . $ `encodedv/encodedv.c:39:9`! 0
40 #define DV_ENCODER_OPT_START_FRAMEcxx . . $ `encodedv/encodedv.c:40:9`! 1
41 #define DV_ENCODER_OPT_END_FRAMEcxx . . $ `encodedv/encodedv.c:41:9`! 2
42 #define DV_ENCODER_OPT_WRONG_INTERLACEcxx . . $ `encodedv/encodedv.c:42:9`! 3
43 #define DV_ENCODER_OPT_ENCODE_PASSEScxx . . $ `encodedv/encodedv.c:43:9`! 4
44 #define DV_ENCODER_OPT_VERBOSEcxx . . $ `encodedv/encodedv.c:44:9`! 5
45 #define DV_ENCODER_OPT_INPUTcxx . . $ `encodedv/encodedv.c:45:9`! 6
46 #define DV_ENCODER_OPT_AUDIO_INPUTcxx . . $ `encodedv/encodedv.c:46:9`! 7
47 #define DV_ENCODER_OPT_OUTPUTcxx . . $ `encodedv/encodedv.c:47:9`! 8
48 #define DV_ENCODER_OPT_AUTOHELPcxx . . $ `encodedv/encodedv.c:48:9`! 9
49 #define DV_ENCODER_OPT_STATIC_QNOcxx . . $ `encodedv/encodedv.c:49:9`! 10
50 #define DV_ENCODER_OPT_FPScxx . . $ `encodedv/encodedv.c:50:9`! 11
51 #define DV_ENCODER_OPT_FORCE_DCTcxx . . $ `encodedv/encodedv.c:51:9`! 12
52 #define DV_ENCODER_OPT_16X9cxx . . $ `encodedv/encodedv.c:52:9`! 13
53 #define DV_ENCODER_OPT_STDINcxx . . $ `encodedv/encodedv.c:53:9`! 14
54 #define DV_ENCODER_NUM_OPTScxx . . $ `encodedv/encodedv.c:54:9`! 15
55
56 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
57 {
58 unsigned long start = 0;
59 unsigned long end = 0xfffffff;
60 int wrong_interlace = 0;
61 const char* filename = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
62 const char* audio_filename = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
63 int vlc_encode_passes = 3;
64 int static_qno = 0;
65 int verbose_mode = 0;
66 const char* audio_input_filter_str = "none";
67 const char* input_filter_str = "ppm";
68 const char* output_filter_str = "raw";
69 dv_enc_audio_input_filter_tcxx . . $ dv_enc_audio_input_filter_t# * audio_input_filter = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
70 dv_enc_input_filter_tcxx . . $ dv_enc_input_filter_t# * input_filter;
71 dv_enc_output_filter_tcxx . . $ dv_enc_output_filter_t# * output_filter;
72 int count = 0;
73 int fps = 0;
74 int is16x9 = 0;
75 int err_code;
76 int force_dct = -1;
77 int isStdin = 0;
78
79 #if HAVE_LIBPOPTcxx . . $ `config.h:38:9`!
80 struct poptOptioncxx . . $ poptOption# option_table[DV_ENCODER_NUM_OPTScxx . . $ `encodedv/encodedv.c:54:9`!+1];
81 int rc; /* return code from popt */
82 poptContextcxx . . $ poptContext# optCon; /* context for parsing command-line options */
83 option_table[DV_ENCODER_OPT_VERSIONcxx . . $ `encodedv/encodedv.c:39:9`!] = (struct poptOptioncxx . . $ poptOption#) {
84 longName: "version",
85 val: 'v',
86 descrip: "show encode version number"
87 }; /* version */
88
89 option_table[DV_ENCODER_OPT_START_FRAMEcxx . . $ `encodedv/encodedv.c:40:9`!] = (struct poptOptioncxx . . $ poptOption#) {
90 longName: "start-frame",
91 shortName: 's',
92 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
93 arg: &start,
94 argDescrip: "count",
95 descrip: "start at <count> frame (defaults to 0)"
96 }; /* start-frame */
97
98 option_table[DV_ENCODER_OPT_END_FRAMEcxx . . $ `encodedv/encodedv.c:41:9`!] = (struct poptOptioncxx . . $ poptOption#) {
99 longName: "end-frame",
100 shortName: 'e',
101 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
102 arg: &end,
103 argDescrip: "count",
104 descrip: "end at <count> frame (defaults to unlimited)"
105 }; /* end-frames */
106
107 option_table[DV_ENCODER_OPT_WRONG_INTERLACEcxx . . $ `encodedv/encodedv.c:42:9`!] = (struct poptOptioncxx . . $ poptOption#) {
108 longName: "wrong-interlace",
109 shortName: 'l',
110 arg: &wrong_interlace,
111 descrip: "flip lines to compensate for wrong interlacing"
112 }; /* wrong-interlace */
113
114 option_table[DV_ENCODER_OPT_ENCODE_PASSEScxx . . $ `encodedv/encodedv.c:43:9`!] = (struct poptOptioncxx . . $ poptOption#) {
115 longName: "vlc-passes",
116 shortName: 'p',
117 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
118 arg: &vlc_encode_passes,
119 descrip: "vlc code distribution passes (1-3) "
120 "greater values = better quality but "
121 "not necessarily slower encoding!"
122 }; /* vlc encoder passes */
123
124 option_table[DV_ENCODER_OPT_VERBOSEcxx . . $ `encodedv/encodedv.c:44:9`!] = (struct poptOptioncxx . . $ poptOption#) {
125 longName: "verbose",
126 shortName: 'v',
127 arg: &verbose_mode,
128 descrip: "show encoder statistics / status information"
129 }; /* verbose mode */
130
131 option_table[DV_ENCODER_OPT_INPUTcxx . . $ `encodedv/encodedv.c:45:9`!] = (struct poptOptioncxx . . $ poptOption#) {
132 longName: "input",
133 shortName: 'i',
134 arg: &input_filter_str,
135 argInfo: POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`!,
136 descrip: "choose input-filter [>ppm<, pgm, video]"
137 }; /* input */
138
139 option_table[DV_ENCODER_OPT_AUDIO_INPUTcxx . . $ `encodedv/encodedv.c:46:9`!] = (struct poptOptioncxx . . $ poptOption#) {
140 longName: "audio-input",
141 shortName: 'a',
142 arg: &audio_input_filter_str,
143 argInfo: POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`!,
144 descrip: "choose audio-input-filter [>none<, wav, dsp]"
145 }; /* audio input */
146
147 option_table[DV_ENCODER_OPT_OUTPUTcxx . . $ `encodedv/encodedv.c:47:9`!] = (struct poptOptioncxx . . $ poptOption#) {
148 longName: "output",
149 shortName: 'o',
150 arg: &output_filter_str,
151 argInfo: POPT_ARG_STRINGcxx . . $ `<external>/16232926639102580118/popt.h:19:9`!,
152 descrip: "choose output-filter [>raw<]"
153 }; /* output */
154
155 option_table[DV_ENCODER_OPT_STATIC_QNOcxx . . $ `encodedv/encodedv.c:49:9`!] = (struct poptOptioncxx . . $ poptOption#) {
156 longName: "static-qno",
157 shortName: 'q',
158 arg: &static_qno,
159 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
160 descrip: "static qno tables for quantisation on 2 VLC "
161 "passes. For turbo (but somewhat lossy encoding) try "
162 "-q [1,2] -p 2"
163 }; /* start qno */
164
165 option_table[DV_ENCODER_OPT_FPScxx . . $ `encodedv/encodedv.c:50:9`!] = (struct poptOptioncxx . . $ poptOption#) {
166 longName: "fps",
167 shortName: 'f',
168 arg: &fps,
169 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
170 descrip: "set frames per second (default: use all frames)"
171 }; /* fps */
172
173 option_table[DV_ENCODER_OPT_FORCE_DCTcxx . . $ `encodedv/encodedv.c:51:9`!] = (struct poptOptioncxx . . $ poptOption#) {
174 longName: "force-dct",
175 shortName: 'd',
176 arg: &force_dct,
177 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
178 descrip: "force dct mode (88 or 248) for whole picture"
179 }; /* force dct */
180
181 option_table[DV_ENCODER_OPT_16X9cxx . . $ `encodedv/encodedv.c:52:9`!] = (struct poptOptioncxx . . $ poptOption#) {
182 longName: "wide",
183 shortName: 'w',
184 arg: &is16x9,
185 argInfo: POPT_ARG_INTcxx . . $ `<external>/16232926639102580118/popt.h:20:9`!,
186 descrip: "set wide 16 x 9 format"
187 }; /* 16x9 */
188
189 option_table[DV_ENCODER_OPT_STDINcxx . . $ `encodedv/encodedv.c:53:9`!] = (struct poptOptioncxx . . $ poptOption#) {
190 longName: "",
191 shortName: '-',
192 arg: &isStdin,
193 descrip: "set stdin input"
194 }; /* stdin */
195
196 option_table[DV_ENCODER_OPT_AUTOHELPcxx . . $ `encodedv/encodedv.c:48:9`!] = (struct poptOptioncxx . . $ poptOption#) {
197 argInfo: POPT_ARG_INCLUDE_TABLEcxx . . $ `<external>/16232926639102580118/popt.h:22:9`!,
198 arg: poptHelpOptionscxx . . $ poptHelpOptions.,
199 descrip: "Help options",
200 }; /* autohelp */
201
202 option_table[DV_ENCODER_NUM_OPTScxx . . $ `encodedv/encodedv.c:54:9`!] = (struct poptOptioncxx . . $ poptOption#) {
203 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0 };
204
205 optCon = poptGetContextcxx . . $ poptGetContext(69e83c0752e8078).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, argc,
206 (const char **)argv, option_table, 0);
207 poptSetOtherOptionHelpcxx . . $ poptSetOtherOptionHelp(fc627e009555550b).(optCon, "<filename pattern or - for stdin>"
208 " [<audio input>]");
209
210 while ((rc = poptGetNextOptcxx . . $ poptGetNextOpt(8c14591e39307bbe).(optCon)) > 0) {
211 switch (rc) {
212 case 'v':
213 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!,"encode: version %s, "
214 "http://libdv.sourceforge.net/\n",
215 "CVS 01/14/2001");
216 exitcxx . . $ exit(3ca292c338df9bb3).(0);
217 break;
218 default:
219 break;
220 } /* switch */
221 } /* while */
222
223 if (rc < -1) {
224 /* an error occurred during option processing */
225 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: %s\n",
226 poptBadOptioncxx . . $ poptBadOption(abdebb552147fd6f).(optCon, POPT_BADOPTION_NOALIAScxx . . $ `<external>/16232926639102580118/popt.h:99:9`!),
227 poptStrerrorcxx . . $ poptStrerror(f7ae7e56280f18ae).(rc));
228 exitcxx . . $ exit(3ca292c338df9bb3).(-1);
229 }
230
231 if ( !isStdin ) {
232 filename = poptGetArgcxx . . $ poptGetArg(86c70cf25448eb00).(optCon);
233 if(filename == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
234 poptPrintUsagecxx . . $ poptPrintUsage(692800addc75c9c3).(optCon, stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, 0);
235 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!,
236 "\nSpecify a single <filename pattern> argument; "
237 "e.g. pond%%05d.ppm or - for stdin\n"
238 "(For audio input specify additionally "
239 "the audio source.)\n");
240 exitcxx . . $ exit(3ca292c338df9bb3).(-1);
241 }
242 }
243 else {
244 filename = "-";
245 }
246
247 audio_filename = poptGetArgcxx . . $ poptGetArg(86c70cf25448eb00).(optCon);
248 poptFreeContextcxx . . $ poptFreeContext(c32b9b4db48a8347).(optCon);
249
250 #else
251 /* No popt, no usage and no options! HINT: get popt if you don't
252 * have it yet, it's at: ftp://ftp.redhat.com/pub/redhat/code/popt
253 */
254 filename = argv[1];
255 #endif /* HAVE_LIBPOPT */
256
257 dv_enc_get_input_filterscxx . . $ dv_enc_get_input_filters(5441b2e7f1ee3c1e).(&input_filter, &count);
258 while (count
259 && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(input_filter->filter_namecxx . . $ dv_enc_input_filter_s#filter_name., input_filter_str) != 0) {
260 input_filter++;
261 count--;
262 }
263 if (!count) {
264 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Unknown input filter selected: %s!\n"
265 "The following filters are supported:\n",
266 input_filter_str);
267 dv_enc_get_input_filterscxx . . $ dv_enc_get_input_filters(5441b2e7f1ee3c1e).(&input_filter, &count);
268 while (count--) {
269 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s\n", input_filter->filter_namecxx . . $ dv_enc_input_filter_s#filter_name.);
270 input_filter++;
271 }
272 return(-1);
273 }
274
275 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(audio_input_filter_str, "none") != 0) {
276 dv_enc_get_audio_input_filterscxx . . $ dv_enc_get_audio_input_filters(e7e97791f7a919ae).(&audio_input_filter, &count);
277 while (count
278 && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(audio_input_filter->filter_namecxx . . $ dv_audio_enc_input_filter_s#filter_name.,
279 audio_input_filter_str) != 0) {
280 audio_input_filter++;
281 count--;
282 }
283 if (!count) {
284 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!,
285 "Unknown audio input filter selected: %s!\n"
286 "The following filters are supported:\n",
287 audio_input_filter_str);
288 dv_enc_get_audio_input_filterscxx . . $ dv_enc_get_audio_input_filters(e7e97791f7a919ae).(&audio_input_filter,
289 &count);
290 while (count--) {
291 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s\n",
292 audio_input_filter->filter_namecxx . . $ dv_audio_enc_input_filter_s#filter_name.);
293 audio_input_filter++;
294 }
295 return(-1);
296 }
297 if (!audio_filename) {
298 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Audio input selected but no filename "
299 "or device given!\n");
300 return(-1);
301 }
302 }
303
304 dv_enc_get_output_filterscxx . . $ dv_enc_get_output_filters(42011b2491d6e6ad).(&output_filter, &count);
305 while (count &&
306 strcmpcxx . . $ strcmp(5ae29d726ae57f88).(output_filter->filter_namecxx . . $ dv_enc_output_filter_s#filter_name., output_filter_str) != 0) {
307 output_filter++;
308 count--;
309 }
310 if (!count) {
311 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Unknown output filter selected: %s!\n"
312 "The following filters are supported:\n",
313 output_filter_str);
314 dv_enc_get_output_filterscxx . . $ dv_enc_get_output_filters(42011b2491d6e6ad).(&output_filter, &count);
315 while (count--) {
316 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s\n", output_filter->filter_namecxx . . $ dv_enc_output_filter_s#filter_name.);
317 output_filter++;
318 }
319 return(-1);
320 }
321 if (static_qno < 0 || static_qno > 2) {
322 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "There are only two static qno tables "
323 "registered right now:\n"
324 "1 : for sharp DV pictures\n"
325 "2 : for somewhat noisy satelite television signal\n"
326 "\nIf you want to add some more, go ahead ;-)\n");
327 return(-1);
328 }
329 if (static_qno && vlc_encode_passes == 1) {
330 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Warning! static_qno enabled but "
331 "vlc_passes == 1.\n"
332 "This won't gain you anything for now !!!\n");
333 }
334 if (force_dct != -1) {
335 switch (force_dct) {
336 case 88:
337 force_dct = DV_DCT_88cxx . . $ `libdv/dv_types.h:134:9`!;
338 break;
339 case 248:
340 force_dct = DV_DCT_248cxx . . $ `libdv/dv_types.h:133:9`!;
341 break;
342 default:
343 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "--force-dct has to be 88 or 248!\n");
344 return(-1);
345 }
346 }
347
348 dv_initcxx . . $ dv_init(3e454b8ccf442868).(FALSEcxx . . $ `libdv/dv_types.h:50:9`!, FALSEcxx . . $ `libdv/dv_types.h:50:9`!);
349
350 if (input_filter->initcxx . . $ dv_enc_input_filter_s#init.(wrong_interlace, force_dct) < 0) {
351 return -1;
352 }
353 if (output_filter->initcxx . . $ dv_enc_output_filter_s#init.(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!) < 0) {
354 return -1;
355 }
356 /* audio_input_filter->init() is in dv_encoder_loop! */
357
358 err_code = dv_encoder_loopcxx . . $ dv_encoder_loop(74472192866b2583).(input_filter,audio_input_filter, output_filter,
359 start, end, filename, audio_filename,
360 vlc_encode_passes, static_qno,
361 verbose_mode, fps, is16x9);
362
363 input_filter->finishcxx . . $ dv_enc_input_filter_s#finish.();
364 if (audio_input_filter) {
365 audio_input_filter->finishcxx . . $ dv_audio_enc_input_filter_s#finish.();
366 }
367 output_filter->finishcxx . . $ dv_enc_output_filter_s#finish.();
368
369 if (verbose_mode) {
370 dv_show_statisticscxx . . $ dv_show_statistics(49f6e7a06ebc5aa8).();
371 }
372 return 0;
373 }
374
375