[FFmpeg-devel] [PATCH] lavf/matroskaenc: avoid assert failure in case of cuepoints with duplicated PTS

Michael Niedermayer michaelni at gmx.at
Tue Feb 19 00:15:07 CET 2013


On Tue, Feb 19, 2013 at 12:04:16AM +0100, Stefano Sabatini wrote:
> On date Monday 2013-02-18 03:42:15 +0100, Michael Niedermayer encoded:
> > On Sun, Feb 10, 2013 at 09:44:35PM +0100, Stefano Sabatini wrote:
> [...]
> > > -static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, int num_tracks)
> > > +static int mkv_write_cues(AVIOContext *pb, int64_t *currentpos_ptr, mkv_cues *cues, int num_tracks)
> > >  {
> > >      ebml_master cues_element;
> > >      int64_t currentpos;
> > > +    int *track_has_cue;
> > >      int i, j;
> > >  
> > > +    if (!(track_has_cue = av_malloc(sizeof(int)*num_tracks)))
> > > +        return AVERROR(ENOMEM);
> > 
> > isnt it sikmpler to use a field in mkv_track instead of a dynamically
> > allocated array
> > ?
> > would also avoid the return code changes
> 
> Yes, updated.
> -- 
> FFmpeg = Faithful & Fantastic Mysterious Pitiless Evil God

>  matroskaenc.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> c266d2177f3b92948ce592ba9b7e2cb35480d6b7  0001-lavf-matroskaenc-avoid-assert-failure-in-case-of-cue.patch
> From 1e8306d18d8885569b6dc0aabb7889e44d6aa106 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Sun, 10 Feb 2013 21:32:37 +0100
> Subject: [PATCH] lavf/matroskaenc: avoid assert failure in case of cuepoints
>  with duplicated PTS
> 
> Avoid to write more than one cuepoint per track and PTS in
> mkv_write_cues(). This avoids a later assertion failure on "(bytes >=
> needed_bytes)" in put_ebml_num() called from end_ebml_master(), in case
> there are several cuepoints per track with the same PTS.
> 
> This may happen with files containing packets with duplicated PTS in the
> same track.
> ---
>  libavformat/matroskaenc.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 5c1e2f1..b0a037a 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -72,6 +72,7 @@ typedef struct {
>  
>  typedef struct {
>      int             write_dts;
> +    int             num_cues;
>  } mkv_track;
>  
>  #define MODE_MATROSKAv2 0x01
> @@ -384,7 +385,7 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts, int64_t clus
>      return 0;
>  }
>  
> -static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, int num_tracks)
> +static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, mkv_track *tracks, int num_tracks)
>  {
>      ebml_master cues_element;
>      int64_t currentpos;
> @@ -404,6 +405,8 @@ static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, int num_tracks)
>          // put all the entries from different tracks that have the exact same
>          // timestamp into the same CuePoint
>          for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
> +            if (++tracks[entry[j].tracknum].num_cues > 1)
> +                continue;

if(x)
    continue
x=1

would avoid theoretical interger overflow
otherwise LGTM

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130219/12704819/attachment.asc>


More information about the ffmpeg-devel mailing list