*/
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
#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
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) {
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 }
};
.version = LIBAVUTIL_VERSION_INT,
};
+#if FF_API_CODER_TYPE
static const AVCodecDefault ffv1_defaults[] = {
{ "coder", "-1" },
{ NULL },
};
+#endif
AVCodec ff_ffv1_encoder = {
.name = "ffv1",
AV_PIX_FMT_NONE
},
+#if FF_API_CODER_TYPE
.defaults = ffv1_defaults,
+#endif
.priv_class = &class,
};
int max_nal_size;
int skip_frames;
int skipped;
+ int cabac;
} SVCContext;
#define OPENH264_VER_AT_LEAST(maj, min) \
{ "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 }
};
(*s->encoder)->GetDefaultParams(s->encoder, ¶m);
+#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;
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;
#include "libavutil/attributes.h"
#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
/* counter for frames submitted to encoder, used as dts */
int64_t dts;
+
+ /** enable noarith */
+ int noarith;
} SchroEncoderParams;
/**
"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);
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",
.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,
int nal_hrd;
int motion_est;
int forced_idr;
+ int coder;
+
char *x264_params;
} X264Context;
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;
#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);
{ "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 },
};
{ "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" },
{"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"},
#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
* 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"
#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) {
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;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
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;
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);
/* 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);
/* 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. */
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[]) {
* 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"
{
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;
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
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;
}
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",
.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,
#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
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;
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 */
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[]){
#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 */