Commit Graph

65 Commits

Author SHA1 Message Date
Andreas Rheinhardt 35ec5c819b avformat/demux: Add new demux.h header
And move those stuff already in demuxer-only files to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:37:38 +02:00
Andreas Rheinhardt b10a8a30db avformat/oggparsevorbis: Avoid tmp bufs when parsing VorbisComment
A single VorbisComment consists of a length field and a
non-NUL-terminated string of the form "key=value". Up until now,
when parsing such a VorbisComment, zero-terminated duplicates of
key and value would be created. This is wasteful if these duplicates
are freed shortly afterwards, as happens in particular in case of
attached pictures: In this case value is base64 encoded and only
needed to decode the actual data.

Therefore this commit changes this: The buffer is temporarily modified
so that both key and value are zero-terminated. Then the data is used
in-place and restored to its original state afterwards.

This requires that the buffer has at least one byte of padding. All
buffers currently have AV_INPUT_BUFFER_PADDING_SIZE bytes padding,
so this is ok.

Finally, this also fixes weird behaviour from ogm_chapter():
It sometimes freed given to it, leaving the caller with dangling
pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-28 15:25:18 +02:00
Andreas Rheinhardt ef6a9e5e31 avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d91.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
Andreas Rheinhardt a46d781905 avcodec/packet: Also change av_packet_pack/unpack_dictionary to size_t
These are auxiliary side-data functions, so they should have been
switched to size_t in d79e0fe65c,
but this has been forgotten.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 03:12:24 +01:00
Lynne 9576e49b40
oggdec: remove the oggparsedaala subdemuxer
The Xiph foundation never standardized either Daala nor its mapping in Ogg,
and all files that were created are undecodable without knowledge of the
git hash.
2020-05-23 19:07:20 +01:00
Lynne 8296443a70
oggdec: add support for proper demuxing of chained Opus files and streams
Part of this patch is based on Paul B Mahol's patch from last year.

This also allows for single-stream parameter/codec changes.
2020-04-30 23:05:51 +01:00
Michael Niedermayer c5cc3b08e5 avformat/oggdec: Fix integer overflow with invalid pts
If negative pts are possible for some codecs in ogg then the code needs to be
changed to use signed values.

Found-by: Thomas Guilbert <tguilbert@google.com>
Fixes: clusterfuzz_usan-2016-08-02
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-03 16:09:03 +02:00
Rostislav Pehlivanov 0f87cbdd51 lavf: add oggparsedaala and bump micro
This commit introduces a parser for the current bitstream produced by
Daala. It currently bears a large similarity with Theora, another
codec produced by Xiph. While likely to change in the future, its basic
format of packet parsing should remain fairly identical with its current
structure.
Once the bitstream freezes, there are a few probable simplifications
that could be made. Also, the current version (major, minor and micro)
is stuck at zero so it's unusable as a way to warn about possible
incompatibilities. This will change once the bitstream freezes,
however until then this file is strictly targeting the current git
master of the reference encoder, libdaala.

This file was developed independently at the same time by both myself
and Vittorio Giovara, who used libav as a starting point. For fairness,
and to prevent confusion and allegations, his name has been added to the
copyright in the license header as well, and vice versa.
2015-10-21 06:02:47 +01:00
Michael Niedermayer a8db787932 Merge commit 'db68ef898a3802e51b6f41fd600d0d46d058e3f8'
* commit 'db68ef898a3802e51b6f41fd600d0d46d058e3f8':
  ogg: update event_flags with STREAM_/METADATA_UPDATED whenever metadata changes.

Conflicts:
	libavformat/oggparsevorbis.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-14 00:05:49 +02:00
Andrew Stone db68ef898a ogg: update event_flags with STREAM_/METADATA_UPDATED whenever metadata changes.
Originally, AVFormatContext and a metadata dict were provided to ff_vorbis_comment(),
but this presented issues if an AVStream was being updated or the metadata on
AVFormatContext wasn't actually being updated. To remedy this, ff_vorbis_stream_comment()
explicitly updates a stream's metadata and sets any necessary flags.

ff_vorbis_comment() does not modify any flags, and any calls to it that update
AVFormatContext's metadata (just a single call) must also update
AVFormatContext.event_flags after detecting any metadata changes to the provided
dictionary, as signaled by a positive return value.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-08-13 16:25:19 +00:00
Michael Niedermayer 579e2b2874 Merge commit '23f741f79327e31be7b2a75ebb2e02111e06e52f'
* commit '23f741f79327e31be7b2a75ebb2e02111e06e52f':
  matroskadec: parse the channel layout mask for FLAC

Conflicts:
	libavformat/oggparsevorbis.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 13:02:19 +02:00
