Help - Search - Members - Calendar
Full Version: Using the Flac library
Hydrogenaudio Forums > Lossless Audio Compression > FLAC
kurt2
Hi.

I am trying to figure out how to use the available Flac source codes to create my own decoder.

My programming experiences include C and Java.

I've downloaded the source codes from
http://prdownloads.sourceforge.net/flac/fl...tar.gz?download

but I don't know what to do with it.

Anyone or anysite that can help me?

Thanks in advance.
kurt2
or perhaps a short tutorial/guide to get me started
kurt2
from the README file,

"./configure && make && make check && make install"

can't seem to be executed.

I'm running Windows.
bryant
QUOTE(kurt2 @ Oct 17 2005, 07:38 PM)
from the README file,

"./configure && make && make check && make install"

can't seem to be executed.

I'm running Windows.
*


Those instructions are for building on Linux. I believe that there was a .zip file there somewhere with sources to build on Windows, probably using MSVC++. Unless you have a .dsw file you're not going to have very good luck building on Windows.

You might be able to build it on Cygwin if you have that...

kjoonlee
From http://flac.sourceforge.net/download.html:

FLAC 1.1.2 full source code; also includes documentation and build systems for Windows (MSVC++) and *nix,*BSD,OS/2,OS X (autotools)

I think that means you're all set if you have MSVC++.
jcoalson
QUOTE(kurt2 @ Oct 17 2005, 10:38 PM)
from the README file,

"./configure && make && make check && make install"

can't seem to be executed.

I'm running Windows.

look further down in that same README file, it has explicit instructions for building with MSVC. if you're not using gcc or msvc then you'll have to tell what your compiler you're using.

or you could just use the prebuilt windows libs+headers: http://prdownloads.sourceforge.net/flac/fl...in.zip?download

once you have the libraries, the full API docs are here: http://flac.sourceforge.net/api/

feel free to ask more questions here and I'll try to answer.

Josh
kurt2
hi.

I'm using lccwin32. I didn't notice the prebuilt Windows link, but now that Josh posted it, i'll go download it now. Thanks a lot.

I'm new to this kind of programming, and only been through basic C and Java courses.

Basically i'm confused now on how to use the available codes.

Inside the bundle, there's a lot of .c and .h files. Are there any examples on how to use them? Or perhaps a brief tutorial to get me started on my program? I'm still confused on how to use them.

In terms of API, i've only used the Java API before, where i search for classes that can do the tasks i'm looking for. It is the same for Flac's API?

I hope you can help. I'm sorry if the question is too vague. I'm basically just stuck at this starting point.

Thanks in advance again for you help.
soiaf
I wrote a simple FLAC codec which might help you show the structure of FLAC decoding at least.

FLAC codec source code

This source code is for the Roku HD1000 so you wouldn't be able to compile it.

Reading the FLAC API by itself can be a bit confusing (initially at least), however, if you look at the file CascadeAudioCodecFLAC.cpp you'll see how to set up the decoder in the DoInitialDecode() function.
If you cross-reference each call to the API reference it should hopefully get you started.
The function DecodeBytes() is used to actually decode the FLAC stream.

jcoalson
QUOTE(kurt2 @ Oct 18 2005, 04:43 AM)
I'm using lccwin32.

hmm, never used that compiler.

QUOTE(kurt2 @ Oct 18 2005, 04:43 AM)
I'm new to this kind of programming, and only been through basic C and Java courses.

Basically i'm confused now on how to use the available codes.

Inside the bundle, there's a lot of .c and .h files. Are there any examples on how to use them? Or perhaps a brief tutorial to get me started on my program? I'm still confused on how to use them.

maybe this isn't the best program to start with. most of the work is going to be figuring out how to compile anything at all (with makefiles, IDE, whatever) and how to link to external libraries.

QUOTE(kurt2 @ Oct 18 2005, 04:43 AM)
In terms of API, i've only used the Java API before, where i search for classes that can do the tasks i'm looking for. It is the same for Flac's API?

I hope you can help. I'm sorry if the question is too vague. I'm basically just stuck at this starting point.

