1 /*
2 * Copyright (c) 2012 Steven Robertson
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * copy an alpha component from another video's luma
24 */
25
26 #include <string.h>
27
35
37
45
47 {
51 }
52
54 {
59 };
66 return 0;
67 }
68
70 {
74 return 0;
75 }
76
78 {
82 if (mainlink->
w != alphalink->
w || mainlink->
h != alphalink->
h) {
84 "Input frame sizes do not match (%dx%d vs %dx%d).\n",
85 mainlink->
w, mainlink->
h,
86 alphalink->
w, alphalink->
h);
88 }
89
90 outlink->
w = mainlink->
w;
91 outlink->
h = mainlink->
h;
95 return 0;
96 }
97
101 {
104
108 for (y = 0; y < h; y++) {
111 for (x = 0; x < main_buf->
width; x++) {
112 *pout = *pin;
113 pin += 1;
114 pout += 4;
115 }
116 }
117 } else {
119 const int main_linesize = main_buf->
linesize[
A];
120 const int alpha_linesize = alpha_buf->
linesize[
Y];
121 for (y = 0; y < h && y < alpha_buf->
height; y++) {
122 memcpy(main_buf->
data[
A] + y * main_linesize,
123 alpha_buf->
data[
Y] + y * alpha_linesize,
124 FFMIN(main_linesize, alpha_linesize));
125 }
126 }
127 }
128
130 {
133
135 int is_alpha = (inlink == ctx->
inputs[1]);
139
140 do {
142
145
148
153 } while (ret >= 0);
155 }
156
158 {
162
167 if (ret < 0)
169 }
170 return 0;
171 }
172
174 {
179 .needs_writable = 1,
180 },{
181 .name = "alpha",
184 },
186 };
187
189 {
194 },
196 };
197
199 .
name =
"alphamerge",
201 "input into the alpha channel of the first input."),
205 .
inputs = alphamerge_inputs,
207 };