gmyth-stream/gmemcoder/src/gmencoder.c
branchtrunk
changeset 778 d32867e8767b
parent 772 47de5c5976bf
child 780 7feaeeed26d5
     1.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c	Tue Jul 03 22:45:24 2007 +0100
     1.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c	Wed Jul 04 15:03:53 2007 +0100
     1.3 @@ -75,7 +75,8 @@
     1.4  static GstElement *_create_video_bin(const gchar * encode,
     1.5                                       gchar ** encode_prop,
     1.6                                       gdouble fps,
     1.7 -                                     gint rate, guint width, guint height);
     1.8 +                                     gint rate, guint width, guint height,
     1.9 +                                     gboolean use_deinterlace);
    1.10  
    1.11  static          gboolean
    1.12  _pipeline_bus_cb(GstBus * bus, GstMessage * msg, gpointer user_data);
    1.13 @@ -103,7 +104,8 @@
    1.14                                      guint video_height,
    1.15                                      const gchar * audio_encode,
    1.16                                      gchar ** audio_encode_prop,
    1.17 -                                    guint audio_rate);
    1.18 +                                    guint audio_rate,
    1.19 +				    gboolean deinterlace);
    1.20  #ifdef USE_MANUAL_SINK
    1.21  static void _flush_queue 	    (GMencoder *self);
    1.22  static void _buffer_arrive_cb       (GstElement* object,
    1.23 @@ -240,7 +242,8 @@
    1.24          g_value_set_float(&p, (float) atof (prop_val));
    1.25          break;
    1.26      default:
    1.27 -        g_warning ("Property %s of type %s. Not supported", 
    1.28 +        g_value_set_enum(&p, atoi(prop_val));
    1.29 +        g_warning ("Property %s of type %s. Not supported using default enum", 
    1.30                     prop_name, g_type_name (s->value_type));
    1.31          return;
    1.32      }
    1.33 @@ -357,7 +360,8 @@
    1.34  static GstElement *
    1.35  _create_video_bin(const gchar * encode,
    1.36                    gchar ** encode_prop,
    1.37 -                  gdouble fps, gint rate, guint width, guint height)
    1.38 +                  gdouble fps, gint rate, guint width, guint height,
    1.39 +                  gboolean use_deinterlace)
    1.40  {
    1.41      GstElement     *vbin = NULL;
    1.42      GstElement     *vqueue = NULL;
    1.43 @@ -365,6 +369,8 @@
    1.44      GstElement     *vcolorspace = NULL;
    1.45      GstElement     *vencode = NULL;
    1.46      GstElement     *vrate = NULL;
    1.47 +    GstElement 	   *deinterlace = NULL;
    1.48 +    GstElement     *walk = NULL;
    1.49      GstPad         *vpad = NULL;
    1.50  
    1.51      vbin = gst_bin_new("vbin");
    1.52 @@ -372,6 +378,14 @@
    1.53      vcolorspace =
    1.54          gst_element_factory_make("ffmpegcolorspace", "colorspace");
    1.55  
    1.56 +    if (use_deinterlace) {
    1.57 +	deinterlace = gst_element_factory_make ("ffdeinterlace", "deinterlace");
    1.58 +	if (deinterlace == NULL) {
    1.59 +	    g_warning ("Fail to create deinterlace element: Continue without deinterlace.");
    1.60 +	} 
    1.61 +    }
    1.62 +
    1.63 +
    1.64      vencode = _create_element_with_prop((encode !=
    1.65                                           NULL ? encode :
    1.66                                           "ffenc_mpeg1video"), "vencode",
    1.67 @@ -387,19 +401,29 @@
    1.68      gst_bin_add_many(GST_BIN(vbin), vqueue, vcolorspace, vencode,
    1.69                       vqueue_src, NULL);
    1.70  
    1.71 +    if (deinterlace != NULL) {
    1.72 +        gst_bin_add(GST_BIN(vbin), deinterlace);
    1.73 +        gst_element_link (vqueue, deinterlace);
    1.74 +        walk = deinterlace;
    1.75 +    } else {
    1.76 +        walk = vqueue;
    1.77 +    }
    1.78 +
    1.79      if ((width > 0) && (height > 0)) {
    1.80          // Scalling video
    1.81          GstCaps        *vcaps;
    1.82          GstElement     *vscale =
    1.83              gst_element_factory_make("videoscale", "vscale");
    1.84  
    1.85 +	g_object_set (G_OBJECT (vscale), "method", 1, NULL);
    1.86 +
    1.87          gst_bin_add(GST_BIN(vbin), vscale);
    1.88  
    1.89          vcaps = gst_caps_new_simple("video/x-raw-yuv",
    1.90                                      "width", G_TYPE_INT, width,
    1.91                                      "height", G_TYPE_INT, height, NULL);
    1.92  
    1.93 -        gst_element_link(vqueue, vscale);
    1.94 +        gst_element_link(walk, vscale);
    1.95  
    1.96          if (gst_element_link_filtered(vscale, vcolorspace, vcaps) == FALSE) {
    1.97              g_warning("Fail to resize video");
    1.98 @@ -409,7 +433,7 @@
    1.99          }
   1.100          gst_caps_unref(vcaps);
   1.101      } else {
   1.102 -        gst_element_link(vqueue, vcolorspace);
   1.103 +        gst_element_link(walk, vcolorspace);
   1.104      }
   1.105  
   1.106      if (fps > 0) {
   1.107 @@ -480,6 +504,7 @@
   1.108  gboolean 
   1.109  g_mencoder_setup_stream(GMencoder * self,
   1.110  			gboolean chunked,
   1.111 +			gboolean deinterlace,
   1.112                          const gchar * mux_name,
   1.113                          const gchar * video_encode,
   1.114                          gchar ** video_encode_prop,
   1.115 @@ -513,7 +538,8 @@
   1.116                                    video_width,
   1.117                                    video_height,
   1.118                                    audio_encode, audio_encode_prop,
   1.119 -                                  audio_rate);
   1.120 +                                  audio_rate,
   1.121 +                                  deinterlace);
   1.122  
   1.123      return (priv->pipe != NULL);
   1.124  }
   1.125 @@ -674,7 +700,8 @@
   1.126                   guint video_width,
   1.127                   guint video_height,
   1.128                   const gchar * audio_encode,
   1.129 -                 gchar ** audio_encode_prop, guint audio_rate)
   1.130 +                 gchar ** audio_encode_prop, guint audio_rate,
   1.131 +	     	 gboolean deinterlace)
   1.132  {
   1.133      GstBus         *bus = NULL;
   1.134      GstElement     *pipe = NULL;
   1.135 @@ -729,7 +756,7 @@
   1.136  
   1.137      vbin =
   1.138          _create_video_bin(video_encode, video_encode_prop, video_fps,
   1.139 -                          video_rate, video_width, video_height);
   1.140 +                          video_rate, video_width, video_height, deinterlace);
   1.141      if (vbin == NULL)
   1.142          goto error;
   1.143