| 225 | }; |
| 226 | |
| 227 | static 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 | |
| 266 | static int srt_encode_frame(AVCodecContext *avctx, |
| 267 | unsigned char *buf, int bufsize, const AVSubtitle *sub) |
no test coverage detected