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.

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