1 /*
2 * Copyright (c) 2024 Michael Niedermayer <michael-ffmpeg@niedermayer.cc>
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 #include "config.h"
29
31
33
34
36
37 static void error(
const char *err)
38 {
39 fprintf(stderr, "%s", err);
40 exit(1);
41 }
42
44 {
49 return -1;
50
52
54
58 }
62
67 return -1;
68 } else
70 }
71 return 0;
72 }
73
75 {
78 }
79
80 static void mapres(
unsigned *r0,
unsigned *r1) {
81 double d = (
double)(*r0*10ll - 9ll*UINT32_MAX) / UINT32_MAX;
84 uint64_t maxb = 16384 / ai;
85 *r0 = ai;
86 *r1 = 1 + (*r1 * maxb) / UINT32_MAX;
87 }
88
90 int srcW= 48, srcH = 48;
91 int dstW= 48, dstH = 48;
92 int srcHShift, srcVShift;
93 int dstHShift, dstVShift;
105
109
112 srcW = bytestream2_get_le32(&gbc);
113 srcH = bytestream2_get_le32(&gbc);
114 dstW = bytestream2_get_le32(&gbc);
115 dstH = bytestream2_get_le32(&gbc);
116
119
120 flags = bytestream2_get_le32(&gbc);
121
135 return 0; // multiple scalers are set, not possible
136
139
140 flags64 = bytestream2_get_le64(&gbc);
141 if (flags64 & 0x10)
143
145 srcW = srcH = 23;
147 dstW = dstH = 23;
148 //TODO alphablend
149 }
150
153
154 // fprintf(stderr, "%d x %d %s -> %d x %d %s\n", srcW, srcH, desc_src->name, dstW, dstH, desc_dst->name);
155
156 ret =
alloc_plane(
src, srcStride, srcW, srcH, srcFormat, &srcHShift, &srcVShift);
158 goto end;
159
160 ret =
alloc_plane(
dst, dstStride, dstW, dstH, dstFormat, &dstHShift, &dstVShift);
162 goto end;
163
164
166 int psize = srcStride[
p] *
AV_CEIL_RSHIFT(srcH, (
p == 1 ||
p == 2) ? srcVShift : 0);
169 if (psize) {
173 }
174 }
175
178 error(
"Failed sws allocation");
179
188
191 goto end;
192
193 //TODO Slices
195
196 end:
198
201
202 return 0;
203 }