jpegenc: Clean up reset/start/stop handling

This commit is contained in:
Sebastian Dröge 2013-07-25 14:26:07 +02:00
parent 4944183061
commit ef4a21253b

View file

@ -70,7 +70,6 @@ enum
PROP_IDCT_METHOD
};
static void gst_jpegenc_reset (GstJpegEnc * enc);
static void gst_jpegenc_finalize (GObject * object);
static void gst_jpegenc_resync (GstJpegEnc * jpegenc);
@ -81,6 +80,7 @@ static void gst_jpegenc_get_property (GObject * object, guint prop_id,
static gboolean gst_jpegenc_start (GstVideoEncoder * benc);
static gboolean gst_jpegenc_stop (GstVideoEncoder * benc);
static gboolean gst_jpegenc_reset (GstVideoEncoder * benc, gboolean hard);
static gboolean gst_jpegenc_set_format (GstVideoEncoder * encoder,
GstVideoCodecState * state);
static GstFlowReturn gst_jpegenc_handle_frame (GstVideoEncoder * encoder,
@ -161,6 +161,7 @@ gst_jpegenc_class_init (GstJpegEncClass * klass)
venc_class->start = gst_jpegenc_start;
venc_class->stop = gst_jpegenc_stop;
venc_class->reset = gst_jpegenc_reset;
venc_class->set_format = gst_jpegenc_set_format;
venc_class->handle_frame = gst_jpegenc_handle_frame;
venc_class->propose_allocation = gst_jpegenc_propose_allocation;
@ -300,28 +301,16 @@ gst_jpegenc_init (GstJpegEnc * jpegenc)
jpegenc->quality = JPEG_DEFAULT_QUALITY;
jpegenc->smoothing = JPEG_DEFAULT_SMOOTHING;
jpegenc->idct_method = JPEG_DEFAULT_IDCT_METHOD;
gst_jpegenc_reset (jpegenc);
}
static void
gst_jpegenc_reset (GstJpegEnc * enc)
static gboolean
gst_jpegenc_reset (GstVideoEncoder * benc, gboolean hard)
{
gint i, j;
GstJpegEnc *enc = (GstJpegEnc *) benc;
g_free (enc->line[0]);
g_free (enc->line[1]);
g_free (enc->line[2]);
enc->line[0] = NULL;
enc->line[1] = NULL;
enc->line[2] = NULL;
for (i = 0; i < 3; i++) {
for (j = 0; j < 4 * DCTSIZE; j++) {
g_free (enc->row[i][j]);
enc->row[i][j] = NULL;
}
}
enc->sof_marker = -1;
return TRUE;
}
static void
@ -633,8 +622,20 @@ static gboolean
gst_jpegenc_stop (GstVideoEncoder * benc)
{
GstJpegEnc *enc = (GstJpegEnc *) benc;
gint i, j;
gst_jpegenc_reset (enc);
g_free (enc->line[0]);
g_free (enc->line[1]);
g_free (enc->line[2]);
enc->line[0] = NULL;
enc->line[1] = NULL;
enc->line[2] = NULL;
for (i = 0; i < 3; i++) {
for (j = 0; j < 4 * DCTSIZE; j++) {
g_free (enc->row[i][j]);
enc->row[i][j] = NULL;
}
}
return TRUE;
}