2012-06-06 19:12:24 +03:00
|
|
|
/*
|
|
|
|
* 3GPP TS 26.245 Timed Text encoder
|
|
|
|
* Copyright (c) 2012 Philip Langdale <philipl@overt.org>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "avcodec.h"
|
2020-04-05 23:02:27 +02:00
|
|
|
#include "libavutil/opt.h"
|
2013-02-05 23:54:02 +03:00
|
|
|
#include "libavutil/avassert.h"
|
2012-06-06 19:12:24 +03:00
|
|
|
#include "libavutil/avstring.h"
|
2012-08-04 22:19:46 +03:00
|
|
|
#include "libavutil/intreadwrite.h"
|
2015-06-26 22:14:44 +02:00
|
|
|
#include "libavutil/mem.h"
|
|
|
|
#include "libavutil/common.h"
|
2012-06-06 19:12:24 +03:00
|
|
|
#include "ass_split.h"
|
|
|
|
#include "ass.h"
|
|
|
|
|
2015-06-26 22:14:44 +02:00
|
|
|
#define STYLE_FLAG_BOLD (1<<0)
|
|
|
|
#define STYLE_FLAG_ITALIC (1<<1)
|
|
|
|
#define STYLE_FLAG_UNDERLINE (1<<2)
|
|
|
|
#define STYLE_RECORD_SIZE 12
|
|
|
|
#define SIZE_ADD 10
|
|
|
|
|
2015-07-20 20:27:28 +02:00
|
|
|
#define STYL_BOX (1<<0)
|
2015-07-20 20:32:31 +02:00
|
|
|
#define HLIT_BOX (1<<1)
|
|
|
|
#define HCLR_BOX (1<<2)
|
2015-07-20 20:27:28 +02:00
|
|
|
|
2020-04-04 23:23:34 +02:00
|
|
|
#define DEFAULT_STYLE_FONT_ID 0x01
|
|
|
|
#define DEFAULT_STYLE_FONTSIZE 0x12
|
|
|
|
#define DEFAULT_STYLE_COLOR 0xffffffff
|
|
|
|
#define DEFAULT_STYLE_FLAG 0x00
|
|
|
|
|
2020-04-04 21:36:51 +02:00
|
|
|
#define BGR_TO_RGB(c) (((c) & 0xff) << 16 | ((c) & 0xff00) | (((c) >> 16) & 0xff))
|
2020-04-05 23:02:27 +02:00
|
|
|
#define FONTSIZE_SCALE(s,fs) ((fs) * (s)->font_scale_factor + 0.5)
|
2015-06-26 22:14:44 +02:00
|
|
|
#define av_bprint_append_any(buf, data, size) av_bprint_append_data(buf, ((const char*)data), size)
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t style_start;
|
|
|
|
uint16_t style_end;
|
|
|
|
uint8_t style_flag;
|
2020-04-04 23:23:34 +02:00
|
|
|
uint16_t style_fontID;
|
|
|
|
uint8_t style_fontsize;
|
|
|
|
uint32_t style_color;
|
2015-06-26 22:14:44 +02:00
|
|
|
} StyleBox;
|
|
|
|
|
2015-07-20 20:32:31 +02:00
|
|
|
typedef struct {
|
|
|
|
uint16_t start;
|
|
|
|
uint16_t end;
|
|
|
|
} HighlightBox;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t color;
|
|
|
|
} HilightcolorBox;
|
|
|
|
|
2012-06-06 19:12:24 +03:00
|
|
|
typedef struct {
|
2020-04-05 23:02:27 +02:00
|
|
|
AVClass *class;
|
2017-04-23 19:42:25 +02:00
|
|
|
AVCodecContext *avctx;
|
|
|
|
|
2012-06-06 19:12:24 +03:00
|
|
|
ASSSplitContext *ass_ctx;
|
2020-04-05 16:34:45 +02:00
|
|
|
ASSStyle *ass_dialog_style;
|
2015-06-26 22:14:44 +02:00
|
|
|
AVBPrint buffer;
|
|
|
|
StyleBox **style_attributes;
|
|
|
|
StyleBox *style_attributes_temp;
|
2015-07-20 20:32:31 +02:00
|
|
|
HighlightBox hlit;
|
|
|
|
HilightcolorBox hclr;
|
2015-06-26 22:14:44 +02:00
|
|
|
int count;
|
2015-07-20 20:27:28 +02:00
|
|
|
uint8_t box_flags;
|
2020-04-04 23:23:34 +02:00
|
|
|
StyleBox d;
|
2015-06-26 22:14:44 +02:00
|
|
|
uint16_t text_pos;
|
2018-03-28 04:55:24 +02:00
|
|
|
uint16_t byte_count;
|
2020-04-05 22:26:02 +02:00
|
|
|
char ** fonts;
|
|
|
|
int font_count;
|
2020-04-05 23:02:27 +02:00
|
|
|
double font_scale_factor;
|
|
|
|
int frame_height;
|
2012-06-06 19:12:24 +03:00
|
|
|
} MovTextContext;
|
|
|
|
|
2015-07-20 20:27:28 +02:00
|
|
|
typedef struct {
|
|
|
|
uint32_t type;
|
|
|
|
void (*encode)(MovTextContext *s, uint32_t tsmb_type);
|
|
|
|
} Box;
|
|
|
|
|
|
|
|
static void mov_text_cleanup(MovTextContext *s)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
if (s->box_flags & STYL_BOX) {
|
|
|
|
for (j = 0; j < s->count; j++) {
|
|
|
|
av_freep(&s->style_attributes[j]);
|
|
|
|
}
|
|
|
|
av_freep(&s->style_attributes);
|
|
|
|
}
|
2020-04-04 22:43:25 +02:00
|
|
|
if (s->style_attributes_temp) {
|
2020-04-05 16:44:24 +02:00
|
|
|
*s->style_attributes_temp = s->d;
|
2020-04-04 22:43:25 +02:00
|
|
|
}
|
2015-07-20 20:27:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
uint32_t tsmb_size;
|
2020-04-04 21:52:44 +02:00
|
|
|
uint16_t style_entries;
|
2020-04-04 22:43:25 +02:00
|
|
|
if ((s->box_flags & STYL_BOX) && s->count) {
|
2015-07-20 20:27:28 +02:00
|
|
|
tsmb_size = s->count * STYLE_RECORD_SIZE + SIZE_ADD;
|
|
|
|
tsmb_size = AV_RB32(&tsmb_size);
|
2020-04-04 21:52:44 +02:00
|
|
|
style_entries = AV_RB16(&s->count);
|
2015-07-20 20:27:28 +02:00
|
|
|
/*The above three attributes are hard coded for now
|
|
|
|
but will come from ASS style in the future*/
|
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_size, 4);
|
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_type, 4);
|
2020-04-04 21:52:44 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &style_entries, 2);
|
2015-07-20 20:27:28 +02:00
|
|
|
for (j = 0; j < s->count; j++) {
|
2020-04-04 23:23:34 +02:00
|
|
|
uint16_t style_start, style_end, style_fontID;
|
|
|
|
uint32_t style_color;
|
2020-04-04 21:52:44 +02:00
|
|
|
|
|
|
|
style_start = AV_RB16(&s->style_attributes[j]->style_start);
|
|
|
|
style_end = AV_RB16(&s->style_attributes[j]->style_end);
|
2020-04-05 00:05:18 +02:00
|
|
|
style_color = AV_RB32(&s->style_attributes[j]->style_color);
|
2020-04-05 16:44:24 +02:00
|
|
|
style_fontID = AV_RB16(&s->style_attributes[j]->style_fontID);
|
2020-04-04 23:23:34 +02:00
|
|
|
|
2020-04-04 21:52:44 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &style_start, 2);
|
|
|
|
av_bprint_append_any(&s->buffer, &style_end, 2);
|
2020-04-04 23:23:34 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &style_fontID, 2);
|
2015-07-20 20:27:28 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_flag, 1);
|
2020-04-05 00:46:40 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &s->style_attributes[j]->style_fontsize, 1);
|
2020-04-04 23:23:34 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &style_color, 4);
|
2015-07-20 20:27:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-04 22:43:25 +02:00
|
|
|
mov_text_cleanup(s);
|
2015-07-20 20:27:28 +02:00
|
|
|
}
|
|
|
|
|
2015-07-20 20:32:31 +02:00
|
|
|
static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
|
|
|
|
{
|
|
|
|
uint32_t tsmb_size;
|
2020-04-04 21:52:44 +02:00
|
|
|
uint16_t start, end;
|
2015-07-20 20:32:31 +02:00
|
|
|
if (s->box_flags & HLIT_BOX) {
|
|
|
|
tsmb_size = 12;
|
|
|
|
tsmb_size = AV_RB32(&tsmb_size);
|
2020-04-04 21:52:44 +02:00
|
|
|
start = AV_RB16(&s->hlit.start);
|
|
|
|
end = AV_RB16(&s->hlit.end);
|
2015-07-20 20:32:31 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_size, 4);
|
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_type, 4);
|
2020-04-04 21:52:44 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &start, 2);
|
|
|
|
av_bprint_append_any(&s->buffer, &end, 2);
|
2015-07-20 20:32:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
|
|
|
|
{
|
2020-04-04 21:36:51 +02:00
|
|
|
uint32_t tsmb_size, color;
|
2015-07-20 20:32:31 +02:00
|
|
|
if (s->box_flags & HCLR_BOX) {
|
|
|
|
tsmb_size = 12;
|
|
|
|
tsmb_size = AV_RB32(&tsmb_size);
|
2020-04-04 21:36:51 +02:00
|
|
|
color = AV_RB32(&s->hclr.color);
|
2015-07-20 20:32:31 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_size, 4);
|
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_type, 4);
|
2020-04-04 21:36:51 +02:00
|
|
|
av_bprint_append_any(&s->buffer, &color, 4);
|
2015-07-20 20:32:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-20 20:27:28 +02:00
|
|
|
static const Box box_types[] = {
|
|
|
|
{ MKTAG('s','t','y','l'), encode_styl },
|
2015-07-20 20:32:31 +02:00
|
|
|
{ MKTAG('h','l','i','t'), encode_hlit },
|
|
|
|
{ MKTAG('h','c','l','r'), encode_hclr },
|
2015-07-20 20:27:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const static size_t box_count = FF_ARRAY_ELEMS(box_types);
|
2012-06-06 19:12:24 +03:00
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
static int mov_text_encode_close(AVCodecContext *avctx)
|
2012-06-06 19:12:24 +03:00
|
|
|
{
|
2020-04-05 22:26:02 +02:00
|
|
|
MovTextContext *s = avctx->priv_data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ff_ass_split_free(s->ass_ctx);
|
|
|
|
if (s->style_attributes) {
|
|
|
|
for (i = 0; i < s->count; i++) {
|
|
|
|
av_freep(&s->style_attributes[i]);
|
|
|
|
}
|
|
|
|
av_freep(&s->style_attributes);
|
|
|
|
}
|
|
|
|
av_freep(&s->fonts);
|
|
|
|
av_freep(&s->style_attributes_temp);
|
|
|
|
av_bprint_finalize(&s->buffer, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encode_sample_description(AVCodecContext *avctx)
|
|
|
|
{
|
|
|
|
ASS * ass;
|
|
|
|
ASSStyle * style;
|
|
|
|
int i, j;
|
|
|
|
uint32_t tsmb_size, tsmb_type, back_color, style_color;
|
|
|
|
uint16_t style_start, style_end, fontID, count;
|
|
|
|
int font_names_total_len = 0;
|
|
|
|
MovTextContext *s = avctx->priv_data;
|
|
|
|
|
|
|
|
static const uint8_t display_and_justification[] = {
|
2012-06-06 19:12:24 +03:00
|
|
|
0x00, 0x00, 0x00, 0x00, // uint32_t displayFlags
|
|
|
|
0x01, // int8_t horizontal-justification
|
|
|
|
0xFF, // int8_t vertical-justification
|
2020-04-05 22:26:02 +02:00
|
|
|
};
|
|
|
|
// 0x00, 0x00, 0x00, 0x00, // uint8_t background-color-rgba[4]
|
|
|
|
static const uint8_t box_record[] = {
|
|
|
|
// BoxRecord {
|
2012-06-06 19:12:24 +03:00
|
|
|
0x00, 0x00, // int16_t top
|
|
|
|
0x00, 0x00, // int16_t left
|
|
|
|
0x00, 0x00, // int16_t bottom
|
|
|
|
0x00, 0x00, // int16_t right
|
2020-04-05 22:26:02 +02:00
|
|
|
// };
|
2012-06-06 19:12:24 +03:00
|
|
|
};
|
2020-04-05 22:26:02 +02:00
|
|
|
// StyleRecord {
|
|
|
|
// 0x00, 0x00, // uint16_t startChar
|
|
|
|
// 0x00, 0x00, // uint16_t endChar
|
|
|
|
// 0x00, 0x01, // uint16_t font-ID
|
|
|
|
// 0x00, // uint8_t face-style-flags
|
|
|
|
// 0x12, // uint8_t font-size
|
|
|
|
// 0xFF, 0xFF, 0xFF, 0xFF, // uint8_t text-color-rgba[4]
|
|
|
|
// };
|
|
|
|
// FontTableBox {
|
|
|
|
// 0x00, 0x00, 0x00, 0x12, // uint32_t size
|
|
|
|
// 'f', 't', 'a', 'b', // uint8_t name[4]
|
|
|
|
// 0x00, 0x01, // uint16_t entry-count
|
|
|
|
// FontRecord {
|
|
|
|
// 0x00, 0x01, // uint16_t font-ID
|
|
|
|
// 0x05, // uint8_t font-name-length
|
|
|
|
// 'S', 'e', 'r', 'i', 'f',// uint8_t font[font-name-length]
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
// Populate sample description from ASS header
|
|
|
|
ass = (ASS*)s->ass_ctx;
|
2020-04-05 23:02:27 +02:00
|
|
|
// Compute font scaling factor based on (optionally) provided
|
|
|
|
// output video height and ASS script play_res_y
|
|
|
|
if (s->frame_height && ass->script_info.play_res_y)
|
|
|
|
s->font_scale_factor = (double)s->frame_height / ass->script_info.play_res_y;
|
|
|
|
else
|
|
|
|
s->font_scale_factor = 1;
|
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
style = ff_ass_style_get(s->ass_ctx, "Default");
|
|
|
|
if (!style && ass->styles_count) {
|
|
|
|
style = &ass->styles[0];
|
|
|
|
}
|
|
|
|
s->d.style_fontID = DEFAULT_STYLE_FONT_ID;
|
|
|
|
s->d.style_fontsize = DEFAULT_STYLE_FONTSIZE;
|
|
|
|
s->d.style_color = DEFAULT_STYLE_COLOR;
|
|
|
|
s->d.style_flag = DEFAULT_STYLE_FLAG;
|
|
|
|
if (style) {
|
2020-04-05 23:02:27 +02:00
|
|
|
s->d.style_fontsize = FONTSIZE_SCALE(s, style->font_size);
|
2020-04-05 22:26:02 +02:00
|
|
|
s->d.style_color = BGR_TO_RGB(style->primary_color & 0xffffff) << 8 |
|
|
|
|
255 - ((uint32_t)style->primary_color >> 24);
|
|
|
|
s->d.style_flag = (!!style->bold * STYLE_FLAG_BOLD) |
|
|
|
|
(!!style->italic * STYLE_FLAG_ITALIC) |
|
|
|
|
(!!style->underline * STYLE_FLAG_UNDERLINE);
|
|
|
|
back_color = (BGR_TO_RGB(style->back_color & 0xffffff) << 8) |
|
|
|
|
(255 - ((uint32_t)style->back_color >> 24));
|
|
|
|
}
|
2012-06-06 19:12:24 +03:00
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
av_bprint_append_any(&s->buffer, display_and_justification,
|
|
|
|
sizeof(display_and_justification));
|
|
|
|
back_color = AV_RB32(&back_color);
|
|
|
|
av_bprint_append_any(&s->buffer, &back_color, 4);
|
|
|
|
// BoxRecord {
|
|
|
|
av_bprint_append_any(&s->buffer, box_record, sizeof(box_record));
|
|
|
|
// };
|
|
|
|
// StyleRecord {
|
|
|
|
style_start = AV_RB16(&s->d.style_start);
|
|
|
|
style_end = AV_RB16(&s->d.style_end);
|
|
|
|
fontID = AV_RB16(&s->d.style_fontID);
|
|
|
|
style_color = AV_RB32(&s->d.style_color);
|
|
|
|
av_bprint_append_any(&s->buffer, &style_start, 2);
|
|
|
|
av_bprint_append_any(&s->buffer, &style_end, 2);
|
|
|
|
av_bprint_append_any(&s->buffer, &fontID, 2);
|
|
|
|
av_bprint_append_any(&s->buffer, &s->d.style_flag, 1);
|
|
|
|
av_bprint_append_any(&s->buffer, &s->d.style_fontsize, 1);
|
|
|
|
av_bprint_append_any(&s->buffer, &style_color, 4);
|
|
|
|
// };
|
|
|
|
|
|
|
|
// Build font table
|
|
|
|
// We can't build a complete font table since that would require
|
|
|
|
// scanning all dialogs first. But we can at least fill in what
|
|
|
|
// is avaiable in the ASS header
|
|
|
|
if (style && ass->styles_count) {
|
|
|
|
// Find unique font names
|
|
|
|
av_dynarray_add(&s->fonts, &s->font_count, style->font_name);
|
|
|
|
font_names_total_len += strlen(style->font_name);
|
|
|
|
for (i = 0; i < ass->styles_count; i++) {
|
|
|
|
int found = 0;
|
|
|
|
for (j = 0; j < s->font_count; j++) {
|
|
|
|
if (!strcmp(s->fonts[j], ass->styles[i].font_name)) {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
av_dynarray_add(&s->fonts, &s->font_count,
|
|
|
|
ass->styles[i].font_name);
|
|
|
|
font_names_total_len += strlen(ass->styles[i].font_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
av_dynarray_add(&s->fonts, &s->font_count, (char*)"Serif");
|
|
|
|
|
|
|
|
// FontTableBox {
|
|
|
|
tsmb_size = SIZE_ADD + 3 * s->font_count + font_names_total_len;
|
|
|
|
tsmb_size = AV_RB32(&tsmb_size);
|
|
|
|
tsmb_type = MKTAG('f','t','a','b');
|
|
|
|
count = AV_RB16(&s->font_count);
|
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_size, 4);
|
|
|
|
av_bprint_append_any(&s->buffer, &tsmb_type, 4);
|
|
|
|
av_bprint_append_any(&s->buffer, &count, 2);
|
|
|
|
// FontRecord {
|
|
|
|
for (i = 0; i < s->font_count; i++) {
|
|
|
|
int len;
|
|
|
|
fontID = i + 1;
|
|
|
|
fontID = AV_RB16(&fontID);
|
|
|
|
av_bprint_append_any(&s->buffer, &fontID, 2);
|
|
|
|
len = strlen(s->fonts[i]);
|
|
|
|
av_bprint_append_any(&s->buffer, &len, 1);
|
|
|
|
av_bprint_append_any(&s->buffer, s->fonts[i], len);
|
|
|
|
}
|
|
|
|
// };
|
|
|
|
// };
|
2012-06-06 19:12:24 +03:00
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
if (!av_bprint_is_complete(&s->buffer)) {
|
2020-04-04 22:43:25 +02:00
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
}
|
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
avctx->extradata_size = s->buffer.len;
|
2015-07-27 22:53:16 +02:00
|
|
|
avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
|
2020-04-05 22:26:02 +02:00
|
|
|
if (!avctx->extradata) {
|
2012-06-06 19:12:24 +03:00
|
|
|
return AVERROR(ENOMEM);
|
2020-04-05 22:26:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(avctx->extradata, s->buffer.str, avctx->extradata_size);
|
|
|
|
av_bprint_clear(&s->buffer);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_cold int mov_text_encode_init(AVCodecContext *avctx)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
MovTextContext *s = avctx->priv_data;
|
|
|
|
s->avctx = avctx;
|
2012-06-06 19:12:24 +03:00
|
|
|
|
2015-06-26 22:14:44 +02:00
|
|
|
av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
|
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
s->style_attributes_temp = av_mallocz(sizeof(*s->style_attributes_temp));
|
|
|
|
if (!s->style_attributes_temp) {
|
|
|
|
ret = AVERROR(ENOMEM);
|
|
|
|
goto fail;
|
|
|
|
}
|
2012-06-06 19:12:24 +03:00
|
|
|
|
|
|
|
s->ass_ctx = ff_ass_split(avctx->subtitle_header);
|
2020-04-05 22:26:02 +02:00
|
|
|
if (!s->ass_ctx) {
|
|
|
|
ret = AVERROR_INVALIDDATA;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
ret = encode_sample_description(avctx);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2020-04-04 23:23:34 +02:00
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
return 0;
|
2020-04-04 23:23:34 +02:00
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
fail:
|
|
|
|
mov_text_encode_close(avctx);
|
|
|
|
return ret;
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
2020-04-04 22:43:25 +02:00
|
|
|
// Start a new style box if needed
|
|
|
|
static int mov_text_style_start(MovTextContext *s)
|
2015-06-26 22:14:44 +02:00
|
|
|
{
|
2020-04-04 22:43:25 +02:00
|
|
|
// there's an existing style entry
|
|
|
|
if (s->style_attributes_temp->style_start == s->text_pos)
|
|
|
|
// Still at same text pos, use same entry
|
|
|
|
return 1;
|
2020-04-05 22:26:02 +02:00
|
|
|
if (s->style_attributes_temp->style_flag != s->d.style_flag ||
|
|
|
|
s->style_attributes_temp->style_color != s->d.style_color ||
|
|
|
|
s->style_attributes_temp->style_fontID != s->d.style_fontID ||
|
2020-04-05 00:46:40 +02:00
|
|
|
s->style_attributes_temp->style_fontsize != s->d.style_fontsize) {
|
2020-04-04 22:43:25 +02:00
|
|
|
// last style != defaults, end the style entry and start a new one
|
|
|
|
s->box_flags |= STYL_BOX;
|
2020-04-04 21:52:44 +02:00
|
|
|
s->style_attributes_temp->style_end = s->text_pos;
|
2015-06-26 22:14:44 +02:00
|
|
|
av_dynarray_add(&s->style_attributes, &s->count, s->style_attributes_temp);
|
|
|
|
s->style_attributes_temp = av_malloc(sizeof(*s->style_attributes_temp));
|
|
|
|
if (!s->style_attributes_temp) {
|
2015-07-20 20:27:28 +02:00
|
|
|
mov_text_cleanup(s);
|
2015-06-26 22:14:44 +02:00
|
|
|
av_bprint_clear(&s->buffer);
|
2015-07-20 20:27:28 +02:00
|
|
|
s->box_flags &= ~STYL_BOX;
|
2020-04-04 22:43:25 +02:00
|
|
|
return 0;
|
2015-06-26 22:14:44 +02:00
|
|
|
}
|
|
|
|
|
2020-04-05 16:44:24 +02:00
|
|
|
*s->style_attributes_temp = s->d;
|
2020-04-04 22:43:25 +02:00
|
|
|
s->style_attributes_temp->style_start = s->text_pos;
|
|
|
|
} else { // style entry matches defaults, drop entry
|
2020-04-05 16:44:24 +02:00
|
|
|
*s->style_attributes_temp = s->d;
|
2020-04-04 22:43:25 +02:00
|
|
|
s->style_attributes_temp->style_start = s->text_pos;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t mov_text_style_to_flag(const char style)
|
|
|
|
{
|
|
|
|
uint8_t style_flag = 0;
|
|
|
|
|
|
|
|
switch (style){
|
|
|
|
case 'b':
|
|
|
|
style_flag = STYLE_FLAG_BOLD;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
style_flag = STYLE_FLAG_ITALIC;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
style_flag = STYLE_FLAG_UNDERLINE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return style_flag;
|
|
|
|
}
|
|
|
|
|
2020-04-04 23:23:34 +02:00
|
|
|
static void mov_text_style_set(MovTextContext *s, uint8_t style_flags)
|
|
|
|
{
|
|
|
|
if (!s->style_attributes_temp ||
|
|
|
|
!((s->style_attributes_temp->style_flag & style_flags) ^ style_flags)) {
|
|
|
|
// setting flags that that are already set
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mov_text_style_start(s))
|
|
|
|
s->style_attributes_temp->style_flag |= style_flags;
|
|
|
|
}
|
|
|
|
|
2020-04-04 22:43:25 +02:00
|
|
|
static void mov_text_style_cb(void *priv, const char style, int close)
|
|
|
|
{
|
|
|
|
MovTextContext *s = priv;
|
|
|
|
uint8_t style_flag = mov_text_style_to_flag(style);
|
|
|
|
|
|
|
|
if (!s->style_attributes_temp ||
|
|
|
|
!!(s->style_attributes_temp->style_flag & style_flag) != close) {
|
|
|
|
// setting flag that is already set
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mov_text_style_start(s)) {
|
|
|
|
if (!close)
|
|
|
|
s->style_attributes_temp->style_flag |= style_flag;
|
|
|
|
else
|
|
|
|
s->style_attributes_temp->style_flag &= ~style_flag;
|
2015-06-26 22:14:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 00:05:18 +02:00
|
|
|
static void mov_text_color_set(MovTextContext *s, uint32_t color)
|
|
|
|
{
|
|
|
|
if (!s->style_attributes_temp ||
|
|
|
|
(s->style_attributes_temp->style_color & 0xffffff00) == color) {
|
|
|
|
// color hasn't changed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mov_text_style_start(s))
|
|
|
|
s->style_attributes_temp->style_color = (color & 0xffffff00) |
|
|
|
|
(s->style_attributes_temp->style_color & 0xff);
|
|
|
|
}
|
|
|
|
|
2015-07-20 20:32:31 +02:00
|
|
|
static void mov_text_color_cb(void *priv, unsigned int color, unsigned int color_id)
|
|
|
|
{
|
|
|
|
MovTextContext *s = priv;
|
2020-04-04 21:36:51 +02:00
|
|
|
|
|
|
|
color = BGR_TO_RGB(color) << 8;
|
2020-04-05 00:05:18 +02:00
|
|
|
if (color_id == 1) { //primary color changes
|
|
|
|
mov_text_color_set(s, color);
|
|
|
|
} else if (color_id == 2) { //secondary color changes
|
2020-04-09 21:12:39 +02:00
|
|
|
if (!(s->box_flags & HCLR_BOX))
|
|
|
|
// Highlight alpha not set yet, use current primary alpha
|
|
|
|
s->hclr.color = s->style_attributes_temp->style_color;
|
|
|
|
if (!(s->box_flags & HLIT_BOX) || s->hlit.start == s->text_pos) {
|
2015-07-20 20:32:31 +02:00
|
|
|
s->box_flags |= HCLR_BOX;
|
|
|
|
s->box_flags |= HLIT_BOX;
|
2020-04-04 21:52:44 +02:00
|
|
|
s->hlit.start = s->text_pos;
|
2020-04-09 21:12:39 +02:00
|
|
|
s->hclr.color = color | (s->hclr.color & 0xFF);
|
2015-07-20 20:32:31 +02:00
|
|
|
}
|
2020-04-09 21:12:39 +02:00
|
|
|
else //close tag
|
|
|
|
s->hlit.end = s->text_pos;
|
|
|
|
/* If there are more than one secondary color changes in ASS,
|
|
|
|
take start of first section and end of last section. Movtext
|
|
|
|
allows only one highlight box per sample.
|
|
|
|
*/
|
2015-07-20 20:32:31 +02:00
|
|
|
}
|
2020-04-09 21:12:39 +02:00
|
|
|
// Movtext does not support changes to other color_id (outline, background)
|
2015-07-20 20:32:31 +02:00
|
|
|
}
|
|
|
|
|
2020-04-05 00:34:16 +02:00
|
|
|
static void mov_text_alpha_set(MovTextContext *s, uint8_t alpha)
|
|
|
|
{
|
|
|
|
if (!s->style_attributes_temp ||
|
|
|
|
(s->style_attributes_temp->style_color & 0xff) == alpha) {
|
|
|
|
// color hasn't changed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mov_text_style_start(s))
|
|
|
|
s->style_attributes_temp->style_color =
|
|
|
|
(s->style_attributes_temp->style_color & 0xffffff00) | alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mov_text_alpha_cb(void *priv, int alpha, int alpha_id)
|
|
|
|
{
|
|
|
|
MovTextContext *s = priv;
|
|
|
|
|
2020-04-09 21:12:39 +02:00
|
|
|
alpha = 255 - alpha;
|
2020-04-05 00:34:16 +02:00
|
|
|
if (alpha_id == 1) // primary alpha changes
|
2020-04-09 21:12:39 +02:00
|
|
|
mov_text_alpha_set(s, alpha);
|
|
|
|
else if (alpha_id == 2) { //secondary alpha changes
|
|
|
|
if (!(s->box_flags & HCLR_BOX))
|
|
|
|
// Highlight color not set yet, use current primary color
|
|
|
|
s->hclr.color = s->style_attributes_temp->style_color;
|
|
|
|
if (!(s->box_flags & HLIT_BOX) || s->hlit.start == s->text_pos) {
|
|
|
|
s->box_flags |= HCLR_BOX;
|
|
|
|
s->box_flags |= HLIT_BOX;
|
|
|
|
s->hlit.start = s->text_pos;
|
|
|
|
s->hclr.color = (s->hclr.color & 0xffffff00) | alpha;
|
|
|
|
}
|
|
|
|
else //close tag
|
|
|
|
s->hlit.end = s->text_pos;
|
|
|
|
}
|
|
|
|
// Movtext does not support changes to other alpha_id (outline, background)
|
2020-04-05 00:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-04-05 22:26:02 +02:00
|
|
|
static uint16_t find_font_id(MovTextContext * s, const char * name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < s->font_count; i++) {
|
|
|
|
if (!strcmp(name, s->fonts[i]))
|
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mov_text_font_name_set(MovTextContext *s, const char *name)
|
|
|
|
{
|
|
|
|
int fontID = find_font_id(s, name);
|
|
|
|
if (!s->style_attributes_temp ||
|
|
|
|
s->style_attributes_temp->style_fontID == fontID) {
|
|
|
|
// color hasn't changed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mov_text_style_start(s))
|
|
|
|
s->style_attributes_temp->style_fontID = fontID;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mov_text_font_name_cb(void *priv, const char *name)
|
|
|
|
{
|
|
|
|
mov_text_font_name_set((MovTextContext*)priv, name);
|
|
|
|
}
|
|
|
|
|
2020-04-05 00:46:40 +02:00
|
|
|
static void mov_text_font_size_set(MovTextContext *s, int size)
|
|
|
|
{
|
2020-04-05 23:02:27 +02:00
|
|
|
size = FONTSIZE_SCALE(s, size);
|
2020-04-05 00:46:40 +02:00
|
|
|
if (!s->style_attributes_temp ||
|
|
|
|
s->style_attributes_temp->style_fontsize == size) {
|
|
|
|
// color hasn't changed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mov_text_style_start(s))
|
|
|
|
s->style_attributes_temp->style_fontsize = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mov_text_font_size_cb(void *priv, int size)
|
|
|
|
{
|
|
|
|
mov_text_font_size_set((MovTextContext*)priv, size);
|
|
|
|
}
|
|
|
|
|
2020-04-04 22:52:00 +02:00
|
|
|
static void mov_text_end_cb(void *priv)
|
|
|
|
{
|
|
|
|
// End of text, close any open style record
|
|
|
|
mov_text_style_start((MovTextContext*)priv);
|
|
|
|
}
|
|
|
|
|
2020-04-05 16:34:45 +02:00
|
|
|
static void mov_text_ass_style_set(MovTextContext *s, ASSStyle *style)
|
2020-04-04 23:23:34 +02:00
|
|
|
{
|
2020-04-05 00:34:16 +02:00
|
|
|
uint8_t style_flags, alpha;
|
2020-04-05 00:05:18 +02:00
|
|
|
uint32_t color;
|
2020-04-04 23:23:34 +02:00
|
|
|
|
|
|
|
if (style) {
|
|
|
|
style_flags = (!!style->bold * STYLE_FLAG_BOLD) |
|
|
|
|
(!!style->italic * STYLE_FLAG_ITALIC) |
|
|
|
|
(!!style->underline * STYLE_FLAG_UNDERLINE);
|
|
|
|
mov_text_style_set(s, style_flags);
|
2020-04-05 00:05:18 +02:00
|
|
|
color = BGR_TO_RGB(style->primary_color & 0xffffff) << 8;
|
|
|
|
mov_text_color_set(s, color);
|
2020-04-05 00:34:16 +02:00
|
|
|
alpha = 255 - ((uint32_t)style->primary_color >> 24);
|
|
|
|
mov_text_alpha_set(s, alpha);
|
2020-04-05 00:46:40 +02:00
|
|
|
mov_text_font_size_set(s, style->font_size);
|
2020-04-05 22:26:02 +02:00
|
|
|
mov_text_font_name_set(s, style->font_name);
|
2020-04-05 16:34:45 +02:00
|
|
|
} else {
|
|
|
|
// End current style record, go back to defaults
|
|
|
|
mov_text_style_start(s);
|
2020-04-04 23:23:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 16:34:45 +02:00
|
|
|
static void mov_text_dialog(MovTextContext *s, ASSDialog *dialog)
|
|
|
|
{
|
|
|
|
ASSStyle * style = ff_ass_style_get(s->ass_ctx, dialog->style);
|
|
|
|
|
|
|
|
s->ass_dialog_style = style;
|
|
|
|
mov_text_ass_style_set(s, style);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mov_text_cancel_overrides_cb(void *priv, const char * style_name)
|
|
|
|
{
|
|
|
|
MovTextContext *s = priv;
|
|
|
|
ASSStyle * style;
|
|
|
|
|
|
|
|
if (!style_name || !*style_name)
|
|
|
|
style = s->ass_dialog_style;
|
|
|
|
else
|
|
|
|
style= ff_ass_style_get(s->ass_ctx, style_name);
|
|
|
|
|
|
|
|
mov_text_ass_style_set(s, style);
|
|
|
|
}
|
|
|
|
|
2018-03-28 04:55:24 +02:00
|
|
|
static uint16_t utf8_strlen(const char *text, int len)
|
|
|
|
{
|
|
|
|
uint16_t i = 0, ret = 0;
|
|
|
|
while (i < len) {
|
|
|
|
char c = text[i];
|
|
|
|
if ((c & 0x80) == 0)
|
|
|
|
i += 1;
|
|
|
|
else if ((c & 0xE0) == 0xC0)
|
|
|
|
i += 2;
|
|
|
|
else if ((c & 0xF0) == 0xE0)
|
|
|
|
i += 3;
|
|
|
|
else if ((c & 0xF8) == 0xF0)
|
|
|
|
i += 4;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-06 19:12:24 +03:00
|
|
|
static void mov_text_text_cb(void *priv, const char *text, int len)
|
|
|
|
{
|
2018-03-28 04:55:24 +02:00
|
|
|
uint16_t utf8_len = utf8_strlen(text, len);
|
2012-06-06 19:12:24 +03:00
|
|
|
MovTextContext *s = priv;
|
2015-06-26 22:14:44 +02:00
|
|
|
av_bprint_append_data(&s->buffer, text, len);
|
2018-03-28 04:55:24 +02:00
|
|
|
// If it's not utf-8, just use the byte length
|
|
|
|
s->text_pos += utf8_len ? utf8_len : len;
|
|
|
|
s->byte_count += len;
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mov_text_new_line_cb(void *priv, int forced)
|
|
|
|
{
|
|
|
|
MovTextContext *s = priv;
|
2015-06-26 22:14:44 +02:00
|
|
|
av_bprint_append_data(&s->buffer, "\n", 1);
|
|
|
|
s->text_pos += 1;
|
2018-03-28 04:55:24 +02:00
|
|
|
s->byte_count += 1;
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ASSCodesCallbacks mov_text_callbacks = {
|
2020-04-05 16:34:45 +02:00
|
|
|
.text = mov_text_text_cb,
|
|
|
|
.new_line = mov_text_new_line_cb,
|
|
|
|
.style = mov_text_style_cb,
|
|
|
|
.color = mov_text_color_cb,
|
|
|
|
.alpha = mov_text_alpha_cb,
|
2020-04-05 22:26:02 +02:00
|
|
|
.font_name = mov_text_font_name_cb,
|
2020-04-05 16:34:45 +02:00
|
|
|
.font_size = mov_text_font_size_cb,
|
|
|
|
.cancel_overrides = mov_text_cancel_overrides_cb,
|
|
|
|
.end = mov_text_end_cb,
|
2012-06-06 19:12:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
2012-09-18 15:30:31 +03:00
|
|
|
int bufsize, const AVSubtitle *sub)
|
2012-06-06 19:12:24 +03:00
|
|
|
{
|
|
|
|
MovTextContext *s = avctx->priv_data;
|
|
|
|
ASSDialog *dialog;
|
2016-02-21 13:58:36 +02:00
|
|
|
int i, length;
|
2015-07-20 20:27:28 +02:00
|
|
|
size_t j;
|
2012-06-06 19:12:24 +03:00
|
|
|
|
2018-03-28 04:55:24 +02:00
|
|
|
s->byte_count = 0;
|
2015-06-26 22:14:44 +02:00
|
|
|
s->text_pos = 0;
|
|
|
|
s->count = 0;
|
2015-07-20 20:27:28 +02:00
|
|
|
s->box_flags = 0;
|
2012-06-06 19:12:24 +03:00
|
|
|
for (i = 0; i < sub->num_rects; i++) {
|
2016-01-06 14:43:23 +02:00
|
|
|
const char *ass = sub->rects[i]->ass;
|
2012-06-06 19:12:24 +03:00
|
|
|
|
|
|
|
if (sub->rects[i]->type != SUBTITLE_ASS) {
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
|
2020-04-10 20:30:10 +02:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
2016-02-21 13:58:36 +02:00
|
|
|
#if FF_API_ASS_TIMING
|
2016-01-06 14:43:23 +02:00
|
|
|
if (!strncmp(ass, "Dialogue: ", 10)) {
|
2016-02-21 13:58:36 +02:00
|
|
|
int num;
|
2016-01-06 14:43:23 +02:00
|
|
|
dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num);
|
2016-02-26 23:15:20 +02:00
|
|
|
for (; dialog && num--; dialog++) {
|
2020-04-04 23:23:34 +02:00
|
|
|
mov_text_dialog(s, dialog);
|
2016-02-26 23:15:20 +02:00
|
|
|
ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text);
|
|
|
|
}
|
2016-01-06 14:43:23 +02:00
|
|
|
} else {
|
2016-02-21 13:58:36 +02:00
|
|
|
#endif
|
2016-01-06 14:43:23 +02:00
|
|
|
dialog = ff_ass_split_dialog2(s->ass_ctx, ass);
|
|
|
|
if (!dialog)
|
|
|
|
return AVERROR(ENOMEM);
|
2020-04-04 23:23:34 +02:00
|
|
|
mov_text_dialog(s, dialog);
|
2016-01-06 14:43:23 +02:00
|
|
|
ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text);
|
|
|
|
ff_ass_free_dialog(&dialog);
|
2016-02-21 13:58:36 +02:00
|
|
|
#if FF_API_ASS_TIMING
|
2016-01-06 14:43:23 +02:00
|
|
|
}
|
2016-02-21 13:58:36 +02:00
|
|
|
#endif
|
2015-07-20 20:27:28 +02:00
|
|
|
|
|
|
|
for (j = 0; j < box_count; j++) {
|
|
|
|
box_types[j].encode(s, box_types[j].type);
|
2015-06-26 22:14:44 +02:00
|
|
|
}
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
2018-03-28 04:55:24 +02:00
|
|
|
AV_WB16(buf, s->byte_count);
|
2012-06-06 19:12:24 +03:00
|
|
|
buf += 2;
|
|
|
|
|
2015-06-26 22:14:44 +02:00
|
|
|
if (!av_bprint_is_complete(&s->buffer)) {
|
|
|
|
length = AVERROR(ENOMEM);
|
|
|
|
goto exit;
|
|
|
|
}
|
2012-06-06 19:12:24 +03:00
|
|
|
|
2015-06-26 22:14:44 +02:00
|
|
|
if (!s->buffer.len) {
|
|
|
|
length = 0;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->buffer.len > bufsize - 3) {
|
2012-06-06 19:12:24 +03:00
|
|
|
av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
|
2020-04-10 20:30:10 +02:00
|
|
|
length = AVERROR_BUFFER_TOO_SMALL;
|
2015-06-26 22:14:44 +02:00
|
|
|
goto exit;
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
2015-06-26 22:14:44 +02:00
|
|
|
memcpy(buf, s->buffer.str, s->buffer.len);
|
|
|
|
length = s->buffer.len + 2;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
av_bprint_clear(&s->buffer);
|
|
|
|
return length;
|
2012-06-06 19:12:24 +03:00
|
|
|
}
|
|
|
|
|
2020-04-05 23:02:27 +02:00
|
|
|
#define OFFSET(x) offsetof(MovTextContext, x)
|
|
|
|
#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
|
|
|
|
static const AVOption options[] = {
|
|
|
|
{ "height", "Frame height, usually video height", OFFSET(frame_height), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
|
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const AVClass mov_text_encoder_class = {
|
|
|
|
.class_name = "MOV text enoder",
|
|
|
|
.item_name = av_default_item_name,
|
|
|
|
.option = options,
|
|
|
|
.version = LIBAVUTIL_VERSION_INT,
|
|
|
|
};
|
|
|
|
|
2012-06-06 19:12:24 +03:00
|
|
|
AVCodec ff_movtext_encoder = {
|
|
|
|
.name = "mov_text",
|
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"),
|
|
|
|
.type = AVMEDIA_TYPE_SUBTITLE,
|
2012-08-07 23:45:46 +03:00
|
|
|
.id = AV_CODEC_ID_MOV_TEXT,
|
2012-06-06 19:12:24 +03:00
|
|
|
.priv_data_size = sizeof(MovTextContext),
|
2020-04-05 23:02:27 +02:00
|
|
|
.priv_class = &mov_text_encoder_class,
|
2012-06-06 19:12:24 +03:00
|
|
|
.init = mov_text_encode_init,
|
2012-09-18 15:30:31 +03:00
|
|
|
.encode_sub = mov_text_encode_frame,
|
2012-06-06 19:12:24 +03:00
|
|
|
.close = mov_text_encode_close,
|
|
|
|
};
|