Anton Khirnov 23f741f793 matroskadec: parse the channel layout mask for FLAC
It is commonly stored in a vorbiscomment block in codec private data.
2014-05-28 07:50:32 +02:00
Ben Boeckel 7eb84f2c3b ogg: allow streams to update metadata
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-05 22:36:42 +01:00
James Almer d890db5f53 oggdec: add support for VP8 demuxing
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-30 04:05:27 +01:00
Nicolas George ecab1c7741 oggdec: add support for Opus in Ogg demuxing 2013-10-12 15:25:18 +02:00
Vignesh Venkatasubramanian 23637f98f4 lavf/ogg: Support for end trimming Opus
Adding support for end trimming Opus embedded in Ogg container.

Signed-Off By: Vignesh Venkatasubramanian <vigneshv@google.com>

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-16 21:42:41 +02:00
Michael Niedermayer c5cf58d4b9 oggdec: resync from the last page.
Previously we re synced from where we where which cam lead
to loosing pages.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-15 20:19:28 +01:00
Michael Niedermayer 1700be5855 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  oggdec: make sure the private parse data is cleaned up

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-07 14:20:21 +01:00
Luca Barbato d894f74762 oggdec: make sure the private parse data is cleaned up 2013-01-06 17:59:54 +01:00
Michael Niedermayer d3ef2da59d oggdec: add missing () for OGG_NOGRANULE_VALUE
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-25 16:03:55 +02:00
Michael Niedermayer 0842e32f99 Merge commit 'd1f05dd18375f2f8e68372edee11436927e43ba8'
* commit 'd1f05dd18375f2f8e68372edee11436927e43ba8':
  ogg: calculate the start position once all the headers are parsed

Conflicts:
	libavformat/oggdec.c
	libavformat/oggparseskeleton.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-25 16:00:09 +02:00
Michael Niedermayer 46a35959d8 Merge commit '7751e4693dd10ec98c20fbd9887233b575034272'
* commit '7751e4693dd10ec98c20fbd9887233b575034272':
  ogg: check that the expected number of headers had been parsed
  libx264: change default to closed gop to match x264cli
  Use avcodec_free_frame() to free AVFrames.
  lavf: use a malloced AVFrame in try_decode_frame().
  lavc: add avcodec_free_frame().
  lavc: ensure extended_data is set properly on decoding
  lavc: initialize AVFrame.extended_data in avcodec_get_frame_defaults()
  lavc: use av_mallocz to allocate AVFrames.
  lavc: rename the argument of avcodec_alloc_frame/get_frame_defaults

Conflicts:
	doc/APIchanges
	doc/examples/decoding_encoding.c
	libavcodec/utils.c
	libavcodec/version.h
	libavfilter/src_movie.c
	libavformat/oggdec.c
	libavformat/oggdec.h
	libavformat/oggparsetheora.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-25 15:15:16 +02:00
Luca Barbato d1f05dd183 ogg: calculate the start position once all the headers are parsed
The fisbone packets can be muxed in any order as long the last one
comes before the first data packet.
2012-09-24 22:35:29 +02:00
Luca Barbato 7751e4693d ogg: check that the expected number of headers had been parsed
Not having the header for a codec is a tell-tale of a broken file.
2012-09-24 22:35:29 +02:00
Clément Bœsch ea5bd7ea6f lavf/oggdec: check for begin-of-stream flag in case of chained streams.
Fix Ticket #1617, revealing a regression I introduced in 8f3eebd.

We need to make sure no stream is added in between Ogg context save and
restore operations (because it would likely lead to a mismatch between
ogg->nstreams and AVFormatContext->nb_streams after the restore op).
This is the reason the ogg->state check is added in ogg_new_stream().
Before this patch, checking for ogg->headers was preventing this:
ogg->headers is always set before any ogg save/restore (though, it was
also preventing from creating the stream when necessary).
2012-09-22 00:40:51 +02:00
Nicolas George e62fd6619f oggdec: add support for Opus codec.
This patch also introduces CODEC_ID_OPUS.
2012-07-20 11:16:52 +02:00
Nicolas George 4ca59d1948 oggdec: add support for Xiph's CELT codec
This patch also introduces CODEC_ID_CELT.

Signed-off-by: Nicolas George <nicolas.george@normalesup.org>
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-09-26 13:51:29 +02:00
Michael Niedermayer d2cab951e3 oggdec: Make sure start time correction is applied once to each stream
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-08-24 23:13:57 +02:00
Michael Niedermayer f9ecb849ef Merge remote-tracking branch 'qatar/master'
* qatar/master:
  crypto: Use av_freep instead of av_free
  lavf: don't try to free private options if priv_data is NULL.
  swscale: fix types of assembly arguments.
  swscale: move two macros that are only used once into caller.
  swscale: remove unused function.
  options: Add missing braces around struct initializer.
  mov: Remove leftover crufty debug statement with references to a local file.
  dvbsubdec: Fix compilation of debug code.
  Remove all uses of now deprecated metadata functions.
  Move metadata API from lavf to lavu.

