~ubuntu-branches/ubuntu/lucid/mpg123/lucid

« back to all changes in this revision

Viewing changes to mpg123.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-09-07 15:57:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040907155757-pgypftl9bt2uqyyl
Tags: 0.59r-16
* layer2.c: Fix buffer overflow in layer2 decoder (CVE ID CAN-2004-0805).
* Makefile: Fix compiler options to build for generic targets on ARM,
  but optimise for xscale. Closes: #261255
* README.3DNOW, dct36_3dnow.s, dct64_3dnow.s, decode_3dnow.s,
  decode_i386.c, equalizer_3dnow.s, getcpuflags.s, layer3.c, mpg123.c,
  mpg123.h, tabinit.c, debian/rules: Apply patch by KIMURA Takuhiro and
  Syuuhei Kashiyama to fix errors in 3dnow-optimised decoding.
  Thanks to Alberto Garcia for the patch-merging. Closes: #242212
* debian/prerm: De-register mp3-decoder alternative. Closes: #222982
* debian/changelog: Convert to utf8.
* debian/control: Bump standards version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <errno.h>
18
18
#include <string.h>
19
19
#include <fcntl.h>
 
20
#include <time.h>
20
21
 
21
 
#if 0
 
22
#if 1
22
23
#define SET_RT 
23
24
#endif
24
25
 
44
45
  FALSE , /* remote */
45
46
  DECODE_AUDIO , /* write samples to audio device */
46
47
  FALSE , /* silent operation */
 
48
  FALSE , /* xterm title on/off */
47
49
  0 ,     /* second level buffer size */
48
50
  TRUE ,  /* resync after stream error */
49
51
  0 ,     /* verbose level */
59
61
  0 ,     /* doublespeed */
60
62
  0 ,     /* halfspeed */
61
63
  0 ,     /* force_reopen, always (re)opens audio device for next song */
 
64
#ifdef USE_3DNOW
 
65
  0 ,     /* autodetect from CPUFLAGS */
 
66
  FALSE , /* normal operation */
 
67
#endif
62
68
  FALSE,  /* try to run process in 'realtime mode' */   
63
69
  { 0,},  /* wav,cdr,au Filename */
64
70
};
144
150
    return;
145
151
  init_done = TRUE;
146
152
#ifndef NOXFERMEM
 
153
  /*
 
154
   * Only DECODE_AUDIO and DECODE_FILE are sanely handled by the
 
155
   * buffer process. For now, we just ignore the request
 
156
   * to buffer the output. [dk]
 
157
   */
 
158
  if (param.usebuffer && (param.outmode != DECODE_AUDIO) &&
 
159
      (param.outmode != DECODE_FILE)) {
 
160
    fprintf(stderr, "Sorry, won't buffer output unless writing plain audio.\n");
 
161
    param.usebuffer = 0;
 
162
  } 
 
163
  
