Add support for building against mjpegtools 1.9 while keeping compatiblity with older...
authorSebastian Dröge <slomo@circular-chaos.org>
Sun, 27 Jan 2008 07:32:19 +0000 (07:32 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Sun, 27 Jan 2008 07:32:19 +0000 (07:32 +0000)
Original commit message from CVS:
Based on a patch by:
Hans de Goede <j dot w dot r dot degoede at hhs dot nl>
* configure.ac:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.hh:
Add support for building against mjpegtools 1.9 while keeping
compatiblity with older versions.

ChangeLog
configure.ac
ext/mpeg2enc/gstmpeg2encoder.cc
ext/mpeg2enc/gstmpeg2encpicturereader.cc
ext/mpeg2enc/gstmpeg2encpicturereader.hh

index 84a4789..88f2535 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-01-27  Sebastian Dröge  <slomo@circular-chaos.org>
 
+       Based on a patch by:
+           Hans de Goede <j dot w dot r dot degoede at hhs dot nl>
+
+       * configure.ac:
+       * ext/mpeg2enc/gstmpeg2encoder.cc:
+       * ext/mpeg2enc/gstmpeg2encpicturereader.cc:
+       * ext/mpeg2enc/gstmpeg2encpicturereader.hh:
+       Add support for building against mjpegtools 1.9 while keeping
+       compatiblity with older versions.
+
+2008-01-27  Sebastian Dröge  <slomo@circular-chaos.org>
+
        * ext/soundtouch/gstbpmdetect.cc:
        Only consider a BPM value above 1.0 as valid.
 
index f2477ce..ce8e3a9 100644 (file)
@@ -676,7 +676,14 @@ AC_SUBST(LIBMMS_LIBS)
 dnl *** mjpegtools version info ***
 dnl some may prefer older version (given quirks above)
 dnl hm, no version info seems available within mjpegtools headers
-PKG_CHECK_EXISTS(mjpegtools >= 1.8.0 mjpegtools < 1.9.0, [
+
+PKG_CHECK_EXISTS(mjpegtools >= 1.9.0 mjpegtools < 1.10.0, [
+  AC_DEFINE(GST_MJPEGTOOLS_19x, 1, [mjpegtools >= 1.9.0 is used])
+  have_mpjegtools_19x=yes
+  ], [
+  have_mpjegtools_19x=no])
+
+PKG_CHECK_EXISTS(mjpegtools >= 1.8.0, [
   AC_DEFINE(GST_MJPEGTOOLS_18x, 1, [mjpegtools >= 1.8.0 is used])
   have_mpjegtools_18x=yes
   ], [
@@ -732,7 +739,10 @@ AG_GST_CHECK_FEATURE(MPEG2ENC, [mpeg2enc], mpeg2enc, [
               ], [
                 mpeg2enc_headers_ok=no
               ])
+         else
+           mpeg2enc_headers_ok=yes
           fi
+
           if test "x$mpeg2enc_headers_ok" = "xyes"; then
             HAVE_MPEG2ENC="yes"
           fi
index 866f63d..c8d1b3e 100644 (file)
 
 #include <mpegconsts.h>
 #include <quantize.hh>
+#ifdef GST_MJPEGTOOLS_19x
+#include <ontheflyratectl.hh>
+#else
 #include <ratectl.hh>
+#endif
 #include <seqencoder.hh>
 #include <mpeg2coder.hh>
 
@@ -53,19 +57,18 @@ GstMpeg2Encoder::~GstMpeg2Encoder ()
   gst_object_unref (element);
 }
 
-gboolean GstMpeg2Encoder::setup ()
+gboolean
+GstMpeg2Encoder::setup ()
 {
-  MPEG2EncInVidParams
-      strm;
-  GstMpeg2enc *
-      enc;
+  MPEG2EncInVidParams strm;
+  GstMpeg2enc *enc;
 
   enc = GST_MPEG2ENC (element);
 
   /* I/O */
   reader = new GstMpeg2EncPictureReader (element, caps, &parms);
   reader->StreamPictureParams (strm);
-#ifdef GST_MJPEGTOOLS_18x
+#if defined(GST_MJPEGTOOLS_18x) && !defined(GST_MJPEGTOOLS_19x)
   /* chain thread caters for reading, do not need another thread for this */
   options.allow_parallel_read = FALSE;
 #endif
@@ -76,11 +79,22 @@ gboolean GstMpeg2Encoder::setup ()
 
   /* encoding internals */
   quantizer = new Quantizer (parms);
+#ifdef GST_MJPEGTOOLS_19x
+  pass1ratectl = new OnTheFlyPass1 (parms);
+  pass2ratectl = new OnTheFlyPass2 (parms);
+#else
   bitrate_controller = new OnTheFlyRateCtl (parms);
+#endif
+
 #ifdef GST_MJPEGTOOLS_18x
   /* sequencer */
+#  ifdef GST_MJPEGTOOLS_19x
+  seqencoder = new SeqEncoder (parms, *reader, *quantizer,
+      *writer, *pass1ratectl, *pass2ratectl);
+#  else
   seqencoder = new SeqEncoder (parms, *reader, *quantizer,
       *writer, *bitrate_controller);
+#  endif
 #else
   coder = new MPEG2Coder (parms, *writer);
   /* sequencer */
index 9bc59ed..57f95cc 100644 (file)
 
 #include <encoderparams.hh>
 
+#ifdef GST_MJPEGTOOLS_19x
+#include <imageplanes.hh>
+#endif
+
 #include "gstmpeg2enc.hh"
 #include "gstmpeg2encpicturereader.hh"
 
@@ -79,9 +83,17 @@ GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams & strm)
  */
 
 bool
-GstMpeg2EncPictureReader::LoadFrame ()
+#ifdef GST_MJPEGTOOLS_19x
+    GstMpeg2EncPictureReader::LoadFrame (ImagePlanes & image)
+#else
+    GstMpeg2EncPictureReader::LoadFrame ()
+#endif
 {
-  gint i, x, y, n;
+
+#ifndef GST_MJPEGTOOLS_19x
+  gint n;
+#endif
+  gint i, x, y;
   guint8 *frame;
   GstMpeg2enc *enc;
 
@@ -100,23 +112,39 @@ GstMpeg2EncPictureReader::LoadFrame ()
   }
 
   frame = GST_BUFFER_DATA (enc->buffer);
+#ifndef GST_MJPEGTOOLS_19x
   n = frames_read % input_imgs_buf_size;
+#endif
   x = encparams.horizontal_size;
   y = encparams.vertical_size;
 
   for (i = 0; i < y; i++) {
+#ifdef GST_MJPEGTOOLS_19x
+    memcpy (image.Plane (0) + i * encparams.phy_width, frame, x);
+#else
     memcpy (input_imgs_buf[n][0] + i * encparams.phy_width, frame, x);
+#endif
     frame += x;
   }
+#ifndef GST_MJPEGTOOLS_19x
   lum_mean[n] = LumMean (input_imgs_buf[n][0]);
+#endif
   x >>= 1;
   y >>= 1;
   for (i = 0; i < y; i++) {
+#ifdef GST_MJPEGTOOLS_19x
+    memcpy (image.Plane (1) + i * encparams.phy_chrom_width, frame, x);
+#else
     memcpy (input_imgs_buf[n][1] + i * encparams.phy_chrom_width, frame, x);
+#endif
     frame += x;
   }
   for (i = 0; i < y; i++) {
+#ifdef GST_MJPEGTOOLS_19x
+    memcpy (image.Plane (2) + i * encparams.phy_chrom_width, frame, x);
+#else
     memcpy (input_imgs_buf[n][2] + i * encparams.phy_chrom_width, frame, x);
+#endif
     frame += x;
   }
   gst_buffer_unref (enc->buffer);
index 7f6c9c3..89fb58d 100644 (file)
@@ -37,7 +37,11 @@ public:
 
 protected:
   /* read a frame */
+#ifdef GST_MJPEGTOOLS_19x
+  bool LoadFrame (ImagePlanes &image);
+#else
   bool LoadFrame ();
+#endif
 
 private:
   GstElement *element;