$OpenBSD: patch-src_xvid_c,v 1.1 2009/05/10 20:16:10 sthen Exp $
--- src/xvid.c.orig	Thu Apr  9 04:03:26 2009
+++ src/xvid.c	Thu Apr  9 04:17:31 2009
@@ -32,6 +32,12 @@
   #include <unistd.h>
 #endif
 
+#if defined(__OpenBSD__)
+  #include <sys/param.h>
+  #include <sys/sysctl.h>
+  #include <machine/cpu.h>
+#endif
+
 #include "xvid.h"
 #include "decoder.h"
 #include "encoder.h"
@@ -675,6 +681,18 @@ xvid_gbl_info(xvid_gbl_info_t * info)
 	SYSTEM_INFO siSysInfo;
 	GetSystemInfo(&siSysInfo);
 	info->num_threads = siSysInfo.dwNumberOfProcessors; /* number of _logical_ cores */
+  }
+
+#elif defined(__OpenBSD__)
+
+  {
+	int ncpu, mib[2] = { CTL_HW, HW_NCPU };
+	size_t length = sizeof (ncpu);
+
+	if (sysctl(mib, 2, &ncpu, &length, NULL, 0))
+	    ncpu = 1;
+
+	info->num_threads = ncpu;
   }
 
 #else
