FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/mpeg4video.h
Date: 2025-06-01 09:29:47
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 1 1 100.0%
Branches: 22 22 100.0%

Line Branch Exec Source
1 /*
2 * MPEG-4 encoder/decoder internal header.
3 * Copyright (c) 2000,2001 Fabrice Bellard
4 * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at>
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 #ifndef AVCODEC_MPEG4VIDEO_H
24 #define AVCODEC_MPEG4VIDEO_H
25
26 #include <stdint.h>
27
28 #include "mpegvideo.h"
29
30 void ff_mpeg4_clean_buffers(MpegEncContext *s);
31 int ff_mpeg4_get_video_packet_prefix_length(enum AVPictureType pict_type,
32 int f_code, int b_code);
33 void ff_mpeg4_init_direct_mv(MpegEncContext *s);
34
35 /**
36 * @return the mb_type
37 */
38 int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
39
40 /**
41 * Predict the dc.
42 * @param n block index (0-3 are luma, 4-5 are chroma)
43 * @param dir_ptr pointer to an integer where the prediction direction will be stored
44 */
45 2420316 static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
46 {
47 int a, b, c, wrap, pred;
48 const int16_t *dc_val;
49
50 /* find prediction */
51
52 2420316 wrap = s->block_wrap[n];
53 2420316 dc_val = s->dc_val[0] + s->block_index[n];
54
55 /* B C
56 * A X
57 */
58 2420316 a = dc_val[-1];
59 2420316 b = dc_val[-1 - wrap];
60 2420316 c = dc_val[-wrap];
61
62 /* outside slice handling (we can't do that by memset as we need the
63 * dc for error resilience) */
64
4/4
✓ Branch 0 taken 283104 times.
✓ Branch 1 taken 2137212 times.
✓ Branch 2 taken 235920 times.
✓ Branch 3 taken 47184 times.
2420316 if (s->first_slice_line && n != 3) {
65
2/2
✓ Branch 0 taken 188736 times.
✓ Branch 1 taken 47184 times.
235920 if (n != 2)
66 188736 b = c = 1024;
67
4/4
✓ Branch 0 taken 188736 times.
✓ Branch 1 taken 47184 times.
✓ Branch 2 taken 10040 times.
✓ Branch 3 taken 178696 times.
235920 if (n != 1 && s->mb_x == s->resync_mb_x)
68 10040 b = a = 1024;
69 }
70
4/4
✓ Branch 0 taken 106140 times.
✓ Branch 1 taken 2314176 times.
✓ Branch 2 taken 15168 times.
✓ Branch 3 taken 90972 times.
2420316 if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) {
71
6/6
✓ Branch 0 taken 12640 times.
✓ Branch 1 taken 2528 times.
✓ Branch 2 taken 10112 times.
✓ Branch 3 taken 2528 times.
✓ Branch 4 taken 2528 times.
✓ Branch 5 taken 7584 times.
15168 if (n == 0 || n == 4 || n == 5)
72 7584 b = 1024;
73 }
74
75
2/2
✓ Branch 0 taken 885646 times.
✓ Branch 1 taken 1534670 times.
2420316 if (abs(a - b) < abs(b - c)) {
76 885646 pred = c;
77 885646 *dir_ptr = 1; /* top */
78 } else {
79 1534670 pred = a;
80 1534670 *dir_ptr = 0; /* left */
81 }
82 2420316 return pred;
83 }
84
85 #endif /* AVCODEC_MPEG4VIDEO_H */
86