aboutsummaryrefslogtreecommitdiffstats
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
parentf1ccd076801444ab7f524cb13e0886faaf10fd50 (diff)
downloadffmpeg-be00ec832c519427cd92218abac77dafdc1d5487.tar.gz
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>
-rw-r--r--libavcodec/avcodec.h7
-rw-r--r--libavcodec/ffv1enc.c20
-rw-r--r--libavcodec/libopenh264enc.c11
-rw-r--r--libavcodec/libschroedingerenc.c31
-rw-r--r--libavcodec/libx264.c18
-rw-r--r--libavcodec/options_table.h2
-rw-r--r--libavcodec/sgienc.c39
-rw-r--r--libavcodec/sunrastenc.c31
-rw-r--r--libavcodec/targaenc.c34
-rw-r--r--libavcodec/version.h3
10 files changed, 181 insertions, 15 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 64328c80ea..dd78be27e7 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2326,6 +2326,7 @@ typedef struct AVCodecContext {
*/
int rc_initial_buffer_occupancy;
+#if FF_API_CODER_TYPE
#define FF_CODER_TYPE_VLC 0
#define FF_CODER_TYPE_AC 1
#define FF_CODER_TYPE_RAW 2
@@ -2334,11 +2335,11 @@ typedef struct AVCodecContext {
#define FF_CODER_TYPE_DEFLATE 4
#endif /* FF_API_UNUSED_MEMBERS */
/**
- * coder type
- * - encoding: Set by user.
- * - decoding: unused
+ * @deprecated use encoder private options instead
*/
+ attribute_deprecated
int coder_type;
+#endif /* FF_API_CODER_TYPE */
/**
* context model
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index fe144b821c..0158605b91 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -587,7 +587,12 @@ static av_cold int ffv1_encode_init(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}
- s->ac = avctx->coder_type > 0 ? AC_RANGE_CUSTOM_TAB : AC_GOLOMB_RICE;
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->coder_type != -1)
+ s->ac = avctx->coder_type > 0 ? AC_RANGE_CUSTOM_TAB : AC_GOLOMB_RICE;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->plane_count = 3;
switch (avctx->pix_fmt) {
@@ -1068,6 +1073,15 @@ static av_cold int ffv1_encode_close(AVCodecContext *avctx)
static const AVOption options[] = {
{ "slicecrc", "Protect slices with CRCs", OFFSET(ec), AV_OPT_TYPE_INT,
{ .i64 = -1 }, -1, 1, VE },
+ { "coder", "Coder type", OFFSET(ac), AV_OPT_TYPE_INT,
+ { .i64 = AC_GOLOMB_RICE }, 0, 2, VE, "coder" },
+ { "rice", "Golomb rice", 0, AV_OPT_TYPE_CONST,
+ { .i64 = AC_GOLOMB_RICE }, INT_MIN, INT_MAX, VE, "coder" },
+ { "range_def", "Range with default table", 0, AV_OPT_TYPE_CONST,
+ { .i64 = AC_RANGE_DEFAULT_TAB }, INT_MIN, INT_MAX, VE, "coder" },
+ { "range_tab", "Range with custom table", 0, AV_OPT_TYPE_CONST,
+ { .i64 = AC_RANGE_CUSTOM_TAB }, INT_MIN, INT_MAX, VE, "coder" },
+
{ NULL }
};
@@ -1078,10 +1092,12 @@ static const AVClass class = {
.version = LIBAVUTIL_VERSION_INT,
};
+#if FF_API_CODER_TYPE
static const AVCodecDefault ffv1_defaults[] = {
{ "coder", "-1" },
{ NULL },
};
+#endif
AVCodec ff_ffv1_encoder = {
.name = "ffv1",
@@ -1106,6 +1122,8 @@ AVCodec ff_ffv1_encoder = {
AV_PIX_FMT_NONE
},
+#if FF_API_CODER_TYPE
.defaults = ffv1_defaults,
+#endif
.priv_class = &class,
};
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index da03b29d51..7369c12a53 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -40,6 +40,7 @@ typedef struct SVCContext {
int max_nal_size;
int skip_frames;
int skipped;
+ int cabac;
} SVCContext;
#define OPENH264_VER_AT_LEAST(maj, min) \
@@ -58,6 +59,7 @@ static const AVOption options[] = {
{ "profile", "Set profile restrictions", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
{ "max_nal_size", "Set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "allow_skip_frames", "Allow skipping frames to hit the target bitrate", OFFSET(skip_frames), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL }
};
@@ -139,6 +141,13 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
(*s->encoder)->GetDefaultParams(s->encoder, &param);
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (!s->cabac)
+ s->cabac = avctx->coder_type == FF_CODER_TYPE_AC;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
param.fMaxFrameRate = avctx->time_base.den / avctx->time_base.num;
param.iPicWidth = avctx->width;
param.iPicHeight = avctx->height;
@@ -165,7 +174,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
param.iMultipleThreadIdc = avctx->thread_count;
if (s->profile && !strcmp(s->profile, "main"))
param.iEntropyCodingModeFlag = 1;
- else if (!s->profile && avctx->coder_type == FF_CODER_TYPE_AC)
+ else if (!s->profile && s->cabac)
param.iEntropyCodingModeFlag = 1;
param.sSpatialLayers[0].iVideoWidth = param.iPicWidth;
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index f390e4690e..e7c158aeaf 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -33,6 +33,7 @@
#include "libavutil/attributes.h"
#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
@@ -71,6 +72,9 @@ typedef struct SchroEncoderParams {
/* counter for frames submitted to encoder, used as dts */
int64_t dts;
+
+ /** enable noarith */
+ int noarith;
} SchroEncoderParams;
/**
@@ -165,9 +169,15 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
"gop_structure",
SCHRO_ENCODER_GOP_INTRA_ONLY);
- if (avctx->coder_type == FF_CODER_TYPE_VLC)
- schro_encoder_setting_set_double(p_schro_params->encoder,
- "enable_noarith", 1);
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->coder_type != FF_CODER_TYPE_VLC)
+ p_schro_params->noarith = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ schro_encoder_setting_set_double(p_schro_params->encoder,
+ "enable_noarith",
+ p_schro_params->noarith);
} else {
schro_encoder_setting_set_double(p_schro_params->encoder,
"au_distance", avctx->gop_size);
@@ -442,6 +452,20 @@ static int libschroedinger_encode_close(AVCodecContext *avctx)
return 0;
}
+#define OFFSET(x) offsetof(SchroEncoderParams, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "noarith", "Enable noarith", OFFSET(noarith), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
+
+ { NULL },
+};
+
+static const AVClass libschroedinger_class = {
+ .class_name = "libschroedinger",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
AVCodec ff_libschroedinger_encoder = {
.name = "libschroedinger",
@@ -449,6 +473,7 @@ AVCodec ff_libschroedinger_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_DIRAC,
.priv_data_size = sizeof(SchroEncoderParams),
+ .priv_class = &libschroedinger_class,
.init = libschroedinger_encode_init,
.encode2 = libschroedinger_encode_frame,
.close = libschroedinger_encode_close,
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index e2648f3e76..fe0247f9a3 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -78,6 +78,8 @@ typedef struct X264Context {
int nal_hrd;
int motion_est;
int forced_idr;
+ int coder;
+
char *x264_params;
} X264Context;
@@ -441,8 +443,12 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
if (avctx->keyint_min >= 0)
x4->params.i_keyint_min = avctx->keyint_min;
+#if FF_API_CODER_TYPE
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->coder_type >= 0)
- x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
+ x4->coder = avctx->coder_type == FF_CODER_TYPE_AC;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->me_cmp >= 0)
x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
@@ -518,6 +524,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
+ if (x4->coder >= 0)
+ x4->params.b_cabac = x4->coder;
+
if (x4->profile)
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
@@ -717,6 +726,11 @@ static const AVOption options[] = {
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "forced-idr", "If forwarding iframes, require them to be IDR frames.", OFFSET(forced_idr), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+ { "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, "coder" },
+ { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, VE, "coder" },
+ { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "coder" },
+ { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "coder" },
+
{ "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ NULL },
};
@@ -742,7 +756,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "subq", "-1" },
{ "b_strategy", "-1" },
{ "keyint_min", "-1" },
+#if FF_API_CODER_TYPE
{ "coder", "-1" },
+#endif
{ "cmp", "-1" },
{ "threads", AV_STRINGIFY(X264_THREADS_AUTO) },
{ "thread_type", "0" },
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index d30905ebf8..ba0cfeaa24 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -297,6 +297,7 @@ static const AVOption avcodec_options[] = {
{"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
#endif
{"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
+#if FF_API_CODER_TYPE
{"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"},
{"vlc", "variable length coder / Huffman coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"},
{"ac", "arithmetic coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_AC }, INT_MIN, INT_MAX, V|E, "coder"},
@@ -305,6 +306,7 @@ static const AVOption avcodec_options[] = {
#if FF_API_UNUSED_MEMBERS
{"deflate", "deflate-based coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"},
#endif /* FF_API_UNUSED_MEMBERS */
+#endif /* FF_API_CODER_TYPE */
{"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#if FF_API_XVMC
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
index 2da4f51d44..763de48123 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) {
@@ -83,6 +91,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;
@@ -97,6 +106,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;
@@ -146,7 +162,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);
@@ -160,7 +176,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);
@@ -180,7 +196,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. */
@@ -244,11 +260,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[]) {
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,
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index 290054de37..204ecfeac7 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -24,12 +24,19 @@
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "internal.h"
#include "rle.h"
#include "targa.h"
+typedef struct TargaContext {
+ AVClass *class;
+
+ int rle;
+} TargaContext;
+
/**
* RLE compress the image, with maximum size of out_size
* @param outbuf Output buffer
@@ -78,6 +85,7 @@ static int targa_encode_normal(uint8_t *outbuf, const AVFrame *pic, int bpp, int
static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet)
{
+ TargaContext *s = avctx->priv_data;
int bpp, picsize, datasize = -1, ret;
uint8_t *out;
@@ -125,8 +133,15 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
out = pkt->data + 18; /* skip past the header we just output */
+#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
+
/* try RLE compression */
- if (avctx->coder_type != FF_CODER_TYPE_RAW)
+ if (s->rle)
datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
/* if that worked well, mark the picture as RLE compressed */
@@ -162,11 +177,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
+#define OFFSET(x) offsetof(TargaContext, 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 targa_class = {
+ .class_name = "targa",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_targa_encoder = {
.name = "targa",
.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_TARGA,
+ .priv_data_size = sizeof(TargaContext),
+ .priv_class = &targa_class,
.init = targa_encode_init,
.encode2 = targa_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
diff --git a/libavcodec/version.h b/libavcodec/version.h
index afa76001eb..c18d4cfc86 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -183,5 +183,8 @@
#ifndef FF_API_VBV_DELAY
#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_CODER_TYPE
+#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
#endif /* AVCODEC_VERSION_H */