45 return value + (value >> 10);
55 int buf_size = avpkt->
size;
60 int magic_num, endian;
62 int w, h,
stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size;
64 unsigned int rgbBuffer;
66 if (avpkt->
size <= 1634) {
76 if (magic_num ==
AV_RL32(
"SDPX")) {
78 }
else if (magic_num ==
AV_RB32(
"SDPX")) {
85 offset =
read32(&buf, endian);
86 if (avpkt->
size <= offset) {
91 buf = avpkt->
data + 0x304;
102 bits_per_color = buf[0];
108 switch (descriptor) {
120 switch (bits_per_color) {
127 source_packet_size = elements;
128 target_packet_size = elements;
132 target_packet_size = 6;
133 source_packet_size = 4;
142 target_packet_size = 6;
143 source_packet_size = elements * 2;
159 buf = avpkt->
data + offset;
164 if (source_packet_size*avctx->
width*avctx->
height > buf_end - buf) {
168 switch (bits_per_color) {
170 for (x = 0; x < avctx->
height; x++) {
171 uint16_t *dst = (uint16_t*)ptr;
172 for (y = 0; y < avctx->
width; y++) {
173 rgbBuffer =
read32(&buf, endian);
185 if (source_packet_size == target_packet_size) {
186 for (x = 0; x < avctx->
height; x++) {
187 memcpy(ptr, buf, target_packet_size*avctx->
width);
189 buf += source_packet_size*avctx->
width;
192 for (x = 0; x < avctx->
height; x++) {
194 for (y = 0; y < avctx->
width; y++) {
195 memcpy(dst, buf, target_packet_size);
196 dst += target_packet_size;
197 buf += source_packet_size;