Go to the documentation of this file.
28 #include <aribb24/aribb24.h>
29 #include <aribb24/parser.h>
30 #include <aribb24/decoder.h>
73 unsigned int plane_width = 0;
74 unsigned int plane_height = 0;
75 unsigned int font_size = 0;
99 "; Script generated by FFmpeg/Lavc%s\r\n"
100 "ScriptType: v4.00+\r\n"
108 "Fontname, Fontsize, "
109 "PrimaryColour, SecondaryColour, OutlineColour, BackColour, "
110 "Bold, Italic, Underline, StrikeOut, "
113 "BorderStyle, Outline, Shadow, "
114 "Alignment, MarginL, MarginR, MarginV, "
120 "&H%x,&H%x,&H%x,&H%x,"
130 "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
132 plane_width, plane_height,
149 void(* arib_dec_init)(arib_decoder_t*
decoder) =
NULL;
180 arib_dec_init = arib_initialize_decoder_a_profile;
183 arib_dec_init = arib_initialize_decoder_c_profile;
202 arib_finalize_decoder(b24->
decoder);
215 arib_finalize_decoder(b24->
decoder);
223 #define RGB_TO_BGR(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff))
228 const arib_buf_region_t *region = arib_decoder_get_regions(b24->
decoder);
230 AVBPrint buf = { 0 };
236 ptrdiff_t region_length = region->p_end - region->p_start;
237 unsigned int ruby_region =
238 region->i_fontheight == (profile_font_size / 2);
241 int foreground_bgr_color =
RGB_TO_BGR(region->i_foreground_color);
242 int background_bgr_color =
RGB_TO_BGR(region->i_background_color);
244 if (region_length < 0) {
256 av_bprintf(&buf,
"{\\1c&H%06x&}", foreground_bgr_color);
258 if (region->i_foreground_alpha != 0)
259 av_bprintf(&buf,
"{\\1a&H%02x&}", region->i_foreground_alpha);
262 av_bprintf(&buf,
"{\\3c&H%06x&}", background_bgr_color);
264 if (region->i_background_alpha != 0)
265 av_bprintf(&buf,
"{\\3a&H%02x&}", region->i_background_alpha);
268 if (region->i_fontwidth != profile_font_size ||
269 region->i_fontheight != profile_font_size) {
270 av_bprintf(&buf,
"{\\fscx%"PRId64
"\\fscy%"PRId64
"}",
284 region = region->p_next;
307 size_t parsed_data_size = 0;
308 size_t decoded_subtitle_size = 0;
309 const unsigned char *parsed_data =
NULL;
310 char *decoded_subtitle =
NULL;
311 time_t subtitle_duration = 0;
319 parsed_data = arib_parser_get_data(b24->
parser,
321 if (!parsed_data || !parsed_data_size) {
323 "packet (dts: %"PRId64
", pts: %"PRId64
").\n",
328 decoded_subtitle_size = parsed_data_size * 4;
329 if (!(decoded_subtitle =
av_mallocz(decoded_subtitle_size + 1))) {
331 "Failed to allocate buffer for decoded subtitle!\n");
335 decoded_subtitle_size = arib_decode_buffer(b24->
decoder,
339 decoded_subtitle_size);
341 subtitle_duration = arib_decoder_get_time(b24->
decoder);
347 sub->end_display_time = subtitle_duration ?
354 "Result: '%s' (size: %zu, pkt_pts: %"PRId64
", sub_pts: %"PRId64
" "
355 "duration: %"PRIu32
", pkt_timebase: %d/%d, time_base: %d/%d')\n",
356 decoded_subtitle ? decoded_subtitle :
"<no subtitle>",
357 decoded_subtitle_size,
359 sub->end_display_time,
363 if (decoded_subtitle)
366 *got_sub_ptr =
sub->num_rects > 0;
372 arib_finalize_decoder(b24->
decoder);
384 #define OFFSET(x) offsetof(Libaribb24Context, x)
385 #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
387 {
"aribb24-base-path",
"set the base path for the libaribb24 library",
389 {
"aribb24-skip-ruby-text",
"skip ruby text blocks during decoding",
391 {
"default_profile",
"default profile to use if not specified in the stream parameters",
406 .
p.
name =
"libaribb24",
411 .p.wrapper_name =
"libaribb24",
#define LIBAVCODEC_VERSION
#define AV_BPRINT_SIZE_UNLIMITED
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
static float sub(float src0, float src1)
arib_instance_t * lib_instance
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
char * av_asprintf(const char *fmt,...)
static int libaribb24_generate_ass_header(AVCodecContext *avctx)
#define ASS_DEFAULT_ALIGNMENT
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 FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
uint8_t * subtitle_header
Header containing style information for text subtitles.
#define ASS_DEFAULT_BORDERSTYLE
static const chunk_decoder decoder[8]
AVCodec p
The public AVCodec.
int flags
AV_CODEC_FLAG_*.
const FFCodec ff_libaribb24_decoder
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned int get_profile_font_size(AVCodecContext *avctx)
int(* init)(AVBSFContext *ctx)
#define FF_PROFILE_ARIB_PROFILE_C
#define FF_PROFILE_UNKNOWN
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define CODEC_LONG_NAME(str)
@ AV_CODEC_ID_ARIB_CAPTION
#define ASS_DEFAULT_BACK_COLOR
static int libaribb24_handle_regions(AVCodecContext *avctx, AVSubtitle *sub)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static const AVOption options[]
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int flags2
AV_CODEC_FLAG2_*.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static void libaribb24_flush(AVCodecContext *avctx)
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_INFO
Standard information.
#define ASS_DEFAULT_UNDERLINE
#define FF_PROFILE_ARIB_PROFILE_A
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
#define ASS_DEFAULT_ITALIC
#define ASS_DEFAULT_COLOR
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void av_bprintf(AVBPrint *buf, const char *fmt,...)
static int libaribb24_close(AVCodecContext *avctx)
unsigned int aribb24_skip_ruby
main external API structure.
#define FF_CODEC_DECODE_SUB_CB(func)
static void libaribb24_log(void *p, const char *msg)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
This structure stores compressed data.
static int libaribb24_decode(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *pkt)
static const AVClass aribb24_class
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_CODEC_FLAG2_RO_FLUSH_NOOP
Do not reset ASS ReadOrder field on flush (subtitles decoding)
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
static int libaribb24_init(AVCodecContext *avctx)