1 /*
2 * Copyright (C) 2015 Pedro Arthur <bygrandao@gmail.com>
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
23
24 /// Scaler instance data
26 {
32
33 /// Color conversion instance data
35 {
38
40 {
42 int srcW =
desc->src->width;
43 int dstW =
desc->dst->width;
44 int xInc = instance->
xInc;
45
47 for (
i = 0;
i < sliceH; ++
i) {
48 uint8_t **
src =
desc->src->plane[0].line;
49 uint8_t **
dst =
desc->dst->plane[0].line;
50 int src_pos = sliceY+
i -
desc->src->plane[0].sliceY;
51 int dst_pos = sliceY+
i -
desc->dst->plane[0].sliceY;
52
53
54 if (
c->hyscale_fast) {
55 c->hyscale_fast(
c, (int16_t*)
dst[dst_pos], dstW,
src[src_pos], srcW, xInc);
56 } else {
57 c->hyScale(
c, (int16_t*)
dst[dst_pos], dstW, (
const uint8_t *)
src[src_pos], instance->
filter,
59 }
60
61 if (
c->lumConvertRange)
62 c->lumConvertRange((int16_t*)
dst[dst_pos], dstW);
63
64 desc->dst->plane[0].sliceH += 1;
65
69
70 src_pos = sliceY+
i -
desc->src->plane[3].sliceY;
71 dst_pos = sliceY+
i -
desc->dst->plane[3].sliceY;
72
73 desc->dst->plane[3].sliceH += 1;
74
75 if (
c->hyscale_fast) {
76 c->hyscale_fast(
c, (int16_t*)
dst[dst_pos], dstW,
src[src_pos], srcW, xInc);
77 } else {
78 c->hyScale(
c, (int16_t*)
dst[dst_pos], dstW, (
const uint8_t *)
src[src_pos], instance->
filter,
80 }
81 }
82 }
83
84 return sliceH;
85 }
86
88 {
89 int srcW =
desc->src->width;
91 uint32_t * pal = instance->
pal;
93
94 desc->dst->plane[0].sliceY = sliceY;
95 desc->dst->plane[0].sliceH = sliceH;
96 desc->dst->plane[3].sliceY = sliceY;
97 desc->dst->plane[3].sliceH = sliceH;
98
99 for (
i = 0;
i < sliceH; ++
i) {
100 int sp0 = sliceY+
i -
desc->src->plane[0].sliceY;
101 int sp1 = ((sliceY+
i) >>
desc->src->v_chr_sub_sample) -
desc->src->plane[1].sliceY;
102 const uint8_t *
src[4] = {
desc->src->plane[0].line[sp0],
103 desc->src->plane[1].line[sp1],
104 desc->src->plane[2].line[sp1],
105 desc->src->plane[3].line[sp0]};
106 uint8_t *
dst =
desc->dst->plane[0].line[
i];
107
109 c->lumToYV12(
dst,
src[0],
src[1],
src[2], srcW, pal,
c->input_opaque);
110 }
else if (
c->readLumPlanar) {
111 c->readLumPlanar(
dst,
src, srcW,
c->input_rgb2yuv_table,
c->input_opaque);
112 }
113
114
118 c->alpToYV12(
dst,
src[3],
src[1],
src[2], srcW, pal,
c->input_opaque);
119 }
else if (
c->readAlpPlanar) {
120 c->readAlpPlanar(
dst,
src, srcW,
NULL,
c->input_opaque);
121 }
122 }
123 }
124
125 return sliceH;
126 }
127
129 {
131 if (!li)
135
140
141 return 0;
142 }
143
144
146 {
148 if (!li)
150
155
157
161
163
164 return 0;
165 }
166
168 {
172 int xInc = instance->
xInc;
173
174 uint8_t **
src1 =
desc->src->plane[1].line;
175 uint8_t ** dst1 =
desc->dst->plane[1].line;
176 uint8_t **
src2 =
desc->src->plane[2].line;
177 uint8_t ** dst2 =
desc->dst->plane[2].line;
178
179 int src_pos1 = sliceY -
desc->src->plane[1].sliceY;
180 int dst_pos1 = sliceY -
desc->dst->plane[1].sliceY;
181
182 int src_pos2 = sliceY -
desc->src->plane[2].sliceY;
183 int dst_pos2 = sliceY -
desc->dst->plane[2].sliceY;
184
186 for (
i = 0;
i < sliceH; ++
i) {
187 if (
c->hcscale_fast) {
188 c->hcscale_fast(
c, (uint16_t*)dst1[dst_pos1+
i], (uint16_t*)dst2[dst_pos2+
i], dstW,
src1[src_pos1+
i],
src2[src_pos2+
i], srcW, xInc);
189 } else {
192 }
193
194 if (
c->chrConvertRange)
195 c->chrConvertRange((uint16_t*)dst1[dst_pos1+
i], (uint16_t*)dst2[dst_pos2+
i], dstW);
196
197 desc->dst->plane[1].sliceH += 1;
198 desc->dst->plane[2].sliceH += 1;
199 }
200 return sliceH;
201 }
202
204 {
207 uint32_t * pal = instance->
pal;
208
209 int sp0 = (sliceY - (
desc->src->plane[0].sliceY >>
desc->src->v_chr_sub_sample)) <<
desc->src->v_chr_sub_sample;
210 int sp1 = sliceY -
desc->src->plane[1].sliceY;
211
213
214 desc->dst->plane[1].sliceY = sliceY;
215 desc->dst->plane[1].sliceH = sliceH;
216 desc->dst->plane[2].sliceY = sliceY;
217 desc->dst->plane[2].sliceH = sliceH;
218
219 for (
i = 0;
i < sliceH; ++
i) {
220 const uint8_t *
src[4] = {
desc->src->plane[0].line[sp0+
i],
221 desc->src->plane[1].line[sp1+
i],
222 desc->src->plane[2].line[sp1+
i],
223 desc->src->plane[3].line[sp0+
i]};
224
225 uint8_t * dst1 =
desc->dst->plane[1].line[
i];
226 uint8_t * dst2 =
desc->dst->plane[2].line[
i];
228 c->chrToYV12(dst1, dst2,
src[0],
src[1],
src[2], srcW, pal,
c->input_opaque);
229 }
else if (
c->readChrPlanar) {
230 c->readChrPlanar(dst1, dst2,
src, srcW,
c->input_rgb2yuv_table,
c->input_opaque);
231 }
232 }
233 return sliceH;
234 }
235
237 {
239 if (!li)
243
247
248 return 0;
249 }
250
252 {
254 if (!li)
256
261
263
267
269
270 return 0;
271 }
272
274 {
275 desc->dst->plane[1].sliceY = sliceY + sliceH -
desc->dst->plane[1].available_lines;
276 desc->dst->plane[1].sliceH =
desc->dst->plane[1].available_lines;
277 desc->dst->plane[2].sliceY = sliceY + sliceH -
desc->dst->plane[2].available_lines;
278 desc->dst->plane[2].sliceH =
desc->dst->plane[2].available_lines;
279 return 0;
280 }
281
283 {
289 return 0;
290 }