FFmpeg
Loading...
Searching...
No Matches
api-movtext-test.c
Go to the documentation of this file.
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 */
28static int dump_sample_description(const AVCodec *codec, const char *header)
29{
31 int ret = 1;
32
33 if (!ctx)
34 return 1;
35
36 ctx->subtitle_header = (uint8_t *)av_strdup(header);
37 if (!ctx->subtitle_header)
38 goto end;
39 ctx->subtitle_header_size = strlen(header);
40 ctx->time_base = (AVRational){ 1, 1000 };
41
42 if (avcodec_open2(ctx, codec, NULL) < 0)
43 goto end;
44
45 printf("extradata_size: %d\n", ctx->extradata_size);
46 for (int i = 0; i < ctx->extradata_size; i++)
47 printf("%02x", ctx->extradata[i]);
48 printf("\n");
49
50 ret = 0;
51end:
53 return ret;
54}
55
56int main(void)
57{
59 int ret;
60
61 if (!codec)
62 return 1;
63
64 printf("Fallback font\n");
65 ret = dump_sample_description(codec,
66 "[Script Info]\n"
67 "ScriptType: v4.00+\n");
68 printf("Explicit Serif style\n");
69 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 return ret;
76}
static AVFormatContext * ctx
int main(void)
static int dump_sample_description(const AVCodec *codec, const char *header)
Print the sample description for comparison with the FATE reference.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition avcodec.c:144
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition options.c:149
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition allcodecs.c:988
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition options.c:164
@ AV_CODEC_ID_MOV_TEXT
Definition codec_id.h:572
Memory handling functions.
#define av_strdup(s)
Definition ops_static.c:55
static const uint8_t header[24]
Definition sdr2.c:68
main external API structure.
Definition avcodec.h:443
AVCodec.
Definition codec.h:175
Rational number (pair of numerator and denominator).
Definition rational.h:58