[FFmpeg-devel] [PATCH v4] lavf/matroskadec: Normalize noncompliant A_QUICKTIME/V_QUICKTIME private data
Michael Niedermayer
michael at niedermayer.cc
Sun Jan 10 02:20:56 CET 2016
On Sat, Jan 09, 2016 at 12:02:19PM +0100, Mats Peterson wrote:
> Minor simplification of get_qt_codec(). Description follows:
>
> This patch adds a new static function get_qt_codec() that takes care
> of the initial retrieval of the fourcc and codec ID for A_QUICKTIME
> and V_QUICKTIME. It also normalizes noncompliant private data found
> in some older files that incorrectly starts with the fourcc by
> expanding/shifting the data by 4 bytes, and storing the data size at
> the start. This is necessary in order for the rest of the code in
> the A_QUICKTIME and V_QUICKTIME blocks (and most likely other code
> as well) to correctly parse the private data.
>
> Mats
>
> --
> Mats Peterson
> http://matsp888.no-ip.org/~mats/
> matroskadec.c | 47 ++++++++++++++++++++++++++++++++++-------------
> 1 file changed, 34 insertions(+), 13 deletions(-)
> 714309bb2cd9614cb58dfdaa5c05574d53386bb5 0001-lavf-matroskadec-Normalize-noncompliant-A_QUICKTIME-.patch
> From 9448cff9c5cdd1e301da8868c8e2e189ef34c760 Mon Sep 17 00:00:00 2001
> From: Mats Peterson <matsp888 at yahoo.com>
> Date: Sat, 9 Jan 2016 11:59:18 +0100
> Subject: [PATCH v4] lavf/matroskadec: Normalize noncompliant A_QUICKTIME/V_QUICKTIME private data
>
> Minor simplification of get_qt_codec(). Description follows:
>
> This patch adds a new static function get_qt_codec() that takes care of
> the initial retrieval of the fourcc and codec ID for A_QUICKTIME and
> V_QUICKTIME. It also normalizes noncompliant private data found in some
> older files that incorrectly starts with the fourcc by expanding/shifting
> the data by 4 bytes, and storing the data size at the start. This is
> necessary in order for the rest of the code in the A_QUICKTIME and
> V_QUICKTIME blocks (and most likely other code as well) to correctly
> parse the private data.
>
> Mats
>
> ---
> libavformat/matroskadec.c | 47 ++++++++++++++++++++++++++++++++-------------
> 1 file changed, 34 insertions(+), 13 deletions(-)
>
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index be4e300..71bf5e5 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1708,6 +1708,32 @@ static void mkv_stereo_mode_display_mul(int stereo_mode, int *h_width, int *h_he
> }
> }
>
> +static int get_qt_codec(MatroskaTrack *track, uint32_t *fourcc, enum AVCodecID *codec_id)
> +{
> + const AVCodecTag *codec_tags;
> +
> + codec_tags = track->type == MATROSKA_TRACK_TYPE_VIDEO ?
> + ff_codec_movvideo_tags : ff_codec_movaudio_tags;
> +
> + /* Normalize noncompliant private data that starts with the fourcc
> + * by expanding/shifting the data by 4 bytes and storing the data
> + * size at the start. */
> + if (ff_codec_get_id(codec_tags, AV_RL32(track->codec_priv.data))) {
> + if (!(track->codec_priv.data = av_realloc(track->codec_priv.data,
> + track->codec_priv.size + 4)))
> + return AVERROR(ENOMEM);
in case of this failing the memory is not freed and leaks
see av_reallocp() if you want it to be freed, alternatively the code
could continue without the move/update
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160110/1a57115f/attachment.sig>
More information about the ffmpeg-devel
mailing list