that FLAC API link leads you right through what you need to know. it has an introduction, and a "getting started" section which points you to the modules. since you are looking for a decoder you follow the link there to the decoder interfaces, read what's there and follow the link for the interface you want. the interface docs tell you exactly what functions to call in what order.

really, it will help to read the basic stuff first before asking, then your questions will be more specific and easier to answer.

Josh
kurt2
QUOTE(soiaf @ Oct 18 2005, 04:21 AM)
I wrote a simple FLAC codec which might help you show the structure of FLAC decoding at least.

FLAC codec source code

This source code is for the Roku HD1000 so you wouldn't be able to compile it.

Reading the FLAC API by itself can be a bit confusing (initially at least), however, if you look at the file CascadeAudioCodecFLAC.cpp you'll see how to set up the decoder in the DoInitialDecode() function.
If you cross-reference each call to the API reference it should hopefully get you started.
The function DecodeBytes() is used to actually decode the FLAC stream.
*



Thanks a lot soiaf, for the file. Begining to understand what the API is trying to say.
However, do you have a version in C, so that it can be clearer because i've never learned C++ before, and I can hardly understand the syntax.

So i've read the decoder part of the API, the sequence seems to be:
-create new instance of stream
-set callbacks
-initialize
-process
-finish
-delete

I just switched to Dev-C++, which uses GCC. I'm still in windows.

I tried to start coding to test, copied the "include" directory beside my .c file. But i get "undefined reference to FLAC__stream_decoder_new()"

CODE
#include <stdio.h>
#include "include/flac/stream_decoder.h"

int main(void)
{
   FLAC__StreamDecoder *flacstream;
   
   flacstream = FLAC__stream_decoder_new();
       
}


Is my approach totally wrong?

By the way, thanks Josh for the previous quick reply
jcoalson
all of the C FLAC API is in a library called libFLAC. so to create the final program you will have to either 1) link against an already-compiled version of the library, or 2) compile the code from libFLAC with your program.

1) will mean first you have to find a lib or build it yourself from the sources. the README file lists instructions for 2 way of building with gcc. the library in the flac-1.1.2-win32-dev package is built with MSVC and won't work with gcc.

2) is a little tricky because of the assembly optimizations, which need to be assembled separately with NASM on windows. if you're okay without those, you can leave them out and compile adding '-DFLAC__NO_ASM' to the gcc compile flags. the files you will need to compile are in src/libFLAC

Josh
soiaf
QUOTE(kurt2 @ Oct 20 2005, 07:37 AM)
Thanks a lot soiaf, for the file. Begining to understand what the API is trying to say.
However, do you have a version in C, so that it can be clearer because i've never learned C++ before, and I can hardly understand the syntax.
*



The source code is for a hardware device (the Roku PhotoBridge) that has its own API, to plugin to this system I had to have a C++ interface.
However its using the libFLAC API calls rather than the libFLAC++ API calls, i.e. its very C, rather than C++ focused.
The zip package contains a number of files taken from the libFLAC source tree - the codec plugin is only concerned with decoding files so all encoding code has been removed - this is one of the advantages of the libFLAC source, you can remove various parts/modules if you have no need for them.
So while all the files have the extension .cpp, they are in fact mostly just renamed from the .c version, also a few minor changes for the include files. The platform I'm compiling for has no assembly and uses fixed-point maths.

So, this codec plugin is using the second method that Josh mentions in his above post, all the required code from libFLAC is compiled with the program, rather than linking against an already prepared library.
kurt2
hi. i'm working in Linux now, and was trying to build using gcc.

i used the following command and last output is shown:

./configure; make; make install

