* qatar/master:
MS Screen 1 decoder
aacdec: Fix popping channel layouts.
av_gettime: support Win32 without gettimeofday()
Use av_gettime() in various places
Move av_gettime() to libavutil
dct-test: use emms_c() from libavutil instead of duplicating it
mov: fix operator precedence bug
mathematics.h: remove a couple of math defines
Remove unnecessary inclusions of [sys/]time.h
lavf: remove unnecessary inclusions of unistd.h
bfin: libswscale: add const where appropriate to fix warnings
bfin: libswscale: remove unnecessary #includes
udp: Properly check for invalid sockets
tcp: Check the return value from getsockopt
network: Use av_strerror for getting error messages
udp: Properly print error from getnameinfo
mmst: Use AVUNERROR() to convert error codes to the right range for strerror
network: Pass pointers of the right type to get/setsockopt/ioctlsocket on windows
rtmp: Reduce the number of idle posts sent by sleeping 50ms
Conflicts:
Changelog
configure
libavcodec/aacdec.c
libavcodec/allcodecs.c
libavcodec/avcodec.h
libavcodec/dct-test.c
libavcodec/version.h
libavformat/riff.c
libavformat/udp.c
libavutil/Makefile
libswscale/bfin/yuv2rgb_bfin.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -1206,7 +1206,9 @@ HAVE_LIST=" |
1206 | 1206 |
GetProcessAffinityMask |
1207 | 1207 |
GetProcessMemoryInfo |
1208 | 1208 |
GetProcessTimes |
1209 |
+ GetSystemTimeAsFileTime |
|
1209 | 1210 |
getrusage |
1211 |
+ gettimeofday |
|
1210 | 1212 |
glob |
1211 | 1213 |
gnu_as |
1212 | 1214 |
ibm_asm |
... | ... |
@@ -3142,6 +3144,7 @@ check_func getaddrinfo $network_extralibs |
3142 | 3142 |
check_func gethrtime |
3143 | 3143 |
check_func getrusage |
3144 | 3144 |
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss |
3145 |
+check_func gettimeofday |
|
3145 | 3146 |
check_func inet_aton $network_extralibs |
3146 | 3147 |
check_func isatty |
3147 | 3148 |
check_func localtime_r |
... | ... |
@@ -3163,6 +3166,7 @@ check_func_headers lzo/lzo1x.h lzo1x_999_compress |
3163 | 3163 |
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi |
3164 | 3164 |
check_func_headers windows.h GetProcessAffinityMask |
3165 | 3165 |
check_func_headers windows.h GetProcessTimes |
3166 |
+check_func_headers windows.h GetSystemTimeAsFileTime |
|
3166 | 3167 |
check_func_headers windows.h MapViewOfFile |
3167 | 3168 |
check_func_headers windows.h VirtualAlloc |
3168 | 3169 |
check_func_headers glob.h glob |
... | ... |
@@ -562,6 +562,8 @@ following image formats are supported: |
562 | 562 |
@item LOCO @tab @tab X |
563 | 563 |
@item lossless MJPEG @tab X @tab X |
564 | 564 |
@item Microsoft RLE @tab @tab X |
565 |
+@item Microsoft Screen 1 @tab @tab X |
|
566 |
+ @tab Also known as Windows Media Video V7 Screen. |
|
565 | 567 |
@item Microsoft Video 1 @tab @tab X |
566 | 568 |
@item Mimic @tab @tab X |
567 | 569 |
@tab Used in MSN Messenger Webcam streams. |
... | ... |
@@ -327,6 +327,7 @@ OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \ |
327 | 327 |
h263dec.o h263.o ituh263dec.o \ |
328 | 328 |
mpeg4videodec.o |
329 | 329 |
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o |
330 |
+OBJS-$(CONFIG_MSS1_DECODER) += mss1.o |
|
330 | 331 |
OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o |
331 | 332 |
OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o |
332 | 333 |
OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o |
... | ... |
@@ -170,6 +170,7 @@ void avcodec_register_all(void) |
170 | 170 |
REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2); |
171 | 171 |
REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3); |
172 | 172 |
REGISTER_DECODER (MSRLE, msrle); |
173 |
+ REGISTER_DECODER (MSS1, mss1); |
|
173 | 174 |
REGISTER_ENCDEC (MSVIDEO1, msvideo1); |
174 | 175 |
REGISTER_DECODER (MSZH, mszh); |
175 | 176 |
REGISTER_DECODER (MXPEG, mxpeg); |
... | ... |
@@ -28,13 +28,13 @@ |
28 | 28 |
#include <stdlib.h> |
29 | 29 |
#include <stdio.h> |
30 | 30 |
#include <string.h> |
31 |
-#include <sys/time.h> |
|
32 | 31 |
#include <unistd.h> |
33 | 32 |
#include <math.h> |
34 | 33 |
|
35 | 34 |
#include "libavutil/cpu.h" |
36 | 35 |
#include "libavutil/common.h" |
37 | 36 |
#include "libavutil/lfg.h" |
37 |
+#include "libavutil/time.h" |
|
38 | 38 |
|
39 | 39 |
#include "simple_idct.h" |
40 | 40 |
#include "aandcttab.h" |
... | ... |
@@ -163,13 +163,6 @@ static const struct algo idct_tab[] = { |
163 | 163 |
|
164 | 164 |
#define AANSCALE_BITS 12 |
165 | 165 |
|
166 |
-static int64_t gettime(void) |
|
167 |
-{ |
|
168 |
- struct timeval tv; |
|
169 |
- gettimeofday(&tv, NULL); |
|
170 |
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
|
171 |
-} |
|
172 |
- |
|
173 | 166 |
#define NB_ITS 20000 |
174 | 167 |
#define NB_ITS_SPEED 50000 |
175 | 168 |
|
... | ... |
@@ -201,14 +194,6 @@ static void idct_mmx_init(void) |
201 | 201 |
DECLARE_ALIGNED(16, static DCTELEM, block)[64]; |
202 | 202 |
DECLARE_ALIGNED(8, static DCTELEM, block1)[64]; |
203 | 203 |
|
204 |
-static inline void mmx_emms(void) |
|
205 |
-{ |
|
206 |
-#if HAVE_MMX |
|
207 |
- if (cpu_flags & AV_CPU_FLAG_MMX) |
|
208 |
- __asm__ volatile ("emms\n\t" ::: "memory"); |
|
209 |
-#endif |
|
210 |
-} |
|
211 |
- |
|
212 | 204 |
static void init_block(DCTELEM block[64], int test, int is_idct, AVLFG *prng, int vals) |
213 | 205 |
{ |
214 | 206 |
int i, j; |
... | ... |
@@ -287,7 +272,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c |
287 | 287 |
permute(block, block1, dct->format); |
288 | 288 |
|
289 | 289 |
dct->func(block); |
290 |
- mmx_emms(); |
|
290 |
+ emms_c(); |
|
291 | 291 |
|
292 | 292 |
if (dct->format == SCALE_PERM) { |
293 | 293 |
for (i = 0; i < 64; i++) { |
... | ... |
@@ -345,16 +330,16 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c |
345 | 345 |
init_block(block, test, is_idct, &prng, vals); |
346 | 346 |
permute(block1, block, dct->format); |
347 | 347 |
|
348 |
- ti = gettime(); |
|
348 |
+ ti = av_gettime(); |
|
349 | 349 |
it1 = 0; |
350 | 350 |
do { |
351 | 351 |
for (it = 0; it < NB_ITS_SPEED; it++) { |
352 | 352 |
memcpy(block, block1, sizeof(block)); |
353 | 353 |
dct->func(block); |
354 | 354 |
} |
355 |
- mmx_emms(); |
|
355 |
+ emms_c(); |
|
356 | 356 |
it1 += NB_ITS_SPEED; |
357 |
- ti1 = gettime() - ti; |
|
357 |
+ ti1 = av_gettime() - ti; |
|
358 | 358 |
} while (ti1 < 1000000); |
359 | 359 |
|
360 | 360 |
printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name, |
... | ... |
@@ -505,7 +490,7 @@ static void idct248_error(const char *name, |
505 | 505 |
if (!speed) |
506 | 506 |
return; |
507 | 507 |
|
508 |
- ti = gettime(); |
|
508 |
+ ti = av_gettime(); |
|
509 | 509 |
it1 = 0; |
510 | 510 |
do { |
511 | 511 |
for (it = 0; it < NB_ITS_SPEED; it++) { |
... | ... |
@@ -513,9 +498,9 @@ static void idct248_error(const char *name, |
513 | 513 |
block[i] = block1[i]; |
514 | 514 |
idct248_put(img_dest, 8, block); |
515 | 515 |
} |
516 |
- mmx_emms(); |
|
516 |
+ emms_c(); |
|
517 | 517 |
it1 += NB_ITS_SPEED; |
518 |
- ti1 = gettime() - ti; |
|
518 |
+ ti1 = av_gettime() - ti; |
|
519 | 519 |
} while (ti1 < 1000000); |
520 | 520 |
|
521 | 521 |
printf("%s %s: %0.1f kdct/s\n", 1 ? "IDCT248" : "DCT248", name, |
... | ... |
@@ -27,6 +27,7 @@ |
27 | 27 |
#include "libavutil/mathematics.h" |
28 | 28 |
#include "libavutil/lfg.h" |
29 | 29 |
#include "libavutil/log.h" |
30 |
+#include "libavutil/time.h" |
|
30 | 31 |
#include "fft.h" |
31 | 32 |
#if CONFIG_FFT_FLOAT |
32 | 33 |
#include "dct.h" |
... | ... |
@@ -34,7 +35,6 @@ |
34 | 34 |
#endif |
35 | 35 |
#include <math.h> |
36 | 36 |
#include <unistd.h> |
37 |
-#include <sys/time.h> |
|
38 | 37 |
#include <stdlib.h> |
39 | 38 |
#include <string.h> |
40 | 39 |
|
... | ... |
@@ -186,13 +186,6 @@ static FFTSample frandom(AVLFG *prng) |
186 | 186 |
return (int16_t)av_lfg_get(prng) / 32768.0 * RANGE; |
187 | 187 |
} |
188 | 188 |
|
189 |
-static int64_t gettime(void) |
|
190 |
-{ |
|
191 |
- struct timeval tv; |
|
192 |
- gettimeofday(&tv,NULL); |
|
193 |
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
|
194 |
-} |
|
195 |
- |
|
196 | 189 |
static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale) |
197 | 190 |
{ |
198 | 191 |
int i; |
... | ... |
@@ -430,7 +423,7 @@ int main(int argc, char **argv) |
430 | 430 |
/* we measure during about 1 seconds */ |
431 | 431 |
nb_its = 1; |
432 | 432 |
for(;;) { |
433 |
- time_start = gettime(); |
|
433 |
+ time_start = av_gettime(); |
|
434 | 434 |
for (it = 0; it < nb_its; it++) { |
435 | 435 |
switch (transform) { |
436 | 436 |
case TRANSFORM_MDCT: |
... | ... |
@@ -456,7 +449,7 @@ int main(int argc, char **argv) |
456 | 456 |
#endif |
457 | 457 |
} |
458 | 458 |
} |
459 |
- duration = gettime() - time_start; |
|
459 |
+ duration = av_gettime() - time_start; |
|
460 | 460 |
if (duration >= 1000000) |
461 | 461 |
break; |
462 | 462 |
nb_its *= 2; |
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
#include "config.h" |
33 | 33 |
#include "dsputil.h" |
34 | 34 |
#include "libavutil/lfg.h" |
35 |
+#include "libavutil/time.h" |
|
35 | 36 |
|
36 | 37 |
#undef printf |
37 | 38 |
|
... | ... |
@@ -58,13 +59,6 @@ static void help(void) |
58 | 58 |
"test motion implementations\n"); |
59 | 59 |
} |
60 | 60 |
|
61 |
-static int64_t gettime(void) |
|
62 |
-{ |
|
63 |
- struct timeval tv; |
|
64 |
- gettimeofday(&tv,NULL); |
|
65 |
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
|
66 |
-} |
|
67 |
- |
|
68 | 61 |
#define NB_ITS 500 |
69 | 62 |
|
70 | 63 |
int dummy; |
... | ... |
@@ -97,7 +91,7 @@ static void test_motion(const char *name, |
97 | 97 |
emms_c(); |
98 | 98 |
|
99 | 99 |
/* speed test */ |
100 |
- ti = gettime(); |
|
100 |
+ ti = av_gettime(); |
|
101 | 101 |
d1 = 0; |
102 | 102 |
for(it=0;it<NB_ITS;it++) { |
103 | 103 |
for(y=0;y<HEIGHT-17;y++) { |
... | ... |
@@ -109,7 +103,7 @@ static void test_motion(const char *name, |
109 | 109 |
} |
110 | 110 |
emms_c(); |
111 | 111 |
dummy = d1; /* avoid optimization */ |
112 |
- ti = gettime() - ti; |
|
112 |
+ ti = av_gettime() - ti; |
|
113 | 113 |
|
114 | 114 |
printf(" %0.0f kop/s\n", |
115 | 115 |
(double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) / |
116 | 116 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,845 @@ |
0 |
+/* |
|
1 |
+ * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder |
|
2 |
+ * Copyright (c) 2012 Konstantin Shishkov |
|
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 |
+ * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+#include "libavutil/intfloat.h" |
|
27 |
+#include "libavutil/intreadwrite.h" |
|
28 |
+#include "avcodec.h" |
|
29 |
+#include "get_bits.h" |
|
30 |
+ |
|
31 |
+enum SplitMode { |
|
32 |
+ SPLIT_VERT = 0, |
|
33 |
+ SPLIT_HOR, |
|
34 |
+ SPLIT_NONE |
|
35 |
+}; |
|
36 |
+ |
|
37 |
+typedef struct ArithCoder { |
|
38 |
+ int low, high, value; |
|
39 |
+ GetBitContext *gb; |
|
40 |
+} ArithCoder; |
|
41 |
+ |
|
42 |
+#define MODEL_MIN_SYMS 2 |
|
43 |
+#define MODEL_MAX_SYMS 256 |
|
44 |
+#define THRESH_ADAPTIVE -1 |
|
45 |
+#define THRESH_LOW 15 |
|
46 |
+#define THRESH_HIGH 50 |
|
47 |
+ |
|
48 |
+typedef struct Model { |
|
49 |
+ int cum_prob[MODEL_MAX_SYMS + 1]; |
|
50 |
+ int weights[MODEL_MAX_SYMS + 1]; |
|
51 |
+ int idx2sym[MODEL_MAX_SYMS + 1]; |
|
52 |
+ int sym2idx[MODEL_MAX_SYMS + 1]; |
|
53 |
+ int num_syms; |
|
54 |
+ int thr_weight, threshold; |
|
55 |
+} Model; |
|
56 |
+ |
|
57 |
+static const int sec_order_sizes[4] = { 1, 7, 6, 1 }; |
|
58 |
+ |
|
59 |
+enum ContextDirection { |
|
60 |
+ TOP_LEFT = 0, |
|
61 |
+ TOP, |
|
62 |
+ TOP_RIGHT, |
|
63 |
+ LEFT |
|
64 |
+}; |
|
65 |
+ |
|
66 |
+typedef struct PixContext { |
|
67 |
+ int cache_size, num_syms; |
|
68 |
+ uint8_t cache[12]; |
|
69 |
+ Model cache_model, full_model; |
|
70 |
+ Model sec_models[4][8][4]; |
|
71 |
+} PixContext; |
|
72 |
+ |
|
73 |
+typedef struct MSS1Context { |
|
74 |
+ AVCodecContext *avctx; |
|
75 |
+ AVFrame pic; |
|
76 |
+ uint8_t *pic_start; |
|
77 |
+ int pic_stride; |
|
78 |
+ uint8_t *mask; |
|
79 |
+ int mask_linesize; |
|
80 |
+ uint32_t pal[256]; |
|
81 |
+ int free_colours; |
|
82 |
+ Model intra_region, inter_region; |
|
83 |
+ Model pivot, edge_mode, split_mode; |
|
84 |
+ PixContext intra_pix_ctx, inter_pix_ctx; |
|
85 |
+ int corrupted; |
|
86 |
+} MSS1Context; |
|
87 |
+ |
|
88 |
+static void arith_init(ArithCoder *c, GetBitContext *gb) |
|
89 |
+{ |
|
90 |
+ c->low = 0; |
|
91 |
+ c->high = 0xFFFF; |
|
92 |
+ c->value = get_bits(gb, 16); |
|
93 |
+ c->gb = gb; |
|
94 |
+} |
|
95 |
+ |
|
96 |
+static void arith_normalise(ArithCoder *c) |
|
97 |
+{ |
|
98 |
+ for (;;) { |
|
99 |
+ if (c->high >= 0x8000) { |
|
100 |
+ if (c->low < 0x8000) { |
|
101 |
+ if (c->low >= 0x4000 && c->high < 0xC000) { |
|
102 |
+ c->value -= 0x4000; |
|
103 |
+ c->low -= 0x4000; |
|
104 |
+ c->high -= 0x4000; |
|
105 |
+ } else { |
|
106 |
+ return; |
|
107 |
+ } |
|
108 |
+ } else { |
|
109 |
+ c->value -= 0x8000; |
|
110 |
+ c->low -= 0x8000; |
|
111 |
+ c->high -= 0x8000; |
|
112 |
+ } |
|
113 |
+ } |
|
114 |
+ c->value <<= 1; |
|
115 |
+ c->low <<= 1; |
|
116 |
+ c->high <<= 1; |
|
117 |
+ c->high |= 1; |
|
118 |
+ c->value |= get_bits1(c->gb); |
|
119 |
+ } |
|
120 |
+} |
|
121 |
+ |
|
122 |
+static int arith_get_bit(ArithCoder *c) |
|
123 |
+{ |
|
124 |
+ int range = c->high - c->low + 1; |
|
125 |
+ int bit = (((c->value - c->low) << 1) + 1) / range; |
|
126 |
+ |
|
127 |
+ if (bit) |
|
128 |
+ c->low += range >> 1; |
|
129 |
+ else |
|
130 |
+ c->high = c->low + (range >> 1) - 1; |
|
131 |
+ |
|
132 |
+ arith_normalise(c); |
|
133 |
+ |
|
134 |
+ return bit; |
|
135 |
+} |
|
136 |
+ |
|
137 |
+static int arith_get_bits(ArithCoder *c, int bits) |
|
138 |
+{ |
|
139 |
+ int range = c->high - c->low + 1; |
|
140 |
+ int val = (((c->value - c->low + 1) << bits) - 1) / range; |
|
141 |
+ int prob = range * val; |
|
142 |
+ |
|
143 |
+ c->high = ((prob + range) >> bits) + c->low - 1; |
|
144 |
+ c->low += prob >> bits; |
|
145 |
+ |
|
146 |
+ arith_normalise(c); |
|
147 |
+ |
|
148 |
+ return val; |
|
149 |
+} |
|
150 |
+ |
|
151 |
+static int arith_get_number(ArithCoder *c, int mod_val) |
|
152 |
+{ |
|
153 |
+ int range = c->high - c->low + 1; |
|
154 |
+ int val = ((c->value - c->low + 1) * mod_val - 1) / range; |
|
155 |
+ int prob = range * val; |
|
156 |
+ |
|
157 |
+ c->high = (prob + range) / mod_val + c->low - 1; |
|
158 |
+ c->low += prob / mod_val; |
|
159 |
+ |
|
160 |
+ arith_normalise(c); |
|
161 |
+ |
|
162 |
+ return val; |
|
163 |
+} |
|
164 |
+ |
|
165 |
+static int arith_get_prob(ArithCoder *c, int *probs) |
|
166 |
+{ |
|
167 |
+ int range = c->high - c->low + 1; |
|
168 |
+ int val = ((c->value - c->low + 1) * probs[0] - 1) / range; |
|
169 |
+ int sym = 1; |
|
170 |
+ |
|
171 |
+ while (probs[sym] > val) |
|
172 |
+ sym++; |
|
173 |
+ |
|
174 |
+ c->high = range * probs[sym - 1] / probs[0] + c->low - 1; |
|
175 |
+ c->low += range * probs[sym] / probs[0]; |
|
176 |
+ |
|
177 |
+ return sym; |
|
178 |
+} |
|
179 |
+ |
|
180 |
+static int model_calc_threshold(Model *m) |
|
181 |
+{ |
|
182 |
+ int thr; |
|
183 |
+ |
|
184 |
+ if (m->thr_weight == -1) { |
|
185 |
+ thr = 2 * m->weights[m->num_syms] - 1; |
|
186 |
+ thr = ((thr >> 1) + 4 * m->cum_prob[0]) / thr; |
|
187 |
+ } else { |
|
188 |
+ thr = m->num_syms * m->thr_weight; |
|
189 |
+ } |
|
190 |
+ |
|
191 |
+ return FFMIN(thr, 0x3FFF); |
|
192 |
+} |
|
193 |
+ |
|
194 |
+static void model_reset(Model *m) |
|
195 |
+{ |
|
196 |
+ int i; |
|
197 |
+ |
|
198 |
+ for (i = 0; i <= m->num_syms; i++) { |
|
199 |
+ m->weights[i] = 1; |
|
200 |
+ m->cum_prob[i] = m->num_syms - i; |
|
201 |
+ } |
|
202 |
+ m->weights[0] = -1; |
|
203 |
+ m->idx2sym[0] = -1; |
|
204 |
+ m->sym2idx[m->num_syms] = -1; |
|
205 |
+ for (i = 0; i < m->num_syms; i++) { |
|
206 |
+ m->sym2idx[i] = i + 1; |
|
207 |
+ m->idx2sym[i + 1] = i; |
|
208 |
+ } |
|
209 |
+} |
|
210 |
+ |
|
211 |
+static av_cold void model_init(Model *m, int num_syms, int thr_weight) |
|
212 |
+{ |
|
213 |
+ m->num_syms = num_syms; |
|
214 |
+ m->thr_weight = thr_weight; |
|
215 |
+ m->threshold = model_calc_threshold(m); |
|
216 |
+ model_reset(m); |
|
217 |
+} |
|
218 |
+ |
|
219 |
+static void model_rescale_weights(Model *m) |
|
220 |
+{ |
|
221 |
+ int i; |
|
222 |
+ int cum_prob; |
|
223 |
+ |
|
224 |
+ if (m->thr_weight == -1) |
|
225 |
+ m->threshold = model_calc_threshold(m); |
|
226 |
+ while (m->cum_prob[0] > m->threshold) { |
|
227 |
+ cum_prob = 0; |
|
228 |
+ for (i = m->num_syms; i >= 0; i--) { |
|
229 |
+ m->cum_prob[i] = cum_prob; |
|
230 |
+ m->weights[i] = (m->weights[i] + 1) >> 1; |
|
231 |
+ cum_prob += m->weights[i]; |
|
232 |
+ } |
|
233 |
+ } |
|
234 |
+} |
|
235 |
+ |
|
236 |
+static void model_update(Model *m, int val) |
|
237 |
+{ |
|
238 |
+ int i; |
|
239 |
+ |
|
240 |
+ if (m->weights[val] == m->weights[val - 1]) { |
|
241 |
+ for (i = val; m->weights[i - 1] == m->weights[val]; i--); |
|
242 |
+ if (i != val) { |
|
243 |
+ int sym1, sym2; |
|
244 |
+ |
|
245 |
+ sym1 = m->idx2sym[val]; |
|
246 |
+ sym2 = m->idx2sym[i]; |
|
247 |
+ |
|
248 |
+ m->idx2sym[val] = sym2; |
|
249 |
+ m->idx2sym[i] = sym1; |
|
250 |
+ m->sym2idx[sym1] = i; |
|
251 |
+ m->sym2idx[sym2] = val; |
|
252 |
+ |
|
253 |
+ val = i; |
|
254 |
+ } |
|
255 |
+ } |
|
256 |
+ m->weights[val]++; |
|
257 |
+ for (i = val - 1; i >= 0; i--) |
|
258 |
+ m->cum_prob[i]++; |
|
259 |
+ model_rescale_weights(m); |
|
260 |
+} |
|
261 |
+ |
|
262 |
+static int arith_get_model_sym(ArithCoder *c, Model *m) |
|
263 |
+{ |
|
264 |
+ int idx, val; |
|
265 |
+ |
|
266 |
+ idx = arith_get_prob(c, m->cum_prob); |
|
267 |
+ |
|
268 |
+ val = m->idx2sym[idx]; |
|
269 |
+ model_update(m, idx); |
|
270 |
+ |
|
271 |
+ arith_normalise(c); |
|
272 |
+ |
|
273 |
+ return val; |
|
274 |
+} |
|
275 |
+ |
|
276 |
+static void pixctx_reset(PixContext *ctx) |
|
277 |
+{ |
|
278 |
+ int i, j, k; |
|
279 |
+ |
|
280 |
+ for (i = 0; i < ctx->cache_size; i++) |
|
281 |
+ ctx->cache[i] = i; |
|
282 |
+ |
|
283 |
+ model_reset(&ctx->cache_model); |
|
284 |
+ model_reset(&ctx->full_model); |
|
285 |
+ |
|
286 |
+ for (i = 0; i < 4; i++) |
|
287 |
+ for (j = 0; j < sec_order_sizes[i]; j++) |
|
288 |
+ for (k = 0; k < 4; k++) |
|
289 |
+ model_reset(&ctx->sec_models[i][j][k]); |
|
290 |
+} |
|
291 |
+ |
|
292 |
+static av_cold void pixctx_init(PixContext *ctx, int cache_size) |
|
293 |
+{ |
|
294 |
+ int i, j, k; |
|
295 |
+ |
|
296 |
+ ctx->cache_size = cache_size + 4; |
|
297 |
+ ctx->num_syms = cache_size; |
|
298 |
+ |
|
299 |
+ for (i = 0; i < ctx->cache_size; i++) |
|
300 |
+ ctx->cache[i] = i; |
|
301 |
+ |
|
302 |
+ model_init(&ctx->cache_model, ctx->num_syms + 1, THRESH_LOW); |
|
303 |
+ model_init(&ctx->full_model, 256, THRESH_HIGH); |
|
304 |
+ |
|
305 |
+ for (i = 0; i < 4; i++) { |
|
306 |
+ for (j = 0; j < sec_order_sizes[i]; j++) { |
|
307 |
+ for (k = 0; k < 4; k++) { |
|
308 |
+ model_init(&ctx->sec_models[i][j][k], 2 + i, |
|
309 |
+ i ? THRESH_LOW : THRESH_ADAPTIVE); |
|
310 |
+ } |
|
311 |
+ } |
|
312 |
+ } |
|
313 |
+} |
|
314 |
+ |
|
315 |
+static int decode_top_left_pixel(ArithCoder *acoder, PixContext *pctx) |
|
316 |
+{ |
|
317 |
+ int i, val, pix; |
|
318 |
+ |
|
319 |
+ val = arith_get_model_sym(acoder, &pctx->cache_model); |
|
320 |
+ if (val < pctx->num_syms) { |
|
321 |
+ pix = pctx->cache[val]; |
|
322 |
+ } else { |
|
323 |
+ pix = arith_get_model_sym(acoder, &pctx->full_model); |
|
324 |
+ for (i = 0; i < pctx->cache_size - 1; i++) |
|
325 |
+ if (pctx->cache[i] == pix) |
|
326 |
+ break; |
|
327 |
+ val = i; |
|
328 |
+ } |
|
329 |
+ if (val) { |
|
330 |
+ for (i = val; i > 0; i--) |
|
331 |
+ pctx->cache[i] = pctx->cache[i - 1]; |
|
332 |
+ pctx->cache[0] = pix; |
|
333 |
+ } |
|
334 |
+ |
|
335 |
+ return pix; |
|
336 |
+} |
|
337 |
+ |
|
338 |
+static int decode_pixel(ArithCoder *acoder, PixContext *pctx, |
|
339 |
+ uint8_t *ngb, int num_ngb) |
|
340 |
+{ |
|
341 |
+ int i, val, pix; |
|
342 |
+ |
|
343 |
+ val = arith_get_model_sym(acoder, &pctx->cache_model); |
|
344 |
+ if (val < pctx->num_syms) { |
|
345 |
+ int idx, j; |
|
346 |
+ |
|
347 |
+ |
|
348 |
+ idx = 0; |
|
349 |
+ for (i = 0; i < pctx->cache_size; i++) { |
|
350 |
+ for (j = 0; j < num_ngb; j++) |
|
351 |
+ if (pctx->cache[i] == ngb[j]) |
|
352 |
+ break; |
|
353 |
+ if (j == num_ngb) { |
|
354 |
+ if (idx == val) |
|
355 |
+ break; |
|
356 |
+ idx++; |
|
357 |
+ } |
|
358 |
+ } |
|
359 |
+ val = FFMIN(i, pctx->cache_size - 1); |
|
360 |
+ pix = pctx->cache[val]; |
|
361 |
+ } else { |
|
362 |
+ pix = arith_get_model_sym(acoder, &pctx->full_model); |
|
363 |
+ for (i = 0; i < pctx->cache_size - 1; i++) |
|
364 |
+ if (pctx->cache[i] == pix) |
|
365 |
+ break; |
|
366 |
+ val = i; |
|
367 |
+ } |
|
368 |
+ if (val) { |
|
369 |
+ for (i = val; i > 0; i--) |
|
370 |
+ pctx->cache[i] = pctx->cache[i - 1]; |
|
371 |
+ pctx->cache[0] = pix; |
|
372 |
+ } |
|
373 |
+ |
|
374 |
+ return pix; |
|
375 |
+} |
|
376 |
+ |
|
377 |
+static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx, |
|
378 |
+ uint8_t *src, int stride, int x, int y, |
|
379 |
+ int has_right) |
|
380 |
+{ |
|
381 |
+ uint8_t neighbours[4]; |
|
382 |
+ uint8_t ref_pix[4]; |
|
383 |
+ int nlen; |
|
384 |
+ int layer = 0, sub; |
|
385 |
+ int pix; |
|
386 |
+ int i, j; |
|
387 |
+ |
|
388 |
+ if (!y) { |
|
389 |
+ memset(neighbours, src[-1], 4); |
|
390 |
+ } else { |
|
391 |
+ neighbours[TOP] = src[-stride]; |
|
392 |
+ if (!x) { |
|
393 |
+ neighbours[TOP_LEFT] = neighbours[LEFT] = neighbours[TOP]; |
|
394 |
+ } else { |
|
395 |
+ neighbours[TOP_LEFT] = src[-stride - 1]; |
|
396 |
+ neighbours[ LEFT] = src[-1]; |
|
397 |
+ } |
|
398 |
+ if (has_right) |
|
399 |
+ neighbours[TOP_RIGHT] = src[-stride + 1]; |
|
400 |
+ else |
|
401 |
+ neighbours[TOP_RIGHT] = neighbours[TOP]; |
|
402 |
+ } |
|
403 |
+ |
|
404 |
+ sub = 0; |
|
405 |
+ if (x >= 2 && src[-2] == neighbours[LEFT]) |
|
406 |
+ sub = 1; |
|
407 |
+ if (y >= 2 && src[-2 * stride] == neighbours[TOP]) |
|
408 |
+ sub |= 2; |
|
409 |
+ |
|
410 |
+ nlen = 1; |
|
411 |
+ ref_pix[0] = neighbours[0]; |
|
412 |
+ for (i = 1; i < 4; i++) { |
|
413 |
+ for (j = 0; j < nlen; j++) |
|
414 |
+ if (ref_pix[j] == neighbours[i]) |
|
415 |
+ break; |
|
416 |
+ if (j == nlen) |
|
417 |
+ ref_pix[nlen++] = neighbours[i]; |
|
418 |
+ } |
|
419 |
+ |
|
420 |
+ switch (nlen) { |
|
421 |
+ case 1: |
|
422 |
+ case 4: |
|
423 |
+ layer = 0; |
|
424 |
+ break; |
|
425 |
+ case 2: |
|
426 |
+ if (neighbours[TOP] == neighbours[TOP_LEFT]) { |
|
427 |
+ if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT]) |
|
428 |
+ layer = 3; |
|
429 |
+ else if (neighbours[LEFT] == neighbours[TOP_LEFT]) |
|
430 |
+ layer = 2; |
|
431 |
+ else |
|
432 |
+ layer = 4; |
|
433 |
+ } else if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT]) { |
|
434 |
+ if (neighbours[LEFT] == neighbours[TOP_LEFT]) |
|
435 |
+ layer = 1; |
|
436 |
+ else |
|
437 |
+ layer = 5; |
|
438 |
+ } else if (neighbours[LEFT] == neighbours[TOP_LEFT]) { |
|
439 |
+ layer = 6; |
|
440 |
+ } else { |
|
441 |
+ layer = 0; |
|
442 |
+ } |
|
443 |
+ break; |
|
444 |
+ case 3: |
|
445 |
+ if (neighbours[TOP] == neighbours[TOP_LEFT]) |
|
446 |
+ layer = 0; |
|
447 |
+ else if (neighbours[TOP_RIGHT] == neighbours[TOP_LEFT]) |
|
448 |
+ layer = 1; |
|
449 |
+ else if (neighbours[LEFT] == neighbours[TOP_LEFT]) |
|
450 |
+ layer = 2; |
|
451 |
+ else if (neighbours[TOP_RIGHT] == neighbours[TOP]) |
|
452 |
+ layer = 3; |
|
453 |
+ else if (neighbours[TOP] == neighbours[LEFT]) |
|
454 |
+ layer = 4; |
|
455 |
+ else |
|
456 |
+ layer = 5; |
|
457 |
+ break; |
|
458 |
+ } |
|
459 |
+ |
|
460 |
+ pix = arith_get_model_sym(acoder, &pctx->sec_models[nlen - 1][layer][sub]); |
|
461 |
+ if (pix < nlen) |
|
462 |
+ return ref_pix[pix]; |
|
463 |
+ else |
|
464 |
+ return decode_pixel(acoder, pctx, ref_pix, nlen); |
|
465 |
+} |
|
466 |
+ |
|
467 |
+static int decode_region(MSS1Context *ctx, ArithCoder *acoder, uint8_t *dst, |
|
468 |
+ int x, int y, int width, int height, int stride, |
|
469 |
+ PixContext *pctx) |
|
470 |
+{ |
|
471 |
+ int i, j; |
|
472 |
+ |
|
473 |
+ dst += x + y * stride; |
|
474 |
+ |
|
475 |
+ dst[0] = decode_top_left_pixel(acoder, pctx); |
|
476 |
+ for (j = 0; j < height; j++) { |
|
477 |
+ for (i = 0; i < width; i++) { |
|
478 |
+ if (!i && !j) |
|
479 |
+ continue; |
|
480 |
+ |
|
481 |
+ dst[i] = decode_pixel_in_context(acoder, pctx, dst + i, stride, |
|
482 |
+ i, j, width - i - 1); |
|
483 |
+ } |
|
484 |
+ dst += stride; |
|
485 |
+ } |
|
486 |
+ |
|
487 |
+ return 0; |
|
488 |
+} |
|
489 |
+ |
|
490 |
+static int decode_region_masked(MSS1Context *ctx, ArithCoder *acoder, |
|
491 |
+ uint8_t *dst, int stride, uint8_t *mask, |
|
492 |
+ int mask_stride, int x, int y, |
|
493 |
+ int width, int height, |
|
494 |
+ PixContext *pctx) |
|
495 |
+{ |
|
496 |
+ int i, j; |
|
497 |
+ |
|
498 |
+ dst += x + y * stride; |
|
499 |
+ mask += x + y * mask_stride; |
|
500 |
+ |
|
501 |
+ if (mask[0] != 0xFF) |
|
502 |
+ dst[0] = decode_top_left_pixel(acoder, pctx); |
|
503 |
+ for (j = 0; j < height; j++) { |
|
504 |
+ for (i = 0; i < width; i++) { |
|
505 |
+ if (!i && !j || mask[i] != 0xFF) |
|
506 |
+ continue; |
|
507 |
+ |
|
508 |
+ dst[i] = decode_pixel_in_context(acoder, pctx, dst + i, stride, |
|
509 |
+ i, j, width - i - 1); |
|
510 |
+ } |
|
511 |
+ dst += stride; |
|
512 |
+ mask += mask_stride; |
|
513 |
+ } |
|
514 |
+ |
|
515 |
+ return 0; |
|
516 |
+} |
|
517 |
+ |
|
518 |
+static av_cold void codec_init(MSS1Context *ctx) |
|
519 |
+{ |
|
520 |
+ model_init(&ctx->intra_region, 2, THRESH_ADAPTIVE); |
|
521 |
+ model_init(&ctx->inter_region, 2, THRESH_ADAPTIVE); |
|
522 |
+ model_init(&ctx->split_mode, 3, THRESH_HIGH); |
|
523 |
+ model_init(&ctx->edge_mode, 2, THRESH_HIGH); |
|
524 |
+ model_init(&ctx->pivot, 3, THRESH_LOW); |
|
525 |
+ pixctx_init(&ctx->intra_pix_ctx, 8); |
|
526 |
+ pixctx_init(&ctx->inter_pix_ctx, 2); |
|
527 |
+ ctx->corrupted = 1; |
|
528 |
+} |
|
529 |
+ |
|
530 |
+static void codec_reset(MSS1Context *ctx) |
|
531 |
+{ |
|
532 |
+ model_reset(&ctx->intra_region); |
|
533 |
+ model_reset(&ctx->inter_region); |
|
534 |
+ model_reset(&ctx->split_mode); |
|
535 |
+ model_reset(&ctx->edge_mode); |
|
536 |
+ model_reset(&ctx->pivot); |
|
537 |
+ pixctx_reset(&ctx->intra_pix_ctx); |
|
538 |
+ pixctx_reset(&ctx->inter_pix_ctx); |
|
539 |
+ |
|
540 |
+ ctx->corrupted = 0; |
|
541 |
+} |
|
542 |
+ |
|
543 |
+static int decode_pal(MSS1Context *ctx, ArithCoder *acoder) |
|
544 |
+{ |
|
545 |
+ int i, ncol, r, g, b; |
|
546 |
+ uint32_t *pal = ctx->pal + 256 - ctx->free_colours; |
|
547 |
+ |
|
548 |
+ if (!ctx->free_colours) |
|
549 |
+ return 0; |
|
550 |
+ |
|
551 |
+ ncol = arith_get_number(acoder, ctx->free_colours + 1); |
|
552 |
+ for (i = 0; i < ncol; i++) { |
|
553 |
+ r = arith_get_bits(acoder, 8); |
|
554 |
+ g = arith_get_bits(acoder, 8); |
|
555 |
+ b = arith_get_bits(acoder, 8); |
|
556 |
+ *pal++ = (r << 16) | (g << 8) | b; |
|
557 |
+ } |
|
558 |
+ |
|
559 |
+ return 0; |
|
560 |
+} |
|
561 |
+ |
|
562 |
+static int decode_pivot(MSS1Context *ctx, ArithCoder *acoder, int base) |
|
563 |
+{ |
|
564 |
+ int val, inv; |
|
565 |
+ |
|
566 |
+ inv = arith_get_model_sym(acoder, &ctx->edge_mode); |
|
567 |
+ val = arith_get_model_sym(acoder, &ctx->pivot) + 1; |
|
568 |
+ |
|
569 |
+ if (val > 2) { |
|
570 |
+ if ((base + 1) / 2 - 2 <= 0) { |
|
571 |
+ ctx->corrupted = 1; |
|
572 |
+ return 0; |
|
573 |
+ } |
|
574 |
+ val = arith_get_number(acoder, (base + 1) / 2 - 2) + 3; |
|
575 |
+ } |
|
576 |
+ |
|
577 |
+ if (val == base) { |
|
578 |
+ ctx->corrupted = 1; |
|
579 |
+ return 0; |
|
580 |
+ } |
|
581 |
+ |
|
582 |
+ return inv ? base - val : val; |
|
583 |
+} |
|
584 |
+ |
|
585 |
+static int decode_region_intra(MSS1Context *ctx, ArithCoder *acoder, |
|
586 |
+ int x, int y, int width, int height) |
|
587 |
+{ |
|
588 |
+ int mode; |
|
589 |
+ |
|
590 |
+ mode = arith_get_model_sym(acoder, &ctx->intra_region); |
|
591 |
+ |
|
592 |
+ if (!mode) { |
|
593 |
+ int i, pix; |
|
594 |
+ int stride = ctx->pic_stride; |
|
595 |
+ uint8_t *dst = ctx->pic_start + x + y * stride; |
|
596 |
+ |
|
597 |
+ pix = decode_top_left_pixel(acoder, &ctx->intra_pix_ctx); |
|
598 |
+ for (i = 0; i < height; i++, dst += stride) |
|
599 |
+ memset(dst, pix, width); |
|
600 |
+ } else { |
|
601 |
+ return decode_region(ctx, acoder, ctx->pic_start, |
|
602 |
+ x, y, width, height, ctx->pic_stride, |
|
603 |
+ &ctx->intra_pix_ctx); |
|
604 |
+ } |
|
605 |
+ |
|
606 |
+ return 0; |
|
607 |
+} |
|
608 |
+ |
|
609 |
+static int decode_intra(MSS1Context *ctx, ArithCoder *acoder, |
|
610 |
+ int x, int y, int width, int height) |
|
611 |
+{ |
|
612 |
+ int mode, pivot; |
|
613 |
+ |
|
614 |
+ if (ctx->corrupted) |
|
615 |
+ return -1; |
|
616 |
+ |
|
617 |
+ mode = arith_get_model_sym(acoder, &ctx->split_mode); |
|
618 |
+ |
|
619 |
+ switch (mode) { |
|
620 |
+ case SPLIT_VERT: |
|
621 |
+ pivot = decode_pivot(ctx, acoder, height); |
|
622 |
+ if (ctx->corrupted) |
|
623 |
+ return -1; |
|
624 |
+ if (decode_intra(ctx, acoder, x, y, width, pivot)) |
|
625 |
+ return -1; |
|
626 |
+ if (decode_intra(ctx, acoder, x, y + pivot, width, height - pivot)) |
|
627 |
+ return -1; |
|
628 |
+ break; |
|
629 |
+ case SPLIT_HOR: |
|
630 |
+ pivot = decode_pivot(ctx, acoder, width); |
|
631 |
+ if (ctx->corrupted) |
|
632 |
+ return -1; |
|
633 |
+ if (decode_intra(ctx, acoder, x, y, pivot, height)) |
|
634 |
+ return -1; |
|
635 |
+ if (decode_intra(ctx, acoder, x + pivot, y, width - pivot, height)) |
|
636 |
+ return -1; |
|
637 |
+ break; |
|
638 |
+ case SPLIT_NONE: |
|
639 |
+ return decode_region_intra(ctx, acoder, x, y, width, height); |
|
640 |
+ default: |
|
641 |
+ return -1; |
|
642 |
+ } |
|
643 |
+ |
|
644 |
+ return 0; |
|
645 |
+} |
|
646 |
+ |
|
647 |
+static int decode_region_inter(MSS1Context *ctx, ArithCoder *acoder, |
|
648 |
+ int x, int y, int width, int height) |
|
649 |
+{ |
|
650 |
+ int mode; |
|
651 |
+ |
|
652 |
+ mode = arith_get_model_sym(acoder, &ctx->inter_region); |
|
653 |
+ |
|
654 |
+ if (!mode) { |
|
655 |
+ mode = decode_top_left_pixel(acoder, &ctx->inter_pix_ctx); |
|
656 |
+ if (mode != 0xFF) { |
|
657 |
+ return 0; |
|
658 |
+ } else { |
|
659 |
+ return decode_region_intra(ctx, acoder, x, y, width, height); |
|
660 |
+ } |
|
661 |
+ } else { |
|
662 |
+ if (decode_region(ctx, acoder, ctx->mask, |
|
663 |
+ x, y, width, height, ctx->mask_linesize, |
|
664 |
+ &ctx->inter_pix_ctx) < 0) |
|
665 |
+ return -1; |
|
666 |
+ return decode_region_masked(ctx, acoder, ctx->pic_start, |
|
667 |
+ -ctx->pic.linesize[0], ctx->mask, |
|
668 |
+ ctx->mask_linesize, |
|
669 |
+ x, y, width, height, |
|
670 |
+ &ctx->intra_pix_ctx); |
|
671 |
+ } |
|
672 |
+ |
|
673 |
+ return 0; |
|
674 |
+} |
|
675 |
+ |
|
676 |
+static int decode_inter(MSS1Context *ctx, ArithCoder *acoder, |
|
677 |
+ int x, int y, int width, int height) |
|
678 |
+{ |
|
679 |
+ int mode, pivot; |
|
680 |
+ |
|
681 |
+ if (ctx->corrupted) |
|
682 |
+ return -1; |
|
683 |
+ |
|
684 |
+ mode = arith_get_model_sym(acoder, &ctx->split_mode); |
|
685 |
+ |
|
686 |
+ switch (mode) { |
|
687 |
+ case SPLIT_VERT: |
|
688 |
+ pivot = decode_pivot(ctx, acoder, height); |
|
689 |
+ if (decode_inter(ctx, acoder, x, y, width, pivot)) |
|
690 |
+ return -1; |
|
691 |
+ if (decode_inter(ctx, acoder, x, y + pivot, width, height - pivot)) |
|
692 |
+ return -1; |
|
693 |
+ break; |
|
694 |
+ case SPLIT_HOR: |
|
695 |
+ pivot = decode_pivot(ctx, acoder, width); |
|
696 |
+ if (decode_inter(ctx, acoder, x, y, pivot, height)) |
|
697 |
+ return -1; |
|
698 |
+ if (decode_inter(ctx, acoder, x + pivot, y, width - pivot, height)) |
|
699 |
+ return -1; |
|
700 |
+ break; |
|
701 |
+ case SPLIT_NONE: |
|
702 |
+ return decode_region_inter(ctx, acoder, x, y, width, height); |
|
703 |
+ default: |
|
704 |
+ return -1; |
|
705 |
+ } |
|
706 |
+ |
|
707 |
+ return 0; |
|
708 |
+} |
|
709 |
+ |
|
710 |
+static int mss1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
|
711 |
+ AVPacket *avpkt) |
|
712 |
+{ |
|
713 |
+ const uint8_t *buf = avpkt->data; |
|
714 |
+ int buf_size = avpkt->size; |
|
715 |
+ MSS1Context *c = avctx->priv_data; |
|
716 |
+ GetBitContext gb; |
|
717 |
+ ArithCoder acoder; |
|
718 |
+ int pal_changed = 0; |
|
719 |
+ int ret; |
|
720 |
+ |
|
721 |
+ init_get_bits(&gb, buf, buf_size * 8); |
|
722 |
+ arith_init(&acoder, &gb); |
|
723 |
+ |
|
724 |
+ c->pic.reference = 3; |
|
725 |
+ c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | |
|
726 |
+ FF_BUFFER_HINTS_REUSABLE; |
|
727 |
+ if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) { |
|
728 |
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
|
729 |
+ return ret; |
|
730 |
+ } |
|
731 |
+ |
|
732 |
+ c->pic_start = c->pic.data[0] + c->pic.linesize[0] * (avctx->height - 1); |
|
733 |
+ c->pic_stride = -c->pic.linesize[0]; |
|
734 |
+ if (!arith_get_bit(&acoder)) { |
|
735 |
+ codec_reset(c); |
|
736 |
+ pal_changed = decode_pal(c, &acoder); |
|
737 |
+ c->corrupted = decode_intra(c, &acoder, 0, 0, |
|
738 |
+ avctx->width, avctx->height); |
|
739 |
+ c->pic.key_frame = 1; |
|
740 |
+ c->pic.pict_type = AV_PICTURE_TYPE_I; |
|
741 |
+ } else { |
|
742 |
+ if (c->corrupted) |
|
743 |
+ return AVERROR_INVALIDDATA; |
|
744 |
+ c->corrupted = decode_inter(c, &acoder, 0, 0, |
|
745 |
+ avctx->width, avctx->height); |
|
746 |
+ c->pic.key_frame = 0; |
|
747 |
+ c->pic.pict_type = AV_PICTURE_TYPE_P; |
|
748 |
+ } |
|
749 |
+ if (c->corrupted) |
|
750 |
+ return AVERROR_INVALIDDATA; |
|
751 |
+ memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE); |
|
752 |
+ c->pic.palette_has_changed = pal_changed; |
|
753 |
+ |
|
754 |
+ *data_size = sizeof(AVFrame); |
|
755 |
+ *(AVFrame*)data = c->pic; |
|
756 |
+ |
|
757 |
+ /* always report that the buffer was completely consumed */ |
|
758 |
+ return buf_size; |
|
759 |
+} |
|
760 |
+ |
|
761 |
+static av_cold int mss1_decode_init(AVCodecContext *avctx) |
|
762 |
+{ |
|
763 |
+ MSS1Context * const c = avctx->priv_data; |
|
764 |
+ int i; |
|
765 |
+ |
|
766 |
+ c->avctx = avctx; |
|
767 |
+ |
|
768 |
+ if (avctx->extradata_size < 52 + 256 * 3) { |
|
769 |
+ av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d\n", |
|
770 |
+ avctx->extradata_size); |
|
771 |
+ return AVERROR_INVALIDDATA; |
|
772 |
+ } |
|
773 |
+ |
|
774 |
+ if (AV_RB32(avctx->extradata) < avctx->extradata_size) { |
|
775 |
+ av_log(avctx, AV_LOG_ERROR, |
|
776 |
+ "Insufficient extradata size: expected %d got %d\n", |
|
777 |
+ AV_RB32(avctx->extradata), |
|
778 |
+ avctx->extradata_size); |
|
779 |
+ return AVERROR_INVALIDDATA; |
|
780 |
+ } |
|
781 |
+ |
|
782 |
+ av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d\n", |
|
783 |
+ AV_RB32(avctx->extradata + 4), AV_RB32(avctx->extradata + 8)); |
|
784 |
+ c->free_colours = AV_RB32(avctx->extradata + 48); |
|
785 |
+ av_log(avctx, AV_LOG_DEBUG, "%d free colour(s)\n", c->free_colours); |
|
786 |
+ avctx->coded_width = AV_RB32(avctx->extradata + 20); |
|
787 |
+ avctx->coded_height = AV_RB32(avctx->extradata + 24); |
|
788 |
+ |
|
789 |
+ av_log(avctx, AV_LOG_DEBUG, "Display dimensions %dx%d\n", |
|
790 |
+ AV_RB32(avctx->extradata + 12), AV_RB32(avctx->extradata + 16)); |
|
791 |
+ av_log(avctx, AV_LOG_DEBUG, "Coded dimensions %dx%d\n", |
|
792 |
+ avctx->coded_width, avctx->coded_height); |
|
793 |
+ av_log(avctx, AV_LOG_DEBUG, "%g frames per second\n", |
|
794 |
+ av_int2float(AV_RB32(avctx->extradata + 28))); |
|
795 |
+ av_log(avctx, AV_LOG_DEBUG, "Bitrate %d bps\n", |
|
796 |
+ AV_RB32(avctx->extradata + 32)); |
|
797 |
+ av_log(avctx, AV_LOG_DEBUG, "Max. lead time %g ms\n", |
|
798 |
+ av_int2float(AV_RB32(avctx->extradata + 36))); |
|
799 |
+ av_log(avctx, AV_LOG_DEBUG, "Max. lag time %g ms\n", |
|
800 |
+ av_int2float(AV_RB32(avctx->extradata + 40))); |
|
801 |
+ av_log(avctx, AV_LOG_DEBUG, "Max. seek time %g ms\n", |
|
802 |
+ av_int2float(AV_RB32(avctx->extradata + 44))); |
|
803 |
+ |
|
804 |
+ for (i = 0; i < 256; i++) |
|
805 |
+ c->pal[i] = AV_RB24(avctx->extradata + 52 + i * 3); |
|
806 |
+ |
|
807 |
+ avctx->pix_fmt = PIX_FMT_PAL8; |
|
808 |
+ |
|
809 |
+ c->mask_linesize = FFALIGN(avctx->width, 16); |
|
810 |
+ c->mask = av_malloc(c->mask_linesize * avctx->height); |
|
811 |
+ if (!c->mask) { |
|
812 |
+ av_log(avctx, AV_LOG_ERROR, "Cannot allocate mask plane\n"); |
|
813 |
+ return AVERROR(ENOMEM); |
|
814 |
+ } |
|
815 |
+ |
|
816 |
+ avctx->coded_frame = &c->pic; |
|
817 |
+ |
|
818 |
+ codec_init(c); |
|
819 |
+ |
|
820 |
+ return 0; |
|
821 |
+} |
|
822 |
+ |
|
823 |
+static av_cold int mss1_decode_end(AVCodecContext *avctx) |
|
824 |
+{ |
|
825 |
+ MSS1Context * const c = avctx->priv_data; |
|
826 |
+ |
|
827 |
+ if (c->pic.data[0]) |
|
828 |
+ avctx->release_buffer(avctx, &c->pic); |
|
829 |
+ av_freep(&c->mask); |
|
830 |
+ |
|
831 |
+ return 0; |
|
832 |
+} |
|
833 |
+ |
|
834 |
+AVCodec ff_mss1_decoder = { |
|
835 |
+ .name = "mss1", |
|
836 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
837 |
+ .id = CODEC_ID_MSS1, |
|
838 |
+ .priv_data_size = sizeof(MSS1Context), |
|
839 |
+ .init = mss1_decode_init, |
|
840 |
+ .close = mss1_decode_end, |
|
841 |
+ .decode = mss1_decode_frame, |
|
842 |
+ .capabilities = CODEC_CAP_DR1, |
|
843 |
+ .long_name = NULL_IF_CONFIG_SMALL("MS Screen 1"), |
|
844 |
+}; |
... | ... |
@@ -1854,10 +1854,9 @@ void av_dump_format(AVFormatContext *ic, |
1854 | 1854 |
const char *url, |
1855 | 1855 |
int is_output); |
1856 | 1856 |
|
1857 |
-/** |
|
1858 |
- * Get the current time in microseconds. |
|
1859 |
- */ |
|
1857 |
+#if FF_API_AV_GETTIME |
|
1860 | 1858 |
int64_t av_gettime(void); |
1859 |
+#endif |
|
1861 | 1860 |
|
1862 | 1861 |
/** |
1863 | 1862 |
* Return in 'buf' the path with '%d' replaced by a number. |
... | ... |
@@ -144,7 +144,7 @@ static int send_command_packet(MMSTContext *mmst) |
144 | 144 |
av_log(NULL, AV_LOG_ERROR, |
145 | 145 |
"Failed to write data of length %d: %d (%s)\n", |
146 | 146 |
exact_length, write_result, |
147 |
- write_result < 0 ? strerror(write_result) : |
|
147 |
+ write_result < 0 ? strerror(AVUNERROR(write_result)) : |
|
148 | 148 |
"The server closed the connection"); |
149 | 149 |
return AVERROR(EIO); |
150 | 150 |
} |
... | ... |
@@ -246,7 +246,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) |
246 | 246 |
if(read_result < 0) { |
247 | 247 |
av_log(NULL, AV_LOG_ERROR, |
248 | 248 |
"Error reading packet header: %d (%s)\n", |
249 |
- read_result, strerror(read_result)); |
|
249 |
+ read_result, strerror(AVUNERROR(read_result))); |
|
250 | 250 |
packet_type = SC_PKT_CANCEL; |
251 | 251 |
} else { |
252 | 252 |
av_log(NULL, AV_LOG_ERROR, |
... | ... |
@@ -266,7 +266,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) |
266 | 266 |
av_log(NULL, AV_LOG_ERROR, |
267 | 267 |
"Reading command packet length failed: %d (%s)\n", |
268 | 268 |
read_result, |
269 |
- read_result < 0 ? strerror(read_result) : |
|
269 |
+ read_result < 0 ? strerror(AVUNERROR(read_result)) : |
|
270 | 270 |
"The server closed the connection"); |
271 | 271 |
return read_result < 0 ? read_result : AVERROR(EIO); |
272 | 272 |
} |
... | ... |
@@ -287,7 +287,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) |
287 | 287 |
av_log(NULL, AV_LOG_ERROR, |
288 | 288 |
"Reading pkt data (length=%d) failed: %d (%s)\n", |
289 | 289 |
length_remaining, read_result, |
290 |
- read_result < 0 ? strerror(read_result) : |
|
290 |
+ read_result < 0 ? strerror(AVUNERROR(read_result)) : |
|
291 | 291 |
"The server closed the connection"); |
292 | 292 |
return read_result < 0 ? read_result : AVERROR(EIO); |
293 | 293 |
} |
... | ... |
@@ -324,7 +324,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) |
324 | 324 |
av_log(NULL, AV_LOG_ERROR, |
325 | 325 |
"Failed to read packet data of size %d: %d (%s)\n", |
326 | 326 |
length_remaining, read_result, |
327 |
- read_result < 0 ? strerror(read_result) : |
|
327 |
+ read_result < 0 ? strerror(AVUNERROR(read_result)) : |
|
328 | 328 |
"The server closed the connection"); |
329 | 329 |
return read_result < 0 ? read_result : AVERROR(EIO); |
330 | 330 |
} |
... | ... |
@@ -1087,7 +1087,7 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
1087 | 1087 |
return AVERROR_INVALIDDATA; |
1088 | 1088 |
|
1089 | 1089 |
profile_level = avio_r8(pb); |
1090 |
- if (profile_level & 0xf0 != 0xc0) |
|
1090 |
+ if ((profile_level & 0xf0) != 0xc0) |
|
1091 | 1091 |
return 0; |
1092 | 1092 |
|
1093 | 1093 |
av_free(st->codec->extradata); |
... | ... |
@@ -47,6 +47,8 @@ |
47 | 47 |
# undef EINPROGRESS |
48 | 48 |
#endif |
49 | 49 |
#define EINPROGRESS WSAEINPROGRESS |
50 |
+#define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e) |
|
51 |
+#define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e) |
|
50 | 52 |
|
51 | 53 |
int ff_neterrno(void); |
52 | 54 |
#else |
... | ... |
@@ -58,7 +58,6 @@ int ff_win32_open(const char *filename_utf8, int oflag, int pmode) |
58 | 58 |
|
59 | 59 |
#if CONFIG_NETWORK |
60 | 60 |
#include <fcntl.h> |
61 |
-#include <unistd.h> |
|
62 | 61 |
#if !HAVE_POLL_H |
63 | 62 |
#include <sys/time.h> |
64 | 63 |
#if HAVE_WINSOCK2_H |
... | ... |
@@ -253,7 +252,8 @@ const char *ff_gai_strerror(int ecode) |
253 | 253 |
int ff_socket_nonblock(int socket, int enable) |
254 | 254 |
{ |
255 | 255 |
#if HAVE_WINSOCK2_H |
256 |
- return ioctlsocket(socket, FIONBIO, &enable); |
|
256 |
+ u_long param = enable; |
|
257 |
+ return ioctlsocket(socket, FIONBIO, ¶m); |
|
257 | 258 |
#else |
258 | 259 |
if (enable) |
259 | 260 |
return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK); |
... | ... |
@@ -307,6 +307,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { |
307 | 307 |
{ CODEC_ID_Y41P, MKTAG('Y', '4', '1', 'P') }, |
308 | 308 |
{ CODEC_ID_FLIC, MKTAG('A', 'F', 'L', 'C') }, |
309 | 309 |
{ CODEC_ID_EXR, MKTAG('e', 'x', 'r', ' ') }, |
310 |
+ { CODEC_ID_MSS1, MKTAG('M', 'S', 'S', '1') }, |
|
310 | 311 |
{ CODEC_ID_NONE, 0 } |
311 | 312 |
}; |
312 | 313 |
|
... | ... |
@@ -24,6 +24,8 @@ |
24 | 24 |
* RTMP HTTP protocol |
25 | 25 |
*/ |
26 | 26 |
|
27 |
+#include <unistd.h> |
|
28 |
+ |
|
27 | 29 |
#include "libavutil/avstring.h" |
28 | 30 |
#include "libavutil/intfloat.h" |
29 | 31 |
#include "libavutil/opt.h" |
... | ... |
@@ -44,6 +46,7 @@ typedef struct RTMP_HTTPContext { |
44 | 44 |
int out_capacity; ///< current output buffer capacity |
45 | 45 |
int initialized; ///< flag indicating when the http context is initialized |
46 | 46 |
int finishing; ///< flag indicating when the client closes the connection |
47 |
+ int nb_bytes_read; ///< number of bytes read since the last request |
|
47 | 48 |
} RTMP_HTTPContext; |
48 | 49 |
|
49 | 50 |
static int rtmp_http_send_cmd(URLContext *h, const char *cmd) |
... | ... |
@@ -70,6 +73,9 @@ static int rtmp_http_send_cmd(URLContext *h, const char *cmd) |
70 | 70 |
if ((ret = ffurl_read(rt->stream, &c, 1)) < 0) |
71 | 71 |
return ret; |
72 | 72 |
|
73 |
+ /* re-init the number of bytes read */ |
|
74 |
+ rt->nb_bytes_read = 0; |
|
75 |
+ |
|
73 | 76 |
return ret; |
74 | 77 |
} |
75 | 78 |
|
... | ... |
@@ -117,6 +123,12 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size) |
117 | 117 |
if ((ret = rtmp_http_send_cmd(h, "send")) < 0) |
118 | 118 |
return ret; |
119 | 119 |
} else { |
120 |
+ if (rt->nb_bytes_read == 0) { |
|
121 |
+ /* Wait 50ms before retrying to read a server reply in |
|
122 |
+ * order to reduce the number of idle requets. */ |
|
123 |
+ usleep(50000); |
|
124 |
+ } |
|
125 |
+ |
|
120 | 126 |
if ((ret = rtmp_http_write(h, "", 1)) < 0) |
121 | 127 |
return ret; |
122 | 128 |
|
... | ... |
@@ -131,6 +143,7 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size) |
131 | 131 |
} else { |
132 | 132 |
off += ret; |
133 | 133 |
size -= ret; |
134 |
+ rt->nb_bytes_read += ret; |
|
134 | 135 |
} |
135 | 136 |
} while (off <= 0); |
136 | 137 |
|
... | ... |
@@ -31,7 +31,6 @@ |
31 | 31 |
#include "rtpdec.h" |
32 | 32 |
#include "url.h" |
33 | 33 |
|
34 |
-#include <unistd.h> |
|
35 | 34 |
#include <stdarg.h> |
36 | 35 |
#include "internal.h" |
37 | 36 |
#include "network.h" |
... | ... |
@@ -40,7 +39,6 @@ |
40 | 40 |
#if HAVE_POLL_H |
41 | 41 |
#include <sys/poll.h> |
42 | 42 |
#endif |
43 |
-#include <sys/time.h> |
|
44 | 43 |
|
45 | 44 |
#define RTP_TX_BUF_SIZE (64 * 1024) |
46 | 45 |
#define RTP_RX_BUF_SIZE (128 * 1024) |
... | ... |
@@ -28,7 +28,6 @@ |
28 | 28 |
#if HAVE_POLL_H |
29 | 29 |
#include <poll.h> |
30 | 30 |
#endif |
31 |
-#include <sys/time.h> |
|
32 | 31 |
|
33 | 32 |
typedef struct TCPContext { |
34 | 33 |
int fd; |
... | ... |
@@ -139,12 +138,15 @@ static int tcp_open(URLContext *h, const char *uri, int flags) |
139 | 139 |
} |
140 | 140 |
/* test error */ |
141 | 141 |
optlen = sizeof(ret); |
142 |
- getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); |
|
142 |
+ if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) |
|
143 |
+ ret = AVUNERROR(ff_neterrno()); |
|
143 | 144 |
if (ret != 0) { |
145 |
+ char errbuf[100]; |
|
146 |
+ ret = AVERROR(ret); |
|
147 |
+ av_strerror(ret, errbuf, sizeof(errbuf)); |
|
144 | 148 |
av_log(h, AV_LOG_ERROR, |
145 | 149 |
"TCP connection to %s:%d failed: %s\n", |
146 |
- hostname, port, strerror(ret)); |
|
147 |
- ret = AVERROR(ret); |
|
150 |
+ hostname, port, errbuf); |
|
148 | 151 |
goto fail; |
149 | 152 |
} |
150 | 153 |
} |
... | ... |
@@ -42,8 +42,6 @@ |
42 | 42 |
#include <pthread.h> |
43 | 43 |
#endif |
44 | 44 |
|
45 |
-#include <sys/time.h> |
|
46 |
- |
|
47 | 45 |
#ifndef IPV6_ADD_MEMBERSHIP |
48 | 46 |
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP |
49 | 47 |
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP |
... | ... |
@@ -78,13 +76,20 @@ typedef struct { |
78 | 78 |
int remaining_in_dg; |
79 | 79 |
} UDPContext; |
80 | 80 |
|
81 |
+static void log_net_error(void *ctx, int level, const char* prefix) |
|
82 |
+{ |
|
83 |
+ char errbuf[100]; |
|
84 |
+ av_strerror(ff_neterrno(), errbuf, sizeof(errbuf)); |
|
85 |
+ av_log(ctx, level, "%s: %s\n", prefix, errbuf); |
|
86 |
+} |
|
87 |
+ |
|
81 | 88 |
static int udp_set_multicast_ttl(int sockfd, int mcastTTL, |
82 | 89 |
struct sockaddr *addr) |
83 | 90 |
{ |
84 | 91 |
#ifdef IP_MULTICAST_TTL |
85 | 92 |
if (addr->sa_family == AF_INET) { |
86 | 93 |
if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { |
87 |
- av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL): %s\n", strerror(errno)); |
|
94 |
+ log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); |
|
88 | 95 |
return -1; |
89 | 96 |
} |
90 | 97 |
} |
... | ... |
@@ -92,7 +97,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, |
92 | 92 |
#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS) |
93 | 93 |
if (addr->sa_family == AF_INET6) { |
94 | 94 |
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) { |
95 |
- av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS): %s\n", strerror(errno)); |
|
95 |
+ log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)"); |
|
96 | 96 |
return -1; |
97 | 97 |
} |
98 | 98 |
} |
... | ... |
@@ -109,7 +114,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr) |
109 | 109 |
mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; |
110 | 110 |
mreq.imr_interface.s_addr= INADDR_ANY; |
111 | 111 |
if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { |
112 |
- av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP): %s\n", strerror(errno)); |
|
112 |
+ log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)"); |
|
113 | 113 |
return -1; |
114 | 114 |
} |
115 | 115 |
} |
... | ... |
@@ -121,7 +126,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr) |
121 | 121 |
memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); |
122 | 122 |
mreq6.ipv6mr_interface= 0; |
123 | 123 |
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { |
124 |
- av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP): %s\n", strerror(errno)); |
|
124 |
+ log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)"); |
|
125 | 125 |
return -1; |
126 | 126 |
} |
127 | 127 |
} |
... | ... |
@@ -138,7 +143,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr) |
138 | 138 |
mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; |
139 | 139 |
mreq.imr_interface.s_addr= INADDR_ANY; |
140 | 140 |
if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { |
141 |
- av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP): %s\n", strerror(errno)); |
|
141 |
+ log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP)"); |
|
142 | 142 |
return -1; |
143 | 143 |
} |
144 | 144 |
} |
... | ... |
@@ -150,7 +155,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr) |
150 | 150 |
memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); |
151 | 151 |
mreq6.ipv6mr_interface= 0; |
152 | 152 |
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { |
153 |
- av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP): %s\n", strerror(errno)); |
|
153 |
+ log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP)"); |
|
154 | 154 |
return -1; |
155 | 155 |
} |
156 | 156 |
} |
... | ... |
@@ -214,8 +219,8 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr, |
214 | 214 |
goto fail; |
215 | 215 |
for (res = res0; res; res=res->ai_next) { |
216 | 216 |
udp_fd = socket(res->ai_family, SOCK_DGRAM, 0); |
217 |
- if (udp_fd > 0) break; |
|
218 |
- av_log(NULL, AV_LOG_ERROR, "socket: %s\n", strerror(errno)); |
|
217 |
+ if (udp_fd != -1) break; |
|
218 |
+ log_net_error(NULL, AV_LOG_ERROR, "socket"); |
|
219 | 219 |
} |
220 | 220 |
|
221 | 221 |
if (udp_fd < 0) |
... | ... |
@@ -239,9 +244,10 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr, |
239 | 239 |
static int udp_port(struct sockaddr_storage *addr, int addr_len) |
240 | 240 |
{ |
241 | 241 |
char sbuf[sizeof(int)*3+1]; |
242 |
+ int error; |
|
242 | 243 |
|
243 |
- if (getnameinfo((struct sockaddr *)addr, addr_len, NULL, 0, sbuf, sizeof(sbuf), NI_NUMERICSERV) != 0) { |
|
244 |
- av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", strerror(errno)); |
|
244 |
+ if ((error = getnameinfo((struct sockaddr *)addr, addr_len, NULL, 0, sbuf, sizeof(sbuf), NI_NUMERICSERV)) != 0) { |
|
245 |
+ av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(error)); |
|
245 | 246 |
return -1; |
246 | 247 |
} |
247 | 248 |
|
... | ... |
@@ -289,7 +295,7 @@ int ff_udp_set_remote_url(URLContext *h, const char *uri) |
289 | 289 |
if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr, |
290 | 290 |
s->dest_addr_len)) { |
291 | 291 |
s->is_connected = 0; |
292 |
- av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); |
|
292 |
+ log_net_error(h, AV_LOG_ERROR, "connect"); |
|
293 | 293 |
return AVERROR(EIO); |
294 | 294 |
} |
295 | 295 |
} |
... | ... |
@@ -479,7 +485,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) |
479 | 479 |
* bind failed */ |
480 | 480 |
/* the bind is needed to give a port to the socket now */ |
481 | 481 |
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) { |
482 |
- av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno)); |
|
482 |
+ log_net_error(h, AV_LOG_ERROR, "bind failed"); |
|
483 | 483 |
goto fail; |
484 | 484 |
} |
485 | 485 |
|
... | ... |
@@ -504,7 +510,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) |
504 | 504 |
/* limit the tx buf size to limit latency */ |
505 | 505 |
tmp = s->buffer_size; |
506 | 506 |
if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) { |
507 |
- av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno)); |
|
507 |
+ log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)"); |
|
508 | 508 |
goto fail; |
509 | 509 |
} |
510 | 510 |
} else { |
... | ... |
@@ -512,14 +518,14 @@ static int udp_open(URLContext *h, const char *uri, int flags) |
512 | 512 |
* avoid losing data on OSes that set this too low by default. */ |
513 | 513 |
tmp = s->buffer_size; |
514 | 514 |
if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) { |
515 |
- av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno)); |
|
515 |
+ log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)"); |
|
516 | 516 |
} |
517 | 517 |
/* make the socket non-blocking */ |
518 | 518 |
ff_socket_nonblock(udp_fd, 1); |
519 | 519 |
} |
520 | 520 |
if (s->is_connected) { |
521 | 521 |
if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) { |
522 |
- av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); |
|
522 |
+ log_net_error(h, AV_LOG_ERROR, "connect"); |
|
523 | 523 |
goto fail; |
524 | 524 |
} |
525 | 525 |
} |
... | ... |
@@ -41,8 +41,6 @@ |
41 | 41 |
#include "riff.h" |
42 | 42 |
#include "audiointerleave.h" |
43 | 43 |
#include "url.h" |
44 |
-#include <sys/time.h> |
|
45 |
-#include <time.h> |
|
46 | 44 |
#include <stdarg.h> |
47 | 45 |
#if CONFIG_NETWORK |
48 | 46 |
#include "network.h" |
... | ... |
@@ -3875,12 +3873,12 @@ void av_dump_format(AVFormatContext *ic, |
3875 | 3875 |
av_free(printed); |
3876 | 3876 |
} |
3877 | 3877 |
|
3878 |
-int64_t av_gettime(void) |
|
3878 |
+#if FF_API_AV_GETTIME && CONFIG_SHARED && HAVE_SYMVER |
|
3879 |
+FF_SYMVER(int64_t, av_gettime, (void), "LIBAVFORMAT_54") |
|
3879 | 3880 |
{ |
3880 |
- struct timeval tv; |
|
3881 |
- gettimeofday(&tv,NULL); |
|
3882 |
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
|
3881 |
+ return av_gettime(); |
|
3883 | 3882 |
} |
3883 |
+#endif |
|
3884 | 3884 |
|
3885 | 3885 |
uint64_t ff_ntp_time(void) |
3886 | 3886 |
{ |
... | ... |
@@ -39,6 +39,7 @@ HEADERS = adler32.h \ |
39 | 39 |
rational.h \ |
40 | 40 |
samplefmt.h \ |
41 | 41 |
sha.h \ |
42 |
+ time.h \ |
|
42 | 43 |
timecode.h \ |
43 | 44 |
timestamp.h \ |
44 | 45 |
|
... | ... |
@@ -83,6 +84,7 @@ OBJS = adler32.o \ |
83 | 83 |
rc4.o \ |
84 | 84 |
samplefmt.o \ |
85 | 85 |
sha.o \ |
86 |
+ time.o \ |
|
86 | 87 |
timecode.o \ |
87 | 88 |
tree.o \ |
88 | 89 |
utils.o \ |
... | ... |
@@ -343,7 +343,7 @@ void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) { |
343 | 343 |
#undef srand |
344 | 344 |
#include <stdlib.h> |
345 | 345 |
#include <stdio.h> |
346 |
-#include <sys/time.h> |
|
346 |
+#include "libavutil/time.h" |
|
347 | 347 |
static uint64_t rand64(void) { |
348 | 348 |
uint64_t r = rand(); |
349 | 349 |
r = (r << 32) | rand(); |
... | ... |
@@ -390,13 +390,11 @@ int main(void) { |
390 | 390 |
#ifdef GENTABLES |
391 | 391 |
int j; |
392 | 392 |
#endif |
393 |
- struct timeval tv; |
|
394 | 393 |
uint64_t key[3]; |
395 | 394 |
uint64_t data; |
396 | 395 |
uint64_t ct; |
397 | 396 |
uint64_t roundkeys[16]; |
398 |
- gettimeofday(&tv, NULL); |
|
399 |
- srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec); |
|
397 |
+ srand(av_gettime()); |
|
400 | 398 |
key[0] = AV_RB64(test_key); |
401 | 399 |
data = AV_RB64(plain); |
402 | 400 |
gen_roundkeys(roundkeys, key[0]); |
... | ... |
@@ -26,30 +26,12 @@ |
26 | 26 |
#include "attributes.h" |
27 | 27 |
#include "rational.h" |
28 | 28 |
|
29 |
-#ifndef M_E |
|
30 |
-#define M_E 2.7182818284590452354 /* e */ |
|
31 |
-#endif |
|
32 |
-#ifndef M_LN2 |
|
33 |
-#define M_LN2 0.69314718055994530942 /* log_e 2 */ |
|
34 |
-#endif |
|
35 |
-#ifndef M_LN10 |
|
36 |
-#define M_LN10 2.30258509299404568402 /* log_e 10 */ |
|
37 |
-#endif |
|
38 | 29 |
#ifndef M_LOG2_10 |
39 | 30 |
#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ |
40 | 31 |
#endif |
41 | 32 |
#ifndef M_PHI |
42 | 33 |
#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ |
43 | 34 |
#endif |
44 |
-#ifndef M_PI |
|
45 |
-#define M_PI 3.14159265358979323846 /* pi */ |
|
46 |
-#endif |
|
47 |
-#ifndef M_SQRT1_2 |
|
48 |
-#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ |
|
49 |
-#endif |
|
50 |
-#ifndef M_SQRT2 |
|
51 |
-#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ |
|
52 |
-#endif |
|
53 | 35 |
#ifndef NAN |
54 | 36 |
#define NAN (0.0/0.0) |
55 | 37 |
#endif |
28 | 27 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,46 @@ |
0 |
+/* |
|
1 |
+ * This file is part of Libav. |
|
2 |
+ * |
|
3 |
+ * Libav is free software; you can redistribute it and/or |
|
4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
5 |
+ * License as published by the Free Software Foundation; either |
|
6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * Libav is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 |
+ * Lesser General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
14 |
+ * License along with Libav; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#include "config.h" |
|
19 |
+ |
|
20 |
+#include <stddef.h> |
|
21 |
+#include <stdint.h> |
|
22 |
+#if HAVE_GETTIMEOFDAY |
|
23 |
+#include <sys/time.h> |
|
24 |
+#elif HAVE_GETSYSTEMTIMEASFILETIME |
|
25 |
+#include <windows.h> |
|
26 |
+#endif |
|
27 |
+ |
|
28 |
+#include "libavutil/time.h" |
|
29 |
+ |
|
30 |
+int64_t av_gettime(void) |
|
31 |
+{ |
|
32 |
+#if HAVE_GETTIMEOFDAY |
|
33 |
+ struct timeval tv; |
|
34 |
+ gettimeofday(&tv, NULL); |
|
35 |
+ return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
|
36 |
+#elif HAVE_GETSYSTEMTIMEASFILETIME |
|
37 |
+ FILETIME ft; |
|
38 |
+ int64_t t; |
|
39 |
+ GetSystemTimeAsFileTime(&ft); |
|
40 |
+ t = (int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime; |
|
41 |
+ return t / 10 - 11644473600000000; /* Jan 1, 1601 */ |
|
42 |
+#else |
|
43 |
+ return -1; |
|
44 |
+#endif |
|
45 |
+} |
0 | 46 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,29 @@ |
0 |
+/* |
|
1 |
+ * This file is part of Libav. |
|
2 |
+ * |
|
3 |
+ * Libav is free software; you can redistribute it and/or |
|
4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
5 |
+ * License as published by the Free Software Foundation; either |
|
6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * Libav is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 |
+ * Lesser General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
14 |
+ * License along with Libav; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#ifndef AVUTIL_TIME_H |
|
19 |
+#define AVUTIL_TIME_H |
|
20 |
+ |
|
21 |
+#include <stdint.h> |
|
22 |
+ |
|
23 |
+/** |
|
24 |
+ * Get the current time in microseconds. |
|
25 |
+ */ |
|
26 |
+int64_t av_gettime(void); |
|
27 |
+ |
|
28 |
+#endif /* AVUTIL_TIME_H */ |
... | ... |
@@ -20,16 +20,9 @@ |
20 | 20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | 21 |
*/ |
22 | 22 |
|
23 |
-#include <stdio.h> |
|
24 |
-#include <stdlib.h> |
|
25 |
-#include <string.h> |
|
26 |
-#include <inttypes.h> |
|
27 |
-#include <assert.h> |
|
28 |
-#include "config.h" |
|
29 |
-#include <unistd.h> |
|
23 |
+#include <stdint.h> |
|
30 | 24 |
|
31 |
-#include "libswscale/rgb2rgb.h" |
|
32 |
-#include "libswscale/swscale.h" |
|
25 |
+#include "config.h" |
|
33 | 26 |
#include "libswscale/swscale_internal.h" |
34 | 27 |
|
35 | 28 |
#if defined (__FDPIC__) && CONFIG_SRAM |
... | ... |
@@ -46,14 +39,14 @@ int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, |
46 | 46 |
uint8_t *vdst, int width, int height, |
47 | 47 |
int lumStride, int chromStride, int srcStride) L1CODE; |
48 | 48 |
|
49 |
-static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[], |
|
50 |
- int srcSliceY, int srcSliceH, uint8_t *dst[], |
|
51 |
- int dstStride[]) |
|
49 |
+static int uyvytoyv12_unscaled(SwsContext *c, const uint8_t *src[], |
|
50 |
+ int srcStride[], int srcSliceY, int srcSliceH, |
|
51 |
+ uint8_t *dst[], int dstStride[]) |
|
52 | 52 |
{ |
53 | 53 |
uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY; |
54 | 54 |
uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2; |
55 | 55 |
uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2; |
56 |
- uint8_t *ip = src[0] + srcStride[0] * srcSliceY; |
|
56 |
+ const uint8_t *ip = src[0] + srcStride[0] * srcSliceY; |
|
57 | 57 |
int w = dstStride[0]; |
58 | 58 |
|
59 | 59 |
ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH, |
... | ... |
@@ -62,14 +55,14 @@ static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[], |
62 | 62 |
return srcSliceH; |
63 | 63 |
} |
64 | 64 |
|
65 |
-static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[], |
|
66 |
- int srcSliceY, int srcSliceH, uint8_t *dst[], |
|
67 |
- int dstStride[]) |
|
65 |
+static int yuyvtoyv12_unscaled(SwsContext *c, const uint8_t *src[], |
|
66 |
+ int srcStride[], int srcSliceY, int srcSliceH, |
|
67 |
+ uint8_t *dst[], int dstStride[]) |
|
68 | 68 |
{ |
69 | 69 |
uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY; |
70 | 70 |
uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2; |
71 | 71 |
uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2; |
72 |
- uint8_t *ip = src[0] + srcStride[0] * srcSliceY; |
|
72 |
+ const uint8_t *ip = src[0] + srcStride[0] * srcSliceY; |
|
73 | 73 |
int w = dstStride[0]; |
74 | 74 |
|
75 | 75 |
ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH, |
... | ... |
@@ -21,17 +21,10 @@ |
21 | 21 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | 22 |
*/ |
23 | 23 |
|
24 |
-#include <stdio.h> |
|
25 |
-#include <stdlib.h> |
|
26 |
-#include <string.h> |
|
27 |
-#include <inttypes.h> |
|
28 |
-#include <assert.h> |
|
29 |
-#include <unistd.h> |
|
30 | 24 |
#include "libavutil/pixdesc.h" |
25 |
+#include <stdint.h> |
|
31 | 26 |
|
32 | 27 |
#include "config.h" |
33 |
-#include "libswscale/rgb2rgb.h" |
|
34 |
-#include "libswscale/swscale.h" |
|
35 | 28 |
#include "libswscale/swscale_internal.h" |
36 | 29 |
|
37 | 30 |
#if defined(__FDPIC__) && CONFIG_SRAM |
... | ... |
@@ -40,17 +33,20 @@ |
40 | 40 |
#define L1CODE |
41 | 41 |
#endif |
42 | 42 |
|
43 |
-void ff_bfin_yuv2rgb555_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out, |
|
43 |
+void ff_bfin_yuv2rgb555_line(const uint8_t *Y, const uint8_t *U, |
|
44 |
+ const uint8_t *V, uint8_t *out, |
|
44 | 45 |
int w, uint32_t *coeffs) L1CODE; |
45 | 46 |
|
46 |
-void ff_bfin_yuv2rgb565_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out, |
|
47 |
+void ff_bfin_yuv2rgb565_line(const uint8_t *Y, const uint8_t *U, |
|
48 |
+ const uint8_t *V, uint8_t *out, |
|
47 | 49 |
int w, uint32_t *coeffs) L1CODE; |
48 | 50 |
|
49 |
-void ff_bfin_yuv2rgb24_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out, |
|
51 |
+void ff_bfin_yuv2rgb24_line(const uint8_t *Y, const uint8_t *U, |
|
52 |
+ const uint8_t *V, uint8_t *out, |
|
50 | 53 |
int w, uint32_t *coeffs) L1CODE; |
51 | 54 |
|
52 |
-typedef void (*ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out, |
|
53 |
- int w, uint32_t *coeffs); |
|
55 |
+typedef void (*ltransform)(const uint8_t *Y, const uint8_t *U, const uint8_t *V, |
|
56 |
+ uint8_t *out, int w, uint32_t *coeffs); |
|
54 | 57 |
|
55 | 58 |
static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks) |
56 | 59 |
{ |
... | ... |
@@ -88,12 +84,13 @@ static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks) |
88 | 88 |
} |
89 | 89 |
} |
90 | 90 |
|
91 |
-static int core_yuv420_rgb(SwsContext *c, uint8_t **in, int *instrides, |
|
91 |
+static int core_yuv420_rgb(SwsContext *c, const uint8_t **in, int *instrides, |
|
92 | 92 |
int srcSliceY, int srcSliceH, uint8_t **oplanes, |
93 | 93 |
int *outstrides, ltransform lcscf, |
94 | 94 |
int rgb, int masks) |
95 | 95 |
{ |
96 |
- uint8_t *py, *pu, *pv, *op; |
|
96 |
+ const uint8_t *py, *pu, *pv; |
|
97 |
+ uint8_t *op; |
|
97 | 98 |
int w = instrides[0]; |
98 | 99 |
int h2 = srcSliceH >> 1; |
99 | 100 |
int i; |
... | ... |
@@ -123,7 +120,7 @@ static int core_yuv420_rgb(SwsContext *c, uint8_t **in, int *instrides, |
123 | 123 |
return srcSliceH; |
124 | 124 |
} |
125 | 125 |
|
126 |
-static int bfin_yuv420_rgb555(SwsContext *c, uint8_t **in, int *instrides, |
|
126 |
+static int bfin_yuv420_rgb555(SwsContext *c, const uint8_t **in, int *instrides, |
|
127 | 127 |
int srcSliceY, int srcSliceH, |
128 | 128 |
uint8_t **oplanes, int *outstrides) |
129 | 129 |
{ |
... | ... |
@@ -131,7 +128,7 @@ static int bfin_yuv420_rgb555(SwsContext *c, uint8_t **in, int *instrides, |
131 | 131 |
outstrides, ff_bfin_yuv2rgb555_line, 1, 555); |
132 | 132 |
} |
133 | 133 |
|
134 |
-static int bfin_yuv420_bgr555(SwsContext *c, uint8_t **in, int *instrides, |
|
134 |
+static int bfin_yuv420_bgr555(SwsContext *c, const uint8_t **in, int *instrides, |
|
135 | 135 |
int srcSliceY, int srcSliceH, |
136 | 136 |
uint8_t **oplanes, int *outstrides) |
137 | 137 |
{ |
... | ... |
@@ -139,7 +136,7 @@ static int bfin_yuv420_bgr555(SwsContext *c, uint8_t **in, int *instrides, |
139 | 139 |
outstrides, ff_bfin_yuv2rgb555_line, 0, 555); |
140 | 140 |
} |
141 | 141 |
|
142 |
-static int bfin_yuv420_rgb24(SwsContext *c, uint8_t **in, int *instrides, |
|
142 |
+static int bfin_yuv420_rgb24(SwsContext *c, const uint8_t **in, int *instrides, |
|
143 | 143 |
int srcSliceY, int srcSliceH, |
144 | 144 |
uint8_t **oplanes, int *outstrides) |
145 | 145 |
{ |
... | ... |
@@ -147,7 +144,7 @@ static int bfin_yuv420_rgb24(SwsContext *c, uint8_t **in, int *instrides, |
147 | 147 |
outstrides, ff_bfin_yuv2rgb24_line, 1, 888); |
148 | 148 |
} |
149 | 149 |
|
150 |
-static int bfin_yuv420_bgr24(SwsContext *c, uint8_t **in, int *instrides, |
|
150 |
+static int bfin_yuv420_bgr24(SwsContext *c, const uint8_t **in, int *instrides, |
|
151 | 151 |
int srcSliceY, int srcSliceH, |
152 | 152 |
uint8_t **oplanes, int *outstrides) |
153 | 153 |
{ |
... | ... |
@@ -155,7 +152,7 @@ static int bfin_yuv420_bgr24(SwsContext *c, uint8_t **in, int *instrides, |
155 | 155 |
outstrides, ff_bfin_yuv2rgb24_line, 0, 888); |
156 | 156 |
} |
157 | 157 |
|
158 |
-static int bfin_yuv420_rgb565(SwsContext *c, uint8_t **in, int *instrides, |
|
158 |
+static int bfin_yuv420_rgb565(SwsContext *c, const uint8_t **in, int *instrides, |
|
159 | 159 |
int srcSliceY, int srcSliceH, |
160 | 160 |
uint8_t **oplanes, int *outstrides) |
161 | 161 |
{ |
... | ... |
@@ -163,7 +160,7 @@ static int bfin_yuv420_rgb565(SwsContext *c, uint8_t **in, int *instrides, |
163 | 163 |
outstrides, ff_bfin_yuv2rgb565_line, 1, 565); |
164 | 164 |
} |
165 | 165 |
|
166 |
-static int bfin_yuv420_bgr565(SwsContext *c, uint8_t **in, int *instrides, |
|
166 |
+static int bfin_yuv420_bgr565(SwsContext *c, const uint8_t **in, int *instrides, |
|
167 | 167 |
int srcSliceY, int srcSliceH, |
168 | 168 |
uint8_t **oplanes, int *outstrides) |
169 | 169 |
{ |