1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-07-25 21:51:29 +02:00
Commit Graph

47 Commits

Author SHA1 Message Date
Andreas Rheinhardt
5ad436fcb9 avcodec/ass_split: Rename ff_ass_split_dialog2->ff_ass_split_dialog
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 00:13:57 +02: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
Andreas Rheinhardt
2a4cedace4 avcodec/movtextenc, srtenc, webvttenc: Mark encoders as init-threadsafe
They all rely on ff_ass_split(), which does not have any static state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-05-02 05:14:42 +02:00
Andreas Rheinhardt
a247ac640d avcodec: Constify AVCodecs
Given that the AVCodec.next pointer has now been removed, most of the
AVCodecs are not modified at all any more and can therefore be made
const (as this patch does); the only exceptions are the very few codecs
for external libraries that have a init_static_data callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:15 -03:00
Andreas Rheinhardt
6c497ac93b avcodec/(movtext|srt|ttml|webvtt)enc: Reindent after previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:04 -03:00
Andreas Rheinhardt
1f63665ca5 avcodec: Remove deprecated ASS with inline timing
Deprecated in 22ebbda637.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:04 -03:00
Andreas Rheinhardt
1c9e53d70b avcodec/movtextenc: Check for too many styles
The counter for the number of styles is written on two bytes, ergo
anything > UINT16_MAX is invalid. This also fixes a compiler warning
because of a tautologically true check on 64bit systems.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-24 07:50:39 +01:00
Andreas Rheinhardt
2134667227 avcodec/movtextenc: Cleanup generically on init failure
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:45:22 +02:00
Andreas Rheinhardt
eab812d6d6 avcodec/movtextenc: Remove redundant function parameters
It makes no sense to call the functions to write styl, hlit or hclr boxes
with a different box name than "styl", "hlit" or "hclr". Therefore this
commit inlines these values in the functions, removes the function
parameter containing the box's name and removes the (non obsolete) box
names from the list of boxes.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:42:55 +02:00
Andreas Rheinhardt
82c636313d avcodec/movtextenc: Simplify writing to AVBPrint
The mov_text encoder uses an AVBPrint to assemble the subtitles;
yet mov_text subtitles are not pure text; they also have a binary
portion that was mostly handled as follows:

    uint32_t size = /* calculation */;
    size = AV_RB32(&size);
    av_bprint_append_data(bprint, (const char*)&size, 4);

Here AV_RB32() is a no-op on big-endian systems and a LE-BE swap
on little-endian systems, making the output endian-independent.

Yet this is ugly and unclean: On LE systems, the variable size from
the snippet above won't contain the correct value any more. Furthermore,
using this pattern leads to lots of small writes to the AVBPrint.

This commit therefore changes this to using a temporary buffer instead:

    uint8_t buf[4];
    AV_WB32(buf, /* size calculation */);
    av_bprint_append_data(bprint, buf, 4);

This method also allows to use bigger buffers holding more than one
element, saving calls to av_bprint_append_data() and reducing codesize.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:41:46 +02:00
Andreas Rheinhardt
2f9fc35028 avcodec/movtextenc: Fix undefined left shifts outside the range of int
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:40:28 +02:00
Andreas Rheinhardt
9a731e9fec avcodec/movtextenc: Fix memleak on (re)allocation error
Up until now, the mov_text encoder used the dynamic array API for its
list of style attributes; it used the (horrible) av_dynarray_add() which
works with an array of pointers; on error it frees its array but not
the buffers referenced by the pointers said array contains. It also
returns no error code, encouraging not to check for errors.

These properties imply that this function may only be used if the buffers
referenced by the list either need not be freed at all or if they are
freed by other means (i.e. if the list contains non-ownership pointers).

In this case, the style attributes are owned by the pointers of the
dynamic list. Ergo the old style attributes leak on a subsequent
reallocation failure. But given that the (re)allocation isn't checked
for success, the style attribute intended to be added to the list also
leaks because the only pointer to it gets overwritten in the belief that
it is now owned by the list.

This commit fixes this by switching to av_fast_realloc() and an array
containing the styles directly instead of pointers to individually
allocated style attributes. The current style attributes are now no longer
individually allocated, instead they are part of the context.

