1
/*****************************************************************
2
* gavl - a general purpose audio/video processing library
4
* Copyright (c) 2001 - 2008 Members of the Gmerlin project
5
* gmerlin-general@lists.sourceforge.net
6
* http://gmerlin.sourceforge.net
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
* *****************************************************************/
24
#include <gavl/gavl.h>
26
#include <transform.h>
28
gavl_image_transform_t * gavl_image_transform_create()
30
gavl_image_transform_t * ret;
31
ret = calloc(1, sizeof(*ret));
32
gavl_video_options_set_defaults(&ret->opt);
36
void gavl_image_transform_destroy(gavl_image_transform_t * t)
39
for(i = 0; i < 3; i++)
41
for(j = 0; j < GAVL_MAX_PLANES; j++)
43
gavl_transform_context_free(&t->contexts[i][j]);
49
/** \brief Destroy a transformation engine
50
* \param A transformation engine
51
* \param Format (can be changed)
52
* \param func Coordinate transform function
53
* \param priv The priv argument for func
56
void gavl_image_transform_init(gavl_image_transform_t * t,
57
gavl_video_format_t * format,
58
gavl_image_transform_func func, void * priv)
61
gavl_video_options_t opt;
62
gavl_video_options_copy(&opt, &t->opt);
64
if(opt.scale_mode == GAVL_SCALE_AUTO)
67
opt.scale_mode = GAVL_SCALE_NEAREST;
68
else if(opt.quality < 3)
69
opt.scale_mode = GAVL_SCALE_BILINEAR;
71
opt.scale_mode = GAVL_SCALE_CUBIC_BSPLINE;
74
/* Warning: Don't change this until you know what you
75
are doing. The supported scale modes have a maximum of
76
4 filter taps and *no* clipping */
78
if(opt.scale_mode > GAVL_SCALE_CUBIC_BSPLINE)
79
opt.scale_mode = GAVL_SCALE_CUBIC_BSPLINE;
82
gavl_video_format_copy(&t->format, format);
84
switch(format->interlace_mode)
86
case GAVL_INTERLACE_NONE:
89
case GAVL_INTERLACE_TOP_FIRST:
90
case GAVL_INTERLACE_BOTTOM_FIRST:
93
case GAVL_INTERLACE_MIXED:
98
if((t->format.pixelformat == GAVL_YUY2) ||
99
(t->format.pixelformat == GAVL_UYVY))
103
gavl_pixelformat_num_planes(t->format.pixelformat);
107
for(i = 0; i < t->num_fields; i++)
108
for(j = 0; j < t->num_planes; j++)
109
gavl_transform_context_init(t, &opt, i, j, func, priv);
113
/** \brief Transform an image
114
* \param A transformation engine
116
* \param Output frame
119
void gavl_image_transform_transform(gavl_image_transform_t * t,
120
gavl_video_frame_t * in_frame,
121
gavl_video_frame_t * out_frame)
125
int num_fields, field;
127
if(t->format.interlace_mode == GAVL_INTERLACE_NONE)
132
else if((t->format.interlace_mode == GAVL_INTERLACE_MIXED) &&
133
(in_frame->interlace_mode == GAVL_INTERLACE_NONE))
143
for(j = 0; j < t->num_planes; j++)
145
// fprintf(stderr, "Transform: %d\n", field);
146
gavl_transform_context_transform(&t->contexts[field][j],
147
in_frame, out_frame);
152
for(i = 0; i < 2; i++)
154
for(j = 0; j < t->num_planes; j++)
156
gavl_transform_context_transform(&t->contexts[i][j],
157
in_frame, out_frame);
164
gavl_video_options_t *
165
gavl_image_transform_get_options(gavl_image_transform_t * t)