Conflicts:
	doc/APIchanges
	libavformat/aiffdec.c
	libavformat/asfdec.c
	libavformat/avformat.h
	libavformat/avidec.c
	libavformat/cafdec.c
	libavformat/matroskaenc.c
	libavformat/mov.c
	libavformat/mp3enc.c
	libavformat/wtv.c
	libavutil/avutil.h
	libavutil/internal.h
	libswscale/swscale.c
	libswscale/x86/swscale_template.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-06-09 04:47:19 +02:00
Anton Khirnov d2d67e424f Remove all uses of now deprecated metadata functions. 2011-06-08 07:43:45 +02:00
Nicolas George e61b83d29e Ogg: add support for Xiph's CELT (Opus) codec.
This patch also introduces CODEC_ID_CELT.

Signed-off-by: Nicolas George <nicolas.george@normalesup.org>
2011-04-19 15:49:32 +02:00
Clément Bœsch 8f3eebd663 oggdec: simplify audio chained ogg streams support
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2011-04-15 11:45:03 +02:00
Clément Bœsch 47dec30edb oggdec: fix demuxing chained audio streams
Chained ogg served by icecast and mpd should demux
properly now.

Fixes issue2337

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2011-04-10 04:33:15 +02:00
David Conrad 49c2d29089 oggdec: Remove write-only variable
Originally committed as revision 22889 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-04-16 12:21:29 +00:00
James Darnley 66061a1220 Add VorbisComment writing to FLAC files.
Patch by James Darnley <james darnley at gmail>.

Originally committed as revision 22605 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-20 13:36:43 +00:00
David Conrad 81b743eb10 oggdec: Pass packets to header() until the stream is done with them
This fixes some old ogm files that had the 3rd vorbis header after a data
packet in another stream. This is invalid in ogg, but this change shouldn't
affect the behaviour of any valid file.

Originally committed as revision 22478 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-12 05:17:01 +00:00
David Conrad 533c30fced Const correctness for vorbis_comment
Originally committed as revision 22474 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-12 05:16:47 +00:00
David Conrad b53cde48bd oggdec: Metadata is per-stream; don't merge multiple streams' together
Originally committed as revision 22473 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-12 05:16:44 +00:00
David Conrad e4d2d8c5d7 Add ff_ prefix to vorbis_comment
Originally committed as revision 22472 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-12 05:16:39 +00:00
David Conrad d8b91fae1d oggdec: Seek to keyframes
Originally committed as revision 22463 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 07:18:00 +00:00
David Conrad 32ad869284 oggdec: Parse skeleton to determine the start time of each stream
Originally committed as revision 22457 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 07:17:40 +00:00
David Conrad 296bdf9cf1 oggdec: Check that we have a codec in gptopts (needed for skeleton)
Originally committed as revision 22456 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 07:17:36 +00:00
David Conrad dfaed51f04 oggdec: Move ogg_find_stream and ogg_gptopts to oggdec.h
(skeleton will need them)

Originally committed as revision 22455 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 07:17:33 +00:00
David Conrad 73823cb941 oggdec: Save offset of the page needed to reconstruct the current packet
Originally committed as revision 22453 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 07:17:24 +00:00
David Conrad ecc0027bc6 Fix playback with invalid files that don't set the continuation flag for
pages that continue packets started in prior pages.
Fixes issue1248

Originally committed as revision 21688 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-08 10:13:03 +00:00
David Conrad 2d4970d88d oggdec: Set dts when known
Originally committed as revision 21134 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-01-11 05:51:09 +00:00
David Conrad 24ca518bd1 Add support for dirac in ogg
Originally committed as revision 21128 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-01-11 00:31:52 +00:00
David Conrad 5e15c7d95b Fix PTS for OGM codecs.
Fixes issue251

Originally committed as revision 20815 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-12-12 20:18:43 +00:00
Justin Ruggles 15299b3821 Calculate correct packet durations when demuxing Ogg/Speex. This involves
determining if there is any delay in the first packet and/or any truncation in
the final packet.

Originally committed as revision 20216 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-10-12 21:30:03 +00:00
Justin Ruggles d7bb185f99 Add a VorbisComment metadata conversion table and use it in the FLAC and
Ogg demuxers.

Originally committed as revision 19186 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-06-13 22:45:58 +00:00