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