~ubuntu-branches/ubuntu/maverick/tvtime/maverick

« back to all changes in this revision

Viewing changes to src/videofilter.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon Law
  • Date: 2004-01-13 18:00:36 UTC
  • Revision ID: james.westby@ubuntu.com-20040113180036-h996q67t476jymsu
Tags: upstream-0.9.12
ImportĀ upstreamĀ versionĀ 0.9.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright (C) 2003 Billy Biggs <vektor@dumbterm.net>.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or (at
 
7
 * your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful, but
 
10
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 */
 
18
 
 
19
#include <stdlib.h>
 
20
#include <unistd.h>
 
21
#include <string.h>
 
22
#include "videocorrection.h"
 
23
#include "speedy.h"
 
24
#include "videofilter.h"
 
25
 
 
26
struct videofilter_s
 
27
{
 
28
    video_correction_t *vc;
 
29
    int bt8x8_correction;
 
30
    int uyvy_conversion;
 
31
    int colour_invert;
 
32
    int mirror;
 
33
    int chromakill;
 
34
 
 
35
    uint8_t tempscanline[ 2048 ];
 
36
};
 
37
 
 
38
videofilter_t *videofilter_new( void )
 
39
{
 
40
    videofilter_t *vf = malloc( sizeof( videofilter_t ) );
 
41
    if( !vf ) return 0;
 
42
 
 
43
    vf->vc = video_correction_new( 1, 0 );
 
44
    vf->bt8x8_correction = 0;
 
45
    vf->uyvy_conversion = 0;
 
46
    vf->colour_invert = 0;
 
47
    vf->mirror = 0;
 
48
    vf->chromakill = 0;
 
49
 
 
50
    return vf;
 
51
}
 
52
 
 
53
void videofilter_delete( videofilter_t *vf )
 
54
{
 
55
    if( vf->vc ) video_correction_delete( vf->vc );
 
56
    free( vf );
 
57
}
 
58
 
 
59
void videofilter_set_bt8x8_correction( videofilter_t *vf, int correct )
 
60
{
 
61
    vf->bt8x8_correction = correct;
 
62
}
 
63
 
 
64
void videofilter_set_colour_invert( videofilter_t *vf, int invert )
 
65
{
 
66
    vf->colour_invert = invert;
 
67
}
 
68
 
 
69
void videofilter_set_mirror( videofilter_t *vf, int mirror )
 
70
{
 
71
    vf->mirror = mirror;
 
72
}
 
73
 
 
74
void videofilter_set_chroma_kill( videofilter_t *vf, int chromakill )
 
75
{
 
76
    vf->chromakill = chromakill;
 
77
}
 
78
 
 
79
void videofilter_set_full_extent_correction( videofilter_t *vf, int correct )
 
80
{
 
81
}
 
82
 
 
83
void videofilter_set_luma_power( videofilter_t *vf, double power )
 
84
{
 
85
    if( vf->vc ) video_correction_set_luma_power( vf->vc, power );
 
86
}
 
87
 
 
88
void videofilter_enable_uyvy_conversion( videofilter_t *vf )
 
89
{
 
90
    vf->uyvy_conversion = 1;
 
91
}
 
92
 
 
93
int videofilter_active_on_scanline( videofilter_t *vf, int scanline )
 
94
{
 
95
    if( vf->uyvy_conversion || vf->colour_invert || vf->mirror ||
 
96
        vf->chromakill || (vf->vc && vf->bt8x8_correction) ) {
 
97
        return 1;
 
98
    } else {
 
99
        return 0;
 
100
    }
 
101
}
 
102
 
 
103
void videofilter_packed422_scanline( videofilter_t *vf, uint8_t *data,
 
104
                                     int width, int xpos, int scanline )
 
105
{
 
106
    if( vf->uyvy_conversion ) {
 
107
        convert_uyvy_to_yuyv_scanline( data, data, width );
 
108
    }
 
109
 
 
110
    if( vf->vc && vf->bt8x8_correction ) {
 
111
        video_correction_correct_packed422_scanline( vf->vc, data, data, width );
 
112
        /* filter_luma_121_packed422_inplace_scanline( data, width ); */
 
113
        /* filter_luma_14641_packed422_inplace_scanline( data, width ); */
 
114
        /* halfmirror_packed422_inplace_scanline( data, width ); */
 
115
        /* testing_packed422_inplace_scanline( data, width, scanline ); */
 
116
    }
 
117
 
 
118
    if( vf->colour_invert ) {
 
119
        invert_colour_packed422_inplace_scanline( data, width );
 
120
    }
 
121
 
 
122
    if( vf->mirror ) {
 
123
        mirror_packed422_inplace_scanline( data, width );
 
124
    }
 
125
 
 
126
    if( vf->chromakill ) {
 
127
        kill_chroma_packed422_inplace_scanline( data, width );
 
128
    }
 
129
}
 
130