liboggvorbis as a single-file

posted in DevJournal for project QLMesh 2.0
Published July 20, 2018
Advertisement

liboggvorbis combined into one file - might be usefull if you want to simpifie dependencies of your project. 

Get it here.


-rw-r--r--  1 piecuchp  staff   2.0M Apr 26 17:55 oggvorbis.c
-rw-r--r--  1 piecuchp  staff   134K Apr 26 17:55 oggvorbis.h
-rw-r--r--  1 piecuchp  staff   3.1M Apr 26 17:55 oggvorbis.o

 

Combining script is quite complex and not well commented (also I might make some changes into source code that I don't recall right now) but maybe someone find it usefull:


#!/bin/bash

src_c="\
\
 lib/codebook.h lib/mdct.h lib/envelope.h lib/smallft.h lib/codec_internal.h lib/lookup.h lib/lookup_data.h lib/lpc.h lib/lsp.h lib/masking.h lib/misc.h lib/os.h lib/registry.h lib/scales.h lib/window.h\
 lib/books/floor/floor_books.h lib/books/coupled/res_books_stereo.h lib/books/uncoupled/res_books_uncoupled.h lib/books/coupled/res_books_51.h\
 lib/analysis.c lib/bitrate.c lib/block.c lib/codebook.c lib/envelope.c lib/floor0.c lib/floor1.c lib/info.c lib/lookup.c lib/lpc.c lib/lsp.c lib/mapping0.c lib/mdct.c lib/psy.c lib/registry.c lib/res0.c lib/sharedbook.c lib/smallft.c lib/synthesis.c lib/vorbisenc.c lib/vorbisfile.c lib/window.c\
"
src_h="\
 include/ogg/config_types.h include/ogg/os_types.h include/ogg/ogg.h\
 lib/ogg/bitwise.c lib/ogg/framing.c\
 include/vorbis/codec.h include/vorbis/vorbisenc.h include/vorbis/vorbisfile.h\
"

mkdir -p lib-portable

files=0

C="lib-portable/oggvorbis.c"
H="lib-portable/oggvorbis.h"

echo "/** $0: `date`*/" > "$C"
echo "" >> "$C"
echo "_#include \"oggvorbis.h\"" >> "$C"
echo "" >> "$C"
echo "#define _BUILD_SINGLE_SOURCE" >> "$C"
echo "#ifdef __cplusplus" >> "$C"
echo "# define restrict __restrict__" >> "$C"
echo "#endif" >> "$C"
echo "" >> "$C"

echo "/** $0: `date`*/" > "$H"
echo "" >> "$H"

line_offset=3

for c in $src_c; do
  if [ -e "$c" ]; then
    echo "/** $0: $c*/" >> "$C"
    echo "" >> "$C"
    #line=`cat "$C"|wc -l`
    echo "#line $line_offset \"$c\"" >> "$C"
    cat $c \
            | sed "s/\([^_]\)ilog/\1ilog${cnt}/g" \
            | sed "s/FLOOR1_fromdB_LOOKUP/FLOOR1_fromdB_LOOKUP${cnt}/g" \
            | sed "s/bitreverse/bitreverse${cnt}/g" \
        >> "$C"
    echo "" >> "$C"
    ((cnt++))
    echo -n "."
  else
    # use '' for space
    echo "" >> "$C"
    echo "${c//\'\'/ }" >> "$C"
    echo "" >> "$C"
    echo -n "_"
  fi
done

for h in $src_h; do
  if [ -e "$h" ]; then
    echo "/** $0: $h*/" >> "$H"
    echo "" >> "$H"
    echo "#line $line_offset \"$h\"" >> "$H"
    cat $h >> "$H"
    echo "" >> "$H"
    ((cnt++))
    echo -n "."
  else
    # use '' for space
    echo "" >> "$H"
    echo "${h//\'\'/ }" >> "$H"
    echo "" >> "$H"
    echo -n "_"
  fi
done

for i in lib/modes/*.h; do
    inl=`basename "$i"`
    sed -i "" -e "/#include \"modes\/$inl\"/r $i" -e "/#include \"modes\/$inl\"/d" "$C"
    echo -n "@"
done

echo ""

sed -i "" -e "/^#\(.*\)include \".*\.h\".*$/d" "$H"
sed -i "" -e "/^#\(.*\)include \<ogg\/.*\.h\>.*$/d" "$H" "$C"
sed -i "" -e "/#include_inline \"psy.h\"/r lib/psy.h" -e "/#include_inline \"psy.h\"/d" "$C"
sed -i "" -e "/#include_inline \"bitrate.h\"/r lib/bitrate.h" -e "/#include_inline \"bitrate.h\"/d" "$C"
sed -i "" -e "/#include_inline \"highlevel.h\"/r lib/highlevel.h" -e "/#include_inline \"highlevel.h\"/d" "$C"
sed -i "" -e "/#include_inline \"backends.h\"/r lib/backends.h" -e "/#include_inline \"backends.h\"/d" "$C"
sed -i "" -e "/#include_inline \"asm_arm.h\"/r tremor/asm_arm.h" -e "/#include_inline \"asm_arm.h\"/d" "$C"
sed -i "" -e "/# include \"collect.c\"/r theora/lib/collect.c" -e "/# include \"collect.c\"/d" "$C"
sed -i "" -e "/^#\(.*\)include \".*\.h\".*$/d" "$C"
sed -i "" -e "/^#\(.*\)include \<theora\/.*\.h\>.*$/d" "$C"

sed -i "" -e "s/^_#/#/" "$C"

echo "** Done (with $cnt files)"

 

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement