shithub: alienpatch

Download patch

ref: 86399d785f68db91a29b54af06a444caf971012f
author: qwx <qwx@sciops.net>
date: Fri Jan 10 21:13:30 EST 2020

add patches for building bleeding edge opus libraries and tools

git://git.xiph.org/libopusenc.git
git://git.xiph.org/opus-tools.git
git://git.xiph.org/opus.git
git://git.xiph.org/opusfile.git

--- /dev/null
+++ b/libopusenc
@@ -1,0 +1,37 @@
+--- /dev/null	Wed Dec 11 10:26:09 2019
++++ mkfile	Sat Jan 11 02:42:30 2020
+@@ -0,0 +1,34 @@
++</$objtype/mkfile
++
++CC=pcc
++CFLAGS=-Iinclude \
++	-I/sys/src/cmd/audio/libogg \
++	-I/sys/include/ape/opus \
++	-DPACKAGE_VERSION="fuckoff" \
++	-DPACKAGE_NAME="libopusenc" \
++	-DOUTSIDE_SPEEX \
++	-DRANDOM_PREFIX=opusenc \
++	-D_POSIX_SOURCE \
++	-c
++LIB=libopusenc.a
++
++OFILES=\
++	ogg_packer.$O \
++	opus_header.$O \
++	opusenc.$O \
++	picture.$O \
++	resample.$O \
++	unicode_support.$O \
++
++</sys/src/cmd/mklib
++
++LIBDIR=/$objtype/lib/ape
++
++%.$O:	src/%.c
++	$CC $CFLAGS src/$stem.c
++
++installheaders:V:
++	mkdir -p /sys/include/ape/opus
++	dircp include /sys/include/ape/opus
++
++install:VQ:	installheaders
--- /dev/null
+++ b/opus
@@ -1,0 +1,184 @@
+--- /dev/null	Wed Dec 11 10:26:09 2019
++++ mkfile	Sat Jan 11 02:26:04 2020
+@@ -0,0 +1,181 @@
++</$objtype/mkfile
++
++CC=pcc
++CFLAGS=-Iinclude -Isilk -Isilk/fixed -Isilk/float -Icelt \
++	-DPACKAGE_VERSION="$VERSION" \
++	-DOPUS_BUILD \
++	-DCUSTOM_MODES \
++	-DNONTHREADSAFE_PSEUDOSTACK \
++	-c
++LIB=libopus.a
++
++OFILES=\
++# silk \
++	CNG.$O \
++	code_signs.$O \
++	init_decoder.$O \
++	decode_core.$O \
++	decode_frame.$O \
++	decode_parameters.$O \
++	decode_indices.$O \
++	decode_pulses.$O \
++	decoder_set_fs.$O \
++	dec_API.$O \
++	enc_API.$O \
++	encode_indices.$O \
++	encode_pulses.$O \
++	gain_quant.$O \
++	interpolate.$O \
++	LP_variable_cutoff.$O \
++	NLSF_decode.$O \
++	NSQ.$O \
++	NSQ_del_dec.$O \
++	PLC.$O \
++	shell_coder.$O \
++	tables_gain.$O \
++	tables_LTP.$O \
++	tables_NLSF_CB_NB_MB.$O \
++	tables_NLSF_CB_WB.$O \
++	tables_other.$O \
++	tables_pitch_lag.$O \
++	tables_pulses_per_block.$O \
++	VAD.$O \
++	control_audio_bandwidth.$O \
++	quant_LTP_gains.$O \
++	VQ_WMat_EC.$O \
++	HP_variable_cutoff.$O \
++	NLSF_encode.$O \
++	NLSF_VQ.$O \
++	NLSF_unpack.$O \
++	NLSF_del_dec_quant.$O \
++	process_NLSFs.$O \
++	stereo_LR_to_MS.$O \
++	stereo_MS_to_LR.$O \
++	check_control_input.$O \
++	control_SNR.$O \
++	init_encoder.$O \
++	control_codec.$O \
++	A2NLSF.$O \
++	ana_filt_bank_1.$O \
++	biquad_alt.$O \
++	bwexpander_32.$O \
++	bwexpander.$O \
++	debug.$O \
++	decode_pitch.$O \
++	inner_prod_aligned.$O \
++	lin2log.$O \
++	log2lin.$O \
++	LPC_analysis_filter.$O \
++	LPC_inv_pred_gain.$O \
++	table_LSF_cos.$O \
++	NLSF2A.$O \
++	NLSF_stabilize.$O \
++	NLSF_VQ_weights_laroia.$O \
++	pitch_est_tables.$O \
++	resampler.$O \
++	resampler_down2_3.$O \
++	resampler_down2.$O \
++	resampler_private_AR2.$O \
++	resampler_private_down_FIR.$O \
++	resampler_private_IIR_FIR.$O \
++	resampler_private_up2_HQ.$O \
++	resampler_rom.$O \
++	sigm_Q15.$O \
++	sort.$O \
++	sum_sqr_shift.$O \
++	stereo_decode_pred.$O \
++	stereo_encode_pred.$O \
++	stereo_find_predictor.$O \
++	stereo_quant_pred.$O \
++	LPC_fit.$O \
++# silk/float \
++	apply_sine_window_FLP.$O \
++	corrMatrix_FLP.$O \
++	encode_frame_FLP.$O \
++	find_LPC_FLP.$O \
++	find_LTP_FLP.$O \
++	find_pitch_lags_FLP.$O \
++	find_pred_coefs_FLP.$O \
++	LPC_analysis_filter_FLP.$O \
++	LTP_analysis_filter_FLP.$O \
++	LTP_scale_ctrl_FLP.$O \
++	noise_shape_analysis_FLP.$O \
++	process_gains_FLP.$O \
++	regularize_correlations_FLP.$O \
++	residual_energy_FLP.$O \
++	warped_autocorrelation_FLP.$O \
++	wrappers_FLP.$O \
++	autocorrelation_FLP.$O \
++	burg_modified_FLP.$O \
++	bwexpander_FLP.$O \
++	energy_FLP.$O \
++	inner_product_FLP.$O \
++	k2a_FLP.$O \
++	LPC_inv_pred_gain_FLP.$O \
++	pitch_analysis_core_FLP.$O \
++	scale_copy_vector_FLP.$O \
++	scale_vector_FLP.$O \
++	schur_FLP.$O \
++	sort_FLP.$O \
++# celt \
++	bands.$O \
++	celt.$O \
++	celt_encoder.$O \
++	celt_decoder.$O \
++	cwrs.$O \
++	entcode.$O \
++	entdec.$O \
++	entenc.$O \
++	kiss_fft.$O \
++	laplace.$O \
++	mathops.$O \
++	mdct.$O \
++	modes.$O \
++	pitch.$O \
++	celt_lpc.$O \
++	quant_bands.$O \
++	rate.$O \
++	vq.$O \
++# src \
++	analysis.$O \
++	mlp.$O \
++	mlp_data.$O \
++	opus.$O \
++	opus_decoder.$O \
++	opus_encoder.$O \
++	opus_multistream.$O \
++	opus_multistream_encoder.$O \
++	opus_multistream_decoder.$O \
++	repacketizer.$O \
++	opus_projection_encoder.$O \
++	opus_projection_decoder.$O \
++	mapping_matrix.$O
++
++
++</sys/src/cmd/mklib
++
++LIBDIR=/$objtype/lib/ape
++
++%.$O:	silk/%.c
++	$CC $CFLAGS silk/$stem.c
++
++%.$O:	silk/fixed/%.c
++	$CC $CFLAGS silk/fixed/$stem.c
++
++%.$O:	silk/float/%.c
++	$CC $CFLAGS silk/float/$stem.c
++
++%.$O:	celt/%.c
++	$CC $CFLAGS celt/$stem.c
++
++%.$O:	src/%.c
++	$CC $CFLAGS src/$stem.c
++
++installheaders:V:
++	mkdir -p /sys/include/ape/opus
++	dircp include /sys/include/ape/opus
++
++install:VQ:	installheaders
++
++uninstall:V:
++	rm -rf $LIBDIR/$LIB /sys/include/ape/opus
--- /dev/null
+++ b/opus-tools
@@ -1,0 +1,140 @@
+--- /dev/null	Wed Dec 11 10:26:09 2019
++++ mkfile	Sat Jan 11 02:50:28 2020
+@@ -0,0 +1,40 @@
++</$objtype/mkfile
++
++CC=pcc
++CFLAGS=-Iinclude \
++	-I/sys/src/cmd/audio/libogg \
++	-I /sys/include/ape/opus \
++	-D_POSIX_SOURCE \
++	-D__GNU_LIBRARY__ \
++	-D_C99_SNPRINTF_EXTENSION \
++	-DSPX_RESAMPLE_EXPORT= -DRANDOM_PREFIX=opustools -DOUTSIDE_SPEEX \
++	-DRESAMPLE_FULL_SINC_TABLE -DOPUSTOOLS \
++	-DPACKAGE_NAME="opus-tools" -DPACKAGE_VERSION="fuckoff" \
++	-c
++
++TARG=opusdec opusenc opusinfo
++BIN=/$objtype/bin/audio
++
++LIB=\
++	/$objtype/lib/ape/libopusfile.a \
++	/$objtype/lib/ape/libopusenc.a \
++	/$objtype/lib/ape/libopus.a \
++
++
++</sys/src/cmd/mkmany
++
++%.$O:	src/%.c
++	$CC $CFLAGS $prereq
++
++%.$O:	share/%.c
++	$CC $CFLAGS $prereq
++
++COMMON=opus_header.$O resample.$O getopt.$O getopt1.$O
++
++$O.opusdec: opusdec.$O wav_io.$O wave_out.$O  diag_range.$O $COMMON
++$O.opusenc: opusenc.$O audio-in.$O diag_range.$O flac.$O picture.$O $COMMON
++$O.opusinfo: opusinfo.$O info_opus.$O picture.$O $COMMON
++
++uninstall:V:
++	for (i in $TARG)
++		rm -f $BIN/$i
+--- /mnt/git/branch/heads/test3-appveyor/tree/src/audio-in.c	Mon Sep  9 09:24:16 2019
++++ src/audio-in.c	Sat Jan 11 00:28:31 2020
+@@ -718,7 +718,11 @@ long wav_read(void *in, float *buffer, i
+     int sampbyte = f->samplesize / 8;
+     int realsamples = f->totalsamples > 0 && samples > (f->totalsamples - f->samplesread)
+         ? (int)(f->totalsamples - f->samplesread) : samples;
+-    signed char *buf = alloca(realsamples*sampbyte*f->channels);
++    signed char *buf = malloc(realsamples*sampbyte*f->channels);
++    if(buf == NULL){
++        fprintf(stderr, "allocation failure\n");
++        return 0;
++    }
+     int i,j;
+     int *ch_permute = f->channel_permute;
+ 
+@@ -790,17 +794,20 @@ long wav_read(void *in, float *buffer, i
+             }
+         }
+         else {
++            free(buf);
+             fprintf(stderr, _("Big endian 24 bit PCM data is not currently "
+                               "supported, aborting.\n"));
+             return 0;
+         }
+     }
+     else {
++        free(buf);
+         fprintf(stderr, _("Internal error: attempt to read unsupported "
+                           "bitdepth %d\n"), f->samplesize);
+         return 0;
+     }
+ 
++    free(buf);
+     return realsamples;
+ }
+ 
+@@ -809,9 +816,14 @@ long wav_ieee_read(void *in, float *buff
+     wavfile *f = (wavfile *)in;
+     int realsamples = f->totalsamples > 0 && samples > (f->totalsamples - f->samplesread)
+         ? (int)(f->totalsamples - f->samplesread) : samples;
+-    float *buf = alloca(realsamples*4*f->channels); /* de-interleave buffer */
++    float *buf = malloc(realsamples*4*f->channels); /* de-interleave buffer */
+     int i,j;
+ 
++    if(buf == NULL){
++        fprintf(stderr, "allocation failure\n");
++        return 0;
++    }
++
+     realsamples = (int)fread(buf, 4*f->channels, realsamples, f->f);
+     f->samplesread += realsamples;
+ 
+@@ -819,6 +831,7 @@ long wav_ieee_read(void *in, float *buff
+         for (j=0; j < f->channels; j++)
+             buffer[i*f->channels+j] = get_le_float(buf + i*f->channels + f->channel_permute[j]);
+ 
++    free(buf);
+     return realsamples;
+ }
+ 
+--- /mnt/git/branch/heads/test3-appveyor/tree/src/opusdec.c	Mon Sep  9 09:24:16 2019
++++ src/opusdec.c	Sat Jan 11 02:51:09 2020
+@@ -494,8 +494,12 @@ opus_int64 audio_write(float *pcm, int c
+    short *out;
+    float *buf;
+    float *output;
+-   out=alloca(sizeof(short)*MAX_FRAME_SIZE*channels);
+-   buf=alloca(sizeof(float)*MAX_FRAME_SIZE*channels);
++   out=malloc(sizeof(short)*MAX_FRAME_SIZE*channels);
++   buf=malloc(sizeof(float)*MAX_FRAME_SIZE*channels);
++   if(out == NULL || buf == NULL){
++      fprintf(stderr, "allocation failure\n");
++      return 0;
++   }
+    maxout=((link_read/48000)*rate + (link_read%48000)*rate/48000) - link_out;
+    maxout=maxout<0?0:maxout;
+    do {
+@@ -561,6 +565,8 @@ opus_int64 audio_write(float *pcm, int c
+        maxout-=ret;
+      }
+    } while (frame_size>0 && maxout>0);
++   free(buf);
++   free(out);
+    return sampout;
+ }
+ 
+@@ -848,8 +854,8 @@ int main(int argc, char **argv)
+    }
+    else
+    {
+-      st=op_open_url(inFile,NULL,NULL);
+-      if (st==NULL)
++      //st=op_open_url(inFile,NULL,NULL);
++      //if (st==NULL)
+       {
+          st=op_open_file(inFile,NULL);
+       }
--- /dev/null
+++ b/opusfile
@@ -1,0 +1,32 @@
+--- /dev/null	Wed Dec 11 10:26:09 2019
++++ mkfile	Sat Jan 11 01:08:03 2020
+@@ -0,0 +1,29 @@
++</$objtype/mkfile
++
++CC=pcc
++CFLAGS=-Iinclude \
++	-I/sys/src/cmd/audio/libogg \
++	-I/sys/include/ape/opus \
++	-DPACKAGE_VERSION="fuckoff" \
++	-D_POSIX_SOURCE \
++	-c
++LIB=libopusfile.a
++
++OFILES=\
++	info.$O \
++	internal.$O \
++	opusfile.$O \
++	stream.$O \
++
++</sys/src/cmd/mklib
++
++LIBDIR=/$objtype/lib/ape
++
++%.$O:	src/%.c
++	$CC $CFLAGS src/$stem.c
++
++installheaders:V:
++	mkdir -p /sys/include/ape/opus
++	dircp include /sys/include/ape/opus
++
++install:VQ:	installheaders