summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/splay/splayDecoder.cpp
blob: 13d6de1bd4a744d04c62001426319c470b2caecd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
  decoder interface for the splay mp3 decoder.
  Copyright (C) 2001  Martin Vogt

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation.

  For more information look at the file COPYRIGHT in this package

 */

#define _FROM_SOURCE
#include "dxHead.h"
#include "splayDecoder.h"
#include "mpegsound.h"



SplayDecoder::SplayDecoder() {
  header = new MpegAudioHeader();
  stream = new MpegAudioStream();
  server = new Mpegtoraw(stream,header);

  xHeadData=new XHEADDATA();
  xHeadData->toc=new unsigned char[101];
  dump=new Dump();
}


SplayDecoder::~SplayDecoder() {
  delete [] xHeadData->toc;
  delete xHeadData;
  
  delete server;
  delete header;
  delete stream;
  delete dump;
}



int SplayDecoder::decode(unsigned char* ptr, int len,AudioFrame* dest) {
  int back;
  // fist setup the stream and the 4 bytes header info;
  //dump->dump((char*)ptr,len);
  if (header->parseHeader(ptr) == false) {
    return false;
  }
  // maybe a Xing Header?
  if (len >= 152+4) {
    int lXing=GetXingHeader(xHeadData,(unsigned char*)ptr);
    if (lXing) {
      return false;
    }
  }
  stream->setFrame(ptr+4,len-4);
  back=server->decode(dest);

  return back;

}


void SplayDecoder::config(const char* key,const char* val,void* ) {
  if (strcmp(key,"2")==0) {
    server->setDownSample(atoi(val));
  }
  if (strcmp(key,"m")==0) {
    server->setStereo(atoi(val));
  }
}