From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Jul 14 14:20:01 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F7C41065678 for ; Wed, 14 Jul 2010 14:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 113198FC0A for ; Wed, 14 Jul 2010 14:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o6EEK0pe074329 for ; Wed, 14 Jul 2010 14:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o6EEK0kN074328; Wed, 14 Jul 2010 14:20:00 GMT (envelope-from gnats) Resent-Date: Wed, 14 Jul 2010 14:20:00 GMT Resent-Message-Id: <201007141420.o6EEK0kN074328@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Matuska Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69F38106567E for ; Wed, 14 Jul 2010 14:19:05 +0000 (UTC) (envelope-from mm@mail2.vx.sk) Received: from mail2.vx.sk (neo.vx.sk [188.40.111.84]) by mx1.freebsd.org (Postfix) with ESMTP id D5FCB8FC13 for ; Wed, 14 Jul 2010 14:19:04 +0000 (UTC) Received: from neo.vx.sk (localhost [127.0.0.1]) by mail2.vx.sk (Postfix) with ESMTP id E5F636ED1E; Wed, 14 Jul 2010 16:19:03 +0200 (CEST) Received: from mail2.vx.sk ([127.0.0.1]) by neo.vx.sk (mail.vx.sk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gvsi4MoqNb0S; Wed, 14 Jul 2010 16:18:57 +0200 (CEST) Received: by mail2.vx.sk (Postfix, from userid 1001) id 85F976ED0E; Wed, 14 Jul 2010 16:18:57 +0200 (CEST) Message-Id: <20100714141857.85F976ED0E@mail2.vx.sk> Date: Wed, 14 Jul 2010 16:18:57 +0200 (CEST) From: Martin Matuska To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: fbsd@opal.com Subject: ports/148600: [PATCH] multimedia/qt-faststart: update to 0.2 X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2010 14:20:01 -0000 >Number: 148600 >Category: ports >Synopsis: [PATCH] multimedia/qt-faststart: update to 0.2 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Wed Jul 14 14:20:00 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Martin Matuska >Release: FreeBSD 8.1-RC2 amd64 >Organization: >Environment: System: FreeBSD neo.vx.sk 8.1-RC2 FreeBSD 8.1-RC2 #20 r209977M: Tue Jul 13 10:18:10 CEST >Description: - Update to svn rev 24237 (0.2), fixes several annoying bugs - Make portlint happier Port maintainer (fbsd@opal.com) is cc'd. Generated with FreeBSD Port Tools 0.99 >How-To-Repeat: >Fix: --- qt-faststart-0.2.patch begins here --- Index: Makefile =================================================================== RCS file: /home/pcvs/ports/multimedia/qt-faststart/Makefile,v retrieving revision 1.1 diff -u -r1.1 Makefile --- Makefile 31 Jan 2010 14:12:03 -0000 1.1 +++ Makefile 14 Jul 2010 14:17:18 -0000 @@ -6,9 +6,10 @@ # PORTNAME= qt-faststart -PORTVERSION= 0.1 +PORTVERSION= 0.2 CATEGORIES= multimedia -DISTFILES= +MASTER_SITES= #none +DISTFILES= #none MAINTAINER= fbsd@opal.com COMMENT= Convert QuickTime movie files to streamable format @@ -17,14 +18,13 @@ .include -do-fetch: - do-extract: ${MKDIR} ${WRKSRC} ${CP} ${FILESDIR}/${PORTNAME}.c ${WRKSRC} do-build: - cd ${WRKSRC}; ${CC} ${PORTNAME}.c -o ${PORTNAME} + cd ${WRKSRC} && \ + ${CC} ${CFLAGS} ${PORTNAME}.c -o ${PORTNAME} do-install: ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/bin Index: files/qt-faststart.c =================================================================== RCS file: /home/pcvs/ports/multimedia/qt-faststart/files/qt-faststart.c,v retrieving revision 1.1 diff -u -r1.1 qt-faststart.c --- files/qt-faststart.c 31 Jan 2010 14:12:03 -0000 1.1 +++ files/qt-faststart.c 14 Jul 2010 14:17:18 -0000 @@ -1,5 +1,5 @@ /* - * qt-faststart.c, v0.1 + * qt-faststart.c, v0.2 * by Mike Melanson (melanson@pcisys.net) * This file is placed in the public domain. Use the program however you * see fit. @@ -7,8 +7,12 @@ * This utility rearranges a Quicktime file such that the moov atom * is in front of the data, thus facilitating network streaming. * - * Compile this program using: - * cc qt-faststart.c -o qt-faststart + * To compile this program, start from the base directory from which you + * are building FFmpeg and type: + * make tools/qt-faststart + * The qt-faststart program will be built in the tools/ directory. If you + * do not build the program in this manner, correct results are not + * guaranteed, particularly on 64-bit platforms. * Invoke the program with: * qt-faststart * @@ -23,6 +27,7 @@ #include #include #include +#include #ifdef __MINGW32__ #define fseeko(x,y,z) fseeko64(x,y,z) @@ -60,6 +65,7 @@ #define WIDE_ATOM QT_ATOM('w', 'i', 'd', 'e') #define PICT_ATOM QT_ATOM('P', 'I', 'C', 'T') #define FTYP_ATOM QT_ATOM('f', 't', 'y', 'p') +#define UUID_ATOM QT_ATOM('u', 'u', 'i', 'd') #define CMOV_ATOM QT_ATOM('c', 'm', 'o', 'v') #define STCO_ATOM QT_ATOM('s', 't', 'c', 'o') @@ -70,14 +76,15 @@ int main(int argc, char *argv[]) { - FILE *infile; - FILE *outfile; + FILE *infile = NULL; + FILE *outfile = NULL; unsigned char atom_bytes[ATOM_PREAMBLE_SIZE]; uint32_t atom_type = 0; uint64_t atom_size = 0; + uint64_t atom_offset = 0; uint64_t last_offset; - unsigned char *moov_atom; - unsigned char *ftyp_atom = 0; + unsigned char *moov_atom = NULL; + unsigned char *ftyp_atom = NULL; uint64_t moov_atom_size; uint64_t ftyp_atom_size = 0; uint64_t i, j; @@ -92,10 +99,15 @@ return 0; } + if (!strcmp(argv[1], argv[2])) { + fprintf(stderr, "input and output files need to be different\n"); + return 1; + } + infile = fopen(argv[1], "rb"); if (!infile) { perror(argv[1]); - return 1; + goto error_out; } /* traverse through the atoms in the file to make sure that 'moov' is @@ -107,39 +119,23 @@ atom_size = (uint32_t)BE_32(&atom_bytes[0]); atom_type = BE_32(&atom_bytes[4]); - if ((atom_type != FREE_ATOM) && - (atom_type != JUNK_ATOM) && - (atom_type != MDAT_ATOM) && - (atom_type != MOOV_ATOM) && - (atom_type != PNOT_ATOM) && - (atom_type != SKIP_ATOM) && - (atom_type != WIDE_ATOM) && - (atom_type != PICT_ATOM) && - (atom_type != FTYP_ATOM)) { - printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n"); - break; - } - /* keep ftyp atom */ if (atom_type == FTYP_ATOM) { ftyp_atom_size = atom_size; + free(ftyp_atom); ftyp_atom = malloc(ftyp_atom_size); if (!ftyp_atom) { - printf ("could not allocate 0x%llX byte for ftyp atom\n", + printf ("could not allocate %"PRIu64" byte for ftyp atom\n", atom_size); - fclose(infile); - return 1; + goto error_out; } fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR); if (fread(ftyp_atom, atom_size, 1, infile) != 1) { perror(argv[1]); - free(ftyp_atom); - fclose(infile); - return 1; + goto error_out; } start_offset = ftello(infile); - continue; - } + } else { /* 64-bit special case */ if (atom_size == 1) { @@ -152,9 +148,38 @@ fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR); } } + printf("%c%c%c%c %10"PRIu64" %"PRIu64"\n", + (atom_type >> 24) & 255, + (atom_type >> 16) & 255, + (atom_type >> 8) & 255, + (atom_type >> 0) & 255, + atom_offset, + atom_size); + if ((atom_type != FREE_ATOM) && + (atom_type != JUNK_ATOM) && + (atom_type != MDAT_ATOM) && + (atom_type != MOOV_ATOM) && + (atom_type != PNOT_ATOM) && + (atom_type != SKIP_ATOM) && + (atom_type != WIDE_ATOM) && + (atom_type != PICT_ATOM) && + (atom_type != UUID_ATOM) && + (atom_type != FTYP_ATOM)) { + printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n"); + break; + } + atom_offset += atom_size; + + /* The atom header is 8 (or 16 bytes), if the atom size (which + * includes these 8 or 16 bytes) is less than that, we won't be + * able to continue scanning sensibly after this atom, so break. */ + if (atom_size < 8) + break; + } if (atom_type != MOOV_ATOM) { printf ("last atom in file was not a moov atom\n"); + free(ftyp_atom); fclose(infile); return 0; } @@ -166,29 +191,25 @@ moov_atom_size = atom_size; moov_atom = malloc(moov_atom_size); if (!moov_atom) { - printf ("could not allocate 0x%llX byte for moov atom\n", + printf ("could not allocate %"PRIu64" byte for moov atom\n", atom_size); - fclose(infile); - return 1; + goto error_out; } if (fread(moov_atom, atom_size, 1, infile) != 1) { perror(argv[1]); - free(moov_atom); - fclose(infile); - return 1; + goto error_out; } /* this utility does not support compressed atoms yet, so disqualify * files with compressed QT atoms */ if (BE_32(&moov_atom[12]) == CMOV_ATOM) { printf ("this utility does not support compressed moov atoms yet\n"); - free(moov_atom); - fclose(infile); - return 1; + goto error_out; } /* close; will be re-opened later */ fclose(infile); + infile = NULL; /* crawl through the moov chunk in search of stco or co64 atoms */ for (i = 4; i < moov_atom_size - 4; i++) { @@ -198,8 +219,7 @@ atom_size = BE_32(&moov_atom[i - 4]); if (i + atom_size - 4 > moov_atom_size) { printf (" bad atom size\n"); - free(moov_atom); - return 1; + goto error_out; } offset_count = BE_32(&moov_atom[i + 8]); for (j = 0; j < offset_count; j++) { @@ -216,8 +236,7 @@ atom_size = BE_32(&moov_atom[i - 4]); if (i + atom_size - 4 > moov_atom_size) { printf (" bad atom size\n"); - free(moov_atom); - return 1; + goto error_out; } offset_count = BE_32(&moov_atom[i + 8]); for (j = 0; j < offset_count; j++) { @@ -240,8 +259,7 @@ infile = fopen(argv[1], "rb"); if (!infile) { perror(argv[1]); - free(moov_atom); - return 1; + goto error_out; } if (start_offset > 0) { /* seek after ftyp atom */ @@ -252,9 +270,7 @@ outfile = fopen(argv[2], "wb"); if (!outfile) { perror(argv[2]); - fclose(outfile); - free(moov_atom); - return 1; + goto error_out; } /* dump the same ftyp atom */ @@ -296,16 +312,16 @@ fclose(infile); fclose(outfile); free(moov_atom); - if (ftyp_atom_size > 0) - free(ftyp_atom); + free(ftyp_atom); return 0; error_out: - fclose(infile); - fclose(outfile); + if (infile) + fclose(infile); + if (outfile) + fclose(outfile); free(moov_atom); - if (ftyp_atom_size > 0) - free(ftyp_atom); + free(ftyp_atom); return 1; } --- qt-faststart-0.2.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: