MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / webvtt_encode_frame

Function webvtt_encode_frame

libavcodec/webvttenc.c:154–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152};
153
154static int webvtt_encode_frame(AVCodecContext *avctx,
155 unsigned char *buf, int bufsize, const AVSubtitle *sub)
156{
157 WebVTTContext *s = avctx->priv_data;
158 ASSDialog *dialog;
159 int i;
160
161 av_bprint_init_for_buffer(&s->buffer, buf, bufsize);
162
163 for (i=0; i<sub->num_rects; i++) {
164 const char *ass = sub->rects[i]->ass;
165
166 if (sub->rects[i]->type != SUBTITLE_ASS) {
167 av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
168 return AVERROR(EINVAL);
169 }
170
171 dialog = ff_ass_split_dialog(s->ass_ctx, ass);
172 if (!dialog)
173 return AVERROR(ENOMEM);
174 webvtt_style_apply(s, dialog->style);
175 ff_ass_split_override_codes(&webvtt_callbacks, s, dialog->text);
176 ff_ass_free_dialog(&dialog);
177 }
178
179 if (!s->buffer.len)
180 return 0;
181
182 if (!av_bprint_is_complete(&s->buffer)) {
183 av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
184 return AVERROR_BUFFER_TOO_SMALL;
185 }
186
187 return s->buffer.len;
188}
189
190static av_cold int webvtt_encode_close(AVCodecContext *avctx)
191{

Callers

nothing calls this directly

Calls 7

av_logFunction · 0.85
ff_ass_split_dialogFunction · 0.85
webvtt_style_applyFunction · 0.85
ff_ass_free_dialogFunction · 0.85
av_bprint_is_completeFunction · 0.85

Tested by

no test coverage detected