Revision f47a7cb7 libavutil/pixdesc.h

View differences:

libavutil/pixdesc.h
24 24

  
25 25
#include <inttypes.h>
26 26

  
27
#include "intreadwrite.h"
28

  
29 27
typedef struct AVComponentDescriptor{
30 28
    uint16_t plane        :2;            ///< which of the 4 planes contains the component
31 29

  
......
110 108
 * component c in data[1] to dst, rather than the palette indexes in
111 109
 * data[0]. The behavior is undefined if the format is not paletted.
112 110
 */
113
static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
114
                             const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
115
{
116
    AVComponentDescriptor comp= desc->comp[c];
117
    int plane= comp.plane;
118
    int depth= comp.depth_minus1+1;
119
    int mask = (1<<depth)-1;
120
    int shift= comp.shift;
121
    int step = comp.step_minus1+1;
122
    int flags= desc->flags;
123

  
124
    if (flags & PIX_FMT_BITSTREAM){
125
        int skip = x*step + comp.offset_plus1-1;
126
        const uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3);
127
        int shift = 8 - depth - (skip&7);
128

  
129
        while(w--){
130
            int val = (*p >> shift) & mask;
131
            if(read_pal_component)
132
                val= data[1][4*val + c];
133
            shift -= step;
134
            p -= shift>>3;
135
            shift &= 7;
136
            *dst++= val;
137
        }
138
    } else {
139
        const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
140

  
141
        while(w--){
142
            int val;
143
            if(flags & PIX_FMT_BE) val= AV_RB16(p);
144
            else                   val= AV_RL16(p);
145
            val = (val>>shift) & mask;
146
            if(read_pal_component)
147
                val= data[1][4*val + c];
148
            p+= step;
149
            *dst++= val;
150
        }
151
    }
152
}
111
void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
112
               const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component);
153 113

  
154 114
/**
155 115
 * Writes the values from src to the pixel format component c of an
......
165 125
 * @param w the width of the line to write, that is the number of
166 126
 * values to write to the image line
167 127
 */
168
static inline void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
169
                              const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
170
{
171
    AVComponentDescriptor comp = desc->comp[c];
172
    int plane = comp.plane;
173
    int depth = comp.depth_minus1+1;
174
    int step  = comp.step_minus1+1;
175
    int flags = desc->flags;
176

  
177
    if (flags & PIX_FMT_BITSTREAM) {
178
        int skip = x*step + comp.offset_plus1-1;
179
        uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3);
180
        int shift = 8 - depth - (skip&7);
181

  
182
        while (w--) {
183
            *p |= *src++ << shift;
184
            shift -= step;
185
            p -= shift>>3;
186
            shift &= 7;
187
        }
188
    } else {
189
        int shift = comp.shift;
190
        uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
191

  
192
        while (w--) {
193
            if (flags & PIX_FMT_BE) {
194
                uint16_t val = AV_RB16(p) | (*src++<<shift);
195
                AV_WB16(p, val);
196
            } else {
197
                uint16_t val = AV_RL16(p) | (*src++<<shift);
198
                AV_WL16(p, val);
199
            }
200
            p+= step;
201
        }
202
    }
203
}
128
void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
129
                const AVPixFmtDescriptor *desc, int x, int y, int c, int w);
204 130

  
205 131
/**
206 132
 * Returns the pixel format corresponding to name.

Also available in: Unified diff