56 unsigned char header[282];
297#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
510 const char* dllnames_og [] =
524 const char* dllnames_vo [] =
538 const char* dllnames_ve [] =
541 "libvorbisenc-2.dll",
545 "libvorbisenc.dylib",
552 const char* dllnames_th [] =
611typedef struct allocatedoggpage_s
621typedef struct capturevideostate_ogg_formatspecific_s
637#define LOAD_FORMATSPECIFIC_OGG() capturevideostate_ogg_formatspecific_t *format = (capturevideostate_ogg_formatspecific_t *) cls.capturevideo.formatspecific
644 if(!
cls.capturevideo.soundrate)
657 if(!
format->videopage.len)
662 if(
format->videopage.len >
sizeof(
format->videopage.data))
667 if(!
format->audiopage.len)
672 if(
format->audiopage.len >
sizeof(
format->audiopage.data))
684 format->videopage.len = 0;
689 format->audiopage.len = 0;
701 if(
cls.capturevideo.soundrate)
705 format->audiopage.len = 0;
711 format->videopage.len = 0;
724 while(
format->lastnum-- > 0)
735 if(
cls.capturevideo.soundrate)
756 if(
cls.capturevideo.soundrate)
768 fprintf (stderr,
"Internal Ogg library error.\n");
775 if(
cls.capturevideo.soundrate)
780 fprintf (stderr,
"Internal Ogg library error.\n");
805 cls.capturevideo.videofile =
NULL;
813 int blockr, blockg, blockb;
815 int w =
cls.capturevideo.width;
816 int h =
cls.capturevideo.height;
821 for(
y = 0;
y < h; ++
y)
823 for(
b = in + (h-1-
y)*
w*4,
x = 0;
x <
w; ++
x)
829 cls.capturevideo.yuvnormalizetable[0][
cls.capturevideo.rgbtoyuvscaletable[0][0][blockr] +
cls.capturevideo.rgbtoyuvscaletable[0][1][blockg] +
cls.capturevideo.rgbtoyuvscaletable[0][2][blockb]];
833 if ((
y & 1) == 0 &&
y/2 < h/2)
835 for(
b = in + (h-2-
y)*
w*4,
x = 0;
x <
w/2; ++
x)
837 blockr = (
b[2] +
b[6] +
b[inpitch+2] +
b[inpitch+6]) >> 2;
838 blockg = (
b[1] +
b[5] +
b[inpitch+1] +
b[inpitch+5]) >> 2;
839 blockb = (
b[0] +
b[4] +
b[inpitch+0] +
b[inpitch+4]) >> 2;
841 cls.capturevideo.yuvnormalizetable[1][
cls.capturevideo.rgbtoyuvscaletable[1][0][blockr] +
cls.capturevideo.rgbtoyuvscaletable[1][1][blockg] +
cls.capturevideo.rgbtoyuvscaletable[1][2][blockb] + 128];
843 cls.capturevideo.yuvnormalizetable[2][
cls.capturevideo.rgbtoyuvscaletable[2][0][blockr] +
cls.capturevideo.rgbtoyuvscaletable[2][1][blockg] +
cls.capturevideo.rgbtoyuvscaletable[2][2][blockb] + 128];
860 while(
format->lastnum-- > 0)
881 { 0, -1, -1, -1, -1, -1, -1, -1 },
882 { 0, 1, -1, -1, -1, -1, -1, -1 },
883 { 0, 1, 2, -1, -1, -1, -1, -1 },
884 { 0, 1, 2, 3, -1, -1, -1, -1 },
885 { 0, 2, 3, 4, 1, -1, -1, -1 },
886 { 0, 2, 3, 4, 1, 5, -1, -1 },
887 { 0, 2, 3, 4, 1, 5, 6, -1 },
888 { 0, 2, 3, 4, 1, 5, 6, 7 }
894 float **vorbis_buffer;
901 for(j = 0; j <
cls.capturevideo.soundchannels; ++j)
903 float *
b = vorbis_buffer[map[j]];
924 cls.capturevideo.format = CAPTUREVIDEOFORMAT_OGG_VORBIS_THEORA;
925 cls.capturevideo.formatextension =
"ogv";
926 cls.capturevideo.videofile =
FS_OpenRealFile(
va(vabuf,
sizeof(vabuf),
"%s.%s",
cls.capturevideo.basename,
cls.capturevideo.formatextension),
"wb",
false);
927 if (!
cls.capturevideo.videofile)
929 Con_Printf(
CON_ERROR "Failed to open video file \"%s\", cancelling video capture.\n", vabuf);
930 cls.capturevideo.error =
true;
950 if(
cls.capturevideo.soundrate)
970 for(
i = 0;
i < 2; ++
i)
984 FindFraction(
cls.capturevideo.framerate /
cls.capturevideo.framestep, &num, &denom, 1001);
1011 Con_DPrintf(
"WARNING: requesting an odd bitrate for theora (sensible values range from 45 to 2000 kbps)\n");
1042 Con_DPrintf(
"Warning: theora stream is not fully VP3 compatible\n");
1046 if(
cls.capturevideo.soundrate)
1061 fprintf (stderr,
"Internal Ogg library error.\n");
1072 if(
cls.capturevideo.soundrate)
1077 fprintf (stderr,
"Internal Ogg library error.\n");
1091 fprintf (stderr,
"Internal Ogg library error.\n");
1098 if(
cls.capturevideo.soundrate)
1103 fprintf (stderr,
"Internal Ogg library error.\n");
static int(* qvorbis_encode_init_vbr)(vorbis_info *vi, long channels, long rate, float base_quality)
static void SCR_CaptureVideo_Ogg_FlushInterleaving(void)
static void(* qvorbis_comment_init)(vorbis_comment *vc)
static int(* qvorbis_block_clear)(vorbis_block *vb)
void SCR_CaptureVideo_Ogg_Init(void)
static int(* qvorbis_analysis_blockout)(vorbis_dsp_state *v, vorbis_block *vb)
static void(* qtheora_clear)(theora_state *t)
static void SCR_CaptureVideo_Ogg_VideoFrames(int num, u8 *in)
static int(* qtheora_encode_comment)(theora_comment *tc, ogg_packet *op)
static float **(* qvorbis_analysis_buffer)(vorbis_dsp_state *v, int vals)
static int(* qtheora_control)(theora_state *th, int req, void *buf, size_t buf_sz)
static double(* qvorbis_granule_time)(vorbis_dsp_state *v, int64_t granulepos)
static int(* qvorbis_analysis_init)(vorbis_dsp_state *v, vorbis_info *vi)
static int(* qvorbis_block_init)(vorbis_dsp_state *v, vorbis_block *vb)
#define TH_ENCCTL_SET_VP3_COMPATIBLE
static int(* qvorbis_bitrate_flushpacket)(vorbis_dsp_state *vd, ogg_packet *op)
static dllfunction_t vorbisencfuncs[]
static void(* qtheora_info_init)(theora_info *c)
static int(* qvorbis_commentheader_out)(vorbis_comment *vc, ogg_packet *op)
static void SCR_CaptureVideo_Ogg_Interleave(void)
channelmapping_t mapping[8]
static dllfunction_t vorbisfuncs[]
static cvar_t cl_capturevideo_ogg_theora_keyframe_auto_threshold
static cvar_t cl_capturevideo_ogg_theora_sharpness
static int(* qvorbis_analysis_wrote)(vorbis_dsp_state *v, int vals)
static int(* qvorbis_analysis)(vorbis_block *vb, ogg_packet *op)
static int(* qvorbis_bitrate_addblock)(vorbis_block *vb)
static dllhandle_t og_dll
static dllhandle_t ve_dll
static int(* qtheora_encode_init)(theora_state *th, theora_info *ti)
static void SCR_CaptureVideo_Ogg_ConvertFrame_BGRA_to_YUV(u8 *in)
static int(* qvorbis_analysis_headerout)(vorbis_dsp_state *v, vorbis_comment *vc, ogg_packet *op, ogg_packet *op_comm, ogg_packet *op_code)
static int(* qogg_stream_clear)(ogg_stream_state *os)
static void(* qvorbis_info_init)(vorbis_info *vi)
static dllhandle_t vo_dll
static int(* qtheora_encode_YUVin)(theora_state *t, yuv_buffer *yuv)
static void(* qtheora_info_clear)(theora_info *c)
#define LOAD_FORMATSPECIFIC_OGG()
static cvar_t cl_capturevideo_ogg_theora_vp3compat
void SCR_CaptureVideo_Ogg_BeginVideo(void)
static cvar_t cl_capturevideo_ogg_theora_bitrate
static int(* qtheora_encode_tables)(theora_state *t, ogg_packet *op)
theora_colorspace
A Colorspace.
@ OC_CS_ITU_REC_470BG
This is the best option for 'PAL' content.
@ OC_CS_NSPACES
This marks the end of the defined colorspaces.
@ OC_CS_ITU_REC_470M
This is the best option for 'NTSC' content.
@ OC_CS_UNSPECIFIED
The colorspace is unknown or unspecified.
void SCR_CaptureVideo_Ogg_CloseDLL(void)
static void(* qtheora_comment_clear)(theora_comment *tc)
static cvar_t cl_capturevideo_ogg_theora_keyframe_maxinterval
static void(* qtheora_comment_init)(theora_comment *tc)
static cvar_t cl_capturevideo_ogg_theora_keyframe_bitrate_multiplier
static double(* qtheora_granule_time)(theora_state *th, int64_t granulepos)
static qbool SCR_CaptureVideo_Ogg_OpenLibrary(void)
static int(* qogg_stream_pageout)(ogg_stream_state *os, ogg_page *og)
static cvar_t cl_capturevideo_ogg_theora_quality
static void SCR_CaptureVideo_Ogg_EndVideo(void)
static dllfunction_t oggfuncs[]
static cvar_t cl_capturevideo_ogg_theora_keyframe_mininterval
static int(* qogg_stream_packetin)(ogg_stream_state *os, ogg_packet *op)
static void(* qvorbis_comment_clear)(vorbis_comment *vc)
static int64_t(* qogg_page_granulepos)(ogg_page *og)
static dllfunction_t theorafuncs[]
theora_pixelformat
A Chroma subsampling.
@ OC_PF_444
No chroma subsampling at all (4:4:4)
@ OC_PF_422
Horizonatal chroma subsampling by 2 (4:2:2)
@ OC_PF_420
Chroma subsampling by 2 in each direction (4:2:0)
@ OC_PF_RSVD
Reserved value.
static void(* qvorbis_info_clear)(vorbis_info *vi)
static int(* qtheora_encode_header)(theora_state *t, ogg_packet *op)
static int(* qogg_stream_flush)(ogg_stream_state *os, ogg_page *og)
static cvar_t cl_capturevideo_ogg_vorbis_quality
static cvar_t cl_capturevideo_ogg_theora_noise_sensitivity
static void SCR_CaptureVideo_Ogg_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length)
qbool SCR_CaptureVideo_Ogg_Available(void)
static void(* qvorbis_dsp_clear)(vorbis_dsp_state *v)
static dllhandle_t th_dll
static int(* qogg_stream_init)(ogg_stream_state *os, int serialno)
static int(* qtheora_encode_packetout)(theora_state *t, int last_p, ogg_packet *op)
#define CF_CLIENT
cvar/command that only the client can change/execute
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
char * va(char *buf, size_t buflen, const char *format,...)
void FindFraction(double val, int *num, int *denom, int denomMax)
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
fs_offset_t FS_Write(qfile_t *file, const void *data, size_t datasize)
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
static int(ZEXPORT *qz_inflate)(z_stream *strm
int FS_Close(qfile_t *file)
GLubyte GLubyte GLubyte GLubyte w
GLenum GLuint GLenum GLsizei length
GLint GLint GLint GLsizei GLsizei GLenum format
GLint GLenum GLint GLint y
GLsizeiptr const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
#define bound(min, num, max)
channel_t channels[MAX_CHANNELS]
static portable_sampleframe_t paintbuffer[PAINTBUFFER_SIZE]
struct alloc_chain * next
unsigned char * body_data
exported for capturevideo so ogg can see all channels
int32_t keyframe_auto_threshold
int target_bitrate
nominal bitrate in bits per second
uint32_t frame_height
display frame height
int quick_p
Quick encode/decode.
uint32_t aspect_denominator
pixel aspect ratio denominator
uint32_t fps_numerator
frame rate numerator
uint32_t keyframe_data_target_bitrate
theora_colorspace colorspace
colorspace
theora_pixelformat pixelformat
chroma subsampling mode to expect
uint32_t width
encoded frame width
int quality
Nominal quality setting, 0-63.
unsigned char version_minor
unsigned char version_major
uint32_t offset_x
horizontal offset of the displayed frame
uint32_t keyframe_frequency_force
unsigned char version_subminor
uint32_t aspect_numerator
pixel aspect ratio numerator
uint32_t height
encoded frame height
uint32_t keyframe_frequency
uint32_t keyframe_mindistance
uint32_t offset_y
vertical offset of the displayed frame
int32_t noise_sensitivity
uint32_t frame_width
display frame width
uint32_t fps_denominator
frame rate denominator
Codec internal state and context.
struct alloc_chain * reap
int y_height
Height of the luminance plane.
int uv_height
Height of the chroma planes.
unsigned char * y
Pointer to start of luminance data.
unsigned char * u
Pointer to start of Cb data.
int uv_width
Width of the Cb and Cr chroma planes.
int y_stride
Offset in bytes between successive rows.
unsigned char * v
Pointer to start of Cr data.
int y_width
Width of the Y' luminance plane.
int uv_stride
Offset between successive chroma rows.
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
qbool Sys_LoadDependency(const char **dllnames, dllhandle_t *handle, const dllfunction_t *fcts)
void Sys_FreeLibrary(dllhandle_t *handle)
#define Mem_Alloc(pool, size)