FFmpeg
4.0
libavcodec
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 "
avcodec.h
"
29
#include "
h261.h
"
30
31
#define IS_FIL(a) ((a) & MB_TYPE_H261_FIL)
32
33
uint8_t
ff_h261_rl_table_store
[2][2 *
MAX_RUN
+
MAX_LEVEL
+ 3];
34
35
static
void
h261_loop_filter
(
uint8_t
*
src
,
int
stride
)
36
{
37
int
x, y, xy, yz;
38
int
temp
[64];
39
40
for
(x = 0; x < 8; x++) {
41
temp[x] = 4 * src[x];
42
temp[x + 7 * 8] = 4 * src[x + 7 *
stride
];
43
}
44
for
(y = 1; y < 7; y++) {
45
for
(x = 0; x < 8; x++) {
46
xy = y * stride + x;
47
yz = y * 8 + x;
48
temp[yz] = src[xy -
stride
] + 2 * src[xy] + src[xy +
stride
];
49
}
50
}
51
52
for
(y = 0; y < 8; y++) {
53
src[y *
stride
] = (temp[y * 8] + 2) >> 2;
54
src[y * stride + 7] = (temp[y * 8 + 7] + 2) >> 2;
55
for
(x = 1; x < 7; x++) {
56
xy = y * stride + x;
57
yz = y * 8 + x;
58
src[xy] = (temp[yz - 1] + 2 * temp[yz] + temp[yz + 1] + 8) >> 4;
59
}
60
}
61
}
62
63
void
ff_h261_loop_filter
(
MpegEncContext
*
s
)
64
{
65
H261Context
*
h
= (
H261Context
*)s;
66
const
int
linesize = s->
linesize
;
67
const
int
uvlinesize = s->
uvlinesize
;
68
uint8_t
*dest_y = s->
dest
[0];
69
uint8_t
*dest_cb = s->
dest
[1];
70
uint8_t
*dest_cr = s->
dest
[2];
71
72
if
(!(
IS_FIL
(h->
mtype
)))
73
return
;
74
75
h261_loop_filter
(dest_y, linesize);
76
h261_loop_filter
(dest_y + 8, linesize);
77
h261_loop_filter
(dest_y + 8 * linesize, linesize);
78
h261_loop_filter
(dest_y + 8 * linesize + 8, linesize);
79
h261_loop_filter
(dest_cb, uvlinesize);
80
h261_loop_filter
(dest_cr, uvlinesize);
81
}
82
83
av_cold
void
ff_h261_common_init
(
void
)
84
{
85
static
int
done = 0;
86
87
if
(done)
88
return
;
89
90
ff_rl_init
(&
ff_h261_rl_tcoeff
,
ff_h261_rl_table_store
);
91
done = 1;
92
}
s
const char * s
Definition:
avisynth_c.h:768
h
h
Definition:
vp9dsp_template.c:2038
temp
else temp
Definition:
vf_mcdeint.c:256
H261Context
H261Context.
Definition:
h261.h:37
src
#define src
Definition:
vp8dsp.c:254
stride
int stride
Definition:
mace.c:144
uint8_t
uint8_t
Definition:
audio_convert.c:194
av_cold
#define av_cold
Definition:
attributes.h:82
MAX_LEVEL
#define MAX_LEVEL
Definition:
rl.h:36
ff_h261_common_init
av_cold void ff_h261_common_init(void)
Definition:
h261.c:83
H261Context::mtype
int mtype
Definition:
h261.h:42
avcodec.h
Libavcodec external API header.
MpegEncContext::linesize
ptrdiff_t linesize
line size, in bytes, may be different from width
Definition:
mpegvideo.h:134
ff_rl_init
av_cold int ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
Definition:
rl.c:39
h261.h
H.261 codec.
MpegEncContext::uvlinesize
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
Definition:
mpegvideo.h:135
ff_h261_rl_tcoeff
RLTable ff_h261_rl_tcoeff
Definition:
h261data.c:150
IS_FIL
#define IS_FIL(a)
Definition:
h261.c:31
MpegEncContext
MpegEncContext.
Definition:
mpegvideo.h:81
MAX_RUN
#define MAX_RUN
Definition:
rl.h:35
MpegEncContext::dest
uint8_t * dest[3]
Definition:
mpegvideo.h:295
h261_loop_filter
static void h261_loop_filter(uint8_t *src, int stride)
Definition:
h261.c:35
ff_h261_rl_table_store
uint8_t ff_h261_rl_table_store[2][2 *MAX_RUN+MAX_LEVEL+3]
Definition:
h261.c:33
ff_h261_loop_filter
void ff_h261_loop_filter(MpegEncContext *s)
Definition:
h261.c:63
Generated on Tue May 22 2018 07:06:32 for FFmpeg by
1.8.13