[FFmpeg-devel] Inconsistent UDP output packet size - patch

Benoit Fouet benoit.fouet at free.fr
Tue Jul 22 15:45:47 CEST 2014


Hi,

> From a9d25569645e4031cd789ddbf696baaf6918f9dc Mon Sep 17 00:00:00 2001
> From: Konstantin Shpinev <mail at ksotik.com>
> Date: Tue, 22 Jul 2014 17:06:07 +0600
> Subject: [PATCH] fix flush_buffer in aviobuf.c to produce constant packet
>  size, see https://trac.ffmpeg.org/ticket/2748
> 
> ---
>  libavformat/aviobuf.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 738459e..38bf4e2 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -138,7 +138,7 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len)
>  
>  static void flush_buffer(AVIOContext *s)
>  {
> -    if (s->buf_ptr > s->buffer) {
> +    if (s->buf_ptr > s->buffer && (!s->max_packet_size || s->buf_ptr - s->buffer == s->max_packet_size)) {
>          writeout(s, s->buffer, s->buf_ptr - s->buffer);
>          if (s->update_checksum) {
>              s->checksum     = s->update_checksum(s->checksum, s->checksum_ptr,
> @@ -146,7 +146,9 @@ static void flush_buffer(AVIOContext *s)
>              s->checksum_ptr = s->buffer;
>          }
>      }
> -    s->buf_ptr = s->buffer;
> +    if (s->buf_ptr - s->buffer == 0 || !s->max_packet_size || s->buf_ptr - s->buffer == s->max_packet_size) {
> +        s->buf_ptr = s->buffer;
> +    }
> 

I think you can drop the first clause as it is a noop.

-- 
Ben


More information about the ffmpeg-devel mailing list