ANN: Ogg library in Go

1,108 views
Skip to first unread message

Gerard

unread,
Sep 21, 2012, 1:18:04 AM9/21/12
to golan...@googlegroups.com
Hello gophers, I just finished re-writing libogg 1.3.0 in Go (www.github.com/grd/ogg). That by itself isn't much, but it can be used as a basis for other libraries such as ogg/vorbis, celt, flac etc (even with cgo imo). The re-writing isn't exactly a one on one copy of the features, but how I think it should be done. The unit testing passes completely. I must say that when looking at the code it looks quite easy, however the coding was anything but easy.

Suggestions for improvements are welcome. O yes, I have an OT question about the licencing stuff. Can I use the std Go license or should I use the xiph license?

Regards,
Gerard

Archos

unread,
Sep 21, 2012, 2:20:48 AM9/21/12
to golan...@googlegroups.com
Hi!
Respect to the license, you can license it like you want since you're its creator but please don't use a GPL license in packages. You don't give the copyright to "Xiph.org Foundation" or another one; the copyright is yours.

I have seen that some functions, like PageOut, return  an int with different meaning for each returned value; it's ok in languages like C/C++ but in Go could be done returning an error, if were necessary, and constants.

i.e., in function PageOut[1], instead of return:

// return values:
// -1) recapture (hole in data)
// 0) need more data
// 1) page returned

you could return a error instead of -1 or 0, and nil error instad of 1

[1]: https://github.com/grd/ogg/blob/master/ogg.go#L744


By the way, thanks because Go needs packages related to audio/video.

Gerard

unread,
Sep 21, 2012, 1:41:09 PM9/21/12
to golan...@googlegroups.com
Thanks for the reply. I agree that packages for audio/video are welcome. As I said before I am working on a vorbis wrapper but it is still premature. We'll see ;-)

Gerard

Harley Laue

unread,
Sep 21, 2012, 2:01:41 PM9/21/12
to Archos, golan...@googlegroups.com
On Fri, Sep 21, 2012 at 1:20 AM, Archos <raul...@sent.com> wrote:
> Hi!
> Respect to the license, you can license it like you want since you're its
> creator but please don't use a GPL license in packages. You don't give the
> copyright to "Xiph.org Foundation" or another one; the copyright is yours.

I haven't looked at the source too closely, and I'm not a lawyer. I
think as long as you didn't actually use any code from libogg directly
(only used the references, and it looks like at least the API
reference) you should be fine to use whatever licence you like.

> I have seen that some functions, like PageOut, return an int with different
> meaning for each returned value; it's ok in languages like C/C++ but in Go
> could be done returning an error, if were necessary, and constants.
>
> i.e., in function PageOut[1], instead of return:
>
> // return values:
> // -1) recapture (hole in data)
> // 0) need more data
> // 1) page returned
>
> you could return a error instead of -1 or 0, and nil error instad of 1
>
> [1]: https://github.com/grd/ogg/blob/master/ogg.go#L744

I agree here. The C API frequently does that. Another example is the
ogg_sync_wrote returning -1 on error and 0 otherwise. func (oy
*SyncState) Wrote(Bytes int) int [1] Follows this exactly. In this
case, it could/should probably return error with the error when needed
and nil otherwise. I'm sure there are other cases where you should use
something like this as well.

Does this not implement the ogg bitpack part of the C API? I see the
General, Encoding, & Decoding, but I don't see Bitpacking. (Granted
I'm not intimately familiar with using the C libogg API, I just
noticed that while doing a quick comparison.)

[1] https://github.com/grd/ogg/blob/master/ogg.go#L635

> By the way, thanks because Go needs packages related to audio/video.

Agreed! Any work here is great to see :)

> El viernes, 21 de septiembre de 2012 06:18:04 UTC+1, Gerard escribió:
>>
>> Hello gophers, I just finished re-writing libogg 1.3.0 in Go
>> (www.github.com/grd/ogg). That by itself isn't much, but it can be used as a
>> basis for other libraries such as ogg/vorbis, celt, flac etc (even with cgo
>> imo). The re-writing isn't exactly a one on one copy of the features, but
>> how I think it should be done. The unit testing passes completely. I must
>> say that when looking at the code it looks quite easy, however the coding
>> was anything but easy.
>>
>> Suggestions for improvements are welcome. O yes, I have an OT question
>> about the licencing stuff. Can I use the std Go license or should I use the
>> xiph license?
>>
>> Regards,
>> Gerard
>
> --
>
>

Gerard

unread,
Sep 23, 2012, 3:58:22 AM9/23/12
to golan...@googlegroups.com
Nice initiative. WebM is quite a beast. But I like the idea behind it. The problem with Matroska is that it can contain everything. Managing that is a nightmare. So the guys from Google said: for the web we want something that works. WebM can only contain Vorbis and VP8. So it's way better managable. That said, IMO it's still a beast from an API perspective. It is just the nature of A/V. 
I see you also use goroutines. That's interesting. I sticked much closer to the original C implementation but now that it's working I might try that also. What helped me a lot was the unit testing. It solved lots of bugs I just couldn't find otherwise. 

Good luck and keep us informed!
Reply all
Reply to author
Forward
0 new messages