FFmpeg
h261.c
Go to the documentation of this file.
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, int stride)
34 {
35  int x, y, xy, yz;
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  xy = y * stride + x;
45  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  xy = y * stride + x;
55  yz = y * 8 + x;
56  src[xy] = (temp[yz - 1] + 2 * temp[yz] + temp[yz + 1] + 8) >> 4;
57  }
58  }
59 }
60 
62 {
63  H261Context *h = (H261Context *)s;
64  const int linesize = s->linesize;
65  const int uvlinesize = s->uvlinesize;
66  uint8_t *dest_y = s->dest[0];
67  uint8_t *dest_cb = s->dest[1];
68  uint8_t *dest_cr = s->dest[2];
69 
70  if (!(IS_FIL(h->mtype)))
71  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 }
stride
int stride
Definition: mace.c:144
IS_FIL
#define IS_FIL(a)
Definition: h261.c:31
mpegvideo.h
h261_loop_filter
static void h261_loop_filter(uint8_t *src, int stride)
Definition: h261.c:33
h261.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
src
#define src
Definition: vp8dsp.c:255
H261Context
H261Context.
Definition: h261.h:37
ff_h261_loop_filter
void ff_h261_loop_filter(MpegEncContext *s)
Definition: h261.c:61
temp
else temp
Definition: vf_mcdeint.c:248
h
h
Definition: vp9dsp_template.c:2038
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:71