[MPlayer-dev-eng] [PATCH] add sh_common

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Aug 27 10:40:52 CEST 2009


Hello,
there is quite a bit of duplicated declaration and also some things like
extradata/codecdata unfortunately got different names.
Thus I suggest adding a SH_COMMON macro to declare common stuff and
a corresponding struct so it is possible to access these without knowing
which one it is.
It also bloats the subtitle struct a bit, but some of it is more a
mistake in the current implementation, e.g. "ass_track_t* ass_track"
would better use a void* context like for the others and pts will
likely be necessary for decoding support via libavcodec.
-------------- next part --------------
Index: libmpdemux/stheader.h
===================================================================
--- libmpdemux/stheader.h	(revision 29551)
+++ libmpdemux/stheader.h	(working copy)
@@ -25,13 +25,27 @@
 
 // Stream headers:
 
+#define SH_COMMON \
+  demux_stream_t *ds; \
+  struct codecs_st *codec; \
+  unsigned int format; \
+  int initialized; \
+  float stream_delay; /* number of seconds stream should be delayed (according to dwStart or similar) */ \
+  /* audio: last known pts value in output from decoder \
+   * video: predicted/interpolated PTS of the current frame */ \
+  double pts; \
+  /* codec-specific: */ \
+  void* context;   /* codec-specific stuff (usually HANDLE or struct pointer) */ \
+  char* lang; /* track language */ \
+  int default_track; \
+
 typedef struct {
+  SH_COMMON
+} sh_common_t;
+
+typedef struct {
+  SH_COMMON
   int aid;
-  demux_stream_t *ds;
-  struct codecs_st *codec;
-  unsigned int format;
-  int initialized;
-  float stream_delay; // number of seconds stream should be delayed (according to dwStart or similar)
   // output format:
   int sample_format;
   int samplerate;
@@ -63,28 +77,19 @@
   AVIStreamHeader audio;
   WAVEFORMATEX* wf;
   // codec-specific:
-  void* context; // codec-specific stuff (usually HANDLE or struct pointer)
   unsigned char* codecdata; // extra header data passed from demuxer to codec
   int codecdata_len;
-  double pts;  // last known pts value in output from decoder
   int pts_bytes; // bytes output by decoder after last known pts
-  char* lang; // track language
-  int default_track;
 } sh_audio_t;
 
 typedef struct {
+  SH_COMMON
   int vid;
-  demux_stream_t *ds;
-  struct codecs_st *codec;
-  unsigned int format;
-  int initialized;
   float timer;		  // absolute time in video stream, since last start/seek
-  float stream_delay; // number of seconds stream should be delayed (according to dwStart or similar)
   // frame counters:
   float num_frames;       // number of frames played
   int num_frames_decoded; // number of frames decoded
   // timing (mostly for mpeg):
-  double pts;     // predicted/interpolated PTS of the current frame
   double i_pts;   // PTS for the _next_ I/P frame
   float next_frame_time;
   double last_pts;
@@ -108,11 +113,10 @@
   AVIStreamHeader video;
   BITMAPINFOHEADER* bih;
   void* ImageDesc; // for quicktime codecs
-  // codec-specific:
-  void* context;   // codec-specific stuff (usually HANDLE or struct pointer)
 } sh_video_t;
 
 typedef struct {
+  SH_COMMON
   int sid;
   char type;                    // t = text, v = VobSub, a = SSA/ASS
   unsigned char* extradata; // extra header data passed from demuxer
@@ -120,8 +124,6 @@
 #ifdef CONFIG_ASS
   ass_track_t* ass_track;  // for SSA/ASS streams (type == 'a')
 #endif
-  char* lang; // track language
-  int default_track;
 } sh_sub_t;
 
 // demuxer.c:


More information about the MPlayer-dev-eng mailing list