FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/h263enc.h
Date: 2025-03-08 20:38:41
Exec Total Coverage
Lines: 11 40 27.5%
Functions: 2 2 100.0%
Branches: 5 42 11.9%

Line Branch Exec 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(MpegEncContext *s);
30 void ff_h263_encode_picture_header(MpegEncContext *s);
31 void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line);
32 void ff_h263_encode_mb(MpegEncContext *s,
33 int16_t block[6][64],
34 int motion_x, int motion_y);
35 void ff_h263_encode_mba(MpegEncContext *s);
36
37 void ff_clean_h263_qscales(MpegEncContext *s);
38
39 void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code);
40 void ff_h263_update_mb(MpegEncContext *s);
41
42 2654560 static inline void ff_h263_encode_motion_vector(MpegEncContext * s,
43 int x, int y, int f_code)
44 {
45 2654560 ff_h263_encode_motion(&s->pb, x, f_code);
46 2654560 ff_h263_encode_motion(&s->pb, y, f_code);
47 2654560 }
48
49 1211262 static inline int get_p_cbp(MpegEncContext * s,
50 int16_t block[6][64],
51 int motion_x, int motion_y){
52 int cbp;
53
54
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1211262 times.
1211262 if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) {
55 int best_cbpy_score = INT_MAX;
56 int best_cbpc_score = INT_MAX;
57 int cbpc = (-1), cbpy = (-1);
58 const int offset = (s->mv_type == MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0);
59 const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
60
61 for (int i = 0; i < 4; i++) {
62 int score = ff_h263_inter_MCBPC_bits[i + offset] * lambda;
63 if (i & 1) score += s->coded_score[5];
64 if (i & 2) score += s->coded_score[4];
65
66 if (score < best_cbpc_score) {
67 best_cbpc_score = score;
68 cbpc = i;
69 }
70 }
71
72 for (int i = 0; i < 16; i++) {
73 int score= ff_h263_cbpy_tab[i ^ 0xF][1] * lambda;
74 if (i & 1) score += s->coded_score[3];
75 if (i & 2) score += s->coded_score[2];
76 if (i & 4) score += s->coded_score[1];
77 if (i & 8) score += s->coded_score[0];
78
79 if (score < best_cbpy_score) {
80 best_cbpy_score = score;
81 cbpy = i;
82 }
83 }
84 cbp = cbpc + 4 * cbpy;
85 if (!(motion_x | motion_y | s->dquant) && s->mv_type == MV_TYPE_16X16) {
86 if (best_cbpy_score + best_cbpc_score + 2 * lambda >= 0)
87 cbp= 0;
88 }
89
90 for (int i = 0; i < 6; i++) {
91 if (s->block_last_index[i] >= 0 && !((cbp >> (5 - i)) & 1)) {
92 s->block_last_index[i] = -1;
93 s->bdsp.clear_block(s->block[i]);
94 }
95 }
96 } else {
97 1211262 cbp = 0;
98
2/2
✓ Branch 0 taken 7267572 times.
✓ Branch 1 taken 1211262 times.
8478834 for (int i = 0; i < 6; i++) {
99
2/2
✓ Branch 0 taken 3272219 times.
✓ Branch 1 taken 3995353 times.
7267572 if (s->block_last_index[i] >= 0)
100 3272219 cbp |= 1 << (5 - i);
101 }
102 }
103 1211262 return cbp;
104 }
105
106 #endif
107