diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-05-12 21:27:48 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-05-12 21:56:29 +0000 |
commit | ae9ef151ad77996b3f17ebe443026099f37ef009 (patch) | |
tree | 931b031d532efe113049aa3b5a04b0ddb6a215b8 /libavcodec | |
parent | 22a038606cde5088cc2b4eee1a1ace1140c3b49b (diff) | |
download | ffmpeg-ae9ef151ad77996b3f17ebe443026099f37ef009.tar.gz |
dpxenc: simplifiy code using AVPixFmtDescriptor
Update rgb24 fate test as it no longer writes image in big endian
format.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/dpxenc.c | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index b5f7c19191..305393f66f 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -35,40 +35,27 @@ typedef struct DPXContext { static av_cold int encode_init(AVCodecContext *avctx) { DPXContext *s = avctx->priv_data; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); - s->big_endian = 1; - s->bits_per_component = 8; - s->descriptor = 50; /* RGB */ - s->planar = 0; + s->big_endian = !!(desc->flags & PIX_FMT_BE); + s->bits_per_component = desc->comp[0].depth_minus1 + 1; + s->descriptor = (desc->flags & PIX_FMT_ALPHA) ? 51 : 50; + s->planar = !!(desc->flags & PIX_FMT_PLANAR); switch (avctx->pix_fmt) { + case AV_PIX_FMT_GBRP10BE: + case AV_PIX_FMT_GBRP10LE: + case AV_PIX_FMT_GBRP12BE: + case AV_PIX_FMT_GBRP12LE: case AV_PIX_FMT_RGB24: - break; + case AV_PIX_FMT_RGBA64BE: + case AV_PIX_FMT_RGBA64LE: case AV_PIX_FMT_RGBA: - s->descriptor = 51; /* RGBA */ break; case AV_PIX_FMT_RGB48LE: - s->big_endian = 0; case AV_PIX_FMT_RGB48BE: - s->bits_per_component = avctx->bits_per_raw_sample ? avctx->bits_per_raw_sample : 16; - break; - case AV_PIX_FMT_RGBA64LE: - s->big_endian = 0; - case AV_PIX_FMT_RGBA64BE: - s->descriptor = 51; - s->bits_per_component = 16; - break; - case AV_PIX_FMT_GBRP10LE: - s->big_endian = 0; - case AV_PIX_FMT_GBRP10BE: - s->bits_per_component = 10; - s->planar = 1; - break; - case AV_PIX_FMT_GBRP12LE: - s->big_endian = 0; - case AV_PIX_FMT_GBRP12BE: - s->bits_per_component = 12; - s->planar = 1; + if (avctx->bits_per_raw_sample) + s->bits_per_component = avctx->bits_per_raw_sample; break; default: av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n"); |