/src/ffmpeg/libavcodec/h263enc.h
Line | Count | Source |
1 | | /* |
2 | | * H.263 encoder header |
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 | | #ifndef AVCODEC_H263ENC_H |
21 | | #define AVCODEC_H263ENC_H |
22 | | |
23 | | #include <stdint.h> |
24 | | #include "h263data.h" |
25 | | #include "mpegvideoenc.h" |
26 | | |
27 | | const uint8_t (*ff_h263_get_mv_penalty(void))[MAX_DMV*2+1]; |
28 | | |
29 | | void ff_h263_encode_init(MPVMainEncContext *m); |
30 | | void ff_h263_mpeg4_reset_dc(MPVEncContext *s); |
31 | | void ff_h263_encode_gob_header(MPVEncContext *s, int mb_line); |
32 | | void ff_h263_encode_mba(MPVEncContext *s); |
33 | | |
34 | | void ff_clean_h263_qscales(MPVEncContext *s); |
35 | | |
36 | | void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code); |
37 | | void ff_h263_update_mb(MPVEncContext *s); |
38 | | |
39 | | static inline void ff_h263_encode_motion_vector(MPVEncContext *s, |
40 | | int x, int y, int f_code) |
41 | 0 | { |
42 | 0 | ff_h263_encode_motion(&s->pb, x, f_code); |
43 | 0 | ff_h263_encode_motion(&s->pb, y, f_code); |
44 | 0 | } Unexecuted instantiation: ituh263enc.c:ff_h263_encode_motion_vector Unexecuted instantiation: mpegvideo_enc.c:ff_h263_encode_motion_vector Unexecuted instantiation: rv20enc.c:ff_h263_encode_motion_vector Unexecuted instantiation: mpeg4videoenc.c:ff_h263_encode_motion_vector Unexecuted instantiation: svq1enc.c:ff_h263_encode_motion_vector Unexecuted instantiation: snowenc.c:ff_h263_encode_motion_vector |
45 | | |
46 | | static inline int get_p_cbp(MPVEncContext *const s, |
47 | | int16_t block[6][64], |
48 | 0 | int motion_x, int motion_y){ |
49 | 0 | int cbp; |
50 | |
|
51 | 0 | if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) { |
52 | 0 | int best_cbpy_score = INT_MAX; |
53 | 0 | int best_cbpc_score = INT_MAX; |
54 | 0 | int cbpc = (-1), cbpy = (-1); |
55 | 0 | const int offset = (s->c.mv_type == MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0); |
56 | 0 | const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6); |
57 | |
|
58 | 0 | for (int i = 0; i < 4; i++) { |
59 | 0 | int score = ff_h263_inter_MCBPC_bits[i + offset] * lambda; |
60 | 0 | if (i & 1) score += s->coded_score[5]; |
61 | 0 | if (i & 2) score += s->coded_score[4]; |
62 | |
|
63 | 0 | if (score < best_cbpc_score) { |
64 | 0 | best_cbpc_score = score; |
65 | 0 | cbpc = i; |
66 | 0 | } |
67 | 0 | } |
68 | |
|
69 | 0 | for (int i = 0; i < 16; i++) { |
70 | 0 | int score= ff_h263_cbpy_tab[i ^ 0xF][1] * lambda; |
71 | 0 | if (i & 1) score += s->coded_score[3]; |
72 | 0 | if (i & 2) score += s->coded_score[2]; |
73 | 0 | if (i & 4) score += s->coded_score[1]; |
74 | 0 | if (i & 8) score += s->coded_score[0]; |
75 | |
|
76 | 0 | if (score < best_cbpy_score) { |
77 | 0 | best_cbpy_score = score; |
78 | 0 | cbpy = i; |
79 | 0 | } |
80 | 0 | } |
81 | 0 | cbp = cbpc + 4 * cbpy; |
82 | 0 | if (!(motion_x | motion_y | s->dquant) && s->c.mv_type == MV_TYPE_16X16) { |
83 | 0 | if (best_cbpy_score + best_cbpc_score + 2 * lambda >= 0) |
84 | 0 | cbp= 0; |
85 | 0 | } |
86 | |
|
87 | 0 | for (int i = 0; i < 6; i++) { |
88 | 0 | if (s->c.block_last_index[i] >= 0 && !((cbp >> (5 - i)) & 1)) { |
89 | 0 | s->c.block_last_index[i] = -1; |
90 | 0 | s->c.bdsp.clear_block(s->block[i]); |
91 | 0 | } |
92 | 0 | } |
93 | 0 | } else { |
94 | 0 | cbp = 0; |
95 | 0 | for (int i = 0; i < 6; i++) { |
96 | 0 | if (s->c.block_last_index[i] >= 0) |
97 | 0 | cbp |= 1 << (5 - i); |
98 | 0 | } |
99 | 0 | } |
100 | 0 | return cbp; |
101 | 0 | } Unexecuted instantiation: ituh263enc.c:get_p_cbp Unexecuted instantiation: mpegvideo_enc.c:get_p_cbp Unexecuted instantiation: rv20enc.c:get_p_cbp Unexecuted instantiation: mpeg4videoenc.c:get_p_cbp Unexecuted instantiation: svq1enc.c:get_p_cbp Unexecuted instantiation: snowenc.c:get_p_cbp |
102 | | |
103 | | #endif |