Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * H.261 common code | ||
3 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
4 | * Copyright (c) 2004 Maarten Daniels | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | /** | ||
24 | * @file | ||
25 | * H.261 codec | ||
26 | */ | ||
27 | |||
28 | #include "h261.h" | ||
29 | #include "mpegvideo.h" | ||
30 | |||
31 | #define IS_FIL(a) ((a) & MB_TYPE_H261_FIL) | ||
32 | |||
33 | ✗ | static void h261_loop_filter(uint8_t *src, ptrdiff_t stride) | |
34 | { | ||
35 | int x, y; | ||
36 | int temp[64]; | ||
37 | |||
38 | ✗ | for (x = 0; x < 8; x++) { | |
39 | ✗ | temp[x] = 4 * src[x]; | |
40 | ✗ | temp[x + 7 * 8] = 4 * src[x + 7 * stride]; | |
41 | } | ||
42 | ✗ | for (y = 1; y < 7; y++) { | |
43 | ✗ | for (x = 0; x < 8; x++) { | |
44 | ✗ | ptrdiff_t xy = y * stride + x; | |
45 | ✗ | ptrdiff_t yz = y * 8 + x; | |
46 | ✗ | temp[yz] = src[xy - stride] + 2 * src[xy] + src[xy + stride]; | |
47 | } | ||
48 | } | ||
49 | |||
50 | ✗ | for (y = 0; y < 8; y++) { | |
51 | ✗ | src[y * stride] = (temp[y * 8] + 2) >> 2; | |
52 | ✗ | src[y * stride + 7] = (temp[y * 8 + 7] + 2) >> 2; | |
53 | ✗ | for (x = 1; x < 7; x++) { | |
54 | ✗ | ptrdiff_t xy = y * stride + x; | |
55 | ✗ | ptrdiff_t yz = y * 8 + x; | |
56 | ✗ | src[xy] = (temp[yz - 1] + 2 * temp[yz] + temp[yz + 1] + 8) >> 4; | |
57 | } | ||
58 | } | ||
59 | ✗ | } | |
60 | |||
61 | 206286 | void ff_h261_loop_filter(MpegEncContext *s) | |
62 | { | ||
63 | 206286 | H261Context *const h = s->private_ctx; | |
64 | 206286 | const ptrdiff_t linesize = s->linesize; | |
65 | 206286 | const ptrdiff_t uvlinesize = s->uvlinesize; | |
66 | 206286 | uint8_t *dest_y = s->dest[0]; | |
67 | 206286 | uint8_t *dest_cb = s->dest[1]; | |
68 | 206286 | uint8_t *dest_cr = s->dest[2]; | |
69 | |||
70 |
1/2✓ Branch 0 taken 206286 times.
✗ Branch 1 not taken.
|
206286 | if (!(IS_FIL(h->mtype))) |
71 | 206286 | return; | |
72 | |||
73 | ✗ | h261_loop_filter(dest_y, linesize); | |
74 | ✗ | h261_loop_filter(dest_y + 8, linesize); | |
75 | ✗ | h261_loop_filter(dest_y + 8 * linesize, linesize); | |
76 | ✗ | h261_loop_filter(dest_y + 8 * linesize + 8, linesize); | |
77 | ✗ | h261_loop_filter(dest_cb, uvlinesize); | |
78 | ✗ | h261_loop_filter(dest_cr, uvlinesize); | |
79 | } | ||
80 |