rtpenc_aac: Use AV_WB16 instead of manual bitshifts

This makes the code slightly more readable and understandable.

Signed-off-by: Martin Storsjö <martin@martin.st>
pull/117/head
Martin Storsjö 10 years ago
parent 9c9b0218e8
commit d16c8d28d4
  1. 14
      libavformat/rtpenc_aac.c

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "libavutil/intreadwrite.h"
#include "avformat.h" #include "avformat.h"
#include "rtpenc.h" #include "rtpenc.h"
@ -45,8 +47,7 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
memmove(p + 2, s->buf + 2, au_size); memmove(p + 2, s->buf + 2, au_size);
} }
/* Write the AU header size */ /* Write the AU header size */
p[0] = au_size >> 5; AV_WB16(p, au_size * 8);
p[1] = (au_size & 0x1F) << 3;
ff_rtp_send_data(s1, p, s->buf_ptr - p, 1); ff_rtp_send_data(s1, p, s->buf_ptr - p, 1);
@ -59,8 +60,7 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
if (size <= max_packet_size) { if (size <= max_packet_size) {
p = s->buf + s->num_frames++ * 2 + 2; p = s->buf + s->num_frames++ * 2 + 2;
*p++ = size >> 5; AV_WB16(p, size * 8);
*p = (size & 0x1F) << 3;
memcpy(s->buf_ptr, buff, size); memcpy(s->buf_ptr, buff, size);
s->buf_ptr += size; s->buf_ptr += size;
} else { } else {
@ -68,12 +68,10 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
max_packet_size = s->max_payload_size - 4; max_packet_size = s->max_payload_size - 4;
p = s->buf; p = s->buf;
p[0] = 0; AV_WB16(p, 2 * 8);
p[1] = 16;
while (size > 0) { while (size > 0) {
len = FFMIN(size, max_packet_size); len = FFMIN(size, max_packet_size);
p[2] = au_size >> 5; AV_WB16(&p[2], au_size * 8);
p[3] = (au_size & 0x1F) << 3;
memcpy(p + 4, buff, len); memcpy(p + 4, buff, len);
ff_rtp_send_data(s1, p, len + 4, len == size); ff_rtp_send_data(s1, p, len + 4, len == size);
size -= len; size -= len;

Loading…
Cancel
Save