1 /*****************************************************************
2  * gmerlin - a general purpose multimedia framework and applications
3  *
4  * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5  * gmerlin-general@lists.sourceforge.net
6  * http://gmerlin.sourceforge.net
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  * *****************************************************************/
21 
22 
23 #ifndef __BG_GAVL_H_
24 #define __BG_GAVL_H_
25 
26 /* Forward declaration */
27 typedef struct bg_thread_pool_s bg_thread_pool_t;
28 
29 /* Struct for converting audio */
30 
31 typedef struct
32   {
33   gavl_audio_options_t * opt;
34   int fixed_samplerate;
35   int samplerate;
36   int fixed_channel_setup;
37 
38   gavl_sample_format_t force_format;
39 
40   int num_front_channels;
41   int num_rear_channels;
42   int num_lfe_channels;
43 
44   int options_changed;
45   } bg_gavl_audio_options_t;
46 
47 int
48 bg_gavl_audio_set_parameter(void * data, const char * name,
49                             const bg_parameter_value_t * val);
50 
51 void bg_gavl_audio_options_init(bg_gavl_audio_options_t *);
52 
53 void bg_gavl_audio_options_free(bg_gavl_audio_options_t *);
54 
55 void bg_gavl_audio_options_set_format(const bg_gavl_audio_options_t *,
56                                       const gavl_audio_format_t * in_format,
57                                       gavl_audio_format_t * out_format);
58 
59 
60 typedef struct
61   {
62   gavl_video_options_t * opt;
63   gavl_pixelformat_t pixelformat;
64 
65   int framerate_mode;
66   int frame_duration;
67   int timescale;
68 
69   int size;
70   int user_image_width;
71   int user_image_height;
72   int user_pixel_width;
73   int user_pixel_height;
74 
75   bg_thread_pool_t * thread_pool;
76   int num_threads;
77   int options_changed;
78   } bg_gavl_video_options_t;
79 
80 int bg_gavl_video_set_parameter(void * data, const char * name,
81                                 const bg_parameter_value_t * val);
82 
83 void bg_gavl_video_options_init(bg_gavl_video_options_t *);
84 
85 void bg_gavl_video_options_free(bg_gavl_video_options_t *);
86 
87 void bg_gavl_video_options_set_framerate(const bg_gavl_video_options_t *,
88                                          const gavl_video_format_t * in_format,
89                                          gavl_video_format_t * out_format);
90 
91 void bg_gavl_video_options_set_frame_size(const bg_gavl_video_options_t * opt,
92                                           const gavl_video_format_t * in_format,
93                                           gavl_video_format_t * out_format);
94 
95 void bg_gavl_video_options_set_pixelformat(const bg_gavl_video_options_t * opt,
96                                            const gavl_video_format_t * in_format,
97                                            gavl_video_format_t * out_format);
98 
99 void bg_gavl_video_options_set_format(const bg_gavl_video_options_t *,
100                                       const gavl_video_format_t * in_format,
101                                       gavl_video_format_t * out_format);
102 
103 void bg_gavl_video_options_set_rectangles(const bg_gavl_video_options_t * opt,
104                                           const gavl_video_format_t * in_format,
105                                           const gavl_video_format_t * out_format,
106                                           int do_crop);
107 
108 gavl_scale_mode_t bg_gavl_string_to_scale_mode(const char * str);
109 gavl_downscale_filter_t bg_gavl_string_to_downscale_filter(const char * str);
110 
111 #if 0
112 void bg_gavl_video_options_set_framerate(const bg_gavl_video_options_t *,
113                                          const gavl_video_format_t * in_format,
114                                          gavl_video_format_t * out_format);
115 void bg_gavl_video_options_set_framesize(const bg_gavl_video_options_t *,
116                                          const gavl_video_format_t * in_format,
117                                          gavl_video_format_t * out_format);
118 void bg_gavl_video_options_set_interlace(const bg_gavl_video_options_t * opt,
119                                          const gavl_video_format_t * in_format,
120                                          gavl_video_format_t * out_format);
121 #endif
122 
123 /* Useful code for gluing gavl and gmerlin */
124 
125 #define BG_GAVL_PARAM_CONVERSION_QUALITY \
126   {                                      \
127   .name =        "conversion_quality",     \
128   .long_name =   TRS("Conversion Quality"),          \
129     .opt =         "q", \
130   .type =        BG_PARAMETER_SLIDER_INT,               \
131   .flags =       BG_PARAMETER_SYNC,                     \
132   .val_min =     { .val_i = GAVL_QUALITY_FASTEST },       \
133   .val_max =     { .val_i = GAVL_QUALITY_BEST    },       \
134   .val_default = { .val_i = GAVL_QUALITY_DEFAULT },                      \
135   .help_string = TRS("Set the conversion quality for format conversions. \
136 Lower quality means more speed. Values above 3 enable slow high quality calculations.") \
137    }
138 
139 #define BG_GAVL_PARAM_FRAMERATE_USER           \
140   {                                            \
141   .name =      "timescale",                    \
142   .long_name = TRS("Timescale"),               \
143   .type =      BG_PARAMETER_INT,               \
144   .val_min =     { .val_i = 1 },               \
145   .val_max =     { .val_i = 100000 },          \
146   .val_default = { .val_i = 25 },              \
147   .help_string = TRS("Timescale for user defined output framerate (Framerate = timescale / frame duration)."), \
148   },                                           \
149   {                                            \
150   .name =      "frame_duration",               \
151   .long_name = TRS("Frame duration"),          \
152   .type =      BG_PARAMETER_INT,               \
153   .val_min =     { .val_i = 1 },               \
154   .val_max =     { .val_i = 100000 },          \
155   .val_default = { .val_i = 1 },               \
156   .help_string = TRS("Frame duration for user defined output framerate (Framerate = timescale / frame duration)."), \
157   }
158 
159 #define BG_GAVL_PARAM_FRAMERATE_NAMES \
160                    "user_defined",    \
161                    "23_976",          \
162                    "24",              \
163                    "25",              \
164                    "29_970",          \
165                    "30",              \
166                    "50",              \
167                    "59_940",          \
168                    "60", (char*)0
169 
170 #define BG_GAVL_PARAM_FRAMERATE_LABELS                                   \
171                    TRS("User defined"),                                  \
172                    TRS("23.976 (NTSC encapsulated film rate)"),          \
173                    TRS("24 (Standard international cinema film rate)"),  \
174                    TRS("25 (PAL [625/50] video frame rate)"),            \
175                    TRS("29.970 (NTSC video frame rate)"),                \
176                    TRS("30 (NTSC drop-frame [525/60] video frame rate)"),\
177                    TRS("50 (Double frame rate / progressive PAL)"),      \
178                    TRS("59.940 (Double frame rate NTSC)"),               \
179                    TRS("60 (Double frame rate drop-frame NTSC)"),        \
180                     (char*)0
181 
182 
183 #define BG_GAVL_PARAM_FRAMERATE                        \
184   {                                                    \
185   .name =      "framerate",                            \
186   .long_name = TRS("Framerate"),                       \
187   .type =      BG_PARAMETER_STRINGLIST,                \
188   .flags =       BG_PARAMETER_SYNC,                    \
189   .val_default = { .val_str = "from_source" },         \
190   .multi_names = (char const *[]){ "from_source",      \
191   BG_GAVL_PARAM_FRAMERATE_NAMES                        \
192                   },                                   \
193   .multi_labels = (char const *[]){ TRS("From Source"),\
194   BG_GAVL_PARAM_FRAMERATE_LABELS                       \
195                    },                                  \
196   .help_string = TRS("Output framerate. For user defined framerate, enter the \
197 timescale and frame duration below (framerate = timescale / frame duration).")\
198   },                                                   \
199 BG_GAVL_PARAM_FRAMERATE_USER
200 
201 #define BG_GAVL_PARAM_FRAMERATE_NOSOURCE \
202   {                                      \
203   .name =      "framerate",              \
204   .long_name = TRS("Framerate"),         \
205   .type =      BG_PARAMETER_STRINGLIST,  \
206   .flags =       BG_PARAMETER_SYNC,      \
207   .val_default = { .val_str = "25" },    \
208   .multi_names = (char const *[]){       \
209   BG_GAVL_PARAM_FRAMERATE_NAMES          \
210                   },                     \
211   .multi_labels = (char const *[]){      \
212   BG_GAVL_PARAM_FRAMERATE_LABELS         \
213                    },                    \
214   .help_string = TRS("Output framerate. For user defined framerate, enter the \
215 timescale and frame duration below (framerate = timescale / frame duration).")\
216   },                                     \
217 BG_GAVL_PARAM_FRAMERATE_USER
218 
219 
220 
221 #define BG_GAVL_PARAM_DEINTERLACE           \
222  {                                          \
223   .name =      "deinterlace_mode",          \
224   .long_name = TRS("Deinterlace mode"),     \
225   .opt =       "dm",                        \
226   .type =      BG_PARAMETER_STRINGLIST,     \
227   .val_default = { .val_str = "none" },     \
228   .multi_names =  (char const *[]){ "none", "copy", "scale", (char*)0 },                \
229   .multi_labels = (char const *[]){ TRS("None"), TRS("Copy"), TRS("Scale"), (char*)0 }, \
230   .help_string = "Specify interlace mode. Higher modes are better but slower."          \
231   },                                        \
232   {                                         \
233   .name =      "deinterlace_drop_mode",     \
234   .opt =       "ddm",                       \
235   .long_name = "Drop mode",                 \
236   .type =      BG_PARAMETER_STRINGLIST,     \
237   .val_default = { .val_str = "top" },      \
238   .multi_names =   (char const *[]){ "top", "bottom", (char*)0 }, \
239   .multi_labels =  (char const *[]){ TRS("Drop top field"), TRS("Drop bottom field"), (char*)0 },   \
240   .help_string = TRS("Specifies which field the deinterlacer should drop.") \
241   },                                        \
242   {                                         \
243   .name =      "force_deinterlacing",       \
244   .long_name = TRS("Force deinterlacing"),  \
245   .opt =       "fd",                        \
246   .type =      BG_PARAMETER_CHECKBUTTON,    \
247   .val_default = { .val_i = 0 },            \
248   .help_string = TRS("Force deinterlacing if you want progressive output and the input format pretends to be progressive also.")                                     \
249   }
250 
251 #define BG_GAVL_PARAM_PIXELFORMAT                      \
252  {                                                     \
253   .name =      "pixelformat",                          \
254   .long_name = TRS("Pixelformat"),                     \
255   .opt =       "pf",                                   \
256   .type =      BG_PARAMETER_STRINGLIST,                \
257   .val_default = { .val_str = "YUV 444 Planar" },      \
258   .multi_names =  (char const *[]){                    \
259      "YUV 444 Planar",          "YUVA 4444 (8 bit)",   \
260      "YUV 444 Planar (16 bit)", "YUVA 4444 (16 bit)",  \
261      "YUV 444 (float)",         "YUVA 4444 (float)",   \
262      "32 bpp RGB",              "32 bpp RGBA",         \
263      "48 bpp RGB",              "64 bpp RGBA",         \
264      "Float RGB",               "Float RGBA",          \
265      (char*)0 },                                       \
266   .multi_labels = (char const *[]){                    \
267      TRS("Y'CbCr 8 bit"), TRS("Y'CbCrA 8 bit"),        \
268      TRS("Y'CbCr 16 bit"), TRS("Y'CbCrA 16 bit"),      \
269      TRS("Y'CbCr float"), TRS("Y'CbCrA float"),        \
270      TRS("RGB 8 bit"), TRS("RGBA 8 bit"),              \
271      TRS("RGB 16 bit"), TRS("RGBA 16 bit"),            \
272      TRS("RGB float"), TRS("RGBA float"),              \
273      (char*)0 },                                       \
274   .help_string = TRS("Specify the pixelformat"),       \
275   }
276 
277 #define BG_GAVL_SCALE_MODE_NAMES \
278    (char const *[]){ "auto",     \
279               "nearest",         \
280               "bilinear",        \
281               "quadratic",       \
282               "cubic_bspline",   \
283               "cubic_mitchell",  \
284               "cubic_catmull",   \
285               "sinc_lanczos",    \
286               (char*)0 }
287 
288 #define BG_GAVL_SCALE_MODE_LABELS   \
289   (char const *[]){ TRS("Auto"),    \
290              TRS("Nearest"),        \
291              TRS("Bilinear"),       \
292              TRS("Quadratic"),      \
293              TRS("Cubic B-Spline"), \
294              TRS("Cubic Mitchell-Netravali"), \
295              TRS("Cubic Catmull-Rom"), \
296              TRS("Sinc with Lanczos window"), \
297             (char*)0 }
298 
299 #define BG_GAVL_TRANSFORM_MODE_NAMES \
300    (char const *[]){ "auto",   \
301               "nearest",       \
302               "bilinear",      \
303               "quadratic",     \
304               "cubic_bspline", \
305               (char*)0 }
306 
307 #define BG_GAVL_TRANSFORM_MODE_LABELS \
308   (char const *[]){ TRS("Auto"),      \
309              TRS("Nearest"),          \
310              TRS("Bilinear"),         \
311              TRS("Quadratic"),        \
312              TRS("Cubic B-Spline"),   \
313             (char*)0 }
314 
315 #define BG_GAVL_DOWNSCALE_FILTER_NAMES \
316   (char const *[]){ "auto", \
317                     "none", \
318                     "wide", \
319                     "gauss", \
320                     (char*)0 }
321 
322 #define BG_GAVL_DOWNSCALE_FILTER_LABELS \
323   (char const *[]){ TRS("Auto"), \
324                     TRS("None"),            \
325                     TRS("Widening"), \
326                     TRS("Gaussian preblur"), \
327                     (char*)0 }
328 
329 #define BG_GAVL_PARAM_SCALE_MODE               \
330   {                                            \
331   .name =        "scale_mode",                 \
332   .long_name =   TRS("Scale mode"),            \
333   .opt =       "sm",                           \
334   .type =        BG_PARAMETER_STRINGLIST,      \
335   .flags =       BG_PARAMETER_SYNC,            \
336   .multi_names = BG_GAVL_SCALE_MODE_NAMES,     \
337   .multi_labels = BG_GAVL_SCALE_MODE_LABELS,   \
338   .val_default = { .val_str = "auto" },        \
339   .help_string = TRS("Choose scaling method. Auto means to choose based on the conversion quality. Nearest is fastest, Sinc with Lanczos window is slowest."),          \
340   },                                           \
341   {                                            \
342   .name =        "scale_order",                \
343   .long_name =   TRS("Scale order"),           \
344   .opt =       "so",                           \
345   .type =        BG_PARAMETER_INT,             \
346   .flags =       BG_PARAMETER_SYNC,            \
347   .val_min =     { .val_i = 4 },               \
348   .val_max =     { .val_i = 1000 },            \
349   .val_default = { .val_i = 4 },               \
350   .help_string = TRS("Order for sinc scaling"),\
351   }
352 
353 #define BG_GAVL_PARAM_RESAMPLE_CHROMA     \
354   {                                       \
355   .name =        "resample_chroma",       \
356   .long_name =   TRS("Resample chroma"),  \
357   .opt =       "sm",                      \
358   .type =        BG_PARAMETER_CHECKBUTTON,\
359   .flags =       BG_PARAMETER_SYNC,       \
360     .help_string = TRS("Always perform chroma resampling if chroma subsampling factors or chroma placements are different. Usually, this is only done for qualities above 3."), \
361   }
362 
363 #define BG_GAVL_PARAM_BACKGROUND \
364    \
365     { \
366       .name =        "background_color", \
367       .long_name =   TRS("Background color"), \
368       .type =      BG_PARAMETER_COLOR_RGB, \
369       .flags =       BG_PARAMETER_SYNC,                     \
370       .val_default = { .val_color = { 0.0, 0.0, 0.0 } }, \
371       .help_string = TRS("Background color to use, when alpha mode above is \"Blend background color\"."), \
372     }
373 
374 #define BG_GAVL_PARAM_ALPHA                \
375     { \
376       .name =        "alpha_mode", \
377       .long_name =   TRS("Alpha mode"), \
378       .type =        BG_PARAMETER_STRINGLIST, \
379       .flags =       BG_PARAMETER_SYNC,                     \
380       .val_default = { .val_str = "ignore" }, \
381       .multi_names = (char const *[]){"ignore", "blend_color", (char*)0}, \
382       .multi_labels = (char const *[]){TRS("Ignore"), TRS("Blend background color"), (char*)0}, \
383     .help_string = TRS("This option is used if the source has an alpha (=transparency) channel, but the output supports no transparency. Either, the transparency is ignored, or the background color you specify below is blended in."),\
384        }, \
385   BG_GAVL_PARAM_BACKGROUND
386 
387 #define BG_GAVL_PARAM_FRAMESIZE_USER           \
388     { \
389       .name =      "user_image_width", \
390       .long_name = TRS("User defined width"), \
391       .opt =       "w", \
392       .type =      BG_PARAMETER_INT,    \
393       .flags =     BG_PARAMETER_SYNC, \
394       .val_min =     { .val_i = 1 }, \
395       .val_max =     { .val_i = 100000 }, \
396       .val_default = { .val_i = 640 }, \
397       .help_string = TRS("User defined width in pixels. Only meaningful if you selected \"User defined\" for the image size."), \
398     }, \
399     {                                         \
400       .name =      "user_image_height", \
401       .long_name = TRS("User defined height"), \
402       .opt =       "h",  \
403       .type =      BG_PARAMETER_INT, \
404       .flags =     BG_PARAMETER_SYNC, \
405       .val_min =     { .val_i = 1 }, \
406       .val_max =     { .val_i = 100000 }, \
407       .val_default = { .val_i = 480 }, \
408       .help_string = TRS("User defined height in pixels. Only meaningful if you selected \"User defined\" for the image size."), \
409       }, \
410     { \
411       .name =      "user_pixel_width", \
412       .long_name = TRS("User defined pixel width"), \
413       .opt =       "sw", \
414       .type =      BG_PARAMETER_INT,    \
415       .flags =     BG_PARAMETER_SYNC, \
416       .val_min =     { .val_i = 1 }, \
417       .val_max =     { .val_i = 100000 },\
418       .val_default = { .val_i = 1 },\
419       .help_string = TRS("User defined pixel width. Only meaningful if you selected \"User defined\" for the image size."),\
420     },\
421     {                                       \
422       .name =      "user_pixel_height",\
423       .long_name = TRS("User defined pixel height"),\
424       .opt =       "sh",\
425       .type =      BG_PARAMETER_INT,\
426       .flags =     BG_PARAMETER_SYNC,\
427       .val_min =     { .val_i = 1 },\
428       .val_max =     { .val_i = 100000 },\
429       .val_default = { .val_i = 1 },\
430       .help_string = TRS("User defined pixel height. Only meaningful if you selected \"User defined\" for the image size."),\
431     }
432 
433 
434 #define BG_GAVL_PARAM_FRAMESIZE_NAMES           \
435         "user_defined", \
436         "pal_d1", \
437         "pal_d1_wide", \
438         "pal_dv", \
439         "pal_dv_wide", \
440         "pal_cvd", \
441         "pal_vcd", \
442         "pal_svcd", \
443         "pal_svcd_wide", \
444         "ntsc_d1", \
445         "ntsc_d1_wide", \
446         "ntsc_dv", \
447         "ntsc_dv_wide", \
448         "ntsc_cvd", \
449         "ntsc_vcd", \
450         "ntsc_svcd", \
451         "ntsc_svcd_wide", \
452         "720", \
453         "1080", \
454         "vga", \
455         "qvga", \
456         "sqcif", \
457         "qcif", \
458         "cif", \
459         "4cif", \
460         "16cif", \
461         (char*)0
462 
463 #define BG_GAVL_PARAM_FRAMESIZE_LABELS           \
464         TRS("User defined"), \
465         TRS("PAL DVD D1 4:3 (720 x 576)"), \
466         TRS("PAL DVD D1 16:9 (720 x 576)"), \
467         TRS("PAL DV 4:3 (720 x 576)"), \
468         TRS("PAL DV 16:9 (720 x 576)"), \
469         TRS("PAL CVD (352 x 576)"), \
470         TRS("PAL VCD (352 x 288)"), \
471         TRS("PAL SVCD 4:3 (480 x 576)"), \
472         TRS("PAL SVCD 16:9 (480 x 576)"), \
473         TRS("NTSC DVD D1 4:3 (720 x 480)"), \
474         TRS("NTSC DVD D1 16:9 (720 x 480)"), \
475         TRS("NTSC DV 4:3 (720 x 480)"), \
476         TRS("NTSC DV 16:9 (720 x 480)"), \
477         TRS("NTSC CVD (352 x 480)"), \
478         TRS("NTSC VCD (352 x 240)"), \
479         TRS("NTSC SVCD 4:3 (480 x 480)"), \
480         TRS("NTSC SVCD 16:9 (480 x 480)"), \
481         TRS("HD 720p/i (1280x720)"), \
482         TRS("HD 1080p/i (1920x1080)"), \
483         TRS("VGA (640 x 480)"), \
484         TRS("QVGA (320 x 240)"), \
485         TRS("SQCIF (128 × 96)"), \
486         TRS("QCIF (176 × 144)"), \
487         TRS("CIF (352 × 288)"), \
488         TRS("4CIF (704 × 576)"), \
489         TRS("16CIF (1408 × 1152)"), \
490         (char*)0
491 
492 #define BG_GAVL_PARAM_FRAMESIZE_NOSOURCE       \
493     { \
494       .name =        "frame_size", \
495       .long_name =   TRS("Image size"), \
496       .type =        BG_PARAMETER_STRINGLIST, \
497       .flags =     BG_PARAMETER_SYNC, \
498       .multi_names = (char const *[]){ \
499       BG_GAVL_PARAM_FRAMESIZE_NAMES \
500         }, \
501       .multi_labels =  (char const *[]){  \
502       BG_GAVL_PARAM_FRAMESIZE_LABELS \
503         }, \
504       .val_default = { .val_str = "pal_d1" }, \
505       .help_string = TRS("Set the output image size. For a user defined size, you must specify the width and height as well as the pixel width and pixel height."), \
506     }, \
507 BG_GAVL_PARAM_FRAMESIZE_USER
508 
509 #define BG_GAVL_PARAM_FRAMESIZE       \
510     { \
511       .name =        "frame_size", \
512       .long_name =   TRS("Image size"), \
513       .type =        BG_PARAMETER_STRINGLIST, \
514       .flags =     BG_PARAMETER_SYNC, \
515       .multi_names = (char const *[]){ \
516       "from_source", \
517       BG_GAVL_PARAM_FRAMESIZE_NAMES \
518         }, \
519       .multi_labels =  (char const *[]){  \
520       TRS("From source"), \
521       BG_GAVL_PARAM_FRAMESIZE_LABELS \
522         }, \
523       .val_default = { .val_str = "from_source" }, \
524       .help_string = TRS("Set the output image size. For a user defined size, you must specify the width and height as well as the pixel width and pixel height."), \
525     }, \
526 BG_GAVL_PARAM_FRAMESIZE_USER
527 
528 #define BG_GAVL_PARAM_SAMPLERATE_NOSOURCE \
529     {\
530       .name =        "samplerate",\
531       .long_name =   TRS("Samplerate"),\
532       .type =        BG_PARAMETER_INT,\
533       .flags =       BG_PARAMETER_SYNC,                     \
534       .val_min =     { .val_i = 8000 },\
535       .val_max =     { .val_i = 192000 },\
536       .val_default = { .val_i = 44100 },\
537       .help_string = TRS("Samplerate"),\
538     }
539 
540 
541 #define BG_GAVL_PARAM_SAMPLERATE                \
542     {\
543       .name =      "fixed_samplerate",\
544       .long_name = TRS("Fixed samplerate"),\
545       .type =      BG_PARAMETER_CHECKBUTTON,\
546       .flags =       BG_PARAMETER_SYNC,                     \
547       .val_default = { .val_i = 0 },\
548       .help_string = TRS("If disabled, the output samplerate is taken from the source. If enabled, the samplerate you specify below us used.")\
549     },\
550 BG_GAVL_PARAM_SAMPLERATE_NOSOURCE
551 
552 #define BG_GAVL_PARAM_CHANNEL_SETUP_NOSOURCE \
553     {                                         \
554     .name =        "num_front_channels",          \
555     .long_name =   TRS("Front channels"),              \
556     .type =        BG_PARAMETER_INT,              \
557     .flags =       BG_PARAMETER_SYNC,                     \
558     .val_min =     { .val_i = 1 },                  \
559     .val_max =     { .val_i = 5 },                  \
560     .val_default = { .val_i = 2 },                  \
561     },\
562     {                                         \
563     .name =        "num_rear_channels",          \
564     .long_name =   TRS("Rear channels"),              \
565     .type =        BG_PARAMETER_INT,              \
566     .flags =       BG_PARAMETER_SYNC,                     \
567     .val_min =     { .val_i = 0 },                  \
568     .val_max =     { .val_i = 3 },                  \
569     .val_default = { .val_i = 0 },                  \
570     },                                        \
571     {                                         \
572     .name =        "num_lfe_channels",          \
573     .long_name =   TRS("LFE"),                        \
574     .type =        BG_PARAMETER_CHECKBUTTON,     \
575     .flags =       BG_PARAMETER_SYNC,                     \
576     .val_default = { .val_i = 0 },                  \
577     },                                        \
578     {                                 \
579       .name =        "front_to_rear", \
580       .long_name =   TRS("Front to rear mode"), \
581       .type =        BG_PARAMETER_STRINGLIST, \
582       .flags =       BG_PARAMETER_SYNC,                     \
583       .val_default = { .val_str = "copy" }, \
584       .multi_names =  (char const *[]){ "mute", \
585                               "copy", \
586                               "diff", \
587                               (char*)0 }, \
588       .multi_labels =  (char const *[]){ TRS("Mute"), \
589                               TRS("Copy"), \
590                               TRS("Diff"), \
591                               (char*)0 }, \
592       .help_string = TRS("Mix mode when the output format has rear channels, \
593 but the source doesn't."), \
594     }, \
595     { \
596       .name =        "stereo_to_mono", \
597       .long_name =   TRS("Stereo to mono mode"), \
598       .type =        BG_PARAMETER_STRINGLIST, \
599       .flags =       BG_PARAMETER_SYNC,                     \
600       .val_default = { .val_str = "mix" }, \
601       .multi_names =  (char const *[]){ "left", \
602                               "right", \
603                               "mix", \
604                               (char*)0 }, \
605       .multi_labels =  (char const *[]){ TRS("Choose left"), \
606                               TRS("Choose right"), \
607                               TRS("Mix"), \
608                               (char*)0 }, \
609       .help_string = TRS("Mix mode when downmixing Stereo to Mono."), \
610     }
611 
612 
613 #define BG_GAVL_PARAM_CHANNEL_SETUP \
614     { \
615       .name =      "fixed_channel_setup", \
616       .long_name = TRS("Fixed channel setup"), \
617       .type =      BG_PARAMETER_CHECKBUTTON,\
618       .flags =       BG_PARAMETER_SYNC,                     \
619       .val_default = { .val_i = 0 },\
620       .help_string = TRS("If disabled, the output channel configuration is taken from the source. If enabled, the setup you specify below us used.") \
621     }, \
622 BG_GAVL_PARAM_CHANNEL_SETUP_NOSOURCE
623 
624 
625 #define BG_GAVL_PARAM_FORCE_SAMPLEFORMAT \
626     { \
627       .name =      "sampleformat", \
628       .long_name = TRS("Force sampleformat"), \
629       .type =      BG_PARAMETER_STRINGLIST,\
630       .flags =       BG_PARAMETER_SYNC, \
631       .val_default = { .val_str = "none" },\
632       .multi_names  = (char const *[]){ "none", "8", "16", "32", "f", "d", (char*)0 },\
633       .multi_labels = (char const *[]){ TRS("None"), TRS("8 bit"), TRS("16 bit"), TRS("32 bit"), TRS("Float"), TRS("Double"), (char*)0 }, \
634       .help_string = TRS("Force a sampleformat to be used for processing. None means to take the input format.") \
635     }
636 
637 #define BG_GAVL_PARAM_SAMPLEFORMAT \
638     { \
639       .name =      "sampleformat", \
640       .long_name = TRS("Sampleformat"), \
641       .type =      BG_PARAMETER_STRINGLIST,\
642       .flags =       BG_PARAMETER_SYNC, \
643       .val_default = { .val_str = "f" },\
644       .multi_names  = (char const *[]){ "16", "32", "f", "d", (char*)0 },\
645       .multi_labels = (char const *[]){ TRS("16 bit"), TRS("32 bit"), TRS("Float"), TRS("Double"), (char*)0 }, \
646       .help_string = TRS("Sampleformat to be used for processing.") \
647     }
648 
649 #define BG_GAVL_PARAM_AUDIO_DITHER_MODE \
650     { \
651       .name =      "dither_mode", \
652       .long_name = TRS("Dither mode"), \
653       .type =      BG_PARAMETER_STRINGLIST,\
654       .flags =       BG_PARAMETER_SYNC,                     \
655       .val_default = { .val_str = "auto" },\
656       .multi_names =  (char const *[]){ "auto", "none", "rect",        "tri",        "shaped", (char*)0 },\
657       .multi_labels = (char const *[]){ TRS("Auto"), TRS("None"), TRS("Rectangular"), \
658                                TRS("Triangular"), TRS("Shaped"), (char*)0 },\
659       .help_string = TRS("Dither mode. Auto means to use the quality level. Subsequent options are ordered by increasing quality (i.e. decreasing speed).") \
660     }
661 
662 #define BG_GAVL_PARAM_RESAMPLE_MODE \
663     { \
664       .name =      "resample_mode", \
665       .long_name = TRS("Resample mode"), \
666       .type =      BG_PARAMETER_STRINGLIST,\
667       .flags =       BG_PARAMETER_SYNC,                     \
668       .val_default = { .val_str = "auto" },\
669       .multi_names =  (char const *[]){ "auto", "zoh", "linear", "sinc_fast",  "sinc_medium", "sinc_best", (char*)0 },\
670       .multi_labels = (char const *[]){ TRS("Auto"), TRS("Zero order hold"), TRS("Linear"), \
671                                TRS("Sinc fast"),  TRS("Sinc medium"), TRS("Sinc best"), (char*)0 },\
672       .help_string = TRS("Resample mode. Auto means to use the quality level. Subsequent options are ordered by increasing quality (i.e. decreasing speed).") \
673     }
674 
675 #define BG_GAVL_PARAM_THREADS         \
676     {                                 \
677       .name = "threads",              \
678       .long_name = TRS("Number of threads"), \
679       .type =      BG_PARAMETER_INT,\
680       .val_default = { .val_i = 1 },\
681       .val_min     = { .val_i = 1 },\
682       .val_max     = { .val_i = 1024 },\
683       .help_string = TRS("Threads to launch for processing operations. Changing this requires program restart"), \
684     }
685 
686 /* Subtitle display decisions */
687 int bg_overlay_too_old(gavl_time_t time, gavl_time_t ovl_time,
688                        gavl_time_t ovl_duration);
689 
690 int bg_overlay_too_new(gavl_time_t time, gavl_time_t ovl_time);
691 
692 /* Thread pool */
693 
694 bg_thread_pool_t * bg_thread_pool_create(int num_threads);
695 void bg_thread_pool_destroy(bg_thread_pool_t *);
696 
697 void bg_thread_pool_run(void (*func)(void*,int start, int len),
698                         void * gavl_data,
699                         int start, int len,
700                         void * client_data, int thread);
701 
702 void bg_thread_pool_stop(void * client_data, int thread);
703 
704 #endif // __BG_GAVL_H_
705