Skip to content

Commit

Permalink
feat: add flake
Browse files Browse the repository at this point in the history
flake: Alternative encoder for the Free Lossless Audio Codec

Log: add flake
Issue:
deepin-community/sig-deepin-sysdev-team#365
  • Loading branch information
liushanyang12138 committed Jul 12, 2023
1 parent 15e325d commit b38889b
Show file tree
Hide file tree
Showing 48 changed files with 6,868 additions and 39 deletions.
504 changes: 504 additions & 0 deletions COPYING

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Flake TODO list
---------------
- Apply feature updates from FFmpeg
- Shared lib/DLL support
- 24-bit/32-bit lossless
- Raw audio input
- AIFF input
- Import FFmpeg's FLAC decoder for verification during encoding
- Vorbis Comment tag support
- Embedded CUESHEET support

Flake Changelog
---------------
version 0.11 : 5 July 2007
- Significant speed improvements
- Added log search
- Added variable block size encoding
- Added level 99 high-compression level
- Quiet encoding mode (no console output except errors)
- Changed output file designation to "-o output.flac"
- Changed order method option to "-m #"
- Added support for encoding multiple files at once

version 0.10 : 11 September 2006 (Initial SVN import)
- New configure system
- Separate library & console app
88 changes: 88 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#
# Flake Main Makefile
#
include config.mak

VPATH=$(SRC_PATH)

CFLAGS=$(OPTFLAGS) -I. -I$(SRC_PATH) -I$(SRC_PATH)/libflake \
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE \
-DHAVE_CONFIG_H

LDFLAGS+= -g

FLAKE_LIBDIRS = -L./libflake
FLAKE_LIBS = -lflake$(BUILDSUF)

all: lib progs utils

lib:
$(MAKE) -C libflake all

progs:
$(MAKE) -C flake all

utils:
$(MAKE) -C util all

.PHONY: install

install: install-progs install-libs install-headers

install-progs: progs
$(MAKE) -C flake install

install-libs:
$(MAKE) -C libflake install-libs

install-headers:
$(MAKE) -C libflake install-headers

uninstall: uninstall-progs uninstall-libs uninstall-headers

uninstall-progs:
$(MAKE) -C flake uninstall-progs

uninstall-libs:
$(MAKE) -C libflake uninstall-libs

uninstall-headers:
$(MAKE) -C libflake uninstall-headers

dep: depend

depend:
$(MAKE) -C libflake depend
$(MAKE) -C flake depend
$(MAKE) -C util depend

clean:
$(MAKE) -C libflake clean
$(MAKE) -C flake clean
$(MAKE) -C util clean
rm -f *.o *.d *~

distclean: clean
$(MAKE) -C libflake distclean
$(MAKE) -C flake distclean
$(MAKE) -C util distclean
rm -f .depend config.*

# tar release (use 'make -k tar' on a checkouted tree)
FILE=flake-$(shell grep "\#define FLAKE_VERSION " libflake/flake.h | \
cut -d " " -f 3 )

tar: distclean
rm -rf /tmp/$(FILE)
cp -r . /tmp/$(FILE)
(tar --exclude config.mak --exclude .svn -C /tmp -jcvf $(FILE).tar.bz2 $(FILE) )
rm -rf /tmp/$(FILE)

config.mak:
touch config.mak

.PHONY: lib

ifneq ($(wildcard .depend),)
include .depend
endif
18 changes: 18 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-------------------------------------------------------------------------------
Flake: FLAC audio encoder

The purpose of Flake is to be an alternative to the FLAC reference encoder
with the goal of increasing encoding speed and implementing experimental
features.

Neither the program nor the library have stable interfaces. Therefore, the
commandline options and the library API/ABI may change. After version 1.0 is
released, this will become more stable.

The FLAC format and reference encoder were created by Josh Coalson and are
hosted by the Xiph.org Foundation. Many thanks!

-------------------------------------------------------------------------------
Copyright (c) 2006-2007 Justin Ruggles <[email protected]>
http://flake-enc.sourceforge.net/
-------------------------------------------------------------------------------
1 change: 0 additions & 1 deletion README.md

This file was deleted.

51 changes: 51 additions & 0 deletions bswap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @file bswap.h
* byte swap.
*/

#ifndef BSWAP_H
#define BSWAP_H

#include "common.h"

static inline uint16_t bswap_16(uint16_t x){
return (x>>8) | (x<<8);
}

static inline uint32_t bswap_32(uint32_t x){
x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
return (x>>16) | (x<<16);
}

static inline uint64_t bswap_64(uint64_t x)
{
union {
uint64_t ll;
uint32_t l[2];
} w, r;
w.ll = x;
r.l[0] = bswap_32(w.l[1]);
r.l[1] = bswap_32(w.l[0]);
return r.ll;
}

// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian

#ifdef WORDS_BIGENDIAN
#define be2me_16(x) (x)
#define be2me_32(x) (x)
#define be2me_64(x) (x)
#define le2me_16(x) bswap_16(x)
#define le2me_32(x) bswap_32(x)
#define le2me_64(x) bswap_64(x)
#else
#define be2me_16(x) bswap_16(x)
#define be2me_32(x) bswap_32(x)
#define be2me_64(x) bswap_64(x)
#define le2me_16(x) (x)
#define le2me_32(x) (x)
#define le2me_64(x) (x)
#endif

#endif /* BSWAP_H */
93 changes: 93 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Flake: FLAC audio encoder
* Copyright (c) 2006 Justin Ruggles
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

/**
* @file common.h
* Common header file
*/

#ifndef COMMON_H
#define COMMON_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif

#ifndef EMULATE_INTTYPES
#include <inttypes.h>
#else
#if defined(_WIN32) && defined(_MSC_VER)
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#endif /* EMULATE_INTTYPES */

#define ABS(a) ((a) >= 0 ? (a) : (-(a)))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) > (b) ? (b) : (a))
#define CLIP(x,min,max) MAX(MIN((x), (max)), (min))

static inline int
log2i(uint32_t v)
{
int i;
int n = 0;
if(v & 0xffff0000){ v >>= 16; n += 16; }
if(v & 0xff00){ v >>= 8; n += 8; }
for(i=2; i<256; i<<=1) {
if(v >= i) n++;
else break;
}
return n;
}

#include <string.h>

// strnlen is a GNU extention. providing implementation if needed.
#ifndef HAVE_STRNLEN
static inline size_t
strnlen(const char *s, size_t maxlen)
{
size_t i = 0;
while((s[i] != '\0') && (i < maxlen)) i++;
return i;
}
#elif !defined(__USE_GNU)
extern size_t strnlen(const char *s, size_t maxlen);
#endif

#endif /* COMMON_H */
Loading

0 comments on commit b38889b

Please sign in to comment.