ref: 1b42fbe6763010ce59047348f67ba9b6f64f24ac
parent: c60e0203169777f518c0cd4a9134626bd5ca400b
author: qwx <[email protected]>
date: Mon Mar 6 17:16:22 EST 2023
remove opus patches: forked
--- a/libopusenc
+++ /dev/null
@@ -1,43 +1,0 @@
-diff 43779464dc7717b9211057df70d3caf5c904592c uncommitted
---- /tmp/diff100000206984
-+++ b/mkfile
-@@ -0,0 +1,39 @@
-+APE=/sys/src/ape
-+<$APE/config
-+
-+LIB=/$objtype/lib/ape/libopusenc.a
-+
-+OFILES=\
-+ ogg_packer.$O \
-+ opus_header.$O \
-+ opusenc.$O \
-+ picture.$O \
-+ resample.$O \
-+ unicode_support.$O \
-+
-+HFILES=\
-+ /sys/include/ape/opus/opusenc.h \
-+
-+UPDATE=\
-+ mkfile\
-+ $HFILES\
-+ ${OFILES:%.$O=%.c}\
-+
-+</sys/src/cmd/mksyslib
-+
-+CFLAGS=$CFLAGS -c \
-+ -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
-+
-+%.$O: src/%.c
-+ $CC $CFLAGS src/$stem.c
-+
-+$HFILES:
-+ mkdir -p /sys/include/ape/opus
-+ dircp include /sys/include/ape/opus
--- a/opus
+++ /dev/null
@@ -1,232 +1,0 @@
-diff a8e6a77c5fe0c37aa6788f939f24f8cd22ae2652 uncommitted
---- a/celt/stack_alloc.h
-+++ b/celt/stack_alloc.h
-@@ -140,7 +140,7 @@
-
- #else
-
--#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
-+#define ALIGN(stack, size) ((stack) += ((size) - (_intptr_t)(stack)) & ((size) - 1))
- #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeof(char))))
- #if 0 /* Set this to 1 to instrument pseudostack usage */
- #define RESTORE_STACK (printf("%ld %s:%d\n", global_stack-scratch_ptr, __FILE__, __LINE__),global_stack = _saved_stack)
---- /tmp/fuckyoutoo
-+++ mkfile
-@@ -0,0 +1,187 @@
-+APE=/sys/src/ape
-+<$APE/config
-+
-+LIB=/$objtype/lib/ape/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
-+
-+HFILES=\
-+ /sys/include/ape/opus/opus.h \
-+ /sys/include/ape/opus/opus_custom.h \
-+ /sys/include/ape/opus/opus_defines.h \
-+ /sys/include/ape/opus/opus_multistream.h \
-+ /sys/include/ape/opus/opus_projection.h \
-+ /sys/include/ape/opus/opus_types.h \
-+
-+UPDATE=\
-+ mkfile\
-+ $HFILES\
-+ ${OFILES:%.$O=%.c}\
-+
-+</sys/src/cmd/mksyslib
-+
-+CFLAGS=$CFLAGS -c -Iinclude -Isilk -Isilk/fixed -Isilk/float -Icelt \
-+ -DPACKAGE_VERSION="$VERSION" \
-+ -DOPUS_BUILD \
-+ -DCUSTOM_MODES \
-+ -DNONTHREADSAFE_PSEUDOSTACK \
-+ -DHAVE_STDINT_H
-+
-+%.$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
-+
-+$HFILES:
-+ mkdir -p /sys/include/ape/opus
-+ dircp include /sys/include/ape/opus
---- a/silk/LPC_inv_pred_gain.c
-+++ b/silk/LPC_inv_pred_gain.c
-@@ -45,7 +45,7 @@
- )
- {
- opus_int k, n, mult2Q;
-- opus_int32 invGain_Q30, rc_Q31, rc_mult1_Q30, rc_mult2, tmp1, tmp2;
-+ opus_int32 invGain_Q30, rc_Q31, rc_mult1_Q30, rc_mult2, tmp1, tmp2, tmp3;
-
- invGain_Q30 = SILK_FIX_CONST( 1, 30 );
- for( k = order - 1; k > 0; k-- ) {
-@@ -80,14 +80,14 @@
- opus_int64 tmp64;
- tmp1 = A_QA[ n ];
- tmp2 = A_QA[ k - n - 1 ];
-- tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp1,
-- MUL32_FRAC_Q( tmp2, rc_Q31, 31 ) ), rc_mult2 ), mult2Q);
-+ tmp3 = silk_SUB_SAT32(tmp1, MUL32_FRAC_Q( tmp2, rc_Q31, 31 ) );
-+ tmp64 = silk_RSHIFT_ROUND64( silk_SMULL(tmp3, rc_mult2 ), mult2Q);
- if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) {
- return 0;
- }
- A_QA[ n ] = ( opus_int32 )tmp64;
-- tmp64 = silk_RSHIFT_ROUND64( silk_SMULL( silk_SUB_SAT32(tmp2,
-- MUL32_FRAC_Q( tmp1, rc_Q31, 31 ) ), rc_mult2), mult2Q);
-+ tmp3 = silk_SUB_SAT32(tmp2, MUL32_FRAC_Q( tmp1, rc_Q31, 31 ) );
-+ tmp64 = silk_RSHIFT_ROUND64( silk_SMULL(tmp3, rc_mult2), mult2Q);
- if( tmp64 > silk_int32_MAX || tmp64 < silk_int32_MIN ) {
- return 0;
- }
--- a/opus-tools
+++ /dev/null
@@ -1,153 +1,0 @@
-diff b982c4c784095dccb77f57169416e02a0cd9c81d uncommitted
---- /tmp/diff100000244624
-+++ b/mkfile
-@@ -0,0 +1,51 @@
-+APE=/sys/src/ape
-+<$APE/config
-+
-+TARG=opusdec opusenc opusinfo
-+BIN=/$objtype/bin/audio
-+
-+CFLAGS=$CFLAGS -c \
-+ -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"
-+
-+LIB=\
-+ /$objtype/lib/ape/libopusfile.a \
-+ /$objtype/lib/ape/libopusenc.a \
-+ /$objtype/lib/ape/libopus.a \
-+ /sys/src/cmd/audio/libogg/libogg.a$O \
-+
-+</sys/src/cmd/mkmany
-+
-+%.$O: src/%.c
-+ $CC $CFLAGS $prereq
-+
-+%.$O: share/%.c
-+ $CC $CFLAGS $prereq
-+
-+%.$O: /sys/src/cmd/audio/libogg/%.c
-+ $CC $CFLAGS $prereq
-+
-+OGG=`{cd /sys/src/cmd/audio/libogg; echo *.c}
-+OGG=${OGG:%.c=%.$O}
-+
-+/sys/src/cmd/audio/libogg/libogg.a$O: $OGG
-+ ar vu $target $OGG
-+
-+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 tagcompare.$O $COMMON
-+
-+CLEANFILES=`{$CLEANFILES echo /sys/src/cmd/audio/libogg/libogg.a[$OS]}
---- a/src/audio-in.c
-+++ b/src/audio-in.c
-@@ -721,7 +721,11 @@
- 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;
-
-@@ -809,9 +813,11 @@
- else {
- fprintf(stderr, _("Internal error: attempt to read unsupported "
- "bitdepth %d\n"), f->samplesize);
-+ free(buf);
- return 0;
- }
-
-+ free(buf);
- return realsamples;
- }
-
-@@ -820,9 +826,14 @@
- 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;
-
-@@ -839,6 +850,7 @@
- get_be_float(buf + i*f->channels + f->channel_permute[j]);
- }
-
-+ free(buf);
- return realsamples;
- }
-
---- a/src/opusdec.c
-+++ b/src/opusdec.c
-@@ -503,8 +503,12 @@
- 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 {
-@@ -570,6 +574,8 @@
- maxout-=ret;
- }
- } while (frame_size>0 && maxout>0);
-+ free(buf);
-+ free(out);
- return sampout;
- }
-
-@@ -857,8 +863,8 @@
- }
- 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);
- }
-@@ -1066,7 +1072,8 @@
- resampler=NULL;
- }
- /*We've encountered a new link.*/
-- link_read=link_out=0;
-+ link_read=0;
-+ link_out=0;
- head=op_head(st, li);
- if (!force_stereo && channels!=head->channel_count)
- {
--- a/opus-tools-defaults
+++ /dev/null
@@ -1,162 +1,0 @@
-diff 1d5e00558c79cf9a4266124d393cfbc879df7475 uncommitted
---- a/src/audio-in.c
-+++ b/src/audio-in.c
-@@ -671,8 +671,8 @@
- this length so that we do not misinterpret any additional
- chunks after this as audio. Also use this length to report
- percent progress. */
-- wav->totalsamples = opt->total_samples_per_channel =
-- len/(format.channels*samplesize);
-+ wav->totalsamples = len/(format.channels*samplesize);
-+ opt->total_samples_per_channel = wav->totalsamples;
- }
- else
- {
---- a/src/opusdec.c
-+++ b/src/opusdec.c
-@@ -445,27 +445,13 @@
- defined HAVE_SYS_AUDIOIO_H || defined WIN32 || defined _WIN32
- printf("Usage: opusdec [options] input [output]\n");
- #else
-- printf("Usage: opusdec [options] input output\n");
-+ printf("Usage: opusdec [options]\n");
- #endif
-- printf("\n");
-- printf("Decode audio in Opus format to Wave or raw PCM\n");
-- printf("\n");
-- printf("input can be:\n");
-- printf(" file:filename.opus Opus URL\n");
-- printf(" filename.opus Opus file\n");
-- printf(" - stdin\n");
-- printf("\n");
-- printf("output can be:\n");
-- printf(" filename.wav Wave file\n");
-- printf(" filename.* Raw PCM file (any extension other than .wav)\n");
-- printf(" - stdout (raw; unless --force-wav)\n");
- #if defined HAVE_LIBSNDIO || defined HAVE_SYS_SOUNDCARD_H || \
- defined HAVE_MACHINE_SOUNDCARD_H || defined HAVE_SOUNDCARD_H || \
- defined HAVE_SYS_AUDIOIO_H || defined WIN32 || defined _WIN32
- printf(" (default) Play audio\n");
- #endif
-- printf("\n");
-- printf("Options:\n");
- printf(" -h, --help Show this help\n");
- printf(" -V, --version Show version information\n");
- printf(" --quiet Suppress program output\n");
-@@ -477,7 +463,6 @@
- printf(" --force-wav Force Wave header on output\n");
- printf(" --packet-loss n Simulate n %% random packet loss\n");
- printf(" --save-range file Save check values for every frame to a file\n");
-- printf("\n");
- }
-
- void version(void)
-@@ -692,7 +677,7 @@
- int file_output;
- int old_li=-1;
- int li;
-- int quiet = 0;
-+ int quiet = 1;
- int forcewav = 0;
- ogg_int64_t nb_read_total=0;
- ogg_int64_t link_read=0;
-@@ -718,10 +703,10 @@
- float loss_percent=-1;
- float manual_gain=0;
- int force_rate=0;
-- int force_stereo=0;
-+ int force_stereo=1;
- int requested_channels=-1;
- int channels=-1;
-- int rate=0;
-+ int rate=44100;
- int wav_format=0;
- int dither=1;
- int fp=0;
-@@ -810,13 +795,7 @@
- goto done;
- }
- }
-- if (argc_utf8-optind!=2 && argc_utf8-optind!=1)
-- {
-- usage();
-- exit_code=1;
-- goto done;
-- }
-- inFile=argv_utf8[optind];
-+ inFile="-";
-
- /*Output to a file or playback?*/
- file_output=argc_utf8-optind==2;
-@@ -833,7 +812,7 @@
- }
- wav_format|=forcewav;
- } else {
-- outFile=NULL;
-+ outFile="-";
- wav_format=0;
- /*If playing to audio out, default the rate to 48000
- instead of the original rate. The original rate is
---- a/src/opusenc.c
-+++ b/src/opusenc.c
-@@ -117,20 +117,12 @@
-
- static void usage(void)
- {
-- printf("Usage: opusenc [options] input_file output_file.opus\n");
-- printf("\n");
-- printf("Encode audio using Opus.\n");
-+ printf("Usage: opusenc [options]\n");
- #if defined(HAVE_LIBFLAC)
- printf("The input format can be Wave, AIFF, FLAC, Ogg/FLAC, or raw PCM.\n");
- #else
- printf("The input format can be Wave, AIFF, or raw PCM.\n");
- #endif
-- printf("\ninput_file can be:\n");
-- printf(" filename.wav file\n");
-- printf(" - stdin\n");
-- printf("\noutput_file can be:\n");
-- printf(" filename.opus compressed file\n");
-- printf(" - stdout\n");
- printf("\nGeneral options:\n");
- printf(" -h, --help Show this help\n");
- printf(" -V, --version Show version information\n");
-@@ -431,7 +423,7 @@
- time_t last_spin=0;
- int last_spin_len=0;
- /*Settings*/
-- int quiet=0;
-+ int quiet=1;
- opus_int32 bitrate=-1;
- opus_int32 rate=48000;
- opus_int32 frame_size=960;
-@@ -474,12 +466,12 @@
- in_format=NULL;
- inopt.channels=chan;
- inopt.channels_format=CHANNELS_FORMAT_DEFAULT;
-- inopt.rate=rate;
-+ inopt.rate=44100;
- /* 0 dB gain is recommended unless you know what you're doing */
- inopt.gain=0;
- inopt.samplesize=16;
- inopt.endianness=0;
-- inopt.rawmode=0;
-+ inopt.rawmode=1;
- inopt.rawmode_f=0;
- inopt.ignorelength=0;
- inopt.copy_comments=1;
-@@ -827,12 +819,8 @@
- fatal("Invalid bit-depth:\n"
- "--raw-bits must be 32 for float sample format\n");
- }
-- if (argc_utf8-optind!=2) {
-- usage();
-- exit(1);
-- }
-- inFile=argv_utf8[optind];
-- outFile=argv_utf8[optind+1];
-+ inFile="-";
-+ outFile="-";
-
- if (cline_size > 0) {
- ret = ope_comments_add(inopt.comments, "ENCODER_OPTIONS", ENCODER_string);
--- a/opus-tools-seek
+++ /dev/null
@@ -1,71 +1,0 @@
---- opus-tools/src/opusdec.c 2022-10-11 16:35:05.577273603 +0200
-+++ opus-tools/src/opusdec.c 2022-10-18 01:42:38.276862173 +0200
-@@ -463,6 +463,7 @@
- printf(" --force-wav Force Wave header on output\n");
- printf(" --packet-loss n Simulate n %% random packet loss\n");
- printf(" --save-range file Save check values for every frame to a file\n");
-+ printf(" -s, --seek seconds Seek within the stream before decoding\n");
- }
-
- void version(void)
-@@ -682,6 +683,7 @@
- ogg_int64_t nb_read_total=0;
- ogg_int64_t link_read=0;
- ogg_int64_t link_out=0;
-+ double seek=0.0;
- struct option long_options[] =
- {
- {"help", no_argument, NULL, 0},
-@@ -696,6 +698,7 @@
- {"force-wav", no_argument, NULL, 0},
- {"packet-loss", required_argument, NULL, 0},
- {"save-range", required_argument, NULL, 0},
-+ {"seek", required_argument, NULL, 0},
- {0, 0, 0, 0}
- };
- opus_int64 audio_size=0;
-@@ -734,7 +737,7 @@
- /*Process options*/
- while (1)
- {
-- c = getopt_long(argc_utf8, argv_utf8, "hV",
-+ c = getopt_long(argc_utf8, argv_utf8, "hVs:",
- long_options, &option_index);
- if (c==-1)
- break;
-@@ -781,6 +784,9 @@
- } else if (strcmp(long_options[option_index].name,"packet-loss")==0)
- {
- loss_percent = atof(optarg);
-+ } else if (strcmp(long_options[option_index].name,"seek")==0)
-+ {
-+ seek = atof(optarg);
- }
- break;
- case 'h':
-@@ -789,6 +795,9 @@
- case 'V':
- version();
- goto done;
-+ case 's':
-+ seek = atof(optarg);
-+ break;
- case '?':
- usage();
- exit_code=1;
-@@ -999,6 +1008,14 @@
- op_set_decode_callback(st, (op_decode_cb_func)decode_cb, &cb_ctx);
- }
-
-+ if (seek > 0.0) {
-+ if (op_pcm_seek(st, seek*48000) != 0)
-+ {
-+ seek = 0.0;
-+ }
-+ fprintf(stderr, "time: %g\n", seek);
-+ }
-+
- /*Main decoding loop*/
- while (1)
- {
-
--- a/opusfile
+++ /dev/null
@@ -1,208 +1,0 @@
-diff 705fefe3be63402de65d74d8a3ff499a2e8b8cc5 uncommitted
---- /tmp/diff100000210759
-+++ b/mkfile
-@@ -0,0 +1,34 @@
-+APE=/sys/src/ape
-+<$APE/config
-+
-+LIB=/$objtype/lib/ape/libopusfile.a
-+
-+OFILES=\
-+ info.$O \
-+ internal.$O \
-+ opusfile.$O \
-+ stream.$O \
-+
-+HFILES=\
-+ /sys/include/ape/opus/opusfile.h \
-+
-+UPDATE=\
-+ mkfile\
-+ $HFILES\
-+ ${OFILES:%.$O=%.c}\
-+
-+</sys/src/cmd/mksyslib
-+
-+CFLAGS=$CFLAGS -c\
-+ -Iinclude \
-+ -I/sys/src/cmd/audio/libogg \
-+ -I/sys/include/ape/opus \
-+ -DPACKAGE_VERSION="fuckoff" \
-+ -D_POSIX_SOURCE
-+
-+%.$O: src/%.c
-+ $CC $CFLAGS src/$stem.c
-+
-+$HFILES:
-+ mkdir -p /sys/include/ape/opus
-+ dircp include /sys/include/ape/opus
---- a/src/opusfile.c
-+++ b/src/opusfile.c
-@@ -327,7 +327,9 @@
- opus_int64 original_end;
- opus_int32 chunk_size;
- int preferred_found;
-- original_end=end=begin=_offset;
-+ original_end=_offset;
-+ end=_offset;
-+ begin=_offset;
- preferred_found=0;
- _offset=-1;
- chunk_size=OP_CHUNK_SIZE;
-@@ -350,7 +352,8 @@
- We're not interested in the page itself... just the serial number, byte
- offset, page size, and granule position.*/
- _sr->search_start=search_start;
-- _sr->offset=_offset=llret;
-+ _sr->offset=llret;
-+ _offset=llret;
- _sr->serialno=serialno;
- OP_ASSERT(_of->offset-_offset>=0);
- OP_ASSERT(_of->offset-_offset<=OP_PAGE_SIZE_MAX);
-@@ -416,7 +419,9 @@
- opus_int32 chunk_size;
- /*The target serial number must belong to the current link.*/
- OP_ASSERT(op_lookup_serialno(_serialno,_serialnos,_nserialnos));
-- original_end=end=begin=_offset;
-+ begin=_offset;
-+ end=_offset;
-+ original_end=_offset;
- _offset=-1;
- /*We shouldn't have to initialize gp, but gcc is too dumb to figure out that
- ret>=0 implies we entered the if(page_gp!=-1) block at least once.*/
-@@ -859,7 +864,8 @@
- _link->pcm_file_offset=0;
- /*Set pcm_end and end_offset so we can skip the call to
- op_find_final_pcm_offset().*/
-- _link->pcm_start=_link->pcm_end=0;
-+ _link->pcm_start=0;
-+ _link->pcm_end=0;
- _link->end_offset=_link->data_offset;
- return 0;
- }
-@@ -869,7 +875,8 @@
- /*Set pcm_end and end_offset so we can skip the call to
- op_find_final_pcm_offset().*/
- _link->pcm_file_offset=0;
-- _link->pcm_start=_link->pcm_end=0;
-+ _link->pcm_start=0;
-+ _link->pcm_end=0;
- _link->end_offset=_link->data_offset;
- /*Tell the caller we've got a buffered page for them.*/
- return 1;
-@@ -939,7 +946,8 @@
- /*If we trimmed the entire packet, stop (the spec says encoders
- shouldn't do this, but we support it anyway).*/
- if(OP_UNLIKELY(diff>durations[pi]))break;
-- _of->op[pi].granulepos=prev_packet_gp=cur_page_gp;
-+ _of->op[pi].granulepos=cur_page_gp;
-+ prev_packet_gp=cur_page_gp;
- /*Move the EOS flag to this packet, if necessary, so we'll trim the
- samples.*/
- _of->op[pi].e_o_s=1;
-@@ -955,7 +963,8 @@
- _of->op_count=pi;
- _of->cur_discard_count=_link->head.pre_skip;
- _link->pcm_file_offset=0;
-- _of->prev_packet_gp=_link->pcm_start=pcm_start;
-+ _of->prev_packet_gp=pcm_start;
-+ _link->pcm_start=pcm_start;
- _of->prev_page_offset=page_offset;
- return 0;
- }
-@@ -1396,7 +1405,8 @@
- int ret;
- /*We can seek, so set out learning all about this file.*/
- (*_of->callbacks.seek)(_of->stream,0,SEEK_END);
-- _of->offset=_of->end=(*_of->callbacks.tell)(_of->stream);
-+ _of->offset=(*_of->callbacks.tell)(_of->stream);
-+ _of->end=(*_of->callbacks.tell)(_of->stream);
- if(OP_UNLIKELY(_of->end<0))return OP_EREAD;
- data_offset=_of->links[0].data_offset;
- if(OP_UNLIKELY(_of->end<data_offset))return OP_EBADLINK;
-@@ -2285,10 +2295,13 @@
- _of->bytes_tracked=0;
- _of->samples_tracked=0;
- link=_of->links+_li;
-- best_gp=pcm_start=link->pcm_start;
-+ best_gp=link->pcm_start;
-+ pcm_start=link->pcm_start;
- pcm_end=link->pcm_end;
- serialno=link->serialno;
-- best=best_start=begin=link->data_offset;
-+ best=link->data_offset;
-+ best_start=link->data_offset;
-+ begin=link->data_offset;
- page_offset=-1;
- buffering=0;
- /*We discard the first 80 ms of data after a seek, so seek back that much
-@@ -2301,9 +2314,12 @@
- /*Special case seeking to the start of the link.*/
- pre_skip=link->head.pre_skip;
- OP_ALWAYS_TRUE(!op_granpos_add(&pcm_pre_skip,pcm_start,pre_skip));
-- if(op_granpos_cmp(_target_gp,pcm_pre_skip)<0)end=boundary=begin;
-- else{
-- end=boundary=link->end_offset;
-+ if(op_granpos_cmp(_target_gp,pcm_pre_skip)<0){
-+ end=begin;
-+ boundary=begin;
-+ }else{
-+ end=link->end_offset;
-+ boundary=link->end_offset;
- #if !defined(OP_SMALL_FOOTPRINT)
- /*If we were decoding from this link, we can narrow the range a bit.*/
- if(_li==_of->cur_link&&_of->ready_state>=OP_INITSET){
-@@ -2338,8 +2354,10 @@
- first seek location gives better results, on average.*/
- if(diff<0){
- if(offset-begin>=end-begin>>1||diff>-OP_CUR_TIME_THRESH){
-- best=begin=offset;
-- best_gp=pcm_start=gp;
-+ best=offset;
-+ begin=offset;
-+ best_gp=gp;
-+ pcm_start=gp;
- /*If we have buffered data from a continued packet, remember the
- offset of the previous page's start, so that if we do wind up
- having to seek back here later, we can prime the stream with
-@@ -2389,7 +2407,8 @@
- Check if we can cut off at least half the range, though.*/
- if(offset-begin<=end-begin>>1||diff<OP_CUR_TIME_THRESH){
- /*We really want the page start here, but this will do.*/
-- end=boundary=offset;
-+ end=offset;
-+ boundary=offset;
- pcm_end=gp;
- }
- }
-@@ -2406,7 +2425,9 @@
- _of->cur_link=_li;
- _of->ready_state=OP_STREAMSET;
- /*Initialize the interval size history.*/
-- d2=d1=d0=end-begin;
-+ d0=end-begin;
-+ d1=d0;
-+ d2=d0;
- force_bisect=0;
- while(begin<end){
- opus_int64 bisect;
-@@ -2510,7 +2531,8 @@
- }
- /*Save the byte offset of the end of the page with this granule
- position.*/
-- best=best_start=begin;
-+ best=begin;
-+ best_start=begin;
- /*Buffer any data from a continued packet, if necessary.
- This avoids the need to seek back here if the next timestamp we
- encounter while scanning forward lies after our target.*/
-@@ -2526,7 +2548,8 @@
- /*Then force buffering on, so that if a packet starts (but does not
- end) on the next page, we still avoid the extra seek back.*/
- buffering=1;
-- best_gp=pcm_start=gp;
-+ best_gp=gp;
-+ pcm_start=gp;
- OP_ALWAYS_TRUE(!op_granpos_diff(&diff,_target_gp,pcm_start));
- /*If we're more than a second away from our target, break out and
- do another bisection.*/