FFmpeg  2.8.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
movtextdec.c
Go to the documentation of this file.
1 /*
2  * 3GPP TS 26.245 Timed Text decoder
3  * Copyright (c) 2012 Philip Langdale <philipl@overt.org>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "avcodec.h"
23 #include "ass.h"
24 #include "libavutil/avstring.h"
25 #include "libavutil/common.h"
26 #include "libavutil/bprint.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/mem.h"
29 
30 #define STYLE_FLAG_BOLD (1<<0)
31 #define STYLE_FLAG_ITALIC (1<<1)
32 #define STYLE_FLAG_UNDERLINE (1<<2)
33 
34 #define BOX_SIZE_INITIAL 40
35 
36 #define STYL_BOX (1<<0)
37 #define HLIT_BOX (1<<1)
38 #define HCLR_BOX (1<<2)
39 #define TWRP_BOX (1<<3)
40 
41 #define BOTTOM_LEFT 1
42 #define BOTTOM_CENTER 2
43 #define BOTTOM_RIGHT 3
44 #define MIDDLE_LEFT 4
45 #define MIDDLE_CENTER 5
46 #define MIDDLE_RIGHT 6
47 #define TOP_LEFT 7
48 #define TOP_CENTER 8
49 #define TOP_RIGHT 9
50 
51 typedef struct {
52  char *font;
53  int fontsize;
54  int color;
56  int bold;
57  int italic;
58  int underline;
59  int alignment;
61 
62 typedef struct {
63  uint16_t fontID;
64  char *font;
65 } FontRecord;
66 
67 typedef struct {
68  uint16_t style_start;
69  uint16_t style_end;
72  uint16_t style_fontID;
73 } StyleBox;
74 
75 typedef struct {
76  uint16_t hlit_start;
77  uint16_t hlit_end;
78 } HighlightBox;
79 
80 typedef struct {
81  uint8_t hlit_color[4];
83 
84 typedef struct {
86 } TextWrapBox;
87 
88 typedef struct {
98  uint16_t style_entries, ftab_entries;
99  uint64_t tracksize;
100  int size_var;
101  int count_s, count_f;
103 
104 typedef struct {
105  uint32_t type;
106  size_t base_size;
107  int (*decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt);
108 } Box;
109 
111 {
112  int i;
113  if (m->box_flags & STYL_BOX) {
114  for(i = 0; i < m->count_s; i++) {
115  av_freep(&m->s[i]);
116  }
117  av_freep(&m->s);
118  m->count_s = 0;
119  m->style_entries = 0;
120  }
121 }
122 
124 {
125  int i;
126  if (m->ftab_temp)
127  av_freep(&m->ftab_temp->font);
128  av_freep(&m->ftab_temp);
129  if (m->ftab) {
130  for(i = 0; i < m->count_f; i++) {
131  av_freep(&m->ftab[i]->font);
132  av_freep(&m->ftab[i]);
133  }
134  }
135  av_freep(&m->ftab);
136 }
137 
139 {
140  uint8_t *tx3g_ptr = avctx->extradata;
141  int i, box_size, font_length;
142  int8_t v_align, h_align;
143  int style_fontID;
144  StyleBox s_default;
145 
146  m->count_f = 0;
147  m->ftab_entries = 0;
148  box_size = BOX_SIZE_INITIAL; /* Size till ftab_entries */
149  if (avctx->extradata_size < box_size)
150  return -1;
151 
152  // Display Flags
153  tx3g_ptr += 4;
154  // Alignment
155  h_align = *tx3g_ptr++;
156  v_align = *tx3g_ptr++;
157  if (h_align == 0) {
158  if (v_align == 0)
159  m->d.alignment = TOP_LEFT;
160  if (v_align == 1)
161  m->d.alignment = MIDDLE_LEFT;
162  if (v_align == -1)
163  m->d.alignment = BOTTOM_LEFT;
164  }
165  if (h_align == 1) {
166  if (v_align == 0)
167  m->d.alignment = TOP_CENTER;
168  if (v_align == 1)
170  if (v_align == -1)
172  }
173  if (h_align == -1) {
174  if (v_align == 0)
175  m->d.alignment = TOP_RIGHT;
176  if (v_align == 1)
177  m->d.alignment = MIDDLE_RIGHT;
178  if (v_align == -1)
179  m->d.alignment = BOTTOM_RIGHT;
180  }
181  // Background Color
182  m->d.back_color = AV_RB24(tx3g_ptr);
183  tx3g_ptr += 4;
184  // BoxRecord
185  tx3g_ptr += 8;
186  // StyleRecord
187  tx3g_ptr += 4;
188  // fontID
189  style_fontID = AV_RB16(tx3g_ptr);
190  tx3g_ptr += 2;
191  // face-style-flags
192  s_default.style_flag = *tx3g_ptr++;
193  m->d.bold = s_default.style_flag & STYLE_FLAG_BOLD;
194  m->d.italic = s_default.style_flag & STYLE_FLAG_ITALIC;
195  m->d.underline = s_default.style_flag & STYLE_FLAG_UNDERLINE;
196  // fontsize
197  m->d.fontsize = *tx3g_ptr++;
198  // Primary color
199  m->d.color = AV_RB24(tx3g_ptr);
200  tx3g_ptr += 4;
201  // FontRecord
202  // FontRecord Size
203  tx3g_ptr += 4;
204  // ftab
205  tx3g_ptr += 4;
206 
207  m->ftab_entries = AV_RB16(tx3g_ptr);
208  tx3g_ptr += 2;
209 
210  for (i = 0; i < m->ftab_entries; i++) {
211 
212  box_size += 3;
213  if (avctx->extradata_size < box_size) {
215  m->ftab_entries = 0;
216  return -1;
217  }
218  m->ftab_temp = av_mallocz(sizeof(*m->ftab_temp));
219  if (!m->ftab_temp) {
221  return AVERROR(ENOMEM);
222  }
223  m->ftab_temp->fontID = AV_RB16(tx3g_ptr);
224  tx3g_ptr += 2;
225  font_length = *tx3g_ptr++;
226 
227  box_size = box_size + font_length;
228  if (avctx->extradata_size < box_size) {
230  m->ftab_entries = 0;
231  return -1;
232  }
233  m->ftab_temp->font = av_malloc(font_length + 1);
234  if (!m->ftab_temp->font) {
236  return AVERROR(ENOMEM);
237  }
238  memcpy(m->ftab_temp->font, tx3g_ptr, font_length);
239  m->ftab_temp->font[font_length] = '\0';
240  av_dynarray_add(&m->ftab, &m->count_f, m->ftab_temp);
241  if (!m->ftab) {
243  return AVERROR(ENOMEM);
244  }
245  m->ftab_temp = NULL;
246  tx3g_ptr = tx3g_ptr + font_length;
247  }
248  for (i = 0; i < m->ftab_entries; i++) {
249  if (style_fontID == m->ftab[i]->fontID)
250  m->d.font = m->ftab[i]->font;
251  }
252  return 0;
253 }
254 
255 static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
256 {
257  m->box_flags |= TWRP_BOX;
258  m->w.wrap_flag = *tsmb++;
259  return 0;
260 }
261 
262 static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
263 {
264  m->box_flags |= HLIT_BOX;
265  m->h.hlit_start = AV_RB16(tsmb);
266  tsmb += 2;
267  m->h.hlit_end = AV_RB16(tsmb);
268  tsmb += 2;
269  return 0;
270 }
271 
272 static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
273 {
274  m->box_flags |= HCLR_BOX;
275  memcpy(m->c.hlit_color, tsmb, 4);
276  tsmb += 4;
277  return 0;
278 }
279 
280 static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
281 {
282  int i;
283  int style_entries = AV_RB16(tsmb);
284  tsmb += 2;
285  // A single style record is of length 12 bytes.
286  if (m->tracksize + m->size_var + 2 + style_entries * 12 > avpkt->size)
287  return -1;
288 
289  m->style_entries = style_entries;
290 
291  m->box_flags |= STYL_BOX;
292  for(i = 0; i < m->style_entries; i++) {
293  m->s_temp = av_malloc(sizeof(*m->s_temp));
294  if (!m->s_temp) {
295  mov_text_cleanup(m);
296  return AVERROR(ENOMEM);
297  }
298  m->s_temp->style_start = AV_RB16(tsmb);
299  tsmb += 2;
300  m->s_temp->style_end = AV_RB16(tsmb);
301 
302  if ( m->s_temp->style_end < m->s_temp->style_start
303  || (m->count_s && m->s_temp->style_start < m->s[m->count_s - 1]->style_end)) {
304  av_freep(&m->s_temp);
305  mov_text_cleanup(m);
306  return AVERROR(ENOMEM);
307  }
308 
309  tsmb += 2;
310  m->s_temp->style_fontID = AV_RB16(tsmb);
311  tsmb += 2;
312  m->s_temp->style_flag = AV_RB8(tsmb);
313  tsmb++;
314  m->s_temp->fontsize = AV_RB8(tsmb);
315  av_dynarray_add(&m->s, &m->count_s, m->s_temp);
316  if(!m->s) {
317  mov_text_cleanup(m);
318  return AVERROR(ENOMEM);
319  }
320  tsmb++;
321  // text-color-rgba
322  tsmb += 4;
323  }
324  return 0;
325 }
326 
327 static const Box box_types[] = {
328  { MKBETAG('s','t','y','l'), 2, decode_styl },
329  { MKBETAG('h','l','i','t'), 4, decode_hlit },
330  { MKBETAG('h','c','l','r'), 4, decode_hclr },
331  { MKBETAG('t','w','r','p'), 1, decode_twrp }
332 };
333 
334 const static size_t box_count = FF_ARRAY_ELEMS(box_types);
335 
336 static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end,
337  MovTextContext *m)
338 {
339  int i = 0;
340  int j = 0;
341  int text_pos = 0;
342 
343  if (text < text_end && m->box_flags & TWRP_BOX) {
344  if (m->w.wrap_flag == 1) {
345  av_bprintf(buf, "{\\q1}"); /* End of line wrap */
346  } else {
347  av_bprintf(buf, "{\\q2}"); /* No wrap */
348  }
349  }
350 
351  while (text < text_end) {
352  if (m->box_flags & STYL_BOX) {
353  for (i = 0; i < m->style_entries; i++) {
354  if (m->s[i]->style_flag && text_pos == m->s[i]->style_end) {
355  av_bprintf(buf, "{\\r}");
356  }
357  }
358  for (i = 0; i < m->style_entries; i++) {
359  if (m->s[i]->style_flag && text_pos == m->s[i]->style_start) {
360  if (m->s[i]->style_flag & STYLE_FLAG_BOLD)
361  av_bprintf(buf, "{\\b1}");
362  if (m->s[i]->style_flag & STYLE_FLAG_ITALIC)
363  av_bprintf(buf, "{\\i1}");
364  if (m->s[i]->style_flag & STYLE_FLAG_UNDERLINE)
365  av_bprintf(buf, "{\\u1}");
366  av_bprintf(buf, "{\\fs%d}", m->s[i]->fontsize);
367  for (j = 0; j < m->ftab_entries; j++) {
368  if (m->s[i]->style_fontID == m->ftab[j]->fontID)
369  av_bprintf(buf, "{\\fn%s}", m->ftab[j]->font);
370  }
371  }
372  }
373  }
374  if (m->box_flags & HLIT_BOX) {
375  if (text_pos == m->h.hlit_start) {
376  /* If hclr box is present, set the secondary color to the color
377  * specified. Otherwise, set primary color to white and secondary
378  * color to black. These colors will come from TextSampleModifier
379  * boxes in future and inverse video technique for highlight will
380  * be implemented.
381  */
382  if (m->box_flags & HCLR_BOX) {
383  av_bprintf(buf, "{\\2c&H%02x%02x%02x&}", m->c.hlit_color[2],
384  m->c.hlit_color[1], m->c.hlit_color[0]);
385  } else {
386  av_bprintf(buf, "{\\1c&H000000&}{\\2c&HFFFFFF&}");
387  }
388  }
389  if (text_pos == m->h.hlit_end) {
390  if (m->box_flags & HCLR_BOX) {
391  av_bprintf(buf, "{\\2c&H000000&}");
392  } else {
393  av_bprintf(buf, "{\\1c&HFFFFFF&}{\\2c&H000000&}");
394  }
395  }
396  }
397 
398  switch (*text) {
399  case '\r':
400  break;
401  case '\n':
402  av_bprintf(buf, "\\N");
403  break;
404  default:
405  av_bprint_chars(buf, *text, 1);
406  break;
407  }
408  text++;
409  text_pos++;
410  }
411 
412  return 0;
413 }
414 
415 static int mov_text_init(AVCodecContext *avctx) {
416  /*
417  * TODO: Handle the default text style.
418  * NB: Most players ignore styles completely, with the result that
419  * it's very common to find files where the default style is broken
420  * and respecting it results in a worse experience than ignoring it.
421  */
422  int ret;
423  MovTextContext *m = avctx->priv_data;
424  ret = mov_text_tx3g(avctx, m);
425  if (ret == 0) {
426  return ff_ass_subtitle_header(avctx, m->d.font, m->d.fontsize, m->d.color,
427  m->d.back_color, m->d.bold, m->d.italic,
428  m->d.underline, m->d.alignment);
429  } else
430  return ff_ass_subtitle_header_default(avctx);
431 }
432 
434  void *data, int *got_sub_ptr, AVPacket *avpkt)
435 {
436  AVSubtitle *sub = data;
437  MovTextContext *m = avctx->priv_data;
438  int ret, ts_start, ts_end;
439  AVBPrint buf;
440  char *ptr = avpkt->data;
441  char *end;
442  int text_length, tsmb_type, ret_tsmb;
443  uint64_t tsmb_size;
444  const uint8_t *tsmb;
445 
446  if (!ptr || avpkt->size < 2)
447  return AVERROR_INVALIDDATA;
448 
449  /*
450  * A packet of size two with value zero is an empty subtitle
451  * used to mark the end of the previous non-empty subtitle.
452  * We can just drop them here as we have duration information
453  * already. If the value is non-zero, then it's technically a
454  * bad packet.
455  */
456  if (avpkt->size == 2)
457  return AV_RB16(ptr) == 0 ? 0 : AVERROR_INVALIDDATA;
458 
459  /*
460  * The first two bytes of the packet are the length of the text string
461  * In complex cases, there are style descriptors appended to the string
462  * so we can't just assume the packet size is the string size.
463  */
464  text_length = AV_RB16(ptr);
465  end = ptr + FFMIN(2 + text_length, avpkt->size);
466  ptr += 2;
467 
468  ts_start = av_rescale_q(avpkt->pts,
469  avctx->time_base,
470  (AVRational){1,100});
471  ts_end = av_rescale_q(avpkt->pts + avpkt->duration,
472  avctx->time_base,
473  (AVRational){1,100});
474 
475  tsmb_size = 0;
476  m->tracksize = 2 + text_length;
477  m->style_entries = 0;
478  m->box_flags = 0;
479  m->count_s = 0;
480  // Note that the spec recommends lines be no longer than 2048 characters.
482  if (text_length + 2 != avpkt->size) {
483  while (m->tracksize + 8 <= avpkt->size) {
484  // A box is a minimum of 8 bytes.
485  tsmb = ptr + m->tracksize - 2;
486  tsmb_size = AV_RB32(tsmb);
487  tsmb += 4;
488  tsmb_type = AV_RB32(tsmb);
489  tsmb += 4;
490 
491  if (tsmb_size == 1) {
492  if (m->tracksize + 16 > avpkt->size)
493  break;
494  tsmb_size = AV_RB64(tsmb);
495  tsmb += 8;
496  m->size_var = 16;
497  } else
498  m->size_var = 8;
499  //size_var is equal to 8 or 16 depending on the size of box
500 
501  if (tsmb_size == 0) {
502  av_log(avctx, AV_LOG_ERROR, "tsmb_size is 0\n");
503  return AVERROR_INVALIDDATA;
504  }
505 
506  if (tsmb_size > avpkt->size - m->tracksize)
507  break;
508 
509  for (size_t i = 0; i < box_count; i++) {
510  if (tsmb_type == box_types[i].type) {
511  if (m->tracksize + m->size_var + box_types[i].base_size > avpkt->size)
512  break;
513  ret_tsmb = box_types[i].decode(tsmb, m, avpkt);
514  if (ret_tsmb == -1)
515  break;
516  }
517  }
518  m->tracksize = m->tracksize + tsmb_size;
519  }
520  text_to_ass(&buf, ptr, end, m);
521  mov_text_cleanup(m);
522  } else
523  text_to_ass(&buf, ptr, end, m);
524 
525  ret = ff_ass_add_rect_bprint(sub, &buf, ts_start, ts_end - ts_start);
526  av_bprint_finalize(&buf, NULL);
527  if (ret < 0)
528  return ret;
529  *got_sub_ptr = sub->num_rects > 0;
530  return avpkt->size;
531 }
532 
534 {
535  MovTextContext *m = avctx->priv_data;
537  return 0;
538 }
539 
541  .name = "mov_text",
542  .long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"),
543  .type = AVMEDIA_TYPE_SUBTITLE,
544  .id = AV_CODEC_ID_MOV_TEXT,
545  .priv_data_size = sizeof(MovTextContext),
546  .init = mov_text_init,
548  .close = mov_text_decode_close,
549 };
uint64_t tracksize
Definition: movtextdec.c:99
#define AV_RB8(x)
Definition: intreadwrite.h:395
#define NULL
Definition: coverity.c:32
#define BOTTOM_RIGHT
Definition: movtextdec.c:43
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:94
HighlightBox h
Definition: movtextdec.c:91
static const size_t box_count
Definition: movtextdec.c:334
#define TOP_LEFT
Definition: movtextdec.c:47
static int decode_twrp(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
Definition: movtextdec.c:255
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
int(* decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
Definition: movtextdec.c:107
memory handling functions
char * font
Definition: movtextdec.c:64
uint8_t wrap_flag
Definition: movtextdec.c:85
#define AV_RB64
Definition: intreadwrite.h:164
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
int size
Definition: avcodec.h:1434
uint16_t style_fontID
Definition: movtextdec.c:72
#define AV_RB24
Definition: intreadwrite.h:64
StyleBox * s_temp
Definition: movtextdec.c:90
unsigned num_rects
Definition: avcodec.h:3813
FontRecord * ftab_temp
Definition: movtextdec.c:94
uint8_t hlit_color[4]
Definition: movtextdec.c:81
AVCodec.
Definition: avcodec.h:3482
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
uint16_t style_entries
Definition: movtextdec.c:98
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1641
uint8_t
#define av_malloc(s)
#define AV_RB32
Definition: intreadwrite.h:130
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
int ff_ass_subtitle_header_default(AVCodecContext *avctx)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS with default style.
Definition: ass.c:80
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1627
static int mov_text_init(AVCodecContext *avctx)
Definition: movtextdec.c:415
static void mov_text_cleanup(MovTextContext *m)
Definition: movtextdec.c:110
uint8_t * data
Definition: avcodec.h:1433
#define STYL_BOX
Definition: movtextdec.c:36
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1451
#define av_log(a,...)
#define STYLE_FLAG_UNDERLINE
Definition: movtextdec.c:32
int ff_ass_subtitle_header(AVCodecContext *avctx, const char *font, int font_size, int color, int back_color, int bold, int italic, int underline, int alignment)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
Definition: ass.c:29
unsigned m
Definition: audioconvert.c:187
MovTextDefault d
Definition: movtextdec.c:96
uint16_t hlit_start
Definition: movtextdec.c:76
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:147
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
TextWrapBox w
Definition: movtextdec.c:95
#define AV_BPRINT_SIZE_UNLIMITED
uint8_t style_flag
Definition: movtextdec.c:70
#define AV_RB16
Definition: intreadwrite.h:53
#define AVERROR(e)
Definition: error.h:43
static const Box box_types[]
Definition: movtextdec.c:327
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:178
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
const char * name
Name of the codec implementation.
Definition: avcodec.h:3489
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Definition: mem.c:324
Libavcodec external API header.
#define TWRP_BOX
Definition: movtextdec.c:39
#define STYLE_FLAG_ITALIC
Definition: movtextdec.c:31
uint8_t box_flags
Definition: movtextdec.c:97
#define HLIT_BOX
Definition: movtextdec.c:37
#define FFMIN(a, b)
Definition: common.h:92
uint16_t hlit_end
Definition: movtextdec.c:77
uint32_t type
Definition: movtextdec.c:105
uint16_t style_start
Definition: movtextdec.c:68
#define FF_ARRAY_ELEMS(a)
static int decode_hlit(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
Definition: movtextdec.c:262
#define TOP_RIGHT
Definition: movtextdec.c:49
HilightcolorBox c
Definition: movtextdec.c:92
uint16_t ftab_entries
Definition: movtextdec.c:98
uint16_t style_end
Definition: movtextdec.c:69
int ff_ass_add_rect_bprint(AVSubtitle *sub, AVBPrint *buf, int ts_start, int duration)
Same as ff_ass_add_rect_bprint, but taking an AVBPrint buffer instead of a string, and assuming raw=0.
Definition: ass.c:178
main external API structure.
Definition: avcodec.h:1512
void * buf
Definition: avisynth_c.h:553
GLint GLenum type
Definition: opengl_enc.c:105
#define BOTTOM_CENTER
Definition: movtextdec.c:42
int extradata_size
Definition: avcodec.h:1628
size_t base_size
Definition: movtextdec.c:106
rational number numerator/denominator
Definition: rational.h:43
StyleBox ** s
Definition: movtextdec.c:89
#define BOX_SIZE_INITIAL
Definition: movtextdec.c:34
static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
Definition: movtextdec.c:272
#define STYLE_FLAG_BOLD
Definition: movtextdec.c:30
#define MIDDLE_CENTER
Definition: movtextdec.c:45
uint16_t fontID
Definition: movtextdec.c:63
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:521
#define BOTTOM_LEFT
Definition: movtextdec.c:41
common internal and external API header
static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
Definition: movtextdec.c:280
uint8_t fontsize
Definition: movtextdec.c:71
static int mov_text_decode_close(AVCodecContext *avctx)
Definition: movtextdec.c:533
AVCodec ff_movtext_decoder
Definition: movtextdec.c:540
#define MKBETAG(a, b, c, d)
Definition: common.h:342
void * priv_data
Definition: avcodec.h:1554
static void mov_text_cleanup_ftab(MovTextContext *m)
Definition: movtextdec.c:123
#define HCLR_BOX
Definition: movtextdec.c:38
#define av_freep(p)
#define MIDDLE_RIGHT
Definition: movtextdec.c:46
#define MIDDLE_LEFT
Definition: movtextdec.c:44
FontRecord ** ftab
Definition: movtextdec.c:93
#define TOP_CENTER
Definition: movtextdec.c:48
static int mov_text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
Definition: movtextdec.c:433
This structure stores compressed data.
Definition: avcodec.h:1410
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:252
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1426
static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
Definition: movtextdec.c:138
static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, MovTextContext *m)
Definition: movtextdec.c:336
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:140