CODE
.
.
.
make[1]: Leaving directory `/home/user1/flac-1.1.2'
Making install in doc
make[1]: Entering directory `/home/user1/flac-1.1.2/doc'
Making install in .
make[2]: Entering directory `/home/user1/flac-1.1.2/doc'
make[3]: Entering directory `/home/user1/flac-1.1.2/doc'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/doc/flac-1.1.2" || mkdir -p -- . "/usr/local/share/doc/flac-1.1.2"
mkdir: cannot create directory `/usr/local/share/doc': Permission denied
make[3]: *** [install-docDATA] Error 1
make[3]: Leaving directory `/home/user1/flac-1.1.2/doc'
make[2]: *** [install-am] Error 2
make[2]: Leaving directory `/home/user1/flac-1.1.2/doc'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/user1/flac-1.1.2/doc'
make: *** [install-recursive] Error 1


it stops after reaching here. I tried changing the flac folder to full access using chmod but still it won't work.

Then i tried to use Makefile.lite, and I deleted the -DFLAC__HAS_NASM (the "Define"s )in the file /src/libFLAC/Makefile.lite, because I don't have nasm installed, and encountered the following:

CODE
(cd doc; make -f Makefile.lite)
make[1]: Entering directory `/home/user1/flac-1.1.2/doc'
make[1]: `FLAC.tag' is up to date.
make[1]: Leaving directory `/home/user1/flac-1.1.2/doc'
(cd src; make -f Makefile.lite release)
make[1]: Entering directory `/home/user1/flac-1.1.2/src'
(cd libFLAC; make -f Makefile.lite release)
make[2]: Entering directory `/home/user1/flac-1.1.2/src/libFLAC'
nasm -f elf -d OBJ_FORMAT_elf -i ia32/ ia32/cpu_asm.nasm -o ia32/cpu_asm.release.o
make[2]: nasm: Command not found
make[2]: *** [ia32/cpu_asm.release.o] Error 127
make[2]: Leaving directory `/home/user1/flac-1.1.2/src/libFLAC'
make[1]: *** [libFLAC] Error 2
make[1]: Leaving directory `/home/user1/flac-1.1.2/src'
make: *** [src] Error 2


I've been trying to solve for days, but no progress.

Any help is appreciated. Thanks
jcoalson
1) the first problem is caused by 'make install' trying to install into a system area when you are probably running as a regular user. if you really want to install to the system area you have to run 'make install' as root.

if you just want to install the files to some user directory to play around with, e.g. ~/flac-install, do

CODE
./configure --prefix=~/flac-install; make; make install


2) the Makefile.lite system is pretty rudimentary, but you can get around the problem you are having like so:

edit src/libFLAC/Makefile.lite

change all occurrences of -DFLAC__HAS_NASM to -DFLAC__NO_ASM
[if you already deleted them that should be fine too.]

delete the lines

CODE
SRCS_NASM = \
   ia32/cpu_asm.nasm \
   ia32/fixed_asm.nasm \
   ia32/lpc_asm.nasm


or you could just install nasm from http://nasm.sourceforge.net/

Josh
kurt2
hi. i used the command
CODE

./configure --prefix=/home/kurt/flac-1.1.2/extra/usr/local; make; make install


kurt is my user name, and extra/usr/local is the directory i created, which had to end in /usr/local, else there's another error.

Everything seems to be ok.

Then when i tried to run flac from [extra/usr/local/bin],
QUOTE
./flac: error while loading shared libraries: libOggFLAC.so.3: cannot open shared object file: No such file or directory