Furthermore, av_fast_realloc() allows to easily distinguish between
valid and allocated elements, thereby allowing to reuse the array
(which up until now has always been freed after processing an
AVSubtitleRect).

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:37:42 +02:00
Andreas Rheinhardt
0dd7b8232d avcodec/movtextenc: Don't presume every style to have a font
Fixes segfaults in the absence of fonts; this can happen because the
file didn't contain any or because the allocation of the font-string
failed.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:37:15 +02:00
Andreas Rheinhardt
8d4431955c avcodec/movtextenc: Reset array counter after freeing array
Otherwise the mov_text encoder can segfault when given subtitles with more
than one AVSubtitleRect if one of the first nb_rects - 1 rects contained
a style attribute.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:36:57 +02:00
Andreas Rheinhardt
56b3726ed2 avcodec/movtextenc: Fix potential use of uninitialized value
Background colour was never initialized if no style was available.
Use a sane default of zero (i.e. completely transparent).

Fixes Coverity issue #1461471.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-19 21:36:17 +02:00
Andriy Gelman
2b5e18a953 avcodec/movtextenc: cosmetics
Change pointer position.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-10-15 22:30:13 -04:00
Andriy Gelman
d4c46dc328 avcodec/movtextenc: fix writing to bytestream on BE arches
Fixes fate-binsub-movtextenc on PPC64

Currently tags are written in reverse order on BE arches. This is fixed
by using MKBETAG() and AV_RB32() to be arch agnostics.

Also s->font_count is of type int. On BE arches with 32bit int,
count = AV_RB16(&s->font_count) will read two most significant bytes
instead of the least significant bytes. This is fixed by assigning
s->font_count to count first.

The final change is modifying the type of len. On BE arches
the most significant byte of the int was written instead of the least
significant byte.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-10-15 22:27:37 -04:00
John Stebbins
1d544e410e lavc/movtextenc: return more meaningful error codes
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 15:58:04 -07:00
John Stebbins
ad3f6212ac lavc/movtextenc: handle changes to hilight alpha
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
eeef870851 lavc/movtextenc: add option to scale fontsize with height
If the video dimensions are different than the ASS play_res then the
font sizes need to be adjusted to get the same apparent render size.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
1f8278ee24 lavc/movtextenc: add font name handling
Initializes the mov text sample description from the ASS header and
creates an mov font table from the fonts available in the ASS Styles.

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
dbdbcbf384 lavc/movtextenc: simplify initialization of new style record
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
bb8fd04665 lavc/movtextenc: handle cancel overrides callback
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
848792be60 lavc/movtextenc: add font size tag handling
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
2e79843e37 lavc/movtextenc: add alpha tag handling
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
b847bd9582 lavc/movtextenc: add color tag handling
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
37ab5e2e7b lavc/movtextenc: init style record from ASS dialog style
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
a129cc9e29 lavc/movtextenc: fix unclosed style records
The last record at the end of each dialog was never closed

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
1bf0df4c4f lavc/movtextenc: simplify style record updates
Makes style update code easier to extend for style types not yet handled

Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
15b81f5e6b lavc/movtextenc: keep values in native byte order till written
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
John Stebbins
32cf264d8f lavc/movtextenc: use correct color component order
Signed-off-by: Philip Langdale <philipl@overt.org>
2020-04-10 09:32:13 -07:00
Philip Langdale
af043b839c movtextenc: fix handling of utf-8 subtitles
See the earlier fix for movtextdec for details. The equivalent bug is
present on the encoder side as well.

We need to track the text length in 'characters' (which seems to really
mean codepoints) to ensure that styles are applied across the correct
ranges.
2018-03-29 20:46:47 -07:00
Philip Langdale
f95c81ce10 avcodec/movtextenc: Ignore unmatched closing style tags
The existing code will segfault if a closing tag shows up when there
was never an opening tag. This isn't a well formed style, but it's also
not a reason to crash.

Fixes: https://trac.ffmpeg.org/ticket/6303
2017-04-23 10:46:11 -07:00
Clément Bœsch
b5451d88cf lavc: reindent a few decoders after previous commits 2016-02-26 22:15:20 +01:00
Clément Bœsch
22ebbda637 lavc: deprecate decoded ass subtitles with timings 2016-02-26 21:53:34 +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
Michael Niedermayer
29d147c94d Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'
* commit '059a934806d61f7af9ab3fd9f74994b838ea5eba':
  lavc: Consistently prefix input buffer defines

