Ticket #2240: vorbis-tools-1.1.1-flac.patch
File vorbis-tools-1.1.1-flac.patch, 18.7 KB (added by , 17 years ago) |
---|
-
vorbis-tools-1.1.1/configure.ac
Add support for libFLAC-1.1.3. Original patch from Josh Coalson: http://lists.xiph.org/pipermail/vorbis-dev/2006-October/018561.html This patch updates that to build against svn trunk, and includes automatic detection of libFLAC version in ./configure. Tested against libFLAC versions 1.1.2 and 1.1.3.
old new 169 169 170 170 FLAC_LIBS="" 171 171 if test "x$build_flac" = xyes; then 172 172 173 AC_CHECK_LIB(m,log,FLAC_LIBS="-lm") 173 AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single], 174 [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"], 175 AC_MSG_WARN([libFLAC missing]) 176 have_libFLAC=no, [$FLAC_LIBS] 177 ) 178 AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new], 179 [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"], 180 AC_MSG_WARN([libOggFLAC missing]) 181 have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS] 182 ) 174 175 dnl First check for libFLAC-1.1.3 or later. As of libFLAC 1.1.3, 176 dnl OggFLAC functionality has been rolled into libFLAC rather 177 dnl than being in a separate libOggFLAC library. 178 179 AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_init_ogg_stream], 180 have_libFLAC=yes, have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]) 181 182 if test "x$have_libFLAC" = xyes; then 183 FLAC_LIBS="-lFLAC $FLAC_LIBS $OGG_LIBS" 184 else 185 dnl Check for libFLAC prior to 1.1.3 186 AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single], 187 [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"], 188 AC_MSG_WARN([libFLAC missing]) 189 have_libFLAC=no, [$FLAC_LIBS] 190 ) 191 192 AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new], 193 [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"], 194 AC_MSG_WARN([libOggFLAC missing]) 195 have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS] 196 ) 197 fi 198 183 199 AC_CHECK_HEADER(FLAC/stream_decoder.h,, 184 200 AC_MSG_WARN(libFLAC headers missing) 185 201 have_libFLAC=no,[ ]) -
vorbis-tools-1.1.1/ogg123/flac_format.c
old new 20 20 #include <string.h> 21 21 #include <sys/types.h> 22 22 #include <math.h> 23 #include <FLAC/ metadata.h>23 #include <FLAC/all.h> 24 24 #include <ao/ao.h> 25 25 #include "audio.h" 26 26 #include "format.h" 27 27 #include "i18n.h" 28 #if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8) 29 #define NEED_EASYFLAC 1 30 #endif 31 #if NEED_EASYFLAC 28 32 #include "easyflac.h" 33 #endif 29 34 #include "vorbis_comments.h" 30 35 31 #define DEFAULT_FLAC_FRAME_SIZE 460832 33 36 typedef struct { 37 #if NEED_EASYFLAC 34 38 EasyFLAC__StreamDecoder *decoder; 39 #else 40 FLAC__StreamDecoder *decoder; 41 int is_oggflac; 42 #endif 35 43 short channels; 36 44 int rate; 37 45 int bits_per_sample; … … 67 75 68 76 69 77 /* Private functions declarations */ 70 FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); 71 FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); 72 void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); 73 void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); 78 #if NEED_EASYFLAC 79 static FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); 80 static FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); 81 static void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); 82 static void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); 83 #else 84 static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); 85 static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); 86 static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); 87 static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); 88 static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data); 89 #endif 74 90 75 91 void resize_buffer(flac_private_t *flac, int newchannels, int newsamples); 76 92 /*void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);*/ … … 155 171 private->buf_start = 0; 156 172 157 173 /* Setup FLAC decoder */ 174 #if NEED_EASYFLAC 158 175 if (oggflac_can_decode(source)) { 159 176 decoder->format = &oggflac_format; 160 177 private->decoder = EasyFLAC__stream_decoder_new(1); … … 172 189 EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO); 173 190 EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); 174 191 EasyFLAC__init(private->decoder); 192 #else 193 if (oggflac_can_decode(source)) { 194 private->is_oggflac = 1; 195 decoder->format = &oggflac_format; 196 } else { 197 private->is_oggflac = 0; 198 decoder->format = &flac_format; 199 } 200 private->decoder = FLAC__stream_decoder_new(); 201 202 FLAC__stream_decoder_set_md5_checking(private->decoder, false); 203 FLAC__stream_decoder_set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO); 204 FLAC__stream_decoder_set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); 205 /*FLAC__stream_decoder_init(private->decoder);*/ 206 if(private->is_oggflac) 207 FLAC__stream_decoder_init_ogg_stream(private->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, decoder); 208 else 209 FLAC__stream_decoder_init_stream(private->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, decoder); 210 #endif 175 211 176 212 /* Callback will set the total samples and sample rate */ 213 #if NEED_EASYFLAC 177 214 EasyFLAC__process_until_end_of_metadata(private->decoder); 215 #else 216 FLAC__stream_decoder_process_until_end_of_metadata(private->decoder); 217 #endif 178 218 179 219 /* Callback will set the number of channels and resize the 180 220 audio buffer */ 221 #if NEED_EASYFLAC 181 222 EasyFLAC__process_single(private->decoder); 223 #else 224 FLAC__stream_decoder_process_single(private->decoder); 225 #endif 182 226 183 227 /* FLAC API returns signed samples on all streams */ 184 228 decoder->actual_fmt.signed_sample = 1; … … 241 285 realsamples += copy; 242 286 } 243 287 else if (!priv->eos) { 288 #if NEED_EASYFLAC 244 289 ret = EasyFLAC__process_single(priv->decoder); 245 290 if (!ret || 246 291 EasyFLAC__get_state(priv->decoder) 247 292 == FLAC__STREAM_DECODER_END_OF_STREAM) 248 293 priv->eos = 1; /* Bail out! */ 294 #else 295 ret = FLAC__stream_decoder_process_single(priv->decoder); 296 if (!ret || 297 FLAC__stream_decoder_get_state(priv->decoder) 298 == FLAC__STREAM_DECODER_END_OF_STREAM) 299 priv->eos = 1; /* Bail out! */ 300 #endif 249 301 } else 250 302 break; 251 303 } … … 311 363 free(priv->buf[i]); 312 364 313 365 free(priv->buf); 366 #if NEED_EASYFLAC 314 367 EasyFLAC__finish(priv->decoder); 315 368 EasyFLAC__stream_decoder_delete(priv->decoder); 369 #else 370 FLAC__stream_decoder_finish(priv->decoder); 371 FLAC__stream_decoder_delete(priv->decoder); 372 #endif 316 373 317 374 free(decoder->private); 318 375 free(decoder); … … 342 399 343 400 344 401 402 #if NEED_EASYFLAC 345 403 FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) 404 #else 405 FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) 406 #endif 346 407 { 347 408 decoder_t *e_decoder = client_data; 348 409 flac_private_t *priv = e_decoder->private; … … 363 424 } 364 425 365 426 427 #if NEED_EASYFLAC 366 428 FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) 429 #else 430 FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) 431 #endif 367 432 { 368 433 decoder_t *e_decoder = client_data; 369 434 flac_private_t *priv = e_decoder->private; … … 389 454 } 390 455 391 456 457 #if NEED_EASYFLAC 392 458 void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) 459 #else 460 void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) 461 #endif 393 462 { 394 463 decoder_t *e_decoder = client_data; 395 464 flac_private_t *priv = e_decoder->private; … … 409 478 } 410 479 411 480 481 #if NEED_EASYFLAC 412 482 void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) 483 #else 484 void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) 485 #endif 413 486 { 414 487 415 488 416 489 } 417 490 491 #if !NEED_EASYFLAC 492 FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) 493 { 494 decoder_t *e_decoder = client_data; 495 flac_private_t *priv = e_decoder->private; 496 497 return priv->eos; 498 } 499 #endif 500 418 501 419 502 void resize_buffer(flac_private_t *flac, int newchannels, int newsamples) 420 503 { … … 457 540 458 541 459 542 543 #if NEED_EASYFLAC 460 544 if (EasyFLAC__is_oggflac(priv->decoder)) 545 #else 546 if (priv->is_oggflac) 547 #endif 461 548 cb->printf_metadata(decoder->callback_arg, 2, 462 549 _("Ogg FLAC stream: %d bits, %d channel, %ld Hz"), 463 550 priv->bits_per_sample, -
vorbis-tools-1.1.1/ogg123/easyflac.c
old new 33 33 * 34 34 */ 35 35 36 #include <FLAC/export.h> 37 #if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8) 38 36 39 #include <stdlib.h> 37 40 #include "easyflac.h" 38 41 39 40 42 FLAC__bool EasyFLAC__is_oggflac(EasyFLAC__StreamDecoder *decoder) 41 43 { 42 44 return decoder->is_oggflac; … … 373 375 else 374 376 return FLAC__stream_decoder_process_until_end_of_stream(decoder->flac); 375 377 } 378 379 #endif -
vorbis-tools-1.1.1/oggenc/flac.c
old new 20 20 #include "platform.h" 21 21 #include "resample.h" 22 22 23 #define DEFAULT_FLAC_FRAME_SIZE 4608 23 #if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8) 24 #define NEED_EASYFLAC 1 25 #endif 26 27 #if NEED_EASYFLAC 28 static FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); 29 static FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); 30 static void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); 31 static void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); 32 #else 33 static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); 34 static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); 35 static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); 36 static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); 37 static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data); 38 #endif 24 39 25 FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); 26 FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); 27 void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); 28 void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); 29 30 void resize_buffer(flacfile *flac, int newchannels, int newsamples); 31 void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments); 40 static void resize_buffer(flacfile *flac, int newchannels, int newsamples); 41 static void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments); 32 42 33 43 34 44 int flac_id(unsigned char *buf, int len) … … 76 86 flac->in = in; 77 87 78 88 /* Setup FLAC decoder */ 89 #if NEED_EASYFLAC 79 90 flac->decoder = EasyFLAC__stream_decoder_new(oggflac_id(oldbuf, buflen)); 80 91 EasyFLAC__set_client_data(flac->decoder, flac); 81 92 EasyFLAC__set_read_callback(flac->decoder, &easyflac_read_callback); … … 85 96 EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO); 86 97 EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); 87 98 EasyFLAC__init(flac->decoder); 99 #else 100 flac->decoder = FLAC__stream_decoder_new(); 101 FLAC__stream_decoder_set_md5_checking(flac->decoder, false); 102 FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO); 103 FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); 104 if(oggflac_id(oldbuf, buflen)) 105 FLAC__stream_decoder_init_ogg_stream(flac->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, flac); 106 else 107 FLAC__stream_decoder_init_stream(flac->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, flac); 108 #endif 88 109 89 110 /* Callback will set the total samples and sample rate */ 111 #if NEED_EASYFLAC 90 112 EasyFLAC__process_until_end_of_metadata(flac->decoder); 113 #else 114 FLAC__stream_decoder_process_until_end_of_metadata(flac->decoder); 115 #endif 91 116 92 117 /* Callback will set the number of channels and resize the 93 118 audio buffer */ 119 #if NEED_EASYFLAC 94 120 EasyFLAC__process_single(flac->decoder); 95 121 #else 122 FLAC__stream_decoder_process_single(flac->decoder); 123 #endif 124 96 125 /* Copy format info for caller */ 97 126 opt->rate = flac->rate; 98 127 opt->channels = flac->channels; … … 133 162 } 134 163 else if (!flac->eos) 135 164 { 165 #if NEED_EASYFLAC 136 166 ret = EasyFLAC__process_single(flac->decoder); 137 167 if (!ret || 138 168 EasyFLAC__get_state(flac->decoder) 139 169 == FLAC__STREAM_DECODER_END_OF_STREAM) 140 170 flac->eos = 1; /* Bail out! */ 171 #else 172 ret = FLAC__stream_decoder_process_single(flac->decoder); 173 if (!ret || 174 FLAC__stream_decoder_get_state(flac->decoder) 175 == FLAC__STREAM_DECODER_END_OF_STREAM) 176 flac->eos = 1; /* Bail out! */ 177 #endif 141 178 } else 142 179 break; 143 180 } … … 157 194 free(flac->buf); 158 195 free(flac->oldbuf); 159 196 free(flac->comments); 197 #if NEED_EASYFLAC 160 198 EasyFLAC__finish(flac->decoder); 161 199 EasyFLAC__stream_decoder_delete(flac->decoder); 200 #else 201 FLAC__stream_decoder_finish(flac->decoder); 202 FLAC__stream_decoder_delete(flac->decoder); 203 #endif 162 204 free(flac); 163 205 } 164 206 165 207 208 #if NEED_EASYFLAC 166 209 FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) 210 #else 211 FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) 212 #endif 167 213 { 168 214 flacfile *flac = (flacfile *) client_data; 169 215 int i = 0; … … 200 246 return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; 201 247 } 202 248 249 #if NEED_EASYFLAC 203 250 FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) 251 #else 252 FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) 253 #endif 204 254 { 205 255 flacfile *flac = (flacfile *) client_data; 206 256 int samples = frame->header.blocksize; … … 221 271 return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; 222 272 } 223 273 274 #if NEED_EASYFLAC 224 275 void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) 276 #else 277 void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) 278 #endif 225 279 { 226 280 flacfile *flac = (flacfile *) client_data; 227 281 … … 240 294 } 241 295 } 242 296 297 #if NEED_EASYFLAC 243 298 void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) 299 #else 300 void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) 301 #endif 244 302 { 245 flacfile *flac = (flacfile *) client_data; 303 flacfile *flac = (flacfile *) client_data; 304 305 } 306 307 #if !NEED_EASYFLAC 308 FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) 309 { 310 flacfile *flac = (flacfile *) client_data; 246 311 312 return feof(flac->in)? true : false; 247 313 } 314 #endif 248 315 249 316 250 317 void resize_buffer(flacfile *flac, int newchannels, int newsamples) -
vorbis-tools-1.1.1/oggenc/easyflac.c
old new 33 33 * 34 34 */ 35 35 36 #include <FLAC/export.h> 37 #if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8) 38 36 39 #include <stdlib.h> 37 40 #include "easyflac.h" 38 41 … … 373 376 else 374 377 return FLAC__stream_decoder_process_until_end_of_stream(decoder->flac); 375 378 } 379 380 #endif -
vorbis-tools-1.1.1/oggenc/flac.h
old new 5 5 #include "encode.h" 6 6 #include "audio.h" 7 7 #include <stdio.h> 8 #include <FLAC/stream_decoder.h> 9 #if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8) 10 #define NEED_EASYFLAC 1 11 #endif 12 #if NEED_EASYFLAC 13 #include <OggFLAC/stream_decoder.h> 8 14 #include "easyflac.h" 15 #endif 9 16 10 17 typedef struct { 18 #if NEED_EASYFLAC 11 19 EasyFLAC__StreamDecoder *decoder; 20 #else 21 FLAC__StreamDecoder *decoder; 22 #endif 12 23 short channels; 13 24 int rate; 14 25 long totalsamples; /* per channel, of course */