git: 6ff68a8504ee - main - multimedia/replex: Fix Abort on decoding mpeg with clang builds

From: Dirk Meyer <dinoex_at_FreeBSD.org>
Date: Mon, 25 Apr 2022 08:43:41 UTC
The branch main has been updated by dinoex:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6ff68a8504ee1e1eb50d58990731be77df2960d3

commit 6ff68a8504ee1e1eb50d58990731be77df2960d3
Author:     Dirk Meyer <dinoex@FreeBSD.org>
AuthorDate: 2022-04-25 08:43:29 +0000
Commit:     Dirk Meyer <dinoex@FreeBSD.org>
CommitDate: 2022-04-25 08:43:29 +0000

    multimedia/replex: Fix Abort on decoding mpeg with clang builds
---
 multimedia/replex/Makefile                 |  3 +--
 multimedia/replex/files/patch-mpg_common.c | 15 ++++++++++++
 multimedia/replex/files/patch-pes.c        |  6 ++---
 multimedia/replex/files/patch-replex.c     | 38 ++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/multimedia/replex/Makefile b/multimedia/replex/Makefile
index bb0ba2da6b6b..4659b8b770c9 100644
--- a/multimedia/replex/Makefile
+++ b/multimedia/replex/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	replex
 PORTVERSION=	0.1.6.8
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	multimedia
 MASTER_SITES=	LOCAL/dinoex
@@ -21,8 +22,6 @@ PORTDOCS=	CHANGES README TODO
 .endif
 
 post-patch:
-	@${GREP} -lR "<stdint\.h>" ${WRKSRC} | ${XARGS} ${REINPLACE_CMD} -e \
-		's|<stdint\.h>|<inttypes.h>|g'
 	@${REINPLACE_CMD} -e 's|-m32||' -e \
 		's|-L. -lreplex|libreplex.a $${LIBS}|g' ${WRKSRC}/Makefile
 
diff --git a/multimedia/replex/files/patch-mpg_common.c b/multimedia/replex/files/patch-mpg_common.c
new file mode 100644
index 000000000000..9308c2ec3108
--- /dev/null
+++ b/multimedia/replex/files/patch-mpg_common.c
@@ -0,0 +1,15 @@
+--- mpg_common.c.orig	2007-06-19 09:30:08 UTC
++++ mpg_common.c
+@@ -73,8 +73,10 @@ void show_buf(uint8_t *buf, int length)
+                         else if (Data[i+2+offset]==0 && Data[i+3+offset]==1) \
+                                 return i+1+offset; \
+                 } \
+-                else if (x==1 && Data[i-1+offset]==0 && Data[i+offset]==0 && (i+offset)>0) \
+-                         return i-1+offset; \
++                else if (x==1 && (i+offset)>0) { \
++                        if (Data[i-1+offset]==0 && Data[i+offset]==0) \
++                                return i-1+offset; \
++                } \
+          }
+ 
+ int FindPacketHeader(const uint8_t *Data, int s, int l)
diff --git a/multimedia/replex/files/patch-pes.c b/multimedia/replex/files/patch-pes.c
index 4c95f268a38b..a5f51d86cd95 100644
--- a/multimedia/replex/files/patch-pes.c
+++ b/multimedia/replex/files/patch-pes.c
@@ -1,6 +1,6 @@
---- pes.c.orig	Sun Dec 28 17:57:19 2003
-+++ pes.c	Tue Jan 20 05:15:09 2004
-@@ -26,6 +26,7 @@
+--- pes.c.orig	2007-06-19 09:30:08 UTC
++++ pes.c
+@@ -28,6 +28,7 @@
  
  #include <stdlib.h>
  #include <stdio.h>
diff --git a/multimedia/replex/files/patch-replex.c b/multimedia/replex/files/patch-replex.c
new file mode 100644
index 000000000000..add60e554f9d
--- /dev/null
+++ b/multimedia/replex/files/patch-replex.c
@@ -0,0 +1,38 @@
+--- replex.c.orig	2007-06-19 09:30:08 UTC
++++ replex.c
+@@ -442,7 +442,7 @@ static int analyze_audio_loop( pes_in_t *p, struct rep
+ 			}
+ 
+ 			if( iu->err!= JUMP_ERR && !rx->keep_pts && diff > 40*CLOCK_MS){
+-					if (!rx->allow_jump || abs((int)diff) > rx->allow_jump){
++					if (!rx->allow_jump || labs((int)diff) > rx->allow_jump){
+ 						fprintf(stderr,"audio PTS inconsistent: ");
+ 						printpts(dpts);
+ 						printpts(iu->pts);
+@@ -698,7 +698,7 @@ void analyze_video( pes_in_t *p, struct replex *rx, in
+ 							       + newpts);
+ 						
+ 						if (rx->allow_jump &&  
+-						    abs(diff) > rx->allow_jump)
++						    labs(diff) > rx->allow_jump)
+ 						{
+ 							if (audio_jump(rx)){
+ 								fprintf(stderr,"AUDIO JUMPED\n");
+@@ -716,7 +716,7 @@ void analyze_video( pes_in_t *p, struct replex *rx, in
+ 						}
+ 
+ 						if (!rx->keep_pts &&
+-						    abs((int)(diff)) > 3*SEC_PER/2){
++						    labs((int)(diff)) > 3*SEC_PER/2){
+ 							fprintf(stderr,"video PTS inconsistent: ");
+ 							printpts(trans_pts_dts(p->pts));
+ 							printpts(iu->pts);
+@@ -735,7 +735,7 @@ void analyze_video( pes_in_t *p, struct replex *rx, in
+ 							       newdts + 
+ 							       rx->first_vpts); 
+ 						if (!rx->keep_pts && !keep_now &&
+-						    abs((int)diff) > 3*SEC_PER/2){
++						    labs((int)diff) > 3*SEC_PER/2){
+ 							fprintf(stderr,"video DTS inconsistent: ");
+ 							printpts(trans_pts_dts(p->dts));
+ 							printpts(iu->dts);