[01/12] rtpenc_aac: Fix sending fragmented frames

Message ID 1425034865-28812-1-git-send-email-martin@martin.st
State Committed
Commit 98563953442560dd83aab938f86de3e5a22a891f
Headers show

Commit Message

Martin Storsjö Feb. 27, 2015, 11 a.m.
After sending a fragmented frame, len (s->buf_ptr - s->buf) isn't
zero, while s->num_frames is zero as intended. Using s->num_frames
makes it work as intended, and is less convoluted than keeping track
of (resetting) s->buf_ptr.

This avoids sending stray data after sending a fragmented aac packet.

CC: libav-stable@libav.org
---
 libavformat/rtpenc_aac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luca Barbato Feb. 27, 2015, 3:02 p.m. | #1
On 27/02/15 12:00, Martin Storsjö wrote:
> After sending a fragmented frame, len (s->buf_ptr - s->buf) isn't
> zero, while s->num_frames is zero as intended. Using s->num_frames
> makes it work as intended, and is less convoluted than keeping track
> of (resetting) s->buf_ptr.
> 
> This avoids sending stray data after sending a fragmented aac packet.
> 
> CC: libav-stable@libav.org
> ---
>  libavformat/rtpenc_aac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/rtpenc_aac.c b/libavformat/rtpenc_aac.c
> index 1b2fa0a..8e39605 100644
> --- a/libavformat/rtpenc_aac.c
> +++ b/libavformat/rtpenc_aac.c
> @@ -39,7 +39,7 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
>  
>      /* test if the packet must be sent */
>      len = (s->buf_ptr - s->buf);
> -    if ((s->num_frames == max_frames_per_packet) || (len && (len + size) > s->max_payload_size)) {
> +    if ((s->num_frames == max_frames_per_packet) || (s->num_frames && (len + size) > s->max_payload_size)) {
>          int au_size = s->num_frames * 2;
>  
>          p = s->buf + max_au_headers_size - au_size - 2;
> 

Looks fine.
Luca Barbato Feb. 27, 2015, 5:33 p.m. | #2
On 27/02/15 12:00, Martin Storsjö wrote:


The whole set looks fine after a first quick look. I hope to read it
again tonight.

lu

Patch

diff --git a/libavformat/rtpenc_aac.c b/libavformat/rtpenc_aac.c
index 1b2fa0a..8e39605 100644
--- a/libavformat/rtpenc_aac.c
+++ b/libavformat/rtpenc_aac.c
@@ -39,7 +39,7 @@  void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
 
     /* test if the packet must be sent */
     len = (s->buf_ptr - s->buf);
-    if ((s->num_frames == max_frames_per_packet) || (len && (len + size) > s->max_payload_size)) {
+    if ((s->num_frames == max_frames_per_packet) || (s->num_frames && (len + size) > s->max_payload_size)) {
         int au_size = s->num_frames * 2;
 
         p = s->buf + max_au_headers_size - au_size - 2;