Commit Graph

50 Commits

Author SHA1 Message Date
Oneric
57c545090d avocdec/ass: simplify linebreaks
ff_ass_subtitle_header_* still used explicit CRLF linebreaks
eventhough they will get normalised to LF later since commit
7bf1b9b357. Just directly use LF.
2024-04-06 09:26:30 +02:00
Oneric
0fc975c0d3 avcodec/ass,webvttdec: implement more portable curly brace escapes
Unlike what the old comment suggested, standard ASS has no character
escape mechanism, but a closing curly bracket doesn't even need one.

For manual authored sub files using a full-width variant of an
appropriate font and with scaling and spacing modifiers is a common
workaround.
This is not an option here, but we can still make things much less bad.
Now the desired opening bracket still shows up in libass, and
standard renders will merely display a backslash in its place
instead of stripping the following text like before.
2024-04-06 09:25:03 +02:00
Oneric
baa64fa4e6 avcodec/ass,webvttdec: fix handling of backslashes
Backslashes cannot be escaped by a backslash in any ASS renderer,
but unless followed by specific characters it is just printed out.
Insert a word-joiner character after a backslash to break up
active sequences without changing the visual output.
2024-04-06 09:24:47 +02:00
Andreas Rheinhardt
790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Oneric
b6f5a7ce0c avcodec/ass: specify a permissive encoding
The Encoding field (and the \fe tag) allows to limit font selection to
only those fonts declaring support for the specified codepage in their
OS/2's table "Code Page Character Range" field.
Particularly, Encoding=0 means only font's declaring support for "ANSI",
or rather "Latin (Western European)", are allowed to be selected.
Specifying Encoding=1 allows all fonts to be considered.
We do not want to limit font selection, so specify Encoding=1.

NB: at the time of writing libass only partially supports this field,
thus hiding the issue in any libass-based renderer. A VSFilter-based
DirectShow filter or XySubFilter will reveal the issue when a font not
declaring support for latin characters is specified in a style.
2022-12-03 19:08:44 +01:00
Oneric
95115fcc18 avcodec/ass: accurately preserve colours
Colour values used in ASS files without a "YCbCr Matrix" header set to
"None" are subject to colour mangling, due to how ASS was historically
conceived. A more in-depth description can be found in the documetation
inside libass' public ass_types.h header. The important part is, if this
header is not set to "None", the final output colours can deviate from
the literal value specified in the file. When converting from non-ASS
formats we do not want any colour shift to happen, so let's set the
appropiate header.

NB: ffmpeg's subtitle filter, does not follow libass' documentation
regarding colour mangling, thus hiding the bug. Anything based on
VSFilter, XySubFilter or e.g. mpv do and might show the issue.
(Of course native ASS subs, which _do_ rely on colour mangling won't
 work properly with the subtitle filter, but this can be fixed another
 time)
2022-12-03 19:08:39 +01:00
Oneric
d82e30d0d1 avcodec/ass: fix comment
There is no v4 ASS. There are versions 1 to 4 of SSA (with only v4
being supported by softsub renderers), ASS which declares itself as v4+
or v4.00+, and the rarely used v4++/v4.00++, which isn't fully supported
by libass.
As reflected by the [V4+ Styles] section header, FFmpeg uses ASS, not
SSA v4, so adjust the comment accordingly.
2022-12-03 19:08:39 +01:00
Carl Eugen Hoyos
4a054c3e97 lavc/ass: Add missing version.h include
Fixes lavc version output in ass, regression since f2da2e14
2022-08-31 16:25:31 +02:00
Michael Niedermayer
aed698efc3 avcodec/ass: Faster ff_ass_add_rect()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-18 19:56:50 +01:00
Andreas Rheinhardt
2adbb0c2af avcodec/ass: Fix leaks upon ff_ass_add_rect() error
Do this by actually incrementing the counter for the number
of rects at the right time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-16 02:37:26 +01:00
Andreas Rheinhardt
2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Oneric
e6dcb6a0db avcodec/ass: explicitly set ScaledBorderAndShadow
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-23 00:26:38 +02:00
John Stebbins
b8d4a66b29 lavc/movtextdec: allow setting subtitle frame dimensions
Font sizes are relative to the subtitle frame dimensions. If the
expected frame dimensions are not known, the font sizes will most
likely be incorrect.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
Limin Wang
f8f86f8356 avcodec/ass: remove the unneeded ()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-26 22:22:33 +01:00
Clément Bœsch
30e7685360 lavc/options: add ass_ro_flush_noop to flags2 2016-02-26 21:53:32 +01:00
Clément Bœsch
2941282124 lavc: allow subtitle text format to be ASS without timing 2016-02-26 21:49:34 +01:00
Clément Bœsch
6d32628bf3 lavc/ccaption_dec: improve default style
Use monospaced font, and a black box outline.
2016-01-10 16:28:14 +01:00
Michael Niedermayer
05af8608c2 avcodec/ass: check for av_mallocz() failure
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-22 14:41:27 +01:00
Michael Niedermayer
94d68a41fa Merge commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615'
* commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615':
  lavc: AV-prefix all codec flags

