Esempio n. 1
0
void Codec::getStats(QStringList *hdrs,QStringList *values,bool is_first)
{
  if(codec_is_framed_changed) {
    hdrs->push_back("Codec|Framed");
    if(isFramed()) {
      values->push_back("Yes");
    }
    else {
      values->push_back("No");
    }
    codec_is_framed_changed=false;
  }

  if(is_first) {
    hdrs->push_back("Codec|Channels");
    values->push_back(QString().sprintf("%u",codec_channels));

    hdrs->push_back("Codec|Samplerate");
    values->push_back(QString().sprintf("%u",codec_samplerate));
  }

  if(codec_bytes_processed_changed) {
    hdrs->push_back("Codec|Bytes Processed");
    values->push_back(QString().sprintf("%lu",codec_bytes_processed));
    codec_bytes_processed_changed=false;
  }

  loadStats(hdrs,values,is_first);
}
Esempio n. 2
0
void CodecMpeg1::process(const QByteArray &data,bool is_last)
{
#ifdef HAVE_LIBMAD
  float pcm[32768*4];
  int frame_offset=0;
  int err_count=0;

  mpeg1_mpeg.append(data);
  mad_stream_buffer(&mpeg1_mad_stream,(const unsigned char *)mpeg1_mpeg.data(),
		    mpeg1_mpeg.length());
  do {
    while(mad_frame_decode(&mpeg1_mad_frame,&mpeg1_mad_stream)==0) {  
      mad_synth_frame(&mpeg1_mad_synth,&mpeg1_mad_frame);
      for(int i=0;i<mpeg1_mad_synth.pcm.length;i++) {
	for(int j=0;j<mpeg1_mad_synth.pcm.channels;j++) {
	  pcm[frame_offset+i*mpeg1_mad_synth.pcm.channels+j]=
	    (float)mad_f_todouble(mpeg1_mad_synth.pcm.samples[j][i]);
	}
      }
      frame_offset+=(mpeg1_mad_synth.pcm.length*mpeg1_mad_synth.pcm.channels);
    }
    if(MAD_RECOVERABLE(mpeg1_mad_stream.error)!=0) {
      if(err_count++>10) {
	Reset();
	break;
      }
    }
  } while(mpeg1_mad_stream.error!=MAD_ERROR_BUFLEN);

  if(mpeg1_mad_stream.error==MAD_ERROR_BUFLEN) {
    if(frame_offset>0) {
      mpeg1_mad_header=mpeg1_mad_frame.header;
      if(!isFramed()) {
	int channels=2;
	if(mpeg1_mad_frame.header.mode==MAD_MODE_SINGLE_CHANNEL) {
	  channels=1;
	}
	setFramed(channels,mpeg1_mad_frame.header.samplerate,
		  mpeg1_mad_frame.header.bitrate/1000);
      }
      else {
	writePcm(pcm,frame_offset/channels(),is_last);
      }
    }
    mpeg1_mpeg=
      mpeg1_mpeg.right(mpeg1_mad_stream.bufend-mpeg1_mad_stream.next_frame);
  }
  if(is_last) {
    frame_offset=0;
    mpeg1_mpeg.append(0,MAD_BUFFER_GUARD);
    mad_stream_buffer(&mpeg1_mad_stream,(const unsigned char *)mpeg1_mpeg.data(),
		      mpeg1_mpeg.length());
    do {
      while(mad_frame_decode(&mpeg1_mad_frame,&mpeg1_mad_stream)==0) {  
	mad_synth_frame(&mpeg1_mad_synth,&mpeg1_mad_frame);
	for(int i=0;i<mpeg1_mad_synth.pcm.length;i++) {
	  for(int j=0;j<mpeg1_mad_synth.pcm.channels;j++) {
	    pcm[frame_offset+i*mpeg1_mad_synth.pcm.channels+j]=
	      (float)mad_f_todouble(mpeg1_mad_synth.pcm.samples[j][i]);
	  }
	}
	frame_offset+=(mpeg1_mad_synth.pcm.length*mpeg1_mad_synth.pcm.channels);
      }
      if(MAD_RECOVERABLE(mpeg1_mad_stream.error)!=0) {
	if(err_count++>10) {
	  Reset();
	  break;
	}
      }
    } while(mpeg1_mad_stream.error!=MAD_ERROR_BUFLEN);
    writePcm(pcm,frame_offset/channels(),is_last);
  }
#endif  // HAVE_LIBMAD
}
Esempio n. 3
0
TextWindow &TextWindow::setMargin(int margin)
{
  int frame = isFramed() ? 1 : 0;
  _margin = margin + frame;
  return *this;
}