rtpvrawpay: micro-optimise variable access in inner loop
Store some values that don't change during the execution of the inner loops locally, so the compiler knows that too.
This commit is contained in:
parent
fdf95fecbd
commit
15a33ccc65
@ -244,10 +244,12 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
guint line, offset;
|
guint line, offset;
|
||||||
guint8 *p0, *yp, *up, *vp;
|
guint8 *p0, *yp, *up, *vp;
|
||||||
guint ystride, uvstride;
|
guint ystride, uvstride;
|
||||||
|
guint xinc, yinc;
|
||||||
guint pgroup;
|
guint pgroup;
|
||||||
guint mtu;
|
guint mtu;
|
||||||
guint width, height;
|
guint width, height;
|
||||||
gint field, fields;
|
gint field, fields;
|
||||||
|
GstVideoFormat format;
|
||||||
GstVideoFrame frame;
|
GstVideoFrame frame;
|
||||||
gint interlaced;
|
gint interlaced;
|
||||||
GstBufferList *list;
|
GstBufferList *list;
|
||||||
@ -278,6 +280,11 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
|
|
||||||
interlaced = GST_VIDEO_INFO_IS_INTERLACED (&rtpvrawpay->vinfo);
|
interlaced = GST_VIDEO_INFO_IS_INTERLACED (&rtpvrawpay->vinfo);
|
||||||
|
|
||||||
|
format = GST_VIDEO_INFO_FORMAT (&rtpvrawpay->vinfo);
|
||||||
|
|
||||||
|
yinc = rtpvrawpay->yinc;
|
||||||
|
xinc = rtpvrawpay->xinc;
|
||||||
|
|
||||||
/* after how many packed lines we push out a buffer list */
|
/* after how many packed lines we push out a buffer list */
|
||||||
lines_delay = GST_ROUND_UP_4 (height / 10);
|
lines_delay = GST_ROUND_UP_4 (height / 10);
|
||||||
|
|
||||||
@ -356,7 +363,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
|
|
||||||
/* get how may bytes we need for the remaining pixels */
|
/* get how may bytes we need for the remaining pixels */
|
||||||
pixels = width - offset;
|
pixels = width - offset;
|
||||||
length = (pixels * pgroup) / rtpvrawpay->xinc;
|
length = (pixels * pgroup) / xinc;
|
||||||
|
|
||||||
if (left >= length) {
|
if (left >= length) {
|
||||||
/* pixels and header fit completely, we will write them and skip to the
|
/* pixels and header fit completely, we will write them and skip to the
|
||||||
@ -364,8 +371,8 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
next_line = TRUE;
|
next_line = TRUE;
|
||||||
} else {
|
} else {
|
||||||
/* line does not fit completely, see how many pixels fit */
|
/* line does not fit completely, see how many pixels fit */
|
||||||
pixels = (left / pgroup) * rtpvrawpay->xinc;
|
pixels = (left / pgroup) * xinc;
|
||||||
length = (pixels * pgroup) / rtpvrawpay->xinc;
|
length = (pixels * pgroup) / xinc;
|
||||||
next_line = FALSE;
|
next_line = FALSE;
|
||||||
}
|
}
|
||||||
GST_LOG_OBJECT (rtpvrawpay, "filling %u bytes in %u pixels", length,
|
GST_LOG_OBJECT (rtpvrawpay, "filling %u bytes in %u pixels", length,
|
||||||
@ -382,7 +389,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
|
|
||||||
if (next_line) {
|
if (next_line) {
|
||||||
/* go to next line we do this here to make the check below easier */
|
/* go to next line we do this here to make the check below easier */
|
||||||
line += rtpvrawpay->yinc;
|
line += yinc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate continuation marker */
|
/* calculate continuation marker */
|
||||||
@ -423,14 +430,14 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
"writing length %u, line %u, offset %u, cont %d", length, lin, offs,
|
"writing length %u, line %u, offset %u, cont %d", length, lin, offs,
|
||||||
cont);
|
cont);
|
||||||
|
|
||||||
switch (GST_VIDEO_INFO_FORMAT (&rtpvrawpay->vinfo)) {
|
switch (format) {
|
||||||
case GST_VIDEO_FORMAT_RGB:
|
case GST_VIDEO_FORMAT_RGB:
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
case GST_VIDEO_FORMAT_RGBA:
|
||||||
case GST_VIDEO_FORMAT_BGR:
|
case GST_VIDEO_FORMAT_BGR:
|
||||||
case GST_VIDEO_FORMAT_BGRA:
|
case GST_VIDEO_FORMAT_BGRA:
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
case GST_VIDEO_FORMAT_UYVY:
|
||||||
case GST_VIDEO_FORMAT_UYVP:
|
case GST_VIDEO_FORMAT_UYVP:
|
||||||
offs /= rtpvrawpay->xinc;
|
offs /= xinc;
|
||||||
memcpy (outdata, p0 + (lin * ystride) + (offs * pgroup), length);
|
memcpy (outdata, p0 + (lin * ystride) + (offs * pgroup), length);
|
||||||
outdata += length;
|
outdata += length;
|
||||||
break;
|
break;
|
||||||
@ -457,8 +464,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
|
|
||||||
yd1p = yp + (lin * ystride) + (offs);
|
yd1p = yp + (lin * ystride) + (offs);
|
||||||
yd2p = yd1p + ystride;
|
yd2p = yd1p + ystride;
|
||||||
uvoff =
|
uvoff = (lin / yinc * uvstride) + (offs / xinc);
|
||||||
(lin / rtpvrawpay->yinc * uvstride) + (offs / rtpvrawpay->xinc);
|
|
||||||
udp = up + uvoff;
|
udp = up + uvoff;
|
||||||
vdp = vp + uvoff;
|
vdp = vp + uvoff;
|
||||||
|
|
||||||
@ -479,8 +485,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||||||
guint8 *ydp, *udp, *vdp;
|
guint8 *ydp, *udp, *vdp;
|
||||||
|
|
||||||
ydp = yp + (lin * ystride) + offs;
|
ydp = yp + (lin * ystride) + offs;
|
||||||
uvoff =
|
uvoff = (lin / yinc * uvstride) + (offs / xinc);
|
||||||
(lin / rtpvrawpay->yinc * uvstride) + (offs / rtpvrawpay->xinc);
|
|
||||||
udp = up + uvoff;
|
udp = up + uvoff;
|
||||||
vdp = vp + uvoff;
|
vdp = vp + uvoff;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user