Re: [linux-audio-dev] MP3 Decoder wishlist

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] MP3 Decoder wishlist
From: Guenther Sohler (guenther.sohler_AT_newlogic.com)
Date: Thu Feb 28 2002 - 09:56:12 EET


hallo rene,
> We _only_ need to add a mid-layer interface to mad. Providing open,
> seek, read, close.
This would be a nice idea, for further people having this problem.
My job is done now, because Now I have everything i want,
open,close. a fast seek without prereading the mp3.

If you were able to write a "write" midlevel-function, which encodes mp3(it
will fit into the stream because the compressed size and the decompressed size
is constant) you could write a "device driver" and attach it to a mp3 when
insmoding.(something similar like mounting an iso file)

> GSMP does this. GSMP/{include,src}/MADHelper.{hh,cc}.
Hmm - it seems that i am too stupid to realize what this code does -
but i was able to write my own tiny, very short seek function.

it is like

void Mp3Player::halt(int mstime)
{
 int status=0;
 fseek(mp3in,0,SEEK_SET);
 mad_stream_init(&mp3stream);
 mad_timer_reset(&mp3timer);

while(((double)mp3timer.seconds+(double)mp3timer.fraction/(double)MAD_TIMER_RESO
LUTION)*1000.0 < mstime && s
tatus == 0)
 {
  status=play(1);
 }
}

int Mp3Player::play(int skip)
{
 int outputbytes;
 size_t ReadSize, Remaining;
 unsigned char *ReadStart;
 int i;
 unsigned short Sample;

 if(mp3stream.buffer==NULL || mp3stream.error==MAD_ERROR_BUFLEN)
 {
  if(mp3stream.next_frame!=NULL)
  {
   Remaining=mp3stream.bufend-mp3stream.next_frame;
   memmove(InputBuffer,mp3stream.next_frame,Remaining);
   ReadStart=InputBuffer+Remaining;
   ReadSize=MP3BUFFERSIZE-Remaining;
  }
  else
  {
   ReadSize=MP3BUFFERSIZE;
   ReadStart=InputBuffer;
   Remaining=0;
  }
  ReadSize=fread(ReadStart,1,ReadSize,mp3in);
  if(ReadSize<=0) return 1;
  mad_stream_buffer(&mp3stream,InputBuffer,ReadSize+Remaining);
  mp3stream.error=(mad_error) 0;
 }
 if(skip)
 {
  mad_header_decode(&mp3frame.header,&mp3stream);
  mad_timer_add(&mp3timer,mp3frame.header.duration);
  mp3stream.this_frame=mp3stream.next_frame;
  return 0;
 }

...

rds

Guenther Sohler

NewLogic Technologies AG
Millennium Park 6
A-6890 Lustenau
                                           Phone: +43-5577-62000-507
E-Mail: guenther.sohler_AT_newlogic.com Fax: +43-5577-62000-988


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Thu Feb 28 2002 - 09:47:56 EET