* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdio.h>
+#include <string.h>
#include "pixfmt.h"
#include "pixdesc.h"
}
} else {
const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
+ int is_8bit = 0;
+ if (shift + depth <= 8) {
+ p += !!(flags & PIX_FMT_BE);
+ is_8bit = 1;
+ }
while(w--){
- int val;
- if(flags & PIX_FMT_BE) val= AV_RB16(p);
- else val= AV_RL16(p);
+ int val = is_8bit ? *p :
+ flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
val = (val>>shift) & mask;
if(read_pal_component)
val= data[1][4*val + c];
int shift = comp.shift;
uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
- while (w--) {
- if (flags & PIX_FMT_BE) {
- uint16_t val = AV_RB16(p) | (*src++<<shift);
- AV_WB16(p, val);
- } else {
- uint16_t val = AV_RL16(p) | (*src++<<shift);
- AV_WL16(p, val);
+ if (shift + depth <= 8) {
+ p += !!(flags & PIX_FMT_BE);
+ while (w--) {
+ *p |= (*src++<<shift);
+ p += step;
+ }
+ } else {
+ while (w--) {
+ if (flags & PIX_FMT_BE) {
+ uint16_t val = AV_RB16(p) | (*src++<<shift);
+ AV_WB16(p, val);
+ } else {
+ uint16_t val = AV_RL16(p) | (*src++<<shift);
+ AV_WL16(p, val);
+ }
+ p+= step;
}
- p+= step;
}
}
}