| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> | ||
| 3 | * Copyright (c) 2014 Arwa Arif <arwaarif1994@gmail.com> | ||
| 4 | * | ||
| 5 | * This file is part of FFmpeg. | ||
| 6 | * | ||
| 7 | * FFmpeg is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along | ||
| 18 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @file | ||
| 24 | * Postprocessing filter - 7 | ||
| 25 | * | ||
| 26 | * Originally written by Michael Niedermayer for the MPlayer | ||
| 27 | * project, and ported by Arwa Arif for FFmpeg. | ||
| 28 | */ | ||
| 29 | |||
| 30 | #include "libavutil/emms.h" | ||
| 31 | #include "libavutil/imgutils.h" | ||
| 32 | #include "libavutil/mem.h" | ||
| 33 | #include "libavutil/mem_internal.h" | ||
| 34 | #include "libavutil/opt.h" | ||
| 35 | #include "libavutil/pixdesc.h" | ||
| 36 | |||
| 37 | #include "filters.h" | ||
| 38 | #include "qp_table.h" | ||
| 39 | #include "vf_pp7.h" | ||
| 40 | #include "video.h" | ||
| 41 | |||
| 42 | enum mode { | ||
| 43 | MODE_HARD, | ||
| 44 | MODE_SOFT, | ||
| 45 | MODE_MEDIUM | ||
| 46 | }; | ||
| 47 | |||
| 48 | #define OFFSET(x) offsetof(PP7Context, x) | ||
| 49 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM | ||
| 50 | static const AVOption pp7_options[] = { | ||
| 51 | { "qp", "force a constant quantizer parameter", OFFSET(qp), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 64, FLAGS }, | ||
| 52 | { "mode", "set thresholding mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MODE_MEDIUM}, 0, 2, FLAGS, .unit = "mode" }, | ||
| 53 | { "hard", "hard thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_HARD}, INT_MIN, INT_MAX, FLAGS, .unit = "mode" }, | ||
| 54 | { "soft", "soft thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_SOFT}, INT_MIN, INT_MAX, FLAGS, .unit = "mode" }, | ||
| 55 | { "medium", "medium thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_MEDIUM}, INT_MIN, INT_MAX, FLAGS, .unit = "mode" }, | ||
| 56 | { NULL } | ||
| 57 | }; | ||
| 58 | |||
| 59 | AVFILTER_DEFINE_CLASS(pp7); | ||
| 60 | |||
| 61 | DECLARE_ALIGNED(8, static const uint8_t, dither)[8][8] = { | ||
| 62 | { 0, 48, 12, 60, 3, 51, 15, 63, }, | ||
| 63 | { 32, 16, 44, 28, 35, 19, 47, 31, }, | ||
| 64 | { 8, 56, 4, 52, 11, 59, 7, 55, }, | ||
| 65 | { 40, 24, 36, 20, 43, 27, 39, 23, }, | ||
| 66 | { 2, 50, 14, 62, 1, 49, 13, 61, }, | ||
| 67 | { 34, 18, 46, 30, 33, 17, 45, 29, }, | ||
| 68 | { 10, 58, 6, 54, 9, 57, 5, 53, }, | ||
| 69 | { 42, 26, 38, 22, 41, 25, 37, 21, }, | ||
| 70 | }; | ||
| 71 | |||
| 72 | #define N0 4 | ||
| 73 | #define N1 5 | ||
| 74 | #define N2 10 | ||
| 75 | #define SN0 2 | ||
| 76 | #define SN1 2.2360679775 | ||
| 77 | #define SN2 3.16227766017 | ||
| 78 | #define N (1 << 16) | ||
| 79 | |||
| 80 | static const int factor[16] = { | ||
| 81 | N / (N0 * N0), N / (N0 * N1), N / (N0 * N0), N / (N0 * N2), | ||
| 82 | N / (N1 * N0), N / (N1 * N1), N / (N1 * N0), N / (N1 * N2), | ||
| 83 | N / (N0 * N0), N / (N0 * N1), N / (N0 * N0), N / (N0 * N2), | ||
| 84 | N / (N2 * N0), N / (N2 * N1), N / (N2 * N0), N / (N2 * N2), | ||
| 85 | }; | ||
| 86 | |||
| 87 | 1 | static void init_thres2(PP7Context *p) | |
| 88 | { | ||
| 89 | int qp, i; | ||
| 90 | 1 | int bias = 0; //FIXME | |
| 91 | |||
| 92 |
2/2✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1 times.
|
100 | for (qp = 0; qp < 99; qp++) { |
| 93 |
2/2✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 99 times.
|
1683 | for (i = 0; i < 16; i++) { |
| 94 |
6/6✓ Branch 0 taken 792 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 792 times.
✓ Branch 3 taken 792 times.
✓ Branch 4 taken 1568 times.
✓ Branch 5 taken 16 times.
|
1584 | p->thres2[qp][i] = ((i&1) ? SN2 : SN0) * ((i&4) ? SN2 : SN0) * FFMAX(1, qp) * (1<<2) - 1 - bias; |
| 95 | } | ||
| 96 | } | ||
| 97 | 1 | } | |
| 98 | |||
| 99 | 235008 | static inline void dctA_c(int16_t *dst, uint8_t *src, int stride) | |
| 100 | { | ||
| 101 | int i; | ||
| 102 | |||
| 103 |
2/2✓ Branch 0 taken 940032 times.
✓ Branch 1 taken 235008 times.
|
1175040 | for (i = 0; i < 4; i++) { |
| 104 | 940032 | int s0 = src[0 * stride] + src[6 * stride]; | |
| 105 | 940032 | int s1 = src[1 * stride] + src[5 * stride]; | |
| 106 | 940032 | int s2 = src[2 * stride] + src[4 * stride]; | |
| 107 | 940032 | int s3 = src[3 * stride]; | |
| 108 | 940032 | int s = s3 + s3; | |
| 109 | 940032 | s3 = s - s0; | |
| 110 | 940032 | s0 = s + s0; | |
| 111 | 940032 | s = s2 + s1; | |
| 112 | 940032 | s2 = s2 - s1; | |
| 113 | 940032 | dst[0] = s0 + s; | |
| 114 | 940032 | dst[2] = s0 - s; | |
| 115 | 940032 | dst[1] = 2 * s3 + s2; | |
| 116 | 940032 | dst[3] = s3 - 2 * s2; | |
| 117 | 940032 | src++; | |
| 118 | 940032 | dst += 4; | |
| 119 | } | ||
| 120 | 235008 | } | |
| 121 | |||
| 122 | 912384 | static void dctB_c(int16_t *dst, int16_t *src) | |
| 123 | { | ||
| 124 | int i; | ||
| 125 | |||
| 126 |
2/2✓ Branch 0 taken 3649536 times.
✓ Branch 1 taken 912384 times.
|
4561920 | for (i = 0; i < 4; i++) { |
| 127 | 3649536 | int s0 = src[0 * 4] + src[6 * 4]; | |
| 128 | 3649536 | int s1 = src[1 * 4] + src[5 * 4]; | |
| 129 | 3649536 | int s2 = src[2 * 4] + src[4 * 4]; | |
| 130 | 3649536 | int s3 = src[3 * 4]; | |
| 131 | 3649536 | int s = s3 + s3; | |
| 132 | 3649536 | s3 = s - s0; | |
| 133 | 3649536 | s0 = s + s0; | |
| 134 | 3649536 | s = s2 + s1; | |
| 135 | 3649536 | s2 = s2 - s1; | |
| 136 | 3649536 | dst[0 * 4] = s0 + s; | |
| 137 | 3649536 | dst[2 * 4] = s0 - s; | |
| 138 | 3649536 | dst[1 * 4] = 2 * s3 + s2; | |
| 139 | 3649536 | dst[3 * 4] = s3 - 2 * s2; | |
| 140 | 3649536 | src++; | |
| 141 | 3649536 | dst++; | |
| 142 | } | ||
| 143 | 912384 | } | |
| 144 | |||
| 145 | ✗ | static int hardthresh_c(PP7Context *p, int16_t *src, int qp) | |
| 146 | { | ||
| 147 | int i; | ||
| 148 | int a; | ||
| 149 | |||
| 150 | ✗ | a = src[0] * factor[0]; | |
| 151 | ✗ | for (i = 1; i < 16; i++) { | |
| 152 | ✗ | unsigned int threshold1 = p->thres2[qp][i]; | |
| 153 | ✗ | unsigned int threshold2 = threshold1 << 1; | |
| 154 | ✗ | int level = src[i]; | |
| 155 | ✗ | if (((unsigned)(level + threshold1)) > threshold2) | |
| 156 | ✗ | a += level * factor[i]; | |
| 157 | } | ||
| 158 | ✗ | return (a + (1 << 11)) >> 12; | |
| 159 | } | ||
| 160 | |||
| 161 | 912384 | static int mediumthresh_c(PP7Context *p, int16_t *src, int qp) | |
| 162 | { | ||
| 163 | int i; | ||
| 164 | int a; | ||
| 165 | |||
| 166 | 912384 | a = src[0] * factor[0]; | |
| 167 |
2/2✓ Branch 0 taken 13685760 times.
✓ Branch 1 taken 912384 times.
|
14598144 | for (i = 1; i < 16; i++) { |
| 168 | 13685760 | unsigned int threshold1 = p->thres2[qp][i]; | |
| 169 | 13685760 | unsigned int threshold2 = threshold1 << 1; | |
| 170 | 13685760 | int level = src[i]; | |
| 171 |
2/2✓ Branch 0 taken 6743694 times.
✓ Branch 1 taken 6942066 times.
|
13685760 | if (((unsigned)(level + threshold1)) > threshold2) { |
| 172 |
2/2✓ Branch 0 taken 4707989 times.
✓ Branch 1 taken 2035705 times.
|
6743694 | if (((unsigned)(level + 2 * threshold1)) > 2 * threshold2) |
| 173 | 4707989 | a += level * factor[i]; | |
| 174 | else { | ||
| 175 |
2/2✓ Branch 0 taken 1016686 times.
✓ Branch 1 taken 1019019 times.
|
2035705 | if (level > 0) |
| 176 | 1016686 | a += 2 * (level - (int)threshold1) * factor[i]; | |
| 177 | else | ||
| 178 | 1019019 | a += 2 * (level + (int)threshold1) * factor[i]; | |
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | 912384 | return (a + (1 << 11)) >> 12; | |
| 183 | } | ||
| 184 | |||
| 185 | ✗ | static int softthresh_c(PP7Context *p, int16_t *src, int qp) | |
| 186 | { | ||
| 187 | int i; | ||
| 188 | int a; | ||
| 189 | |||
| 190 | ✗ | a = src[0] * factor[0]; | |
| 191 | ✗ | for (i = 1; i < 16; i++) { | |
| 192 | ✗ | unsigned int threshold1 = p->thres2[qp][i]; | |
| 193 | ✗ | unsigned int threshold2 = threshold1 << 1; | |
| 194 | ✗ | int level = src[i]; | |
| 195 | ✗ | if (((unsigned)(level + threshold1)) > threshold2) { | |
| 196 | ✗ | if (level > 0) | |
| 197 | ✗ | a += (level - (int)threshold1) * factor[i]; | |
| 198 | else | ||
| 199 | ✗ | a += (level + (int)threshold1) * factor[i]; | |
| 200 | } | ||
| 201 | } | ||
| 202 | ✗ | return (a + (1 << 11)) >> 12; | |
| 203 | } | ||
| 204 | |||
| 205 | 18 | static void filter(PP7Context *p, uint8_t *dst, uint8_t *src, | |
| 206 | int dst_stride, int src_stride, | ||
| 207 | int width, int height, | ||
| 208 | uint8_t *qp_store, int qp_stride, int is_luma) | ||
| 209 | { | ||
| 210 | int x, y; | ||
| 211 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
|
18 | const int stride = is_luma ? p->temp_stride : ((width + 16 + 15) & (~15)); |
| 212 | 18 | uint8_t *p_src = p->src + 8 * stride; | |
| 213 | 18 | int16_t *block = (int16_t *)p->src; | |
| 214 | 18 | int16_t *temp = (int16_t *)(p->src + 32); | |
| 215 | |||
| 216 |
2/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
|
18 | if (!src || !dst) return; |
| 217 |
2/2✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 18 times.
|
3474 | for (y = 0; y < height; y++) { |
| 218 | 3456 | int index = 8 + 8 * stride + y * stride; | |
| 219 | 3456 | memcpy(p_src + index, src + y * src_stride, width); | |
| 220 |
2/2✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 3456 times.
|
31104 | for (x = 0; x < 8; x++) { |
| 221 | 27648 | p_src[index - x - 1]= p_src[index + x ]; | |
| 222 | 27648 | p_src[index + width + x ]= p_src[index + width - x - 1]; | |
| 223 | } | ||
| 224 | } | ||
| 225 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 18 times.
|
162 | for (y = 0; y < 8; y++) { |
| 226 | 144 | memcpy(p_src + ( 7 - y ) * stride, p_src + ( y + 8 ) * stride, stride); | |
| 227 | 144 | memcpy(p_src + (height + 8 + y) * stride, p_src + (height - y + 7) * stride, stride); | |
| 228 | } | ||
| 229 | //FIXME (try edge emu) | ||
| 230 | |||
| 231 |
2/2✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 18 times.
|
3474 | for (y = 0; y < height; y++) { |
| 232 |
2/2✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 3456 times.
|
10368 | for (x = -8; x < 0; x += 4) { |
| 233 | 6912 | const int index = x + y * stride + (8 - 3) * (1 + stride) + 8; //FIXME silly offset | |
| 234 | 6912 | uint8_t *src = p_src + index; | |
| 235 | 6912 | int16_t *tp = temp + 4 * x; | |
| 236 | |||
| 237 | 6912 | dctA_c(tp + 4 * 8, src, stride); | |
| 238 | } | ||
| 239 |
2/2✓ Branch 0 taken 114048 times.
✓ Branch 1 taken 3456 times.
|
117504 | for (x = 0; x < width; ) { |
| 240 | 114048 | const int qps = 3 + is_luma; | |
| 241 | int qp; | ||
| 242 |
1/2✓ Branch 0 taken 114048 times.
✗ Branch 1 not taken.
|
114048 | int end = FFMIN(x + 8, width); |
| 243 | |||
| 244 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 114048 times.
|
114048 | if (p->qp) |
| 245 | ✗ | qp = p->qp; | |
| 246 | else { | ||
| 247 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 114048 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114048 times.
|
114048 | qp = qp_store[ (FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride]; |
| 248 | 114048 | qp = ff_norm_qscale(qp, p->qscale_type); | |
| 249 | } | ||
| 250 |
2/2✓ Branch 0 taken 912384 times.
✓ Branch 1 taken 114048 times.
|
1026432 | for (; x < end; x++) { |
| 251 | 912384 | const int index = x + y * stride + (8 - 3) * (1 + stride) + 8; //FIXME silly offset | |
| 252 | 912384 | uint8_t *src = p_src + index; | |
| 253 | 912384 | int16_t *tp = temp + 4 * x; | |
| 254 | int v; | ||
| 255 | |||
| 256 |
2/2✓ Branch 0 taken 228096 times.
✓ Branch 1 taken 684288 times.
|
912384 | if ((x & 3) == 0) |
| 257 | 228096 | dctA_c(tp + 4 * 8, src, stride); | |
| 258 | |||
| 259 | 912384 | p->dctB(block, tp); | |
| 260 | |||
| 261 | 912384 | v = p->requantize(p, block, qp); | |
| 262 | 912384 | v = (v + dither[y & 7][x & 7]) >> 6; | |
| 263 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 912375 times.
|
912384 | if ((unsigned)v > 255) |
| 264 | 9 | v = (-v) >> 31; | |
| 265 | 912384 | dst[x + y * dst_stride] = v; | |
| 266 | } | ||
| 267 | } | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | static const enum AVPixelFormat pix_fmts[] = { | ||
| 272 | AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, | ||
| 273 | AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, | ||
| 274 | AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, | ||
| 275 | AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, | ||
| 276 | AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ440P, | ||
| 277 | AV_PIX_FMT_GBRP, | ||
| 278 | AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE | ||
| 279 | }; | ||
| 280 | |||
| 281 | 1 | static int config_input(AVFilterLink *inlink) | |
| 282 | { | ||
| 283 | 1 | AVFilterContext *ctx = inlink->dst; | |
| 284 | 1 | PP7Context *pp7 = ctx->priv; | |
| 285 | 1 | const int h = FFALIGN(inlink->h + 16, 16); | |
| 286 | 1 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); | |
| 287 | |||
| 288 | 1 | pp7->hsub = desc->log2_chroma_w; | |
| 289 | 1 | pp7->vsub = desc->log2_chroma_h; | |
| 290 | |||
| 291 | 1 | pp7->temp_stride = FFALIGN(inlink->w + 16, 16); | |
| 292 | 1 | pp7->src = av_malloc_array(pp7->temp_stride, (h + 8) * sizeof(uint8_t)); | |
| 293 | |||
| 294 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!pp7->src) |
| 295 | ✗ | return AVERROR(ENOMEM); | |
| 296 | |||
| 297 | 1 | init_thres2(pp7); | |
| 298 | |||
| 299 |
1/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | switch (pp7->mode) { |
| 300 | ✗ | case 0: pp7->requantize = hardthresh_c; break; | |
| 301 | ✗ | case 1: pp7->requantize = softthresh_c; break; | |
| 302 | 1 | default: | |
| 303 | 1 | case 2: pp7->requantize = mediumthresh_c; break; | |
| 304 | } | ||
| 305 | |||
| 306 | 1 | pp7->dctB = dctB_c; | |
| 307 | |||
| 308 | #if ARCH_X86 && HAVE_X86ASM | ||
| 309 | 1 | ff_pp7_init_x86(pp7); | |
| 310 | #endif | ||
| 311 | |||
| 312 | 1 | return 0; | |
| 313 | } | ||
| 314 | |||
| 315 | 6 | static int filter_frame(AVFilterLink *inlink, AVFrame *in) | |
| 316 | { | ||
| 317 | 6 | AVFilterContext *ctx = inlink->dst; | |
| 318 | 6 | PP7Context *pp7 = ctx->priv; | |
| 319 | 6 | AVFilterLink *outlink = ctx->outputs[0]; | |
| 320 | 6 | AVFrame *out = in; | |
| 321 | |||
| 322 | 6 | int qp_stride = 0; | |
| 323 | 6 | int8_t *qp_table = NULL; | |
| 324 | |||
| 325 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (!pp7->qp) { |
| 326 | 6 | int ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL, &pp7->qscale_type); | |
| 327 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (ret < 0) { |
| 328 | ✗ | av_frame_free(&in); | |
| 329 | ✗ | return ret; | |
| 330 | } | ||
| 331 | } | ||
| 332 | |||
| 333 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (!ctx->is_disabled) { |
| 334 | 6 | const int cw = AV_CEIL_RSHIFT(inlink->w, pp7->hsub); | |
| 335 | 6 | const int ch = AV_CEIL_RSHIFT(inlink->h, pp7->vsub); | |
| 336 | |||
| 337 | /* get a new frame if in-place is not possible or if the dimensions | ||
| 338 | * are not multiple of 8 */ | ||
| 339 |
4/6✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
|
6 | if (!av_frame_is_writable(in) || (inlink->w & 7) || (inlink->h & 7)) { |
| 340 | 3 | const int aligned_w = FFALIGN(inlink->w, 8); | |
| 341 | 3 | const int aligned_h = FFALIGN(inlink->h, 8); | |
| 342 | |||
| 343 | 3 | out = ff_get_video_buffer(outlink, aligned_w, aligned_h); | |
| 344 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (!out) { |
| 345 | ✗ | av_frame_free(&in); | |
| 346 | ✗ | av_freep(&qp_table); | |
| 347 | ✗ | return AVERROR(ENOMEM); | |
| 348 | } | ||
| 349 | 3 | av_frame_copy_props(out, in); | |
| 350 | 3 | out->width = in->width; | |
| 351 | 3 | out->height = in->height; | |
| 352 | } | ||
| 353 | |||
| 354 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6 | if (qp_table || pp7->qp) { |
| 355 | |||
| 356 | 6 | filter(pp7, out->data[0], in->data[0], out->linesize[0], in->linesize[0], | |
| 357 | inlink->w, inlink->h, qp_table, qp_stride, 1); | ||
| 358 | 6 | filter(pp7, out->data[1], in->data[1], out->linesize[1], in->linesize[1], | |
| 359 | cw, ch, qp_table, qp_stride, 0); | ||
| 360 | 6 | filter(pp7, out->data[2], in->data[2], out->linesize[2], in->linesize[2], | |
| 361 | cw, ch, qp_table, qp_stride, 0); | ||
| 362 | 6 | emms_c(); | |
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 366 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | if (in != out) { |
| 367 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (in->data[3]) |
| 368 | ✗ | av_image_copy_plane(out->data[3], out->linesize[3], | |
| 369 | ✗ | in ->data[3], in ->linesize[3], | |
| 370 | inlink->w, inlink->h); | ||
| 371 | 3 | av_frame_free(&in); | |
| 372 | } | ||
| 373 | 6 | av_freep(&qp_table); | |
| 374 | 6 | return ff_filter_frame(outlink, out); | |
| 375 | } | ||
| 376 | |||
| 377 | 2 | static av_cold void uninit(AVFilterContext *ctx) | |
| 378 | { | ||
| 379 | 2 | PP7Context *pp7 = ctx->priv; | |
| 380 | 2 | av_freep(&pp7->src); | |
| 381 | 2 | } | |
| 382 | |||
| 383 | static const AVFilterPad pp7_inputs[] = { | ||
| 384 | { | ||
| 385 | .name = "default", | ||
| 386 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 387 | .config_props = config_input, | ||
| 388 | .filter_frame = filter_frame, | ||
| 389 | }, | ||
| 390 | }; | ||
| 391 | |||
| 392 | const FFFilter ff_vf_pp7 = { | ||
| 393 | .p.name = "pp7", | ||
| 394 | .p.description = NULL_IF_CONFIG_SMALL("Apply Postprocessing 7 filter."), | ||
| 395 | .p.priv_class = &pp7_class, | ||
| 396 | .p.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, | ||
| 397 | .priv_size = sizeof(PP7Context), | ||
| 398 | .uninit = uninit, | ||
| 399 | FILTER_INPUTS(pp7_inputs), | ||
| 400 | FILTER_OUTPUTS(ff_video_default_filterpad), | ||
| 401 | FILTER_PIXFMTS_ARRAY(pix_fmts), | ||
| 402 | }; | ||
| 403 |