Conflicts:
	doc/examples/decoding_encoding.c
	libavcodec/4xm.c
	libavcodec/aac_adtstoasc_bsf.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.h
	libavcodec/asvenc.c
	libavcodec/avcodec.h
	libavcodec/avpacket.c
	libavcodec/dvdec.c
	libavcodec/ffv1enc.c
	libavcodec/g2meet.c
	libavcodec/gif.c
	libavcodec/h264.c
	libavcodec/h264_mp4toannexb_bsf.c
	libavcodec/huffyuvdec.c
	libavcodec/huffyuvenc.c
	libavcodec/jpeglsenc.c
	libavcodec/libxvid.c
	libavcodec/mdec.c
	libavcodec/motionpixels.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/noise_bsf.c
	libavcodec/nuv.c
	libavcodec/nvenc.c
	libavcodec/options.c
	libavcodec/parser.c
	libavcodec/pngenc.c
	libavcodec/proresenc_kostya.c
	libavcodec/qsvdec.c
	libavcodec/svq1enc.c
	libavcodec/tiffenc.c
	libavcodec/truemotion2.c
	libavcodec/utils.c
	libavcodec/utvideoenc.c
	libavcodec/vc1dec.c
	libavcodec/wmalosslessdec.c
	libavformat/adxdec.c
	libavformat/aiffdec.c
	libavformat/apc.c
	libavformat/apetag.c
	libavformat/avidec.c
	libavformat/bink.c
	libavformat/cafdec.c
	libavformat/flvdec.c
	libavformat/id3v2.c
	libavformat/isom.c
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/mpc.c
	libavformat/mpc8.c
	libavformat/mpegts.c
	libavformat/mvi.c
	libavformat/mxfdec.c
	libavformat/mxg.c
	libavformat/nutdec.c
	libavformat/oggdec.c
	libavformat/oggparsecelt.c
	libavformat/oggparseflac.c
	libavformat/oggparseopus.c
	libavformat/oggparsespeex.c
	libavformat/omadec.c
	libavformat/rawdec.c
	libavformat/riffdec.c
	libavformat/rl2.c
	libavformat/rmdec.c
	libavformat/rtpdec_latm.c
	libavformat/rtpdec_mpeg4.c
	libavformat/rtpdec_qdm2.c
	libavformat/rtpdec_svq3.c
	libavformat/sierravmd.c
	libavformat/smacker.c
	libavformat/smush.c
	libavformat/spdifenc.c
	libavformat/takdec.c
	libavformat/tta.c
	libavformat/utils.c
	libavformat/vqf.c
	libavformat/westwood_vqa.c
	libavformat/xmv.c
	libavformat/xwma.c
	libavformat/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 23:15:19 +02:00
Niklesh
d373b508b5 movtextenc.c: Add support for text highlighting
This patch takes care of the secondary color changes in ASS through highlight and hilightcolor boxes.

Signed-off-by: Niklesh <niklesh.lalwani@iitb.ac.in>
2015-07-21 20:13:40 -07:00
Niklesh
93e80a343b movtextenc.c: Reorganize the code for easier maintenance
This patch reorganizes the code to make it easier to add support for different text modifier boxes and other styles in the future.

Signed-off-by: Niklesh <niklesh.lalwani@iitb.ac.in>
2015-07-21 20:13:40 -07:00
Niklesh
cf9051deac movtextenc.c: Support for Bold, Italic and Underlined Styles
Signed-off-by: Niklesh <niklesh.lalwani@iitb.ac.in>
2015-06-27 09:28:34 -07:00
Reimar Döffinger
d9e2aceb7f Add missing "const" all over the place.
Only "./configure --enable-gpl" on x86 was tested.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-08-29 18:57:25 +02:00
Michael Niedermayer
5441eb460c avcodec/movtextenc: allocate padding for extradata
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-18 15:59:03 +02:00
Michael Niedermayer
b0635e2fcf movtextenc: fix pointer messup and out of array accesses
Fixes Ticket2187

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-05 21:54:02 +01:00
Michael Niedermayer
91af76099e Merge commit '23aae62c2cb4504a09ceb8cd0cabc1c8b260f521'
* commit '23aae62c2cb4504a09ceb8cd0cabc1c8b260f521':
  alsdec: Check k used for rice decoder.
  avfiltergraph: silence an uninitialized variable warning
  xsubenc: reindent
  lavc: replace AVCodecContext.encode with subtitle-specific callback
  lavc: add const to private codec class initialization.
  avconv: don't pass a bogus parameter to avfilter_graph_create_filter().
  id3v2: strdup the genre name explicitly.
  lavf/id3v2: do not export empty fields.
  buffersrc: add const to the AVFrame* argument of av_buffersrc_write_frame()
  lavfi: replace empty input/output lists with null pointers

