diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-04-21 23:15:21 +0400 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-04-21 23:15:21 +0400 |
commit | 9401d18fa5b2a746c27d52bfd0282988ce90fc1a (patch) | |
tree | ced3a138650a599c35da076c9100bef349ac6b4c | |
parent | fd548e5bd6c1a11ad6739143817c125a41efe5f5 (diff) |
Implement a write_line() function.
Originally committed as revision 18646 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/pixdesc.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libavcodec/pixdesc.h b/libavcodec/pixdesc.h index 9610262b51..5c2718dba7 100644 --- a/libavcodec/pixdesc.h +++ b/libavcodec/pixdesc.h @@ -137,3 +137,54 @@ static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int li } } } + +/** + * Writes the values from src to the pixel format component c of an + * image line. + * + * @param src array containing the values to write + * @param data the array containing the pointers to the planes of the + * image to write into. It is supposed to be zeroed. + * @param linesizes the array containing the linesizes of the image + * @param desc the pixel format descriptor for the image + * @param x the horizontal coordinate of the first pixel to write + * @param y the vertical coordinate of the first pixel to write + * @param w the width of the line to write, that is the number of + * values to write to the image line + */ +static inline void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w) +{ + AVComponentDescriptor comp = desc->comp[c]; + int plane = comp.plane; + int depth = comp.depth_minus1+1; + int step = comp.step_minus1+1; + int flags = desc->flags; + + if (flags & PIX_FMT_BITSTREAM) { + int skip = x*step + comp.offset_plus1-1; + uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3); + int shift = 8 - depth - (skip&7); + + while (w--) { + *p |= *src++ << shift; + shift -= step; + p -= shift>>3; + shift &= 7; + } + } else { + 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); + } + p+= step; + } + } +} |