Re: mplex drops last access unit / frame from input video stream

Bernhard Praschinger <[email protected]> Sun, 10 Aug 2014 10:39:59 +0200
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <[email protected]>
Hallo


> I posted this to mjpeg-users yesterday but it shows a blank message in
> the archives?
I find in the archive just this mail from you, nothing in the 
mjpeg-developer in the pending requests, beside a few spammails. (I hope 
that nobody was in need for some cheap watches) I delete everything not 
related to the mjpegtools and zoran based cards. I don't remember any 
other mail from you.

> Anyways I did some more hacking on the source code and it
> seems like there is a condition where if the next AU causes an
> end-of-stream condition, it will not necessarily be pushed into the
> access unit buffer, (because eoscan is set to true) and subsequently
> gets left out of the output.
Thanks for noticing and the patch.

> The fix is to ensure it gets added in this case. It seems to do the
> right thing, but I will let you decide if this is the correct way to fix it.
I think Steven did add your patch into the CVS. So the patch is good and 
was accepted. The change will be in the next release.
Sp please check the cvs.
http://mjpeg.cvs.sourceforge.net/viewvc/mjpeg/mjpeg_play/

> -------------------------------
> diff -ru -U 10 mjpegtools-2.0.0/mplex/videostrm_in.cpp
> mjpegtools/mplex/videostrm_in.cpp
> --- mjpegtools-2.0.0/mplex/videostrm_in.cpp     2005-12-09 15:05:26 -0500
> +++ mjpegtools/mplex/videostrm_in.cpp   2014-08-08 11:25:25 -0400
> @@ -307,20 +307,43 @@
>                                  old_frames = decoding_order;
>                          }
>
>                          break;
>
>
>
>                  }
>          }
>
> +    // make sure the last AU gets added at the end of the stream
> +    if (bs.eos() && AU_pict_data)
> +    {
> +        stream_length = bs.bitcount();
> +        access_unit.start = AU_start;
> +        access_unit.length = static_cast<int>(stream_length - AU_start)>>3;
> +        access_unit.end_seq = 0;
> +        avg_frames[access_unit.type-1]+=access_unit.length;
> +
> +        mjpeg_debug( "LAST AU %d %d %d @ %lld: DTS=%ud",
> +                     decoding_order,
> +                     access_unit.type,
> +                     access_unit.length,
> +                     bs.bitcount() / 8-4,
> +                     static_cast<unsigned int>(access_unit.DTS/300) );
>
>
> +        aunits.Append( access_unit );
> +        decoding_order++;
> +        AU_hdr = syncword;
> +        AU_start = stream_length;
> +        AU_pict_data = 0;
> +    }
> +
>          last_buffered_AU = decoding_order;
>          num_pictures = decoding_order;
>          eoscan = bs.eos() || muxinto.AfterMaxPTS(access_unit.PTS);
>   }
>
>   void VideoStream::Close()
>   {
>       unsigned int comp_bit_rate ;
>       unsigned int peak_bit_rate  ;


auf hoffentlich bald,

Berni the Chaos of Woodquarter

Email: [email protected]
www: http://www.lysator.liu.se/~gz/bernhard

------------------------------------------------------------------------------