33#include <aribcaption/aribcaption.h>
35#if !defined(DEFAULT_FONT_ASS)
36# define DEFAULT_FONT_ASS "sans-serif"
39#define ARIBC_BPRINT_SIZE_INIT 64
40#define ARIBC_BPRINT_SIZE_MAX (8 * 1024)
41#define ARIBC_ALPHA_MAX_NUM 4
42#define ARIBC_ALPHA_DEFAULT_FRONT 0xFFu
43#define ARIBC_ALPHA_DEFAULT_BACK 0x80u
45#define ARIBCC_COLOR_RGB(c) ((c) & 0xFFFFFF)
46#define ARIBCC_COLOR_DIFF_RGB(c1,c2) (((c1) ^ (c2)) & 0x00FFFFFF)
47#define ARIBCC_COLOR_DIFF_A(c1,c2) (((c1) ^ (c2)) & 0xFF000000)
49#define CLUT_RGBA(r,g,b,a) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
50#define CLUT_A(c) (((c) >> 24) & 0xFF)
51#define CLUT_R(c) (((c) >> 16) & 0xFF)
52#define CLUT_G(c) (((c) >> 8) & 0xFF)
53#define CLUT_B(c) ( (c) & 0xFF)
55#define ARIBCC_COLOR_TO_CLUT_RGBA(c,a) (((ARIBCC_COLOR_A(c) ? ARIBCC_COLOR_A(c) : (a)) << 24) | \
56 (ARIBCC_COLOR_R(c) << 16) | \
57 (ARIBCC_COLOR_G(c) << 8) | \
110 for (
i = 0;
i < buf_size;
i++) {
126 case ARIBCC_LOGLEVEL_ERROR:
129 case ARIBCC_LOGLEVEL_WARNING:
142 if (
ctx->avctx->width > 0 &&
ctx->avctx->height > 0) {
144 ctx->bitmap_plane_width =
ctx->avctx->width;
145 ctx->bitmap_plane_height =
ctx->avctx->height;
146 }
else if (
ctx->plane_width == 960) {
149 ctx->bitmap_plane_width = 1440;
150 ctx->bitmap_plane_height = 1080;
152 ctx->bitmap_plane_width =
ctx->plane_width;
153 ctx->bitmap_plane_height =
ctx->plane_height;
156 if (
ctx->bitmap_plane_height *
ctx->plane_width >
ctx->bitmap_plane_width *
ctx->plane_height) {
157 ctx->frame_height =
ctx->bitmap_plane_height;
158 ctx->frame_width =
ctx->frame_height *
ctx->plane_width /
ctx->plane_height;
160 ctx->frame_width =
ctx->bitmap_plane_width;
161 ctx->frame_height =
ctx->frame_width *
ctx->plane_height /
ctx->plane_width;
170 if (
ctx->clut_alpha[
i] == 0) {
171 ctx->clut_alpha[
i] =
a;
174 if (
ctx->clut_alpha[
i] ==
a)
189 if (
ctx->clut_alpha[
i] ==
a)
191 if (
ctx->clut_alpha[
i] == 0)
193 if (
abs((
int)
a - (
int)
ctx->clut_alpha[
i]) < d) {
194 d =
abs((
int)
a - (
int)
ctx->clut_alpha[
i]);
198 return ctx->clut_alpha[j];
205 for (
i = 0;
i <
ctx->clut_idx;
i++) {
206 if (
ctx->clut[
i] == rgba)
231 for (
i = 0;
i <
ctx->clut_idx;
i++) {
232 if (
ctx->clut[
i] == rgba)
244 ctx->clut_overflow++;
247 ctx->clut[
ctx->clut_idx++] = rgba;
257 memset(
ctx->clut_alpha, 0,
sizeof(
ctx->clut_alpha));
258 ctx->clut_alpha[0] = 0xFF;
260 ctx->clut_overflow = 0;
269 ctx->clut_overflow++;
272 ctx->clut[
ctx->clut_idx++] = rgba;
279 return !region->char_count || (region->is_ruby && ignore_ruby);
283 const aribcc_caption_region_t *region)
291 for (
int i = 0;
i < region->char_count;
i++) {
292 aribcc_caption_char_t *ch = ®ion->chars[
i];
313 int status, rect_idx, image_count = 0, seed_idx, seed_overflow;
314 int old_width =
ctx->frame_width;
315 int old_height =
ctx->frame_height;
317 if (
ctx->caption.plane_width > 0 &&
ctx->caption.plane_height > 0) {
318 ctx->plane_width =
ctx->caption.plane_width;
319 ctx->plane_height =
ctx->caption.plane_height;
322 if (
ctx->frame_width != old_width ||
ctx->frame_height != old_height) {
323 ff_dlog(
ctx,
"canvas: %dx%d plane: %dx%d bitmap: %dx%d frame: %dx%d\n",
324 ctx->avctx->width,
ctx->avctx->height,
325 ctx->plane_width,
ctx->plane_height,
326 ctx->bitmap_plane_width,
ctx->bitmap_plane_height,
327 ctx->frame_width,
ctx->frame_height);
328 if (!aribcc_renderer_set_frame_size(
ctx->renderer,
329 ctx->frame_width,
ctx->frame_height)) {
331 "aribcc_renderer_set_frame_size() returned with error.\n");
336 status = aribcc_renderer_append_caption(
ctx->renderer, &
ctx->caption);
339 "aribcc_renderer_append_caption() returned with error.\n");
343 status = aribcc_renderer_render(
ctx->renderer,
ctx->pts, &
ctx->render_result);
345 case ARIBCC_RENDER_STATUS_GOT_IMAGE:
348 case ARIBCC_RENDER_STATUS_GOT_IMAGE_UNCHANGED:
349 aribcc_render_result_cleanup(&
ctx->render_result);
353 case ARIBCC_RENDER_STATUS_NO_IMAGE:
357 case ARIBCC_RENDER_STATUS_ERROR:
359 "aribcc_renderer_render() returned with error.\n");
363 aribcc_render_result_cleanup(&
ctx->render_result);
365 "aribcc_renderer_render() returned unknown status: %d\n", status);
369 if (!
ctx->render_result.image_count ||
ctx->render_result.images ==
NULL) {
370 ff_dlog(
ctx,
"no image (%d)\n",
ctx->render_result.image_count);
371 aribcc_render_result_cleanup(&
ctx->render_result);
378 if (
ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN) {
386 image_count =
ctx->render_result.image_count;
393 for (
int i = 0;
i < image_count;
i++) {
406 for (
int i = 0;
i <
ctx->caption.region_count;
i++)
409 seed_idx =
ctx->clut_idx;
410 seed_overflow =
ctx->clut_overflow;
412 for (rect_idx = 0; rect_idx < image_count; rect_idx++) {
414 aribcc_image_t *image = &
ctx->render_result.images[rect_idx];
415 int w,
h, shrink_height, dst_idx;
417 ctx->clut_idx = seed_idx;
418 ctx->clut_overflow = seed_overflow;
420 rect->
w = image->width *
ctx->bitmap_plane_width /
ctx->frame_width;
421 rect->
h = image->height *
ctx->bitmap_plane_height /
ctx->frame_height;
423 if (!
rect->data[0]) {
427 if ((image->height !=
rect->
h && image->width !=
rect->
w) ||
428 image->stride < image->width * 4 ||
429 image->stride * image->height > image->bitmap_size) {
431 image->width, image->stride / 4, image->height,
rect->
w,
rect->
h);
436 shrink_height = image->height !=
rect->
h;
441 int n, m, idx0, idx1,
r,
g,
b,
a;
444 div_a =
h *
ctx->frame_height;
445 n =
ctx->bitmap_plane_height;
447 y1 =
FFMIN(y0 + 1, image->height - 1);
449 idx0 = image->stride * y0 +
w * 4;
450 idx1 = image->stride * y1 +
w * 4;
453 div_a =
w *
ctx->frame_width;
454 n =
ctx->bitmap_plane_width;
456 x1 =
FFMIN(x0 + 1, image->width - 1);
458 idx0 = image->stride *
h + x0 * 4;
459 idx1 = image->stride *
h + x1 * 4;
461 r = (image->bitmap[idx0++] * (n - m) + image->bitmap[idx1++] * m) / n;
462 g = (image->bitmap[idx0++] * (n - m) + image->bitmap[idx1++] * m) / n;
463 b = (image->bitmap[idx0++] * (n - m) + image->bitmap[idx1++] * m) / n;
464 a = (image->bitmap[idx0++] * (n - m) + image->bitmap[idx1++] * m) / n;
469 if (!
rect->data[1]) {
478 rect->
y =
ctx->frame_height -
rect->
h * (image_count - rect_idx);
480 rect->
x = image->dst_x *
ctx->bitmap_plane_width /
ctx->frame_width;
481 rect->
y = image->dst_y *
ctx->bitmap_plane_height /
ctx->frame_height;
485 rect->nb_colors = 256;
487 ff_dlog(
ctx,
"BITMAP subtitle (%d,%d) %dx%d -> (%d,%d) %dx%d [%d]: %d colors\n",
488 image->dst_x, image->dst_y, image->width, image->height,
490 rect_idx,
ctx->clut_idx);
491 if (
ctx->clut_overflow)
495 aribcc_render_result_cleanup(&
ctx->render_result);
501 for (
int i = 0;
i < image_count;
i++) {
511 aribcc_render_result_cleanup(&
ctx->render_result);
520 const char *font_name;
521 const char *fonts =
ctx->font;
523 if (
ctx->border_style == 4) {
530 if (
ctx->force_stroke_text)
531 outline = (int)(
ctx->stroke_width * 4.0 / 3.0);
543 "ScriptType: v4.00+\n"
551 "Fontname, Fontsize, "
552 "PrimaryColour, SecondaryColour, OutlineColour, BackColour, "
553 "Bold, Italic, Underline, StrikeOut, "
556 "BorderStyle, Outline, Shadow, "
557 "Alignment, MarginL, MarginR, MarginV, "
563 "&H%x,&H%x,&H%x,&H%x,"
573 "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n",
574 ctx->plane_width,
ctx->plane_height,
575 font_name,
ctx->font_size,
589 aribcc_color_t new_color, aribcc_color_t old_color)
596 0xFF - ARIBCC_COLOR_A(new_color));
602 const aribcc_caption_region_t *region,
int *x,
int *y)
604 *x = region->x < 0 ? region->x +
ctx->plane_width : region->x;
605 *y = region->y < 0 ? region->y +
ctx->plane_height : region->y;
612 bool single_rect =
ctx->ass_single_rect;
613 bool emitted =
false;
614 int ret = 0, rect_idx;
616 if (
ctx->caption.plane_width > 0 &&
ctx->caption.plane_height > 0 &&
617 (
ctx->caption.plane_width !=
ctx->plane_width ||
618 ctx->caption.plane_height !=
ctx->plane_height)) {
619 ctx->plane_width =
ctx->caption.plane_width;
620 ctx->plane_height =
ctx->caption.plane_height;
636 x =
ctx->plane_width;
637 y =
ctx->plane_height;
638 for (
int i = 0;
i <
ctx->caption.region_count;
i++) {
653 for (
int i = 0;
i <
ctx->caption.region_count;
i++) {
654 aribcc_caption_region_t *region = &
ctx->caption.regions[
i];
655 aribcc_color_t text_color = ARIBCC_MAKE_RGBA(0xFF, 0xFF, 0xFF,
657 aribcc_color_t stroke_color = ARIBCC_MAKE_RGBA(0, 0, 0,
659 aribcc_color_t back_color = ARIBCC_MAKE_RGBA(0, 0, 0,
661 aribcc_charstyle_t charstyle =
ctx->charstyle;
662 int char_width =
ctx->font_size;
663 int char_height =
ctx->font_size;
664 int char_horizontal_spacing = 0;
669 if (single_rect && emitted)
682 av_bprintf(&buf,
"{\\fs%d}", char_height / 2);
684 for (
int j = 0; j < region->char_count; j++) {
685 aribcc_caption_char_t *ch = ®ion->chars[j];
688 if (ch->char_horizontal_spacing != char_horizontal_spacing) {
689 av_bprintf(&buf,
"{\\fsp%d}", (region->is_ruby) ?
690 ch->char_horizontal_spacing / 2 :
691 ch->char_horizontal_spacing);
692 char_horizontal_spacing = ch->char_horizontal_spacing;
694 if (ch->char_width != char_width) {
697 char_width = ch->char_width;
699 if (ch->char_height != char_height) {
702 char_height = ch->char_height;
705 if (ch->style != charstyle) {
706 aribcc_charstyle_t
diff = ch->style ^ charstyle;
707 if (
diff & ARIBCC_CHARSTYLE_STROKE) {
708 if (charstyle & ARIBCC_CHARSTYLE_STROKE) {
709 if (
ctx->force_stroke_text)
711 (
int)(
ctx->stroke_width * 4.0 / 3.0));
717 if (
diff & ARIBCC_CHARSTYLE_BOLD) {
718 if (charstyle & ARIBCC_CHARSTYLE_BOLD)
723 if (
diff & ARIBCC_CHARSTYLE_ITALIC) {
724 if (charstyle & ARIBCC_CHARSTYLE_ITALIC)
729 if (
diff & ARIBCC_CHARSTYLE_UNDERLINE) {
730 if (charstyle & ARIBCC_CHARSTYLE_UNDERLINE)
735 charstyle = ch->style;
737 if (ch->text_color != text_color) {
739 text_color = ch->text_color;
741 if (ch->stroke_color != stroke_color) {
743 stroke_color = ch->stroke_color;
745 if (ch->back_color != back_color) {
746 if (
ctx->border_style == 4)
750 back_color = ch->back_color;
752 if (region->chars[j].type == ARIBCC_CHARTYPE_DRCS)
759 ff_dlog(
ctx,
"ASS subtitle%s (%d,%d) %dx%d [region %d]\n",
760 (region->is_ruby) ?
" (ruby)" :
"",
761 region->x, region->y, region->width, region->height,
i);
767 ff_dlog(
ctx,
"ASS subtitle%s (%d,%d) %dx%d [%d]: %s\n",
768 (region->is_ruby) ?
" (ruby)" :
"",
769 region->x, region->y, region->width, region->height,
783 if (!(
ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN)) {
829 int ret = 0, has_text = 0;
830 const char *text =
ctx->caption.text ?
ctx->caption.text :
"";
835 for (
int i = 0;
i <
ctx->caption.region_count && !has_text;
i++)
842 if (!(
ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN))
855 if (!sub->
rects[0]) {
888 int *got_sub_ptr,
const AVPacket *avpkt)
893 ff_dlog(
ctx,
"ARIB caption packet pts=%"PRIx64
":\n", avpkt->
pts);
903 if (
ctx->time_base.num <= 0 ||
ctx->time_base.den <= 0) {
908 ctx->pts = ARIBCC_PTS_NOPTS;
912 status = aribcc_decoder_decode(
ctx->decoder, avpkt->
data, avpkt->
size,
914 if (status == ARIBCC_DECODE_STATUS_ERROR) {
916 "aribcc_decoder_decode() returned with error.\n");
919 if (status == ARIBCC_DECODE_STATUS_NO_CAPTION) {
923 ff_dlog(
ctx,
"type=%02x, flags=%x, lang=%03x\n",
924 ctx->caption.type,
ctx->caption.flags,
ctx->caption.iso6392_language_code);
925 ff_dlog(
ctx,
"region count = %d, start=%d.%d, duration=%d.%d\n",
926 ctx->caption.region_count,
927 (
int)(
ctx->caption.pts / 1000), (
int)(
ctx->caption.pts % 1000),
928 (
int)((
ctx->caption.wait_duration == ARIBCC_DURATION_INDEFINITE) ?
929 -1 :
ctx->caption.wait_duration / 1000),
930 (
int)((
ctx->caption.wait_duration == ARIBCC_DURATION_INDEFINITE) ?
931 0 :
ctx->caption.wait_duration % 1000));
955 aribcc_caption_cleanup(&
ctx->caption);
963 if (
ctx->caption.wait_duration == ARIBCC_DURATION_INDEFINITE)
969 aribcc_caption_cleanup(&
ctx->caption);
978 aribcc_decoder_flush(
ctx->decoder);
980 aribcc_renderer_flush(
ctx->renderer);
991 aribcc_renderer_free(
ctx->renderer);
993 aribcc_decoder_free(
ctx->decoder);
995 aribcc_context_free(
ctx->context);
1012 ctx->plane_width = 960;
1013 ctx->plane_height = 540;
1014 ctx->font_size = 36;
1018 ctx->plane_width = 320;
1019 ctx->plane_height = 180;
1020 ctx->font_size = 16;
1027 if (
ctx->ignore_background)
1028 ctx->border_style = 1;
1030 ctx->border_style = 4;
1031 ctx->charstyle = ARIBCC_CHARSTYLE_DEFAULT;
1032 if (
ctx->force_stroke_text ||
ctx->ignore_background)
1033 ctx->charstyle |= ARIBCC_CHARSTYLE_STROKE;
1035 if (!(
ctx->context = aribcc_context_alloc())) {
1040 if (!(
ctx->decoder = aribcc_decoder_alloc(
ctx->context))) {
1044 if (!aribcc_decoder_initialize(
ctx->decoder,
1045 (
enum aribcc_encoding_scheme_t)
ctx->encoding_scheme,
1046 ARIBCC_CAPTIONTYPE_CAPTION,
1048 ARIBCC_LANGUAGEID_FIRST)) {
1052 aribcc_decoder_set_replace_msz_fullwidth_ascii(
ctx->decoder,
1053 ctx->replace_msz_ascii);
1054 aribcc_decoder_set_replace_msz_fullwidth_japanese(
ctx->decoder,
1055 ctx->replace_msz_japanese);
1058 if (
ctx->canvas_width > 0 &&
ctx->canvas_height > 0 &&
1059 (
ctx->avctx->width == 0 ||
ctx->avctx->height == 0)) {
1060 ctx->avctx->width =
ctx->canvas_width;
1061 ctx->avctx->height =
ctx->canvas_height;
1075 if(!(
ctx->renderer = aribcc_renderer_alloc(
ctx->context))) {
1079 if(!aribcc_renderer_initialize(
ctx->renderer,
1080 ARIBCC_CAPTIONTYPE_CAPTION,
1081 ARIBCC_FONTPROVIDER_TYPE_AUTO,
1082 ARIBCC_TEXTRENDERER_TYPE_AUTO)) {
1087 ff_dlog(
ctx,
"canvas: %dx%d plane: %dx%d bitmap: %dx%d frame: %dx%d\n",
1088 ctx->avctx->width,
ctx->avctx->height,
1089 ctx->plane_width,
ctx->plane_height,
1090 ctx->bitmap_plane_width,
ctx->bitmap_plane_height,
1091 ctx->frame_width,
ctx->frame_height);
1092 if (!aribcc_renderer_set_frame_size(
ctx->renderer,
1093 ctx->frame_width,
ctx->frame_height)) {
1095 "aribcc_renderer_set_frame_size() returned with error.\n");
1102 aribcc_renderer_set_storage_policy(
ctx->renderer, ARIBCC_CAPTION_STORAGE_POLICY_MINIMUM, 0);
1103 aribcc_renderer_set_replace_drcs(
ctx->renderer,
ctx->replace_drcs);
1104 aribcc_renderer_set_force_stroke_text(
ctx->renderer,
ctx->force_stroke_text);
1105 aribcc_renderer_set_force_no_background(
ctx->renderer,
ctx->ignore_background);
1106 aribcc_renderer_set_force_no_ruby(
ctx->renderer,
ctx->ignore_ruby);
1107 aribcc_renderer_set_stroke_width(
ctx->renderer,
ctx->stroke_width);
1108 aribcc_renderer_set_replace_msz_halfwidth_glyph(
ctx->renderer,
1109 ctx->replace_msz_glyph);
1113 const char **font_families =
NULL;
1114 const char *fonts =
ctx->font;
1117 const char **ff =
av_realloc_array(font_families, count + 1,
sizeof(*font_families));
1124 if (!ff[count - 1]) {
1131 if (!is_nomem && count)
1132 aribcc_renderer_set_default_font_family(
ctx->renderer, font_families, count,
true);
1152#if !defined(ASS_SINGLE_RECT)
1153# define ASS_SINGLE_RECT 0
1156#define OFFSET(x) offsetof(ARIBCaptionContext, x)
1157#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
1159 {
"sub_type",
"subtitle rendering type",
1170 {
"caption_encoding",
"encoding scheme of subtitle text",
1172 ARIBCC_ENCODING_SCHEME_AUTO, ARIBCC_ENCODING_SCHEME_ABNT_NBR_15606_1_LATIN,
SD, .unit =
"encoding" },
1174 { .i64 = ARIBCC_ENCODING_SCHEME_AUTO }, .flags =
SD, .unit =
"encoding" },
1175 {
"jis",
"8bit-char JIS encoding (Japanese ISDB captions)", 0,
AV_OPT_TYPE_CONST,
1176 { .i64 = ARIBCC_ENCODING_SCHEME_ARIB_STD_B24_JIS }, .flags =
SD, .unit =
"encoding" },
1178 { .i64 = ARIBCC_ENCODING_SCHEME_ARIB_STD_B24_UTF8 }, .flags =
SD, .unit =
"encoding" },
1179 {
"latin",
"latin characters (SBTVD / ISDB-Tb captions used in South America)", 0,
AV_OPT_TYPE_CONST,
1180 { .i64 = ARIBCC_ENCODING_SCHEME_ABNT_NBR_15606_1_LATIN }, .flags =
SD, .unit =
"encoding" },
1181 {
"ass_single_rect",
"workaround of ASS subtitle for players which can't handle multi-rectangle [ass]",
1183 {
"font",
"comma-separated font family [ass, bitmap]",
1185 {
"force_outline_text",
"always render characters with outline [(ass), bitmap]",
1187 {
"ignore_background",
"ignore rendering caption background [(ass), bitmap]",
1189 {
"ignore_ruby",
"ignore ruby-like characters [ass, bitmap]",
1191 {
"outline_width",
"outline width of text [(ass), bitmap]",
1193 {
"replace_drcs",
"replace known DRCS [bitmap]",
1195 {
"replace_msz_ascii",
"replace MSZ fullwidth alphanumerics with halfwidth alphanumerics [ass, bitmap]",
1197 {
"replace_msz_japanese",
"replace MSZ fullwidth Japanese with halfwidth [ass, bitmap]",
1199 {
"replace_msz_glyph",
"replace MSZ characters with halfwidth glyphs [bitmap]",
1201 {
"canvas_size",
"set input video size (WxH or abbreviation) [bitmap]",
1207 .class_name =
"aribcaption decoder",
1214 .p.name =
"libaribcaption",
const FFCodec ff_libaribcaption_decoder
static AVFormatContext * ctx
void ff_ass_bprint_text_event(AVBPrint *buf, const char *p, int size, const char *linebreaks, int keep_ass_markup)
Escape a text subtitle using ASS syntax into an AVBPrint buffer.
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, int readorder, int layer, const char *style, const char *speaker)
Add an ASS dialog to a subtitle.
#define ASS_DEFAULT_ALIGNMENT
#define ASS_DEFAULT_COLOR
#define ASS_DEFAULT_BACK_COLOR
#define ASS_DEFAULT_UNDERLINE
#define ASS_DEFAULT_ITALIC
Libavcodec external API header.
char * av_asprintf(const char *fmt,...)
Convenience header that includes libavutil's core.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FF_CODEC_DECODE_SUB_CB(func)
#define AV_PROFILE_ARIB_PROFILE_A
#define AV_PROFILE_ARIB_PROFILE_C
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AV_CODEC_FLAG2_RO_FLUSH_NOOP
Do not reset ASS ReadOrder field on flush (subtitles decoding)
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
@ SUBTITLE_ASS
Formatted text, the ass field must be set by the decoder and is authoritative.
@ SUBTITLE_TEXT
Plain text, the text field must be set by the decoder and is authoritative.
@ AV_CODEC_ID_ARIB_CAPTION
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
static int aribcaption_trans_bitmap_subtitle(ARIBCaptionContext *ctx)
aribcaption_trans_{bitmap|ass|text}_subtitle()
static int aribcaption_trans_ass_subtitle(ARIBCaptionContext *ctx)
#define ARIBC_ALPHA_DEFAULT_FRONT
#define ARIBC_BPRINT_SIZE_INIT
static void estimate_video_frame_size(ARIBCaptionContext *ctx)
static int clut_find(ARIBCaptionContext *ctx, uint32_t rgba)
static void logcat_callback(aribcc_loglevel_t level, const char *message, void *userdata)
#define ARIBC_ALPHA_DEFAULT_BACK
static int aribcaption_trans_text_subtitle(ARIBCaptionContext *ctx)
#define ARIBCC_COLOR_DIFF_RGB(c1, c2)
static void set_ass_color(AVBPrint *buf, int color_num, aribcc_color_t new_color, aribcc_color_t old_color)
static av_cold int aribcaption_close(AVCodecContext *avctx)
static int region_skipped(const ARIBCaptionContext *ctx, const aribcc_caption_region_t *region)
static void region_position(const ARIBCaptionContext *ctx, const aribcc_caption_region_t *region, int *x, int *y)
static int set_ass_header(ARIBCaptionContext *ctx)
#define ARIBC_ALPHA_MAX_NUM
static void clut_add_region(ARIBCaptionContext *ctx, aribcc_caption_region_t *region)
#define CLUT_RGBA(r, g, b, a)
static void aribcaption_flush(AVCodecContext *avctx)
static void clut_reset(ARIBCaptionContext *ctx)
static uint8_t clut_find_nearlest_alpha(ARIBCaptionContext *ctx, uint8_t a)
static void clut_set_alpha(ARIBCaptionContext *ctx, uint8_t a)
static void clut_add(ARIBCaptionContext *ctx, uint32_t rgba)
#define ARIBCC_COLOR_DIFF_A(c1, c2)
static const AVClass aribcaption_class
#define ARIBCC_COLOR_TO_CLUT_RGBA(c, a)
static int clut_color_distance(uint32_t rgba1, uint32_t rgba2)
static int region_left_out(const aribcc_caption_region_t *region, int ignore_ruby)
#define ARIBCC_COLOR_RGB(c)
#define ARIBC_BPRINT_SIZE_MAX
static uint8_t clut_pick_or_set(ARIBCaptionContext *ctx, int r, int g, int b, int a)
static int aribcaption_decode(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
static av_cold int aribcaption_init(AVCodecContext *avctx)
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
common internal api header.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
uint8_t clut_alpha[ARIBC_ALPHA_MAX_NUM]
aribcc_decoder_t * decoder
aribcc_context_t * context
aribcc_renderer_t * renderer
aribcc_render_result_t render_result
Describe the class of an AVClass context structure.
main external API structure.
int subtitle_header_size
Header containing style information for text subtitles.
int flags2
AV_CODEC_FLAG2_*.
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
uint8_t * subtitle_header
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Rational number (pair of numerator and denominator).
char * ass
0 terminated ASS/SSA compatible event line.
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
uint32_t end_display_time
int64_t pts
Same as packet pts, in AV_TIME_BASE.
#define avpriv_request_sample(...)
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)