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