Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> | ||
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 <assert.h> | ||
22 | |||
23 | #include "libavutil/log.h" | ||
24 | #include "libavutil/mem.h" | ||
25 | #include "libavutil/thread.h" | ||
26 | #include "avcodec.h" | ||
27 | #include "snow_dwt.h" | ||
28 | #include "snow.h" | ||
29 | #include "snowdata.h" | ||
30 | |||
31 | #define pixeltmp int16_t | ||
32 | #define BIT_DEPTH 8 | ||
33 | #define SNOW | ||
34 | #include "h264qpel_template.c" | ||
35 | |||
36 | 58634 | static void put_snow_qpel2_h_lowpass_8(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride) | |
37 | { | ||
38 | 58634 | const int h = 2; | |
39 |
2/2✓ Branch 0 taken 117268 times.
✓ Branch 1 taken 58634 times.
|
175902 | for (int i = 0; i < h; ++i) { |
40 | 117268 | dst[0] = av_clip_uint8(((src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + 16) >> 5); | |
41 | 117268 | dst[1] = av_clip_uint8(((src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + 16) >> 5); | |
42 | 117268 | dst += dstStride; | |
43 | 117268 | src += srcStride; | |
44 | } | ||
45 | 58634 | } | |
46 | |||
47 | 65508 | static void put_snow_qpel2_v_lowpass_8(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride) | |
48 | { | ||
49 | 65508 | const int w = 2; | |
50 |
2/2✓ Branch 0 taken 131016 times.
✓ Branch 1 taken 65508 times.
|
196524 | for (int i = 0; i < w; ++i) { |
51 | 131016 | const int srcB = src[-2*srcStride]; | |
52 | 131016 | const int srcA = src[-1*srcStride]; | |
53 | 131016 | const int src0 = src[0 *srcStride]; | |
54 | 131016 | const int src1 = src[1 *srcStride]; | |
55 | 131016 | const int src2 = src[2 *srcStride]; | |
56 | 131016 | const int src3 = src[3 *srcStride]; | |
57 | 131016 | const int src4 = src[4 *srcStride]; | |
58 | 131016 | dst[0*dstStride] = av_clip_uint8(((src0+src1)*20 - (srcA+src2)*5 + (srcB+src3) + 16) >> 5); | |
59 | 131016 | dst[1*dstStride] = av_clip_uint8(((src1+src2)*20 - (src0+src3)*5 + (srcA+src4) + 16) >> 5); | |
60 | 131016 | dst++; | |
61 | 131016 | src++; | |
62 | } | ||
63 | 65508 | } | |
64 | |||
65 | 59440 | static void put_snow_qpel2_hv_lowpass_8(uint8_t *dst, pixeltmp *tmp, const uint8_t *restrict src, int dstStride, int tmpStride, int srcStride) | |
66 | { | ||
67 | 59440 | const int h = 2; | |
68 | 59440 | const int w = 2; | |
69 | 59440 | src -= 2*srcStride; | |
70 |
2/2✓ Branch 0 taken 416080 times.
✓ Branch 1 taken 59440 times.
|
475520 | for (int i = 0; i < h + 5; ++i) { |
71 | 416080 | tmp[0] = (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]); | |
72 | 416080 | tmp[1] = (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]); | |
73 | 416080 | tmp += tmpStride; | |
74 | 416080 | src += srcStride; | |
75 | } | ||
76 | 59440 | tmp -= tmpStride*(h+5-2); | |
77 |
2/2✓ Branch 0 taken 118880 times.
✓ Branch 1 taken 59440 times.
|
178320 | for (int i = 0; i < w; ++i) { |
78 | 118880 | const int tmpB = tmp[-2*tmpStride]; | |
79 | 118880 | const int tmpA = tmp[-1*tmpStride]; | |
80 | 118880 | const int tmp0 = tmp[0 *tmpStride]; | |
81 | 118880 | const int tmp1 = tmp[1 *tmpStride]; | |
82 | 118880 | const int tmp2 = tmp[2 *tmpStride]; | |
83 | 118880 | const int tmp3 = tmp[3 *tmpStride]; | |
84 | 118880 | const int tmp4 = tmp[4 *tmpStride]; | |
85 | 118880 | dst[0*dstStride] = av_clip_uint8(((tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3) + 512) >> 10); | |
86 | 118880 | dst[1*dstStride] = av_clip_uint8(((tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4) + 512) >> 10); | |
87 | 118880 | dst++; | |
88 | 118880 | tmp++; | |
89 | } | ||
90 | 59440 | } | |
91 | |||
92 | 391404 | H264_MC(put_, snow, 2) | |
93 | |||
94 | 31 | static av_cold void init_qpel(SnowContext *const s) | |
95 | { | ||
96 | static_assert(offsetof(H264QpelContext, put_h264_qpel_pixels_tab) == 0, | ||
97 | "put_h264_qpel_pixels_tab not at start of H264QpelContext"); | ||
98 | 31 | ff_h264qpel_init(&s->h264qpel, 8); | |
99 | 31 | s->put_snow_qpel_pixels_tab[3][0] = put_snow_qpel2_mc00_8_c; | |
100 | 31 | s->put_snow_qpel_pixels_tab[3][1] = put_snow_qpel2_mc10_8_c; | |
101 | 31 | s->put_snow_qpel_pixels_tab[3][2] = put_snow_qpel2_mc20_8_c; | |
102 | 31 | s->put_snow_qpel_pixels_tab[3][3] = put_snow_qpel2_mc30_8_c; | |
103 | 31 | s->put_snow_qpel_pixels_tab[3][4] = put_snow_qpel2_mc01_8_c; | |
104 | 31 | s->put_snow_qpel_pixels_tab[3][5] = put_snow_qpel2_mc11_8_c; | |
105 | 31 | s->put_snow_qpel_pixels_tab[3][6] = put_snow_qpel2_mc21_8_c; | |
106 | 31 | s->put_snow_qpel_pixels_tab[3][7] = put_snow_qpel2_mc31_8_c; | |
107 | 31 | s->put_snow_qpel_pixels_tab[3][8] = put_snow_qpel2_mc02_8_c; | |
108 | 31 | s->put_snow_qpel_pixels_tab[3][9] = put_snow_qpel2_mc12_8_c; | |
109 | 31 | s->put_snow_qpel_pixels_tab[3][10] = put_snow_qpel2_mc22_8_c; | |
110 | 31 | s->put_snow_qpel_pixels_tab[3][11] = put_snow_qpel2_mc32_8_c; | |
111 | 31 | s->put_snow_qpel_pixels_tab[3][12] = put_snow_qpel2_mc03_8_c; | |
112 | 31 | s->put_snow_qpel_pixels_tab[3][13] = put_snow_qpel2_mc13_8_c; | |
113 | 31 | s->put_snow_qpel_pixels_tab[3][14] = put_snow_qpel2_mc23_8_c; | |
114 | 31 | s->put_snow_qpel_pixels_tab[3][15] = put_snow_qpel2_mc33_8_c; | |
115 | 31 | } | |
116 | |||
117 | 710775 | void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, | |
118 | int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){ | ||
119 | int y, x; | ||
120 | IDWTELEM * dst; | ||
121 |
2/2✓ Branch 0 taken 3810240 times.
✓ Branch 1 taken 710775 times.
|
4521015 | for(y=0; y<b_h; y++){ |
122 | //FIXME ugly misuse of obmc_stride | ||
123 | 3810240 | const uint8_t *obmc1= obmc + y*obmc_stride; | |
124 | 3810240 | const uint8_t *obmc2= obmc1+ (obmc_stride>>1); | |
125 | 3810240 | const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1); | |
126 | 3810240 | const uint8_t *obmc4= obmc3+ (obmc_stride>>1); | |
127 |
1/2✓ Branch 0 taken 3810240 times.
✗ Branch 1 not taken.
|
3810240 | dst = slice_buffer_get_line(sb, src_y + y); |
128 |
2/2✓ Branch 0 taken 23846400 times.
✓ Branch 1 taken 3810240 times.
|
27656640 | for(x=0; x<b_w; x++){ |
129 | 23846400 | int v= obmc1[x] * block[3][x + y*src_stride] | |
130 | 23846400 | +obmc2[x] * block[2][x + y*src_stride] | |
131 | 23846400 | +obmc3[x] * block[1][x + y*src_stride] | |
132 | 23846400 | +obmc4[x] * block[0][x + y*src_stride]; | |
133 | |||
134 | 23846400 | v <<= 8 - LOG2_OBMC_MAX; | |
135 | if(FRAC_BITS != 8){ | ||
136 | 23846400 | v >>= 8 - FRAC_BITS; | |
137 | } | ||
138 |
1/2✓ Branch 0 taken 23846400 times.
✗ Branch 1 not taken.
|
23846400 | if(add){ |
139 | 23846400 | v += dst[x + src_x]; | |
140 | 23846400 | v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS; | |
141 |
2/2✓ Branch 0 taken 1126 times.
✓ Branch 1 taken 23845274 times.
|
23846400 | if(v&(~255)) v= ~(v>>31); |
142 | 23846400 | dst8[x + y*src_stride] = v; | |
143 | }else{ | ||
144 | ✗ | dst[x + src_x] -= v; | |
145 | } | ||
146 | } | ||
147 | } | ||
148 | 710775 | } | |
149 | |||
150 | 103 | void ff_snow_reset_contexts(SnowContext *s){ //FIXME better initial contexts | |
151 | int plane_index, level, orientation; | ||
152 | |||
153 |
2/2✓ Branch 0 taken 309 times.
✓ Branch 1 taken 103 times.
|
412 | for(plane_index=0; plane_index<3; plane_index++){ |
154 |
2/2✓ Branch 0 taken 2472 times.
✓ Branch 1 taken 309 times.
|
2781 | for(level=0; level<MAX_DECOMPOSITIONS; level++){ |
155 |
2/2✓ Branch 0 taken 7725 times.
✓ Branch 1 taken 2472 times.
|
10197 | for(orientation=level ? 1:0; orientation<4; orientation++){ |
156 | 7725 | memset(s->plane[plane_index].band[level][orientation].state, MID_STATE, sizeof(s->plane[plane_index].band[level][orientation].state)); | |
157 | } | ||
158 | } | ||
159 | } | ||
160 | 103 | memset(s->header_state, MID_STATE, sizeof(s->header_state)); | |
161 | 103 | memset(s->block_state, MID_STATE, sizeof(s->block_state)); | |
162 | 103 | } | |
163 | |||
164 | 472 | int ff_snow_alloc_blocks(SnowContext *s){ | |
165 | 472 | int w= AV_CEIL_RSHIFT(s->avctx->width, LOG2_MB_SIZE); | |
166 | 472 | int h= AV_CEIL_RSHIFT(s->avctx->height, LOG2_MB_SIZE); | |
167 | |||
168 | 472 | s->b_width = w; | |
169 | 472 | s->b_height= h; | |
170 | |||
171 | 472 | av_free(s->block); | |
172 | 472 | s->block = av_calloc(w * h, sizeof(*s->block) << (s->block_max_depth*2)); | |
173 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
|
472 | if (!s->block) |
174 | ✗ | return AVERROR(ENOMEM); | |
175 | |||
176 | 472 | return 0; | |
177 | } | ||
178 | |||
179 | 3240046 | static void mc_block(Plane *p, uint8_t *dst, const uint8_t *src, int stride, int b_w, int b_h, int dx, int dy){ | |
180 | static const uint8_t weight[64]={ | ||
181 | 8,7,6,5,4,3,2,1, | ||
182 | 7,7,0,0,0,0,0,1, | ||
183 | 6,0,6,0,0,0,2,0, | ||
184 | 5,0,0,5,0,3,0,0, | ||
185 | 4,0,0,0,4,0,0,0, | ||
186 | 3,0,0,5,0,3,0,0, | ||
187 | 2,0,6,0,0,0,2,0, | ||
188 | 1,7,0,0,0,0,0,1, | ||
189 | }; | ||
190 | |||
191 | static const uint8_t brane[256]={ | ||
192 | 0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x12,0x12,0x12,0x12,0x12,0x12,0x12, | ||
193 | 0x04,0x05,0xcc,0xcc,0xcc,0xcc,0xcc,0x41,0x15,0x16,0xcc,0xcc,0xcc,0xcc,0xcc,0x52, | ||
194 | 0x04,0xcc,0x05,0xcc,0xcc,0xcc,0x41,0xcc,0x15,0xcc,0x16,0xcc,0xcc,0xcc,0x52,0xcc, | ||
195 | 0x04,0xcc,0xcc,0x05,0xcc,0x41,0xcc,0xcc,0x15,0xcc,0xcc,0x16,0xcc,0x52,0xcc,0xcc, | ||
196 | 0x04,0xcc,0xcc,0xcc,0x41,0xcc,0xcc,0xcc,0x15,0xcc,0xcc,0xcc,0x16,0xcc,0xcc,0xcc, | ||
197 | 0x04,0xcc,0xcc,0x41,0xcc,0x05,0xcc,0xcc,0x15,0xcc,0xcc,0x52,0xcc,0x16,0xcc,0xcc, | ||
198 | 0x04,0xcc,0x41,0xcc,0xcc,0xcc,0x05,0xcc,0x15,0xcc,0x52,0xcc,0xcc,0xcc,0x16,0xcc, | ||
199 | 0x04,0x41,0xcc,0xcc,0xcc,0xcc,0xcc,0x05,0x15,0x52,0xcc,0xcc,0xcc,0xcc,0xcc,0x16, | ||
200 | 0x44,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x55,0x56,0x56,0x56,0x56,0x56,0x56,0x56, | ||
201 | 0x48,0x49,0xcc,0xcc,0xcc,0xcc,0xcc,0x85,0x59,0x5A,0xcc,0xcc,0xcc,0xcc,0xcc,0x96, | ||
202 | 0x48,0xcc,0x49,0xcc,0xcc,0xcc,0x85,0xcc,0x59,0xcc,0x5A,0xcc,0xcc,0xcc,0x96,0xcc, | ||
203 | 0x48,0xcc,0xcc,0x49,0xcc,0x85,0xcc,0xcc,0x59,0xcc,0xcc,0x5A,0xcc,0x96,0xcc,0xcc, | ||
204 | 0x48,0xcc,0xcc,0xcc,0x49,0xcc,0xcc,0xcc,0x59,0xcc,0xcc,0xcc,0x96,0xcc,0xcc,0xcc, | ||
205 | 0x48,0xcc,0xcc,0x85,0xcc,0x49,0xcc,0xcc,0x59,0xcc,0xcc,0x96,0xcc,0x5A,0xcc,0xcc, | ||
206 | 0x48,0xcc,0x85,0xcc,0xcc,0xcc,0x49,0xcc,0x59,0xcc,0x96,0xcc,0xcc,0xcc,0x5A,0xcc, | ||
207 | 0x48,0x85,0xcc,0xcc,0xcc,0xcc,0xcc,0x49,0x59,0x96,0xcc,0xcc,0xcc,0xcc,0xcc,0x5A, | ||
208 | }; | ||
209 | |||
210 | static const uint8_t needs[16]={ | ||
211 | 0,1,0,0, | ||
212 | 2,4,2,0, | ||
213 | 0,1,0,0, | ||
214 | 15 | ||
215 | }; | ||
216 | |||
217 | int x, y, b, r, l; | ||
218 | int16_t tmpIt [64*(32+HTAPS_MAX)]; | ||
219 | uint8_t tmp2t[3][64*(32+HTAPS_MAX)]; | ||
220 | 3240046 | int16_t *tmpI= tmpIt; | |
221 | 3240046 | uint8_t *tmp2= tmp2t[0]; | |
222 | const uint8_t *hpel[11]; | ||
223 | av_assert2(dx<16 && dy<16); | ||
224 | 3240046 | r= brane[dx + 16*dy]&15; | |
225 | 3240046 | l= brane[dx + 16*dy]>>4; | |
226 | |||
227 | 3240046 | b= needs[l] | needs[r]; | |
228 |
3/4✓ Branch 0 taken 3219792 times.
✓ Branch 1 taken 20254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3219792 times.
|
3240046 | if(p && !p->diag_mc) |
229 | ✗ | b= 15; | |
230 | |||
231 |
2/2✓ Branch 0 taken 2902303 times.
✓ Branch 1 taken 337743 times.
|
3240046 | if(b&5){ |
232 |
2/2✓ Branch 0 taken 32986489 times.
✓ Branch 1 taken 2902303 times.
|
35888792 | for(y=0; y < b_h+HTAPS_MAX-1; y++){ |
233 |
2/2✓ Branch 0 taken 151160584 times.
✓ Branch 1 taken 32986489 times.
|
184147073 | for(x=0; x < b_w; x++){ |
234 | 151160584 | int a_1=src[x + HTAPS_MAX/2-4]; | |
235 | 151160584 | int a0= src[x + HTAPS_MAX/2-3]; | |
236 | 151160584 | int a1= src[x + HTAPS_MAX/2-2]; | |
237 | 151160584 | int a2= src[x + HTAPS_MAX/2-1]; | |
238 | 151160584 | int a3= src[x + HTAPS_MAX/2+0]; | |
239 | 151160584 | int a4= src[x + HTAPS_MAX/2+1]; | |
240 | 151160584 | int a5= src[x + HTAPS_MAX/2+2]; | |
241 | 151160584 | int a6= src[x + HTAPS_MAX/2+3]; | |
242 | 151160584 | int am=0; | |
243 |
3/4✓ Branch 0 taken 145535704 times.
✓ Branch 1 taken 5624880 times.
✓ Branch 2 taken 145535704 times.
✗ Branch 3 not taken.
|
151160584 | if(!p || p->fast_mc){ |
244 | 151160584 | am= 20*(a2+a3) - 5*(a1+a4) + (a0+a5); | |
245 | 151160584 | tmpI[x]= am; | |
246 | 151160584 | am= (am+16)>>5; | |
247 | }else{ | ||
248 | ✗ | am= p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6); | |
249 | ✗ | tmpI[x]= am; | |
250 | ✗ | am= (am+32)>>6; | |
251 | } | ||
252 | |||
253 |
2/2✓ Branch 0 taken 6243 times.
✓ Branch 1 taken 151154341 times.
|
151160584 | if(am&(~255)) am= ~(am>>31); |
254 | 151160584 | tmp2[x]= am; | |
255 | } | ||
256 | 32986489 | tmpI+= 64; | |
257 | 32986489 | tmp2+= 64; | |
258 | 32986489 | src += stride; | |
259 | } | ||
260 | 2902303 | src -= stride*y; | |
261 | } | ||
262 | 3240046 | src += HTAPS_MAX/2 - 1; | |
263 | 3240046 | tmp2= tmp2t[1]; | |
264 | |||
265 |
2/2✓ Branch 0 taken 1995647 times.
✓ Branch 1 taken 1244399 times.
|
3240046 | if(b&2){ |
266 |
2/2✓ Branch 0 taken 8675168 times.
✓ Branch 1 taken 1995647 times.
|
10670815 | for(y=0; y < b_h; y++){ |
267 |
2/2✓ Branch 0 taken 49883520 times.
✓ Branch 1 taken 8675168 times.
|
58558688 | for(x=0; x < b_w+1; x++){ |
268 | 49883520 | int a_1=src[x + (HTAPS_MAX/2-4)*stride]; | |
269 | 49883520 | int a0= src[x + (HTAPS_MAX/2-3)*stride]; | |
270 | 49883520 | int a1= src[x + (HTAPS_MAX/2-2)*stride]; | |
271 | 49883520 | int a2= src[x + (HTAPS_MAX/2-1)*stride]; | |
272 | 49883520 | int a3= src[x + (HTAPS_MAX/2+0)*stride]; | |
273 | 49883520 | int a4= src[x + (HTAPS_MAX/2+1)*stride]; | |
274 | 49883520 | int a5= src[x + (HTAPS_MAX/2+2)*stride]; | |
275 | 49883520 | int a6= src[x + (HTAPS_MAX/2+3)*stride]; | |
276 | 49883520 | int am=0; | |
277 |
3/4✓ Branch 0 taken 48531952 times.
✓ Branch 1 taken 1351568 times.
✓ Branch 2 taken 48531952 times.
✗ Branch 3 not taken.
|
49883520 | if(!p || p->fast_mc) |
278 | 49883520 | am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 16)>>5; | |
279 | else | ||
280 | ✗ | am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 32)>>6; | |
281 | |||
282 |
2/2✓ Branch 0 taken 3684 times.
✓ Branch 1 taken 49879836 times.
|
49883520 | if(am&(~255)) am= ~(am>>31); |
283 | 49883520 | tmp2[x]= am; | |
284 | } | ||
285 | 8675168 | src += stride; | |
286 | 8675168 | tmp2+= 64; | |
287 | } | ||
288 | 1995647 | src -= stride*y; | |
289 | } | ||
290 | 3240046 | src += stride*(HTAPS_MAX/2 - 1); | |
291 | 3240046 | tmp2= tmp2t[2]; | |
292 | 3240046 | tmpI= tmpIt; | |
293 |
2/2✓ Branch 0 taken 1956310 times.
✓ Branch 1 taken 1283736 times.
|
3240046 | if(b&4){ |
294 |
2/2✓ Branch 0 taken 8485272 times.
✓ Branch 1 taken 1956310 times.
|
10441582 | for(y=0; y < b_h; y++){ |
295 |
2/2✓ Branch 0 taken 40817200 times.
✓ Branch 1 taken 8485272 times.
|
49302472 | for(x=0; x < b_w; x++){ |
296 | 40817200 | int a_1=tmpI[x + (HTAPS_MAX/2-4)*64]; | |
297 | 40817200 | int a0= tmpI[x + (HTAPS_MAX/2-3)*64]; | |
298 | 40817200 | int a1= tmpI[x + (HTAPS_MAX/2-2)*64]; | |
299 | 40817200 | int a2= tmpI[x + (HTAPS_MAX/2-1)*64]; | |
300 | 40817200 | int a3= tmpI[x + (HTAPS_MAX/2+0)*64]; | |
301 | 40817200 | int a4= tmpI[x + (HTAPS_MAX/2+1)*64]; | |
302 | 40817200 | int a5= tmpI[x + (HTAPS_MAX/2+2)*64]; | |
303 | 40817200 | int a6= tmpI[x + (HTAPS_MAX/2+3)*64]; | |
304 | 40817200 | int am=0; | |
305 |
3/4✓ Branch 0 taken 38320176 times.
✓ Branch 1 taken 2497024 times.
✓ Branch 2 taken 38320176 times.
✗ Branch 3 not taken.
|
40817200 | if(!p || p->fast_mc) |
306 | 40817200 | am= (20*(a2+a3) - 5*(a1+a4) + (a0+a5) + 512)>>10; | |
307 | else | ||
308 | ✗ | am= (p->hcoeff[0]*(a2+a3) + p->hcoeff[1]*(a1+a4) + p->hcoeff[2]*(a0+a5) + p->hcoeff[3]*(a_1+a6) + 2048)>>12; | |
309 |
2/2✓ Branch 0 taken 6658 times.
✓ Branch 1 taken 40810542 times.
|
40817200 | if(am&(~255)) am= ~(am>>31); |
310 | 40817200 | tmp2[x]= am; | |
311 | } | ||
312 | 8485272 | tmpI+= 64; | |
313 | 8485272 | tmp2+= 64; | |
314 | } | ||
315 | } | ||
316 | |||
317 | 3240046 | hpel[ 0]= src; | |
318 | 3240046 | hpel[ 1]= tmp2t[0] + 64*(HTAPS_MAX/2-1); | |
319 | 3240046 | hpel[ 2]= src + 1; | |
320 | |||
321 | 3240046 | hpel[ 4]= tmp2t[1]; | |
322 | 3240046 | hpel[ 5]= tmp2t[2]; | |
323 | 3240046 | hpel[ 6]= tmp2t[1] + 1; | |
324 | |||
325 | 3240046 | hpel[ 8]= src + stride; | |
326 | 3240046 | hpel[ 9]= hpel[1] + 64; | |
327 | 3240046 | hpel[10]= hpel[8] + 1; | |
328 | |||
329 | #define MC_STRIDE(x) (needs[x] ? 64 : stride) | ||
330 | |||
331 |
2/2✓ Branch 0 taken 789096 times.
✓ Branch 1 taken 2450950 times.
|
3240046 | if(b==15){ |
332 | 789096 | int dxy = dx / 8 + dy / 8 * 4; | |
333 | 789096 | const uint8_t *src1 = hpel[dxy ]; | |
334 | 789096 | const uint8_t *src2 = hpel[dxy + 1]; | |
335 | 789096 | const uint8_t *src3 = hpel[dxy + 4]; | |
336 | 789096 | const uint8_t *src4 = hpel[dxy + 5]; | |
337 |
2/2✓ Branch 0 taken 197858 times.
✓ Branch 1 taken 591238 times.
|
789096 | int stride1 = MC_STRIDE(dxy); |
338 |
2/2✓ Branch 0 taken 202020 times.
✓ Branch 1 taken 587076 times.
|
789096 | int stride2 = MC_STRIDE(dxy + 1); |
339 |
2/2✓ Branch 0 taken 191088 times.
✓ Branch 1 taken 598008 times.
|
789096 | int stride3 = MC_STRIDE(dxy + 4); |
340 |
2/2✓ Branch 0 taken 198130 times.
✓ Branch 1 taken 590966 times.
|
789096 | int stride4 = MC_STRIDE(dxy + 5); |
341 | 789096 | dx&=7; | |
342 | 789096 | dy&=7; | |
343 |
2/2✓ Branch 0 taken 3464504 times.
✓ Branch 1 taken 789096 times.
|
4253600 | for(y=0; y < b_h; y++){ |
344 |
2/2✓ Branch 0 taken 16562072 times.
✓ Branch 1 taken 3464504 times.
|
20026576 | for(x=0; x < b_w; x++){ |
345 | 16562072 | dst[x]= ((8-dx)*(8-dy)*src1[x] + dx*(8-dy)*src2[x]+ | |
346 | 16562072 | (8-dx)* dy *src3[x] + dx* dy *src4[x]+32)>>6; | |
347 | } | ||
348 | 3464504 | src1+=stride1; | |
349 | 3464504 | src2+=stride2; | |
350 | 3464504 | src3+=stride3; | |
351 | 3464504 | src4+=stride4; | |
352 | 3464504 | dst +=stride; | |
353 | } | ||
354 | }else{ | ||
355 | 2450950 | const uint8_t *src1= hpel[l]; | |
356 | 2450950 | const uint8_t *src2= hpel[r]; | |
357 |
2/2✓ Branch 0 taken 600698 times.
✓ Branch 1 taken 1850252 times.
|
2450950 | int stride1 = MC_STRIDE(l); |
358 |
2/2✓ Branch 0 taken 655540 times.
✓ Branch 1 taken 1795410 times.
|
2450950 | int stride2 = MC_STRIDE(r); |
359 | 2450950 | int a= weight[((dx&7) + (8*(dy&7)))]; | |
360 | 2450950 | int b= 8-a; | |
361 |
2/2✓ Branch 0 taken 10726636 times.
✓ Branch 1 taken 2450950 times.
|
13177586 | for(y=0; y < b_h; y++){ |
362 |
2/2✓ Branch 0 taken 52938552 times.
✓ Branch 1 taken 10726636 times.
|
63665188 | for(x=0; x < b_w; x++){ |
363 | 52938552 | dst[x]= (a*src1[x] + b*src2[x] + 4)>>3; | |
364 | } | ||
365 | 10726636 | src1+=stride1; | |
366 | 10726636 | src2+=stride2; | |
367 | 10726636 | dst +=stride; | |
368 | } | ||
369 | } | ||
370 | 3240046 | } | |
371 | |||
372 | 9378716 | void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, ptrdiff_t stride, int sx, int sy, int b_w, int b_h, const BlockNode *block, int plane_index, int w, int h){ | |
373 |
2/2✓ Branch 0 taken 1260713 times.
✓ Branch 1 taken 8118003 times.
|
9378716 | if(block->type & BLOCK_INTRA){ |
374 | int x, y; | ||
375 | 1260713 | const unsigned color = block->color[plane_index]; | |
376 | 1260713 | const unsigned color4 = color*0x01010101; | |
377 |
2/2✓ Branch 0 taken 18314 times.
✓ Branch 1 taken 1242399 times.
|
1260713 | if(b_w==32){ |
378 |
2/2✓ Branch 0 taken 586048 times.
✓ Branch 1 taken 18314 times.
|
604362 | for(y=0; y < b_h; y++){ |
379 | 586048 | *(uint32_t*)&dst[0 + y*stride]= color4; | |
380 | 586048 | *(uint32_t*)&dst[4 + y*stride]= color4; | |
381 | 586048 | *(uint32_t*)&dst[8 + y*stride]= color4; | |
382 | 586048 | *(uint32_t*)&dst[12+ y*stride]= color4; | |
383 | 586048 | *(uint32_t*)&dst[16+ y*stride]= color4; | |
384 | 586048 | *(uint32_t*)&dst[20+ y*stride]= color4; | |
385 | 586048 | *(uint32_t*)&dst[24+ y*stride]= color4; | |
386 | 586048 | *(uint32_t*)&dst[28+ y*stride]= color4; | |
387 | } | ||
388 |
2/2✓ Branch 0 taken 131664 times.
✓ Branch 1 taken 1110735 times.
|
1242399 | }else if(b_w==16){ |
389 |
2/2✓ Branch 0 taken 1976224 times.
✓ Branch 1 taken 131664 times.
|
2107888 | for(y=0; y < b_h; y++){ |
390 | 1976224 | *(uint32_t*)&dst[0 + y*stride]= color4; | |
391 | 1976224 | *(uint32_t*)&dst[4 + y*stride]= color4; | |
392 | 1976224 | *(uint32_t*)&dst[8 + y*stride]= color4; | |
393 | 1976224 | *(uint32_t*)&dst[12+ y*stride]= color4; | |
394 | } | ||
395 |
2/2✓ Branch 0 taken 545322 times.
✓ Branch 1 taken 565413 times.
|
1110735 | }else if(b_w==8){ |
396 |
2/2✓ Branch 0 taken 4272760 times.
✓ Branch 1 taken 545322 times.
|
4818082 | for(y=0; y < b_h; y++){ |
397 | 4272760 | *(uint32_t*)&dst[0 + y*stride]= color4; | |
398 | 4272760 | *(uint32_t*)&dst[4 + y*stride]= color4; | |
399 | } | ||
400 |
2/2✓ Branch 0 taken 564463 times.
✓ Branch 1 taken 950 times.
|
565413 | }else if(b_w==4){ |
401 |
2/2✓ Branch 0 taken 2300276 times.
✓ Branch 1 taken 564463 times.
|
2864739 | for(y=0; y < b_h; y++){ |
402 | 2300276 | *(uint32_t*)&dst[0 + y*stride]= color4; | |
403 | } | ||
404 | }else{ | ||
405 |
2/2✓ Branch 0 taken 3740 times.
✓ Branch 1 taken 950 times.
|
4690 | for(y=0; y < b_h; y++){ |
406 |
2/2✓ Branch 0 taken 7480 times.
✓ Branch 1 taken 3740 times.
|
11220 | for(x=0; x < b_w; x++){ |
407 | 7480 | dst[x + y*stride]= color; | |
408 | } | ||
409 | } | ||
410 | } | ||
411 | }else{ | ||
412 | 8118003 | const uint8_t *src = s->last_picture[block->ref]->data[plane_index]; | |
413 |
2/2✓ Branch 0 taken 5219918 times.
✓ Branch 1 taken 2898085 times.
|
8118003 | const int scale= plane_index ? (2*s->mv_scale)>>s->chroma_h_shift : 2*s->mv_scale; |
414 | 8118003 | int mx= block->mx*scale; | |
415 | 8118003 | int my= block->my*scale; | |
416 | 8118003 | const int dx= mx&15; | |
417 | 8118003 | const int dy= my&15; | |
418 | 8118003 | const int tab_index= 3 - (b_w>>2) + (b_w>>4); | |
419 | 8118003 | sx += (mx>>4) - (HTAPS_MAX/2-1); | |
420 | 8118003 | sy += (my>>4) - (HTAPS_MAX/2-1); | |
421 | 8118003 | src += sx + sy*stride; | |
422 |
3/4✓ Branch 0 taken 8118003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7607887 times.
✓ Branch 3 taken 510116 times.
|
8118003 | if( (unsigned)sx >= FFMAX(w - b_w - (HTAPS_MAX-2), 0) |
423 |
3/4✓ Branch 0 taken 7607887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 642582 times.
✓ Branch 3 taken 6965305 times.
|
7607887 | || (unsigned)sy >= FFMAX(h - b_h - (HTAPS_MAX-2), 0)){ |
424 | 1152698 | s->vdsp.emulated_edge_mc(tmp + MB_SIZE, src, | |
425 | stride, stride, | ||
426 | b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, | ||
427 | sx, sy, w, h); | ||
428 | 1152698 | src= tmp + MB_SIZE; | |
429 | } | ||
430 | |||
431 | av_assert2(s->chroma_h_shift == s->chroma_v_shift); // only one mv_scale | ||
432 | |||
433 | av_assert2((tab_index>=0 && tab_index<4) || b_w==32); | ||
434 |
4/4✓ Branch 0 taken 5952425 times.
✓ Branch 1 taken 2165578 times.
✓ Branch 2 taken 4898211 times.
✓ Branch 3 taken 1054214 times.
|
8118003 | if( (dx&3) || (dy&3) |
435 |
5/6✓ Branch 0 taken 349199 times.
✓ Branch 1 taken 4549012 times.
✓ Branch 2 taken 204372 times.
✓ Branch 3 taken 144827 times.
✓ Branch 4 taken 204372 times.
✗ Branch 5 not taken.
|
4898211 | || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h) |
436 |
1/2✓ Branch 0 taken 4898211 times.
✗ Branch 1 not taken.
|
4898211 | || (b_w&(b_w-1)) |
437 |
1/2✓ Branch 0 taken 4898211 times.
✗ Branch 1 not taken.
|
4898211 | || b_w == 1 |
438 |
1/2✓ Branch 0 taken 4898211 times.
✗ Branch 1 not taken.
|
4898211 | || b_h == 1 |
439 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4898211 times.
|
4898211 | || !s->plane[plane_index].fast_mc ) |
440 | 3219792 | mc_block(&s->plane[plane_index], dst, src, stride, b_w, b_h, dx, dy); | |
441 |
2/2✓ Branch 0 taken 288126 times.
✓ Branch 1 taken 4610085 times.
|
4898211 | else if(b_w==32){ |
442 | int y; | ||
443 |
2/2✓ Branch 0 taken 576252 times.
✓ Branch 1 taken 288126 times.
|
864378 | for(y=0; y<b_h; y+=16){ |
444 | 576252 | s->put_snow_qpel_pixels_tab[0][dy+(dx>>2)](dst + y*stride, src + 3 + (y+3)*stride,stride); | |
445 | 576252 | s->put_snow_qpel_pixels_tab[0][dy+(dx>>2)](dst + 16 + y*stride, src + 19 + (y+3)*stride,stride); | |
446 | } | ||
447 |
2/2✓ Branch 0 taken 4260886 times.
✓ Branch 1 taken 349199 times.
|
4610085 | }else if(b_w==b_h) |
448 | 4260886 | s->put_snow_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst,src + 3 + 3*stride,stride); | |
449 |
2/2✓ Branch 0 taken 204372 times.
✓ Branch 1 taken 144827 times.
|
349199 | else if(b_w==2*b_h){ |
450 | 204372 | s->put_snow_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst ,src + 3 + 3*stride,stride); | |
451 | 204372 | s->put_snow_qpel_pixels_tab[tab_index+1][dy+(dx>>2)](dst+b_h,src + 3 + b_h + 3*stride,stride); | |
452 | }else{ | ||
453 | av_assert2(2*b_w==b_h); | ||
454 | 144827 | s->put_snow_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst ,src + 3 + 3*stride ,stride); | |
455 | 144827 | s->put_snow_qpel_pixels_tab[tab_index ][dy+(dx>>2)](dst+b_w*stride,src + 3 + 3*stride+b_w*stride,stride); | |
456 | } | ||
457 | } | ||
458 | 9378716 | } | |
459 | |||
460 | #define mca(dx,dy,b_w)\ | ||
461 | static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h){\ | ||
462 | av_assert2(h==b_w);\ | ||
463 | mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\ | ||
464 | } | ||
465 | |||
466 | ✗ | mca( 0, 0,16) | |
467 | 5531 | mca( 8, 0,16) | |
468 | 4969 | mca( 0, 8,16) | |
469 | 9754 | mca( 8, 8,16) | |
470 | ✗ | mca( 0, 0,8) | |
471 | ✗ | mca( 8, 0,8) | |
472 | ✗ | mca( 0, 8,8) | |
473 | ✗ | mca( 8, 8,8) | |
474 | |||
475 | 22 | static av_cold void snow_static_init(void) | |
476 | { | ||
477 |
2/2✓ Branch 0 taken 176 times.
✓ Branch 1 taken 22 times.
|
198 | for (int i = 0; i < MAX_REF_FRAMES; i++) |
478 |
2/2✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 176 times.
|
1584 | for (int j = 0; j < MAX_REF_FRAMES; j++) |
479 | 1408 | ff_scale_mv_ref[i][j] = 256 * (i + 1) / (j + 1); | |
480 | 22 | } | |
481 | |||
482 | 31 | av_cold int ff_snow_common_init(AVCodecContext *avctx){ | |
483 | static AVOnce init_static_once = AV_ONCE_INIT; | ||
484 | 31 | SnowContext *s = avctx->priv_data; | |
485 | int width, height; | ||
486 | int i; | ||
487 | |||
488 | 31 | s->avctx= avctx; | |
489 | 31 | s->max_ref_frames=1; //just make sure it's not an invalid value in case of no initial keyframe | |
490 | 31 | s->spatial_decomposition_count = 1; | |
491 | |||
492 | 31 | ff_videodsp_init(&s->vdsp, 8); | |
493 | 31 | ff_dwt_init(&s->dwt); | |
494 | |||
495 | 31 | init_qpel(s); | |
496 | |||
497 | #define mcfh(dx,dy)\ | ||
498 | s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\ | ||
499 | s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\ | ||
500 | mc_block_hpel ## dx ## dy ## 16;\ | ||
501 | s->hdsp.put_pixels_tab [1][dy/4+dx/8]=\ | ||
502 | s->hdsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\ | ||
503 | mc_block_hpel ## dx ## dy ## 8; | ||
504 | |||
505 | 31 | mcfh(0, 0) | |
506 | 31 | mcfh(8, 0) | |
507 | 31 | mcfh(0, 8) | |
508 | 31 | mcfh(8, 8) | |
509 | |||
510 | // dec += FFMAX(s->chroma_h_shift, s->chroma_v_shift); | ||
511 | |||
512 | 31 | width= s->avctx->width; | |
513 | 31 | height= s->avctx->height; | |
514 | |||
515 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | if (!FF_ALLOCZ_TYPED_ARRAY(s->spatial_idwt_buffer, width * height) || |
516 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | !FF_ALLOCZ_TYPED_ARRAY(s->spatial_dwt_buffer, width * height) || //FIXME this does not belong here |
517 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | !FF_ALLOCZ_TYPED_ARRAY(s->temp_dwt_buffer, width) || |
518 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | !FF_ALLOCZ_TYPED_ARRAY(s->temp_idwt_buffer, width) || |
519 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
|
31 | !FF_ALLOCZ_TYPED_ARRAY(s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1) + 1)) |
520 | ✗ | return AVERROR(ENOMEM); | |
521 | |||
522 |
2/2✓ Branch 0 taken 248 times.
✓ Branch 1 taken 31 times.
|
279 | for(i=0; i<MAX_REF_FRAMES; i++) { |
523 | 248 | s->last_picture[i] = av_frame_alloc(); | |
524 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
|
248 | if (!s->last_picture[i]) |
525 | ✗ | return AVERROR(ENOMEM); | |
526 | } | ||
527 | |||
528 | 31 | s->mconly_picture = av_frame_alloc(); | |
529 | 31 | s->current_picture = av_frame_alloc(); | |
530 |
2/4✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
|
31 | if (!s->mconly_picture || !s->current_picture) |
531 | ✗ | return AVERROR(ENOMEM); | |
532 | |||
533 | 31 | ff_thread_once(&init_static_once, snow_static_init); | |
534 | |||
535 | 31 | return 0; | |
536 | } | ||
537 | |||
538 | 973 | int ff_snow_common_init_after_header(AVCodecContext *avctx) { | |
539 | 973 | SnowContext *s = avctx->priv_data; | |
540 | int plane_index, level, orientation; | ||
541 | |||
542 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 942 times.
|
973 | if(!s->scratchbuf) { |
543 | int emu_buf_size; | ||
544 | 31 | emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1); | |
545 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
31 | if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) || |
546 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
|
31 | !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size)) |
547 | ✗ | return AVERROR(ENOMEM); | |
548 | } | ||
549 | |||
550 |
2/2✓ Branch 0 taken 2919 times.
✓ Branch 1 taken 973 times.
|
3892 | for(plane_index=0; plane_index < s->nb_planes; plane_index++){ |
551 | 2919 | int w= s->avctx->width; | |
552 | 2919 | int h= s->avctx->height; | |
553 | |||
554 |
2/2✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 973 times.
|
2919 | if(plane_index){ |
555 | 1946 | w = AV_CEIL_RSHIFT(w, s->chroma_h_shift); | |
556 | 1946 | h = AV_CEIL_RSHIFT(h, s->chroma_v_shift); | |
557 | } | ||
558 | 2919 | s->plane[plane_index].width = w; | |
559 | 2919 | s->plane[plane_index].height= h; | |
560 | |||
561 |
2/2✓ Branch 0 taken 14595 times.
✓ Branch 1 taken 2919 times.
|
17514 | for(level=s->spatial_decomposition_count-1; level>=0; level--){ |
562 |
2/2✓ Branch 0 taken 46704 times.
✓ Branch 1 taken 14595 times.
|
61299 | for(orientation=level ? 1 : 0; orientation<4; orientation++){ |
563 | 46704 | SubBand *b= &s->plane[plane_index].band[level][orientation]; | |
564 | |||
565 | 46704 | b->buf= s->spatial_dwt_buffer; | |
566 | 46704 | b->level= level; | |
567 | 46704 | b->stride= s->plane[plane_index].width << (s->spatial_decomposition_count - level); | |
568 | 46704 | b->width = (w + !(orientation&1))>>1; | |
569 | 46704 | b->height= (h + !(orientation>1))>>1; | |
570 | |||
571 | 46704 | b->stride_line = 1 << (s->spatial_decomposition_count - level); | |
572 | 46704 | b->buf_x_offset = 0; | |
573 | 46704 | b->buf_y_offset = 0; | |
574 | |||
575 |
2/2✓ Branch 0 taken 29190 times.
✓ Branch 1 taken 17514 times.
|
46704 | if(orientation&1){ |
576 | 29190 | b->buf += (w+1)>>1; | |
577 | 29190 | b->buf_x_offset = (w+1)>>1; | |
578 | } | ||
579 |
2/2✓ Branch 0 taken 29190 times.
✓ Branch 1 taken 17514 times.
|
46704 | if(orientation>1){ |
580 | 29190 | b->buf += b->stride>>1; | |
581 | 29190 | b->buf_y_offset = b->stride_line >> 1; | |
582 | } | ||
583 | 46704 | b->ibuf= s->spatial_idwt_buffer + (b->buf - s->spatial_dwt_buffer); | |
584 | |||
585 |
2/2✓ Branch 0 taken 35028 times.
✓ Branch 1 taken 11676 times.
|
46704 | if(level) |
586 | 35028 | b->parent= &s->plane[plane_index].band[level-1][orientation]; | |
587 | //FIXME avoid this realloc | ||
588 | 46704 | av_freep(&b->x_coeff); | |
589 | 46704 | b->x_coeff = av_calloc((b->width + 1) * b->height + 1, | |
590 | sizeof(*b->x_coeff)); | ||
591 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46704 times.
|
46704 | if (!b->x_coeff) |
592 | ✗ | return AVERROR(ENOMEM); | |
593 | } | ||
594 | 14595 | w= (w+1)>>1; | |
595 | 14595 | h= (h+1)>>1; | |
596 | } | ||
597 | } | ||
598 | |||
599 | 973 | return 0; | |
600 | } | ||
601 | |||
602 | 973 | int ff_snow_frames_prepare(SnowContext *s) | |
603 | { | ||
604 | AVFrame *tmp; | ||
605 | |||
606 | 973 | tmp= s->last_picture[s->max_ref_frames-1]; | |
607 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 973 times.
|
973 | for (int i = s->max_ref_frames - 1; i > 0; i--) |
608 | ✗ | s->last_picture[i] = s->last_picture[i-1]; | |
609 | 973 | s->last_picture[0] = s->current_picture; | |
610 | 973 | s->current_picture = tmp; | |
611 | |||
612 | 973 | av_frame_unref(s->current_picture); | |
613 | |||
614 |
2/2✓ Branch 0 taken 103 times.
✓ Branch 1 taken 870 times.
|
973 | if(s->keyframe){ |
615 | 103 | s->ref_frames= 0; | |
616 | 103 | s->current_picture->flags |= AV_FRAME_FLAG_KEY; | |
617 | }else{ | ||
618 | int i; | ||
619 |
3/4✓ Branch 0 taken 870 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 870 times.
✗ Branch 3 not taken.
|
1740 | for(i=0; i<s->max_ref_frames && s->last_picture[i]->data[0]; i++) |
620 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
870 | if(i && (s->last_picture[i-1]->flags & AV_FRAME_FLAG_KEY)) |
621 | ✗ | break; | |
622 | 870 | s->ref_frames= i; | |
623 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 870 times.
|
870 | if(s->ref_frames==0){ |
624 | ✗ | av_log(s->avctx,AV_LOG_ERROR, "No reference frames\n"); | |
625 | ✗ | return AVERROR_INVALIDDATA; | |
626 | } | ||
627 | 870 | s->current_picture->flags &= ~AV_FRAME_FLAG_KEY; | |
628 | } | ||
629 | |||
630 | 973 | return 0; | |
631 | } | ||
632 | |||
633 | 31 | av_cold void ff_snow_common_end(SnowContext *s) | |
634 | { | ||
635 | int plane_index, level, orientation, i; | ||
636 | |||
637 | 31 | av_freep(&s->spatial_dwt_buffer); | |
638 | 31 | av_freep(&s->temp_dwt_buffer); | |
639 | 31 | av_freep(&s->spatial_idwt_buffer); | |
640 | 31 | av_freep(&s->temp_idwt_buffer); | |
641 | 31 | av_freep(&s->run_buffer); | |
642 | |||
643 | 31 | av_freep(&s->block); | |
644 | 31 | av_freep(&s->scratchbuf); | |
645 | 31 | av_freep(&s->emu_edge_buffer); | |
646 | |||
647 |
2/2✓ Branch 0 taken 248 times.
✓ Branch 1 taken 31 times.
|
279 | for(i=0; i<MAX_REF_FRAMES; i++){ |
648 | 248 | av_frame_free(&s->last_picture[i]); | |
649 | } | ||
650 | |||
651 |
2/2✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
|
155 | for(plane_index=0; plane_index < MAX_PLANES; plane_index++){ |
652 |
2/2✓ Branch 0 taken 992 times.
✓ Branch 1 taken 124 times.
|
1116 | for(level=MAX_DECOMPOSITIONS-1; level>=0; level--){ |
653 |
2/2✓ Branch 0 taken 3100 times.
✓ Branch 1 taken 992 times.
|
4092 | for(orientation=level ? 1 : 0; orientation<4; orientation++){ |
654 | 3100 | SubBand *b= &s->plane[plane_index].band[level][orientation]; | |
655 | |||
656 | 3100 | av_freep(&b->x_coeff); | |
657 | } | ||
658 | } | ||
659 | } | ||
660 | 31 | av_frame_free(&s->mconly_picture); | |
661 | 31 | av_frame_free(&s->current_picture); | |
662 | 31 | } | |
663 |