2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 * SECTION:element-jpegenc
22 * Encodes jpeg images.
25 * <title>Example launch line</title>
27 * gst-launch videotestsrc num-buffers=50 ! video/x-raw-yuv, framerate='(fraction)'5/1 ! jpegenc ! avimux ! filesink location=mjpeg.avi
28 * ]| a pipeline to mux 5 JPEG frames per second into a 10 sec. long motion jpeg
38 #include "gstjpegenc.h"
40 #include <gst/video/video.h>
43 /* setting smoothig seems to have no effect in libjepeg
44 #define ENABLE_SMOOTHING 1
47 GST_DEBUG_CATEGORY_STATIC (jpegenc_debug);
48 #define GST_CAT_DEFAULT jpegenc_debug
50 #define JPEG_DEFAULT_QUALITY 85
51 #define JPEG_DEFAULT_SMOOTHING 0
52 #define JPEG_DEFAULT_IDCT_METHOD JDCT_FASTEST
54 /* JpegEnc signals and args */
69 static void gst_jpegenc_reset (GstJpegEnc * enc);
70 static void gst_jpegenc_finalize (GObject * object);
72 static GstFlowReturn gst_jpegenc_chain (GstPad * pad, GstObject * parent,
74 static gboolean gst_jpegenc_sink_event (GstPad * pad, GstObject * parent,
76 static GstCaps *gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter);
77 static gboolean gst_jpegenc_sink_query (GstPad * pad, GstObject * parent,
80 static void gst_jpegenc_resync (GstJpegEnc * jpegenc);
81 static void gst_jpegenc_set_property (GObject * object, guint prop_id,
82 const GValue * value, GParamSpec * pspec);
83 static void gst_jpegenc_get_property (GObject * object, guint prop_id,
84 GValue * value, GParamSpec * pspec);
85 static GstStateChangeReturn gst_jpegenc_change_state (GstElement * element,
86 GstStateChange transition);
88 #define gst_jpegenc_parent_class parent_class
89 G_DEFINE_TYPE (GstJpegEnc, gst_jpegenc, GST_TYPE_ELEMENT);
92 static GstStaticPadTemplate gst_jpegenc_sink_pad_template =
93 GST_STATIC_PAD_TEMPLATE ("sink",
96 GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
97 ("{ I420, YV12, YUY2, UYVY, Y41B, Y42B, YVYU, Y444, "
98 "RGB, BGR, RGBx, xRGB, BGRx, xBGR, GRAY8 }"))
102 static GstStaticPadTemplate gst_jpegenc_src_pad_template =
103 GST_STATIC_PAD_TEMPLATE ("src",
106 GST_STATIC_CAPS ("image/jpeg, "
107 "width = (int) [ 16, 65535 ], "
108 "height = (int) [ 16, 65535 ], " "framerate = (fraction) [ 0/1, MAX ]")
113 gst_jpegenc_class_init (GstJpegEncClass * klass)
115 GObjectClass *gobject_class;
116 GstElementClass *gstelement_class;
118 gobject_class = (GObjectClass *) klass;
119 gstelement_class = (GstElementClass *) klass;
121 gobject_class->finalize = gst_jpegenc_finalize;
122 gobject_class->set_property = gst_jpegenc_set_property;
123 gobject_class->get_property = gst_jpegenc_get_property;
125 g_object_class_install_property (gobject_class, PROP_QUALITY,
126 g_param_spec_int ("quality", "Quality", "Quality of encoding",
127 0, 100, JPEG_DEFAULT_QUALITY,
128 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
130 #ifdef ENABLE_SMOOTHING
131 /* disabled, since it doesn't seem to work */
132 g_object_class_install_property (gobject_class, PROP_SMOOTHING,
133 g_param_spec_int ("smoothing", "Smoothing", "Smoothing factor",
134 0, 100, JPEG_DEFAULT_SMOOTHING,
135 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
138 g_object_class_install_property (gobject_class, PROP_IDCT_METHOD,
139 g_param_spec_enum ("idct-method", "IDCT Method",
140 "The IDCT algorithm to use", GST_TYPE_IDCT_METHOD,
141 JPEG_DEFAULT_IDCT_METHOD,
142 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
144 gstelement_class->change_state = gst_jpegenc_change_state;
146 gst_element_class_add_pad_template (gstelement_class,
147 gst_static_pad_template_get (&gst_jpegenc_sink_pad_template));
148 gst_element_class_add_pad_template (gstelement_class,
149 gst_static_pad_template_get (&gst_jpegenc_src_pad_template));
150 gst_element_class_set_details_simple (gstelement_class, "JPEG image encoder",
151 "Codec/Encoder/Image",
152 "Encode images in JPEG format", "Wim Taymans <wim.taymans@tvd.be>");
154 GST_DEBUG_CATEGORY_INIT (jpegenc_debug, "jpegenc", 0,
155 "JPEG encoding element");
159 ensure_memory (GstJpegEnc * jpegenc)
161 GstMemory *new_memory;
163 gsize old_size, desired_size, new_size;
165 static GstAllocationParams params = { 0, 0, 0, 3, };
167 old_size = jpegenc->output_map.size;
169 desired_size = jpegenc->bufsize;
171 desired_size = old_size * 2;
173 /* Our output memory wasn't big enough.
174 * Make a new memory that's twice the size, */
175 new_memory = gst_allocator_alloc (NULL, desired_size, ¶ms);
176 gst_memory_map (new_memory, &map, GST_MAP_READWRITE);
180 /* copy previous data if any */
181 if (jpegenc->output_mem) {
182 memcpy (new_data, jpegenc->output_map.data, old_size);
183 gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
184 gst_memory_unref (jpegenc->output_mem);
187 /* drop it into place, */
188 jpegenc->output_mem = new_memory;
189 jpegenc->output_map = map;
191 /* and last, update libjpeg on where to work. */
192 jpegenc->jdest.next_output_byte = new_data + old_size;
193 jpegenc->jdest.free_in_buffer = new_size - old_size;
197 gst_jpegenc_init_destination (j_compress_ptr cinfo)
199 GST_DEBUG ("gst_jpegenc_chain: init_destination");
203 gst_jpegenc_flush_destination (j_compress_ptr cinfo)
205 GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
207 GST_DEBUG_OBJECT (jpegenc,
208 "gst_jpegenc_chain: flush_destination: buffer too small");
210 ensure_memory (jpegenc);
216 gst_jpegenc_term_destination (j_compress_ptr cinfo)
218 GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
219 GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source");
221 gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
222 /* Trim the buffer size. we will push it in the chain function */
223 gst_memory_resize (jpegenc->output_mem, 0,
224 jpegenc->output_map.size - jpegenc->jdest.free_in_buffer);
225 jpegenc->output_map.data = NULL;
226 jpegenc->output_map.size = 0;
230 gst_jpegenc_init (GstJpegEnc * jpegenc)
232 /* create the sink and src pads */
234 gst_pad_new_from_static_template (&gst_jpegenc_sink_pad_template, "sink");
235 gst_pad_set_chain_function (jpegenc->sinkpad,
236 GST_DEBUG_FUNCPTR (gst_jpegenc_chain));
237 gst_pad_set_query_function (jpegenc->sinkpad,
238 GST_DEBUG_FUNCPTR (gst_jpegenc_sink_query));
239 gst_pad_set_event_function (jpegenc->sinkpad,
240 GST_DEBUG_FUNCPTR (gst_jpegenc_sink_event));
241 gst_element_add_pad (GST_ELEMENT (jpegenc), jpegenc->sinkpad);
244 gst_pad_new_from_static_template (&gst_jpegenc_src_pad_template, "src");
245 gst_pad_use_fixed_caps (jpegenc->srcpad);
246 gst_element_add_pad (GST_ELEMENT (jpegenc), jpegenc->srcpad);
248 /* reset the initial video state */
249 gst_video_info_init (&jpegenc->info);
252 memset (&jpegenc->cinfo, 0, sizeof (jpegenc->cinfo));
253 memset (&jpegenc->jerr, 0, sizeof (jpegenc->jerr));
254 jpegenc->cinfo.err = jpeg_std_error (&jpegenc->jerr);
255 jpeg_create_compress (&jpegenc->cinfo);
257 jpegenc->jdest.init_destination = gst_jpegenc_init_destination;
258 jpegenc->jdest.empty_output_buffer = gst_jpegenc_flush_destination;
259 jpegenc->jdest.term_destination = gst_jpegenc_term_destination;
260 jpegenc->cinfo.dest = &jpegenc->jdest;
261 jpegenc->cinfo.client_data = jpegenc;
263 /* init properties */
264 jpegenc->quality = JPEG_DEFAULT_QUALITY;
265 jpegenc->smoothing = JPEG_DEFAULT_SMOOTHING;
266 jpegenc->idct_method = JPEG_DEFAULT_IDCT_METHOD;
268 gst_jpegenc_reset (jpegenc);
272 gst_jpegenc_reset (GstJpegEnc * enc)
276 g_free (enc->line[0]);
277 g_free (enc->line[1]);
278 g_free (enc->line[2]);
282 for (i = 0; i < 3; i++) {
283 for (j = 0; j < 4 * DCTSIZE; j++) {
284 g_free (enc->row[i][j]);
285 enc->row[i][j] = NULL;
289 gst_video_info_init (&enc->info);
293 gst_jpegenc_finalize (GObject * object)
295 GstJpegEnc *filter = GST_JPEGENC (object);
297 jpeg_destroy_compress (&filter->cinfo);
299 G_OBJECT_CLASS (parent_class)->finalize (object);
303 gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter)
305 GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
306 GstCaps *caps, *othercaps;
309 GstStructure *structure = NULL;
311 /* we want to proxy properties like width, height and framerate from the
312 other end of the element */
314 othercaps = gst_pad_peer_query_caps (jpegenc->srcpad, filter);
315 templ = gst_pad_get_pad_template_caps (pad);
316 if (othercaps == NULL ||
317 gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps)) {
322 caps = gst_caps_new_empty ();
324 for (i = 0; i < gst_caps_get_size (templ); i++) {
325 /* pick fields from peer caps */
326 for (j = 0; j < gst_caps_get_size (othercaps); j++) {
327 GstStructure *s = gst_caps_get_structure (othercaps, j);
330 structure = gst_structure_copy (gst_caps_get_structure (templ, i));
331 if ((val = gst_structure_get_value (s, "width")))
332 gst_structure_set_value (structure, "width", val);
333 if ((val = gst_structure_get_value (s, "height")))
334 gst_structure_set_value (structure, "height", val);
335 if ((val = gst_structure_get_value (s, "framerate")))
336 gst_structure_set_value (structure, "framerate", val);
338 caps = gst_caps_merge_structure (caps, structure);
342 gst_caps_unref (templ);
346 gst_caps_replace (&othercaps, NULL);
347 gst_object_unref (jpegenc);
353 gst_jpegenc_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
357 switch (GST_QUERY_TYPE (query)) {
360 GstCaps *filter, *caps;
362 gst_query_parse_caps (query, &filter);
363 caps = gst_jpegenc_getcaps (pad, filter);
364 gst_query_set_caps_result (query, caps);
365 gst_caps_unref (caps);
370 res = gst_pad_query_default (pad, parent, query);
377 gst_jpegenc_setcaps (GstJpegEnc * enc, GstCaps * caps)
383 const GstVideoFormatInfo *vinfo;
385 /* get info from caps */
386 if (!gst_video_info_from_caps (&info, caps))
389 /* store input description */
394 /* prepare a cached image description */
395 enc->channels = 3 + (GST_VIDEO_FORMAT_INFO_HAS_ALPHA (vinfo) ? 1 : 0);
396 /* ... but any alpha is disregarded in encoding */
397 if (GST_VIDEO_FORMAT_INFO_IS_GRAY (vinfo))
404 for (i = 0; i < enc->channels; ++i) {
405 enc->cwidth[i] = GST_VIDEO_INFO_COMP_WIDTH (&info, i);
406 enc->cheight[i] = GST_VIDEO_INFO_COMP_HEIGHT (&info, i);
407 enc->inc[i] = GST_VIDEO_INFO_COMP_PSTRIDE (&info, i);
409 enc->h_samp[i] = GST_ROUND_UP_4 (info.width) / enc->cwidth[i];
410 enc->h_max_samp = MAX (enc->h_max_samp, enc->h_samp[i]);
411 enc->v_samp[i] = GST_ROUND_UP_4 (info.height) / enc->cheight[i];
412 enc->v_max_samp = MAX (enc->v_max_samp, enc->v_samp[i]);
414 /* samp should only be 1, 2 or 4 */
415 g_assert (enc->h_max_samp <= 4);
416 g_assert (enc->v_max_samp <= 4);
418 /* maximum is invariant, as one of the components should have samp 1 */
419 for (i = 0; i < enc->channels; ++i) {
420 enc->h_samp[i] = enc->h_max_samp / enc->h_samp[i];
421 enc->v_samp[i] = enc->v_max_samp / enc->v_samp[i];
423 enc->planar = (enc->inc[0] == 1 && enc->inc[1] == 1 && enc->inc[2] == 1);
425 othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (enc->srcpad));
426 gst_caps_set_simple (othercaps,
427 "width", G_TYPE_INT, info.width, "height", G_TYPE_INT, info.height, NULL);
429 gst_caps_set_simple (othercaps,
430 "framerate", GST_TYPE_FRACTION, info.fps_n, info.fps_d, NULL);
432 gst_caps_set_simple (othercaps,
433 "pixel-aspect-ratio", GST_TYPE_FRACTION, info.par_n, info.par_d, NULL);
435 ret = gst_pad_set_caps (enc->srcpad, othercaps);
436 gst_caps_unref (othercaps);
439 gst_jpegenc_resync (enc);
446 GST_WARNING_OBJECT (enc, "refused caps %" GST_PTR_FORMAT, caps);
452 gst_jpegenc_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
455 GstJpegEnc *enc = GST_JPEGENC (parent);
457 switch (GST_EVENT_TYPE (event)) {
462 gst_event_parse_caps (event, &caps);
463 res = gst_jpegenc_setcaps (enc, caps);
464 gst_event_unref (event);
468 res = gst_pad_event_default (pad, parent, event);
476 gst_jpegenc_resync (GstJpegEnc * jpegenc)
480 const GstVideoFormatInfo *finfo;
482 GST_DEBUG_OBJECT (jpegenc, "resync");
484 finfo = jpegenc->info.finfo;
486 jpegenc->cinfo.image_width = width = GST_VIDEO_INFO_WIDTH (&jpegenc->info);
487 jpegenc->cinfo.image_height = height = GST_VIDEO_INFO_HEIGHT (&jpegenc->info);
488 jpegenc->cinfo.input_components = jpegenc->channels;
490 GST_DEBUG_OBJECT (jpegenc, "width %d, height %d", width, height);
491 GST_DEBUG_OBJECT (jpegenc, "format %d",
492 GST_VIDEO_INFO_FORMAT (&jpegenc->info));
494 if (GST_VIDEO_FORMAT_INFO_IS_RGB (finfo)) {
495 GST_DEBUG_OBJECT (jpegenc, "RGB");
496 jpegenc->cinfo.in_color_space = JCS_RGB;
497 } else if (GST_VIDEO_FORMAT_INFO_IS_GRAY (finfo)) {
498 GST_DEBUG_OBJECT (jpegenc, "gray");
499 jpegenc->cinfo.in_color_space = JCS_GRAYSCALE;
501 GST_DEBUG_OBJECT (jpegenc, "YUV");
502 jpegenc->cinfo.in_color_space = JCS_YCbCr;
505 /* input buffer size as max output */
506 jpegenc->bufsize = GST_VIDEO_INFO_SIZE (&jpegenc->info);
507 jpeg_set_defaults (&jpegenc->cinfo);
508 jpegenc->cinfo.raw_data_in = TRUE;
509 /* duh, libjpeg maps RGB to YUV ... and don't expect some conversion */
510 if (jpegenc->cinfo.in_color_space == JCS_RGB)
511 jpeg_set_colorspace (&jpegenc->cinfo, JCS_RGB);
513 GST_DEBUG_OBJECT (jpegenc, "h_max_samp=%d, v_max_samp=%d",
514 jpegenc->h_max_samp, jpegenc->v_max_samp);
515 /* image dimension info */
516 for (i = 0; i < jpegenc->channels; i++) {
517 GST_DEBUG_OBJECT (jpegenc, "comp %i: h_samp=%d, v_samp=%d", i,
518 jpegenc->h_samp[i], jpegenc->v_samp[i]);
519 jpegenc->cinfo.comp_info[i].h_samp_factor = jpegenc->h_samp[i];
520 jpegenc->cinfo.comp_info[i].v_samp_factor = jpegenc->v_samp[i];
521 g_free (jpegenc->line[i]);
522 jpegenc->line[i] = g_new (guchar *, jpegenc->v_max_samp * DCTSIZE);
523 if (!jpegenc->planar) {
524 for (j = 0; j < jpegenc->v_max_samp * DCTSIZE; j++) {
525 g_free (jpegenc->row[i][j]);
526 jpegenc->row[i][j] = g_malloc (width);
527 jpegenc->line[i][j] = jpegenc->row[i][j];
532 /* guard against a potential error in gst_jpegenc_term_destination
533 which occurs iff bufsize % 4 < free_space_remaining */
534 jpegenc->bufsize = GST_ROUND_UP_4 (jpegenc->bufsize);
536 jpeg_suppress_tables (&jpegenc->cinfo, TRUE);
538 GST_DEBUG_OBJECT (jpegenc, "resync done");
542 gst_jpegenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
547 guchar *base[3], *end[3];
552 static GstAllocationParams params = { 0, 0, 0, 3, };
554 jpegenc = GST_JPEGENC (parent);
556 if (G_UNLIKELY (GST_VIDEO_INFO_FORMAT (&jpegenc->info) ==
557 GST_VIDEO_FORMAT_UNKNOWN))
560 if (!gst_video_frame_map (&frame, &jpegenc->info, buf, GST_MAP_READ))
563 height = GST_VIDEO_FRAME_HEIGHT (&frame);
565 GST_LOG_OBJECT (jpegenc, "got buffer of %lu bytes",
566 gst_buffer_get_size (buf));
568 for (i = 0; i < jpegenc->channels; i++) {
569 base[i] = GST_VIDEO_FRAME_COMP_DATA (&frame, i);
570 stride[i] = GST_VIDEO_FRAME_COMP_STRIDE (&frame, i);
571 end[i] = base[i] + GST_VIDEO_FRAME_COMP_HEIGHT (&frame, i) * stride[i];
574 jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, ¶ms);
575 gst_memory_map (jpegenc->output_mem, &jpegenc->output_map, GST_MAP_READWRITE);
577 jpegenc->jdest.next_output_byte = jpegenc->output_map.data;
578 jpegenc->jdest.free_in_buffer = jpegenc->output_map.size;
580 /* prepare for raw input */
581 #if JPEG_LIB_VERSION >= 70
582 jpegenc->cinfo.do_fancy_downsampling = FALSE;
584 jpegenc->cinfo.smoothing_factor = jpegenc->smoothing;
585 jpegenc->cinfo.dct_method = jpegenc->idct_method;
586 jpeg_set_quality (&jpegenc->cinfo, jpegenc->quality, TRUE);
587 jpeg_start_compress (&jpegenc->cinfo, TRUE);
589 GST_LOG_OBJECT (jpegenc, "compressing");
591 if (jpegenc->planar) {
592 for (i = 0; i < height; i += jpegenc->v_max_samp * DCTSIZE) {
593 for (k = 0; k < jpegenc->channels; k++) {
594 for (j = 0; j < jpegenc->v_samp[k] * DCTSIZE; j++) {
595 jpegenc->line[k][j] = base[k];
596 if (base[k] + stride[k] < end[k])
597 base[k] += stride[k];
600 jpeg_write_raw_data (&jpegenc->cinfo, jpegenc->line,
601 jpegenc->v_max_samp * DCTSIZE);
604 for (i = 0; i < height; i += jpegenc->v_max_samp * DCTSIZE) {
605 for (k = 0; k < jpegenc->channels; k++) {
606 for (j = 0; j < jpegenc->v_samp[k] * DCTSIZE; j++) {
610 /* ouch, copy line */
612 dst = jpegenc->line[k][j];
613 for (l = jpegenc->cwidth[k]; l > 0; l--) {
615 src += jpegenc->inc[k];
618 if (base[k] + stride[k] < end[k])
619 base[k] += stride[k];
622 jpeg_write_raw_data (&jpegenc->cinfo, jpegenc->line,
623 jpegenc->v_max_samp * DCTSIZE);
627 /* This will ensure that gst_jpegenc_term_destination is called */
628 jpeg_finish_compress (&jpegenc->cinfo);
629 GST_LOG_OBJECT (jpegenc, "compressing done");
631 outbuf = gst_buffer_new ();
632 gst_buffer_copy_into (outbuf, buf, GST_BUFFER_COPY_METADATA, 0, -1);
633 gst_buffer_append_memory (outbuf, jpegenc->output_mem);
634 jpegenc->output_mem = NULL;
636 ret = gst_pad_push (jpegenc->srcpad, outbuf);
638 gst_video_frame_unmap (&frame);
639 gst_buffer_unref (buf);
646 GST_WARNING_OBJECT (jpegenc, "no input format set (no caps on buffer)");
647 gst_buffer_unref (buf);
648 return GST_FLOW_NOT_NEGOTIATED;
652 GST_WARNING_OBJECT (jpegenc, "invalid frame received");
653 gst_buffer_unref (buf);
659 gst_jpegenc_set_property (GObject * object, guint prop_id,
660 const GValue * value, GParamSpec * pspec)
662 GstJpegEnc *jpegenc = GST_JPEGENC (object);
664 GST_OBJECT_LOCK (jpegenc);
668 jpegenc->quality = g_value_get_int (value);
670 #ifdef ENABLE_SMOOTHING
672 jpegenc->smoothing = g_value_get_int (value);
675 case PROP_IDCT_METHOD:
676 jpegenc->idct_method = g_value_get_enum (value);
679 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
683 GST_OBJECT_UNLOCK (jpegenc);
687 gst_jpegenc_get_property (GObject * object, guint prop_id, GValue * value,
690 GstJpegEnc *jpegenc = GST_JPEGENC (object);
692 GST_OBJECT_LOCK (jpegenc);
696 g_value_set_int (value, jpegenc->quality);
698 #ifdef ENABLE_SMOOTHING
700 g_value_set_int (value, jpegenc->smoothing);
703 case PROP_IDCT_METHOD:
704 g_value_set_enum (value, jpegenc->idct_method);
707 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
711 GST_OBJECT_UNLOCK (jpegenc);
714 static GstStateChangeReturn
715 gst_jpegenc_change_state (GstElement * element, GstStateChange transition)
717 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
718 GstJpegEnc *filter = GST_JPEGENC (element);
720 switch (transition) {
721 case GST_STATE_CHANGE_NULL_TO_READY:
722 GST_DEBUG_OBJECT (element, "setting line buffers");
723 filter->line[0] = NULL;
724 filter->line[1] = NULL;
725 filter->line[2] = NULL;
731 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
732 if (ret == GST_STATE_CHANGE_FAILURE)
735 switch (transition) {
736 case GST_STATE_CHANGE_PAUSED_TO_READY:
737 gst_jpegenc_reset (filter);