Conflicts:
	ffmpeg_filter.c
	libavcodec/alsdec.c
	libavcodec/dvdsubenc.c
	libavcodec/utils.c
	libavcodec/v210dec.h
	libavfilter/af_channelsplit.c
	libavfilter/avfiltergraph.c
	libavfilter/buffersrc.c
	libavfilter/src_movie.c
	libavfilter/vf_ass.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-18 14:45:44 +02:00
Michael Niedermayer
7a72695c05 Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
* commit '36ef5369ee9b336febc2c270f8718cec4476cb85':
  Replace all CODEC_ID_* with AV_CODEC_ID_*
  lavc: add AV prefix to codec ids.

Conflicts:
	doc/APIchanges
	doc/examples/decoding_encoding.c
	doc/examples/muxing.c
	ffmpeg.c
	ffprobe.c
	ffserver.c
	libavcodec/8svx.c
	libavcodec/avcodec.h
	libavcodec/dnxhd_parser.c
	libavcodec/dvdsubdec.c
	libavcodec/error_resilience.c
	libavcodec/h263dec.c
	libavcodec/libvorbisenc.c
	libavcodec/mjpeg_parser.c
	libavcodec/mjpegenc.c
	libavcodec/mpeg12.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pcm.c
	libavcodec/r210dec.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/version.h
	libavdevice/alsa-audio-dec.c
	libavdevice/bktr.c
	libavdevice/v4l2.c
	libavformat/asfdec.c
	libavformat/asfenc.c
	libavformat/avformat.h
	libavformat/avidec.c
	libavformat/caf.c
	libavformat/electronicarts.c
	libavformat/flacdec.c
	libavformat/flvdec.c
	libavformat/flvenc.c
	libavformat/framecrcenc.c
	libavformat/img2.c
	libavformat/img2dec.c
	libavformat/img2enc.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/matroska.c
	libavformat/matroskadec.c
	libavformat/matroskaenc.c
	libavformat/mov.c
	libavformat/movenc.c
	libavformat/mp3dec.c
	libavformat/mpeg.c
	libavformat/mpegts.c
	libavformat/mxf.c
	libavformat/mxfdec.c
	libavformat/mxfenc.c
	libavformat/nsvdec.c
	libavformat/nut.c
	libavformat/oggenc.c
	libavformat/pmpdec.c
	libavformat/rawdec.c
	libavformat/rawenc.c
	libavformat/riff.c
	libavformat/sdp.c
	libavformat/utils.c
	libavformat/vocenc.c
	libavformat/wtv.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-07 22:45:46 +02:00
Philip Langdale
82de3e16a8 movtextenc: Remove dangling reference to movtext.h
This is a reference that leaked in from my future work to
support styling.

Signed-off-by: Philip Langdale <philipl@overt.org>
2012-08-04 12:21:09 -07:00
Philip Langdale
2daaf77698 movtextenc: 3GPP TS 26.245 Timed Text Encoder.
This change introduces a basic encoder for 3GPP Timed Text subtitles,
also known as TX3G, Quicktime subtitles, or "movtext" in the existing
code.

This initial change doesn't attempt to write styling information,
and just writes the plain text of the subtitles. I intend to add
support for styles eventually, but it's challenging due to a lack
of existing players that support them.

Note that an additional change is required to the mov/mp4 muxer to
write empty subtitle packets to indicate subtitle duration.

Signed-off-by: Philip Langdale <philipl@overt.org>
2012-08-04 12:01:24 -07:00