Refresh 10.1

This commit is contained in:
n64
2020-06-17 22:14:59 -04:00
parent df7897da28
commit 1275714269
15 changed files with 21279 additions and 4051 deletions
+7
View File
@@ -1,3 +1,10 @@
Refresh #10.1
1.) Diff update (#1033)
2.) Fix texture dimensions for exclamation boxes (#1034)
3.) Fix armips compilation on Windows by changing order of inclusion files (#1035)
4.) Embed libaudiofile into the repo as a single file (#1036)
5.) Fix some tools issues found while compiling on MSYS2 (#1037)
Refresh #10
1.) GCC 9 noreturn UB fixes (#961)
2.) List supported binutils variants in README.md (#960)
+2 -2
View File
@@ -13,7 +13,7 @@ ALIGNED8 static const u8 exclamation_box_seg8_texture_08012E28[] = {
// 0x08013628
ALIGNED8 static const u8 exclamation_box_seg8_texture_08013628[] = {
#include "actors/exclamation_box/vanish_cap_box_sides.rgba16.inc.c"
#include "actors/exclamation_box/vanish_cap_box_side.rgba16.inc.c"
};
// 0x08014628
@@ -33,7 +33,7 @@ ALIGNED8 static const u8 exclamation_box_seg8_texture_08015E28[] = {
// 0x08016628
ALIGNED8 static const u8 exclamation_box_seg8_texture_08016628[] = {
#include "actors/exclamation_box/wing_cap_box_sides.rgba16.inc.c"
#include "actors/exclamation_box/wing_cap_box_side.rgba16.inc.c"
};
// 0x08017628
+2 -2
View File
@@ -210,9 +210,9 @@
"actors/exclamation_box/metal_cap_box_front.rgba16.png": [32,32,2048,{"jp":[2032944,83496],"us":[2040320,83496],"eu":[1912288,83496],"sh":[1888800,83496]}],
"actors/exclamation_box/metal_cap_box_side.rgba16.png": [64,32,4096,{"jp":[2032944,85544],"us":[2040320,85544],"eu":[1912288,85544],"sh":[1888800,85544]}],
"actors/exclamation_box/vanish_cap_box_front.rgba16.png": [32,32,2048,{"jp":[2032944,77352],"us":[2040320,77352],"eu":[1912288,77352],"sh":[1888800,77352]}],
"actors/exclamation_box/vanish_cap_box_sides.rgba16.png": [64,32,4096,{"jp":[2032944,79400],"us":[2040320,79400],"eu":[1912288,79400],"sh":[1888800,79400]}],
"actors/exclamation_box/vanish_cap_box_side.rgba16.png": [32,64,4096,{"jp":[2032944,79400],"us":[2040320,79400],"eu":[1912288,79400],"sh":[1888800,79400]}],
"actors/exclamation_box/wing_cap_box_front.rgba16.png": [32,32,2048,{"jp":[2032944,89640],"us":[2040320,89640],"eu":[1912288,89640],"sh":[1888800,89640]}],
"actors/exclamation_box/wing_cap_box_sides.rgba16.png": [64,32,4096,{"jp":[2032944,91688],"us":[2040320,91688],"eu":[1912288,91688],"sh":[1888800,91688]}],
"actors/exclamation_box/wing_cap_box_side.rgba16.png": [32,64,4096,{"jp":[2032944,91688],"us":[2040320,91688],"eu":[1912288,91688],"sh":[1888800,91688]}],
"actors/exclamation_box_outline/exclamation_box_outline.rgba16.png": [32,32,2048,{"jp":[2032944,151912],"us":[2040320,151912],"eu":[1912288,151912],"sh":[1888800,151912]}],
"actors/exclamation_box_outline/exclamation_point.rgba16.png": [16,32,1024,{"jp":[2032944,154240],"us":[2040320,154240],"eu":[1912288,154240],"sh":[1888800,154240]}],
"actors/explosion/explosion_0.rgba16.png": [32,32,2048,{"jp":[2094912,2568],"us":[2102288,2568],"eu":[1974256,2568],"sh":[1950768,2568]}],
+218 -68
View File
@@ -18,16 +18,18 @@ def fail(msg):
sys.exit(1)
MISSING_PREREQUISITES = (
"Missing prerequisite python module {}. "
"Run `python3 -m pip install --user colorama ansiwrap attrs watchdog python-Levenshtein` to install prerequisites (python-Levenshtein only needed for --algorithm=levenshtein)."
)
try:
import attr
from colorama import Fore, Style, Back
import ansiwrap
import watchdog
except ModuleNotFoundError as e:
fail(
f"Missing prerequisite python module {e.name}. "
"Run `python3 -m pip install --user colorama ansiwrap attrs watchdog` to install prerequisites."
)
fail(MISSING_PREREQUISITES.format(e.name))
# Prefer to use diff_settings.py from the current working directory
sys.path.insert(0, ".")
@@ -121,6 +123,22 @@ parser.add_argument(
default=50,
help="Sets the width of the left and right view column.",
)
parser.add_argument(
"--algorithm",
dest="algorithm",
default="difflib",
choices=["levenshtein", "difflib"],
help="Diff algorithm to use.",
)
parser.add_argument(
"--max-size",
"--max-lines",
dest="max_lines",
type=int,
default=1024,
help="The maximum length of the diff, in lines. Not recommended when -f is used.",
)
# Project-specific flags, e.g. different versions/make arguments.
if hasattr(diff_settings, "add_custom_arguments"):
@@ -138,8 +156,8 @@ mapfile = config.get("mapfile", None)
makeflags = config.get("makeflags", [])
source_directories = config.get("source_directories", None)
MAX_FUNCTION_SIZE_LINES = 1024
MAX_FUNCTION_SIZE_BYTES = 1024 * 4
MAX_FUNCTION_SIZE_LINES = args.max_lines
MAX_FUNCTION_SIZE_BYTES = MAX_FUNCTION_SIZE_LINES * 4
COLOR_ROTATION = [
Fore.MAGENTA,
@@ -161,6 +179,12 @@ FS_WATCH_EXTENSIONS = [".c", ".h"]
# ==== LOGIC ====
if args.algorithm == "levenshtein":
try:
import Levenshtein
except ModuleNotFoundError as e:
fail(MISSING_PREREQUISITES.format(e.name))
binutils_prefix = None
for binutils_cand in ["mips-linux-gnu-", "mips64-elf-"]:
@@ -292,7 +316,7 @@ def dump_objfile():
run_make(objfile)
if not os.path.isfile(objfile):
fail("Not able to find .o file for function.")
fail(f"Not able to find .o file for function: {objfile} is not a file.")
refobjfile = "expected/" + objfile
if not os.path.isfile(refobjfile):
@@ -344,28 +368,27 @@ def ansi_ljust(s, width):
re_int = re.compile(r"[0-9]+")
re_comments = re.compile(r"<.*?>")
re_regs = re.compile(r"\b(a[0-3]|t[0-9]|s[0-7]|at|v[01]|f[12]?[0-9]|f3[01]|fp)\b")
re_sprel = re.compile(r",([1-9][0-9]*|0x[1-9a-f][0-9a-f]*)\(sp\)")
re_regs = re.compile(r"\$?\b(a[0-3]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|fp)\b")
re_sprel = re.compile(r",([0-9]+|0x[0-9a-f]+)\(sp\)")
re_large_imm = re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}")
re_imm = re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)")
forbidden = set(string.ascii_letters + "_")
branch_likely_instructions = set(
[
"beql",
"bnel",
"beqzl",
"bnezl",
"bgezl",
"bgtzl",
"blezl",
"bltzl",
"bc1tl",
"bc1fl",
]
)
branch_instructions = set(
["b", "beq", "bne", "beqz", "bnez", "bgez", "bgtz", "blez", "bltz", "bc1t", "bc1f"]
+ list(branch_likely_instructions)
branch_likely_instructions = {
"beql",
"bnel",
"beqzl",
"bnezl",
"bgezl",
"bgtzl",
"blezl",
"bltzl",
"bc1tl",
"bc1fl",
}
branch_instructions = branch_likely_instructions.union(
{"b", "beq", "bne", "beqz", "bnez", "bgez", "bgtz", "blez", "bltz", "bc1t", "bc1f"}
)
jump_instructions = branch_instructions.union({"jal", "j"})
def hexify_int(row, pat):
@@ -420,6 +443,7 @@ def process_reloc(row, prev):
def process(lines):
mnemonics = []
diff_rows = []
rows_with_imms = []
skip_next = False
originals = []
line_nums = []
@@ -434,8 +458,9 @@ def process(lines):
continue
if "R_MIPS_" in row:
if diff_rows[-1] != "<delay-slot>":
diff_rows[-1] = process_reloc(row, diff_rows[-1])
# N.B. Don't transform the diff rows, they already ignore immediates
# if diff_rows[-1] != '<delay-slot>':
# diff_rows[-1] = process_reloc(row, rows_with_imms[-1])
originals[-1] = process_reloc(row, originals[-1])
continue
@@ -446,7 +471,7 @@ def process(lines):
line_num = tabs[0].strip()
row_parts = row.split("\t", 1)
mnemonic = row_parts[0].strip()
if mnemonic not in branch_instructions:
if mnemonic not in jump_instructions:
row = re.sub(re_int, lambda s: hexify_int(row, s), row)
original = row
if skip_next:
@@ -457,11 +482,16 @@ def process(lines):
skip_next = True
row = re.sub(re_regs, "<reg>", row)
row = re.sub(re_sprel, ",addr(sp)", row)
if args.ignore_large_imms:
row = re.sub(re_large_imm, "<imm>", row)
row_with_imm = row
if mnemonic in jump_instructions:
row = row.strip()
row, _ = split_off_branch(row)
row += "<imm>"
else:
row = re.sub(re_imm, "<imm>", row)
# Replace tabs with spaces
mnemonics.append(mnemonic)
rows_with_imms.append(row_with_imm)
diff_rows.append(row)
originals.append(original)
line_nums.append(line_num)
@@ -504,12 +534,85 @@ class SymbolColorer:
return f"{color}{t}{Fore.RESET}"
def normalize_large_imms(row):
def maybe_normalize_large_imms(row):
if args.ignore_large_imms:
row = re.sub(re_large_imm, "<imm>", row)
return row
def normalize_imms(row):
return re.sub(re_imm, "<imm>", row)
def normalize_stack(row):
return re.sub(re_sprel, ",addr(sp)", row)
def split_off_branch(line):
parts = line.split(",")
if len(parts) < 2:
parts = line.split(None, 1)
off = len(line) - len(parts[-1])
return line[:off], line[off:]
def color_imms(out1, out2):
g1 = []
g2 = []
re.sub(re_imm, lambda s: g1.append(s.group()), out1)
re.sub(re_imm, lambda s: g2.append(s.group()), out2)
if len(g1) == len(g2):
diffs = [x != y for (x, y) in zip(g1, g2)]
it = iter(diffs)
def maybe_color(s):
return f"{Fore.LIGHTBLUE_EX}{s}{Style.RESET_ALL}" if next(it) else s
out1 = re.sub(re_imm, lambda s: maybe_color(s.group()), out1)
it = iter(diffs)
out2 = re.sub(re_imm, lambda s: maybe_color(s.group()), out2)
return out1, out2
def color_branch_imms(br1, br2):
if br1 != br2:
br1 = f"{Fore.LIGHTBLUE_EX}{br1}{Style.RESET_ALL}"
br2 = f"{Fore.LIGHTBLUE_EX}{br2}{Style.RESET_ALL}"
return br1, br2
def diff_sequences_difflib(seq1, seq2):
differ = difflib.SequenceMatcher(a=seq1, b=seq2, autojunk=False)
return differ.get_opcodes()
def diff_sequences(seq1, seq2):
if (
args.algorithm != "levenshtein"
or len(seq1) * len(seq2) > 4 * 10 ** 8
or len(seq1) + len(seq2) >= 0x110000
):
return diff_sequences_difflib(seq1, seq2)
# The Levenshtein library assumes that we compare strings, not lists. Convert.
# (Per the check above we know we have fewer than 0x110000 unique elements, so chr() works.)
remapping = {}
def remap(seq):
seq = seq[:]
for i in range(len(seq)):
val = remapping.get(seq[i])
if val is None:
val = chr(len(remapping))
remapping[seq[i]] = val
seq[i] = val
return "".join(seq)
seq1 = remap(seq1)
seq2 = remap(seq2)
return Levenshtein.opcodes(seq1, seq2)
def do_diff(basedump, mydump):
asm_lines1 = basedump.split("\n")
asm_lines2 = mydump.split("\n")
@@ -545,10 +648,7 @@ def do_diff(basedump, mydump):
btset.add(bt + ":")
sc.color_symbol(bt + ":")
differ: difflib.SequenceMatcher = difflib.SequenceMatcher(
a=mnemonics1, b=mnemonics2, autojunk=False
)
for (tag, i1, i2, j1, j2) in differ.get_opcodes():
for (tag, i1, i2, j1, j2) in diff_sequences(mnemonics1, mnemonics2):
lines1 = asm_lines1[i1:i2]
lines2 = asm_lines2[j1:j2]
@@ -572,65 +672,113 @@ def do_diff(basedump, mydump):
original2 = ""
line_num2 = ""
line_color = Fore.RESET
has1 = has2 = True
line_color1 = line_color2 = sym_color = Fore.RESET
line_prefix = " "
if line1 == line2:
if normalize_large_imms(original1) == normalize_large_imms(original2):
out1 = f"{original1}"
out2 = f"{original2}"
if not line1:
has1 = has2 = False
if maybe_normalize_large_imms(original1) == maybe_normalize_large_imms(
original2
):
out1 = original1
out2 = original2
elif line1 == "<delay-slot>":
out1 = f"{Style.DIM}{original1}"
out2 = f"{Style.DIM}{original2}"
else:
line_color = Fore.YELLOW
line_prefix = "r"
out1 = f"{Fore.YELLOW}{original1}{Style.RESET_ALL}"
out2 = f"{Fore.YELLOW}{original2}{Style.RESET_ALL}"
out1 = re.sub(re_regs, lambda s: sc1.color_symbol(s.group()), out1)
out2 = re.sub(re_regs, lambda s: sc2.color_symbol(s.group()), out2)
out1 = re.sub(re_sprel, lambda s: sc3.color_symbol(s.group()), out1)
out2 = re.sub(re_sprel, lambda s: sc4.color_symbol(s.group()), out2)
mnemonic = original1.split()[0]
out1, out2 = original1, original2
branch1 = branch2 = ""
if mnemonic in jump_instructions:
out1, branch1 = split_off_branch(original1)
out2, branch2 = split_off_branch(original2)
branchless1 = out1
branchless2 = out2
out1, out2 = color_imms(out1, out2)
branch1, branch2 = color_branch_imms(branch1, branch2)
out1 += branch1
out2 += branch2
if normalize_imms(branchless1) == normalize_imms(branchless2):
# only imms differences
sym_color = Fore.LIGHTBLUE_EX
line_prefix = "i"
else:
out1 = re.sub(
re_sprel,
lambda s: "," + sc3.color_symbol(s.group()[1:]),
out1,
)
out2 = re.sub(
re_sprel,
lambda s: "," + sc4.color_symbol(s.group()[1:]),
out2,
)
if normalize_stack(branchless1) == normalize_stack(branchless2):
# only stack differences (luckily stack and imm
# differences can't be combined in MIPS, so we
# don't have to think about that case)
sym_color = Fore.YELLOW
line_prefix = "s"
else:
# regs differences and maybe imms as well
out1 = re.sub(
re_regs, lambda s: sc1.color_symbol(s.group()), out1
)
out2 = re.sub(
re_regs, lambda s: sc2.color_symbol(s.group()), out2
)
line_color1 = line_color2 = sym_color = Fore.YELLOW
line_prefix = "r"
elif tag in ["replace", "equal"]:
line_prefix = "|"
line_color = Fore.BLUE
out1 = f"{Fore.BLUE}{original1}{Style.RESET_ALL}"
out2 = f"{Fore.BLUE}{original2}{Style.RESET_ALL}"
line_color1 = Fore.LIGHTBLUE_EX
line_color2 = Fore.LIGHTBLUE_EX
sym_color = Fore.LIGHTBLUE_EX
out1 = original1
out2 = original2
elif tag == "delete":
line_prefix = "<"
line_color = Fore.RED
out1 = f"{Fore.RED}{original1}{Style.RESET_ALL}"
line_color1 = line_color2 = sym_color = Fore.RED
has2 = False
out1 = original1
out2 = ""
elif tag == "insert":
line_prefix = ">"
line_color = Fore.GREEN
line_color1 = line_color2 = sym_color = Fore.GREEN
has1 = False
out1 = ""
out2 = f"{Fore.GREEN}{original2}{Style.RESET_ALL}"
out2 = original2
in_arrow1 = " "
in_arrow2 = " "
out_arrow1 = ""
out_arrow2 = ""
line_num1 = line_num1 if out1 else ""
line_num2 = line_num2 if out2 else ""
line_num1 = line_num1 if has1 else ""
line_num2 = line_num2 if has2 else ""
if args.show_branches and out1:
if sym_color == line_color2:
line_color2 = ""
if args.show_branches and has1:
if line_num1 in bts1:
in_arrow1 = sc5.color_symbol(line_num1, "~>")
in_arrow1 = sc5.color_symbol(line_num1, "~>") + line_color1
if branch_targets1[i1 + k] is not None:
out_arrow1 = " " + sc5.color_symbol(
branch_targets1[i1 + k] + ":", "~>"
)
if args.show_branches and out2:
if args.show_branches and has2:
if line_num2 in bts2:
in_arrow2 = sc6.color_symbol(line_num2, "~>")
in_arrow2 = sc6.color_symbol(line_num2, "~>") + line_color2
if branch_targets2[j1 + k] is not None:
out_arrow2 = " " + sc6.color_symbol(
branch_targets2[j1 + k] + ":", "~>"
)
out1 = f"{line_color}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}"
out2 = f"{line_color}{line_prefix} {line_num2} {in_arrow2} {out2}{Style.RESET_ALL}{out_arrow2}"
output.append(format_single_line_diff(out1, out2, args.column_width))
out1 = f"{line_color1}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}"
out2 = f"{line_color2}{line_num2} {in_arrow2} {out2}{Style.RESET_ALL}{out_arrow2}"
mid = f"{sym_color}{line_prefix} "
output.append(format_single_line_diff(out1, mid + out2, args.column_width))
return output[args.skip_lines :]
@@ -677,7 +825,7 @@ def debounced_fs_watch(targets, outq, debounce_delay):
observer.schedule(event_handler, target, recursive=True)
else:
file_targets.append(target)
target = os.path.dirname(target)
target = os.path.dirname(target) or "."
if target not in observed:
observed.add(target)
observer.schedule(event_handler, target)
@@ -800,7 +948,7 @@ def main():
if args.write_asm is not None:
mydump = run_objdump(mycmd)
with open(args.write_asm) as f:
with open(args.write_asm, "w") as f:
f.write(mydump)
print(f"Wrote assembly to {args.write_asm}.")
sys.exit(0)
@@ -850,7 +998,9 @@ def main():
ret = run_make(make_target, capture_output=True)
if ret.returncode != 0:
display.update(
ret.stderr.decode() or ret.stdout.decode(), error=True
ret.stderr.decode("utf-8-sig", "replace")
or ret.stdout.decode("utf-8-sig", "replace"),
error=True,
)
continue
mydump = run_objdump(mycmd)
+1 -1
View File
@@ -257,7 +257,7 @@ def main():
)
finally:
png_file.close()
remove_file(png_file.name)
os.remove(png_file.name)
else:
with open(asset, "wb") as f:
f.write(input)
+14 -4
View File
@@ -9,10 +9,14 @@ ifeq (, $(shell which armips 2> /dev/null))
CXX_PROGRAMS += armips
endif
ifeq ($(OS),Windows_NT)
ARMIPS_FLAGS := -municode
endif
default: all
armips: armips.cpp
$(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti -pipe $^ -o $@ -lpthread
$(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti -pipe $^ -o $@ -lpthread $(ARMIPS_FLAGS)
n64graphics_SOURCES := n64graphics.c utils.c
n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE
@@ -33,8 +37,8 @@ aifc_decode_SOURCES := aifc_decode.c
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c
tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
tabledesign_CFLAGS := -Wno-uninitialized
tabledesign_LDFLAGS := -laudiofile
tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized
tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++ -lm
vadpcm_enc_SOURCES := sdk-tools/adpcm/vadpcm_enc.c sdk-tools/adpcm/vpredictor.c sdk-tools/adpcm/quant.c sdk-tools/adpcm/util.c sdk-tools/adpcm/vencode.c
vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -Wno-absolute-value
@@ -43,10 +47,16 @@ extract_data_for_mio_SOURCES := extract_data_for_mio.c
skyconv_SOURCES := skyconv.c n64graphics.c utils.c
all: $(PROGRAMS) $(CXX_PROGRAMS)
LIBAUDIOFILE := audiofile/libaudiofile.a
$(LIBAUDIOFILE):
@$(MAKE) -C audiofile
all: $(LIBAUDIOFILE) $(PROGRAMS) $(CXX_PROGRAMS)
clean:
$(RM) $(PROGRAMS) $(CXX_PROGRAMS)
$(MAKE) -C audiofile clean
define COMPILE
$(1): $($1_SOURCES)
+3958 -3958
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
CXX := g++
libaudiofile.a: audiofile.o
ar rcs libaudiofile.a audiofile.o
audiofile.o: audiofile.cpp audiofile.h aupvlist.h
$(CXX) -std=c++11 -O2 -I. -c audiofile.cpp
clean:
rm -f audiofile.o libaudiofile.a
.PHONY: clean
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+68
View File
@@ -0,0 +1,68 @@
/*
Audio File Library
Copyright (C) 1998-2000, Michael Pruett <michael@68k.org>
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.1 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
*/
/*
aupvlist.h
This file contains the interface to the parameter value list data
structures and routines.
*/
#ifndef AUPVLIST_H
#define AUPVLIST_H
#ifdef __cplusplus
extern "C" {
#endif
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
#define AFAPI __attribute__((visibility("default")))
#else
#define AFAPI
#endif
enum
{
AU_PVTYPE_LONG = 1,
AU_PVTYPE_DOUBLE = 2,
AU_PVTYPE_PTR = 3
};
typedef struct _AUpvlist *AUpvlist;
#define AU_NULL_PVLIST ((struct _AUpvlist *) 0)
AFAPI AUpvlist AUpvnew (int maxItems);
AFAPI int AUpvgetmaxitems (AUpvlist);
AFAPI int AUpvfree (AUpvlist);
AFAPI int AUpvsetparam (AUpvlist, int item, int param);
AFAPI int AUpvsetvaltype (AUpvlist, int item, int type);
AFAPI int AUpvsetval (AUpvlist, int item, void *val);
AFAPI int AUpvgetparam (AUpvlist, int item, int *param);
AFAPI int AUpvgetvaltype (AUpvlist, int item, int *type);
AFAPI int AUpvgetval (AUpvlist, int item, void *val);
#undef AFAPI
#ifdef __cplusplus
}
#endif
#endif /* AUPVLIST_H */
+6 -6
View File
@@ -802,9 +802,9 @@ int main(int argc, char *argv[])
if (config.mode == MODE_IMPORT) {
if (config.bin_truncate) {
bin_fp = fopen(config.bin_filename, "w");
bin_fp = fopen(config.bin_filename, "wb");
} else {
bin_fp = fopen(config.bin_filename, "r+");
bin_fp = fopen(config.bin_filename, "r+b");
}
if (!bin_fp) {
ERROR("Error opening \"%s\"\n", config.bin_filename);
@@ -854,9 +854,9 @@ int main(int argc, char *argv[])
int pal_length;
if (config.pal_truncate) {
pal_fp = fopen(config.pal_filename, "w");
pal_fp = fopen(config.pal_filename, "wb");
} else {
pal_fp = fopen(config.pal_filename, "r+");
pal_fp = fopen(config.pal_filename, "r+b");
}
if (!pal_fp) {
ERROR("Error opening \"%s\"\n", config.pal_filename);
@@ -934,7 +934,7 @@ int main(int argc, char *argv[])
ERROR("Error: must set position width and height for export\n");
return EXIT_FAILURE;
}
bin_fp = fopen(config.bin_filename, "r");
bin_fp = fopen(config.bin_filename, "rb");
if (!bin_fp) {
ERROR("Error opening \"%s\"\n", config.bin_filename);
return -1;
@@ -971,7 +971,7 @@ int main(int argc, char *argv[])
INFO("Extracting %s offset 0x%X, pal.offset 0x%0X, pal.format %s\n", format2str(&config.format),
config.bin_offset, config.pal_offset, format2str(&config.pal_format));
pal_fp = fopen(config.pal_filename, "r");
pal_fp = fopen(config.pal_filename, "rb");
if (!pal_fp) {
ERROR("Error opening \"%s\"\n", config.bin_filename);
return EXIT_FAILURE;
+318
View File
@@ -0,0 +1,318 @@
diff --git a/libaudiofile/FileHandle.cpp b/libaudiofile/FileHandle.cpp
index 8562d4b..5d6342a 100644
--- a/libaudiofile/FileHandle.cpp
+++ b/libaudiofile/FileHandle.cpp
@@ -74,26 +74,8 @@ _AFfilehandle *_AFfilehandle::create(int fileFormat)
case AF_FILE_AIFF:
case AF_FILE_AIFFC:
return new AIFFFile();
- case AF_FILE_NEXTSND:
- return new NeXTFile();
case AF_FILE_WAVE:
return new WAVEFile();
- case AF_FILE_BICSF:
- return new IRCAMFile();
- case AF_FILE_AVR:
- return new AVRFile();
- case AF_FILE_IFF_8SVX:
- return new IFFFile();
- case AF_FILE_SAMPLEVISION:
- return new SampleVisionFile();
- case AF_FILE_VOC:
- return new VOCFile();
- case AF_FILE_NIST_SPHERE:
- return new NISTFile();
- case AF_FILE_CAF:
- return new CAFFile();
- case AF_FILE_FLAC:
- return new FLACFile();
default:
return NULL;
}
diff --git a/libaudiofile/aupv.c b/libaudiofile/aupv.c
index 64e798b..374838b 100644
--- a/libaudiofile/aupv.c
+++ b/libaudiofile/aupv.c
@@ -47,7 +47,7 @@ AUpvlist AUpvnew (int maxitems)
if (aupvlist == NULL)
return AU_NULL_PVLIST;
- aupvlist->items = calloc(maxitems, sizeof (struct _AUpvitem));
+ aupvlist->items = (struct _AUpvitem *)calloc(maxitems, sizeof (struct _AUpvitem));
assert(aupvlist->items);
if (aupvlist->items == NULL)
diff --git a/libaudiofile/g711.c b/libaudiofile/g711.c
index 8fb2323..1b323ec 100644
--- a/libaudiofile/g711.c
+++ b/libaudiofile/g711.c
@@ -74,8 +74,7 @@ static int search(int val, const short *table, int size)
* John Wiley & Sons, pps 98-111 and 472-476.
*/
unsigned char
-_af_linear2alaw(pcm_val)
- int pcm_val; /* 2's complement (16-bit range) */
+_af_linear2alaw(int pcm_val)
{
int mask;
int seg;
@@ -110,8 +109,7 @@ _af_linear2alaw(pcm_val)
*
*/
int
-_af_alaw2linear(a_val)
- unsigned char a_val;
+_af_alaw2linear(unsigned char a_val)
{
int t;
int seg;
diff --git a/libaudiofile/units.cpp b/libaudiofile/units.cpp
index ffd0a63..51d2dc3 100644
--- a/libaudiofile/units.cpp
+++ b/libaudiofile/units.cpp
@@ -32,24 +32,12 @@
#include "units.h"
#include "AIFF.h"
-#include "AVR.h"
-#include "CAF.h"
-#include "FLACFile.h"
-#include "IFF.h"
-#include "IRCAM.h"
-#include "NeXT.h"
-#include "NIST.h"
#include "Raw.h"
-#include "SampleVision.h"
-#include "VOC.h"
#include "WAVE.h"
#include "compression.h"
-#include "modules/ALAC.h"
-#include "modules/FLAC.h"
#include "modules/G711.h"
-#include "modules/IMA.h"
#include "modules/MSADPCM.h"
#include "modules/PCM.h"
@@ -99,20 +87,6 @@ const Unit _af_units[_AF_NUM_UNITS] =
_AF_AIFF_NUM_INSTPARAMS,
_af_aiff_inst_params
},
- {
- AF_FILE_NEXTSND,
- "NeXT .snd/Sun .au", "NeXT .snd/Sun .au Format", "next",
- true,
- NeXTFile::completeSetup,
- NeXTFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_NEXT_NUM_COMPTYPES,
- _af_next_compression_types,
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, NULL
- },
{
AF_FILE_WAVE,
"MS RIFF WAVE", "Microsoft RIFF WAVE Format", "wave",
@@ -128,144 +102,6 @@ const Unit _af_units[_AF_NUM_UNITS] =
_AF_WAVE_NUM_INSTPARAMS,
_af_wave_inst_params
},
- {
- AF_FILE_IRCAM,
- "BICSF", "Berkeley/IRCAM/CARL Sound Format", "bicsf",
- true,
- IRCAMFile::completeSetup,
- IRCAMFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_IRCAM_NUM_COMPTYPES,
- _af_ircam_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_MPEG1BITSTREAM,
- "MPEG", "MPEG Audio Bitstream", "mpeg",
- false
- },
- {
- AF_FILE_SOUNDDESIGNER1,
- "Sound Designer 1", "Sound Designer 1 File Format", "sd1",
- false
- },
- {
- AF_FILE_SOUNDDESIGNER2,
- "Sound Designer 2", "Sound Designer 2 File Format", "sd2",
- false
- },
- {
- AF_FILE_AVR,
- "AVR", "Audio Visual Research File Format", "avr",
- true,
- AVRFile::completeSetup,
- AVRFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- 0, /* number of compression types */
- NULL, /* compression types */
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, /* number of instrument parameters */
- },
- {
- AF_FILE_IFF_8SVX,
- "IFF/8SVX", "Amiga IFF/8SVX Sound File Format", "iff",
- true,
- IFFFile::completeSetup,
- IFFFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 8,
- 0, /* number of compression types */
- NULL, /* compression types */
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, /* number of instrument parameters */
- },
- {
- AF_FILE_SAMPLEVISION,
- "Sample Vision", "Sample Vision File Format", "smp",
- true,
- SampleVisionFile::completeSetup,
- SampleVisionFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- 0, // number of compression types
- NULL, // compression types
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_VOC,
- "VOC", "Creative Voice File Format", "voc",
- true,
- VOCFile::completeSetup,
- VOCFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_VOC_NUM_COMPTYPES,
- _af_voc_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_NIST_SPHERE,
- "NIST SPHERE", "NIST SPHERE File Format", "nist",
- true,
- NISTFile::completeSetup,
- NISTFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- 0, /* number of compression types */
- NULL, /* compression types */
- 0, /* maximum marker count */
- 0, /* maximum instrument count */
- 0, /* maximum number of loops per instrument */
- 0, /* number of instrument parameters */
- NULL /* instrument parameters */
- },
- {
- AF_FILE_SOUNDFONT2,
- "SoundFont 2", "SoundFont 2 File Format", "sf2",
- false
- },
- {
- AF_FILE_CAF,
- "CAF", "Core Audio Format", "caf",
- true,
- CAFFile::completeSetup,
- CAFFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_CAF_NUM_COMPTYPES,
- _af_caf_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- },
- {
- AF_FILE_FLAC,
- "FLAC", "Free Lossless Audio Codec", "flac",
- true,
- FLACFile::completeSetup,
- FLACFile::recognize,
- AF_SAMPFMT_TWOSCOMP, 16,
- _AF_FLAC_NUM_COMPTYPES,
- _af_flac_compression_types,
- 0, // maximum marker count
- 0, // maximum instrument count
- 0, // maximum number of loops per instrument
- 0, // number of instrument parameters
- NULL // instrument parameters
- }
};
const CompressionUnit _af_compression[_AF_NUM_COMPRESSION] =
@@ -309,19 +145,6 @@ const CompressionUnit _af_compression[_AF_NUM_COMPRESSION] =
_af_g711_format_ok,
_AFg711initcompress, _AFg711initdecompress
},
- {
- AF_COMPRESSION_IMA,
- true,
- "ima4", /* label */
- "IMA ADPCM", /* short name */
- "IMA DVI ADPCM",
- 4.0,
- AF_SAMPFMT_TWOSCOMP, 16,
- true, /* needsRebuffer */
- false, /* multiple_of */
- _af_ima_adpcm_format_ok,
- _af_ima_adpcm_init_compress, _af_ima_adpcm_init_decompress
- },
{
AF_COMPRESSION_MS_ADPCM,
true,
@@ -335,34 +158,4 @@ const CompressionUnit _af_compression[_AF_NUM_COMPRESSION] =
_af_ms_adpcm_format_ok,
_af_ms_adpcm_init_compress, _af_ms_adpcm_init_decompress
},
- {
- AF_COMPRESSION_FLAC,
-#if ENABLE(FLAC)
- true,
-#else
- false,
-#endif
- "flac", // label
- "FLAC", // short name
- "Free Lossless Audio Codec",
- 1.0,
- AF_SAMPFMT_TWOSCOMP, 16,
- false, // needsRebuffer
- false, // multiple_of
- _af_flac_format_ok,
- _af_flac_init_compress, _af_flac_init_decompress
- },
- {
- AF_COMPRESSION_ALAC,
- true,
- "alac", // label
- "ALAC", // short name
- "Apple Lossless Audio Codec",
- 1.0,
- AF_SAMPFMT_TWOSCOMP, 16,
- true, // needsRebuffer
- false, // multiple_of
- _af_alac_format_ok,
- _af_alac_init_compress, _af_alac_init_decompress
- }
};
+10 -10
View File
@@ -63,16 +63,6 @@ file_list = [
'Commands/CDirectiveMessage.h',
'Commands/CDirectiveMessage.cpp',
'Commands/CommandSequence.cpp',
'Core/ELF/ElfFile.cpp',
'Core/ELF/ElfRelocator.cpp',
'Core/Assembler.cpp',
'Core/Common.cpp',
'Core/Expression.cpp',
'Core/ExpressionFunctions.cpp',
'Core/FileManager.cpp',
'Core/Misc.cpp',
'Core/SymbolData.cpp',
'Core/SymbolTable.cpp',
'Parser/DirectivesParser.cpp',
'Parser/ExpressionParser.cpp',
'Parser/Parser.cpp',
@@ -84,6 +74,16 @@ file_list = [
'Util/Util.cpp',
'Main/CommandLineInterface.h',
'Main/CommandLineInterface.cpp',
'Core/ELF/ElfFile.cpp',
'Core/ELF/ElfRelocator.cpp',
'Core/Assembler.cpp',
'Core/Common.cpp',
'Core/Expression.cpp',
'Core/ExpressionFunctions.cpp',
'Core/FileManager.cpp',
'Core/Misc.cpp',
'Core/SymbolData.cpp',
'Core/SymbolTable.cpp',
'Main/main.cpp',
]
+136
View File
@@ -0,0 +1,136 @@
#!/usr/bin/env python
import os
import re
import sys
file_list = [
'Features.h',
'Compiler.h',
'error.h',
'extended.h',
'compression.h',
'aupvinternal.h',
'aupvlist.h',
'audiofile.h',
'afinternal.h',
'byteorder.h',
'AudioFormat.h',
'debug.h',
'util.h',
'units.h',
'UUID.h',
'Shared.h',
'Buffer.h',
'File.h',
'FileHandle.h',
'Instrument.h',
'Track.h',
'Marker.h',
'Setup.h',
'Tag.h',
'PacketTable.h',
'pcm.h',
'g711.h',
'af_vfs.h',
'Raw.h',
'WAVE.h',
'SampleVision.h',
'modules/Module.h',
'modules/ModuleState.h',
'modules/SimpleModule.h',
'modules/FileModule.h',
'modules/RebufferModule.h',
'modules/BlockCodec.h',
'modules/BlockCodec.cpp',
'modules/FileModule.cpp',
'modules/G711.h',
'modules/G711.cpp',
'modules/Module.cpp',
'modules/ModuleState.cpp',
'modules/MSADPCM.h',
'modules/MSADPCM.cpp',
'modules/PCM.h',
'modules/PCM.cpp',
'modules/SimpleModule.cpp',
'modules/RebufferModule.cpp',
'AIFF.h',
'AIFF.cpp',
'AudioFormat.cpp',
'Buffer.cpp',
'File.cpp',
'FileHandle.cpp',
'Instrument.cpp',
'Loop.cpp',
'Marker.cpp',
'Miscellaneous.cpp',
'PacketTable.cpp',
'Raw.cpp',
'Setup.cpp',
'Track.cpp',
'UUID.cpp',
'WAVE.cpp',
'aes.cpp',
'af_vfs.cpp',
'aupv.c',
'compression.cpp',
'data.cpp',
'debug.cpp',
'error.c',
'extended.c',
'format.cpp',
'g711.c',
'openclose.cpp',
'pcm.cpp',
'query.cpp',
'units.cpp',
'util.cpp',
]
file_header = \
"""// libaudiofile b62c902
// https://github.com/mpruett/audiofile
// To simplify compilation, all files have been concatenated into one.
// Support for all formats except WAVE, AIFF(C) and RAW has been stripped out.
"""
prepend_defs = \
"""#define HAVE_UNISTD_H 1
#if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
#endif
#include <stdlib.h>
"""
def banned(line):
return '#pragma once' in line or '#include "' in line or '#include <config.h>' in line
def cat_file(fout, fin_name):
with open(fin_name) as fin:
lines = fin.readlines()
lines = [l.rstrip() for l in lines if not banned(l)]
for l in lines:
fout.write(l + '\n')
fout.write('\n')
def combine_libaudiofile(fout_name, libaudiofile_path):
with open(fout_name, 'w') as fout:
fout.write(file_header + "\n")
fout.write("/*\n")
cat_file(fout, os.path.join(libaudiofile_path, '../COPYING'))
fout.write("*/\n\n")
fout.write(prepend_defs + "\n")
for f in file_list:
fout.write(f"// file: {f}\n")
cat_file(fout, os.path.join(libaudiofile_path, f))
def main():
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help']:
print('Usage: generate_audiofile_cpp.py [output_filename] [libaudiofile_src_dir]')
print('Defaults: [output_filename = "audiofile.cpp"] [libaudiofile_src_dir = "./audiofile/libaudiofile"]')
return
fout_name = sys.argv[1] if len(sys.argv) > 1 else 'audiofile.cpp'
libaudiofile_path = sys.argv[2] if len(sys.argv) > 2 else './audiofile/libaudiofile'
combine_libaudiofile(fout_name, os.path.expanduser(libaudiofile_path))
main()