[FFmpeg-devel] [PATCH] Clip-Wrapped MXF support (attempt #4)

Tomas Härdin tomas.hardin
Fri Feb 11 13:29:46 CET 2011


Maksym Veremeyenko skrev 2011-01-30 14:37:
> Maksym Veremeyenko ???????(??):
>> Baptiste Coudurier ???????(??):
> [...]
>>>> are there any objection against committing?
>>>
>>> Why do you keep reposting patches and ignoring comments ?
>>>
>> sorry...
>>
>> updated #0005 against /with useless cast/
>> updated #0006 against /...use this value when the edit unit is 1.../
>
> updated patches (against replace of *dprintf* with *av_dlog*) attached
>
>
> From ee5482e84f2eab0cfb74e82bfdd469af7daa53b1 Mon Sep 17 00:00:00 2001
> From: Maksym Veremeyenko <verem at m1stereo.tv>
> Date: Tue, 25 Jan 2011 13:28:51 +0200
> Subject: [PATCH 7/7] Clip wrapped code
>
> ---
>  libavformat/mxfdec.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 56 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index ce86525..13f6a35 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -145,6 +145,9 @@ typedef struct {
>      struct AVAES *aesc;
>      uint8_t *local_tags;
>      int local_tags_count;
> +    KLVPacket current_klv_data;
> +    int current_klv_index;
> +    int current_klv_bsize;
>  } MXFContext;
>
>  typedef int MXFMetadataReadFunc(void *arg, ByteIOContext *pb, int tag, int size, UID uid);
> @@ -318,8 +321,26 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
>  static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
>      KLVPacket klv;
> +    int index;
> +    MXFContext* mxf = s->priv_data;
>
>      while (!url_feof(s->pb)) {
> +        if (mxf->current_klv_data.length) {
> +            /* store */
> +            klv = mxf->current_klv_data;
> +            index = mxf->current_klv_index;
> +
> +            /* setup length */
> +            klv.length = FFMIN(mxf->current_klv_bsize, mxf->current_klv_data.length);

After poking around quite a bit with clip wrapped files for the last few 
days I've found that this code is wrong. It'll output garbage when 
EditUnitByteCount is larger than the remaining data in the essence 
element. You have to make sure that klv.length is a multiple of 
EditUnitByteCount (for audio) after FFMIN():ing, or set 
mxf->current_klv_data.length = 0 if it isn't.

I have an AVC-Inntra 50 sample where EditUnitByteCount = 140288 but the 
essence element is 105250816 bytes large. The result is an extra 34816 B 
packet of garbage.

/Tomas



More information about the ffmpeg-devel mailing list