The file libOggFLAC.so.3 is available, but in the /extra/.... folder which i created, and not in the default /usr/local/lib directory, which i have no access to. (I have no root access for the school's linux machine)

I tried looking at the makefile to see if i can tweak anything to adjust this, but ...

is it possible to change the directory that flac refers to?

thanks.
jcoalson
QUOTE(kurt2 @ Oct 27 2005, 04:43 AM)
is it possible to change the directory that flac refers to?

yep:

CODE
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/kurt/flac-1.1.2/extra/usr/local/lib flac


the search path for shared libraries is in the $LD_LIBRARY_PATH shell variable. since your shell is probably bash, you can alter the variable just for one process with the prefix scheme above. or change it for the whole shell like:

CODE
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/kurt/flac-1.1.2/extra/usr/local/lib
flac


(that's 2 separate commands)

another alternative is to disable building the shared library, then it will link statically:

CODE
./configure --disable-shared --prefix=...


Josh

kerpal
hmm...i saw this thread, find it interesting and decided to try create my own decoder as well, and probably help out kurt2.

but i came across some problems myself sad.gif

So far i've sort of completed the body of each callbacks (read, write, metadata and error). I roughly guess what needs to be done in each callback by the refering to the API (such as what status to return, etc).

I have a buffer(inputBuff) that takes in a certain amount of data regularly from the FLAC file. I expect to decode the data in inputBuff, and pass to another buffer(outputBuff) which should be PCM

The thing that i don't understand is this:

QUOTE
Read callback: Set the read callback. The supplied function will be called when the decoder needs more input data. The address of the buffer to be filled is supplied, along with the number of bytes the buffer can hold. The callback may choose to supply less data and modify the byte count but must be careful not to overflow the buffer. The callback then returns a status code chosen from FLAC__StreamDecoderReadStatus.


Q1: The buffer mentioned in the quote(which is one of the callback's parameters), is it automatically created by the FLAC codes, or is it one of the buffers that i defined myself (inputBuff, outputBuff).

Q2: If not mistaken, callbacks are event-based, and read callback is called when the decoder needs more input data, as mentioned in the quote. Which buffer does it check for insufficient data?

Well, basically my questions are about buffers; how many do i need, what should be the program flow. This is what i'm blur at now.

jcoalson
A1. both input and output buffers are managed by libFLAC. you don't need to create inputBuff, and might not need outputBuff, depending on your design.

once you call one of the FLAC__*_decoder_process_*() functions, libFLAC is managing the execution until it finishes or there is an error. the first thing it probably will do is call your read callback to give it some FLAC data. you will use the client data to dig out a structure that has your input stream in it and read from it in the read callback to fill up the buffer and return.

A2. it's checking it's own internal input buffer (which is the one you are filling in the read callback).

there are examples in the test code of how to use each interface (see src/test_libFLAC/decoders.c and src/test_libFLAC++/decoders.cpp)

Josh
yong
Couldnt compile FLAC 1.1.2 with nasm optimization

Here is some part of msys console output:
CODE

long_code_here = ';
gcc -I../.. -I./include -I../../include -O2 -DNDEBUG -O3 -fomit-frame-pointer -funroll-loops -finline-functions -Wall -W -Winline -DFLaC__INLINE=__inline__ -O3 -mtune=pentium4 -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -mfpmath=sse,387 -o flac.exe analyze.o decode.o encode.o main.o local_string_utils.o utils.o vorbiscomment.o ../../src/libOggFLAC/.libs/libOggFLAC.a /source/flac/src/libFLAC/.libs/libFLAC.a ../../src/share/grabbag/.libs/libgrabbag.a ../../src/share/getopt/libgetopt.a ../../src/share/replaygain_analysis/.libs/libreplaygain_analysis.a ../../src/share/replaygain_synthesis/.libs/libreplaygain_synthesis.a ../../src/share/utf8/.libs/libutf8.a ../../src/libFLAC/.libs/libFLAC.a /mingw/lib/libogg.a -lm
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x119b): undefined reference to `FLAC__lpc_restore_signal_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x11a2): undefined reference to `FLAC__lpc_restore_signal_asm_ia32_mmx'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x11a9): undefined reference to `FLAC__lpc_restore_signal_asm_ia32_mmx'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x11ec): undefined reference to `FLAC__lpc_restore_signal_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x11f3): undefined reference to `FLAC__lpc_restore_signal_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_decoder.o):stream_decoder.c:(.text+0x11fa): undefined reference to `FLAC__lpc_restore_signal_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1144): undefined reference to `FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x115c): undefined reference to `FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1166): undefined reference to `FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1187): undefined reference to `FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1aba): undefined reference to `FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1b2a): undefined reference to `FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1b40): undefined reference to `FLAC__lpc_compute_autocorrelation_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1c2c): undefined reference to `FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1c36): undefined reference to `FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1eaf): undefined reference to `FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(stream_encoder.o):stream_encoder.c:(.text+0x1eb4): undefined reference to `FLAC__lpc_compute_autocorrelation_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(cpu.o):cpu.c:(.text+0x16): undefined reference to `FLAC__cpu_info_asm_ia32'
c:/source/flac/src/libFLAC/.libs/libFLAC.a(cpu.o):cpu.c:(.text+0x4f): undefined reference to `FLAC__cpu_info_extended_amd_asm_ia32'
collect2: ld returned 1 exit status
make[3]: *** [flac.exe] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2