Conflicts:
	doc/examples/muxing.c
	ffmpeg.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/ac3enc_float.c
	libavcodec/atrac1.c
	libavcodec/atrac3.c
	libavcodec/atrac3plusdec.c
	libavcodec/dcadec.c
	libavcodec/ffv1enc.c
	libavcodec/h264.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_mb.c
	libavcodec/imc.c
	libavcodec/libmp3lame.c
	libavcodec/libtheoraenc.c
	libavcodec/libtwolame.c
	libavcodec/libvpxenc.c
	libavcodec/libxavs.c
	libavcodec/libxvid.c
	libavcodec/mpeg12dec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegaudiodec_template.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_motion.c
	libavcodec/nellymoserdec.c
	libavcodec/nellymoserenc.c
	libavcodec/nvenc.c
	libavcodec/on2avc.c
	libavcodec/options_table.h
	libavcodec/opus_celt.c
	libavcodec/pngenc.c
	libavcodec/ra288.c
	libavcodec/ratecontrol.c
	libavcodec/twinvq.c
	libavcodec/vc1_block.c
	libavcodec/vc1_loopfilter.c
	libavcodec/vc1_mc.c
	libavcodec/vc1dec.c
	libavcodec/vorbisdec.c
	libavcodec/vp3.c
	libavcodec/wma.c
	libavcodec/wmaprodec.c
	libavcodec/x86/hpeldsp_init.c
	libavcodec/x86/me_cmp_init.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:10:35 +02:00
Clément Bœsch
56bc0a6736 avcodec/ass: make default playback resolution available to decoders 2015-05-14 12:11:34 +02:00
Michael Niedermayer
727cb2bda9 avcodec/ass: Use av_realloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-09 20:33:53 +01:00
Clément Bœsch
c669af0f24 avcodec/ass: add ASS trailing \r\n in one single place 2014-10-19 23:24:34 +02:00
Clément Bœsch
3d25869605 avcodec/ass: assume raw=0 in ff_ass_add_rect_bprint 2014-10-19 23:24:34 +02:00
Clément Bœsch
52b0a0ecaa avcodec/ass: add FFmpeg signature 2014-10-15 19:25:06 +02:00
Clément Bœsch
40b9f28641 avcodec/ass: output missing fields in AVSubtitles and output files
Fixes Ticket #3207
2014-10-15 19:25:06 +02:00
Clément Bœsch
d210c0e777 avcodec/ass: add ff_ass_add_rect_bprint() helper 2014-09-21 18:41:45 +02:00
Clément Bœsch
88514378ba avcodec/ass: move playres parameters below scripttype
Suggested-by: wm4
2014-06-18 18:43:36 +02:00
Clément Bœsch
5039aadf68 avcodec/ass: explicit PlayRes[XY]
This avoids the following libass warning when using the subtitles
filter: "Neither PlayResX nor PlayResY defined. Assuming 384x288"

Subtitles tests change because the output is ASS and the PlayRes[XY]
ends up in the output.
2014-06-18 18:22:40 +02:00
Marton Balint
b96325e023 ass: move text_event_to_ass from textdec.c to ass.c and export it
Signed-off-by: Marton Balint <cus@passwd.hu>
2013-11-10 18:57:52 +01:00
Marton Balint
0f0a8d9859 ass: fix error handling in ff_ass_add_subrect
Signed-off-by: Marton Balint <cus@passwd.hu>
2013-11-10 18:57:51 +01:00
Marton Balint
f148954b0a ass: factor out ff_ass_bprint_dialog
Signed-off-by: Marton Balint <cus@passwd.hu>
2013-11-10 18:57:51 +01:00
Michael Niedermayer
04fa818779 Merge commit '088f38a4f9f54bb923405c67c9e72d96d90aa284'
* commit '088f38a4f9f54bb923405c67c9e72d96d90aa284':
  avcodec: Drop unnecessary ff_ name prefixes from static functions

