FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tools/venc_data_dump.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 41 45 91.1%
Functions: 2 2 100.0%
Branches: 16 22 72.7%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stdio.h>
20 #include <stdint.h>
21 #include <stdlib.h>
22
23 #include "decode_simple.h"
24
25 #include "libavutil/common.h"
26 #include "libavutil/dict.h"
27 #include "libavutil/error.h"
28 #include "libavutil/video_enc_params.h"
29
30 #include "libavformat/avformat.h"
31
32 #include "libavcodec/avcodec.h"
33
34 8 static int process_frame(DecodeContext *dc, AVFrame *frame)
35 {
36 AVFrameSideData *sd;
37
38
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if (!frame)
39 2 return 0;
40
41 6 fprintf(stdout, "frame %"PRId64"\n", dc->decoder->frame_num - 1);
42
43 6 sd = av_frame_get_side_data(frame, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
44
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (sd) {
45 6 AVVideoEncParams *par = (AVVideoEncParams*)sd->data;
46
47 6 fprintf(stdout, "AVVideoEncParams %d\n", par->type);
48 6 fprintf(stdout, "qp %d\n", par->qp);
49
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for (int i = 0; i < FF_ARRAY_ELEMS(par->delta_qp); i++)
50
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for (int j = 0; j < FF_ARRAY_ELEMS(par->delta_qp[i]); j++) {
51
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44 times.
48 if (par->delta_qp[i][j])
52 4 fprintf(stdout, "delta_qp[%d][%d] %"PRId32"\n", i, j, par->delta_qp[i][j]);
53 }
54
55
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (par->nb_blocks) {
56 6 fprintf(stdout, "nb_blocks %d\n", par->nb_blocks);
57
2/2
✓ Branch 0 taken 1313 times.
✓ Branch 1 taken 6 times.
1319 for (int i = 0; i < par->nb_blocks; i++) {
58 1313 AVVideoBlockParams *b = av_video_enc_params_block(par, i);
59
60 1313 fprintf(stdout, "block %d %d:%d %dx%d %"PRId32"\n",
61 i, b->src_x, b->src_y, b->w, b->h, b->delta_qp);
62 }
63 }
64 }
65
66 6 return 0;
67 }
68
69 2 int main(int argc, char **argv)
70 {
71 DecodeContext dc;
72
73 unsigned int stream_idx, max_frames;
74 2 const char *filename, *thread_type = NULL, *nb_threads = NULL;
75 2 int ret = 0;
76
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (argc <= 3) {
78 fprintf(stderr, "Usage: %s <input file> <stream index> <max frame count> [<thread count> <thread type>]\n", argv[0]);
79 return 0;
80 }
81
82 2 filename = argv[1];
83 2 stream_idx = strtol(argv[2], NULL, 0);
84 2 max_frames = strtol(argv[3], NULL, 0);
85
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (argc > 5) {
86 2 nb_threads = argv[4];
87 2 thread_type = argv[5];
88 }
89
90 2 ret = ds_open(&dc, filename, stream_idx);
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ret < 0)
92 goto finish;
93
94 2 dc.process_frame = process_frame;
95 2 dc.max_frames = max_frames;
96
97 2 ret = av_dict_set(&dc.decoder_opts, "threads", nb_threads, 0);
98 2 ret |= av_dict_set(&dc.decoder_opts, "thread_type", thread_type, 0);
99 2 ret |= av_dict_set(&dc.decoder_opts, "export_side_data", "venc_params", 0);
100
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ret < 0)
102 goto finish;
103
104 2 ret = ds_run(&dc);
105
106 2 finish:
107 2 ds_free(&dc);
108 2 return ret;
109 }
110