summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2013-06-23 14:32:15 +0100
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-08-06 17:13:03 +0000
commit7f6eb54d42466f4961149bfc2f43ce1e713cbf06 (patch)
treeaa35abe9c3c215d2fe97fe9cec9c5dfc5068f2e5
parent79d90b4fd2301d8ae794e4bd5b8c4c3edbcade33 (diff)
mpeg2enc: remove code paths for older mjpegtools versions
Gets rid of lots of code paths that no one has built, used or tested for ages, and makes code more maintainable. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1491>
-rw-r--r--ext/mpeg2enc/gstmpeg2encoder.cc40
-rw-r--r--ext/mpeg2enc/gstmpeg2encoptions.cc5
-rw-r--r--ext/mpeg2enc/gstmpeg2encpicturereader.cc25
-rw-r--r--ext/mpeg2enc/gstmpeg2encpicturereader.hh6
-rw-r--r--ext/mpeg2enc/gstmpeg2encstreamwriter.cc95
-rw-r--r--ext/mpeg2enc/gstmpeg2encstreamwriter.hh21
6 files changed, 0 insertions, 192 deletions
diff --git a/ext/mpeg2enc/gstmpeg2encoder.cc b/ext/mpeg2enc/gstmpeg2encoder.cc
index 20010fa0b..441735af8 100644
--- a/ext/mpeg2enc/gstmpeg2encoder.cc
+++ b/ext/mpeg2enc/gstmpeg2encoder.cc
@@ -33,8 +33,6 @@
#include <ontheflyratectl.hh>
#include <pass1ratectl.hh>
#include <pass2ratectl.hh>
-#else
-#include <ratectl.hh>
#endif
#include <seqencoder.hh>
#include <mpeg2coder.hh>
@@ -74,32 +72,15 @@ gboolean GstMpeg2Encoder::setup ()
/* I/O */
reader = new GstMpeg2EncPictureReader (element, caps, &parms);
reader->StreamPictureParams (strm);
-#if GST_MJPEGTOOLS_API == 10800
- /* chain thread caters for reading, do not need another thread for this */
- options.allow_parallel_read = FALSE;
-#endif
if (options.SetFormatPresets (strm)) {
delete reader;
reader = NULL;
writer = NULL;
quantizer = NULL;
-#if GST_MJPEGTOOLS_API < 10900
- bitrate_controller = NULL;
-#else
pass1ratectl = NULL;
pass2ratectl = NULL;
-#endif
-#if GST_MJPEGTOOLS_API >= 10900
- /* sequencer */
- seqencoder = NULL;
-#elif GST_MJPEGTOOLS_API >= 10800
/* sequencer */
seqencoder = NULL;
-#else
- coder = NULL;
- /* sequencer */
- seqencoder = NULL;
-#endif
return FALSE;
}
@@ -107,26 +88,11 @@ gboolean GstMpeg2Encoder::setup ()
/* encoding internals */
quantizer = new Quantizer (parms);
-#if GST_MJPEGTOOLS_API < 10900
- bitrate_controller = new OnTheFlyRateCtl (parms);
-#else
pass1ratectl = new OnTheFlyPass1 (parms);
pass2ratectl = new OnTheFlyPass2 (parms);
-#endif
-#if GST_MJPEGTOOLS_API >= 10900
/* sequencer */
seqencoder = new SeqEncoder (parms, *reader, *quantizer,
*writer, *pass1ratectl, *pass2ratectl);
-#elif GST_MJPEGTOOLS_API >= 10800
- /* sequencer */
- seqencoder = new SeqEncoder (parms, *reader, *quantizer,
- *writer, *bitrate_controller);
-#else
- coder = new MPEG2Coder (parms, *writer);
- /* sequencer */
- seqencoder = new SeqEncoder (parms, *reader, *quantizer,
- *writer, *coder, *bitrate_controller);
-#endif
return TRUE;
}
@@ -138,9 +104,7 @@ GstMpeg2Encoder::init ()
parms.Init (options);
reader->Init ();
quantizer->Init ();
-#if GST_MJPEGTOOLS_API >= 10800
seqencoder->Init ();
-#endif
init_done = TRUE;
}
}
@@ -153,11 +117,7 @@ void
GstMpeg2Encoder::encode ()
{
/* hm, this is all... eek! */
-#if GST_MJPEGTOOLS_API >= 10800
seqencoder->EncodeStream ();
-#else
- seqencoder->Encode ();
-#endif
}
/*
diff --git a/ext/mpeg2enc/gstmpeg2encoptions.cc b/ext/mpeg2enc/gstmpeg2encoptions.cc
index 59265e0fc..092856070 100644
--- a/ext/mpeg2enc/gstmpeg2encoptions.cc
+++ b/ext/mpeg2enc/gstmpeg2encoptions.cc
@@ -495,7 +495,6 @@ GstMpeg2EncOptions::initProperties (GObjectClass * klass)
g_param_spec_boolean ("constraints", "Constraints",
"Use strict video resolution and bitrate checks",
TRUE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
-#if GST_MJPEGTOOLS_API >= 10800
g_object_class_install_property (klass, ARG_DUALPRIME_MPEG2,
g_param_spec_boolean ("dualprime", "Dual Prime Motion Estimation",
"Dual Prime Motion Estimation Mode for MPEG-2 I/P-frame only "
@@ -632,11 +631,9 @@ GstMpeg2EncOptions::getProperty (guint prop_id, GValue * value)
case ARG_CONSTRAINTS:
g_value_set_boolean (value, !ignore_constraints);
break;
-#if GST_MJPEGTOOLS_API >= 10800
case ARG_DUALPRIME_MPEG2:
g_value_set_boolean (value, hack_dualprime);
break;
-#endif
default:
break;
}
@@ -770,11 +767,9 @@ GstMpeg2EncOptions::setProperty (guint prop_id, const GValue * value)
case ARG_CONSTRAINTS:
ignore_constraints = !g_value_get_boolean (value);
break;
-#if GST_MJPEGTOOLS_API >= 10800
case ARG_DUALPRIME_MPEG2:
hack_dualprime = g_value_get_boolean (value);
break;
-#endif
default:
break;
}
diff --git a/ext/mpeg2enc/gstmpeg2encpicturereader.cc b/ext/mpeg2enc/gstmpeg2encpicturereader.cc
index 282158f7e..67d8ee689 100644
--- a/ext/mpeg2enc/gstmpeg2encpicturereader.cc
+++ b/ext/mpeg2enc/gstmpeg2encpicturereader.cc
@@ -104,15 +104,8 @@ GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams & strm)
*/
bool
-#if GST_MJPEGTOOLS_API >= 10900
GstMpeg2EncPictureReader::LoadFrame (ImagePlanes & image)
-#else
- GstMpeg2EncPictureReader::LoadFrame ()
-#endif
{
-#if GST_MJPEGTOOLS_API < 10900
- gint n;
-#endif
gint i, x, y, s;
guint8 *frame;
GstMpeg2enc *enc;
@@ -137,45 +130,27 @@ bool
gst_video_frame_map (&vframe, &enc->input_state->info, inframe->input_buffer, GST_MAP_READ);
// frame = GST_BUFFER_DATA (enc->buffer);
-#if GST_MJPEGTOOLS_API < 10900
- n = frames_read % input_imgs_buf_size;
-#endif
frame = GST_VIDEO_FRAME_COMP_DATA (&vframe, 0);
s = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 0);
x = encparams.horizontal_size;
y = encparams.vertical_size;
for (i = 0; i < y; i++) {
-#if GST_MJPEGTOOLS_API >= 10900
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 += s;
}
-#if GST_MJPEGTOOLS_API < 10900
- lum_mean[n] = LumMean (input_imgs_buf[n][0]);
-#endif
frame = GST_VIDEO_FRAME_COMP_DATA (&vframe, 1);
s = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 1);
x >>= 1;
y >>= 1;
for (i = 0; i < y; i++) {
-#if GST_MJPEGTOOLS_API >= 10900
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 += s;
}
frame = GST_VIDEO_FRAME_COMP_DATA (&vframe, 2);
s = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 2);
for (i = 0; i < y; i++) {
-#if GST_MJPEGTOOLS_API >= 10900
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 += s;
}
gst_video_frame_unmap (&vframe);
diff --git a/ext/mpeg2enc/gstmpeg2encpicturereader.hh b/ext/mpeg2enc/gstmpeg2encpicturereader.hh
index 1c9e7f9ee..030c7f3a7 100644
--- a/ext/mpeg2enc/gstmpeg2encpicturereader.hh
+++ b/ext/mpeg2enc/gstmpeg2encpicturereader.hh
@@ -25,9 +25,7 @@
#include <gst/gst.h>
#include <picturereader.hh>
-#if GST_MJPEGTOOLS_API >= 10900
#include <imageplanes.hh>
-#endif
class GstMpeg2EncPictureReader : public PictureReader {
@@ -41,11 +39,7 @@ public:
protected:
/* read a frame */
-#if GST_MJPEGTOOLS_API >= 10900
bool LoadFrame (ImagePlanes &image);
-#else
- bool LoadFrame ();
-#endif
private:
GstElement *element;
diff --git a/ext/mpeg2enc/gstmpeg2encstreamwriter.cc b/ext/mpeg2enc/gstmpeg2encstreamwriter.cc
index 2353ace82..bcf467f5f 100644
--- a/ext/mpeg2enc/gstmpeg2encstreamwriter.cc
+++ b/ext/mpeg2enc/gstmpeg2encstreamwriter.cc
@@ -28,8 +28,6 @@
#include "gstmpeg2encstreamwriter.hh"
#include <string.h>
-#if GST_MJPEGTOOLS_API >= 10800
-
/*
* Class init stuff.
*/
@@ -78,96 +76,3 @@ GstMpeg2EncStreamWriter::BitCount ()
{
return flushed * 8ll;
}
-
-#else
-
-#define BUFSIZE (128*1024)
-
-/*
- * Class init stuff.
- */
-
-GstMpeg2EncStreamWriter::GstMpeg2EncStreamWriter (GstPad * in_pad, EncoderParams * params):
-ElemStrmWriter (*params)
-{
- pad = in_pad;
- gst_object_ref (pad);
- buf = NULL;
-}
-
-GstMpeg2EncStreamWriter::~GstMpeg2EncStreamWriter ()
-{
- gst_object_unref (pad);
-}
-
-/*
- * Output functions.
- */
-
-void
-GstMpeg2EncStreamWriter::PutBits (guint32 val, gint n)
-{
- /* only relevant bits. Note that (according to Andrew),
- * some CPUs do bitshifts modulo wordsize (32), which
- * means that we have to check for n != 32 before
- * bitshifting to the relevant bits (i.e. 0xffffffff <<
- * 32 == 0xffffffff). */
- if (n != 32)
- val &= ~(0xffffffffU << n);
-
- /* write data */
- while (n >= outcnt) {
- if (!buf) {
- buf = gst_buffer_new_and_alloc (BUFSIZE);
- GST_BUFFER_SIZE (buf) = 0;
- }
-
- outbfr = (outbfr << outcnt) | (val >> (n - outcnt));
- GST_BUFFER_DATA (buf)[GST_BUFFER_SIZE (buf)++] = outbfr;
- n -= outcnt;
- outcnt = 8;
- bytecnt++;
-
- if (GST_BUFFER_SIZE (buf) >= BUFSIZE)
- FrameFlush ();
- }
-
- /* cache remaining bits */
- if (n != 0) {
- outbfr = (outbfr << n) | val;
- outcnt -= n;
- }
-}
-
-void
-GstMpeg2EncStreamWriter::FrameBegin ()
-{
-}
-
-void
-GstMpeg2EncStreamWriter::FrameFlush ()
-{
- GstVideoCodecFrame *frame;
- GstVideoEncoder *video_encoder = GST_VIDEO_ENCODER (GST_PAD_PARENT (pad));
- GstMpeg2enc *enc = GST_MPEG2ENC (video_encoder);
-
- frame = gst_video_encoder_get_oldest_frame (video_encoder);
- g_assert (frame != NULL);
-
- if (buf) {
- frame->output_buffer = buf;
- /* this should not block anything else (e.g. chain), but if it does,
- * it's ok as mpeg2enc is not really a loop-based element, but push-based */
- GST_MPEG2ENC_MUTEX_LOCK (enc);
- gst_buffer_set_caps (buf, pad->get_current_caps());
- enc->srcresult = gst_video_encoder_finish_frame (video_encoder, frame);
- GST_MPEG2ENC_MUTEX_UNLOCK (enc);
- buf = NULL;
- }
-}
-
-void
-GstMpeg2EncStreamWriter::FrameDiscard ()
-{
-}
-#endif /* GST_MJPEGTOOLS_API >= 10800 */
diff --git a/ext/mpeg2enc/gstmpeg2encstreamwriter.hh b/ext/mpeg2enc/gstmpeg2encstreamwriter.hh
index 85053dbf0..4c92c148d 100644
--- a/ext/mpeg2enc/gstmpeg2encstreamwriter.hh
+++ b/ext/mpeg2enc/gstmpeg2encstreamwriter.hh
@@ -27,8 +27,6 @@
#include <elemstrmwriter.hh>
-#if GST_MJPEGTOOLS_API >= 10800
-
class GstMpeg2EncStreamWriter : public ElemStrmWriter {
public:
GstMpeg2EncStreamWriter (GstPad *pad, EncoderParams *params);
@@ -44,23 +42,4 @@ class GstMpeg2EncStreamWriter : public ElemStrmWriter {
GstBuffer *buf;
};
-#else
-
-class GstMpeg2EncStreamWriter : public ElemStrmWriter {
-public:
- GstMpeg2EncStreamWriter (GstPad *pad, EncoderParams *params);
- ~GstMpeg2EncStreamWriter ();
-
- /* output functions */
- void PutBits (guint32 val, gint n);
- void FrameBegin ();
- void FrameFlush ();
- void FrameDiscard ();
-
-private:
- GstPad *pad;
- GstBuffer *buf;
-};
-#endif /* GST_MJPEGTOOLS_API >= 10800 */
-
#endif /* __GST_MPEG2ENCSTREAMWRITER_H__ */