[FFmpeg-devel] [PATCH] libavformat/matroskadec.c, mov.c/qtpalette.c: Fix issue with, palettized QuickTime video in Matroska

Michael Niedermayer michael at niedermayer.cc
Mon Dec 21 22:57:39 CET 2015


On Mon, Dec 21, 2015 at 06:04:28PM +0100, Mats Peterson wrote:
> Alright then, let's see how this turns out:
> 
> ---
>  libavformat/Makefile      |    1 +
>  libavformat/matroskadec.c |   30 ++++++++++++-
>  libavformat/mov.c         |   95 ++++++++++-------------------------------
>  libavformat/qtpalette.c   |  102
> +++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/qtpalette.h   |    2 +
>  5 files changed, 155 insertions(+), 75 deletions(-)
>  create mode 100644 libavformat/qtpalette.c
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 110e9e3..e03c73e 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -18,6 +18,7 @@ OBJS = allformats.o         \
>         mux.o                \
>         options.o            \
>         os_support.o         \
> +       qtpalette.o          \
>         riff.o               \
>         sdp.o                \
>         url.o                \
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index c574749..f94f7fb 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -64,6 +64,8 @@
>  #include <zlib.h>
>  #endif
> 
> +#include "qtpalette.h"
> +
>  typedef enum {
>      EBML_NONE,
>      EBML_UINT,
> @@ -312,6 +314,9 @@ typedef struct MatroskaDemuxContext {
> 
>      /* WebM DASH Manifest live flag/ */
>      int is_live;
> +
> +    uint32_t palette[256];
> +    int has_palette;
>  } MatroskaDemuxContext;
> 
>  typedef struct MatroskaBlock {
> @@ -1856,7 +1861,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
>              fourcc           = st->codec->codec_tag;
>              extradata_offset = FFMIN(track->codec_priv.size, 18);
>          } else if (!strcmp(track->codec_id, "A_QUICKTIME")
> -                   && (track->codec_priv.size >= 86)
> +                   && (track->codec_priv.size >= 36)
>                     && (track->codec_priv.data)) {
>              fourcc = AV_RL32(track->codec_priv.data + 4);
>              codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
> @@ -1865,7 +1870,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
>                  codec_id = ff_codec_get_id(ff_codec_movaudio_tags,
> fourcc);
>              }
>          } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
> -                   (track->codec_priv.size >= 21)          &&
> +                   (track->codec_priv.size >= 86)          &&
>                     (track->codec_priv.data)) {
>              fourcc   = AV_RL32(track->codec_priv.data + 4);
>              codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
> @@ -1881,6 +1886,18 @@ static int matroska_parse_tracks(AVFormatContext *s)
>                  av_log(matroska->ctx, AV_LOG_ERROR,
>                         "mov FourCC not found %s.\n", buf);
>              }
> +            bit_depth = AV_RB16(track->codec_priv.data + 82);
> +            if (get_qtpalette(codec_id, track->codec_priv.data + 16,
> +                        matroska->palette)) {
> +                bit_depth &= 0x1F;
> +                /* Behave like V_MS/VFW/FOURCC; copy the palette to
> +                 * extradata */
> +                if (! (extradata = av_malloc(AVPALETTE_SIZE)))
> +                    return AVERROR(ENOMEM);
> +                memcpy(extradata, matroska->palette, AVPALETTE_SIZE);
> +                extradata_size = AVPALETTE_SIZE;
> +                matroska->has_palette = 1;
> +            }
>          } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
>              switch (track->audio.bitdepth) {
>              case  8:
> @@ -2326,6 +2343,15 @@ static int
> matroska_deliver_packet(MatroskaDemuxContext *matroska,

the patch is corrupted by newlines
attaching the patch uncompressed should solve this
disabling automatic line/word wraping in your editor instead might as
well

Applying: libavformat/matroskadec.c, mov.c/qtpalette.c: Fix issue with, palettized QuickTime video in Matroska
fatal: corrupt patch at line 57
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 libavformat/matroskadec.c, mov.c/qtpalette.c: Fix issue with, palettized QuickTime video in Matroska
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- 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/20151221/b7fb383f/attachment.sig>


More information about the ffmpeg-devel mailing list