mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-09 10:59:39 +00:00
c1b100cf9c
When not using the fieldanalysis element immediately upstream of deinterlace, behaviour should remain unchanged. fieldanalysis will set the caps and flags on the buffers such that they can be interpreted and acted upon to produce progressive output. There are two main modes of operation: - Passive pattern locking Passive pattern locking is a non-blocking, low-latency mode of operation that is suitable for close-to-live usage. Initially a telecine stream will be output as variable framerate with naïve timestamp adjustment. With each incoming buffer, an attempt is made to lock onto a pattern. When a lock is obtained, the src pad and output buffer caps will reflect the pattern and timestamps will be accurately interpolated between pattern repeats. This means that initially and at pattern transitions there will be short periods of inaccurate timestamping. - Active pattern locking Active pattern locking is a blocking, high-latency mode of operation that is targeted at use-cases where timestamp accuracy is paramount. Buffers will be queued until enough are present to make a lock. When locked, timestamps will be accurately interpolated between pattern repeats. Orphan fields can be dropped or deinterlaced. If no lock can be obtained, a single field might be pushed through to be deinterlaced. Locking can also be disabled or 'auto' chooses between passive and active locking modes depending on whether upstream is live.
199 lines
5.3 KiB
C
199 lines
5.3 KiB
C
/*
|
|
* GStreamer
|
|
* Copyright (C) 2005 Martin Eikermann <meiker@upb.de>
|
|
* Copyright (C) 2008-2010 Sebastian Dröge <slomo@collabora.co.uk>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 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
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library 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.
|
|
*/
|
|
|
|
#ifndef __GST_DEINTERLACE_H__
|
|
#define __GST_DEINTERLACE_H__
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/video/video.h>
|
|
|
|
#include "gstdeinterlacemethod.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GST_TYPE_DEINTERLACE \
|
|
(gst_deinterlace_get_type())
|
|
#define GST_DEINTERLACE(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DEINTERLACE,GstDeinterlace))
|
|
#define GST_DEINTERLACE_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DEINTERLACE,GstDeinterlace))
|
|
#define GST_IS_DEINTERLACE(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEINTERLACE))
|
|
#define GST_IS_DEINTERLACE_CLASS(obj) \
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEINTERLACE))
|
|
|
|
typedef struct _GstDeinterlace GstDeinterlace;
|
|
typedef struct _GstDeinterlaceClass GstDeinterlaceClass;
|
|
|
|
typedef enum
|
|
{
|
|
GST_DEINTERLACE_TOMSMOCOMP,
|
|
GST_DEINTERLACE_GREEDY_H,
|
|
GST_DEINTERLACE_GREEDY_L,
|
|
GST_DEINTERLACE_VFIR,
|
|
GST_DEINTERLACE_LINEAR,
|
|
GST_DEINTERLACE_LINEAR_BLEND,
|
|
GST_DEINTERLACE_SCALER_BOB,
|
|
GST_DEINTERLACE_WEAVE,
|
|
GST_DEINTERLACE_WEAVE_TFF,
|
|
GST_DEINTERLACE_WEAVE_BFF
|
|
} GstDeinterlaceMethods;
|
|
|
|
typedef enum
|
|
{
|
|
GST_DEINTERLACE_ALL, /* All (missing data is interp.) */
|
|
GST_DEINTERLACE_TF, /* Top Fields Only */
|
|
GST_DEINTERLACE_BF /* Bottom Fields Only */
|
|
} GstDeinterlaceFields;
|
|
|
|
typedef enum
|
|
{
|
|
GST_DEINTERLACE_LAYOUT_AUTO,
|
|
GST_DEINTERLACE_LAYOUT_TFF,
|
|
GST_DEINTERLACE_LAYOUT_BFF
|
|
} GstDeinterlaceFieldLayout;
|
|
|
|
typedef enum {
|
|
GST_DEINTERLACE_MODE_AUTO,
|
|
GST_DEINTERLACE_MODE_INTERLACED,
|
|
GST_DEINTERLACE_MODE_DISABLED
|
|
} GstDeinterlaceMode;
|
|
|
|
typedef enum
|
|
{
|
|
GST_DEINTERLACE_LOCKING_NONE,
|
|
GST_DEINTERLACE_LOCKING_AUTO,
|
|
GST_DEINTERLACE_LOCKING_ACTIVE,
|
|
GST_DEINTERLACE_LOCKING_PASSIVE,
|
|
} GstDeinterlaceLocking;
|
|
|
|
#define GST_DEINTERLACE_MAX_FIELD_HISTORY 10
|
|
#define GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY 50
|
|
/* check max field history is large enough */
|
|
#if GST_DEINTERLACE_MAX_FIELD_HISTORY < GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY * 3
|
|
#undef GST_DEINTERLACE_MAX_FIELD_HISTORY
|
|
#define GST_DEINTERLACE_MAX_FIELD_HISTORY (GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY * 3)
|
|
#endif
|
|
|
|
typedef struct _TelecinePattern TelecinePattern;
|
|
struct _TelecinePattern
|
|
{
|
|
const gchar *nick;
|
|
guint8 length;
|
|
guint8 ratio_n, ratio_d;
|
|
guint8 states[GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY];
|
|
};
|
|
|
|
typedef struct _GstDeinterlaceBufferState GstDeinterlaceBufferState;
|
|
struct _GstDeinterlaceBufferState
|
|
{
|
|
GstClockTime timestamp;
|
|
GstClockTime duration;
|
|
guint8 state;
|
|
};
|
|
|
|
struct _GstDeinterlace
|
|
{
|
|
GstElement parent;
|
|
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
/* <private> */
|
|
GstDeinterlaceMode mode;
|
|
|
|
GstDeinterlaceFieldLayout field_layout;
|
|
|
|
GstDeinterlaceFields fields;
|
|
|
|
/* current state (differs when flushing/inverse telecine using weave) */
|
|
GstDeinterlaceMethods method_id;
|
|
/* property value */
|
|
GstDeinterlaceMethods user_set_method_id;
|
|
GstDeinterlaceMethod *method;
|
|
|
|
GstVideoFormat format;
|
|
gint width, height; /* frame width & height */
|
|
guint frame_size; /* frame size in bytes */
|
|
gint fps_n, fps_d; /* frame rate */
|
|
gboolean interlaced; /* is input interlaced? */
|
|
|
|
gboolean passthrough;
|
|
|
|
GstClockTime field_duration; /* Duration of one field */
|
|
|
|
/* The most recent pictures
|
|
PictureHistory[0] is always the most recent.
|
|
Pointers are NULL if the picture in question isn't valid, e.g. because
|
|
the program just started or a picture was skipped.
|
|
*/
|
|
GstDeinterlaceField field_history[GST_DEINTERLACE_MAX_FIELD_HISTORY];
|
|
guint history_count;
|
|
|
|
/* Set to TRUE if we're in still frame mode,
|
|
i.e. just forward all buffers
|
|
*/
|
|
gboolean still_frame_mode;
|
|
|
|
/* Last buffer that was pushed in */
|
|
GstBuffer *last_buffer;
|
|
|
|
/* Current segment */
|
|
GstSegment segment;
|
|
|
|
/* QoS stuff */
|
|
gdouble proportion;
|
|
GstClockTime earliest_time;
|
|
|
|
GstCaps *request_caps;
|
|
|
|
gboolean reconfigure;
|
|
GstDeinterlaceMode new_mode;
|
|
GstDeinterlaceFields new_fields;
|
|
|
|
GstDeinterlaceLocking locking;
|
|
gint low_latency;
|
|
gboolean drop_orphans;
|
|
gboolean ignore_obscure;
|
|
gboolean pattern_lock;
|
|
gboolean pattern_refresh;
|
|
GstDeinterlaceBufferState buf_states[GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY];
|
|
gint state_count;
|
|
gint pattern;
|
|
guint8 pattern_phase;
|
|
guint8 pattern_count;
|
|
guint8 output_count;
|
|
GstClockTime pattern_base_ts;
|
|
GstClockTime pattern_buf_dur;
|
|
|
|
gboolean need_more;
|
|
gboolean have_eos;
|
|
};
|
|
|
|
struct _GstDeinterlaceClass
|
|
{
|
|
GstElementClass parent_class;
|
|
};
|
|
|
|
GType gst_deinterlace_get_type (void);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_DEINTERLACE_H__ */
|