filter_crop.o \
filter_data_feed.o \
filter_data_show.o \
+ filter_fieldorder.o \
filter_gamma.o \
filter_greyscale.o \
filter_imageconvert.o \
extern mlt_filter filter_crop_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
extern mlt_filter filter_data_feed_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
extern mlt_filter filter_data_show_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
+extern mlt_filter filter_fieldorder_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
extern mlt_filter filter_gamma_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
extern mlt_filter filter_greyscale_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
extern mlt_filter filter_imageconvert_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
MLT_REGISTER( filter_type, "crop", filter_crop_init );
MLT_REGISTER( filter_type, "data_feed", filter_data_feed_init );
MLT_REGISTER( filter_type, "data_show", filter_data_show_init );
+ MLT_REGISTER( filter_type, "fieldorder", filter_fieldorder_init );
MLT_REGISTER( filter_type, "gamma", filter_gamma_init );
MLT_REGISTER( filter_type, "greyscale", filter_greyscale_init );
MLT_REGISTER( filter_type, "grayscale", filter_greyscale_init );
MLT_REGISTER_METADATA( filter_type, "channelswap", metadata, "filter_channelcopy.yml" );
MLT_REGISTER_METADATA( filter_type, "crop", metadata, "filter_crop.yml" );
MLT_REGISTER_METADATA( filter_type, "data_show", metadata, "filter_data_show.yml" );
+ MLT_REGISTER_METADATA( filter_type, "fieldorder", metadata, "filter_fieldorder.yml" );
MLT_REGISTER_METADATA( filter_type, "gamma", metadata, "filter_gamma.yml" );
MLT_REGISTER_METADATA( filter_type, "greyscale", metadata, "filter_greyscale.yml" );
MLT_REGISTER_METADATA( filter_type, "grayscale", metadata, "filter_greyscale.yml" );
--- /dev/null
+/*
+ * filter_fieldorder.c -- change field dominance
+ * Copyright (C) 2011 Ushodaya Enterprises Limited
+ * Author: Dan Dennedy <dan@dennedy.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <framework/mlt.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+ // Get the properties from the frame
+ mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
+
+ int error = mlt_frame_get_image( frame, image, format, width, height, writable );
+
+ if ( !error && *image )
+ {
+ int bpp;
+ int size = mlt_image_format_size( *format, *width, *height, &bpp );
+ int tff = mlt_properties_get_int( properties, "consumer_tff" );
+
+ // Provides a manual override for misreported field order
+ if ( mlt_properties_get( properties, "meta.top_field_first" ) )
+ mlt_properties_set_int( properties, "top_field_first", mlt_properties_get_int( properties, "meta.top_field_first" ) );
+
+ // Correct field order if needed
+ if ( mlt_properties_get_int( properties, "top_field_first" ) != tff &&
+ mlt_properties_get( properties, "progressive" ) &&
+ mlt_properties_get_int( properties, "progressive" ) == 0 )
+ {
+ // Get the input image, width and height
+ uint8_t *new_image = mlt_pool_alloc( size );
+ uint8_t *ptr = new_image + *width * bpp;
+ memcpy( new_image, *image, *width * bpp );
+ memcpy( ptr, *image, *width * ( *height - 1 ) * bpp );
+ mlt_frame_set_image( frame, new_image, size, mlt_pool_release );
+ *image = new_image;
+
+ // Set the normalised field order
+ mlt_properties_set_int( properties, "top_field_first", tff );
+ mlt_properties_set_int( properties, "meta.top_field_first", tff );
+ }
+ }
+
+ return error;
+}
+
+static mlt_frame process( mlt_filter filter, mlt_frame frame )
+{
+ mlt_frame_push_get_image( frame, get_image );
+ return frame;
+}
+
+mlt_filter filter_fieldorder_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
+{
+ mlt_filter filter = calloc( 1, sizeof( *filter ) );
+ if ( mlt_filter_init( filter, NULL ) == 0 )
+ {
+ filter->process = process;
+ }
+ return filter;
+}
--- /dev/null
+schema_version: 0.1
+type: filter
+identifier: fieldorder
+title: Field order
+description: Correct the field order of interlaced video.
+version: 1
+copyright: Ushodaya Enterprises Limited
+creator: Dan Dennedy <dan@dennedy.org>
+license: LGPLv2.1
+language: en
+tags:
+ - Video
+ - Hidden
+notes: >
+ This filter is automatically invoked by the loader as part of image
+ normalisation.
+parameters:
+ - identifier: argument
+ title: Scale
+ type: string
+ description: The scaling method.
+ required: no
+ readonly: no
#include <stdlib.h>
#include <math.h>
-/** Swapbytes inline.
-*/
-
-static inline void swap_bytes( uint8_t *upper, uint8_t *lower )
-{
- uint8_t t = *lower;
- *lower = *upper;
- *upper = t;
-}
-
static uint8_t *resize_alpha( uint8_t *input, int owidth, int oheight, int iwidth, int iheight, uint8_t alpha_value )
{
uint8_t *output = NULL;
if ( error == 0 && *image )
{
- // Get the requested scale operation
- char *op = mlt_properties_get( MLT_FILTER_PROPERTIES( filter ), "scale" );
int bpp;
- int size = mlt_image_format_size( *format, owidth, oheight, &bpp );
- int tff = mlt_properties_get_int( properties, "consumer_tff" );
-
- // Provides a manual override for misreported field order
- if ( mlt_properties_get( properties, "meta.top_field_first" ) )
- mlt_properties_set_int( properties, "top_field_first", mlt_properties_get_int( properties, "meta.top_field_first" ) );
-
- // Correct field order if needed
- if ( mlt_properties_get_int( properties, "top_field_first" ) != tff &&
- mlt_properties_get( properties, "progressive" ) &&
- mlt_properties_get_int( properties, "progressive" ) == 0 )
- {
- // Get the input image, width and height
- uint8_t *new_image = mlt_pool_alloc( size );
- uint8_t *ptr = new_image + owidth * bpp;
- memcpy( new_image, *image, owidth * bpp );
- memcpy( ptr, *image, owidth * ( oheight - 1 ) * bpp );
- mlt_frame_set_image( this, new_image, size, mlt_pool_release );
- *image = new_image;
-
- // Set the normalised field order
- mlt_properties_set_int( properties, "top_field_first", tff );
- mlt_properties_set_int( properties, "meta.top_field_first", tff );
- }
-
- if ( !strcmp( op, "affine" ) )
- {
- // TODO: Determine where this is needed and find a different way
- // *image = mlt_frame_rescale_image( this, *width, *height, bpp );
- }
- else if ( strcmp( op, "none" ) != 0 )
- {
- *image = frame_resize_image( this, *width, *height, bpp );
- }
- else
- {
- *width = owidth;
- *height = oheight;
- }
+ mlt_image_format_size( *format, owidth, oheight, &bpp );
+ *image = frame_resize_image( this, *width, *height, bpp );
}
return error;
if ( mlt_filter_init( this, this ) == 0 )
{
this->process = filter_process;
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "scale", arg == NULL ? "off" : arg );
}
return this;
}
schema_version: 0.1
type: filter
identifier: resize
-title: Resize
-version: 1
+title: Pad
+version: 2
copyright: Ushodaya Enterprises Limited
creator: Charles Yates <charles.yates@pandora.be>
license: LGPLv2.1
tags:
- Video
- Hidden
-description: >
- Image scaling and padding and field order adjustment.
+description: Pad an image with black to fulfill the requested image size.
notes: >
Normally resize is used to pad the producer's output to what the consumer has
requested after an upstream rescale filter first scales the image to maximise
- usage of the image area. This filter also adjusts the field order to lower
- field first if the frame property "top_field_first" has been set to 1.
- Therefore, when done, it sets the top_field_first to 0. This filter is
- automatically invoked by the loader as part of image sample aspect ratio
- normalisation.
-bugs:
- - Assumes lower field first output.
-parameters:
- - identifier: argument
- title: Scale
- type: string
- description: The scaling method.
- values:
- - affine
- required: no
- readonly: no
+ usage of the image area. This filter is automatically invoked by the loader
+ as part of image normalisation.
crop=crop:1
deinterlace=deinterlace,avdeinterlace
rescaler=swscale,gtkrescale,rescale
+fieldorder=fieldorder
resizer=resize
# audio filters