summaryrefslogtreecommitdiff
path: root/libavcodec/sunrastenc.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-11-30 12:17:31 -0500
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-12-07 11:01:22 -0500
commitbe00ec832c519427cd92218abac77dafdc1d5487 (patch)
tree970ca330447b69c3dc6b1efc734cbdffd613e4eb /libavcodec/sunrastenc.c
parentf1ccd076801444ab7f524cb13e0886faaf10fd50 (diff)
lavc: Deprecate coder_type and its symbols
Most option values are simply unused or ignored and in practice the majory of codecs only need to check whether to enable rle or not. Add appropriate codec private options which better expose the allowed features. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/sunrastenc.c')
-rw-r--r--libavcodec/sunrastenc.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c
index ddf624eee2..411d184a14 100644
--- a/libavcodec/sunrastenc.c
+++ b/libavcodec/sunrastenc.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"
@@ -141,6 +143,8 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
{
SUNRASTContext *s = avctx->priv_data;
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
switch (avctx->coder_type) {
case FF_CODER_TYPE_RLE:
s->type = RT_BYTE_ENCODED;
@@ -152,6 +156,11 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n");
return AVERROR(EINVAL);
}
+FF_ENABLE_DEPRECATION_WARNINGS
+ if (s->type != RT_BYTE_ENCODED && s->type != RT_STANDARD)
+#endif
+ // adjust boolean option to RT equivalent
+ s->type++;
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
@@ -180,8 +189,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return AVERROR_BUG;
}
s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3);
- s->size = 32 + s->maplength +
- s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1);
+ s->size = 32 + s->maplength + s->length * s->type;
return 0;
}
@@ -210,10 +218,27 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return 0;
}
+#define OFFSET(x) offsetof(SUNRASTContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "rle", "Use run-length compression", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
+
+ { NULL },
+};
+
+static const AVClass utvideo_class = {
+ .class_name = "sunrast",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+#if FF_API_CODER_TYPE
static const AVCodecDefault sunrast_defaults[] = {
{ "coder", "rle" },
{ NULL },
};
+#endif
AVCodec ff_sunrast_encoder = {
.name = "sunrast",
@@ -223,7 +248,9 @@ AVCodec ff_sunrast_encoder = {
.priv_data_size = sizeof(SUNRASTContext),
.init = sunrast_encode_init,
.encode2 = sunrast_encode_frame,
+#if FF_API_CODER_TYPE
.defaults = sunrast_defaults,
+#endif
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24,
AV_PIX_FMT_PAL8,
AV_PIX_FMT_GRAY8,