rtpjpeg: fix copying of quant data if it spans memory segments
rtpjpeg no longer joins all memory segments before encoding. Ensure we copy the data from the correct segments. Re-arrange test data so it's not correctly ordered and add test. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5533>
This commit is contained in:
parent
4b6c732fdd
commit
09a0a6a9d5
@ -194,7 +194,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
guint8 size;
|
||||
const guint8 *data;
|
||||
guint offset;
|
||||
} RtpQuantTable;
|
||||
|
||||
/*
|
||||
@ -469,7 +469,7 @@ gst_rtp_jpeg_pay_read_quant_table (GstBufferMemoryMap * memory,
|
||||
GST_LOG ("read quant table %d, tab_size %d, prec %02x", id, tab_size, prec);
|
||||
|
||||
tables[id].size = tab_size;
|
||||
tables[id].data = memory->data;
|
||||
tables[id].offset = memory->offset;
|
||||
|
||||
quant_size -= (tab_size + 1);
|
||||
if (!gst_buffer_memory_advance_bytes (memory, tab_size)) {
|
||||
@ -721,7 +721,7 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||
RtpJpegHeader jpeg_header;
|
||||
RtpQuantHeader quant_header;
|
||||
RtpRestartMarkerHeader restart_marker_header;
|
||||
RtpQuantTable tables[15] = { {0, NULL}, };
|
||||
RtpQuantTable tables[15] = { {0, 0}, };
|
||||
CompInfo info[3] = { {0,}, };
|
||||
guint quant_data_size;
|
||||
guint mtu, max_payload_size;
|
||||
@ -930,10 +930,12 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||
for (i = 0; i < 2; i++) {
|
||||
guint qsize;
|
||||
guint qt;
|
||||
gsize rc;
|
||||
|
||||
qt = info[i].qt;
|
||||
qsize = tables[qt].size;
|
||||
memcpy (payload, tables[qt].data, qsize);
|
||||
rc = gst_buffer_extract (buffer, tables[qt].offset, payload, qsize);
|
||||
g_assert (rc == qsize);
|
||||
|
||||
GST_LOG_OBJECT (pay, "component %d using quant %d, size %d", i, qt,
|
||||
qsize);
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <gst/app/app.h>
|
||||
#include <gst/rtp/gstrtpbuffer.h>
|
||||
|
||||
static const gchar rtp_jpeg_frame_sha1[] =
|
||||
"4d6fb8dba3fdfc7aaead473fadf5b1bfd07c1bec";
|
||||
|
||||
/* one complete blank jpeg 1x1 */
|
||||
static const guint8 rtp_jpeg_frame_data[] =
|
||||
@ -113,24 +115,6 @@ static const guint8 rtp_jpeg_frame_data_s1[] = {
|
||||
0x00, 0x60, 0x00
|
||||
};
|
||||
|
||||
/* second slice of one complete blank jpeg 1x1 */
|
||||
static const guint8 rtp_jpeg_frame_data_s2[] = {
|
||||
0x00, /* DQT */ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06,
|
||||
0x05, 0x08,
|
||||
0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b,
|
||||
0x0c, 0x19, 0x12,
|
||||
0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24,
|
||||
0x2e, 0x27, 0x20,
|
||||
0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34,
|
||||
0x34, 0x1f, 0x27,
|
||||
0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43,
|
||||
0x01, 0x09, 0x09,
|
||||
0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32,
|
||||
0x32, 0x32, 0x32,
|
||||
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
||||
0x32, 0x32, 0x32
|
||||
};
|
||||
|
||||
/* third slice of one complete blank jpeg 1x1 */
|
||||
static const guint8 rtp_jpeg_frame_data_s3[] = {
|
||||
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
||||
@ -173,6 +157,24 @@ static const guint8 rtp_jpeg_frame_data_s4[] = {
|
||||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff
|
||||
};
|
||||
|
||||
/* second slice of one complete blank jpeg 1x1 */
|
||||
static const guint8 rtp_jpeg_frame_data_s2[] = {
|
||||
0x00, /* DQT */ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06,
|
||||
0x05, 0x08,
|
||||
0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b,
|
||||
0x0c, 0x19, 0x12,
|
||||
0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24,
|
||||
0x2e, 0x27, 0x20,
|
||||
0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34,
|
||||
0x34, 0x1f, 0x27,
|
||||
0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43,
|
||||
0x01, 0x09, 0x09,
|
||||
0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32,
|
||||
0x32, 0x32, 0x32,
|
||||
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
||||
0x32, 0x32, 0x32
|
||||
};
|
||||
|
||||
/* fifth and last slice of one complete blank jpeg 1x1 */
|
||||
static const guint8 rtp_jpeg_frame_data_s5[] = {
|
||||
0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03,
|
||||
@ -257,6 +259,11 @@ GST_START_TEST (test_rtpjpegpay_1_slice)
|
||||
fail_unless (payload[6] == 1); /* Width */
|
||||
fail_unless (payload[7] == 1); /* Height */
|
||||
|
||||
s = g_compute_checksum_for_data (G_CHECKSUM_SHA1, payload,
|
||||
gst_rtp_buffer_get_payload_len (&rtp));
|
||||
ck_assert_str_eq (s, rtp_jpeg_frame_sha1);
|
||||
g_free (s);
|
||||
|
||||
fail_unless (gst_rtp_buffer_get_marker (&rtp));
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
gst_buffer_unref (buffer);
|
||||
@ -324,6 +331,12 @@ GST_START_TEST (test_rtpjpegpay_5_slices)
|
||||
fail_unless (payload[4] == 1); /* type */
|
||||
fail_unless (payload[6] == 1); /* Width */
|
||||
fail_unless (payload[7] == 1); /* Height */
|
||||
fail_unless (payload[113] == 0x32); /* Quant from 3rd slice */
|
||||
|
||||
s = g_compute_checksum_for_data (G_CHECKSUM_SHA1, payload,
|
||||
gst_rtp_buffer_get_payload_len (&rtp));
|
||||
ck_assert_str_eq (s, rtp_jpeg_frame_sha1);
|
||||
g_free (s);
|
||||
|
||||
fail_unless (gst_rtp_buffer_get_marker (&rtp));
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user