diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/dpxenc.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/dpxenc.c')
| -rw-r--r-- | ffmpeg/libavcodec/dpxenc.c | 87 |
1 files changed, 37 insertions, 50 deletions
diff --git a/ffmpeg/libavcodec/dpxenc.c b/ffmpeg/libavcodec/dpxenc.c index f210bbc..0eb1297 100644 --- a/ffmpeg/libavcodec/dpxenc.c +++ b/ffmpeg/libavcodec/dpxenc.c @@ -26,7 +26,6 @@ #include "internal.h" typedef struct DPXContext { - AVFrame picture; int big_endian; int bits_per_component; int descriptor; @@ -36,44 +35,35 @@ 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); - avctx->coded_frame = &s->picture; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; - avctx->coded_frame->key_frame = 1; - - s->big_endian = 1; - s->bits_per_component = 8; - s->descriptor = 50; /* RGB */ - s->planar = 0; + s->big_endian = !!(desc->flags & AV_PIX_FMT_FLAG_BE); + s->bits_per_component = desc->comp[0].depth_minus1 + 1; + s->descriptor = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? 51 : 50; + s->planar = !!(desc->flags & AV_PIX_FMT_FLAG_PLANAR); switch (avctx->pix_fmt) { - case AV_PIX_FMT_RGB24: + case AV_PIX_FMT_ABGR: + s->descriptor = 52; + break; + case AV_PIX_FMT_GRAY16BE: + case AV_PIX_FMT_GRAY16LE: + case AV_PIX_FMT_GRAY8: + s->descriptor = 6; break; + 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: + 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"); @@ -132,11 +122,11 @@ static void encode_gbrp10(AVCodecContext *avctx, const AVPicture *pic, uint8_t * 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); + | ((unsigned)AV_RB16(src[2] + 2*x) << 22); } else { value = (AV_RL16(src[0] + 2*x) << 12) | (AV_RL16(src[1] + 2*x) << 2) - | (AV_RL16(src[2] + 2*x) << 22); + | ((unsigned)AV_RL16(src[2] + 2*x) << 22); } write32(dst, value); dst += 4; @@ -252,23 +242,20 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } AVCodec ff_dpx_encoder = { - .name = "dpx", - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_DPX, + .name = "dpx", + .long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_DPX, .priv_data_size = sizeof(DPXContext), - .init = encode_init, - .encode2 = encode_frame, - .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, + .init = encode_init, + .encode2 = encode_frame, + .pix_fmts = (const enum AVPixelFormat[]){ + AV_PIX_FMT_GRAY8, + AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_ABGR, + AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE, + 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"), }; |
