[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mp3encoder
Subject:    [mp3encoder] How to use libmp3lame decoder?
From:       Artem Ignatiev <timon () technopunk ! ru>
Date:       2004-07-14 11:37:04
Message-ID: 213B533E-D58A-11D8-BFAA-000502D300DB () technopunk ! ru
[Download RAW message or body]

Hi,
I'm trying to feed mpeg 1 layer 2 data from satellite into Icecast, 
after recoding to layer 3. LAME codes data ok, but I don't understand 
quite clearly, how to use LAME's own decoder, so I have to use another 
library for decoding, which violates KISS principle.

I've got rather small chunk of data from satellite, 5376 bytes in 
length. mpg123 plays it ok, and command-line frontend to LAME recodes 
it to mp3 fine, too, but when I'm trying to decode it ``by hands'', 
using code below, debugger shows that decoder found correct 
header(bitrate, samplerate, number of channels, frame length), but 
returned 0 samples. What am I doing wrong?

/* "tst" is 5376 bytes long file. */
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <lame/lame.h>

char buf[5376];
short left[1024000], right[1024000];

int main(void) {
	int cnt, cnt2, fid1 = open("tst", O_RDONLY);
	lame_global_flags *gf = lame_init();
	mp3data_struct mpd;
	
	lame_set_decode_only(gf, 1); lame_init_params(gf); lame_decode_init();
	cnt = read(fid1, buf, 5376); cnt2 = lame_decode_headers(buf, cnt, 
left, right, &mpd);
	return 0;
}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic