Revision 4ec72005

View differences:

libavcodec/dpxenc.c
73 73
    else               AV_WL32(p, value); \
74 74
} while(0)
75 75

  
76
static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst)
77
{
78
    DPXContext *s = avctx->priv_data;
79
    const uint8_t *src = pic->data[0];
80
    int x, y;
81

  
82
    for (y = 0; y < avctx->height; y++) {
83
        for (x = 0; x < avctx->width; x++) {
84
            int value;
85
            if ((avctx->pix_fmt & 1)) {
86
                value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4)
87
                      | ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6)
88
                      | ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16);
89
            } else {
90
                value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4)
91
                      | ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6)
92
                      | ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16);
93
            }
94
            write32(dst, value);
95
            dst += 4;
96
        }
97
        src += pic->linesize[0];
98
    }
99
}
100

  
76 101
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
77 102
{
78 103
    DPXContext *s = avctx->priv_data;
......
102 127
    buf[801] = 2; /* linear transfer */
103 128
    buf[802] = 2; /* linear colorimetric */
104 129
    buf[803] = s->bits_per_component;
130
    write16(buf + 804, s->bits_per_component == 10 ? 1 : 0); /* packing method */
105 131

  
106 132
    /* Image source information header */
107 133
    write32(buf + 1628, avctx->sample_aspect_ratio.num);
108 134
    write32(buf + 1632, avctx->sample_aspect_ratio.den);
109 135

  
136
    switch(s->bits_per_component) {
137
    case 8:
138
    case 16:
110 139
    size = avpicture_layout((AVPicture*)data, avctx->pix_fmt,
111 140
                            avctx->width, avctx->height,
112 141
                            buf + HEADER_SIZE, buf_size - HEADER_SIZE);
113 142
    if (size < 0)
114 143
        return size;
144
        break;
145
    case 10:
146
        size = avctx->height * avctx->width * 4;
147
        if (buf_size < HEADER_SIZE + size)
148
            return -1;
149
        encode_rgb48_10bit(avctx, (AVPicture*)data, buf + HEADER_SIZE);
150
        break;
151
    default:
152
        av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n", bits_per_component);
153
        return -1;
154
    }
115 155

  
116 156
    size += HEADER_SIZE;
117 157

  

Also available in: Unified diff