~ubuntu-branches/ubuntu/utopic/lebiniou/utopic

« back to all changes in this revision

Viewing changes to src/context_export.c

  • Committer: Package Import Robot
  • Author(s): Olivier Girondel
  • Date: 2012-04-22 22:07:40 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20120422220740-xncgwhc3g71nopnu
Tags: 3.18-1
* New upstream release 3.18.
* Support older libswscale.
* Add missing Build-Depends: libfreetype6-dev, libasound2-dev,
  libpulse-dev. (Closes: #669437)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright 1994-2011 Olivier Girondel
 
2
 *  Copyright 1994-2012 Olivier Girondel
3
3
 *
4
4
 *  This file is part of lebiniou.
5
5
 *
27
27
  Buffer8_t *buf = ctx->buffers[screen];
28
28
  const Pixel_t *src = NULL;
29
29
  Pixel_t *res;
30
 
  u_long c, i=0;
 
30
  u_long c, i = 0;
31
31
 
32
32
  if (flip)
33
 
    Buffer8_flip_x(buf);
 
33
    Buffer8_flip_v(buf);
34
34
  src = buf->buffer;
35
35
 
36
36
  res = xmalloc(3*BUFFSIZE*sizeof(Pixel_t));
42
42
  }
43
43
 
44
44
  if (flip)
45
 
    Buffer8_flip_x(buf);
 
45
    Buffer8_flip_v(buf);
46
46
 
47
47
  return res;
48
48
}
53
53
{
54
54
  return export_RGB_buffer(ctx, ACTIVE_BUFFER, flip);
55
55
}
 
56
 
 
57
 
 
58
Pixel_t *
 
59
export_YUV_buffer(const Context_t *ctx, const u_char screen, const u_char flip)
 
60
{
 
61
  rgba_t *colors = &ctx->cf->cur->colors[0];
 
62
  Buffer8_t *buf = ctx->buffers[screen];
 
63
  const Pixel_t *src = NULL;
 
64
  Pixel_t *res;
 
65
  u_long c, i = 0;
 
66
 
 
67
  if (flip)
 
68
    Buffer8_flip_v(buf);
 
69
  src = buf->buffer;
 
70
 
 
71
  res = xmalloc(3*BUFFSIZE*sizeof(Pixel_t));
 
72
 
 
73
  /*
 
74
   * From wikipedia, sorry
 
75
   *
 
76
   * Y = 0,299⋅R + 0,587⋅G + 0,114⋅B
 
77
   * U = 0,492⋅(B − Y) = −0,14713⋅R − 0,28886⋅G + 0,436⋅B
 
78
   * V = 0,877⋅(R − Y) = 0,615⋅R − 0,51498⋅G- 0,10001⋅B
 
79
   */
 
80
#define CR (colors[src[c]].col.r)
 
81
#define CG (colors[src[c]].col.g)
 
82
#define CB (colors[src[c]].col.b)
 
83
 
 
84
  for (c = 0; c < BUFFSIZE; c++) {
 
85
    res[i++] = 0.299*CR + 0.587*CG + 0.114*CB;;
 
86
    res[i++] = -0.14713*CR - 0.28886*CG + 0.436*CB;
 
87
    res[i++] = 0.615*CR - 0.51498*CG - 0.10001*CB;
 
88
  }
 
89
 
 
90
  if (flip)
 
91
    Buffer8_flip_v(buf);
 
92
 
 
93
  return res;
 
94
}
 
95
 
 
96
 
 
97
Pixel_t *
 
98
export_YUV_active_buffer(const Context_t *ctx, const u_char flip)
 
99
{
 
100
  return export_YUV_buffer(ctx, ACTIVE_BUFFER, flip);
 
101
}
 
102
 
 
103
 
 
104
const RGBA_t *
 
105
export_RGBA_buffer(const Context_t *ctx, const u_char screen)
 
106
{
 
107
  rgba_t *colors = &ctx->cf->cur->colors[0];
 
108
  Pixel_t *src = ctx->buffers[screen]->buffer, *start;
 
109
  RGBA_t *dst = ctx->rgba_buffers[screen]->buffer;
 
110
 
 
111
  assert(NULL != dst);
 
112
  start = src;
 
113
 
 
114
  for ( ; src < start+BUFFSIZE*sizeof(Pixel_t); src++, dst++)
 
115
    *dst = colors[*src].col;
 
116
 
 
117
  return ctx->rgba_buffers[screen]->buffer;
 
118
}
 
119
 
 
120
 
 
121
const RGBA_t *
 
122
export_RGBA_active_buffer(const Context_t *ctx)
 
123
{
 
124
  return export_RGBA_buffer(ctx, ACTIVE_BUFFER);
 
125
}