mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
fieldanalysis: Add fieldanalysis element
This element analyses video buffers to identify if they are progressive, interlaced or telecined and outputs buffers with appropriate flags for a downstream element (which will be the deinterlace element, after some forthcoming modifications) to be able to output progressive frames and adjust timestamps resulting in a progressive stream.
This commit is contained in:
parent
8e60680c33
commit
14fb720149
5 changed files with 2097 additions and 0 deletions
|
@ -306,6 +306,7 @@ AG_GST_CHECK_PLUGIN(dtmf)
|
|||
AG_GST_CHECK_PLUGIN(dvbsuboverlay)
|
||||
AG_GST_CHECK_PLUGIN(dvdspu)
|
||||
AG_GST_CHECK_PLUGIN(festival)
|
||||
AG_GST_CHECK_PLUGIN(fieldanalysis)
|
||||
AG_GST_CHECK_PLUGIN(freeze)
|
||||
AG_GST_CHECK_PLUGIN(frei0r)
|
||||
AG_GST_CHECK_PLUGIN(gaudieffects)
|
||||
|
@ -1753,6 +1754,7 @@ gst/dtmf/Makefile
|
|||
gst/dvbsuboverlay/Makefile
|
||||
gst/dvdspu/Makefile
|
||||
gst/festival/Makefile
|
||||
gst/fieldanalysis/Makefile
|
||||
gst/freeze/Makefile
|
||||
gst/frei0r/Makefile
|
||||
gst/gaudieffects/Makefile
|
||||
|
|
26
gst/fieldanalysis/Makefile.am
Normal file
26
gst/fieldanalysis/Makefile.am
Normal file
|
@ -0,0 +1,26 @@
|
|||
plugin_LTLIBRARIES = libgstfieldanalysis.la
|
||||
|
||||
ORC_SOURCE=gstfieldanalysisorc
|
||||
include $(top_srcdir)/common/orc.mak
|
||||
|
||||
libgstfieldanalysis_la_SOURCES = gstfieldanalysis.c gstfieldanalysis.h
|
||||
nodist_libgstfieldanalysis_la_SOURCES = $(ORC_NODIST_SOURCES)
|
||||
|
||||
libgstfieldanalysis_la_CFLAGS = \
|
||||
$(GST_PLUGINS_BAD_CFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
$(ORC_CFLAGS)
|
||||
|
||||
libgstfieldanalysis_la_LIBADD = \
|
||||
$(top_builddir)/gst-libs/gst/video/libgstbasevideo-@GST_MAJORMINOR@.la \
|
||||
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@ \
|
||||
$(GST_BASE_LIBS) \
|
||||
$(GST_LIBS) \
|
||||
$(ORC_LIBS)
|
||||
|
||||
libgstfieldanalysis_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgstfieldanalysis_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
noinst_HEADERS = gstfieldanalysis.h
|
1806
gst/fieldanalysis/gstfieldanalysis.c
Normal file
1806
gst/fieldanalysis/gstfieldanalysis.c
Normal file
File diff suppressed because it is too large
Load diff
144
gst/fieldanalysis/gstfieldanalysis.h
Normal file
144
gst/fieldanalysis/gstfieldanalysis.h
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2010 Robert Swain <robert.swain@collabora.co.uk>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* 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_FIELDANALYSIS_H__
|
||||
#define __GST_FIELDANALYSIS_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GST_TYPE_FIELDANALYSIS \
|
||||
(gst_field_analysis_get_type())
|
||||
#define GST_FIELDANALYSIS(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FIELDANALYSIS,GstFieldAnalysis))
|
||||
#define GST_FIELDANALYSIS_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FIELDANALYSIS,GstFieldAnalysisClass))
|
||||
#define GST_IS_FIELDANALYSIS(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FIELDANALYSIS))
|
||||
#define GST_IS_FIELDANALYSIS_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FIELDANALYSIS))
|
||||
|
||||
typedef struct _GstFieldAnalysis GstFieldAnalysis;
|
||||
typedef struct _GstFieldAnalysisClass GstFieldAnalysisClass;
|
||||
typedef struct _FieldAnalysisFields FieldAnalysisFields;
|
||||
typedef struct _FieldAnalysis FieldAnalysis;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIELD_ANALYSIS_PROGRESSIVE,
|
||||
FIELD_ANALYSIS_INTERLACED,
|
||||
FIELD_ANALYSIS_TELECINE_PROGRESSIVE,
|
||||
FIELD_ANALYSIS_TELECINE_MIXED
|
||||
} FieldAnalysisConclusion;
|
||||
|
||||
enum FieldParity
|
||||
{
|
||||
TOP_FIELD,
|
||||
BOTTOM_FIELD,
|
||||
BOTH_FIELDS
|
||||
};
|
||||
|
||||
struct _FieldAnalysisFields
|
||||
{
|
||||
GstBuffer *buf;
|
||||
gboolean parity;
|
||||
};
|
||||
|
||||
struct _FieldAnalysis
|
||||
{
|
||||
/* frame, top, bottom, top with prev bottom, bottom with prev top */
|
||||
gfloat f, t, b, t_b, b_t;
|
||||
FieldAnalysisConclusion conclusion;
|
||||
/* -1 - unknown; 0 - holding none; 1 - top field; 2 - bottom field; 3 - both */
|
||||
gint holding;
|
||||
gboolean gap;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
METHOD_32DETECT,
|
||||
METHOD_IS_COMBED,
|
||||
METHOD_5_TAP
|
||||
} FieldAnalysisCombMethod;
|
||||
|
||||
struct _GstFieldAnalysis
|
||||
{
|
||||
GstElement element;
|
||||
|
||||
GstPad *sinkpad, *srcpad;
|
||||
|
||||
GQueue *frames;
|
||||
gint width, height;
|
||||
gint data_offset;
|
||||
gint line_stride; /* step size in bytes from the 0th sample of one line to the next */
|
||||
gint sample_incr; /* step size in bytes from one sample to the next */
|
||||
FieldAnalysis results[2];
|
||||
gfloat (*same_field) (GstFieldAnalysis *, FieldAnalysisFields *);
|
||||
gfloat (*same_frame) (GstFieldAnalysis *, FieldAnalysisFields *);
|
||||
guint64 (*block_score_for_row) (GstFieldAnalysis *, guint8 *, guint8 *);
|
||||
gboolean is_telecine;
|
||||
gboolean first_buffer; /* indicates the first buffer for which a buffer will be output
|
||||
* after a discont or flushing seek */
|
||||
guint8 *comb_mask;
|
||||
guint *block_scores;
|
||||
gboolean flushing; /* indicates whether we are flushing or not */
|
||||
|
||||
/* properties */
|
||||
guint32 noise_floor; /* threshold for the result of a metric to be valid */
|
||||
gfloat field_thresh; /* threshold used for the same parity field metric */
|
||||
gfloat frame_thresh; /* threshold used for the opposite parity field metric */
|
||||
gint64 spatial_thresh; /* threshold used spatial comb detection */
|
||||
guint64 block_width, block_height; /* width/height of window used for comb clusted detection */
|
||||
guint64 block_thresh;
|
||||
guint64 ignored_lines;
|
||||
};
|
||||
|
||||
struct _GstFieldAnalysisClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_field_analysis_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GST_FIELDANALYSIS_H__ */
|
119
gst/fieldanalysis/gstfieldanalysisorc.orc
Normal file
119
gst/fieldanalysis/gstfieldanalysisorc.orc
Normal file
|
@ -0,0 +1,119 @@
|
|||
|
||||
.init gst_fieldanalysis_orc_init
|
||||
|
||||
|
||||
.function orc_same_parity_sad_planar_yuv
|
||||
.accumulator 4 a1 guint32
|
||||
.source 1 s1
|
||||
.source 1 s2
|
||||
# noise threshold
|
||||
.param 4 nt
|
||||
.temp 2 t1
|
||||
.temp 2 t2
|
||||
.temp 4 t3
|
||||
.temp 4 t4
|
||||
|
||||
convubw t1, s1
|
||||
convubw t2, s2
|
||||
subw t1, t1, t2
|
||||
absw t1, t1
|
||||
convuwl t3, t1
|
||||
cmpgtsl t4, t3, nt
|
||||
andl t3, t3, t4
|
||||
accl a1, t3
|
||||
|
||||
|
||||
.function orc_same_parity_ssd_planar_yuv
|
||||
.accumulator 4 a1 guint32
|
||||
.source 1 s1
|
||||
.source 1 s2
|
||||
# noise threshold
|
||||
.param 4 nt
|
||||
.temp 2 t1
|
||||
.temp 2 t2
|
||||
.temp 4 t3
|
||||
.temp 4 t4
|
||||
|
||||
convubw t1, s1
|
||||
convubw t2, s2
|
||||
subw t1, t1, t2
|
||||
mulswl t3, t1, t1
|
||||
cmpgtsl t4, t3, nt
|
||||
andl t3, t3, t4
|
||||
accl a1, t3
|
||||
|
||||
|
||||
.function orc_same_parity_3_tap_planar_yuv
|
||||
.accumulator 4 a1 guint32
|
||||
.source 1 s1
|
||||
.source 1 s2
|
||||
.source 1 s3
|
||||
.source 1 s4
|
||||
.source 1 s5
|
||||
.source 1 s6
|
||||
# noise threshold
|
||||
.param 4 nt
|
||||
.temp 2 t1
|
||||
.temp 2 t2
|
||||
.temp 2 t3
|
||||
.temp 2 t4
|
||||
.temp 2 t5
|
||||
.temp 2 t6
|
||||
.temp 4 t7
|
||||
.temp 4 t8
|
||||
|
||||
convubw t1, s1
|
||||
convubw t2, s2
|
||||
convubw t3, s3
|
||||
convubw t4, s4
|
||||
convubw t5, s5
|
||||
convubw t6, s6
|
||||
shlw t2, t2, 2
|
||||
shlw t5, t5, 2
|
||||
addw t1, t1, t2
|
||||
addw t1, t1, t3
|
||||
addw t4, t4, t5
|
||||
addw t4, t4, t6
|
||||
subw t1, t1, t4
|
||||
absw t1, t1
|
||||
convuwl t7, t1
|
||||
cmpgtsl t8, t7, nt
|
||||
andl t7, t7, t8
|
||||
accl a1, t7
|
||||
|
||||
|
||||
.function orc_opposite_parity_5_tap_planar_yuv
|
||||
.accumulator 4 a1 guint32
|
||||
.source 1 s1
|
||||
.source 1 s2
|
||||
.source 1 s3
|
||||
.source 1 s4
|
||||
.source 1 s5
|
||||
# noise threshold
|
||||
.param 4 nt
|
||||
.temp 2 t1
|
||||
.temp 2 t2
|
||||
.temp 2 t3
|
||||
.temp 2 t4
|
||||
.temp 2 t5
|
||||
.temp 4 t6
|
||||
.temp 4 t7
|
||||
|
||||
convubw t1, s1
|
||||
convubw t2, s2
|
||||
convubw t3, s3
|
||||
convubw t4, s4
|
||||
convubw t5, s5
|
||||
shlw t3, t3, 2
|
||||
mullw t2, t2, 3
|
||||
mullw t4, t4, 3
|
||||
subw t1, t1, t2
|
||||
addw t1, t1, t3
|
||||
subw t1, t1, t4
|
||||
addw t1, t1, t5
|
||||
absw t1, t1
|
||||
convuwl t6, t1
|
||||
cmpgtsl t7, t6, nt
|
||||
andl t6, t6, t7
|
||||
accl a1, t6
|
||||
|
Loading…
Reference in a new issue