mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
j2kpay: cleanup header construction
Use a simpler way of constructing the header that doesn't depend on the endianness.
This commit is contained in:
parent
984564150f
commit
744472d2ad
1 changed files with 29 additions and 39 deletions
|
@ -86,47 +86,18 @@ enum
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* RtpJ2KHeader:
|
|
||||||
* @tp: type (0 progressive, 1 odd field, 2 even field)
|
|
||||||
* @MHF: Main Header Flag
|
|
||||||
* @mh_id: Main Header Identification
|
|
||||||
* @T: Tile field invalidation flag
|
|
||||||
* @priority: priority
|
|
||||||
* @tile number: the tile number of the payload
|
|
||||||
* @reserved: set to 0
|
|
||||||
* @fragment offset: the byte offset of the current payload
|
|
||||||
*
|
|
||||||
* 0 1 2 3
|
|
||||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
* |tp |MHF|mh_id|T| priority | tile number |
|
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
* |reserved | fragment offset |
|
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
*/
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
||||||
guint T:1;
|
|
||||||
guint mh_id:3;
|
|
||||||
guint MHF:2;
|
|
||||||
guint tp:2;
|
|
||||||
#elif G_BYTE_ORDER == G_BIG_ENDIAN
|
|
||||||
guint tp:2;
|
guint tp:2;
|
||||||
guint MHF:2;
|
guint MHF:2;
|
||||||
guint mh_id:3;
|
guint mh_id:3;
|
||||||
guint T:1;
|
guint T:1;
|
||||||
#else
|
|
||||||
#error "G_BYTE_ORDER should be big or little endian."
|
|
||||||
#endif
|
|
||||||
guint priority:8;
|
guint priority:8;
|
||||||
guint tile:16;
|
guint tile:16;
|
||||||
guint reserved:8;
|
|
||||||
guint offset:24;
|
guint offset:24;
|
||||||
} RtpJ2KHeader;
|
} RtpJ2KHeader;
|
||||||
|
|
||||||
#define HEADER_SIZE sizeof(RtpJ2KHeader)
|
#define HEADER_SIZE 8
|
||||||
|
|
||||||
static void gst_rtp_j2k_pay_set_property (GObject * object, guint prop_id,
|
static void gst_rtp_j2k_pay_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -388,7 +359,6 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
state.header.T = 1; /* invalid tile */
|
state.header.T = 1; /* invalid tile */
|
||||||
state.header.priority = 255; /* always 255 for now */
|
state.header.priority = 255; /* always 255 for now */
|
||||||
state.header.tile = 0; /* no tile number */
|
state.header.tile = 0; /* no tile number */
|
||||||
state.header.reserved = 0;
|
|
||||||
state.bitstream = FALSE;
|
state.bitstream = FALSE;
|
||||||
state.n_tiles = 0;
|
state.n_tiles = 0;
|
||||||
state.next_sot = 0;
|
state.next_sot = 0;
|
||||||
|
@ -493,14 +463,34 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
gst_rtp_buffer_set_marker (outbuf, TRUE);
|
gst_rtp_buffer_set_marker (outbuf, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the header and push the packet */
|
/*
|
||||||
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
* RtpJ2KHeader:
|
||||||
state.header.offset = ((offset & 0x0000FF) << 16) |
|
* @tp: type (0 progressive, 1 odd field, 2 even field)
|
||||||
((offset & 0xFF0000) >> 16) | (offset & 0x00FF00);
|
* @MHF: Main Header Flag
|
||||||
#else
|
* @mh_id: Main Header Identification
|
||||||
state.header.offset = offset;
|
* @T: Tile field invalidation flag
|
||||||
#endif
|
* @priority: priority
|
||||||
memcpy (header, &state.header, HEADER_SIZE);
|
* @tile number: the tile number of the payload
|
||||||
|
* @reserved: set to 0
|
||||||
|
* @fragment offset: the byte offset of the current payload
|
||||||
|
*
|
||||||
|
* 0 1 2 3
|
||||||
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* |tp |MHF|mh_id|T| priority | tile number |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
* |reserved | fragment offset |
|
||||||
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*/
|
||||||
|
header[0] = (state.header.tp << 6) | (state.header.MHF << 4) |
|
||||||
|
(state.header.mh_id << 1) | state.header.T;
|
||||||
|
header[1] = state.header.priority;
|
||||||
|
header[2] = state.header.tile >> 8;
|
||||||
|
header[3] = state.header.tile & 0xff;
|
||||||
|
header[4] = 0;
|
||||||
|
header[5] = state.header.offset >> 16;
|
||||||
|
header[6] = (state.header.offset >> 8) & 0xff;
|
||||||
|
header[7] = state.header.offset & 0xff;
|
||||||
|
|
||||||
if (pay->buffer_list) {
|
if (pay->buffer_list) {
|
||||||
GstBuffer *paybuf;
|
GstBuffer *paybuf;
|
||||||
|
|
Loading…
Reference in a new issue