From 08efd315f98b78325d020d9331ca9d4841210dea Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 18 Apr 2003 10:28:14 +0000 Subject: [PATCH] Reversed the relationship between q_c and generic_packetizer_c: q_c is now the father of generic_packetizer_c. --- cluster_helper.cpp | 7 ++++--- p_ac3.cpp | 7 +++---- p_ac3.h | 6 +++--- p_mp3.cpp | 6 +++--- p_mp3.h | 6 +++--- p_pcm.cpp | 6 +++--- p_pcm.h | 6 +++--- p_textsubs.cpp | 4 ++-- p_textsubs.h | 6 +++--- p_video.cpp | 6 +++--- p_video.h | 6 +++--- p_vorbis.cpp | 4 ++-- p_vorbis.h | 6 +++--- pr_generic.cpp | 5 +++-- pr_generic.h | 25 ++++++------------------- queue.cpp | 4 ++-- queue.h | 24 +++++++++++++++++++----- 17 files changed, 68 insertions(+), 66 deletions(-) diff --git a/cluster_helper.cpp b/cluster_helper.cpp index 0dc45a100..01f7511b0 100644 --- a/cluster_helper.cpp +++ b/cluster_helper.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: cluster_helper.cpp,v 1.1 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: cluster_helper.cpp,v 1.2 2003/04/18 10:28:14 mosu Exp $ \brief cluster helper \author Moritz Bunkus */ @@ -180,7 +180,8 @@ int cluster_helper_c::render(IOCallback *out) { pack->data_buffer = new DataBuffer((binary *)pack->data, pack->length); KaxTrackEntry &track_entry = - static_cast(*pack->source->track_entry); + static_cast + (*((generic_packetizer_c *)pack->source)->track_entry); if (pack->bref != 0) { // P and B frames: add backward reference. bref_packet = find_packet(pack->bref); @@ -294,7 +295,7 @@ int cluster_helper_c::free_clusters() { for (i = 0; i < num_clusters; i++) { for (k = 0; k < clusters[i]->num_packets; k++) { p = clusters[i]->packets[k]; - if (p->source->get_free_refs() >= p->id) + if (((generic_packetizer_c *)p->source)->get_free_refs() >= p->id) p->superseeded = 1; } } diff --git a/p_ac3.cpp b/p_ac3.cpp index 61777d213..8d9d392bd 100644 --- a/p_ac3.cpp +++ b/p_ac3.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_ac3.cpp,v 1.10 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: p_ac3.cpp,v 1.11 2003/04/18 10:28:14 mosu Exp $ \brief AC3 output module \author Moritz Bunkus */ @@ -24,7 +24,7 @@ #include #include "mkvmerge.h" -#include "queue.h" +#include "pr_generic.h" #include "ac3_common.h" #include "p_ac3.h" @@ -37,8 +37,7 @@ ac3_packetizer_c::ac3_packetizer_c(unsigned long nsamples_per_sec, int nchannels, track_info_t *nti) - throw (error_c): - q_c(nti) { + throw (error_c): generic_packetizer_c(nti) { packetno = 0; bytes_output = 0; packet_buffer = NULL; diff --git a/p_ac3.h b/p_ac3.h index f9392e229..5b5052e80 100644 --- a/p_ac3.h +++ b/p_ac3.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_ac3.h,v 1.9 2003/04/13 15:23:02 mosu Exp $ + \version \$Id: p_ac3.h,v 1.10 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the AC3 output module \author Moritz Bunkus */ @@ -22,10 +22,10 @@ #define __P_AC3_H #include "common.h" -#include "queue.h" +#include "pr_generic.h" #include "ac3_common.h" -class ac3_packetizer_c: public q_c { +class ac3_packetizer_c: public generic_packetizer_c { private: int64_t bytes_output, packetno; unsigned long samples_per_sec; diff --git a/p_mp3.cpp b/p_mp3.cpp index 40b2f07d0..26d67c906 100644 --- a/p_mp3.cpp +++ b/p_mp3.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_mp3.cpp,v 1.12 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: p_mp3.cpp,v 1.13 2003/04/18 10:28:14 mosu Exp $ \brief MP3 output module \author Moritz Bunkus */ @@ -24,7 +24,7 @@ #include #include "mkvmerge.h" -#include "queue.h" +#include "pr_generic.h" #include "mp3_common.h" #include "p_mp3.h" @@ -37,7 +37,7 @@ mp3_packetizer_c::mp3_packetizer_c(unsigned long nsamples_per_sec, int nchannels, track_info_t *nti) - throw (error_c): q_c(nti) { + throw (error_c): generic_packetizer_c(nti) { samples_per_sec = nsamples_per_sec; channels = nchannels; bytes_output = 0; diff --git a/p_mp3.h b/p_mp3.h index 918f822a7..92805e78e 100644 --- a/p_mp3.h +++ b/p_mp3.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_mp3.h,v 1.9 2003/04/13 15:23:02 mosu Exp $ + \version \$Id: p_mp3.h,v 1.10 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the MP3 output module \author Moritz Bunkus */ @@ -22,10 +22,10 @@ #define __P_MP3_H #include "common.h" -#include "queue.h" +#include "pr_generic.h" #include "mp3_common.h" -class mp3_packetizer_c: public q_c { +class mp3_packetizer_c: public generic_packetizer_c { private: int64_t bytes_output, packetno; unsigned long samples_per_sec; diff --git a/p_pcm.cpp b/p_pcm.cpp index 451e0bef9..23d71d66a 100644 --- a/p_pcm.cpp +++ b/p_pcm.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_pcm.cpp,v 1.11 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: p_pcm.cpp,v 1.12 2003/04/18 10:28:14 mosu Exp $ \brief PCM output module \author Moritz Bunkus */ @@ -25,7 +25,7 @@ #include "mkvmerge.h" #include "common.h" -#include "queue.h" +#include "pr_generic.h" #include "p_pcm.h" #include "KaxTracks.h" @@ -38,7 +38,7 @@ pcm_packetizer_c::pcm_packetizer_c(unsigned long nsamples_per_sec, int nchannels, int nbits_per_sample, track_info_t *nti) throw (error_c): - q_c(nti) { + generic_packetizer_c(nti) { packetno = 0; bps = nchannels * nbits_per_sample * nsamples_per_sec / 8; tempbuf = (unsigned char *)malloc(bps + 128); diff --git a/p_pcm.h b/p_pcm.h index e3c72a419..cfd3dc0ab 100644 --- a/p_pcm.h +++ b/p_pcm.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_pcm.h,v 1.10 2003/04/13 15:23:03 mosu Exp $ + \version \$Id: p_pcm.h,v 1.11 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the PCM output module \author Moritz Bunkus */ @@ -22,9 +22,9 @@ #define __P_PCM_H #include "common.h" -#include "queue.h" +#include "pr_generic.h" -class pcm_packetizer_c: public q_c { +class pcm_packetizer_c: public generic_packetizer_c { private: int packetno; int bps, channels, bits_per_sample; diff --git a/p_textsubs.cpp b/p_textsubs.cpp index 96f10a179..2c72ef966 100644 --- a/p_textsubs.cpp +++ b/p_textsubs.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_textsubs.cpp,v 1.3 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: p_textsubs.cpp,v 1.4 2003/04/18 10:28:14 mosu Exp $ \brief Subripper subtitle reader \author Moritz Bunkus */ @@ -36,7 +36,7 @@ #endif textsubs_packetizer_c::textsubs_packetizer_c(track_info_t *nti) - throw (error_c): q_c(nti) { + throw (error_c): generic_packetizer_c(nti) { packetno = 0; set_header(); } diff --git a/p_textsubs.h b/p_textsubs.h index f463b147f..83f0c9277 100644 --- a/p_textsubs.h +++ b/p_textsubs.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_textsubs.h,v 1.2 2003/04/11 11:23:54 mosu Exp $ + \version \$Id: p_textsubs.h,v 1.3 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the simple text subtitle packetizer \author Moritz Bunkus */ @@ -23,9 +23,9 @@ #include "common.h" #include "pr_generic.h" -#include "queue.h" +#include "pr_generic.h" -class textsubs_packetizer_c: public q_c { +class textsubs_packetizer_c: public generic_packetizer_c { private: int packetno; diff --git a/p_video.cpp b/p_video.cpp index 651e439e6..538ba82e7 100644 --- a/p_video.cpp +++ b/p_video.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_video.cpp,v 1.19 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: p_video.cpp,v 1.20 2003/04/18 10:28:14 mosu Exp $ \brief video output module \author Moritz Bunkus */ @@ -26,7 +26,7 @@ #include "mkvmerge.h" #include "common.h" -#include "queue.h" +#include "pr_generic.h" #include "p_video.h" #include "KaxTracks.h" @@ -40,7 +40,7 @@ video_packetizer_c::video_packetizer_c(double nfps, int nwidth, int nheight, int nbpp, int navi_compat_mode, track_info_t *nti) - throw (error_c) : q_c(nti) { + throw (error_c) : generic_packetizer_c(nti) { packetno = 0; fps = nfps; width = nwidth; diff --git a/p_video.h b/p_video.h index 70b3333e5..f7936a7c5 100644 --- a/p_video.h +++ b/p_video.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_video.h,v 1.17 2003/04/13 15:23:03 mosu Exp $ + \version \$Id: p_video.h,v 1.18 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the video output module \author Moritz Bunkus */ @@ -22,14 +22,14 @@ #define __P_VIDEO_H #include "common.h" -#include "queue.h" +#include "pr_generic.h" #define VFT_IFRAME 0x10000000L #define VFT_PFRAME 0x20000000L #define VFT_BFRAME 0x40000000L #define VNUMFRAMES 0x0000FFFFL -class video_packetizer_c: public q_c { +class video_packetizer_c: public generic_packetizer_c { private: double fps; int width, height, bpp, packetno; diff --git a/p_vorbis.cpp b/p_vorbis.cpp index f9b5b6f5c..c994812e2 100644 --- a/p_vorbis.cpp +++ b/p_vorbis.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_vorbis.cpp,v 1.9 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: p_vorbis.cpp,v 1.10 2003/04/18 10:28:14 mosu Exp $ \brief Vorbis packetizer \author Moritz Bunkus */ @@ -49,7 +49,7 @@ vorbis_packetizer_c::vorbis_packetizer_c(unsigned char *d_header, int l_header, int l_comments, unsigned char *d_codecsetup, int l_codecsetup, track_info_t *nti) - throw (error_c): q_c(nti) { + throw (error_c): generic_packetizer_c(nti) { int i; packetno = 0; diff --git a/p_vorbis.h b/p_vorbis.h index dd6824cb4..7e5523f75 100644 --- a/p_vorbis.h +++ b/p_vorbis.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: p_vorbis.h,v 1.7 2003/04/13 15:23:03 mosu Exp $ + \version \$Id: p_vorbis.h,v 1.8 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the Vorbis packetizer \author Moritz Bunkus */ @@ -30,9 +30,9 @@ #include "common.h" #include "pr_generic.h" -#include "queue.h" +#include "pr_generic.h" -class vorbis_packetizer_c: public q_c { +class vorbis_packetizer_c: public generic_packetizer_c { private: int64_t last_bs, samples; int packetno; diff --git a/pr_generic.cpp b/pr_generic.cpp index 1f69aec6b..3d5bbcf3d 100644 --- a/pr_generic.cpp +++ b/pr_generic.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: pr_generic.cpp,v 1.19 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: pr_generic.cpp,v 1.20 2003/04/18 10:28:14 mosu Exp $ \brief functions common for all readers/packetizers \author Moritz Bunkus */ @@ -23,7 +23,8 @@ #include "common.h" #include "pr_generic.h" -generic_packetizer_c::generic_packetizer_c(track_info_t *nti) { +generic_packetizer_c::generic_packetizer_c(track_info_t *nti) throw(error_c): + q_c() { serialno = -1; track_entry = NULL; ti = duplicate_track_info(nti); diff --git a/pr_generic.h b/pr_generic.h index 4ec356eff..995dd7b36 100644 --- a/pr_generic.h +++ b/pr_generic.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: pr_generic.h,v 1.20 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: pr_generic.h,v 1.21 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the generic reader and packetizer \author Moritz Bunkus */ @@ -25,9 +25,10 @@ #include "KaxCluster.h" #include "KaxTracks.h" -using namespace LIBMATROSKA_NAMESPACE; +#include "error.h" +#include "queue.h" -class generic_packetizer_c; +using namespace LIBMATROSKA_NAMESPACE; typedef struct { int displacement; @@ -48,18 +49,7 @@ typedef struct { audio_sync_t async; } track_info_t; -typedef struct packet_t { - DataBuffer *data_buffer; - KaxBlockGroup *group; - KaxBlock *block; - KaxCluster *cluster; - unsigned char *data; - int length, superseeded; - int64_t timecode, id, bref, fref; - generic_packetizer_c *source; -} packet_t; - -class generic_packetizer_c { +class generic_packetizer_c: public q_c { protected: int serialno; track_info_t *ti; @@ -67,14 +57,11 @@ protected: public: KaxTrackEntry *track_entry; - generic_packetizer_c(track_info_t *nti); + generic_packetizer_c(track_info_t *nti) throw (error_c); virtual ~generic_packetizer_c(); virtual void set_free_refs(int64_t nfree_refs); virtual int64_t get_free_refs(); - virtual int packet_available() = 0; - virtual packet_t *get_packet() = 0; virtual void set_header() = 0; - virtual int64_t get_smallest_timecode() = 0; virtual int process(unsigned char *data, int size, int64_t timecode = -1, int64_t length = -1) = 0; }; diff --git a/queue.cpp b/queue.cpp index b5dc7a8c5..edfda8518 100644 --- a/queue.cpp +++ b/queue.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: queue.cpp,v 1.13 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: queue.cpp,v 1.14 2003/04/18 10:28:14 mosu Exp $ \brief packet queueing class used by every packetizer \author Moritz Bunkus */ @@ -33,7 +33,7 @@ int64_t q_c::id = 1; -q_c::q_c(track_info_t *nti) throw (error_c) : generic_packetizer_c(nti) { +q_c::q_c() { first = NULL; current = NULL; } diff --git a/queue.h b/queue.h index 7d941ddd4..96921d9f8 100644 --- a/queue.h +++ b/queue.h @@ -13,7 +13,7 @@ /*! \file - \version \$Id: queue.h,v 1.11 2003/04/18 10:08:24 mosu Exp $ + \version \$Id: queue.h,v 1.12 2003/04/18 10:28:14 mosu Exp $ \brief class definition for the queueing class \author Moritz Bunkus */ @@ -21,8 +21,22 @@ #ifndef __QUEUE_H #define __QUEUE_H -#include "error.h" -#include "pr_generic.h" +#include "KaxBlock.h" +#include "KaxCluster.h" +#include "KaxTracks.h" + +using namespace LIBMATROSKA_NAMESPACE; + +typedef struct packet_t { + DataBuffer *data_buffer; + KaxBlockGroup *group; + KaxBlock *block; + KaxCluster *cluster; + unsigned char *data; + int length, superseeded; + int64_t timecode, id, bref, fref; + void *source; +} packet_t; // q_page_t is used internally only typedef struct q_page { @@ -30,13 +44,13 @@ typedef struct q_page { struct q_page *next; } q_page_t; -class q_c: public generic_packetizer_c { +class q_c { private: static int64_t id; struct q_page *first, *current; public: - q_c(track_info_t *nti) throw (error_c); + q_c(); virtual ~q_c(); virtual int64_t add_packet(unsigned char *data, int lenth,