1 --- a/src/format_vorbis.c
2 +++ b/src/format_vorbis.c
7 -#include <vorbis/codec.h>
8 +#include <tremor/ivorbiscodec.h>
13 #define CATMODULE "format-vorbis"
16 +int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
18 typedef struct vorbis_codec_tag
20 @@ -583,3 +584,91 @@ static refbuf_t *process_vorbis_page (og
24 +/* Some additional functions from vorbis missing from tremor */
26 +static void _v_writestring(oggpack_buffer *o,char *s, int bytes)
30 + oggpack_write(o,*s++,8);
34 +static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc)
36 + char temp[]="Xiph.Org libVorbis I 20150104";
37 + int bytes = strlen(temp);
40 + oggpack_write(opb,0x03,8);
41 + _v_writestring(opb,"vorbis", 6);
44 + oggpack_write(opb,bytes,32);
45 + _v_writestring(opb,temp, bytes);
49 + oggpack_write(opb,vc->comments,32);
52 + for(i=0;i<vc->comments;i++){
53 + if(vc->user_comments[i]){
54 + oggpack_write(opb,vc->comment_lengths[i],32);
55 + _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
57 + oggpack_write(opb,0,32);
61 + oggpack_write(opb,1,1);
66 +void vorbis_comment_add(vorbis_comment *vc,char *comment)
68 + vc->user_comments=_ogg_realloc(vc->user_comments,
69 + (vc->comments+2)*sizeof(*vc->user_comments));
70 + vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
71 + (vc->comments+2)*sizeof(*vc->comment_lengths));
72 + vc->comment_lengths[vc->comments]=strlen(comment);
73 + vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1);
74 + strcpy(vc->user_comments[vc->comments], comment);
76 + vc->user_comments[vc->comments]=NULL;
79 +void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents)
81 + char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
82 + strcpy(comment, tag);
83 + strcat(comment, "=");
84 + strcat(comment, contents);
85 + vorbis_comment_add(vc, comment);
90 +int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op)
94 + oggpack_writeinit(&opb);
95 + if(_vorbis_pack_comment(&opb,vc)){
96 + oggpack_writeclear(&opb);
100 + op->packet = _ogg_malloc(oggpack_bytes(&opb));
101 + memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
103 + op->bytes=oggpack_bytes(&opb);
109 + oggpack_writeclear(&opb);
114 @@ -38,9 +38,9 @@ if test "x$vorbis_prefix" != "x$ogg_pref
118 -VORBIS_LIBS="-lvorbis"
119 -VORBISFILE_LIBS="-lvorbisfile"
120 -VORBISENC_LIBS="-lvorbisenc"
121 +VORBIS_LIBS="-lvorbisidec"
122 +VORBISFILE_LIBS="-lvorbisidec"
123 +VORBISENC_LIBS="-lvorbisidec"
126 xt_save_LDFLAGS="$LDFLAGS"
127 @@ -58,18 +58,6 @@ AC_TRY_LINK_FUNC(ogg_stream_init, [xt_li
131 -if test "x$xt_lib_vorbis" = "xok"; then
133 -# Now check if the installed Vorbis is sufficiently new.
135 -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
136 -#include <vorbis/codec.h>
137 -#include <vorbis/vorbisenc.h>
139 -struct ovectl_ratemanage_arg a;
140 -])],,[xt_lib_vorbis="old version found"])
141 -AC_MSG_RESULT([$xt_lib_vorbis])
143 CPPFLAGS="$xt_save_CPPFLAGS"
145 LDFLAGS="$xt_save_LDFLAGS"
148 @@ -29,7 +29,7 @@ XIPH_GCC_WARNING([-I$ogg_prefix/include]
150 AC_CACHE_CHECK([for libogg], xt_cv_lib_ogg,
153 +OGG_LIBS="-lvorbisidec"
156 # check if the installed Ogg is sufficiently new.