f6841bdaf29a02c2c48f6144488c92abd8e6500a
[goodguy/history.git] / cinelerra-5.1 / bsd.patch
1 diff --git a/cinelerra-5.1/Makefile.devel b/cinelerra-5.1/Makefile.devel
2 index a12d8f2b..f892f648 100644
3 --- a/cinelerra-5.1/Makefile.devel
4 +++ b/cinelerra-5.1/Makefile.devel
5 @@ -4,7 +4,7 @@ TOPDIR := $(CURDIR)
6  CFLAGS ?= -ggdb
7  export CFLAGS_ := $(CFLAGS)
8  
9 -cpus:=$(shell grep -c "^proc" /proc/cpuinfo)
10 +cpus:=$(shell sysctl -n hw.ncpu)
11  jobs:=-j$(shell echo $$(($(cpus) + $(cpus)/2 +2)))
12  MAKEJ := $(MAKE) $(jobs)
13  
14 diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
15 index 18590e3a..a60c71d1 100644
16 --- a/cinelerra-5.1/cinelerra/Makefile
17 +++ b/cinelerra-5.1/cinelerra/Makefile
18 @@ -395,6 +395,7 @@ LIBS += -lfontconfig -lfreetype
19  LIBS += -lavcodec -lavdevice -lavfilter -lavformat -lavresample -lavutil
20  LIBS += -lswresample -lswscale
21  LIBS += -lvpx -lwebp -lwebpmux
22 +LIBS += -lintl -liconv -lexecinfo
23  
24  LIBS += $(if $(filter fftw,$(static_pkgs)), -lfftw3)
25  LIBS += $(if $(filter flac,$(static_pkgs)), -lFLAC)
26 @@ -476,6 +477,7 @@ LV2OBJS = \
27  endif
28  
29  CFLAGS := \
30 +       -I/usr/local/include \
31         -I$(GUICAST) \
32         -I$(LIBZMPEG3) \
33         $(static_incs) \
34 @@ -523,15 +525,15 @@ all:      $(OUTPUT) $(CUTADS) $(BDWRITE) $(LV2UI)
35  $(OUTPUT): $(OBJS) $(THEME_DATA) $(DCRAW) $(LIBRARIES)
36         $(LINKER) `cat $(OBJDIR)/objs`
37         $(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(OUTPUT) $(OUTPUT_G))
38 -       $(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
39 +       #$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
40         ln -f -s ../bin/$(WANT_CIN) ci
41  
42  ifneq ($(WANT_COMMERCIAL),no)
43  $(CUTADS):     $(CUTOBJS) $(CUTLIBS) $(LIBRARIES)
44 -       @echo g++ -o $@ $(CUTOBJS)
45 -       @g++ $(CFLAGS) -pthread -o $@ $(CUTOBJS) $(CUTLIBS) $(LIBS)
46 +       @echo $(CXX) -o $@ $(CUTOBJS)
47 +       @$(CXX) $(CFLAGS) -pthread -o $@ $(CUTOBJS) $(CUTLIBS) $(LIBS)
48         $(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(CUTADS) $(CUTADS).debuginfo)
49 -       $(if $(findstring -ggdb,$(CFLAGS)),,strip $(CUTADS))
50 +       #$(if $(findstring -ggdb,$(CFLAGS)),,strip $(CUTADS))
51  
52  install-cutads:
53         cp -av $(OBJDIR)/cutads $(BINDIR)/.
54 @@ -540,18 +542,18 @@ install:  install-cutads
55  endif
56  
57  $(BDWRITE):    $(BDWOBJS) $(LIBRARIES)
58 -       @echo g++ -o $@ $(BDWOBJS)
59 -       @g++ $(CFLAGS) -pthread -o $@ $(BDWOBJS) $(LIBS)
60 +       @echo $(CXX) -o $@ $(BDWOBJS)
61 +       @$(CXX) $(CFLAGS) -pthread -o $@ $(BDWOBJS) $(LIBS)
62         $(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(BDWRITE) $(BDWRITE).debuginfo)
63 -       $(if $(findstring -ggdb,$(CFLAGS)),,strip $(BDWRITE))
64 +       #$(if $(findstring -ggdb,$(CFLAGS)),,strip $(BDWRITE))
65  
66  install-bdwrite:
67         cp -av $(OBJDIR)/bdwrite $(BINDIR)/.
68  install:       install-bdwrite
69  
70  ydiff: ydiff.C $(LIBRARIES)
71 -       @echo g++ -o $@ ydiff.C
72 -       @g++ $(CFLAGS) ydiff.C -o $@ $(LIBS)
73 +       @echo $(CXX) -o $@ ydiff.C
74 +       @$(CXX) $(CFLAGS) ydiff.C -o $@ $(LIBS)
75  
76  clean:
77         rm -rf $(OBJDIR)
78 @@ -585,7 +587,7 @@ $(OBJDIR)/lv2ui: $(LV2OBJS)
79         @echo $(CXX) \`cat $(OBJDIR)/c_flags\` $^ -o $@
80         @$(CXX) `cat $(OBJDIR)/c_flags` $^ -o $@ $(LIBS) $(GTK2_LIBS)
81         $(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(LV2UI) $(LV2UI).debuginfo)
82 -       $(if $(findstring -ggdb,$(CFLAGS)),,strip $(LV2UI))
83 +       #$(if $(findstring -ggdb,$(CFLAGS)),,strip $(LV2UI))
84  
85  .PHONY:        lv2ui
86  lv2ui: $(LV2UI)
87 diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C
88 index 27f728ad..9215090d 100644
89 --- a/cinelerra-5.1/cinelerra/bdcreate.C
90 +++ b/cinelerra-5.1/cinelerra/bdcreate.C
91 @@ -25,8 +25,8 @@
92  #include <unistd.h>
93  #include <fcntl.h>
94  #include <errno.h>
95 -#include <sys/stat.h>
96 -#include <sys/statfs.h>
97 +#include <sys/param.h>
98 +#include <sys/mount.h>
99  
100  // BD Creation
101  
102 diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
103 index 6a2b4ca3..78cf9bef 100644
104 --- a/cinelerra-5.1/cinelerra/bdwrite.C
105 +++ b/cinelerra-5.1/cinelerra/bdwrite.C
106 @@ -38,7 +38,7 @@
107  #include <stdint.h>
108  #include <stdlib.h>
109  #include <string.h>
110 -#include <endian.h>
111 +#include <sys/endian.h>
112  #include <limits.h>
113  #include <sys/stat.h>
114  // work arounds (centos)
115 diff --git a/cinelerra-5.1/cinelerra/cutads.C b/cinelerra-5.1/cinelerra/cutads.C
116 index ac58d56a..f6690cf2 100644
117 --- a/cinelerra-5.1/cinelerra/cutads.C
118 +++ b/cinelerra-5.1/cinelerra/cutads.C
119 @@ -23,14 +23,6 @@
120  using namespace std;
121  #define fail(s) do { printf("fail %s%s:%d\n",__func__,#s,__LINE__); return 1; } while(0)
122  
123 -/* missing from system headers, no /usr/include <linux/ioprio.h>
124 - *   IOPRIO_WHO_PROCESS, IOPRIO_CLASS_SHIFT, IOPRIO_CLASS_IDLE */
125 -enum { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE, };
126 -#define IO_CLASS(n) (((int)(n)) << 13)
127 -#define IO_WHO_PROCESS  1
128 -#include <sys/syscall.h>
129 -#include <asm/unistd.h>
130 -
131  // commercial edge detection:
132  // must have audio < min_audio
133  //   and within +- check_margin seconds of low audio
134 @@ -55,11 +47,6 @@ class Video;
135  class Audio;
136  class Scan;
137  
138 -static int ioprio_set(int which, int who, int ioprio)
139 -{
140 -       return syscall(SYS_ioprio_set, which, who, ioprio);
141 -}
142 -
143  static inline int clip(int v, int mn, int mx)
144  {
145    return v<mn ? mn : v>mx ? mx : v;
146 @@ -617,7 +604,6 @@ class Scan
147         const char *asset_path;
148         static void set_priority(int pr, int io) {
149                 setpriority(PRIO_PROCESS, 0, pr);  // lowest cpu priority
150 -               ioprio_set(IO_WHO_PROCESS, 0, IO_CLASS(io));
151         }
152         class low_priority { public:
153                 low_priority() { set_priority(19, IOPRIO_CLASS_IDLE); }
154 diff --git a/cinelerra-5.1/cinelerra/dvdcreate.C b/cinelerra-5.1/cinelerra/dvdcreate.C
155 index 1014baf5..f38094e9 100644
156 --- a/cinelerra-5.1/cinelerra/dvdcreate.C
157 +++ b/cinelerra-5.1/cinelerra/dvdcreate.C
158 @@ -24,8 +24,8 @@
159  #include <unistd.h>
160  #include <fcntl.h>
161  #include <errno.h>
162 -#include <sys/stat.h>
163 -#include <sys/statfs.h>
164 +#include <sys/param.h>
165 +#include <sys/mount.h>
166  
167  
168  #define DVD_PAL_4x3    0
169 diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C
170 index 03348e0a..552a140d 100644
171 --- a/cinelerra-5.1/cinelerra/file.C
172 +++ b/cinelerra-5.1/cinelerra/file.C
173 @@ -1584,7 +1584,10 @@ int File::record_fd()
174  void File::get_exe_path(char *result, char *bnp)
175  {
176  // Get executable path, basename
177 -       int len = readlink("/proc/self/exe", result, BCTEXTLEN-1);
178 +       char exe_path[BCTEXTLEN];
179 +       sprintf(exe_path,"/proc/%d/file",getpid());
180 +       int len = readlink(exe_path, result, BCTEXTLEN-1);
181 +
182         if( len >= 0 ) {
183                 result[len] = 0;
184                 char *ptr = strrchr(result, '/');
185 diff --git a/cinelerra-5.1/cinelerra/indexfile.C b/cinelerra-5.1/cinelerra/indexfile.C
186 index 3d21d2af..f3064199 100644
187 --- a/cinelerra-5.1/cinelerra/indexfile.C
188 +++ b/cinelerra-5.1/cinelerra/indexfile.C
189 @@ -70,7 +70,7 @@
190  
191  #include <sys/types.h>
192  #include <sys/stat.h>
193 -#include <linux/iso_fs.h>
194 +#include <isofs/cd9660/iso.h>
195  
196  // check for isofs volume_id for dvd/cdrom
197  
198 diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
199 index 6fba32bb..ccdb683b 100644
200 --- a/cinelerra-5.1/configure.ac
201 +++ b/cinelerra-5.1/configure.ac
202 @@ -16,15 +16,26 @@ CFG_CFLAGS+=" -Wno-unused-result"
203  CFG_CFLAGS+=" -Wno-stringop-overflow"
204  CFG_CFLAGS+=" -Wno-format-truncation"
205  CFG_CFLAGS+=" -Wno-format-overflow"
206 +CFG_CFLAGS+=" -Wno-unknown-warning-option"
207  CFG_CFLAGS+=" -Wno-parentheses"
208  CFG_CFLAGS+=" -Wno-stringop-truncation"
209 +CFG_CFLAGS+=" -Wno-gnu-designator"
210 +CFG_CFLAGS+=" -Wno-missing-braces"
211 +CFG_CFLAGS+=" -Wno-overloaded-virtual"
212 +CFG_CFLAGS+=" -Wno-self-assign-field"
213 +CFG_CFLAGS+=" -Wno-sometimes-uninitialized"
214 +CFG_CFLAGS+=" -Wno-tautological-pointer-compare"
215 +CFG_CFLAGS+=" -Wno-unused-function"
216 +CFG_CFLAGS+=" -Wno-unused-private-field"
217 +CFG_CFLAGS+=" -Wno-infinite-recursion"
218  CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS"
219  CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS"
220  CFG_CFLAGS+=" -DPNG_SKIP_SETJMP_CHECK=1"
221  CFG_CFLAGS+=" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
222 -CFG_CFLAGS+=" -I/usr/include/freetype2"
223 -CFG_CFLAGS+=" -I/usr/include/uuid"
224 -CFG_CFLAGS+=" -I/usr/include/mjpegtools"
225 +CFG_CFLAGS+=" -I/usr/local/include"
226 +CFG_CFLAGS+=" -I/usr/local/include/freetype2 -I/usr/include/freetype2"
227 +CFG_CFLAGS+=" -I/usr/local/include/uuid -I/usr/include/uuid"
228 +CFG_CFLAGS+=" -I/usr/local/include/mjpegtools -I/usr/include/mjpegtools"
229  
230  AC_DEFUN([CHECK_WITH], [
231  AC_ARG_WITH([$1],
232 @@ -126,7 +137,7 @@ AC_SUBST(MAK_INSTALLS)
233  AC_SUBST(MAK_UNINSTALLS)
234  
235  if test "x$WANT_JOBS" = "xauto"; then
236 -  CPUS=`grep -c "^proc" /proc/cpuinfo`
237 +  CPUS=`sysctl -n hw.ncpu`
238    WANT_JOBS=`expr $CPUS + $CPUS / 2 + 2`
239  fi
240  
241 diff --git a/cinelerra-5.1/db/tdb.h b/cinelerra-5.1/db/tdb.h
242 index 8ee88002..9a17091e 100644
243 --- a/cinelerra-5.1/db/tdb.h
244 +++ b/cinelerra-5.1/db/tdb.h
245 @@ -32,7 +32,7 @@ inline void operator delete[](void *t,size_t n) { free(t); }
246  #endif
247  
248  #define ZMEDIA
249 -#define ZFUTEX
250 +//#define ZFUTEX
251  #ifdef ZFUTEX
252  #include <unistd.h>
253  #include <endian.h>
254 diff --git a/cinelerra-5.1/guicast/bclistbox.h b/cinelerra-5.1/guicast/bclistbox.h
255 index f5994d53..c73169bb 100644
256 --- a/cinelerra-5.1/guicast/bclistbox.h
257 +++ b/cinelerra-5.1/guicast/bclistbox.h
258 @@ -185,7 +185,9 @@ public:
259  
260  // take_focus - used by the suggestion box to keep it from taking focus from the
261  // textbox
262 -       int activate(int take_focus = 1);
263 +       int activate() {  return activate(1); }
264 +       int activate(int take_focus);
265 +
266         int activate(int x, int y, int w=-1, int h=-1);
267         int deactivate();
268         int is_active();
269 diff --git a/cinelerra-5.1/guicast/bcpan.h b/cinelerra-5.1/guicast/bcpan.h
270 index 40f5971f..73d47586 100644
271 --- a/cinelerra-5.1/guicast/bcpan.h
272 +++ b/cinelerra-5.1/guicast/bcpan.h
273 @@ -93,7 +93,8 @@ public:
274                 int &stick_x,
275                 int &stick_y);
276         static int rdtoxy(int &x, int &y, int a, int virtual_r);
277 -       int activate(int popup_x = -1, int popup_y = -1);
278 +       int activate(int popup_x, int popup_y);
279 +       int activate() { return activate(-1,-1); }
280         int deactivate();
281         float* get_values();
282  
283 diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C
284 index e3400600..b32d0a6f 100644
285 --- a/cinelerra-5.1/guicast/bcresources.C
286 +++ b/cinelerra-5.1/guicast/bcresources.C
287 @@ -38,6 +38,7 @@
288  #include <iconv.h>
289  #include <sys/ipc.h>
290  #include <sys/shm.h>
291 +#include <sys/sysctl.h>
292  #include <X11/extensions/XShm.h>
293  #include <fontconfig/fontconfig.h>
294  #include <fontconfig/fcfreetype.h>
295 @@ -297,23 +298,12 @@ int BC_Resources::machine_cpus = 1;
296  
297  int BC_Resources::get_machine_cpus()
298  {
299 -       int cpus = 1;
300 -       FILE *proc = fopen("/proc/cpuinfo", "r");
301 -       if( proc ) {
302 -               char string[BCTEXTLEN], *cp;
303 -               while(!feof(proc) && fgets(string, sizeof(string), proc) ) {
304 -                       if( !strncasecmp(string, "processor", 9) &&
305 -                           (cp = strchr(string, ':')) != 0 ) {
306 -                               int n = atol(cp+1) + 1;
307 -                               if( n > cpus ) cpus = n;
308 -                       }
309 -                       else if( !strncasecmp(string, "cpus detected", 13) &&
310 -                           (cp = strchr(string, ':')) != 0 )
311 -                               cpus = atol(cp+1);
312 -               }
313 -               fclose(proc);
314 -       }
315 -       return cpus;
316 +       int mib[2], ncpu;
317 +       size_t len = sizeof(ncpu);
318 +       mib[0] = CTL_HW;
319 +       mib[1] = HW_NCPU;
320 +       if( sysctl(mib, 2, &ncpu, &len, 0, 0) ) ncpu = 1;
321 +       return ncpu;
322  }
323  
324  void BC_Resources::new_vframes(int n, VFrame *vframes[], ...)
325 @@ -695,7 +685,7 @@ new_vframes(20,default_medium_7segment,
326         generic_button_margin = 15;
327         draw_clock_background=1;
328  
329 -       use_shm = -1;
330 +       use_shm = 0;
331         shm_reply = 1;
332  
333  // Initialize
334 @@ -1681,6 +1671,87 @@ BC_FontEntry *BC_Resources::find_fontentry(const char *displayname, int style,
335         return style_match;
336  }
337  
338 +
339 +class utf8conv {
340 +       uint8_t *obfr, *out, *oend;
341 +       uint8_t *ibfr, *inp, *iend;
342 +public:
343 +       utf8conv(void *out, int olen, void *inp, int ilen) {
344 +               this->obfr = this->out = (uint8_t*)out;
345 +               this->oend = this->out + olen;
346 +               this->ibfr = this->inp = (uint8_t*)inp;
347 +               this->iend = this->inp + ilen;
348 +       }
349 +       int cur() { return inp>=iend ? -1 : *inp; }
350 +       int next() { return inp>=iend ? -1 : *inp++; }
351 +       int next(int ch) { return out>=oend ? -1 : *out++ = ch; }
352 +       int ilen() { return inp-ibfr; }
353 +       int olen() { return out-obfr; }
354 +       int wnext();
355 +       int wnext(unsigned int v);
356 +};
357 +
358 +int utf8conv::
359 +wnext(unsigned int v)
360 +{
361 +  if( v < 0x00000080 ) { next(v);  return 1; }
362 +  int n = v < 0x00000800 ? 2 : v < 0x00010000 ? 3 :
363 +          v < 0x00200000 ? 4 : v < 0x04000000 ? 5 : 6;
364 +  int m = (0xff00 >> n), i = n-1;
365 +  next((v>>(6*i)) | m);
366 +  while( --i >= 0 ) next(((v>>(6*i)) & 0x3f) | 0x80);
367 +  return n;
368 +}
369 +
370 +int utf8conv::
371 +wnext()
372 +{
373 +  int v = 0, n = 0, ch = next();
374 +  if( ch == '\\' ) {
375 +    switch( (ch=next()) ) {
376 +    case 'n': return '\n';
377 +    case 't': return '\t';
378 +    case 'r': return '\r';
379 +    case 'b': return '\b';
380 +    case 'f': return '\f';
381 +    case 'v': return '\v';
382 +    case 'a': return '\a';
383 +    case '0': case '1': case '2': case '3':
384 +    case '4': case '5': case '6': case '7':
385 +      v = ch - '0';
386 +      for( int i=3; --i>0; v=v*8+ch, next() )
387 +        if( (ch=cur()-'0') < 0 || ch >= 8 ) break;
388 +      return v;
389 +    case 'x':  n = 2;  break;
390 +    case 'u':  n = 4;  break;
391 +    case 'U':  n = 8;  break;
392 +    default: return ch;
393 +    }
394 +    for( int i=n; --i>=0; v=v*16+ch, next() ) {
395 +      if( (ch=cur()-'0')>=0 && ch<10 ) continue;
396 +      if( (ch-='A'-'0'-10)>=10 && ch<16 ) continue;
397 +      if( (ch-='a'-'A')<10 || ch>=16 ) break;
398 +    }
399 +  }
400 +  else if( ch >= 0x80 ) {
401 +    static const unsigned char byts[] = {
402 +      1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5,
403 +    };
404 +    int i = ch - 0xc0;
405 +    n = i<0 ? 0 : byts[i/4];
406 +    for( v=ch, i=n; --i>=0; v+=next() ) v <<= 6;
407 +    static const unsigned int ofs[6] = {
408 +      0x00000000U, 0x00003080U, 0x000E2080U,
409 +      0x03C82080U, 0xFA082080U, 0x82082080U
410 +    };
411 +    v -= ofs[n];
412 +  }
413 +  else
414 +    v = ch;
415 +  return v;
416 +}
417 +
418 +
419  size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
420         char *input, int input_length, char *output, int output_length)
421  {
422 @@ -1688,10 +1759,12 @@ size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
423         iconv_t cd;
424         char *outbase = output;
425  
426 -       if(!from_enc || *from_enc == 0)
427 +       if( !from_enc || *from_enc == 0 ||
428 +           !strcmp(from_enc,"UTF8") || !strcmp(from_enc, "US-ASCII") )
429                 from_enc = "UTF-8";
430  
431 -       if(!to_enc || *to_enc == 0)
432 +       if( !to_enc || *to_enc == 0 ||
433 +           !strcmp(to_enc,"UTF8") || !strcmp(to_enc, "US-ASCII") )
434                 to_enc = "UTF-8";
435  
436         if(input_length < 0)
437 @@ -1701,32 +1774,45 @@ size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
438  
439         if(strcmp(from_enc, to_enc) && inbytes)
440         {
441 -               if((cd = iconv_open(to_enc, from_enc)) == (iconv_t)-1)
442 +               if( !strcmp(from_enc, "UTF-8") && !strcmp(to_enc,"UTF32LE") ) {
443 +                       utf8conv uc(0,0, input,inbytes);
444 +                       uint32_t *op = (uint32_t *)output;
445 +                       uint32_t *ep = (uint32_t *)(output+output_length);
446 +                       for( int wch; op<ep && (wch=uc.wnext())>=0; *op++=wch );
447 +                       output = (char *)op;
448 +                       outbytes = (char*)ep - output;
449 +               }
450 +               else if( !strcmp(from_enc, "UTF32LE") && !strcmp(to_enc,"UTF-8") ) {
451 +                       utf8conv uc(output,output_length, 0,0);
452 +                       uint32_t *ip = (uint32_t *)input;
453 +                       uint32_t *ep = (uint32_t *)(input+inbytes);
454 +                       for( ; ip<ep && uc.wnext(*ip)>=0; ++ip );
455 +                       output += uc.olen();
456 +                       outbytes = output_length-uc.olen();
457 +               }
458 +               else if((cd = iconv_open(to_enc, from_enc)) == (iconv_t)-1)
459                 {
460                         printf(_("Conversion from %s to %s is not available\n"),
461                                 from_enc, to_enc);
462                         return 0;
463                 }
464 -
465 -               outbytes = output_length - 1;
466 -
467 -               iconv(cd, &input, &inbytes, &output, &outbytes);
468 -
469 -               iconv_close(cd);
470 -               inbytes = output - outbase;
471 +               else {
472 +                       outbytes = output_length - 1;
473 +                       iconv(cd, &input, &inbytes, &output, &outbytes);
474 +                       iconv_close(cd);
475 +               }
476         }
477         else if(inbytes)
478         {
479                 memcpy(output,  input, inbytes);
480 +               output += inbytes;
481                 outbytes -= inbytes;
482         }
483 -       for(int i = 0; i < 4; i++)
484 -       {
485 +       if( outbytes > sizeof(uint32_t) )
486 +               outbytes = sizeof(uint32_t);
487 +       for(int i = 0; i < outbytes; i++)
488                 output[i] = 0;
489 -               if(outbytes-- == 0)
490 -                       break;
491 -       }
492 -       return inbytes;
493 +       return output - outbase;
494  }
495  
496  void BC_Resources::encode_to_utf8(char *buffer, int buflen)
497 diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C
498 index ed50cfb1..f1b894ba 100644
499 --- a/cinelerra-5.1/guicast/bcsignals.C
500 +++ b/cinelerra-5.1/guicast/bcsignals.C
501 @@ -37,9 +37,11 @@
502  #include <sys/stat.h>
503  #include <unistd.h>
504  #include <sys/ioctl.h>
505 -#include <sys/prctl.h>
506  #include <sys/types.h>
507  
508 +#define dirent64 dirent
509 +#define readdir64 readdir
510 +
511  BC_Signals* BC_Signals::global_signals = 0;
512  static int signal_done = 0;
513  
514 @@ -279,18 +281,6 @@ static void handle_exit(int signum)
515  
516  void BC_Signals::set_sighup_exit(int enable)
517  {
518 -       if( enable ) {
519 -// causes SIGHUP to be generated when parent dies
520 -               signal(SIGHUP, handle_exit);
521 -               prctl(PR_SET_PDEATHSIG, SIGHUP, 0,0,0);
522 -// prevents ^C from signalling child when attached to gdb
523 -               setpgid(0, 0);
524 -               if( isatty(0) ) ioctl(0, TIOCNOTTY, 0);
525 -       }
526 -       else {
527 -               signal(SIGHUP, signal_entry);
528 -               prctl(PR_SET_PDEATHSIG, 0,0,0,0);
529 -       }
530  }
531  
532  BC_Signals::BC_Signals()
533 @@ -383,11 +373,13 @@ const char* BC_Signals::sig_to_str(int number)
534  #include <sys/wait.h>
535  #include "thread.h"
536  
537 +#define SC_(r)sc_##r
538 +
539  #if __i386__
540 -#define IP eip
541 +#define IP SC_(eip)
542  #endif
543  #if __x86_64__
544 -#define IP rip
545 +#define IP SC_(rip)
546  #endif
547  #ifndef IP
548  #error gotta have IP
549 @@ -473,26 +465,5 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
550  
551         fprintf(fp,"\n\n");
552         if( fp != stdout ) fclose(fp);
553 -       char cmd[1024], *cp = cmd;
554 -       cp += sprintf(cp, "exec gdb /proc/%d/exe -p %d --batch --quiet "
555 -               "-ex \"thread apply all info registers\" "
556 -               "-ex \"thread apply all bt full\" "
557 -               "-ex \"quit\"", pid, pid);
558 -       if( fp != stdout )
559 -               cp += sprintf(cp," >> \"%s\"", fn);
560 -       cp += sprintf(cp," 2>&1");
561 -//printf("handle_dump:: pid=%d, cmd='%s'  fn='%s'\n",pid,cmd,fn);
562 -        pid = vfork();
563 -        if( pid < 0 ) {
564 -               fprintf(stderr,"** can't start gdb, dump abondoned\n");
565 -               return;
566 -       }
567 -       if( pid > 0 ) {
568 -               waitpid(pid,0,0);
569 -               fprintf(stderr,"** dump complete\n");
570 -               return;
571 -       }
572 -        char *const argv[4] = { (char*) "/bin/sh", (char*) "-c", cmd, 0 };
573 -        execvp(argv[0], &argv[0]);
574  }
575  
576 diff --git a/cinelerra-5.1/guicast/filesystem.C b/cinelerra-5.1/guicast/filesystem.C
577 index ebc2007d..9d6452cb 100644
578 --- a/cinelerra-5.1/guicast/filesystem.C
579 +++ b/cinelerra-5.1/guicast/filesystem.C
580 @@ -33,6 +33,8 @@
581  #include <unistd.h>
582  #include <utime.h>
583  
584 +#define dirent64 dirent
585 +#define readdir64 readdir
586  
587  #include "filesystem.h"
588  
589 diff --git a/cinelerra-5.1/guicast/thread.C b/cinelerra-5.1/guicast/thread.C
590 index dff53e61..321ab4fc 100644
591 --- a/cinelerra-5.1/guicast/thread.C
592 +++ b/cinelerra-5.1/guicast/thread.C
593 @@ -55,13 +55,6 @@ void* Thread::entrypoint(void *parameters)
594         pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
595         thread->cancel_enabled = false;
596  
597 -// Set realtime here seince it doesn't work in start
598 -       if( thread->realtime && getuid() == 0 ) {
599 -               struct sched_param param = { sched_priority : 1 };
600 -               if(pthread_setschedparam(thread->tid, SCHED_RR, &param) < 0)
601 -                       perror("Thread::entrypoint pthread_attr_setschedpolicy");
602 -       }
603 -
604         thread->run();
605         thread->finished = true;
606         if( !thread->synchronous ) {
607 diff --git a/cinelerra-5.1/guicast/thread.h b/cinelerra-5.1/guicast/thread.h
608 index 216ecd2b..8ebec237 100644
609 --- a/cinelerra-5.1/guicast/thread.h
610 +++ b/cinelerra-5.1/guicast/thread.h
611 @@ -27,7 +27,7 @@
612  #include <unistd.h>
613  #include <sys/syscall.h>
614  
615 -static inline int gettid() { return syscall(SYS_gettid, 0, 0, 0); }
616 +static inline long gettid() { return (long)pthread_self(); }
617  
618  // The thread does not autodelete by default.
619  // If autodelete is 1 the thread autodeletes.
620 diff --git a/cinelerra-5.1/plugins/Makefile b/cinelerra-5.1/plugins/Makefile
621 index 6ed357c7..56081181 100644
622 --- a/cinelerra-5.1/plugins/Makefile
623 +++ b/cinelerra-5.1/plugins/Makefile
624 @@ -31,7 +31,6 @@ DIRS = $(OPENCV_OBJS) \
625         brightness \
626         burn \
627         C41 \
628 -       cdripper \
629         chromakey \
630         chromakeyhsv \
631         color3way \
632 @@ -161,6 +160,8 @@ DIRS = $(OPENCV_OBJS) \
633  #      denoisemjpeg \
634  # duplicate
635  #      vocoder \
636 +# not in bsd
637 +#      cdripper \
638  
639  PLUGIN_DIR = $(BINDIR)/plugins
640  DATA = $(PLUGIN_DIR)/fonts $(PLUGIN_DIR)/shapes
641 diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C
642 index fefbbdb1..045e96d4 100644
643 --- a/cinelerra-5.1/plugins/titler/titler.C
644 +++ b/cinelerra-5.1/plugins/titler/titler.C
645 @@ -57,8 +57,7 @@
646  #include <stdint.h>
647  #include <stdio.h>
648  #include <string.h>
649 -#include <endian.h>
650 -#include <byteswap.h>
651 +#include <sys/endian.h>
652  #include <iconv.h>
653  #include <sys/stat.h>
654  #include <fontconfig/fontconfig.h>