Conflicts:
	libavcodec/ass.c
	libavcodec/h264_parser.c
	libavcodec/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-01 18:16:32 +02:00
Diego Biurrun
088f38a4f9 avcodec: Drop unnecessary ff_ name prefixes from static functions 2013-04-30 16:02:02 +02:00
Clément Bœsch
7c1a002c78 subtitles: introduce ASS codec id and use it.
Currently, we have a AV_CODEC_ID_SSA, which matches the way the ASS/SSA
markup is muxed in a standalone .ass/.ssa file. This means the AVPacket
data starts with a "Dialogue:" string, followed by a timing information
(start and end of the event as string) and a trailing CRLF after each
line. One packet can contain several lines. We'll refer to this layout
as "SSA" or "SSA lines".

In matroska, this markup is not stored as such: it has no "Dialogue:"
prefix, it contains a ReadOrder field, the timing information is not in
the payload, and it doesn't contain the trailing CRLF. See [1] for more
info. We'll refer to this layout as "ASS".

Since we have only one common codec for both formats, the matroska
demuxer is constructing an AVPacket following the "SSA lines" format.
This causes several problems, so it was decided to change this into
clean ASS packets.

Some insight about what is changed or unchanged in this commit:

  CODECS
  ------

  - the decoding process still writes "SSA lines" markup inside the ass
    fields of the subtitles rectangles (sub->rects[n]->ass), which is
    still the current common way of representing decoded subtitles
    markup. It is meant to change later.

  - new ASS codec id: AV_CODEC_ID_ASS (which is different from the
    legacy AV_CODEC_ID_SSA)

  - lavc/assdec: the "ass" decoder is renamed into "ssa" (instead of
    "ass") for consistency with the codec id and allows to add a real
    ass decoder. This ass decoder receives clean ASS lines (so it starts
    with a ReadOrder, is followed by the Layer, etc). We make sure this
    is decoded properly in a new ass-line rectangle of the decoded
    subtitles (the ssa decoder OTOH is doing a simple straightforward
    copy). Using the packet timing instead of data string makes sure the
    ass-line now contains the appropriate timing.

  - lavc/assenc: just like the ass decoder, the "ssa" encoder is renamed
    into "ssa" (instead of "ass") for consistency with the codec id, and
    allows to add a real "ass" encoder.

    One important thing about this encoder is that it only supports one
    ass rectangle: we could have put several dialogue events in the
    AVPacket (separated by a \0 for instance) but this would have cause
    trouble for the muxer which needs not only the start time, but also
    the duration: typically, you have merged events with the same start
    time (stored in the AVPacket->pts) but a different duration. At the
    moment, only the matroska do the merge with the SSA-line codec.

    We will need to make sure all the decoders in the future can't add
    more than one rectangle (and only one Dialogue line in it
    obviously).

  FORMATS
  -------

  - lavf/assenc: the .ass/.ssa muxer can take both SSA and ASS packets.
    In the case of ASS packets as input, it adds the timing based on the
    AVPacket pts and duration, and mux it with "Dialogue:", trailing
    CRLF, etc.

  - lavf/assdec: unchanged; it currently still only outputs SSA-lines
    packets.

  - lavf/mkv: the demuxer can now output ASS packets without the need of
    any "SSA-lines" reconstruction hack. It will become the default at
    next libavformat bump, and the SSA support will be dropped from the
    demuxer. The muxer can take ASS packets since it's muxed normally,
    and still supports the old SSA packets. All the SSA support and
    hacks in Matroska code will be dropped at next lavf bump.

[1]: http://www.matroska.org/technical/specs/subtitles/ssa.html
2013-04-18 23:23:59 +02:00
Clément Bœsch
1043cb8e80 lavc/ass: use bprint API in ff_ass_add_rect(). 2013-04-09 21:43:44 +02:00
Michael Niedermayer
9fea619f19 ass: assert that the timsstamps fitted in the buffers
Failure of the assert would cause various problems later
if we continue.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-09 14:19:02 +02:00
Michael Niedermayer
c581cb4e4f Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Fix even more missing includes after the common.h removal
  build: Factor out rangecoder dependencies to CONFIG_RANGECODER
  build: Factor out error resilience dependencies to CONFIG_ERROR_RESILIENCE
  x86: avcodec: Consistently name all init files
  Add more missing includes after removing the implicit common.h
  Add some more missing includes after removing the implicit common.h
  Don't include common.h from avutil.h
  rtmp: Automatically compute the hash for SWFVerification

