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

Function encode_frame

libavcodec/srtenc.c:227–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225};
226
227static int encode_frame(AVCodecContext *avctx,
228 unsigned char *buf, int bufsize, const AVSubtitle *sub,
229 const ASSCodesCallbacks *cb)
230{
231 SRTContext *s = avctx->priv_data;
232 ASSDialog *dialog;
233 int i;
234
235 av_bprint_init_for_buffer(&s->buffer, buf, bufsize);
236
237 for (i=0; i<sub->num_rects; i++) {
238 const char *ass = sub->rects[i]->ass;
239
240 if (sub->rects[i]->type != SUBTITLE_ASS) {
241 av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
242 return AVERROR(EINVAL);
243 }
244
245 dialog = ff_ass_split_dialog(s->ass_ctx, ass);
246 if (!dialog)
247 return AVERROR(ENOMEM);
248 s->alignment_applied = 0;
249 if (avctx->codec_id == AV_CODEC_ID_SUBRIP)
250 srt_style_apply(s, dialog->style);
251 ff_ass_split_override_codes(cb, s, dialog->text);
252 ff_ass_free_dialog(&dialog);
253 }
254
255 if (!s->buffer.len)
256 return 0;
257
258 if (!av_bprint_is_complete(&s->buffer)) {
259 av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
260 return AVERROR_BUFFER_TOO_SMALL;
261 }
262
263 return s->buffer.len;
264}
265
266static int srt_encode_frame(AVCodecContext *avctx,
267 unsigned char *buf, int bufsize, const AVSubtitle *sub)

Callers 2

srt_encode_frameFunction · 0.70
text_encode_frameFunction · 0.70

Calls 7

av_logFunction · 0.85
ff_ass_split_dialogFunction · 0.85
srt_style_applyFunction · 0.85
ff_ass_free_dialogFunction · 0.85
av_bprint_is_completeFunction · 0.85

Tested by

no test coverage detected