shithub: libvpx

Download patch

ref: adcac7c03b086a56ba8d50de71b8c8c129509fe9
parent: 97356acb50e212fcfb7c91715718ec70953f780c
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Sep 16 11:09:33 EDT 2020

port to Plan 9, just enough to decode video with treason (also thanks to Uramekus for initial porting work)

--- a/.gitignore
+++ b/.gitignore
@@ -67,3 +67,5 @@
 /vpxenc
 /vpxenc.dox
 TAGS
+[a0125678vqki].out
+*.[ao0125678vqki]
--- a/args.c
+++ b/args.c
@@ -8,6 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
--- a/md5_utils.c
+++ b/md5_utils.c
@@ -20,6 +20,8 @@
  * Still in the public domain.
  */
 
+#include "vpx_config.h"
+
 #include <string.h> /* for memcpy() */
 
 #include "md5_utils.h"
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,257 @@
+</$objtype/mkfile
+
+LIB=libvpx.a
+
+CFLAGS=$CFLAGS -I. -Iplan9 -p -D__plan9__ -Dvolatile= -DNDEBUG
+
+OFILES=\
+	args.$O\
+	ivfdec.$O\
+	ivfenc.$O\
+	md5_utils.$O\
+	rate_hist.$O\
+	tools_common.$O\
+	video_reader.$O\
+	video_writer.$O\
+#	vpxdec.$O\
+#	vpxenc.$O\
+#	vpxstats.$O\
+	warnings.$O\
+	y4menc.$O\
+	y4minput.$O\
+# vp8/ \
+	vp8_cx_iface.$O\
+	vp8_dx_iface.$O\
+# vp8/common \
+	alloccommon.$O\
+	blockd.$O\
+	context.$O\
+	debugmodes.$O\
+	dequantize.$O\
+	entropy.$O\
+	entropymode.$O\
+	entropymv.$O\
+	extend.$O\
+	filter.$O\
+	findnearmv.$O\
+	idct_blk.$O\
+	idctllm.$O\
+	loopfilter_filters.$O\
+	mbpitch.$O\
+#	mfqe.$O\
+	modecont.$O\
+	postproc.$O\
+	quant_common.$O\
+	reconinter.$O\
+	reconintra.$O\
+	reconintra4x4.$O\
+	rtcd.$O\
+	setupintrarecon.$O\
+	swapyv12buffer.$O\
+	treecoder.$O\
+	vp8_loopfilter.$O\
+	vp8_skin_detection.$O\
+# vp8/common/generic \
+	systemdependent.$O\
+# vp8/decoder \
+	dboolhuff.$O\
+	decodeframe.$O\
+	decodemv.$O\
+	detokenize.$O\
+#	error_concealment.$O\
+	onyxd_if.$O\
+#	threading.$O\
+# vp8/encoder \
+	bitstream.$O\
+	boolhuff.$O\
+	copy_c.$O\
+	dct.$O\
+	denoising.$O\
+	encodeframe.$O\
+	encodeintra.$O\
+	encodemb.$O\
+	encodemv.$O\
+	ethreading.$O\
+	firstpass.$O\
+	lookahead.$O\
+	mcomp.$O\
+	modecosts.$O\
+#	mr_dissim.$O\
+	onyx_if.$O\
+	pickinter.$O\
+	picklpf.$O\
+	ratectrl.$O\
+	rdopt.$O\
+	segmentation.$O\
+	temporal_filter.$O\
+	tokenize.$O\
+	treewriter.$O\
+	vp8_quantize.$O\
+# vp9 \
+	vp9_cx_iface.$O\
+	vp9_dx_iface.$O\
+	vp9_iface_common.$O\
+# vp9/common \
+	vp9_alloccommon.$O\
+	vp9_blockd.$O\
+	vp9_common_data.$O\
+	vp9_debugmodes.$O\
+	vp9_entropy.$O\
+	vp9_entropymode.$O\
+	vp9_entropymv.$O\
+	vp9_filter.$O\
+	vp9_frame_buffers.$O\
+	vp9_idct.$O\
+	vp9_loopfilter.$O\
+#	vp9_mfqe.$O\
+	vp9_mvref_common.$O\
+#	vp9_postproc.$O\
+	vp9_pred_common.$O\
+	vp9_quant_common.$O\
+	vp9_reconinter.$O\
+	vp9_reconintra.$O\
+	vp9_rtcd.$O\
+	vp9_scale.$O\
+	vp9_scan.$O\
+	vp9_seg_common.$O\
+	vp9_thread_common.$O\
+	vp9_tile_common.$O\
+# vp9/decoder \
+	vp9_decodeframe.$O\
+	vp9_decodemv.$O\
+	vp9_decoder.$O\
+	vp9_detokenize.$O\
+	vp9_dsubexp.$O\
+	vp9_job_queue.$O\
+# vp9/encoder \
+	vp9_alt_ref_aq.$O\
+	vp9_aq_360.$O\
+	vp9_aq_complexity.$O\
+	vp9_aq_cyclicrefresh.$O\
+	vp9_aq_variance.$O\
+	vp9_bitstream.$O\
+	vp9_blockiness.$O\
+	vp9_context_tree.$O\
+	vp9_cost.$O\
+	vp9_dct.$O\
+	vp9_denoiser.$O\
+	vp9_encodeframe.$O\
+	vp9_encodemb.$O\
+	vp9_encodemv.$O\
+	vp9_encoder.$O\
+	vp9_ethread.$O\
+	vp9_extend.$O\
+	vp9_firstpass.$O\
+	vp9_frame_scale.$O\
+	vp9_lookahead.$O\
+	vp9_mbgraph.$O\
+	vp9_mcomp.$O\
+	vp9_multi_thread.$O\
+	vp9_noise_estimate.$O\
+	vp9_non_greedy_mv.$O\
+	vp9_picklpf.$O\
+	vp9_pickmode.$O\
+	vp9_quantize.$O\
+	vp9_ratectrl.$O\
+	vp9_rd.$O\
+	vp9_rdopt.$O\
+	vp9_resize.$O\
+	vp9_segmentation.$O\
+	vp9_skin_detection.$O\
+	vp9_speed_features.$O\
+	vp9_subexp.$O\
+	vp9_svc_layercontext.$O\
+	vp9_temporal_filter.$O\
+	vp9_tokenize.$O\
+	vp9_treewriter.$O\
+# vpx/src \
+	vpx_codec.$O\
+	vpx_decoder.$O\
+	vpx_encoder.$O\
+	vpx_image.$O\
+# vpx_dsp/ \
+	add_noise.$O\
+	avg.$O\
+	bitreader.$O\
+	bitreader_buffer.$O\
+	bitwriter.$O\
+	bitwriter_buffer.$O\
+	deblock.$O\
+	fastssim.$O\
+	fwd_txfm.$O\
+	intrapred.$O\
+	inv_txfm.$O\
+	loopfilter.$O\
+	prob.$O\
+	psnr.$O\
+	psnrhvs.$O\
+	quantize.$O\
+	sad.$O\
+	skin_detection.$O\
+	ssim.$O\
+	subtract.$O\
+	sum_squares.$O\
+	variance.$O\
+	vpx_convolve.$O\
+	vpx_dsp_rtcd.$O\
+# vpx_mem/ \
+	vpx_mem.$O\
+# vpx_scale/ \
+	vpx_scale_rtcd.$O\
+# vpx_scale/generic \
+	gen_scalers.$O\
+	vpx_scale.$O\
+	yv12config.$O\
+	yv12extend.$O\
+# vpx_util/ \
+	vpx_debug_util.$O\
+	vpx_thread.$O\
+	vpx_write_yuv_frame.$O\
+# plan9/ \
+	plan9.$O\
+
+UPDATE=\
+	mkfile\
+	$HFILES\
+	${OFILES:%.$O=%.c}\
+	${TARG:%=%.c}\
+	${LIB}\
+
+</sys/src/cmd/mklib
+
+%.$O: %.c
+	$CC $CFLAGS $stem.c
+%.$O: plan9/%.c
+	$CC $CFLAGS plan9/$stem.c
+%.$O: vp8/%.c
+	$CC $CFLAGS vp8/$stem.c
+%.$O: vp8/common/%.c
+	$CC $CFLAGS vp8/common/$stem.c
+%.$O: vp8/common/generic/%.c
+	$CC $CFLAGS vp8/common/generic/$stem.c
+%.$O: vp8/decoder/%.c
+	$CC $CFLAGS vp8/decoder/$stem.c
+%.$O: vp8/encoder/%.c
+	$CC $CFLAGS vp8/encoder/$stem.c
+%.$O: vp9/%.c
+	$CC $CFLAGS vp9/$stem.c
+%.$O: vp9/common/%.c
+	$CC $CFLAGS vp9/common/$stem.c
+%.$O: vp9/decoder/%.c
+	$CC $CFLAGS vp9/decoder/$stem.c
+%.$O: vp9/encoder/%.c
+	$CC $CFLAGS vp9/encoder/$stem.c
+%.$O: vpx/%.c
+	$CC $CFLAGS vpx/$stem.c
+%.$O: vpx/src/%.c
+	$CC $CFLAGS vpx/src/$stem.c
+%.$O: vpx_dsp/%.c
+	$CC $CFLAGS vpx_dsp/$stem.c
+%.$O: vpx_mem/%.c
+	$CC $CFLAGS vpx_mem/$stem.c
+%.$O: vpx_scale/%.c
+	$CC $CFLAGS vpx_scale/$stem.c
+%.$O: vpx_scale/generic/%.c
+	$CC $CFLAGS vpx_scale/generic/$stem.c
+%.$O: vpx_util/%.c
+	$CC $CFLAGS vpx_util/$stem.c
--- /dev/null
+++ b/plan9/assert.h
@@ -1,0 +1,1 @@
+
--- /dev/null
+++ b/plan9/plan9.c
@@ -1,0 +1,50 @@
+#include <u.h>
+#include <libc.h>
+#include <tos.h>
+
+struct timeval {
+	long tv_sec;
+	long tv_usec;
+};
+
+static uvlong
+nanosec(void)
+{
+	static uvlong fasthz, xstart;
+	uvlong x, div;
+
+	if(fasthz == ~0ULL)
+		return nsec() - xstart;
+
+	if(fasthz == 0){
+		if((fasthz = _tos->cyclefreq) == 0){
+			fasthz = ~0ULL;
+			xstart = nsec();
+			fprint(2, "cyclefreq not available, falling back to nsec()\n");
+			fprint(2, "you might want to disable aux/timesync\n");
+			return 0;
+		}else{
+			cycles(&xstart);
+		}
+	}
+	cycles(&x);
+	x -= xstart;
+
+	/* this is ugly */
+	for(div = 1000000000ULL; x < 0x1999999999999999ULL && div > 1 ; div /= 10ULL, x *= 10ULL);
+
+	return x / (fasthz / div);
+}
+
+int
+gettimeofday(struct timeval *tp, struct timezone *tzp)
+{
+	long long t;
+
+	USED(tzp);
+	t = nanosec();
+	tp->tv_sec = t / 1000000000ULL;
+	tp->tv_usec = (t / 1000ULL)%1000000ULL;
+
+	return 0;
+}
--- a/rate_hist.c
+++ b/rate_hist.c
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <math.h>
 
