diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-12-18 14:27:41 +0100 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-12-18 14:27:41 +0100 |
commit | 2630f7f709049113dc03d6b999efad6acc423d67 (patch) | |
tree | d7a217a844f6b7939d3f08da45c027caa9e6761c /libavcodec/sgienc.c | |
parent | ec1b95dda4a856ae532a0a27aa6213040e712d68 (diff) | |
parent | be00ec832c519427cd92218abac77dafdc1d5487 (diff) | |
download | ffmpeg-2630f7f709049113dc03d6b999efad6acc423d67.tar.gz |
Merge commit 'be00ec832c519427cd92218abac77dafdc1d5487'
* commit 'be00ec832c519427cd92218abac77dafdc1d5487':
lavc: Deprecate coder_type and its symbols
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavcodec/sgienc.c')
-rw-r--r-- | libavcodec/sgienc.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index d631e23656..9352737f42 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/opt.h" + #include "avcodec.h" #include "bytestream.h" #include "internal.h" @@ -28,6 +30,12 @@ #define SGI_SINGLE_CHAN 2 #define SGI_MULTI_CHAN 3 +typedef struct SgiContext { + AVClass *class; + + int rle; +} SgiContext; + static av_cold int encode_init(AVCodecContext *avctx) { if (avctx->width > 65535 || avctx->height > 65535) { @@ -84,6 +92,7 @@ static int sgi_rle_encode(PutByteContext *pbc, const uint8_t *src, static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { + SgiContext *s = avctx->priv_data; const AVFrame * const p = frame; PutByteContext pbc; uint8_t *in_buf, *encode_buf; @@ -98,6 +107,13 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif +#if FF_API_CODER_TYPE +FF_DISABLE_DEPRECATION_WARNINGS + if (avctx->coder_type == FF_CODER_TYPE_RAW) + s->rle = 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + width = avctx->width; height = avctx->height; bytes_per_channel = 1; @@ -147,7 +163,7 @@ FF_ENABLE_DEPRECATION_WARNINGS tablesize = depth * height * 4; length = SGI_HEADER_SIZE; - if (avctx->coder_type == FF_CODER_TYPE_RAW) + if (!s->rle) length += depth * height * width; else // assume sgi_rle_encode() produces at most 2x size of input length += tablesize * 2 + depth * height * (2 * width + 1); @@ -159,7 +175,7 @@ FF_ENABLE_DEPRECATION_WARNINGS /* Encode header. */ bytestream2_put_be16(&pbc, SGI_MAGIC); - bytestream2_put_byte(&pbc, avctx->coder_type != FF_CODER_TYPE_RAW); /* RLE 1 - VERBATIM 0 */ + bytestream2_put_byte(&pbc, s->rle); /* RLE 1 - VERBATIM 0 */ bytestream2_put_byte(&pbc, bytes_per_channel); bytestream2_put_be16(&pbc, dimension); bytestream2_put_be16(&pbc, width); @@ -179,7 +195,7 @@ FF_ENABLE_DEPRECATION_WARNINGS /* The rest of the 512 byte header is unused. */ bytestream2_skip_p(&pbc, 404); - if (avctx->coder_type != FF_CODER_TYPE_RAW) { + if (s->rle) { PutByteContext taboff_pcb, tablen_pcb; /* Skip RLE offset table. */ @@ -243,11 +259,28 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; } +#define OFFSET(x) offsetof(SgiContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "rle", "Use run-length compression", OFFSET(rle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, + + { NULL }, +}; + +static const AVClass sgi_class = { + .class_name = "sgi", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_sgi_encoder = { .name = "sgi", .long_name = NULL_IF_CONFIG_SMALL("SGI image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SGI, + .priv_data_size = sizeof(SgiContext), + .priv_class = &sgi_class, .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { |