File: deinterlace_copy.c

package info (click to toggle)
gavl 1.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 14,912 kB
  • sloc: ansic: 437,319; sh: 10,487; makefile: 238
file content (79 lines) | stat: -rw-r--r-- 2,391 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*****************************************************************
 * gavl - a general purpose audio/video processing library
 *
 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
 * gmerlin-general@lists.sourceforge.net
 * http://gmerlin.sourceforge.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * *****************************************************************/

#include <stdio.h>

#include <gavl/gavl.h>
#include <video.h>
#include <deinterlace.h>
#include <accel.h>

static void deinterlace_copy(gavl_video_deinterlacer_t * d,
                             const gavl_video_frame_t * input_frame,
                             gavl_video_frame_t * output_frame)
  {
  int i, j, jmax;
  int bytes;
  uint8_t * src;
  uint8_t * dst;
  int src_field =
    (d->opt.deinterlace_drop_mode == GAVL_DEINTERLACE_DROP_TOP) ? 1 : 0;
  
  jmax = d->format.image_height / 2;
  bytes = d->line_width;

    
  for(i = 0; i < d->num_planes; i++)
    {
    src = input_frame->planes[i] + src_field * input_frame->strides[i];
    dst = output_frame->planes[i];
    
    if(i == 1)
      {
      jmax /= d->sub_v;
      bytes /= d->sub_h;
      }
    for(j = 0; j < jmax; j++)
      {
      gavl_memcpy(dst, src, bytes);
      dst += output_frame->strides[i];
      gavl_memcpy(dst, src, bytes);
      dst += output_frame->strides[i];
      src += input_frame->strides[i] * 2;
      }
    }
  }

int
gavl_deinterlacer_init_copy(gavl_video_deinterlacer_t* d)
  {
  d->func = deinterlace_copy;
  d->line_width = gavl_pixelformat_is_planar(d->format.pixelformat) ?
    d->format.image_width *
    gavl_pixelformat_bytes_per_component(d->format.pixelformat) :
    d->format.image_width *
    gavl_pixelformat_bytes_per_pixel(d->format.pixelformat);

  gavl_init_memcpy();
  
  return 1;
  }