147
164
  if (param.usebuffer) {
148
165
    unsigned int bufferbytes;
149
166
    sigset_t newsigset, oldsigset;
514
531
    {'Z', "random",      0,                  0, &param.shuffle,    2},
515
532
    {'E', "equalizer",   GLO_ARG | GLO_CHAR, 0, &equalfile,1},
516
533
    {0,   "aggressive",  0,                  0, &param.aggressive,2},
 
534
#ifdef USE_3DNOW
 
535
    {0,   "force-3dnow", 0,                  0, &param.stat_3dnow,1},
 
536
    {0,   "no-3dnow",    0,                  0, &param.stat_3dnow,2},
 
537
    {0,   "test-3dnow",  0,                  0, &param.test_3dnow,TRUE},
 
538
#endif
517
539
#if !defined(WIN32) && !defined(GENERIC)
518
540
    {'u', "auth",        GLO_ARG | GLO_CHAR, 0, &httpauth,   0},
519
541
#endif
522
544
#else
523
545
    {'T', "realtime",    0,       not_compiled, 0,           0 },    
524
546
#endif
 
547
    {0, "title",         0,                  0, &param.xterm_title, TRUE },
525
548
    {'w', "wav",         GLO_ARG | GLO_CHAR, set_wav, 0 , 0 },
526
549
    {0, "cdr",         GLO_ARG | GLO_CHAR, set_cdr, 0 , 0 },
527
550
    {0, "au",         GLO_ARG | GLO_CHAR, set_au, 0 , 0 },
722
745
{
723
746
        typedef int (*func)(real *,int,unsigned char *,int *);
724
747
        typedef int (*func_mono)(real *,unsigned char *,int *);
 
748
        typedef void (*func_dct36)(real *,real *,real *,real *,real *);
725
749
        int ds = fr->down_sample;
726
750
        int p8=0;
727
 
 
 
751
#ifdef USE_3DNOW
 
752
        static func funcs[3][4] = {
 
753
#else
728
754
        static func funcs[2][4] = { 
 
755
#endif
729
756
                { synth_1to1,
730
757
                  synth_2to1,
731
758
                  synth_4to1,
734
761
                  synth_2to1_8bit,
735
762
                  synth_4to1_8bit,
736
763
                  synth_ntom_8bit } 
 
764
#ifdef USE_3DNOW
 
765
               ,{ synth_1to1_3dnow,
 
766
                  synth_2to1,
 
767
                  synth_4to1,
 
768
                  synth_ntom }
 
769
#endif
737
770
        };
738
771
 
739
772
        static func_mono funcs_mono[2][2][4] = {    
755
788
                    synth_ntom_8bit_mono } }
756
789
        };
757
790
 
 
791
#ifdef USE_3DNOW        
 
792
        static func_dct36 funcs_dct36[2] = {dct36 , dct36_3dnow};
 
793
#endif
 
794
 
758
795
        if((ai.format & AUDIO_FORMAT_MASK) == AUDIO_FORMAT_8)
759
796
                p8 = 1;
760
797
        fr->synth = funcs[p8][ds];
761
798
        fr->synth_mono = funcs_mono[param.force_stereo?0:1][p8][ds];
762
799
 
 
800
#ifdef USE_3DNOW
 
801
        /* check cpuflags bit 31 (3DNow!) and 23 (MMX) */
 
802
        if((param.stat_3dnow < 2) && 
 
803
           ((param.stat_3dnow == 1) ||
 
804
            (getcpuflags() & 0x80800000) == 0x80800000))
 
805
        {
 
806
          fr->synth = funcs[2][ds]; /* 3DNow! optimized synth_1to1() */
 
807
          fr->dct36 = funcs_dct36[1]; /* 3DNow! optimized dct36() */
 
808
        }
 
809
        else
 
810
        {
 
811
                  fr->dct36 = funcs_dct36[0];
 
812
        }
 
813
#endif
 
814
 
763
815
        if(p8) {
764
816
                make_conv16to8_table(ai.format);
765
817
        }
812
864
                        exit (1);
813
865
        }
814
866
 
815
 
        if (loptind >= argc && !listname && !frontend_type)
 
867
#ifdef USE_3DNOW
 
868
        if (param.test_3dnow) {
 
869
                int cpuflags = getcpuflags();
 
870
                fprintf(stderr,"CPUFLAGS = %08x\n",cpuflags);
 
871
                if ((cpuflags & 0x00800000) == 0x00800000) {
 
872
                        fprintf(stderr,"MMX instructions are supported.\n");
 
873
                }
 
874
                if ((cpuflags & 0x80000000) == 0x80000000) {
 
875
                        fprintf(stderr,"3DNow! instructions are supported.\n");
 
876
                }
 
877
                exit(0);
 
878
        }
 
879
#endif
 
880
 
 
881
        if (loptind >= argc && !listname && !frontend_type && !param.remote)
816
882
                usage(NULL);
817
883
 
818
884
#if !defined(WIN32) && !defined(GENERIC)
906
972
 
907
973
                if(!*fname || !strcmp(fname, "-"))
908
974
                        fname = NULL;
909
 
                open_stream(fname,-1);
 
975
               if (open_stream(fname,-1) < 0)
 
976
                       continue;
910
977
      
911
978
                if (!param.quiet) {
912
979
                        if (split_dir_file(fname ? fname : "standard input",
918
985
{
919
986
     const char *term_type;
920
987
         term_type = getenv("TERM");
921
 
         if (!strcmp(term_type,"xterm"))
922
 
         {
 
988
         if (term_type &&
 
989
             param.xterm_title &&
 
990
             (!strcmp(term_type,"xterm") || !strcmp(term_type,"rxvt")))
 
991
         {
923
992
           fprintf(stderr, "\033]0;%s\007", filename);
924
993
         }
925
994
}
1194
1263
  fprintf(o," -w <f> --wav <f>          Writes samples as WAV file in <f> (- is stdout)\n");
1195
1264
  fprintf(o,"        --au <f>           Writes samples as Sun AU file in <f> (- is stdout)\n");
1196
1265
  fprintf(o,"        --cdr <f>          Writes samples as CDR file in <f> (- is stdout)\n");
 
1266
#ifdef USE_3DNOW
 
1267
  fprintf(o,"        --test-3dnow       Display result of 3DNow! autodetect and exit\n");
 
1268
  fprintf(o,"        --force-3dnow      Force use of 3DNow! optimized routine\n");
 
1269
  fprintf(o,"        --no-3dnow         Force use of floating-pointer routine\n");
 
1270
#endif
1197
1271
 
1198
1272
  fprintf(o,"\nSee the manpage %s(1) for more information.\n", prgName);
1199
1273
  exit(0);