gst_plugins_base/gst/videoscale/gstvideoscale.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    20 
    20 
    21 /**
    21 /**
    22  * SECTION:element-videoscale
    22  * SECTION:element-videoscale
    23  * @see_also: videorate, ffmpegcolorspace
    23  * @see_also: videorate, ffmpegcolorspace
    24  *
    24  *
       
    25  * <refsect2>
       
    26  * <para>
    25  * This element resizes video frames. By default the element will try to
    27  * This element resizes video frames. By default the element will try to
    26  * negotiate to the same size on the source and sinkpad so that no scaling
    28  * negotiate to the same size on the source and sinkpad so that no scaling
    27  * is needed. It is therefore safe to insert this element in a pipeline to
    29  * is needed. It is therefore safe to insert this element in a pipeline to
    28  * get more robust behaviour without any cost if no scaling is needed.
    30  * get more robust behaviour without any cost if no scaling is needed.
    29  *
    31  * </para>
       
    32  * <para>
    30  * This element supports a wide range of color spaces including various YUV and
    33  * This element supports a wide range of color spaces including various YUV and
    31  * RGB formats and is therefore generally able to operate anywhere in a
    34  * RGB formats and is therefore generally able to operate anywhere in a
    32  * pipeline.
    35  * pipeline.
    33  *
    36  * </para>
    34  * <refsect2>
       
    35  * <title>Example pipelines</title>
    37  * <title>Example pipelines</title>
    36  * |[
    38  * <para>
       
    39  * <programlisting>
    37  * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! ffmpegcolorspace ! videoscale ! ximagesink
    40  * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! ffmpegcolorspace ! videoscale ! ximagesink
    38  * ]| Decode an Ogg/Theora and display the video using ximagesink. Since
    41  * </programlisting>
       
    42  * Decode an Ogg/Theora and display the video using ximagesink. Since
    39  * ximagesink cannot perform scaling, the video scaling will be performed by
    43  * ximagesink cannot perform scaling, the video scaling will be performed by
    40  * videoscale when you resize the video window.
    44  * videoscale when you resize the video window.
    41  * To create the test Ogg/Theora file refer to the documentation of theoraenc.
    45  * To create the test Ogg/Theora file refer to the documentation of theoraenc.
    42  * |[
    46  * </para>
       
    47  * <para>
       
    48  * <programlisting>
    43  * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw-yuv, width=50 ! xvimagesink
    49  * gst-launch -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoscale ! video/x-raw-yuv, width=50 ! xvimagesink
    44  * ]| Decode an Ogg/Theora and display the video using xvimagesink with a width
    50  * </programlisting>
    45  * of 50.
    51  * Decode an Ogg/Theora and display the video using xvimagesink with a width of
       
    52  * 50.
       
    53  * </para>
    46  * </refsect2>
    54  * </refsect2>
    47  *
    55  *
    48  * Last reviewed on 2006-03-02 (0.10.4)
    56  * Last reviewed on 2006-03-02 (0.10.4)
    49  */
    57  */
    50 
    58 
    53 #endif
    61 #endif
    54 
    62 
    55 #include <string.h>
    63 #include <string.h>
    56 
    64 
    57 #include <gst/video/video.h>
    65 #include <gst/video/video.h>
    58 #include <liboil/liboil.h>
    66 #include <gst/liboil.h>
    59 
    67 
    60 #ifdef __SYMBIAN32__
       
    61 #include <liboil/globals.h>
       
    62 #endif
       
    63 
    68 
    64 #include "gstvideoscale.h"
    69 #include "gstvideoscale.h"
    65 #include "vs_image.h"
    70 #include "vs_image.h"
    66 #include "vs_4tap.h"
    71 #include "vs_4tap.h"
       
    72 
       
    73 #include <glib_global.h>
    67 
    74 
    68 
    75 
    69 /* debug variable definition */
    76 /* debug variable definition */
    70 GST_DEBUG_CATEGORY (video_scale_debug);
    77 GST_DEBUG_CATEGORY (video_scale_debug);
    71 
    78 
    74 GST_ELEMENT_DETAILS ("Video scaler",
    81 GST_ELEMENT_DETAILS ("Video scaler",
    75     "Filter/Effect/Video",
    82     "Filter/Effect/Video",
    76     "Resizes video",
    83     "Resizes video",
    77     "Wim Taymans <wim.taymans@chello.be>");
    84     "Wim Taymans <wim.taymans@chello.be>");
    78 
    85 
    79 #define DEFAULT_PROP_METHOD	GST_VIDEO_SCALE_BILINEAR
    86 #define DEFAULT_PROP_METHOD	GST_VIDEO_SCALE_NEAREST
    80 
    87 
    81 enum
    88 enum
    82 {
    89 {
    83   PROP_0,
    90   PROP_0,
    84   PROP_METHOD
    91   PROP_METHOD
    85       /* FILL ME */
    92       /* FILL ME */
    86 };
    93 };
       
    94 
       
    95 /* can't handle width/height of 1 yet, since we divide a lot by (n-1) */
       
    96 #undef GST_VIDEO_SIZE_RANGE
       
    97 #define GST_VIDEO_SIZE_RANGE "(int) [ 2, MAX ]"
    87 
    98 
    88 static GstStaticCaps gst_video_scale_format_caps[] = {
    99 static GstStaticCaps gst_video_scale_format_caps[] = {
    89   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx),
   100   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx),
    90   GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB),
   101   GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB),
    91   GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx),
   102   GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx),
    94   GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB),
   105   GST_STATIC_CAPS (GST_VIDEO_CAPS_ARGB),
    95   GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRA),
   106   GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRA),
    96   GST_STATIC_CAPS (GST_VIDEO_CAPS_ABGR),
   107   GST_STATIC_CAPS (GST_VIDEO_CAPS_ABGR),
    97   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB),
   108   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB),
    98   GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR),
   109   GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR),
    99   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("v308")),
       
   100   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")),
   110   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")),
   101   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2")),
   111   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2")),
   102   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YVYU")),
   112   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YVYU")),
   103   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("UYVY")),
   113   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("UYVY")),
   104   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y800")),
   114   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("Y800")),
   105   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")),
   115   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")),
   106   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12")),
   116   GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12")),
   107   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16),
   117   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16),
   108   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15),
   118   GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15)
   109   GST_STATIC_CAPS ("video/x-raw-gray, "
       
   110       "bpp = 8, "
       
   111       "depth = 8, "
       
   112       "width = " GST_VIDEO_SIZE_RANGE ", "
       
   113       "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE),
       
   114   GST_STATIC_CAPS ("video/x-raw-gray, "
       
   115       "bpp = 16, "
       
   116       "depth = 16, "
       
   117       "endianness = BYTE_ORDER, "
       
   118       "width = " GST_VIDEO_SIZE_RANGE ", "
       
   119       "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE)
       
   120 };
   119 };
   121 
   120 
   122 enum
   121 enum
   123 {
   122 {
   124   GST_VIDEO_SCALE_RGBx = 0,
   123   GST_VIDEO_SCALE_RGBx = 0,
   129   GST_VIDEO_SCALE_ARGB,
   128   GST_VIDEO_SCALE_ARGB,
   130   GST_VIDEO_SCALE_BGRA,
   129   GST_VIDEO_SCALE_BGRA,
   131   GST_VIDEO_SCALE_ABGR,
   130   GST_VIDEO_SCALE_ABGR,
   132   GST_VIDEO_SCALE_RGB,
   131   GST_VIDEO_SCALE_RGB,
   133   GST_VIDEO_SCALE_BGR,
   132   GST_VIDEO_SCALE_BGR,
   134   GST_VIDEO_SCALE_v308,
       
   135   GST_VIDEO_SCALE_AYUV,
   133   GST_VIDEO_SCALE_AYUV,
   136   GST_VIDEO_SCALE_YUY2,
   134   GST_VIDEO_SCALE_YUY2,
   137   GST_VIDEO_SCALE_YVYU,
   135   GST_VIDEO_SCALE_YVYU,
   138   GST_VIDEO_SCALE_UYVY,
   136   GST_VIDEO_SCALE_UYVY,
   139   GST_VIDEO_SCALE_Y,
   137   GST_VIDEO_SCALE_Y,
   140   GST_VIDEO_SCALE_I420,
   138   GST_VIDEO_SCALE_I420,
   141   GST_VIDEO_SCALE_YV12,
   139   GST_VIDEO_SCALE_YV12,
   142   GST_VIDEO_SCALE_RGB565,
   140   GST_VIDEO_SCALE_RGB565,
   143   GST_VIDEO_SCALE_RGB555,
   141   GST_VIDEO_SCALE_RGB555
   144   GST_VIDEO_SCALE_GRAY8,
       
   145   GST_VIDEO_SCALE_GRAY16
       
   146 };
   142 };
   147 
   143 
   148 #define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type())
   144 #define GST_TYPE_VIDEO_SCALE_METHOD (gst_video_scale_method_get_type())
   149 static GType
   145 static GType
   150 gst_video_scale_method_get_type (void)
   146 gst_video_scale_method_get_type (void)
   151 {
   147 {
   152   static GType video_scale_method_type = 0;
   148   static GType video_scale_method_type = 0;
   153 
       
   154   static const GEnumValue video_scale_methods[] = {
   149   static const GEnumValue video_scale_methods[] = {
   155     {GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
   150     {GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
   156     {GST_VIDEO_SCALE_BILINEAR, "Bilinear", "bilinear"},
   151     {GST_VIDEO_SCALE_BILINEAR, "Bilinear", "bilinear"},
   157     {GST_VIDEO_SCALE_4TAP, "4-tap", "4-tap"},
   152     {GST_VIDEO_SCALE_4TAP, "4-tap", "4-tap"},
   158     {0, NULL, NULL},
   153     {0, NULL, NULL},
   197       gst_caps_ref (gst_video_scale_get_capslist ()));
   192       gst_caps_ref (gst_video_scale_get_capslist ()));
   198 }
   193 }
   199 
   194 
   200 
   195 
   201 static void gst_video_scale_base_init (gpointer g_class);
   196 static void gst_video_scale_base_init (gpointer g_class);
   202 
       
   203 static void gst_video_scale_class_init (GstVideoScaleClass * klass);
   197 static void gst_video_scale_class_init (GstVideoScaleClass * klass);
   204 
       
   205 static void gst_video_scale_init (GstVideoScale * videoscale);
   198 static void gst_video_scale_init (GstVideoScale * videoscale);
   206 
       
   207 static void gst_video_scale_finalize (GstVideoScale * videoscale);
   199 static void gst_video_scale_finalize (GstVideoScale * videoscale);
   208 
       
   209 static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
   200 static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
   210     GstEvent * event);
   201     GstEvent * event);
   211 
   202 
   212 /* base transform vmethods */
   203 /* base transform vmethods */
   213 static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
   204 static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
   284   gobject_class->set_property = gst_video_scale_set_property;
   275   gobject_class->set_property = gst_video_scale_set_property;
   285   gobject_class->get_property = gst_video_scale_get_property;
   276   gobject_class->get_property = gst_video_scale_get_property;
   286 
   277 
   287   g_object_class_install_property (gobject_class, PROP_METHOD,
   278   g_object_class_install_property (gobject_class, PROP_METHOD,
   288       g_param_spec_enum ("method", "method", "method",
   279       g_param_spec_enum ("method", "method", "method",
   289           GST_TYPE_VIDEO_SCALE_METHOD, DEFAULT_PROP_METHOD,
   280           GST_TYPE_VIDEO_SCALE_METHOD, DEFAULT_PROP_METHOD, G_PARAM_READWRITE));
   290           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   291 
   281 
   292   trans_class->transform_caps =
   282   trans_class->transform_caps =
   293       GST_DEBUG_FUNCPTR (gst_video_scale_transform_caps);
   283       GST_DEBUG_FUNCPTR (gst_video_scale_transform_caps);
   294   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_scale_set_caps);
   284   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_scale_set_caps);
   295   trans_class->get_unit_size =
   285   trans_class->get_unit_size =
   375   method = videoscale->method;
   365   method = videoscale->method;
   376   GST_OBJECT_UNLOCK (videoscale);
   366   GST_OBJECT_UNLOCK (videoscale);
   377 
   367 
   378   structure = gst_caps_get_structure (caps, 0);
   368   structure = gst_caps_get_structure (caps, 0);
   379 
   369 
       
   370   /* check compatibility of format and method before we copy the input caps */
       
   371   if (method == GST_VIDEO_SCALE_4TAP) {
       
   372     guint32 fourcc;
       
   373 
       
   374     if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
       
   375       goto method_not_implemented_for_format;
       
   376     if (!gst_structure_get_fourcc (structure, "format", &fourcc))
       
   377       goto method_not_implemented_for_format;
       
   378     if (fourcc != GST_MAKE_FOURCC ('I', '4', '2', '0') &&
       
   379         fourcc != GST_MAKE_FOURCC ('Y', 'V', '1', '2'))
       
   380       goto method_not_implemented_for_format;
       
   381   }
       
   382 
   380   ret = gst_caps_copy (caps);
   383   ret = gst_caps_copy (caps);
   381   structure = gst_structure_copy (gst_caps_get_structure (ret, 0));
   384   structure = gst_caps_get_structure (ret, 0);
   382 
   385 
   383   gst_structure_set (structure,
   386   gst_structure_set (structure,
   384       "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
   387       "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
   385       "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
   388       "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
   386 
   389 
   387   gst_caps_merge_structure (ret, gst_structure_copy (structure));
       
   388 
       
   389   /* if pixel aspect ratio, make a range of it */
   390   /* if pixel aspect ratio, make a range of it */
   390   if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
   391   if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
   391     gst_structure_set (structure,
   392     GstCaps *copy;
       
   393     GstStructure *cstruct;
       
   394 
       
   395     /* copy input PAR first, this is the prefered PAR */
       
   396     gst_structure_set_value (structure, "pixel-aspect-ratio", par);
       
   397 
       
   398     /* then make a copy with a fraction range as a second choice */
       
   399     copy = gst_caps_copy (ret);
       
   400     cstruct = gst_caps_get_structure (copy, 0);
       
   401     gst_structure_set (cstruct,
   392         "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
   402         "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
   393 
   403 
   394     gst_caps_merge_structure (ret, structure);
   404     /* and append */
   395   } else {
   405     gst_caps_append (ret, copy);
   396     gst_structure_free (structure);
       
   397   }
   406   }
   398 
   407 
   399   GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
   408   GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
   400 
   409 
   401   return ret;
   410   return ret;
       
   411 
       
   412 method_not_implemented_for_format:
       
   413   {
       
   414     GST_DEBUG_OBJECT (trans, "method %d not implemented for format %"
       
   415         GST_PTR_FORMAT ", returning empty caps", method, caps);
       
   416     return gst_caps_new_empty ();
       
   417   }
   402 }
   418 }
   403 
   419 
   404 static int
   420 static int
   405 gst_video_scale_get_format (GstCaps * caps)
   421 gst_video_scale_get_format (GstCaps * caps)
   406 {
   422 {
   443       img->stride = img->width * 4;
   459       img->stride = img->width * 4;
   444       *size = img->stride * img->height;
   460       *size = img->stride * img->height;
   445       break;
   461       break;
   446     case GST_VIDEO_SCALE_RGB:
   462     case GST_VIDEO_SCALE_RGB:
   447     case GST_VIDEO_SCALE_BGR:
   463     case GST_VIDEO_SCALE_BGR:
   448     case GST_VIDEO_SCALE_v308:
       
   449       img->stride = GST_ROUND_UP_4 (img->width * 3);
   464       img->stride = GST_ROUND_UP_4 (img->width * 3);
   450       *size = img->stride * img->height;
   465       *size = img->stride * img->height;
   451       break;
   466       break;
   452     case GST_VIDEO_SCALE_YUY2:
   467     case GST_VIDEO_SCALE_YUY2:
   453     case GST_VIDEO_SCALE_YVYU:
   468     case GST_VIDEO_SCALE_YVYU:
   454     case GST_VIDEO_SCALE_UYVY:
   469     case GST_VIDEO_SCALE_UYVY:
   455       img->stride = GST_ROUND_UP_4 (img->width * 2);
   470       img->stride = GST_ROUND_UP_4 (img->width * 2);
   456       *size = img->stride * img->height;
   471       *size = img->stride * img->height;
   457       break;
   472       break;
   458     case GST_VIDEO_SCALE_Y:
   473     case GST_VIDEO_SCALE_Y:
   459     case GST_VIDEO_SCALE_GRAY8:
       
   460       img->stride = GST_ROUND_UP_4 (img->width);
   474       img->stride = GST_ROUND_UP_4 (img->width);
   461       *size = img->stride * img->height;
       
   462       break;
       
   463     case GST_VIDEO_SCALE_GRAY16:
       
   464       img->stride = GST_ROUND_UP_4 (img->width * 2);
       
   465       *size = img->stride * img->height;
   475       *size = img->stride * img->height;
   466       break;
   476       break;
   467     case GST_VIDEO_SCALE_I420:
   477     case GST_VIDEO_SCALE_I420:
   468     case GST_VIDEO_SCALE_YV12:
   478     case GST_VIDEO_SCALE_YV12:
   469     {
   479     {
   598   to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
   608   to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
   599 
   609 
   600   /* we have both PAR but they might not be fixated */
   610   /* we have both PAR but they might not be fixated */
   601   if (from_par && to_par) {
   611   if (from_par && to_par) {
   602     gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
   612     gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
   603 
       
   604     gint count = 0, w = 0, h = 0;
   613     gint count = 0, w = 0, h = 0;
   605 
       
   606     guint num, den;
   614     guint num, den;
   607 
   615 
   608     /* from_par should be fixed */
   616     /* from_par should be fixed */
   609     g_return_if_fail (gst_value_is_fixed (from_par));
   617     g_return_if_fail (gst_value_is_fixed (from_par));
   610 
   618 
   751 
   759 
   752   gst_video_scale_prepare_image (videoscale->format, in, src, &src_u, &src_v);
   760   gst_video_scale_prepare_image (videoscale->format, in, src, &src_u, &src_v);
   753   gst_video_scale_prepare_image (videoscale->format, out, dest, &dest_u,
   761   gst_video_scale_prepare_image (videoscale->format, out, dest, &dest_u,
   754       &dest_v);
   762       &dest_v);
   755 
   763 
   756   if (src->height < 4 && method == GST_VIDEO_SCALE_4TAP)
       
   757     method = GST_VIDEO_SCALE_BILINEAR;
       
   758 
       
   759   switch (method) {
   764   switch (method) {
   760     case GST_VIDEO_SCALE_NEAREST:
   765     case GST_VIDEO_SCALE_NEAREST:
   761       GST_LOG_OBJECT (videoscale, "doing nearest scaling");
       
   762       switch (videoscale->format) {
   766       switch (videoscale->format) {
   763         case GST_VIDEO_SCALE_RGBx:
   767         case GST_VIDEO_SCALE_RGBx:
   764         case GST_VIDEO_SCALE_xRGB:
   768         case GST_VIDEO_SCALE_xRGB:
   765         case GST_VIDEO_SCALE_BGRx:
   769         case GST_VIDEO_SCALE_BGRx:
   766         case GST_VIDEO_SCALE_xBGR:
   770         case GST_VIDEO_SCALE_xBGR:
   771         case GST_VIDEO_SCALE_AYUV:
   775         case GST_VIDEO_SCALE_AYUV:
   772           vs_image_scale_nearest_RGBA (dest, src, videoscale->tmp_buf);
   776           vs_image_scale_nearest_RGBA (dest, src, videoscale->tmp_buf);
   773           break;
   777           break;
   774         case GST_VIDEO_SCALE_RGB:
   778         case GST_VIDEO_SCALE_RGB:
   775         case GST_VIDEO_SCALE_BGR:
   779         case GST_VIDEO_SCALE_BGR:
   776         case GST_VIDEO_SCALE_v308:
       
   777           vs_image_scale_nearest_RGB (dest, src, videoscale->tmp_buf);
   780           vs_image_scale_nearest_RGB (dest, src, videoscale->tmp_buf);
   778           break;
   781           break;
   779         case GST_VIDEO_SCALE_YUY2:
   782         case GST_VIDEO_SCALE_YUY2:
   780         case GST_VIDEO_SCALE_YVYU:
   783         case GST_VIDEO_SCALE_YVYU:
   781           vs_image_scale_nearest_YUYV (dest, src, videoscale->tmp_buf);
   784           vs_image_scale_nearest_YUYV (dest, src, videoscale->tmp_buf);
   782           break;
   785           break;
   783         case GST_VIDEO_SCALE_UYVY:
   786         case GST_VIDEO_SCALE_UYVY:
   784           vs_image_scale_nearest_UYVY (dest, src, videoscale->tmp_buf);
   787           vs_image_scale_nearest_UYVY (dest, src, videoscale->tmp_buf);
   785           break;
   788           break;
   786         case GST_VIDEO_SCALE_Y:
   789         case GST_VIDEO_SCALE_Y:
   787         case GST_VIDEO_SCALE_GRAY8:
       
   788           vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
   790           vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
   789           break;
       
   790         case GST_VIDEO_SCALE_GRAY16:
       
   791           vs_image_scale_nearest_Y16 (dest, src, videoscale->tmp_buf);
       
   792           break;
   791           break;
   793         case GST_VIDEO_SCALE_I420:
   792         case GST_VIDEO_SCALE_I420:
   794         case GST_VIDEO_SCALE_YV12:
   793         case GST_VIDEO_SCALE_YV12:
   795           vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
   794           vs_image_scale_nearest_Y (dest, src, videoscale->tmp_buf);
   796           vs_image_scale_nearest_Y (&dest_u, &src_u, videoscale->tmp_buf);
   795           vs_image_scale_nearest_Y (&dest_u, &src_u, videoscale->tmp_buf);
   805         default:
   804         default:
   806           goto unsupported;
   805           goto unsupported;
   807       }
   806       }
   808       break;
   807       break;
   809     case GST_VIDEO_SCALE_BILINEAR:
   808     case GST_VIDEO_SCALE_BILINEAR:
   810       GST_LOG_OBJECT (videoscale, "doing bilinear scaling");
       
   811       switch (videoscale->format) {
   809       switch (videoscale->format) {
   812         case GST_VIDEO_SCALE_RGBx:
   810         case GST_VIDEO_SCALE_RGBx:
   813         case GST_VIDEO_SCALE_xRGB:
   811         case GST_VIDEO_SCALE_xRGB:
   814         case GST_VIDEO_SCALE_BGRx:
   812         case GST_VIDEO_SCALE_BGRx:
   815         case GST_VIDEO_SCALE_xBGR:
   813         case GST_VIDEO_SCALE_xBGR:
   820         case GST_VIDEO_SCALE_AYUV:
   818         case GST_VIDEO_SCALE_AYUV:
   821           vs_image_scale_linear_RGBA (dest, src, videoscale->tmp_buf);
   819           vs_image_scale_linear_RGBA (dest, src, videoscale->tmp_buf);
   822           break;
   820           break;
   823         case GST_VIDEO_SCALE_RGB:
   821         case GST_VIDEO_SCALE_RGB:
   824         case GST_VIDEO_SCALE_BGR:
   822         case GST_VIDEO_SCALE_BGR:
   825         case GST_VIDEO_SCALE_v308:
       
   826           vs_image_scale_linear_RGB (dest, src, videoscale->tmp_buf);
   823           vs_image_scale_linear_RGB (dest, src, videoscale->tmp_buf);
   827           break;
   824           break;
   828         case GST_VIDEO_SCALE_YUY2:
   825         case GST_VIDEO_SCALE_YUY2:
   829         case GST_VIDEO_SCALE_YVYU:
   826         case GST_VIDEO_SCALE_YVYU:
   830           vs_image_scale_linear_YUYV (dest, src, videoscale->tmp_buf);
   827           vs_image_scale_linear_YUYV (dest, src, videoscale->tmp_buf);
   831           break;
   828           break;
   832         case GST_VIDEO_SCALE_UYVY:
   829         case GST_VIDEO_SCALE_UYVY:
   833           vs_image_scale_linear_UYVY (dest, src, videoscale->tmp_buf);
   830           vs_image_scale_linear_UYVY (dest, src, videoscale->tmp_buf);
   834           break;
   831           break;
   835         case GST_VIDEO_SCALE_Y:
   832         case GST_VIDEO_SCALE_Y:
   836         case GST_VIDEO_SCALE_GRAY8:
       
   837           vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
   833           vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
   838           break;
       
   839         case GST_VIDEO_SCALE_GRAY16:
       
   840           vs_image_scale_linear_Y16 (dest, src, videoscale->tmp_buf);
       
   841           break;
   834           break;
   842         case GST_VIDEO_SCALE_I420:
   835         case GST_VIDEO_SCALE_I420:
   843         case GST_VIDEO_SCALE_YV12:
   836         case GST_VIDEO_SCALE_YV12:
   844           vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
   837           vs_image_scale_linear_Y (dest, src, videoscale->tmp_buf);
   845           vs_image_scale_linear_Y (&dest_u, &src_u, videoscale->tmp_buf);
   838           vs_image_scale_linear_Y (&dest_u, &src_u, videoscale->tmp_buf);
   854         default:
   847         default:
   855           goto unsupported;
   848           goto unsupported;
   856       }
   849       }
   857       break;
   850       break;
   858     case GST_VIDEO_SCALE_4TAP:
   851     case GST_VIDEO_SCALE_4TAP:
   859       GST_LOG_OBJECT (videoscale, "doing 4tap scaling");
       
   860       switch (videoscale->format) {
   852       switch (videoscale->format) {
   861         case GST_VIDEO_SCALE_RGBx:
       
   862         case GST_VIDEO_SCALE_xRGB:
       
   863         case GST_VIDEO_SCALE_BGRx:
       
   864         case GST_VIDEO_SCALE_xBGR:
       
   865         case GST_VIDEO_SCALE_RGBA:
       
   866         case GST_VIDEO_SCALE_ARGB:
       
   867         case GST_VIDEO_SCALE_BGRA:
       
   868         case GST_VIDEO_SCALE_ABGR:
       
   869         case GST_VIDEO_SCALE_AYUV:
       
   870           vs_image_scale_4tap_RGBA (dest, src, videoscale->tmp_buf);
       
   871           break;
       
   872         case GST_VIDEO_SCALE_RGB:
       
   873         case GST_VIDEO_SCALE_BGR:
       
   874         case GST_VIDEO_SCALE_v308:
       
   875           vs_image_scale_4tap_RGB (dest, src, videoscale->tmp_buf);
       
   876           break;
       
   877         case GST_VIDEO_SCALE_YUY2:
       
   878         case GST_VIDEO_SCALE_YVYU:
       
   879           vs_image_scale_4tap_YUYV (dest, src, videoscale->tmp_buf);
       
   880           break;
       
   881         case GST_VIDEO_SCALE_UYVY:
       
   882           vs_image_scale_4tap_UYVY (dest, src, videoscale->tmp_buf);
       
   883           break;
       
   884         case GST_VIDEO_SCALE_Y:
       
   885         case GST_VIDEO_SCALE_GRAY8:
       
   886           vs_image_scale_4tap_Y (dest, src, videoscale->tmp_buf);
       
   887           break;
       
   888         case GST_VIDEO_SCALE_GRAY16:
       
   889           vs_image_scale_4tap_Y16 (dest, src, videoscale->tmp_buf);
       
   890           break;
       
   891         case GST_VIDEO_SCALE_I420:
   853         case GST_VIDEO_SCALE_I420:
   892         case GST_VIDEO_SCALE_YV12:
   854         case GST_VIDEO_SCALE_YV12:
   893           vs_image_scale_4tap_Y (dest, src, videoscale->tmp_buf);
   855           vs_image_scale_4tap_Y (dest, src, videoscale->tmp_buf);
   894           vs_image_scale_4tap_Y (&dest_u, &src_u, videoscale->tmp_buf);
   856           vs_image_scale_4tap_Y (&dest_u, &src_u, videoscale->tmp_buf);
   895           vs_image_scale_4tap_Y (&dest_v, &src_v, videoscale->tmp_buf);
   857           vs_image_scale_4tap_Y (&dest_v, &src_v, videoscale->tmp_buf);
   896           break;
   858           break;
   897         case GST_VIDEO_SCALE_RGB565:
       
   898           vs_image_scale_4tap_RGB565 (dest, src, videoscale->tmp_buf);
       
   899           break;
       
   900         case GST_VIDEO_SCALE_RGB555:
       
   901           vs_image_scale_4tap_RGB555 (dest, src, videoscale->tmp_buf);
       
   902           break;
       
   903         default:
   859         default:
       
   860           /* FIXME: update gst_video_scale_transform_caps once RGB and/or
       
   861            * other YUV formats work too */
   904           goto unsupported;
   862           goto unsupported;
   905       }
   863       }
   906       break;
   864       break;
   907     default:
   865     default:
   908       goto unknown_mode;
   866       goto unknown_mode;
   969 }
   927 }
   970 
   928 
   971 static gboolean
   929 static gboolean
   972 plugin_init (GstPlugin * plugin)
   930 plugin_init (GstPlugin * plugin)
   973 {
   931 {
       
   932 	#ifndef __SYMBIAN32__
   974   oil_init ();
   933   oil_init ();
   975 
   934   #endif
   976   if (!gst_element_register (plugin, "videoscale", GST_RANK_NONE,
   935   if (!gst_element_register (plugin, "videoscale", GST_RANK_NONE,
   977           GST_TYPE_VIDEO_SCALE))
   936           GST_TYPE_VIDEO_SCALE))
   978     return FALSE;
   937     return FALSE;
   979 
   938 
   980   GST_DEBUG_CATEGORY_INIT (video_scale_debug, "videoscale", 0,
   939   GST_DEBUG_CATEGORY_INIT (video_scale_debug, "videoscale", 0,