diff --git a/libavformat/rtpenc_aac.c b/libavformat/rtpenc_aac.c
index 0a74e27ca42af03b66288ed5ea576888c34a9631..7805ab9034dfceac2b520889d414ee0d8f5ad99b 100644
--- a/libavformat/rtpenc_aac.c
+++ b/libavformat/rtpenc_aac.c
@@ -39,7 +39,9 @@ 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 == s->max_frames_per_packet) || (s->num_frames && (len + size) > s->max_payload_size)) {
+    if (s->num_frames &&
+        (s->num_frames == s->max_frames_per_packet ||
+         (len + size) > s->max_payload_size)) {
         int au_size = s->num_frames * 2;
 
         p = s->buf + max_au_headers_size - au_size - 2;
diff --git a/libavformat/rtpenc_amr.c b/libavformat/rtpenc_amr.c
index 9f4f21a1dee8b81cceca47d4be2e174a9c71e9d6..6da5f0f17ac5f215d8d4774daa0b58bfd4b6aaee 100644
--- a/libavformat/rtpenc_amr.c
+++ b/libavformat/rtpenc_amr.c
@@ -36,7 +36,9 @@ 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 || (s->num_frames && len + size - 1 > s->max_payload_size)) {
+    if (s->num_frames &&
+        (s->num_frames == s->max_frames_per_packet ||
+         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)
diff --git a/libavformat/rtpenc_xiph.c b/libavformat/rtpenc_xiph.c
index 7d8883a353454f2b1470f4cc8ad4cc612f4e38c2..2167bdc99f17f34b19427b12cdf4c334643ef314 100644
--- a/libavformat/rtpenc_xiph.c
+++ b/libavformat/rtpenc_xiph.c
@@ -75,8 +75,9 @@ void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size)
         int remaining    = end_ptr - ptr;
 
         assert(s->num_frames <= s->max_frames_per_packet);
-        if ((s->num_frames > 0 && remaining < 0) ||
-            s->num_frames == s->max_frames_per_packet) {
+        if (s->num_frames > 0 &&
+            (remaining < 0 ||
+             s->num_frames == s->max_frames_per_packet)) {
             // send previous packets now; no room for new data
             ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
             s->num_frames = 0;