You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
rtpenc: Restructure if statements in packetizers to simplify adding more conditions
Factorize out the s->num_frames check at the start of the if statements, simplifying adding more alternative causes for sending the buffered frames. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
@@ -39,7 +39,9 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
|
|||||||
|
|
||||||
/* test if the packet must be sent */
|
/* test if the packet must be sent */
|
||||||
len = (s->buf_ptr - s->buf);
|
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;
|
int au_size = s->num_frames * 2;
|
||||||
|
|
||||||
p = s->buf + max_au_headers_size - au_size - 2;
|
p = s->buf + max_au_headers_size - au_size - 2;
|
||||||
|
@@ -36,7 +36,9 @@ void ff_rtp_send_amr(AVFormatContext *s1, const uint8_t *buff, int size)
|
|||||||
|
|
||||||
/* Test if the packet must be sent. */
|
/* Test if the packet must be sent. */
|
||||||
len = s->buf_ptr - s->buf;
|
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;
|
int header_size = s->num_frames + 1;
|
||||||
p = s->buf + max_header_toc_size - header_size;
|
p = s->buf + max_header_toc_size - header_size;
|
||||||
if (p != s->buf)
|
if (p != s->buf)
|
||||||
|
@@ -75,8 +75,9 @@ void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size)
|
|||||||
int remaining = end_ptr - ptr;
|
int remaining = end_ptr - ptr;
|
||||||
|
|
||||||
assert(s->num_frames <= s->max_frames_per_packet);
|
assert(s->num_frames <= s->max_frames_per_packet);
|
||||||
if ((s->num_frames > 0 && remaining < 0) ||
|
if (s->num_frames > 0 &&
|
||||||
s->num_frames == s->max_frames_per_packet) {
|
(remaining < 0 ||
|
||||||
|
s->num_frames == s->max_frames_per_packet)) {
|
||||||
// send previous packets now; no room for new data
|
// send previous packets now; no room for new data
|
||||||
ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
|
ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
|
||||||
s->num_frames = 0;
|
s->num_frames = 0;
|
||||||
|
Reference in New Issue
Block a user