videoconvert.h 2.92 KB
Newer Older
1
/* Video conversion functions
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
 * Copyright (C) 2010 David Schleef <ds@schleef.org>
 *
 * 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 __COLORSPACE_H__
#define __COLORSPACE_H__

#include <gst/video/video.h>

G_BEGIN_DECLS

27 28
typedef struct _VideoConvert VideoConvert;
typedef struct _VideoFrame VideoComponent;
29

30 31 32 33 34 35 36 37
typedef enum {
  COLOR_SPEC_NONE = 0,
  COLOR_SPEC_RGB,
  COLOR_SPEC_GRAY,
  COLOR_SPEC_YUV_BT470_6,
  COLOR_SPEC_YUV_BT709
} ColorSpaceColorSpec;

38 39 40 41 42 43
typedef enum {
  DITHER_NONE,
  DITHER_VERTERR,
  DITHER_HALFTONE
} ColorSpaceDitherMethod;

44
struct _VideoComponent {
45 46 47 48
  int offset;
  int stride;
};

49
struct _VideoConvert {
50 51
  gint width, height;
  gboolean interlaced;
52
  gboolean use_16bit;
53
  gboolean dither;
54 55

  GstVideoFormat from_format;
56
  ColorSpaceColorSpec from_spec;
57
  GstVideoFormat to_format;
58
  ColorSpaceColorSpec to_spec;
59 60 61
  guint32 *palette;

  guint8 *tmpline;
62
  guint16 *tmpline16;
63
  guint16 *errline;
64 65 66 67 68 69

  int dest_offset[4];
  int dest_stride[4];
  int src_offset[4];
  int src_stride[4];

70 71 72 73
  void (*convert) (VideoConvert *convert, guint8 *dest, const guint8 *src);
  void (*getline) (VideoConvert *convert, guint8 *dest, const guint8 *src, int j);
  void (*putline) (VideoConvert *convert, guint8 *dest, const guint8 *src, int j);
  void (*matrix) (VideoConvert *convert);
74

75 76 77 78
  void (*getline16) (VideoConvert *convert, guint16 *dest, const guint8 *src, int j);
  void (*putline16) (VideoConvert *convert, guint8 *dest, const guint16 *src, int j);
  void (*matrix16) (VideoConvert *convert);
  void (*dither16) (VideoConvert *convert, int j);
79 80
};

81
VideoConvert * videoconvert_convert_new (GstVideoFormat to_format,
82 83
    ColorSpaceColorSpec from_spec, GstVideoFormat from_format,
    ColorSpaceColorSpec to_spec, int width, int height);
84 85
void videoconvert_convert_set_dither (VideoConvert * convert, int type);
void videoconvert_convert_set_interlaced (VideoConvert *convert,
86
    gboolean interlaced);
87
void videoconvert_convert_set_palette (VideoConvert *convert,
88
    const guint32 *palette);
89 90 91
const guint32 * videoconvert_convert_get_palette (VideoConvert *convert);
void videoconvert_convert_free (VideoConvert * convert);
void videoconvert_convert_convert (VideoConvert * convert,
92
    guint8 *dest, const guint8 *src);
93 94 95 96 97


G_END_DECLS

#endif /* __GST_COLORSPACE_H__ */