added support for external MP3 files

This commit is contained in:
Moritz Bunkus 2003-02-23 23:23:10 +00:00
parent 69d4f9b9bc
commit fe65e487e5
7 changed files with 73 additions and 81 deletions

View File

@ -16,7 +16,8 @@ mkvmerge_SOURCES = mkvmerge.cpp mkvmerge.h \
pr_generic.h pr_generic.cpp \
queue.cpp queue.h \
r_ac3.cpp r_ac3.h \
r_avi.cpp r_avi.h
r_avi.cpp r_avi.h \
r_mp3.cpp r_mp3.h
#mkvmerge_LDADD = @OGG_LIBS@ @VORBIS_LIBS@ @VORBISENC_LIBS@ @AVILIB_LIBS@ \
# @DMALLOC_LIBS@ @PROFILING_LIBS@ @MATROSKA_LIBS@

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: mkvmerge.cpp,v 1.10 2003/02/23 22:51:49 mosu Exp $
\version \$Id: mkvmerge.cpp,v 1.11 2003/02/23 23:23:10 mosu Exp $
\brief command line parameter parsing, looping, output handling
\author Moritz Bunkus <moritz @ bunkus.org>
*/
@ -50,8 +50,9 @@
#include "common.h"
#include "queue.h"
#include "r_avi.h"
#include "r_ac3.h"
#include "r_avi.h"
#include "r_mp3.h"
#ifdef DMALLOC
#include <dmalloc.h>
@ -100,20 +101,20 @@ StdIOCallback *out;
file_type_t file_types[] =
{{"---", TYPEUNKNOWN, "<unknown>"},
{"demultiplexers:", -1, ""},
{"ogg", TYPEOGM, "general OGG media stream, Vorbis audio embedded in OGG"},
// {"ogg", TYPEOGM, "general OGG media stream, Vorbis audio embedded in OGG"},
{"avi", TYPEAVI, "AVI (Audio/Video Interleaved)"},
{"wav", TYPEWAV, "WAVE (uncompressed PCM)"},
{"srt", TYPEWAV, "SRT text subtitles"},
{" ", TYPEMICRODVD, "MicroDVD text subtitles"},
{"idx", TYPEVOBSUB, "VobSub subtitles"},
// {"wav", TYPEWAV, "WAVE (uncompressed PCM)"},
// {"srt", TYPEWAV, "SRT text subtitles"},
// {" ", TYPEMICRODVD, "MicroDVD text subtitles"},
// {"idx", TYPEVOBSUB, "VobSub subtitles"},
{"mp3", TYPEMP3, "MPEG1 layer III audio (CBR and VBR/ABR)"},
{"ac3", TYPEAC3, "A/52 (aka AC3)"},
{"output modules:", -1, ""},
{" ", -1, "Vorbis audio"},
// {" ", -1, "Vorbis audio"},
{" ", -1, "Video (not MPEG1/2)"},
{" ", -1, "uncompressed PCM audio"},
{" ", -1, "text subtitles"},
{" ", -1, "VobSub subtitles"},
// {" ", -1, "uncompressed PCM audio"},
// {" ", -1, "text subtitles"},
// {" ", -1, "VobSub subtitles"},
{" ", -1, "MP3 audio"},
{" ", -1, "AC3 audio"},
{NULL, -1, NULL}};
@ -190,8 +191,8 @@ static int get_type(char *filename) {
// return TYPEOGM;
// else if (srt_reader_c::probe_file(f, size))
// return TYPESRT;
// else if (mp3_reader_c::probe_file(f, size))
// return TYPEMP3;
else if (mp3_reader_c::probe_file(f, size))
return TYPEMP3;
else if (ac3_reader_c::probe_file(f, size))
return TYPEAC3;
// else if (microdvd_reader_c::probe_file(f, size))
@ -639,14 +640,13 @@ static void parse_args(int argc, char **argv) {
// file->reader = new srt_reader_c(file->name, &async, &range,
// comments);
// break;
// case TYPEMP3:
// if ((astreams != NULL) || (vstreams != NULL) ||
// (tstreams != NULL))
// fprintf(stderr, "Warning: -a/-A/-d/-D/-t/-T are ignored for " \
// "MP3 files.\n");
// file->reader = new mp3_reader_c(file->name, &async, &range,
// comments);
// break;
case TYPEMP3:
if ((astreams != NULL) || (vstreams != NULL) ||
(tstreams != NULL))
fprintf(stderr, "Warning: -a/-A/-d/-D/-t/-T are ignored for " \
"MP3 files.\n");
file->reader = new mp3_reader_c(file->name, &async, &range);
break;
case TYPEAC3:
if ((astreams != NULL) || (vstreams != NULL) ||
(tstreams != NULL))

View File

@ -2,7 +2,7 @@
mkvmerge -- utility for splicing together matroska files
from component media subtypes
p_mp3.h
p_ac3.h
Written by Moritz Bunkus <moritz@bunkus.org>
@ -13,8 +13,8 @@
/*!
\file
\version \$Id: p_ac3.cpp,v 1.1 2003/02/23 22:51:49 mosu Exp $
\brief MP3 output module
\version \$Id: p_ac3.cpp,v 1.2 2003/02/23 23:23:10 mosu Exp $
\brief AC3 output module
\author Moritz Bunkus <moritz @ bunkus.org>
*/

View File

@ -2,7 +2,7 @@
mkvmerge -- utility for splicing together matroska files
from component media subtypes
p_mp3.h
p_ac3.h
Written by Moritz Bunkus <moritz@bunkus.org>
@ -13,8 +13,8 @@
/*!
\file
\version \$Id: p_ac3.h,v 1.1 2003/02/23 22:51:49 mosu Exp $
\brief class definition for the MP3 output module
\version \$Id: p_ac3.h,v 1.2 2003/02/23 23:23:10 mosu Exp $
\brief class definition for the AC3 output module
\author Moritz Bunkus <moritz @ bunkus.org>
*/

View File

@ -2,7 +2,7 @@
mkvmerge -- utility for splicing together matroska files
from component media subtypes
r_avi.h
r_ac3.h
Written by Moritz Bunkus <moritz@bunkus.org>
@ -13,8 +13,8 @@
/*!
\file
\version \$Id: r_ac3.cpp,v 1.2 2003/02/23 22:51:49 mosu Exp $
\brief AVI demultiplexer module
\version \$Id: r_ac3.cpp,v 1.3 2003/02/23 23:23:10 mosu Exp $
\brief AC3 demultiplexer module
\author Moritz Bunkus <moritz @ bunkus.org>
*/

View File

@ -1,31 +1,34 @@
/*
ogmmerge -- utility for splicing together ogg bitstreams
mkvmerge -- utility for splicing together matroska files
from component media subtypes
r_mp3.cpp
MP3 demultiplexer module
r_mp3.h
Written by Moritz Bunkus <moritz@bunkus.org>
Based on Xiph.org's 'oggmerge' found in their CVS repository
See http://www.xiph.org
Distributed under the GPL
see the file COPYING for details
or visit http://www.gnu.org/copyleft/gpl.html
*/
/*!
\file
\version \$Id: r_mp3.cpp,v 1.2 2003/02/23 23:23:10 mosu Exp $
\brief MP3 reader module
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ogg/ogg.h>
#include "ogmmerge.h"
#include "ogmstreams.h"
#include "common.h"
#include "error.h"
#include "mkvmerge.h"
#include "queue.h"
#include "r_mp3.h"
#include "mp3_common.h"
#include "p_mp3.h"
#ifdef DMALLOC
#include <dmalloc.h>
@ -64,7 +67,7 @@ int mp3_reader_c::probe_file(FILE *file, u_int64_t size) {
}
mp3_reader_c::mp3_reader_c(char *fname, audio_sync_t *nasync,
range_t *nrange, char **ncomments) throw (error_c) {
range_t *nrange) throw (error_c) {
int pos;
unsigned long header;
mp3_header_t mp3header;
@ -91,11 +94,12 @@ mp3_reader_c::mp3_reader_c(char *fname, audio_sync_t *nasync,
decode_mp3_header(header, &mp3header);
bytes_processed = 0;
mp3packetizer = new mp3_packetizer_c(mp3_freqs[mp3header.sampling_frequency],
mp3packetizer = new mp3_packetizer_c(NULL, 0,
mp3_freqs[mp3header.sampling_frequency],
mp3header.stereo ? 2 : 1,
mp3_tabsel[mp3header.lsf]
[mp3header.bitrate_index],
nasync, nrange, ncomments);
nasync, nrange);
if (verbose)
fprintf(stderr, "Using MP3 demultiplexer for %s.\n+-> Using " \
"MP3 output module for audio stream.\n", fname);
@ -114,14 +118,13 @@ int mp3_reader_c::read() {
int nread, last_frame;
do {
if (mp3packetizer->page_available())
if (mp3packetizer->packet_available())
return EMOREDATA;
nread = fread(chunk, 1, 4096, file);
if (nread <= 0) {
mp3packetizer->produce_eos_packet();
if (nread <= 0)
return 0;
}
last_frame = (nread == 4096 ? 0 : 1);
mp3packetizer->process((char *)chunk, nread, last_frame);
bytes_processed += nread;
@ -131,22 +134,14 @@ int mp3_reader_c::read() {
} while (1);
}
int mp3_reader_c::serial_in_use(int serial) {
return mp3packetizer->serial_in_use(serial);
packet_t *mp3_reader_c::get_packet() {
return mp3packetizer->get_packet();
}
ogmmerge_page_t *mp3_reader_c::get_header_page(int header_type) {
return mp3packetizer->get_header_page(header_type);
}
ogmmerge_page_t *mp3_reader_c::get_page() {
return mp3packetizer->get_page();
}
void mp3_reader_c::reset() {
if (mp3packetizer != NULL)
mp3packetizer->reset();
}
// void mp3_reader_c::reset() {
// if (mp3packetizer != NULL)
// mp3packetizer->reset();
// }
int mp3_reader_c::display_priority() {
return DISPLAYPRIORITY_HIGH - 1;
@ -158,4 +153,3 @@ void mp3_reader_c::display_progress() {
(int)(bytes_processed * 100L / size));
fflush(stdout);
}

33
r_mp3.h
View File

@ -1,31 +1,30 @@
/*
ogmmerge -- utility for splicing together ogg bitstreams
mkvmerge -- utility for splicing together matroska files
from component media subtypes
r_mp3.h
class definitions for the MP3 demultiplexer module
Written by Moritz Bunkus <moritz@bunkus.org>
Based on Xiph.org's 'oggmerge' found in their CVS repository
See http://www.xiph.org
Distributed under the GPL
see the file COPYING for details
or visit http://www.gnu.org/copyleft/gpl.html
*/
/*!
\file
\version \$Id: r_mp3.h,v 1.2 2003/02/23 23:23:10 mosu Exp $
\brief class definitions for the MP3 reader module
\author Moritz Bunkus <moritz @ bunkus.org>
*/
#ifndef __R_MP3_H__
#define __R_MP3_H__
#include <stdio.h>
#include <ogg/ogg.h>
extern "C" {
#include <avilib.h>
}
#include "ogmmerge.h"
#include "common.h"
#include "error.h"
#include "queue.h"
#include "p_mp3.h"
@ -39,16 +38,14 @@ class mp3_reader_c: public generic_reader_c {
u_int64_t size;
public:
mp3_reader_c(char *fname, audio_sync_t *nasync, range_t *nrange,
char **ncomments) throw (error_c);
mp3_reader_c(char *fname, audio_sync_t *nasync, range_t *nrange)
throw (error_c);
virtual ~mp3_reader_c();
virtual int read();
virtual int serial_in_use(int);
virtual ogmmerge_page_t *get_page();
virtual ogmmerge_page_t *get_header_page(int header_type =
PACKET_TYPE_HEADER);
virtual void reset();
virtual packet_t *get_packet();
/* virtual void reset(); */
virtual int display_priority();
virtual void display_progress();