Changeset 455
- Timestamp:
- 11/07/09 20:03:01 (15 years ago)
- Location:
- bmp-musepack/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
bmp-musepack/trunk/configure.ac
r34 r455 12 12 AC_PROG_INSTALL 13 13 14 CXXFLAGS="-O3 -fomit-frame-pointer" 15 14 16 AC_HEADER_STDC 15 17 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h wchar.h]) … … 20 22 AC_TYPE_SIZE_T 21 23 22 PKG_CHECK_MODULES( BEEP, [bmp >= 0.9.7],24 PKG_CHECK_MODULES(AUDACIOUS, [audclient >= 1.0.0], 23 25 [], 24 [AC_MSG_ERROR([ BMP >= 0.9.7development package not installed])]26 [AC_MSG_ERROR([AUDACIOUS >= 1.0.0 development package not installed])] 25 27 ) 26 28 27 BEEP_PLUGIN_DIR=`pkg-config --variable input_plugin_dir bmp`28 AC_SUBST( BEEP_PLUGIN_DIR)29 AUD_PLUGIN_DIR=`pkg-config --variable input_plugin_dir audacious` 30 AC_SUBST(AUD_PLUGIN_DIR) 29 31 30 32 PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.4.0], … … 38 40 ) 39 41 40 CXXFLAGS="$CXXFLAGS -O3 -fomit-frame-pointer" 41 AC_CHECK_HEADERS(mpcdec/config_types.h,,AC_MSG_ERROR([*** Libmpcdec not installed - please install first ***])) 42 AC_CHECK_HEADERS(mpc/mpc_types.h,,AC_MSG_ERROR([*** Libmpcdec not installed - please install first ***])) 42 43 43 44 AC_DEFUN([AC_HAVE_TAGLIB], -
bmp-musepack/trunk/src/Makefile.am
r34 r455 3 3 lib_LTLIBRARIES = libmpc.la 4 4 5 libdir = @ BEEP_PLUGIN_DIR@5 libdir = @AUD_PLUGIN_DIR@ 6 6 7 INCLUDES = @GLIB_2_0_CFLAGS@ @ BEEP_CFLAGS@ @GTK_CFLAGS@ @TAGLIB_CFLAGS@ -DVERSION=\"@VERSION@\"7 INCLUDES = @GLIB_2_0_CFLAGS@ @AUDACIOUS_CFLAGS@ @GTK_CFLAGS@ @TAGLIB_CFLAGS@ -DVERSION=\"@VERSION@\" 8 8 libmpc_la_LIBADD = @PTHREAD_LIBS@ @GLIB_2_0_LIBS@ @BEEP_LIBS@ @GTK_LIBS@ @TAGLIB_LIBS@ 9 9 -
bmp-musepack/trunk/src/libmpc.cpp
r34 r455 2 2 * Copyright (c) 2005, The Musepack Development Team 3 3 * All rights reserved. 4 * 4 * 5 5 * Redistribution and use in source and binary forms, with or without 6 6 * modification, are permitted provided that the following conditions are 7 7 * met: 8 * 8 * 9 9 * * Redistributions of source code must retain the above copyright 10 10 * notice, this list of conditions and the following disclaimer. 11 * 11 * 12 12 * * Redistributions in binary form must reproduce the above 13 13 * copyright notice, this list of conditions and the following 14 14 * disclaimer in the documentation and/or other materials provided 15 15 * with the distribution. 16 * 16 * 17 17 * * Neither the name of the The Musepack Development Team nor the 18 18 * names of its contributors may be used to endorse or promote 19 19 * products derived from this software without specific prior 20 20 * written permission. 21 * 21 * 22 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 111 111 { 112 112 char* titleText = g_strdup_printf("Musepack Decoder Plugin %s", VERSION); 113 c har* contentText = "Plugin code by\nBenoit Amiaux\nMartin Spuler\nKuniklo\n\nGet latest version at http://musepack.net\n";114 113 const char* contentText = "Plugin code by\nBenoit Amiaux\nMartin Spuler\nKuniklo\n\nGet latest version at http://musepack.net\n"; 114 const char* buttonText = "Nevermind"; 115 115 aboutBox = xmms_show_message(titleText, contentText, buttonText, FALSE, NULL, NULL); 116 116 widgets.aboutBox = aboutBox; … … 313 313 static void mpcGetSongInfo(char* p_Filename, char** p_Title, int* p_Length) 314 314 { 315 FILE* input = fopen(p_Filename, "rb");316 if(input) 317 315 mpc_reader reader; 316 mpc_demux * demux; 317 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) { 318 318 MpcInfo tags = getTags(p_Filename); 319 319 *p_Title = mpcGenerateTitle(tags, p_Filename); 320 320 freeTags(tags); 321 mpc_streaminfo info; 322 mpc_reader_file reader; 323 mpc_reader_setup_file_reader(&reader, input); 324 mpc_streaminfo_read(&info, &reader.reader); 325 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 326 fclose(input); 327 } 328 else 329 { 321 mpc_streaminfo info; 322 mpc_demux_get_info(demux, &info); 323 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 324 mpc_demux_exit(demux); 325 mpc_reader_exit_stdio(&reader); 326 } else { 330 327 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename); 331 328 perror(temp); … … 474 471 GtkWidget* streamLabel = mpcGtkLabel(infoVbox); 475 472 GtkWidget* encoderLabel = mpcGtkLabel(infoVbox); 476 GtkWidget* profileLabel = mpcGtkLabel(infoVbox); 473 GtkWidget* profileLabel = mpcGtkLabel(infoVbox); 474 GtkWidget* pnsLabel = mpcGtkLabel(infoVbox); 475 GtkWidget* gaplessLabel = mpcGtkLabel(infoVbox); 477 476 GtkWidget* bitrateLabel = mpcGtkLabel(infoVbox); 478 477 GtkWidget* rateLabel = mpcGtkLabel(infoVbox); … … 485 484 GtkWidget* albumGainLabel = mpcGtkLabel(infoVbox); 486 485 487 FILE* input = fopen(p_Filename, "rb");488 if(input) 489 486 mpc_reader reader; 487 mpc_demux * demux; 488 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) { 490 489 mpc_streaminfo info; 491 mpc_reader_file reader; 492 mpc_reader_setup_file_reader(&reader, input); 493 mpc_streaminfo_read(&info, &reader.reader); 490 mpc_demux_get_info(demux, &info); 494 491 495 492 int time = static_cast<int> (mpc_streaminfo_get_length(&info)); … … 499 496 mpcGtkPrintLabel(streamLabel, "Streamversion %d", info.stream_version); 500 497 mpcGtkPrintLabel(encoderLabel, "Encoder: \%s", info.encoder); 501 mpcGtkPrintLabel(profileLabel, "Profile: \%s", info.profile_name); 498 mpcGtkPrintLabel(profileLabel, "Profile: \%s (q=%0.2f)", info.profile_name, info.profile - 5); 499 mpcGtkPrintLabel(pnsLabel, "PNS: \%s", info.pns == 0xFF ? "unknow" : info.pns ? "on" : "off"); 500 mpcGtkPrintLabel(gaplessLabel, "Gapless: \%s", info.is_true_gapless ? "on" : "off"); 502 501 mpcGtkPrintLabel(bitrateLabel, "Average bitrate: \%6.1f kbps", info.average_bitrate * 1.e-3); 503 502 mpcGtkPrintLabel(rateLabel, "Samplerate: \%d Hz", info.sample_freq); 504 503 mpcGtkPrintLabel(channelsLabel, "Channels: \%d", info.channels); 505 mpcGtkPrintLabel(lengthLabel, "Length: \%d:\%.2d", minutes, seconds);504 mpcGtkPrintLabel(lengthLabel, "Length: \%d:\%.2d (%u samples)", minutes, seconds, (mpc_uint32_t)mpc_streaminfo_get_length_samples(&info)); 506 505 mpcGtkPrintLabel(fileSizeLabel, "File size: \%d Bytes", info.total_file_length); 507 mpcGtkPrintLabel(trackPeakLabel, "Track Peak: \%5u", info.peak_title);508 mpcGtkPrintLabel(trackGainLabel, "Track Gain: \%-+2.2f dB", 0.01 * info.gain_title);509 mpcGtkPrintLabel(albumPeakLabel, "Album Peak: \%5u", info.peak_album);510 mpcGtkPrintLabel(albumGainLabel, "Album Gain: \%-+5.2f dB", 0.01 * info.gain_album);506 mpcGtkPrintLabel(trackPeakLabel, "Track Peak: \%2.2f dB", info.peak_title / 256.); 507 mpcGtkPrintLabel(trackGainLabel, "Track Gain: \%2.2f dB", info.gain_title / 256.); 508 mpcGtkPrintLabel(albumPeakLabel, "Album Peak: \%2.2f dB", info.peak_album / 256.); 509 mpcGtkPrintLabel(albumGainLabel, "Album Gain: \%2.2f dB", info.gain_album / 256.); 511 510 512 511 MpcInfo tags = getTags(p_Filename); … … 526 525 free(entry); 527 526 freeTags(tags); 528 fclose(input); 527 mpc_demux_exit(demux); 528 mpc_reader_exit_stdio(&reader); 529 529 } 530 530 else … … 709 709 { 710 710 lockAcquire(); 711 char* filename = static_cast<char*> (data); 712 FILE* input = fopen(filename, "rb"); 713 if (!input) 714 { 711 const char* filename = static_cast<const char*> (data); 712 mpc_reader reader; 713 if (mpc_reader_init_stdio(&reader, filename) != MPC_STATUS_OK) { 715 714 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename); 716 return endThread(filename, input, true); 717 } 718 719 mpc_reader_file reader; 720 mpc_reader_setup_file_reader(&reader, input); 721 722 mpc_streaminfo info; 723 if (mpc_streaminfo_read(&info, &reader.reader) != ERROR_CODE_OK) 724 { 725 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename); 726 return endThread(filename, input, true); 727 } 728 729 MpcInfo tags = getTags(filename); 730 track.display = mpcGenerateTitle(tags, filename); 731 track.length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 732 track.bitrate = static_cast<int> (info.average_bitrate); 733 track.sampleFreq = info.sample_freq; 734 track.channels = info.channels; 715 return endThread(filename, 0, true); 716 } 717 718 mpc_demux * demux = 0; 719 demux = mpc_demux_init(&reader); 720 721 if ( demux == 0 ) { 722 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename); 723 mpc_reader_exit_stdio(&reader); 724 return endThread(filename, 0, true); 725 } 726 727 mpc_streaminfo info; 728 mpc_demux_get_info(demux, &info); 729 MpcInfo tags = getTags(filename); 730 track.display = mpcGenerateTitle(tags, filename); 731 track.length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); 732 track.bitrate = static_cast<int> (info.average_bitrate); 733 track.sampleFreq = info.sample_freq; 734 track.channels = info.channels; 735 735 freeTags(tags); 736 736 737 737 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 738 738 739 mpc_decoder decoder; 740 mpc_decoder_setup(&decoder, &reader.reader); 741 if (!mpc_decoder_initialize(&decoder, &info)) 742 { 743 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename); 744 return endThread(filename, input, true); 745 } 746 747 setReplaygain(info, decoder); 739 setReplaygain(demux); 748 740 749 741 MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH]; … … 752 744 if (!MpcPlugin.output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels)) 753 745 { 754 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output"); 755 return endThread(filename, input, true); 746 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output"); 747 mpc_reader_exit_stdio(&reader); 748 return endThread(filename, 0, true); 756 749 } 757 750 else … … 762 755 lockRelease(); 763 756 764 int counter = 2 * track.sampleFreq / 3; 757 int counter = 2 * track.sampleFreq / 3; 758 int status = 0; 765 759 while (isAlive()) 766 760 { 767 761 if (getOffset() != -1) 768 762 { 769 mpc_decoder_seek_seconds(&decoder, mpcDecoder.offset);763 mpc_demux_seek_second(demux, mpcDecoder.offset); 770 764 setOffset(-1); 765 status = 0; 771 766 } 772 767 … … 774 769 short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0; 775 770 int iFree = MpcPlugin.output->buffer_free(); 776 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying) )771 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying) && status != -1) 777 772 { 778 unsigned status = processBuffer(sampleBuffer, xmmsBuffer, decoder); 779 if (status == (unsigned) (-1)) 780 { 781 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename); 782 return endThread(filename, input, true); 783 } 784 else if (status == 0) 785 { 786 //mpcDecoder.isError = g_strdup_printf("[xmms-musepack] null output from internal decoder on %s", filename); 787 return endThread(filename, input, true); 788 } 789 lockRelease(); 790 791 if(pluginConfig.dynamicBitrate) 792 { 793 counter -= status; 794 if(counter < 0) 795 { 796 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 797 counter = 2 * track.sampleFreq / 3; 798 } 799 } 773 status = processBuffer(sampleBuffer, xmmsBuffer, *demux); 774 lockRelease(); 775 776 if(pluginConfig.dynamicBitrate) { 777 counter -= status; 778 if(counter < 0) { 779 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); 780 counter = 2 * track.sampleFreq / 3; 781 } 782 } 800 783 } 801 784 else 802 785 { 803 lockRelease(); 804 xmms_usleep(10000); 805 } 806 } 807 return endThread(filename, input, false); 808 } 809 810 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_decoder& decoder) 811 { 812 mpc_uint32_t vbrAcc = 0; 813 mpc_uint32_t vbrUpd = 0; 814 815 unsigned status = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd); 816 copyBuffer(sampleBuffer, xmmsBuffer, status); 786 lockRelease(); 787 if (mpcDecoder.isPause == FALSE && status == -1 && 788 MpcPlugin.output->buffer_playing() == FALSE) 789 break; 790 xmms_usleep(100000); 791 } 792 } 793 mpc_demux_exit(demux); 794 mpc_reader_exit_stdio(&reader); 795 return endThread(filename, 0, false); 796 } 797 798 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_demux& demux) 799 { 800 mpc_frame_info info; 801 802 info.buffer = sampleBuffer; 803 mpc_demux_decode(&demux, &info); 804 805 if (info.bits == -1) return -1; // end of stream 806 807 copyBuffer(sampleBuffer, xmmsBuffer, info.samples * track.channels); 817 808 818 809 if (pluginConfig.dynamicBitrate) 819 810 { 820 track.bitrate = static_cast<int> ( vbrUpd* track.sampleFreq / 1152);811 track.bitrate = static_cast<int> (info.bits * track.sampleFreq / 1152); 821 812 } 822 813 823 814 if (pluginConfig.isEq) 824 815 { 825 iir(xmmsBuffer, 4 * status); 826 } 827 828 MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, status * 4, xmmsBuffer); 829 MpcPlugin.output->write_audio(xmmsBuffer, status * 4); 830 return status; 831 } 832 833 static void setReplaygain(mpc_streaminfo& info, mpc_decoder& decoder) 834 { 835 if(!pluginConfig.replaygain && !pluginConfig.clipPrevention) 836 return; 837 838 int peak = pluginConfig.albumGain ? info.peak_album : info.peak_title; 839 double gain = pluginConfig.albumGain ? info.gain_album : info.gain_title; 840 841 if(!peak) 842 peak = 32767; 843 if(!gain) 844 gain = 1.; 845 846 double clip = 32767. / peak; 847 gain = exp((M_LN10 / 2000.) * gain); 848 849 if(pluginConfig.clipPrevention && !pluginConfig.replaygain) 850 gain = clip; 851 else if(pluginConfig.replaygain && pluginConfig.clipPrevention) 852 if(clip < gain) 853 gain = clip; 854 855 mpc_decoder_scale_output(&decoder, gain); 816 iir(xmmsBuffer, 4 * info.samples); 817 } 818 819 MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, info.samples * 2 * track.channels, xmmsBuffer); 820 MpcPlugin.output->write_audio(xmmsBuffer, info.samples * 2 * track.channels); 821 return info.samples; 822 } 823 824 static void setReplaygain(mpc_demux * d) 825 { 826 mpc_set_replay_level(d, MPC_OLD_GAIN_REF, pluginConfig.replaygain, 827 !pluginConfig.albumGain, pluginConfig.clipPrevention); 856 828 } 857 829 -
bmp-musepack/trunk/src/libmpc.h
r34 r455 2 2 * Copyright (c) 2005, The Musepack Development Team 3 3 * All rights reserved. 4 * 4 * 5 5 * Redistribution and use in source and binary forms, with or without 6 6 * modification, are permitted provided that the following conditions are 7 7 * met: 8 * 8 * 9 9 * * Redistributions of source code must retain the above copyright 10 10 * notice, this list of conditions and the following disclaimer. 11 * 11 * 12 12 * * Redistributions in binary form must reproduce the above 13 13 * copyright notice, this list of conditions and the following 14 14 * disclaimer in the documentation and/or other materials provided 15 15 * with the distribution. 16 * 16 * 17 17 * * Neither the name of the The Musepack Development Team nor the 18 18 * names of its contributors may be used to endorse or promote 19 19 * products derived from this software without specific prior 20 20 * written permission. 21 * 21 * 22 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 39 39 extern "C" 40 40 { 41 #include < bmp/plugin.h>42 #include < bmp/util.h>43 #include < bmp/configdb.h>44 #include < bmp/titlestring.h>41 #include <audacious/plugin.h> 42 #include <audacious/util.h> 43 #include <audacious/configdb.h> 44 #include <audacious/strings.h> 45 45 } 46 46 … … 54 54 55 55 //libmpcdec headers 56 #include <mpc dec/mpcdec.h>56 #include <mpc/mpcdec.h> 57 57 58 58 //GTK+ headers … … 160 160 static void lockRelease(); 161 161 static void* decodeStream(void*); 162 static int processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_de coder&);162 static int processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_demux&); 163 163 static void* endThread(char*, FILE*, bool); 164 164 static bool isAlive(); … … 167 167 static void setOffset(double); 168 168 static bool isPause(); 169 static void setReplaygain(mpc_ streaminfo&, mpc_decoder&);169 static void setReplaygain(mpc_demux *); 170 170 171 171 #ifdef MPC_FIXED_POINT … … 186 186 int clipMax = (1 << (pSize - 1)) - 1; 187 187 int floatScale = 1 << (pSize - 1); 188 for (unsigned n = 0; n < 2 *pLength; n++)188 for (unsigned n = 0; n < pLength; n++) 189 189 { 190 190 int val;
Note: See TracChangeset
for help on using the changeset viewer.