i have nasm0.98.39 installed, how to solve this problem?
although i can successful compiled FLAC with --disable-asm-optimizations,
but i wan to compare the GCC w/asm and ICL 8.1 build encoding speed wink.gif
(ICL 8.1 encoing speed is ~9x, GCC w/o asm enabled only ~6x in P4 machine)
jcoalson
whatever went wrong, it happened before the part you pasted. look farther up when it just starts to build in libFLAC/ia32 to see what happened. or possibly the configure step could not find nasm in the path.

Josh
yong
here is the full msys console output:
http://rapidshare.de/files/8344871/flac.zip.html

and im using this command when configure FLAC:
configure --disable-shared --enable-nasm-optimizations --enable-sse CFLAGS="-O3 -mtune=pentium4 -march=pentium4 -mmmx -msse -msse2 -mfpmath=sse -mfpmath=sse,387"

Anything wrong with my configure options?

I have similar problem when i treid to compiling orthers source code too,
http://www.hydrogenaudio.org/forums/index....showtopic=39130
i solved the problem my self because Devc++ generated an invalid make file(the -logg is appear before -lvorbis and -lvorbisenc in make file).
But FLAC source code is too complex for me, i dont know which make file(?) to edit... tongue.gif
jcoalson
looks fine, it is hard to tell what went wrong without looking at the symbol tables of the libraries (like with "nm"). when it builds libFLAC.a it is supposed to import the symbols from libFLAC-asm.a and it appears to do that, so I don't know what the problem is. maybe there is some problem with the object format used or symbol creation (usually differences in the leading underscore on symbols).

you could try the Makefile.lite system (see the README in the source), maybe that will work. make sure to set the include/lib path to your ogg libs in build/config.mk (at the end of the file).

Josh
yong
QUOTE(jcoalson @ Nov 30 2005, 08:39 AM)
looks fine, it is hard to tell what went wrong without looking at the symbol tables of the libraries (like with "nm").  when it builds libFLAC.a it is supposed to import the symbols from libFLAC-asm.a and it appears to do that, so I don't know what the problem is.  maybe there is some problem with the object format used or symbol creation (usually differences in the leading underscore on symbols).

you could try the Makefile.lite system (see the README in the source), maybe that will work.  make sure to set the include/lib path to your ogg libs in build/config.mk (at the end of the file).

Josh
*


I see, thank for the replies smile.gif

Here is the console output when i use makefile.lite:
http://rapidshare.de/files/8369794/makefil...output.zip.html
still have problem with the asm....
(im still a noob, couldnt do anything to FLAC source code sweat.gif)
ak
I believe configure needs a rule for mingw, otherwise it runs nasm with '-f elf'.

CODE
--- configure.in        2 Sep 2005 05:07:35 -0000       1.111
+++ configure.in        30 Nov 2005 14:59:37 -0000
@@ -54,7 +54,7 @@
AM_CONDITIONAL(FLaC__CPU_SPARC, test x$cpu_sparc = xtrue)
case "$host" in
       i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb;;
-       *-*-cygwin) OBJ_FORMAT=win32;;
+       *-*-cygwin|*mingw*) OBJ_FORMAT=win32;;
       *) OBJ_FORMAT=elf;;
esac
AC_SUBST(OBJ_FORMAT)
yong
QUOTE(ak @ Nov 30 2005, 11:11 PM)
I believe configure needs a rule for mingw, otherwise it runs nasm with '-f elf'.

CODE
--- configure.in        2 Sep 2005 05:07:35 -0000       1.111
+++ configure.in        30 Nov 2005 14:59:37 -0000
@@ -54,7 +54,7 @@
AM_CONDITIONAL(FLaC__CPU_SPARC, test x$cpu_sparc = xtrue)
case "$host" in
       i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb;;