Conflicts:
	configure
	doc/APIchanges
	doc/examples/decoding_encoding.c
	libavcodec/Makefile
	libavcodec/assdec.c
	libavcodec/audio_frame_queue.c
	libavcodec/avpacket.c
	libavcodec/dv_profile.c
	libavcodec/dwt.c
	libavcodec/libtheoraenc.c
	libavcodec/rawdec.c
	libavcodec/rv40dsp.c
	libavcodec/tiff.c
	libavcodec/tiffenc.c
	libavcodec/v210dec.h
	libavcodec/vc1dsp.c
	libavcodec/x86/Makefile
	libavfilter/asrc_anullsrc.c
	libavfilter/avfilter.c
	libavfilter/buffer.c
	libavfilter/formats.c
	libavfilter/vf_ass.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fade.c
	libavfilter/vf_select.c
	libavfilter/video.c
	libavfilter/vsrc_testsrc.c
	libavformat/version.h
	libavutil/audioconvert.c
	libavutil/error.h
	libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-16 16:20:30 +02:00
Martin Storsjö
1d9c2dc89a Don't include common.h from avutil.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-15 22:32:06 +03:00
Clément Bœsch
0e7782c08e lavc/ass: honor Default style.
The "Default" style written in the header is ignored unless you explicit
it in the Dialogue events (it was valid, just ignored). This requires an
update of the SubRip test since the ASS output obviously changes.
2012-06-29 20:20:02 +02:00
Lou Logan
6851130fd6 cosmetics: minor libavcodec spelling errors
Also update some common misspelled words in patcheck

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-29 14:54:15 +02:00
Clément Bœsch
d51e08bb89 lavc: switch from ts_end to duration in ff_ass_add_rect.
Make possible a end-to-presentation duration.
2012-05-29 21:33:28 +02:00
Clément Bœsch
7c0d30b57b ass: use av_asprintf() instead of a temporary stack buffer. 2012-01-30 23:28:26 +01:00
Michael Niedermayer
b000b86e1d Merge remote branch 'qatar/master'
* qatar/master: (23 commits)
  doc: Check standalone compilation before submitting new components.
  Fix standalone compilation of pipe protocol.
  Fix standalone compilation of ac3_fixed encoder.
  Fix standalone compilation of binkaudio_dct / binkaudio_rdft decoders.
  Fix standalone compilation of IMC decoder.
  Fix standalone compilation of WTV demuxer.
  Fix standalone compilation of MXPEG decoder.
  flashsv: K&R cosmetics
  matroskaenc: fix memory leak
  vc1: make overlap filter for I-frames bit-exact.
  vc1dec: use s->start/end_mb_y instead of passing them as function args.
  Revert "VC1: merge idct8x8, coeff adjustments and put_pixels."
  Replace strncpy() with av_strlcpy().
  indeo3: Eliminate use of long.
  get_bits: make cache unsigned to eliminate undefined signed overflow.
  asfdec: fix assert failure on invalid files
  avfilter: check malloc return values.
Not pulled as reason for reindent is not pulled:  mpegvideo: reindent.
  nutenc: check malloc return values.
Not pulled due to much simpler solution in ffmpeg  *: don't av_malloc(0).
  ...

Conflicts:
	doc/developer.texi
	libavcodec/Makefile
	libavcodec/get_bits.h
	libavcodec/mpegvideo.c
	libavformat/Makefile
	libavutil/log.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-05-05 03:30:24 +02:00
Alex Converse
1a5e4fd8c5 Replace strncpy() with av_strlcpy(). 2011-05-03 21:20:13 -07:00
Aurelien Jacobs
3ee8ca9b08 add avcodec_get_subtitle_defaults() to initialize AVSubtitle struct
Call this new function before decode() to replace the custom and
inconsistant initialization in various decoders.
This function is equivalent to avcodec_get_frame_defaults() for AVFrame.

Signed-off-by: Aurelien Jacobs <aurel@gnuage.org>
2011-04-11 23:27:50 +02:00
Mans Rullgard
2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Diego Elio Pettenò
cf1d794a49 Make ff_ass_subtitle_header static to ass.c
Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
2011-01-25 22:05:12 +01:00
Aurelien Jacobs
2c77c90684 add SubRip decoder
Originally committed as revision 26119 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-12-28 23:52:53 +00:00
Aurelien Jacobs
4ab4d65f35 ensure the ASS string in AVSubtitleRect is 0 terminated
Originally committed as revision 25832 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-11-27 01:07:06 +00:00
Aurelien Jacobs
5952be07dc add missing files in previous commit (ASS encoder and decoder)
Originally committed as revision 25747 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-11-13 14:18:59 +00:00