FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/api/api-movtext-test.c
Date: 2026-09-25 11:37:27
Exec Total Coverage
Lines: 25 29 86.2%
Functions: 2 2 100.0%
Branches: 6 10 60.0%

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 <string.h>
21
22 #include "libavcodec/avcodec.h"
23 #include "libavutil/mem.h"
24
25 /**
26 * Print the sample description for comparison with the FATE reference.
27 */
28 2 static int dump_sample_description(const AVCodec *codec, const char *header)
29 {
30 2 AVCodecContext *ctx = avcodec_alloc_context3(codec);
31 2 int ret = 1;
32
33
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!ctx)
34 ✗ return 1;
35
36 2 ctx->subtitle_header = (uint8_t *)av_strdup(header);
37
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!ctx->subtitle_header)
38 ✗ goto end;
39 2 ctx->subtitle_header_size = strlen(header);
40 2 ctx->time_base = (AVRational){ 1, 1000 };
41
42
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (avcodec_open2(ctx, codec, NULL) < 0)
43 ✗ goto end;
44
45 2 printf("extradata_size: %d\n", ctx->extradata_size);
46
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 2 times.
98 for (int i = 0; i < ctx->extradata_size; i++)
47 96 printf("%02x", ctx->extradata[i]);
48 2 printf("\n");
49
50 2 ret = 0;
51 2 end:
52 2 avcodec_free_context(&ctx);
53 2 return ret;
54 }
55
56 1 int main(void)
57 {
58 1 const AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_MOV_TEXT);
59 int ret;
60
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!codec)
62 ✗ return 1;
63
64 1 printf("Fallback font\n");
65 1 ret = dump_sample_description(codec,
66 "[Script Info]\n"
67 "ScriptType: v4.00+\n");
68 1 printf("Explicit Serif style\n");
69 1 ret |= dump_sample_description(codec,
70 "[Script Info]\n"
71 "ScriptType: v4.00+\n"
72 "[V4+ Styles]\n"
73 "Format: Name, Fontname, Fontsize\n"
74 "Style: Default,Serif,18\n");
75 1 return ret;
76 }
77