-       *-*-cygwin) OBJ_FORMAT=win32;;
+       *-*-cygwin|*mingw*) OBJ_FORMAT=win32;;
       *) OBJ_FORMAT=elf;;
esac
AC_SUBST(OBJ_FORMAT)

*


thanks smile.gif
i finally able to compile FLAC with nasm tongue.gif
jcoalson
thanks, I'll check in the patch

Josh
kurt2
Hi guys.

I'm trying to do the seeking function for the stream decoder. I know that there's the seekable stream decoder, however i would like to use the stream decoder.
QUOTE
To seek within a stream the callbacks have only to flush the decoder using FLAC__stream_decoder_flush() and start feeding data from the new position through the read callback.

Sounds simple but when i refered to the seek_to_absolute_sample_ function in the seekable stream decoder, seems like there's more to it, e.g. checking the lower and upper bound, etc.

Are all these necessary?

So far for my project, when seeking is called from the remote, a "seek lookup" function will be called. Inside, i flush the stream decoder and calculate the seek point. The player (a digital media player) will seek to the corresponding location of the flac stream located inside its buffer. Then it loops back to the normal decoding functions (i.e. read, write, etc)

This seems to fulfil the quote above, but can't seem to work.

Anything else i missed? Maybe the best way is to just use the seekable stream decoder, however if it is just flushing and feeding in new data (just these two things to do), i would be easier for my case. (instead of changing the whole code to seekable stream decoder)

Thanks.
jcoalson
how doesn't it work? once you seek physically in the stream and start feeding data from there back through the read callback, you will get one sync error if the offset is not at the start of a frame. that is normal.

most of the complexity in FLAC__seekable_stream_decoder_seek_absolute() is for being able to seek to the exact target sample, and as fast as possible, with as little decoding as possible, even if there is no seek table. the upper/lower bounds are used to converge on the target frame quickly.

Josh
kurt2
Hi guys.

Yeah, "out of sync" is the problem. I get it each and everytime i try to seek.

Are there any easy ways that the stream_decoder has to go back in sync, regardless of location (as long as it gets back in sync)?

I've tried things like reseting the decoder and processing until end of metadata, feeding data (seeked location) that are of multiples of the blocksize, etc etc.

Anybody can help, beside using seekable_stream_decoder ?
jcoalson
sync errors are not a problem while seeking, they're expected. note how error_callback_() in the seekable stream decoder ignores errors while seeking. FLAC__stream_decoder_process_single() will return true even on sync error since it is not fatal to decoding. if you are in the middle of seeking, ignore the sync error in the error callback, and in your seek routine, check the status of the stream decoder after FLAC__stream_decoder_process_single() returns. if it is FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC, just call FLAC__stream_decoder_process_single() again until it syncs.

see also http://flac.sourceforge.net/api/group__fla...ecoder.html#a32

Josh
kerpal
hi everyone.

since this thread is about "Using the Flac library", i guess i'll just ask here...

In the ordinals.h, there's the following:

CODE
#ifndef _MSC_VER
#include <inttypes.h>
#endif


Unfortunately my developing environment (Linux, gcc variant) does not have inttypes.h, however it does have <sys/types.h>

I've notices in earlier releases that there's an option to use sys/types.h. Can i substitute inttypes with sys/types.h?

I searched the net for inttypes.h, and got this. But it's different from my sys/types.h

Differences for example, are:

typedef int int32_t; (sys/types.h)
typedef int int16_t; (inttypes.h from the above site)

Is it system dependant? I'm sorry if the question sounds too stupid, but i'm new in this field.

Thank you.
jcoalson
what version of libc or glibc is it? must be old. I think inttypes.h is ANSI C99.

you can't just substitute an inttypes.h from anywhere; the sizes have to match your compiler.

if your setup has a sys/types.h or stdint.h that defines int8_t, uint8_t, int16_t, ... then that should be sufficient and you can swap the #include.

Josh
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.