From e3166d73c6ae7652efe2c365ae4790f1e43984b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?=
 <lucio@lucioillanes.de>
Date: Sun, 5 Aug 2018 11:50:24 +0000
Subject: vars/build.vars:native_packages_deps: adds lib{xslt,theora}
 v{1.1.32,1.1.1} (via Redfoxmoon.) vars/build.vars:native_packages_inet: adds
 microsocks (HEAD) (via Redfoxmoon.) patches/lib{theora,xslt}*: via
 Redfoxmoon.

---
 patches/libtheora/fix-mmx.patch    | 31 ++++++++++++++++
 patches/libtheora/fix-sizeof.patch | 15 ++++++++
 patches/libtheora/fix-timeb.patch  | 75 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 patches/libtheora/fix-mmx.patch
 create mode 100644 patches/libtheora/fix-sizeof.patch
 create mode 100644 patches/libtheora/fix-timeb.patch

(limited to 'patches/libtheora')

diff --git a/patches/libtheora/fix-mmx.patch b/patches/libtheora/fix-mmx.patch
new file mode 100644
index 00000000..63fb9f76
--- /dev/null
+++ b/patches/libtheora/fix-mmx.patch
@@ -0,0 +1,31 @@
+http://bugs.alpinelinux.org/issues/6132
+https://trac.xiph.org/ticket/2287
+
+patch rebased for libtheory 1.1.1 stable
+
+diff -ru libtheora-1.1.1.orig/lib/encode.c libtheora-1.1.1/lib/encode.c
+--- libtheora-1.1.1.orig/lib/encode.c	2009-08-22 18:14:04.000000000 +0000
++++ libtheora-1.1.1/lib/encode.c	2016-09-15 05:27:02.065785527 +0000
+@@ -864,6 +864,9 @@
+ }
+ 
+ static void oc_enc_frame_pack(oc_enc_ctx *_enc){
++  /*musl libc malloc()/realloc() calls might use floating point, so make sure
++     we've cleared the MMX state for them.*/
++  oc_restore_fpu(&_enc->state);
+   oggpackB_reset(&_enc->opb);
+   /*Only proceed if we have some coded blocks.
+     If there are no coded blocks, we can drop this frame simply by emitting a
+diff -ru libtheora-1.1.1.orig/lib/decode.c libtheora-1.1.1/lib/decode.c
+--- libtheora-1.1.1.orig/lib/decode.c	2009-09-26 20:55:21.000000000 +0000
++++ libtheora-1.1.1/lib/decode.c	2016-09-15 05:29:45.912196850 +0000
+@@ -1181,6 +1181,9 @@
+ 
+ 
+ static int oc_dec_postprocess_init(oc_dec_ctx *_dec){
++  /*musl libc malloc()/realloc() calls might use floating point, so make sure
++     we've cleared the MMX state for them.*/
++  oc_restore_fpu(&_dec->state);
+   /*pp_level 0: disabled; free any memory used and return*/
+   if(_dec->pp_level<=OC_PP_LEVEL_DISABLED){
+     if(_dec->dc_qis!=NULL){
diff --git a/patches/libtheora/fix-sizeof.patch b/patches/libtheora/fix-sizeof.patch
new file mode 100644
index 00000000..e84685a1
--- /dev/null
+++ b/patches/libtheora/fix-sizeof.patch
@@ -0,0 +1,15 @@
+diff -ru libtheora-1.1.1.orig/examples/png2theora.c libtheora-1.1.1/examples/png2theora.c
+--- libtheora-1.1.1.orig/examples/png2theora.c	2009-08-22 20:14:04.000000000 +0200
++++ libtheora-1.1.1/examples/png2theora.c	2018-08-04 18:02:49.568313482 +0200
+@@ -462,9 +462,9 @@
+   png_set_strip_alpha(png_ptr);
+ 
+   row_data = (png_bytep)png_malloc(png_ptr,
+-    3*height*width*png_sizeof(*row_data));
++    3*height*width*sizeof(*row_data));
+   row_pointers = (png_bytep *)png_malloc(png_ptr,
+-    height*png_sizeof(*row_pointers));
++    height*sizeof(*row_pointers));
+   for(y = 0; y < height; y++) {
+     row_pointers[y] = row_data + y*(3*width);
+   }
diff --git a/patches/libtheora/fix-timeb.patch b/patches/libtheora/fix-timeb.patch
new file mode 100644
index 00000000..5344c075
--- /dev/null
+++ b/patches/libtheora/fix-timeb.patch
@@ -0,0 +1,75 @@
+--- libtheora-1.1.1.orig/examples/dump_psnr.c
++++ libtheora-1.1.1/examples/dump_psnr.c
+@@ -37,7 +37,6 @@
+ #endif
+ #include <stdlib.h>
+ #include <string.h>
+-#include <sys/timeb.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ /*Yes, yes, we're going to hell.*/
+--- libtheora-1.1.1.orig/examples/dump_video.c
++++ libtheora-1.1.1/examples/dump_video.c
+@@ -37,7 +37,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <sys/timeb.h>
++#include <sys/time.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ /*Yes, yes, we're going to hell.*/
+@@ -205,9 +205,9 @@
+   int long_option_index;
+   int c;
+ 
+-  struct timeb start;
+-  struct timeb after;
+-  struct timeb last;
++  struct timeval start;
++  struct timeval after;
++  struct timeval last;
+   int fps_only=0;
+   int frames = 0;
+ 
+@@ -418,8 +418,8 @@
+   }
+ 
+   if(fps_only){
+-    ftime(&start);
+-    ftime(&last);
++    gettimeofday(&start, NULL);
++    gettimeofday(&last, NULL);
+   }
+ 
+   while(!got_sigint){
+@@ -433,7 +433,7 @@
+           videobuf_ready=1;
+           frames++;
+           if(fps_only)
+-            ftime(&after);
++            gettimeofday(&after, NULL);
+         }
+ 
+       }else
+@@ -442,16 +442,16 @@
+ 
+     if(fps_only && (videobuf_ready || fps_only==2)){
+       long ms =
+-        after.time*1000.+after.millitm-
+-        (last.time*1000.+last.millitm);
++        after.tv_sec*1000.+after.tv_usec/1000-
++        (last.tv_sec*1000.+last.tv_usec/1000);
+ 
+       if(ms>500 || fps_only==1 ||
+          (feof(infile) && !videobuf_ready)){
+         float file_fps = (float)ti.fps_numerator/ti.fps_denominator;
+         fps_only=2;
+ 
+-        ms = after.time*1000.+after.millitm-
+-          (start.time*1000.+start.millitm);
++        ms = after.tv_sec*1000.+after.tv_usec/1000-
++          (start.tv_sec*1000.+start.tv_usec/1000);
+ 
+         fprintf(stderr,"\rframe:%d rate:%.2fx           ",
+                 frames,
-- 
cgit v1.2.3