]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cap_ogg.c
Add a third masterextra and default it to dpm.dpmaster.org
[xonotic/darkplaces.git] / cap_ogg.c
index 0565a9e8e51109592ad5c493eddc158f82a1163a..6218e8ad5fd71d51040d5a90ace806fa4d46becc 100644 (file)
--- a/cap_ogg.c
+++ b/cap_ogg.c
@@ -5,23 +5,16 @@
 #include "cap_ogg.h"
 
 // video capture cvars
-static cvar_t cl_capturevideo_ogg_theora_vp3compat = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_vp3compat", "1", "make VP3 compatible theora streams"};
-static cvar_t cl_capturevideo_ogg_theora_quality = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_quality", "48", "video quality factor (0 to 63), or -1 to use bitrate only; higher is better; setting both to -1 achieves unlimited quality"};
-static cvar_t cl_capturevideo_ogg_theora_bitrate = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_bitrate", "-1", "video bitrate (45 to 2000 kbps), or -1 to use quality only; higher is better; setting both to -1 achieves unlimited quality"};
-static cvar_t cl_capturevideo_ogg_theora_keyframe_bitrate_multiplier = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_keyframe_bitrate_multiplier", "1.5", "how much more bit rate to use for keyframes, specified as a factor of at least 1"};
-static cvar_t cl_capturevideo_ogg_theora_keyframe_maxinterval = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_keyframe_maxinterval", "64", "maximum keyframe interval (1 to 1000)"};
-static cvar_t cl_capturevideo_ogg_theora_keyframe_mininterval = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_keyframe_mininterval", "8", "minimum keyframe interval (1 to 1000)"};
-static cvar_t cl_capturevideo_ogg_theora_keyframe_auto_threshold = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_keyframe_auto_threshold", "80", "threshold for key frame decision (0 to 100)"};
-static cvar_t cl_capturevideo_ogg_theora_noise_sensitivity = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_noise_sensitivity", "1", "video noise sensitivity (0 to 6); lower is better"};
-static cvar_t cl_capturevideo_ogg_theora_sharpness = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_theora_sharpness", "0", "sharpness (0 to 2); lower is sharper"};
-static cvar_t cl_capturevideo_ogg_vorbis_quality = {CVAR_CLIENT | CVAR_SAVE, "cl_capturevideo_ogg_vorbis_quality", "3", "audio quality (-1 to 10); higher is better"};
-
-// ogg.h stuff
-typedef int16_t ogg_int16_t;
-typedef uint16_t ogg_uint16_t;
-typedef int32_t ogg_int32_t;
-typedef uint32_t ogg_uint32_t;
-typedef int64_t ogg_int64_t;
+static cvar_t cl_capturevideo_ogg_theora_vp3compat = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_vp3compat", "1", "make VP3 compatible theora streams"};
+static cvar_t cl_capturevideo_ogg_theora_quality = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_quality", "48", "video quality factor (0 to 63), or -1 to use bitrate only; higher is better; setting both to -1 achieves unlimited quality"};
+static cvar_t cl_capturevideo_ogg_theora_bitrate = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_bitrate", "-1", "video bitrate (45 to 2000 kbps), or -1 to use quality only; higher is better; setting both to -1 achieves unlimited quality"};
+static cvar_t cl_capturevideo_ogg_theora_keyframe_bitrate_multiplier = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_keyframe_bitrate_multiplier", "1.5", "how much more bit rate to use for keyframes, specified as a factor of at least 1"};
+static cvar_t cl_capturevideo_ogg_theora_keyframe_maxinterval = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_keyframe_maxinterval", "64", "maximum keyframe interval (1 to 1000)"};
+static cvar_t cl_capturevideo_ogg_theora_keyframe_mininterval = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_keyframe_mininterval", "8", "minimum keyframe interval (1 to 1000)"};
+static cvar_t cl_capturevideo_ogg_theora_keyframe_auto_threshold = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_keyframe_auto_threshold", "80", "threshold for key frame decision (0 to 100)"};
+static cvar_t cl_capturevideo_ogg_theora_noise_sensitivity = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_noise_sensitivity", "1", "video noise sensitivity (0 to 6); lower is better"};
+static cvar_t cl_capturevideo_ogg_theora_sharpness = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_theora_sharpness", "0", "sharpness (0 to 2); lower is sharper"};
+static cvar_t cl_capturevideo_ogg_vorbis_quality = {CF_CLIENT | CF_ARCHIVE, "cl_capturevideo_ogg_vorbis_quality", "3", "audio quality (-1 to 10); higher is better"};
 
 typedef struct {
   long endbyte;
@@ -52,7 +45,7 @@ typedef struct {
 
 
   int     *lacing_vals;      /* The values that will go to the segment table */
-  ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
+  int64_t *granule_vals; /* granulepos values for headers. Not compact
                                this way, but it is simple coupled to the
                                lacing fifo */
   long    lacing_storage;
@@ -69,12 +62,12 @@ typedef struct {
                              of a logical bitstream */
   long    serialno;
   long    pageno;
-  ogg_int64_t  packetno;      /* sequence number for decode; the framing
+  int64_t  packetno;      /* sequence number for decode; the framing
                              knows where there's a hole in the data,
                              but we need coupling so that the codec
                              (which is in a seperate abstraction
                              layer) also knows about the gap */
-  ogg_int64_t   granulepos;
+  int64_t   granulepos;
 
 } ogg_stream_state;
 
@@ -87,9 +80,9 @@ typedef struct {
   long  b_o_s;
   long  e_o_s;
 
-  ogg_int64_t  granulepos;
+  int64_t  granulepos;
   
-  ogg_int64_t  packetno;     /* sequence number for decode; the framing
+  int64_t  packetno;     /* sequence number for decode; the framing
                                knows where there's a hole in the data,
                                but we need coupling so that the codec
                                (which is in a seperate abstraction
@@ -117,7 +110,7 @@ static int      (*qogg_stream_flush) (ogg_stream_state *os, ogg_page *og);
 
 static int      (*qogg_stream_init) (ogg_stream_state *os,int serialno);
 static int      (*qogg_stream_clear) (ogg_stream_state *os);
-static ogg_int64_t  (*qogg_page_granulepos) (ogg_page *og);
+static int64_t  (*qogg_page_granulepos) (ogg_page *og);
 
 // end of ogg.h stuff
 
@@ -171,13 +164,13 @@ typedef struct vorbis_dsp_state{
   long nW;
   long centerW;
 
-  ogg_int64_t granulepos;
-  ogg_int64_t sequence;
+  int64_t granulepos;
+  int64_t sequence;
 
-  ogg_int64_t glue_bits;
-  ogg_int64_t time_bits;
-  ogg_int64_t floor_bits;
-  ogg_int64_t res_bits;
+  int64_t glue_bits;
+  int64_t time_bits;
+  int64_t floor_bits;
+  int64_t res_bits;
 
   void       *backend_state;
 } vorbis_dsp_state;
@@ -194,8 +187,8 @@ typedef struct vorbis_block{
   int   mode;
 
   int         eofflag;
-  ogg_int64_t granulepos;
-  ogg_int64_t sequence;
+  int64_t granulepos;
+  int64_t sequence;
   vorbis_dsp_state *vd; /* For read-only access of configuration */
 
   /* local storage to avoid remallocing; it's up to the mapping to
@@ -268,7 +261,7 @@ static int      (*qvorbis_block_init) (vorbis_dsp_state *v, vorbis_block *vb);
 static int      (*qvorbis_block_clear) (vorbis_block *vb);
 static void     (*qvorbis_dsp_clear) (vorbis_dsp_state *v);
 static double   (*qvorbis_granule_time) (vorbis_dsp_state *v,
-                                   ogg_int64_t granulepos);
+                                   int64_t granulepos);
 
 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
 
@@ -362,16 +355,16 @@ typedef enum {
  * other paramters and good default settings for the encoder parameters.
  */
 typedef struct {
-  ogg_uint32_t  width;      /**< encoded frame width  */
-  ogg_uint32_t  height;     /**< encoded frame height */
-  ogg_uint32_t  frame_width;    /**< display frame width  */
-  ogg_uint32_t  frame_height;   /**< display frame height */
-  ogg_uint32_t  offset_x;   /**< horizontal offset of the displayed frame */
-  ogg_uint32_t  offset_y;   /**< vertical offset of the displayed frame */
-  ogg_uint32_t  fps_numerator;      /**< frame rate numerator **/
-  ogg_uint32_t  fps_denominator;    /**< frame rate denominator **/
-  ogg_uint32_t  aspect_numerator;   /**< pixel aspect ratio numerator */
-  ogg_uint32_t  aspect_denominator; /**< pixel aspect ratio denominator */
+  uint32_t  width;      /**< encoded frame width  */
+  uint32_t  height;     /**< encoded frame height */
+  uint32_t  frame_width;    /**< display frame width  */
+  uint32_t  frame_height;   /**< display frame height */
+  uint32_t  offset_x;   /**< horizontal offset of the displayed frame */
+  uint32_t  offset_y;   /**< vertical offset of the displayed frame */
+  uint32_t  fps_numerator;      /**< frame rate numerator **/
+  uint32_t  fps_denominator;    /**< frame rate denominator **/
+  uint32_t  aspect_numerator;   /**< pixel aspect ratio numerator */
+  uint32_t  aspect_denominator; /**< pixel aspect ratio denominator */
   theora_colorspace colorspace;     /**< colorspace */
   int           target_bitrate;     /**< nominal bitrate in bits per second */
   int           quality;  /**< Nominal quality setting, 0-63 */
@@ -387,14 +380,14 @@ typedef struct {
   /* encode only */
   int           dropframes_p;
   int           keyframe_auto_p;
-  ogg_uint32_t  keyframe_frequency;
-  ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
+  uint32_t  keyframe_frequency;
+  uint32_t  keyframe_frequency_force;  /* also used for decode init to
                                               get granpos shift correct */
-  ogg_uint32_t  keyframe_data_target_bitrate;
-  ogg_int32_t   keyframe_auto_threshold;
-  ogg_uint32_t  keyframe_mindistance;
-  ogg_int32_t   noise_sensitivity;
-  ogg_int32_t   sharpness;
+  uint32_t  keyframe_data_target_bitrate;
+  int32_t   keyframe_auto_threshold;
+  uint32_t  keyframe_mindistance;
+  int32_t   noise_sensitivity;
+  int32_t   sharpness;
 
   theora_pixelformat pixelformat;   /**< chroma subsampling mode to expect */
 
@@ -404,7 +397,7 @@ typedef struct {
  */
 typedef struct{
   theora_info *i;
-  ogg_int64_t granulepos;
+  int64_t granulepos;
 
   void *internal_encode;
   void *internal_decode;
@@ -449,7 +442,7 @@ static void (*qtheora_info_clear) (theora_info *c);
 static void (*qtheora_clear) (theora_state *t);
 static void (*qtheora_comment_init) (theora_comment *tc);
 static void  (*qtheora_comment_clear) (theora_comment *tc);
-static double (*qtheora_granule_time) (theora_state *th,ogg_int64_t granulepos);
+static double (*qtheora_granule_time) (theora_state *th,int64_t granulepos);
 static int (*qtheora_control) (theora_state *th,int req,void *buf,size_t buf_sz);
 // end of theora.h stuff
 
@@ -512,7 +505,7 @@ static dllfunction_t theorafuncs[] =
 
 static dllhandle_t og_dll = NULL, vo_dll = NULL, ve_dll = NULL, th_dll = NULL;
 
-static qboolean SCR_CaptureVideo_Ogg_OpenLibrary(void)
+static qbool SCR_CaptureVideo_Ogg_OpenLibrary(void)
 {
        const char* dllnames_og [] =
        {
@@ -572,13 +565,13 @@ static qboolean SCR_CaptureVideo_Ogg_OpenLibrary(void)
        };
 
        return
-               Sys_LoadLibrary (dllnames_og, &og_dll, oggfuncs)
+               Sys_LoadDependency (dllnames_og, &og_dll, oggfuncs)
                &&
-               Sys_LoadLibrary (dllnames_th, &th_dll, theorafuncs)
+               Sys_LoadDependency (dllnames_th, &th_dll, theorafuncs)
                &&
-               Sys_LoadLibrary (dllnames_vo, &vo_dll, vorbisfuncs)
+               Sys_LoadDependency (dllnames_vo, &vo_dll, vorbisfuncs)
                &&
-               Sys_LoadLibrary (dllnames_ve, &ve_dll, vorbisencfuncs);
+               Sys_LoadDependency (dllnames_ve, &ve_dll, vorbisencfuncs);
 }
 
 void SCR_CaptureVideo_Ogg_Init(void)
@@ -596,17 +589,17 @@ void SCR_CaptureVideo_Ogg_Init(void)
        Cvar_RegisterVariable(&cl_capturevideo_ogg_vorbis_quality);
 }
 
-qboolean SCR_CaptureVideo_Ogg_Available(void)
+qbool SCR_CaptureVideo_Ogg_Available(void)
 {
        return og_dll && th_dll && vo_dll && ve_dll;
 }
 
 void SCR_CaptureVideo_Ogg_CloseDLL(void)
 {
-       Sys_UnloadLibrary (&ve_dll);
-       Sys_UnloadLibrary (&vo_dll);
-       Sys_UnloadLibrary (&th_dll);
-       Sys_UnloadLibrary (&og_dll);
+       Sys_FreeLibrary (&ve_dll);
+       Sys_FreeLibrary (&vo_dll);
+       Sys_FreeLibrary (&th_dll);
+       Sys_FreeLibrary (&og_dll);
 }
 
 // this struct should not be needed