s->planar = 0;
switch (avctx->pix_fmt) {
- case PIX_FMT_RGB24:
+ case AV_PIX_FMT_RGB24:
break;
- case PIX_FMT_RGBA:
+ case AV_PIX_FMT_RGBA:
s->descriptor = 51; /* RGBA */
break;
- case PIX_FMT_RGB48LE:
+ case AV_PIX_FMT_RGB48LE:
s->big_endian = 0;
- case PIX_FMT_RGB48BE:
+ case AV_PIX_FMT_RGB48BE:
s->bits_per_component = avctx->bits_per_raw_sample ? avctx->bits_per_raw_sample : 16;
break;
- case PIX_FMT_RGBA64LE:
+ case AV_PIX_FMT_RGBA64LE:
s->big_endian = 0;
- case PIX_FMT_RGBA64BE:
+ case AV_PIX_FMT_RGBA64BE:
s->descriptor = 51;
s->bits_per_component = 16;
break;
- case PIX_FMT_GBRP10LE:
+ case AV_PIX_FMT_GBRP10LE:
s->big_endian = 0;
- case PIX_FMT_GBRP10BE:
+ case AV_PIX_FMT_GBRP10BE:
s->bits_per_component = 10;
s->planar = 1;
break;
- case PIX_FMT_GBRP12LE:
+ case AV_PIX_FMT_GBRP12LE:
s->big_endian = 0;
- case PIX_FMT_GBRP12BE:
+ case AV_PIX_FMT_GBRP12BE:
s->bits_per_component = 12;
s->planar = 1;
break;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
int value;
- if ((avctx->pix_fmt & 1)) {
- value = ((AV_RB16(src + 6*x + 4) & 0xFFC0) >> 4)
- | ((AV_RB16(src + 6*x + 2) & 0xFFC0) << 6)
- | ((AV_RB16(src + 6*x + 0) & 0xFFC0) << 16);
+ if (s->big_endian) {
+ value = ((AV_RB16(src + 6*x + 4) & 0xFFC0U) >> 4)
+ | ((AV_RB16(src + 6*x + 2) & 0xFFC0U) << 6)
+ | ((AV_RB16(src + 6*x + 0) & 0xFFC0U) << 16);
} else {
- value = ((AV_RL16(src + 6*x + 4) & 0xFFC0) >> 4)
- | ((AV_RL16(src + 6*x + 2) & 0xFFC0) << 6)
- | ((AV_RL16(src + 6*x + 0) & 0xFFC0) << 16);
+ value = ((AV_RL16(src + 6*x + 4) & 0xFFC0U) >> 4)
+ | ((AV_RL16(src + 6*x + 2) & 0xFFC0U) << 6)
+ | ((AV_RL16(src + 6*x + 0) & 0xFFC0U) << 16);
}
write32(dst, value);
dst += 4;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
int value;
- if ((avctx->pix_fmt & 1)) {
+ if (s->big_endian) {
value = (AV_RB16(src[0] + 2*x) << 12)
| (AV_RB16(src[1] + 2*x) << 2)
| (AV_RB16(src[2] + 2*x) << 22);
static void encode_gbrp12(AVCodecContext *avctx, const AVPicture *pic, uint16_t *dst)
{
+ DPXContext *s = avctx->priv_data;
const uint16_t *src[3] = {(uint16_t*)pic->data[0],
(uint16_t*)pic->data[1],
(uint16_t*)pic->data[2]};
int x, y, i;
for (y = 0; y < avctx->height; y++) {
for (x = 0; x < avctx->width; x++) {
+ uint16_t value[3];
+ if (s->big_endian) {
+ value[1] = AV_RB16(src[0] + x) << 4;
+ value[2] = AV_RB16(src[1] + x) << 4;
+ value[0] = AV_RB16(src[2] + x) << 4;
+ } else {
+ value[1] = AV_RL16(src[0] + x) << 4;
+ value[2] = AV_RL16(src[1] + x) << 4;
+ value[0] = AV_RL16(src[2] + x) << 4;
+ }
for (i = 0; i < 3; i++)
- *dst++ = *(src[i] + x);
+ write16(dst++, value[i]);
}
for (i = 0; i < 3; i++)
src[i] += pic->linesize[i]/2;
.priv_data_size = sizeof(DPXContext),
.init = encode_init,
.encode2 = encode_frame,
- .pix_fmts = (const enum PixelFormat[]){
- PIX_FMT_RGB24,
- PIX_FMT_RGBA,
- PIX_FMT_RGB48LE,
- PIX_FMT_RGB48BE,
- PIX_FMT_RGBA64LE,
- PIX_FMT_RGBA64BE,
- PIX_FMT_GBRP10LE,
- PIX_FMT_GBRP10BE,
- PIX_FMT_GBRP12LE,
- PIX_FMT_GBRP12BE,
- PIX_FMT_NONE},
+ .pix_fmts = (const enum AVPixelFormat[]){
+ AV_PIX_FMT_RGB24,
+ AV_PIX_FMT_RGBA,
+ AV_PIX_FMT_RGB48LE,
+ AV_PIX_FMT_RGB48BE,
+ AV_PIX_FMT_RGBA64LE,
+ AV_PIX_FMT_RGBA64BE,
+ AV_PIX_FMT_GBRP10LE,
+ AV_PIX_FMT_GBRP10BE,
+ AV_PIX_FMT_GBRP12LE,
+ AV_PIX_FMT_GBRP12BE,
+ AV_PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("DPX image"),
};