+#include "vpx_config.h"
 #include "./rate_hist.h"
 
 #define RATE_BINS 100
--- a/vp8/common/blockd.c
+++ b/vp8/common/blockd.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "blockd.h"
 #include "vpx_mem/vpx_mem.h"
 
--- a/vp8/common/context.c
+++ b/vp8/common/context.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "entropy.h"
 
 /* *** GENERATED FILE: DO NOT EDIT *** */
--- a/vp8/common/debugmodes.c
+++ b/vp8/common/debugmodes.c
@@ -9,6 +9,7 @@
  */
 
 #include <stdio.h>
+#include "vpx_config.h"
 #include "blockd.h"
 
 void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols,
--- a/vp8/common/entropy.c
+++ b/vp8/common/entropy.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "entropy.h"
 #include "blockd.h"
 #include "onyxc_int.h"
--- a/vp8/common/mbpitch.c
+++ b/vp8/common/mbpitch.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "blockd.h"
 
 void vp8_setup_block_dptrs(MACROBLOCKD *x) {
--- a/vp8/common/modecont.c
+++ b/vp8/common/modecont.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "entropy.h"
 
 const int vp8_mode_contexts[6][4] = {
--- a/vp8/common/quant_common.c
+++ b/vp8/common/quant_common.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "quant_common.h"
 
 static const int dc_qlookup[QINDEX_RANGE] = {
--- a/vp8/common/treecoder.c
+++ b/vp8/common/treecoder.c
@@ -11,6 +11,7 @@
 #include <assert.h>
 #include <stdio.h>
 
+#include "vpx_config.h"
 #include "vp8/common/treecoder.h"
 #include "vpx/vpx_integer.h"
 
--- a/vp8/decoder/detokenize.c
+++ b/vp8/decoder/detokenize.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "vp8/common/blockd.h"
 #include "onyxd_int.h"
 #include "vpx_mem/vpx_mem.h"
--- a/vp8/encoder/modecosts.c
+++ b/vp8/encoder/modecosts.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "vp8/common/blockd.h"
 #include "modecosts.h"
 #include "onyx_int.h"
--- a/vp8/encoder/segmentation.c
+++ b/vp8/encoder/segmentation.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "segmentation.h"
 #include "vpx_mem/vpx_mem.h"
 
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -206,6 +206,7 @@
 
   PARTITION_TYPE *partition;
 } MACROBLOCKD;
+#pragma incomplete MACROBLOCKD
 
 static INLINE PLANE_TYPE get_plane_type(int plane) {
   return (PLANE_TYPE)(plane > 0);
--- a/vp9/common/vp9_frame_buffers.c
+++ b/vp9/common/vp9_frame_buffers.c
@@ -10,6 +10,7 @@
 
 #include <assert.h>
 
+#include "vpx_config.h"
 #include "vp9/common/vp9_frame_buffers.h"
 #include "vpx_mem/vpx_mem.h"
 
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -12,6 +12,8 @@
 #include <stdio.h>
 #include <limits.h>
 
+#include "vpx_config.h"
+
 #include "vpx/vpx_encoder.h"
 #include "vpx_dsp/bitwriter_buffer.h"
 #include "vpx_dsp/vpx_dsp_common.h"
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1901,7 +1901,7 @@
   return enc_cfg;
 }
 
-static vp9_extracfg get_extra_cfg() {
+static vp9_extracfg get_extra_cfg(void) {
   vp9_extracfg extra_cfg = default_extra_cfg;
   return extra_cfg;
 }
--- a/vpx/src/vpx_codec.c
+++ b/vpx/src/vpx_codec.c
@@ -14,6 +14,7 @@
  */
 #include <stdarg.h>
 #include <stdlib.h>
+#include "vpx_config.h"
 #include "vpx/vpx_integer.h"
 #include "vpx/internal/vpx_codec_internal.h"
 #include "vpx_version.h"
--- a/vpx/src/vpx_decoder.c
+++ b/vpx/src/vpx_decoder.c
@@ -13,6 +13,7 @@
  *
  */
 #include <string.h>
+#include "vpx_config.h"
 #include "vpx/internal/vpx_codec_internal.h"
 
 #define SAVE_STATUS(ctx, var) (ctx ? (ctx->err = var) : var)
--- a/vpx/src/vpx_encoder.c
+++ b/vpx/src/vpx_encoder.c
@@ -16,6 +16,7 @@
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#include "vpx_config.h"
 #include "vp8/common/blockd.h"
 #include "vpx_config.h"
 #include "vpx/internal/vpx_codec_internal.h"
@@ -180,8 +181,8 @@
   while (0)
 
 #else
-static void FLOATING_POINT_INIT() {}
-static void FLOATING_POINT_RESTORE() {}
+static void FLOATING_POINT_INIT(void) {}
+static void FLOATING_POINT_RESTORE(void) {}
 #endif
 
 vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
--- a/vpx/vpx_codec.h
+++ b/vpx/vpx_codec.h
@@ -175,6 +175,7 @@
  * implementation. This structure is opaque to the application.
  */
 typedef const struct vpx_codec_iface vpx_codec_iface_t;
+#pragma incomplete vpx_codec_iface_t
 
 /*!\brief Codec private data structure.
  *
@@ -212,6 +213,7 @@
   } config;               /**< Configuration pointer aliasing union */
   vpx_codec_priv_t *priv; /**< Algorithm private storage */
 } vpx_codec_ctx_t;
+#pragma incomplete vpx_codec_ctx_t
 
 /*!\brief Bit depth for codec
  * *
--- a/vpx_ports/mem.h
+++ b/vpx_ports/mem.h
@@ -19,7 +19,9 @@
 #elif defined(_MSC_VER)
 #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val
 #else
+#ifndef __plan9__
 #warning No alignment directives known for this compiler.
+#endif
 #define DECLARE_ALIGNED(n, typ, val) typ val
 #endif
 
--- a/vpx_util/vpx_thread.c
+++ b/vpx_util/vpx_thread.c
@@ -141,7 +141,7 @@
 #endif
 }
 
-static void end(VPxWorker *const worker) {
+static void end_(VPxWorker *const worker) {
 #if CONFIG_MULTITHREAD
   if (worker->impl_ != NULL) {
     change_state(worker, NOT_OK);
@@ -161,7 +161,7 @@
 //------------------------------------------------------------------------------
 
 static VPxWorkerInterface g_worker_interface = { init,   reset,   sync,
-                                                 launch, execute, end };
+                                                 launch, execute, end_ };
 
 int vpx_set_worker_interface(const VPxWorkerInterface *const winterface) {
   if (winterface == NULL || winterface->init == NULL ||
--- a/warnings.c
+++ b/warnings.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "vpx_config.h"
 #include "./warnings.h"
 
 #include <assert.h>
--- a/y4minput.c
+++ b/y4minput.c
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "vpx_config.h"
 #include "vpx/vpx_integer.h"
 #include "y4minput.h"