[02/12] rtpenc_amr: Use s->num_frames instead of s->buf_ptr - s->buf

Message ID 1425034865-28812-2-git-send-email-martin@martin.st
State Committed
Commit 12b3459979f5ea6481660cd2c99a0381e2b5ba37
Headers show

Commit Message

Martin Storsjö Feb. 27, 2015, 11 a.m.
This doesn't fix any bug, but makes the code simpler for later
patches, and more straightforward to read as is.
---
 libavformat/rtpenc_amr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luca Barbato Feb. 27, 2015, 8:11 p.m. | #1
On 27/02/15 12:00, Martin Storsjö wrote:
> This doesn't fix any bug, but makes the code simpler for later
> patches, and more straightforward to read as is.
> ---
>  libavformat/rtpenc_amr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/rtpenc_amr.c b/libavformat/rtpenc_amr.c
> index 73da8c8..9f4f21a 100644
> --- a/libavformat/rtpenc_amr.c
> +++ b/libavformat/rtpenc_amr.c
> @@ -36,7 +36,7 @@ void ff_rtp_send_amr(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 == s->max_frames_per_packet || (len && len + size - 1 > s->max_payload_size)) {
> +    if (s->num_frames == s->max_frames_per_packet || (s->num_frames && len + size - 1 > s->max_payload_size)) {
>          int header_size = s->num_frames + 1;
>          p = s->buf + max_header_toc_size - header_size;
>          if (p != s->buf)
> 

Ok.

Patch

diff --git a/libavformat/rtpenc_amr.c b/libavformat/rtpenc_amr.c
index 73da8c8..9f4f21a 100644
--- a/libavformat/rtpenc_amr.c
+++ b/libavformat/rtpenc_amr.c
@@ -36,7 +36,7 @@  void ff_rtp_send_amr(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 == s->max_frames_per_packet || (len && len + size - 1 > s->max_payload_size)) {
+    if (s->num_frames == s->max_frames_per_packet || (s->num_frames && len + size - 1 > s->max_payload_size)) {
         int header_size = s->num_frames + 1;
         p = s->buf + max_header_toc_size - header_size;
         if (p != s->buf)