ports/137907: [PATCH] audio/lame: upstream bugfix (ffmpeg)

Martin Matuska mm at FreeBSD.org
Tue Aug 18 07:20:02 UTC 2009


>Number:         137907
>Category:       ports
>Synopsis:       [PATCH] audio/lame: upstream bugfix (ffmpeg)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 18 07:20:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Martin Matuska
>Release:        FreeBSD 7.2-STABLE amd64
>Organization:
>Environment:
System: FreeBSD 7.2-STABLE 8.0-BETA2 FreeBSD i386/amd64
>Description:
Add upstream bugfix to work correctly with recent ffmpeg versions.
Patch backported from lame3_98 branch, diff between revisions 1.323.2.6 and 1.323.2.5.
CVS comment: workaround for FFMPEG bug, which uses to call lame_encode_flush more than once in loop

References:
https://roundup.ffmpeg.org/roundup/ffmpeg/issue803
http://sourceforge.net/tracker/?func=detail&aid=2553863&group_id=290&atid=100290
http://lame.cvs.sourceforge.net/viewvc/lame/lame/libmp3lame/lame.c?sortby=date&r1=1.323.2.5&r2=1.323.2.6&pathrev=lame3_98

Added file(s):
- files/patch-libmp3lame-lame.c

Port maintainer (netchild at FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
>Fix:

--- lame-3.98.2_2.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/audio/lame/Makefile,v
retrieving revision 1.50
diff -u -r1.50 Makefile
--- Makefile	2 Aug 2009 19:32:16 -0000	1.50
+++ Makefile	18 Aug 2009 07:14:51 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	lame
 PORTVERSION=	3.98.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	audio
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE} \
 		ftp://ftp.fu-berlin.de/unix/sound/%SUBDIR%/
Index: files/patch-libmp3lame-lame.c
===================================================================
RCS file: files/patch-libmp3lame-lame.c
diff -N files/patch-libmp3lame-lame.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-libmp3lame-lame.c	18 Aug 2009 07:14:51 -0000
@@ -0,0 +1,72 @@
+--- libmp3lame/lame.c.orig	2008-08-05 19:26:02.000000000 +0200
++++ libmp3lame/lame.c	2009-08-17 21:25:17.749630168 +0200
+@@ -1602,6 +1602,13 @@
+         /* update mfbuf[] counters */
+         gfc->mf_size += n_out;
+         assert(gfc->mf_size <= MFSIZE);
++
++        /* lame_encode_flush may have set gfc->mf_sample_to_encode to 0
++         * so we have to reinitialize it here when that happened.
++         */
++        if (gfc->mf_samples_to_encode < 1) {
++            gfc->mf_samples_to_encode = ENCDELAY + POSTDELAY;
++        }
+         gfc->mf_samples_to_encode += n_out;
+ 
+ 
+@@ -1931,6 +1938,10 @@
+     int     frames_left;
+     int     samples_to_encode = gfc->mf_samples_to_encode;
+ 
++    /* Was flush already called? */
++    if (gfc->mf_samples_to_encode < 1) {
++        return 0;
++    }
+     memset(buffer, 0, sizeof(buffer));
+     mp3count = 0;
+     
+@@ -1942,7 +1953,9 @@
+     end_padding += pad_out_samples;
+ 
+     frames_left = (samples_to_encode + pad_out_samples) / gfp->framesize;
+-    while (frames_left > 0) {
++
++    /* send in a frame of 0 padding until all internal sample buffers are flushed */
++    while (frames_left > 0 && imp3 >= 0) {
+         int frame_num = gfp->frameNum;
+ 
+         mp3buffer_size_remaining = mp3buffer_size - mp3count;
+@@ -1951,22 +1964,22 @@
+         if (mp3buffer_size == 0)
+             mp3buffer_size_remaining = 0;
+ 
+-        /* send in a frame of 0 padding until all internal sample buffers
+-         * are flushed
+-         */
+         imp3 = lame_encode_buffer(gfp, buffer[0], buffer[1], 32,
+                                   mp3buffer, mp3buffer_size_remaining);
+-        
+-        if (frame_num != gfp->frameNum) {
+-            --frames_left;
+-        }
+-        if (imp3 < 0) {
+-            /* some type of fatal error */
+-            return imp3;
+-        }
+         mp3buffer += imp3;
+         mp3count += imp3;
++	frames_left -= (frame_num != gfp->frameNum) ? 1 : 0;
+     }
++    /* Set gfc->mf_samples_to_encode to 0, so we may detect
++     * and break loops calling it more than once in a row.
++     */
++    gfc->mf_samples_to_encode = 0;
++
++    if (imp3 < 0) {
++        /* some type of fatal error */
++        return imp3;
++    }
++
+     mp3buffer_size_remaining = mp3buffer_size - mp3count;
+     /* if user specifed buffer size = 0, dont check size */
+     if (mp3buffer_size == 0)
--- lame-3.98.2_2.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list