# HG changeset patch # User mru # Date 1284327594 0 # Node ID 3728a7291737fd06ef1049f8cc4c04f19862a7e7 # Parent 83021885b234e0580f562c74c913eaa75ce773df pixdesc: use 8-bit accesses when possible in av_read/write_image_line() This fixes out of bounds accesses for big endian formats and should be a little faster. diff -r 83021885b234 -r 3728a7291737 pixdesc.c --- a/pixdesc.c Sun Sep 12 21:31:39 2010 +0000 +++ b/pixdesc.c Sun Sep 12 21:39:54 2010 +0000 @@ -53,9 +53,15 @@ } } 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 = flags & PIX_FMT_BE ? AV_RB16(p) : 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]; @@ -89,6 +95,13 @@ int shift = comp.shift; uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; + if (shift + depth <= 8) { + p += !!(flags & PIX_FMT_BE); + while (w--) { + *p |= (*src++<