0001-Fix-static-linking-with-libmagic.patch 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. From 484275de103b2214cb8ff3868a2562e2c61ce0e1 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Thu, 8 Nov 2018 20:57:08 +0100
  4. Subject: [PATCH] Fix static linking with libmagic
  5. libmagic (from file package) already provides the buffer_init function
  6. so to avoid a build failure for applications wanting to statically link
  7. with twolame and libmagic (for example sox), rename buffer_init into
  8. bitbuffer_init (also rename buffer_deinit into bitbuffer_deinit and
  9. buffer_sstell into bitbuffer_sstell for consistency)
  10. Fixes:
  11. - http://autobuild.buildroot.org/results/b3fc62e7f372fe595966e84091c11ccdb4cfa77c
  12. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  13. [Upstream status: https://github.com/njh/twolame/pull/81]
  14. ---
  15. libtwolame/bitbuffer.c | 4 ++--
  16. libtwolame/bitbuffer.h | 6 +++---
  17. libtwolame/energy.c | 2 +-
  18. libtwolame/twolame.c | 32 ++++++++++++++++----------------
  19. 4 files changed, 22 insertions(+), 22 deletions(-)
  20. diff --git a/libtwolame/bitbuffer.c b/libtwolame/bitbuffer.c
  21. index 38a632b..5b2fc4b 100644
  22. --- a/libtwolame/bitbuffer.c
  23. +++ b/libtwolame/bitbuffer.c
  24. @@ -33,7 +33,7 @@
  25. /*create bit buffer*/
  26. -bit_stream *buffer_init(unsigned char *buffer, int buffer_size)
  27. +bit_stream *bitbuffer_init(unsigned char *buffer, int buffer_size)
  28. {
  29. bit_stream *bs = (bit_stream *) TWOLAME_MALLOC(sizeof(bit_stream));
  30. @@ -49,7 +49,7 @@ bit_stream *buffer_init(unsigned char *buffer, int buffer_size)
  31. }
  32. /* Dellocate bit buffer */
  33. -void buffer_deinit(bit_stream ** bs)
  34. +void bitbuffer_deinit(bit_stream ** bs)
  35. {
  36. if (bs == NULL || *bs == NULL)
  37. diff --git a/libtwolame/bitbuffer.h b/libtwolame/bitbuffer.h
  38. index 0201347..f377c8f 100644
  39. --- a/libtwolame/bitbuffer.h
  40. +++ b/libtwolame/bitbuffer.h
  41. @@ -39,11 +39,11 @@ typedef struct bit_stream_struc {
  42. } bit_stream;
  43. -bit_stream *buffer_init(unsigned char *buffer, int buffer_size);
  44. -void buffer_deinit(bit_stream ** bs);
  45. +bit_stream *bitbuffer_init(unsigned char *buffer, int buffer_size);
  46. +void bitbuffer_deinit(bit_stream ** bs);
  47. /*return the current bit stream length (in bits)*/
  48. -#define buffer_sstell(bs) (bs->totbit)
  49. +#define bitbuffer_sstell(bs) (bs->totbit)
  50. #endif
  51. diff --git a/libtwolame/energy.c b/libtwolame/energy.c
  52. index 219bd2c..312d8ae 100644
  53. --- a/libtwolame/energy.c
  54. +++ b/libtwolame/energy.c
  55. @@ -73,7 +73,7 @@ void do_energy_levels(twolame_options * glopts, bit_stream * bs)
  56. unsigned char rhibyte, rlobyte, lhibyte, llobyte;
  57. // Get the position (in butes) of the end of the mpeg audio frame
  58. - int frameEnd = buffer_sstell(bs) / 8;
  59. + int frameEnd = bitbuffer_sstell(bs) / 8;
  60. // find the maximum in the left and right channels
  61. diff --git a/libtwolame/twolame.c b/libtwolame/twolame.c
  62. index fa4bcc0..d3b8450 100644
  63. --- a/libtwolame/twolame.c
  64. +++ b/libtwolame/twolame.c
  65. @@ -442,7 +442,7 @@ static int encode_frame(twolame_options * glopts, bit_stream * bs)
  66. glopts->num_crc_bits = 0;
  67. // Store the number of bits initially in the bit buffer
  68. - initial_bits = buffer_sstell(bs);
  69. + initial_bits = bitbuffer_sstell(bs);
  70. adb = available_bits(glopts);
  71. @@ -580,7 +580,7 @@ static int encode_frame(twolame_options * glopts, bit_stream * bs)
  72. // Calulate the number of bits in this frame
  73. - frameBits = buffer_sstell(bs) - initial_bits;
  74. + frameBits = bitbuffer_sstell(bs) - initial_bits;
  75. if (frameBits % 8) { /* a program failure */
  76. fprintf(stderr, "Sent %ld bits = %ld slots plus %ld\n", frameBits, frameBits / 8,
  77. frameBits % 8);
  78. @@ -630,7 +630,7 @@ int twolame_encode_buffer(twolame_options * glopts,
  79. // now would be a great time to validate the size of the buffer.
  80. // samples/1152 * sizeof(frame) < mp2buffer_size
  81. - mybs = buffer_init(mp2buffer, mp2buffer_size);
  82. + mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
  83. // Use up all the samples in in_buffer
  84. @@ -658,7 +658,7 @@ int twolame_encode_buffer(twolame_options * glopts,
  85. if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
  86. int bytes = encode_frame(glopts, mybs);
  87. if (bytes <= 0) {
  88. - buffer_deinit(&mybs);
  89. + bitbuffer_deinit(&mybs);
  90. return bytes;
  91. }
  92. mp2_size += bytes;
  93. @@ -667,7 +667,7 @@ int twolame_encode_buffer(twolame_options * glopts,
  94. }
  95. // free up the bit stream buffer structure
  96. - buffer_deinit(&mybs);
  97. + bitbuffer_deinit(&mybs);
  98. return (mp2_size);
  99. }
  100. @@ -687,7 +687,7 @@ int twolame_encode_buffer_interleaved(twolame_options * glopts,
  101. // now would be a great time to validate the size of the buffer.
  102. // samples/1152 * sizeof(frame) < mp2buffer_size
  103. - mybs = buffer_init(mp2buffer, mp2buffer_size);
  104. + mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
  105. // Use up all the samples in in_buffer
  106. while (num_samples) {
  107. @@ -714,7 +714,7 @@ int twolame_encode_buffer_interleaved(twolame_options * glopts,
  108. if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
  109. int bytes = encode_frame(glopts, mybs);
  110. if (bytes <= 0) {
  111. - buffer_deinit(&mybs);
  112. + bitbuffer_deinit(&mybs);
  113. return bytes;
  114. }
  115. mp2_size += bytes;
  116. @@ -723,7 +723,7 @@ int twolame_encode_buffer_interleaved(twolame_options * glopts,
  117. }
  118. // free up the bit stream buffer structure
  119. - buffer_deinit(&mybs);
  120. + bitbuffer_deinit(&mybs);
  121. return (mp2_size);
  122. @@ -771,7 +771,7 @@ int twolame_encode_buffer_float32(twolame_options * glopts,
  123. // now would be a great time to validate the size of the buffer.
  124. // samples/1152 * sizeof(frame) < mp2buffer_size
  125. - mybs = buffer_init(mp2buffer, mp2buffer_size);
  126. + mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
  127. // Use up all the samples in in_buffer
  128. @@ -800,7 +800,7 @@ int twolame_encode_buffer_float32(twolame_options * glopts,
  129. if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
  130. int bytes = encode_frame(glopts, mybs);
  131. if (bytes <= 0) {
  132. - buffer_deinit(&mybs);
  133. + bitbuffer_deinit(&mybs);
  134. return bytes;
  135. }
  136. mp2_size += bytes;
  137. @@ -809,7 +809,7 @@ int twolame_encode_buffer_float32(twolame_options * glopts,
  138. }
  139. // free up the bit stream buffer structure
  140. - buffer_deinit(&mybs);
  141. + bitbuffer_deinit(&mybs);
  142. return (mp2_size);
  143. }
  144. @@ -829,7 +829,7 @@ int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
  145. // now would be a great time to validate the size of the buffer.
  146. // samples/1152 * sizeof(frame) < mp2buffer_size
  147. - mybs = buffer_init(mp2buffer, mp2buffer_size);
  148. + mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
  149. // Use up all the samples in in_buffer
  150. while (num_samples) {
  151. @@ -857,7 +857,7 @@ int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
  152. if (glopts->samples_in_buffer >= TWOLAME_SAMPLES_PER_FRAME) {
  153. int bytes = encode_frame(glopts, mybs);
  154. if (bytes <= 0) {
  155. - buffer_deinit(&mybs);
  156. + bitbuffer_deinit(&mybs);
  157. return bytes;
  158. }
  159. mp2_size += bytes;
  160. @@ -866,7 +866,7 @@ int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
  161. }
  162. // free up the bit stream buffer structure
  163. - buffer_deinit(&mybs);
  164. + bitbuffer_deinit(&mybs);
  165. return (mp2_size);
  166. @@ -885,7 +885,7 @@ int twolame_encode_flush(twolame_options * glopts, unsigned char *mp2buffer, int
  167. return 0;
  168. }
  169. // Create bit stream structure
  170. - mybs = buffer_init(mp2buffer, mp2buffer_size);
  171. + mybs = bitbuffer_init(mp2buffer, mp2buffer_size);
  172. // Pad out the PCM buffers with 0 and encode the frame
  173. for (i = glopts->samples_in_buffer; i < TWOLAME_SAMPLES_PER_FRAME; i++) {
  174. @@ -897,7 +897,7 @@ int twolame_encode_flush(twolame_options * glopts, unsigned char *mp2buffer, int
  175. glopts->samples_in_buffer = 0;
  176. // free up the bit stream buffer structure
  177. - buffer_deinit(&mybs);
  178. + bitbuffer_deinit(&mybs);
  179. return mp2_size;
  180. }
  181. --
  182. 2.17.1