[Flac-dev] Flac and OggFlac

Josh Coalson
2005-10-04T10:37:36Z

--- Erik de Castro Lopo <erikd-flac@mega-nerd.com>
wrote:
> HI all,
>
> I have already added FLAC support to libsndfile and I am now
> working on adding support for OggFLAC.

cool.

> I have a couple of
> question about things that seem radically different between
> regular FLAC and OggFLAC.
>
>   1) FLAC has a function:
>
>         FLAC__seekable_stream_decoder_get_decode_position
>
>       but there seems to be no corresponding function:
>
>         OggFLAC__seekable_stream_decoder_get_decode_position
>
>       Why is that?

that function is not really possible with ogg flac because
flac frames (which are in ogg packets) can be broken up into
multiple pages.

the reason I added that function was because of a design flaw
in native FLAC, where raw frames cannot be fully extracted without
decoding.  for example, for taking an existing native FLAC file,
extracting the frames and putting them in a matroska container,
the program that does this has to decode a frame, use that function
to find where it is, and know that the bytes between it and the
previous call is where the frame is.

but with ogg flac that can span a page boundary so you can't
extract the frame that way.  best to use an ogg decoder to
recover pages, then packets.  then you don't even need to
decode the flac frames.

unless there is another reason you need that kind of functionality?

(p.s. this might also help:
http://flac.sourceforge.net/ogg_mapping.html)

>   2) I have registered a metadata callback function with
>      OggFLAC__seekable_stream_decoder_set_metadata_callback and
>      I'm looking at the metadata struct being passed back. When
> 	 using regular FLAC the field:
>
>         metadata->data.stream_info.total_samples
>
>      is set correctly, but with OggFLAC it seems to always be
> 	 zero. Why?
>
> Can anyone shed any light?

normally the flac encoder goes back to fill in missing STREAMINFO
fields after encoding is finished.  the encoder may not know
total_samples when encoding starts; if not it has to go back and
put it in at the end of encoding.  even when encoding to ogg flac
as of flac-1.1.2 it should do that.  so either:

- the ogg flac file was encoded with flac-1.1.1 or earlier
- the ogg flac file was encoded to stdout so the writeback couldn't
  happen (flac --ogg file.wav > file.flac)
- there is a bug somewhere!

Josh




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005