32 static unsigned int read32(
const uint8_t **ptr,
int is_big)
49 return value + (value >> 10);
57 const uint8_t *buf = avpkt->
data;
58 const uint8_t *buf_end = avpkt->
data + avpkt->
size;
59 int buf_size = avpkt->
size;
65 int magic_num, offset, endian;
67 int w, h,
stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size;
69 unsigned int rgbBuffer;
71 if (avpkt->
size <= 1634) {
81 if (magic_num ==
AV_RL32(
"SDPX")) {
83 }
else if (magic_num ==
AV_RB32(
"SDPX")) {
90 offset =
read32(&buf, endian);
91 if (avpkt->
size <= offset) {
96 buf = avpkt->
data + 0x304;
107 bits_per_color = buf[0];
113 switch (descriptor) {
125 switch (bits_per_color) {
132 source_packet_size = elements;
133 target_packet_size = elements;
137 target_packet_size = 6;
138 source_packet_size = 4;
147 target_packet_size = 6;
148 source_packet_size = elements * 2;
167 buf = avpkt->
data + offset;
172 if (source_packet_size*avctx->
width*avctx->
height > buf_end - buf) {
176 switch (bits_per_color) {
178 for (x = 0; x < avctx->
height; x++) {
179 uint16_t *dst = (uint16_t*)ptr;
180 for (y = 0; y < avctx->
width; y++) {
181 rgbBuffer =
read32(&buf, endian);
193 if (source_packet_size == target_packet_size) {
194 for (x = 0; x < avctx->
height; x++) {
195 memcpy(ptr, buf, target_packet_size*avctx->
width);
197 buf += source_packet_size*avctx->
width;
200 for (x = 0; x < avctx->
height; x++) {
202 for (y = 0; y < avctx->
width; y++) {
203 memcpy(dst, buf, target_packet_size);
204 dst += target_packet_size;
205 buf += source_packet_size;