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