You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.8 KiB

  1. --- a/m4/ogg.m4
  2. +++ b/m4/ogg.m4
  3. @@ -29,7 +29,7 @@ XIPH_GCC_WARNING([-I$ogg_prefix/include],,
  4. ])
  5. AC_CACHE_CHECK([for libogg], xt_cv_lib_ogg,
  6. [dnl
  7. -OGG_LIBS="-logg"
  8. +OGG_LIBS="-lvorbisidec"
  9. #
  10. # check if the installed Ogg is sufficiently new.
  11. diff --git a/m4/vorbis.m4 b/m4/vorbis.m4
  12. index 17add29..066dc2a 100644
  13. --- a/m4/vorbis.m4
  14. +++ b/m4/vorbis.m4
  15. @@ -38,9 +38,9 @@ if test "x$vorbis_prefix" != "x$ogg_prefix"; then
  16. ])
  17. fi
  18. -VORBIS_LIBS="-lvorbis"
  19. -VORBISFILE_LIBS="-lvorbisfile"
  20. -VORBISENC_LIBS="-lvorbisenc"
  21. +VORBIS_LIBS="-lvorbisidec"
  22. +VORBISFILE_LIBS="-lvorbisidec"
  23. +VORBISENC_LIBS="-lvorbisidec"
  24. xt_save_LIBS="$LIBS"
  25. xt_save_LDFLAGS="$LDFLAGS"
  26. @@ -58,18 +58,6 @@ AC_TRY_LINK_FUNC(ogg_stream_init, [xt_lib_vorbis=ok],
  27. )
  28. ])
  29. -if test "x$xt_lib_vorbis" = "xok"; then
  30. -#
  31. -# Now check if the installed Vorbis is sufficiently new.
  32. -#
  33. -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  34. -#include <vorbis/codec.h>
  35. -#include <vorbis/vorbisenc.h>
  36. - ], [
  37. -struct ovectl_ratemanage_arg a;
  38. -])],,[xt_lib_vorbis="old version found"])
  39. -AC_MSG_RESULT([$xt_lib_vorbis])
  40. -fi
  41. CPPFLAGS="$xt_save_CPPFLAGS"
  42. LIBS="$xt_save_LIBS"
  43. LDFLAGS="$xt_save_LDFLAGS"
  44. --- a/src/format_vorbis.c
  45. +++ b/src/format_vorbis.c
  46. @@ -19,7 +19,7 @@
  47. #include <stdlib.h>
  48. #include <ogg/ogg.h>
  49. -#include <vorbis/codec.h>
  50. +#include <tremor/ivorbiscodec.h>
  51. #include <memory.h>
  52. #include <string.h>
  53. @@ -34,6 +34,7 @@
  54. #define CATMODULE "format-vorbis"
  55. #include "logging.h"
  56. +int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
  57. typedef struct vorbis_codec_tag
  58. {
  59. @@ -583,3 +584,91 @@ static refbuf_t *process_vorbis_page (ogg_state_t *ogg_info,
  60. return NULL;
  61. }
  62. +/* Some additional functions from vorbis missing from tremor */
  63. +
  64. +static void _v_writestring(oggpack_buffer *o,char *s, int bytes)
  65. +{
  66. +
  67. + while(bytes--){
  68. + oggpack_write(o,*s++,8);
  69. + }
  70. +}
  71. +
  72. +static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc)
  73. +{
  74. + char temp[]="Xiph.Org libVorbis I 20150104";
  75. + int bytes = strlen(temp);
  76. +
  77. + /* preamble */
  78. + oggpack_write(opb,0x03,8);
  79. + _v_writestring(opb,"vorbis", 6);
  80. +
  81. + /* vendor */
  82. + oggpack_write(opb,bytes,32);
  83. + _v_writestring(opb,temp, bytes);
  84. +
  85. + /* comments */
  86. +
  87. + oggpack_write(opb,vc->comments,32);
  88. + if(vc->comments){
  89. + int i;
  90. + for(i=0;i<vc->comments;i++){
  91. + if(vc->user_comments[i]){
  92. + oggpack_write(opb,vc->comment_lengths[i],32);
  93. + _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
  94. + }else{
  95. + oggpack_write(opb,0,32);
  96. + }
  97. + }
  98. + }
  99. + oggpack_write(opb,1,1);
  100. +
  101. + return(0);
  102. +}
  103. +
  104. +void vorbis_comment_add(vorbis_comment *vc,char *comment)
  105. +{
  106. + vc->user_comments=_ogg_realloc(vc->user_comments,
  107. + (vc->comments+2)*sizeof(*vc->user_comments));
  108. + vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
  109. + (vc->comments+2)*sizeof(*vc->comment_lengths));
  110. + vc->comment_lengths[vc->comments]=strlen(comment);
  111. + vc->user_comments[vc->comments]=_ogg_malloc(vc->comment_lengths[vc->comments]+1);
  112. + strcpy(vc->user_comments[vc->comments], comment);
  113. + vc->comments++;
  114. + vc->user_comments[vc->comments]=NULL;
  115. +}
  116. +
  117. +void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents)
  118. +{
  119. + char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
  120. + strcpy(comment, tag);
  121. + strcat(comment, "=");
  122. + strcat(comment, contents);
  123. + vorbis_comment_add(vc, comment);
  124. +
  125. + return;
  126. +}
  127. +
  128. +int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op)
  129. +{
  130. + oggpack_buffer opb;
  131. +
  132. + oggpack_writeinit(&opb);
  133. + if(_vorbis_pack_comment(&opb,vc)){
  134. + oggpack_writeclear(&opb);
  135. + return OV_EIMPL;
  136. + }
  137. +
  138. + op->packet = _ogg_malloc(oggpack_bytes(&opb));
  139. + memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
  140. +
  141. + op->bytes=oggpack_bytes(&opb);
  142. + op->b_o_s=0;
  143. + op->e_o_s=0;
  144. + op->granulepos=0;
  145. + op->packetno=1;
  146. +
  147. + oggpack_writeclear(&opb);
  148. + return 0;
  149. +}