aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-02-03 16:49:19 +0000
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-02-03 16:49:19 +0000
commitf3af379b5c1816271b1afce0ccb2a935dc29940c (patch)
tree629aec01a415bfe4a0552d31292adbb01b31d180 /libavcodec
parent908d010b12fadc36d8cadf6bba5e073e23b9603c (diff)
parent2862b63783b5556f7f3fb2d097629bc6879f833a (diff)
downloadffmpeg-f3af379b5c1816271b1afce0ccb2a935dc29940c.tar.gz
Merge commit '2862b63783b5556f7f3fb2d097629bc6879f833a'
* commit '2862b63783b5556f7f3fb2d097629bc6879f833a': lavc: Move prediction_method to codec private options Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h10
-rw-r--r--libavcodec/huffyuvenc.c11
-rw-r--r--libavcodec/j2kenc.c13
-rw-r--r--libavcodec/jpeglsenc.c39
-rw-r--r--libavcodec/libutvideo.h2
-rw-r--r--libavcodec/libutvideoenc.cpp33
-rw-r--r--libavcodec/ljpegenc.c43
-rw-r--r--libavcodec/mjpegenc.c17
-rw-r--r--libavcodec/mjpegenc_common.c4
-rw-r--r--libavcodec/mjpegenc_common.h2
-rw-r--r--libavcodec/mpegvideo.h1
-rw-r--r--libavcodec/mpegvideo_enc.c5
-rw-r--r--libavcodec/options_table.h2
-rw-r--r--libavcodec/pngenc.c21
-rw-r--r--libavcodec/snow.h2
-rw-r--r--libavcodec/snowenc.c14
-rw-r--r--libavcodec/utvideo.c2
-rw-r--r--libavcodec/utvideo.h1
-rw-r--r--libavcodec/utvideoenc.c29
19 files changed, 221 insertions, 30 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3dd4c4c3fb..b40e317edc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1908,15 +1908,15 @@ typedef struct AVCodecContext {
* - decoding: Set by user (or 0).
*/
int slice_count;
- /**
- * prediction method (needed for huffyuv)
- * - encoding: Set by user.
- * - decoding: unused
- */
+
+#if FF_API_PRIVATE_OPT
+ /** @deprecated use encoder private options instead */
+ attribute_deprecated
int prediction_method;
#define FF_PRED_LEFT 0
#define FF_PRED_PLANE 1
#define FF_PRED_MEDIAN 2
+#endif
/**
* slice offsets in the frame in bytes
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index c70f1fee89..572de16a1f 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -319,7 +319,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
avctx->bits_per_coded_sample = s->bitstream_bpp;
s->decorrelate = s->bitstream_bpp >= 24 && !s->yuv && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR);
- s->predictor = avctx->prediction_method;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->predictor = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_ME ? 1 : 0;
if (s->context) {
if (s->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) {
@@ -1057,6 +1062,10 @@ static av_cold int encode_end(AVCodecContext *avctx)
{ "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism", \
OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 1 }, \
0, 1, VE }, \
+ { "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, "pred" }, \
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, "pred" }, \
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, "pred" }, \
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, "pred" }, \
static const AVOption normal_options[] = {
COMMON_OPTIONS
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 152da8bdfd..2cd837d8be 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -88,6 +88,7 @@ typedef struct {
Jpeg2000Tile *tile;
int format;
+ int pred;
} Jpeg2000EncoderContext;
@@ -1069,6 +1070,13 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
s->avctx = avctx;
av_log(s->avctx, AV_LOG_DEBUG, "init\n");
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
// defaults:
// TODO: implement setting non-standard precinct size
memset(codsty->log2_prec_widths , 15, sizeof(codsty->log2_prec_widths ));
@@ -1077,7 +1085,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
codsty->nreslevels = 7;
codsty->log2_cblk_width = 4;
codsty->log2_cblk_height = 4;
- codsty->transform = avctx->prediction_method ? FF_DWT53 : FF_DWT97_INT;
+ codsty->transform = s->pred ? FF_DWT53 : FF_DWT97_INT;
qntsty->nguardbits = 1;
@@ -1139,6 +1147,9 @@ static const AVOption options[] = {
{ "jp2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CODEC_JP2 }, 0, 0, VE, "format" },
{ "tile_width", "Tile Width", OFFSET(tile_width), AV_OPT_TYPE_INT, { .i64 = 256 }, 1, 1<<30, VE, },
{ "tile_height", "Tile Height", OFFSET(tile_height), AV_OPT_TYPE_INT, { .i64 = 256 }, 1, 1<<30, VE, },
+ { "pred", "DWT Type", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "pred" },
+ { "dwt97int", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "dwt53", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
{ NULL }
};
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 71e87e7748..cd16184c18 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -35,6 +35,12 @@
#include "mjpegenc.h"
#include "jpegls.h"
+typedef struct JPEGLSContext {
+ AVClass *class;
+
+ int pred;
+} JPEGLSContext;
+
/**
* Encode error from regular symbol
*/
@@ -250,8 +256,8 @@ static void ls_store_lse(JLSState *state, PutBitContext *pb)
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
+ JPEGLSContext *ctx = avctx->priv_data;
const AVFrame *const p = pict;
- const int near = avctx->prediction_method;
PutBitContext pb, pb2;
GetBitContext gb;
uint8_t *buf2 = NULL;
@@ -262,6 +268,13 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
int i, size, ret;
int comps;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ ctx->pred = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16)
comps = 1;
@@ -300,7 +313,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
put_bits(&pb, 8, i); // component ID
put_bits(&pb, 8, 0); // mapping index: none
}
- put_bits(&pb, 8, near);
+ put_bits(&pb, 8, ctx->pred);
put_bits(&pb, 8, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
put_bits(&pb, 8, 0); // point transform: none
@@ -309,7 +322,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
goto memfail;
/* initialize JPEG-LS state from JPEG parameters */
- state->near = near;
+ state->near = ctx->pred;
state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state);
@@ -432,11 +445,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
+#define OFFSET(x) offsetof(JPEGLSContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass jpegls_class = {
+ .class_name = "jpegls",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_jpegls_encoder = {
.name = "jpegls",
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
+ .priv_data_size = sizeof(JPEGLSContext),
+ .priv_class = &jpegls_class,
.init = encode_init_ls,
.capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY,
.encode2 = encode_picture_ls,
diff --git a/libavcodec/libutvideo.h b/libavcodec/libutvideo.h
index 5fb1174c84..0c03097bb7 100644
--- a/libavcodec/libutvideo.h
+++ b/libavcodec/libutvideo.h
@@ -62,9 +62,11 @@ typedef struct {
} UtVideoExtra;
typedef struct {
+ const AVClass *c;
CCodec *codec;
unsigned int buf_size;
uint8_t *buffer;
+ int pred;
} UtVideoContext;
#endif /* AVCODEC_LIBUTVIDEO_H */
diff --git a/libavcodec/libutvideoenc.cpp b/libavcodec/libutvideoenc.cpp
index 96d8fe1030..7a2c37fe9b 100644
--- a/libavcodec/libutvideoenc.cpp
+++ b/libavcodec/libutvideoenc.cpp
@@ -73,8 +73,15 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ utv->pred = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
/* Check before we alloc anything */
- if (avctx->prediction_method != 0 && avctx->prediction_method != 2) {
+ if (utv->pred != 0 && utv->pred != 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid prediction method.\n");
return AVERROR(EINVAL);
}
@@ -218,6 +225,28 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
return 0;
}
+#define OFFSET(x) offsetof(UtVideoContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+ { "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, 0, 0, 2, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, 0, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, 2, INT_MIN, INT_MAX, VE, "pred" },
+};
+
+static const AVClass utvideo_class = {
+ "libutvideo",
+ av_default_item_name,
+ options.
+ LIBAVUTIL_VERSION,
+ 0,
+ 0,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+};
+
AVCodec ff_libutvideo_encoder = {
"libutvideo",
NULL_IF_CONFIG_SMALL("Ut Video"),
@@ -233,7 +262,7 @@ AVCodec ff_libutvideo_encoder = {
NULL, /* sample_fmts */
NULL, /* channel_layouts */
0, /* max_lowres */
- NULL, /* priv_class */
+ &utvideo_class, /* priv_class */
NULL, /* profiles */
sizeof(UtVideoContext),
NULL, /* next */
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 7f2dd602db..afaab05568 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -43,6 +43,7 @@
#include "mjpegenc.h"
typedef struct LJpegEncContext {
+ AVClass *class;
IDCTDSPContext idsp;
ScanTable scantable;
uint16_t matrix[64];
@@ -56,6 +57,7 @@ typedef struct LJpegEncContext {
uint8_t huff_size_dc_chrominance[12];
uint16_t (*scratch)[4];
+ int pred;
} LJpegEncContext;
static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
@@ -66,15 +68,21 @@ static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
const int height = frame->height;
const int linesize = frame->linesize[0];
uint16_t (*buffer)[4] = s->scratch;
- const int predictor = avctx->prediction_method+1;
int left[4], top[4], topleft[4];
int x, y, i;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method + 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (9 - 1);
for (y = 0; y < height; y++) {
- const int modified_predictor = y ? predictor : 1;
+ const int modified_predictor = y ? s->pred : 1;
uint8_t *ptr = frame->data[0] + (linesize * y);
if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < width * 4 * 4) {
@@ -189,12 +197,18 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb,
const AVFrame *frame)
{
- const int predictor = avctx->prediction_method + 1;
LJpegEncContext *s = avctx->priv_data;
const int mb_width = (avctx->width + s->hsample[0] - 1) / s->hsample[0];
const int mb_height = (avctx->height + s->vsample[0] - 1) / s->vsample[0];
int mb_x, mb_y;
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method + 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
for (mb_y = 0; mb_y < mb_height; mb_y++) {
if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) <
mb_width * 4 * 3 * s->hsample[0] * s->vsample[0]) {
@@ -203,7 +217,7 @@ static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb,
}
for (mb_x = 0; mb_x < mb_width; mb_x++)
- ljpeg_encode_yuv_mb(s, pb, frame, predictor, mb_x, mb_y);
+ ljpeg_encode_yuv_mb(s, pb, frame, s->pred, mb_x, mb_y);
}
return 0;
@@ -237,7 +251,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
init_put_bits(&pb, pkt->data, pkt->size);
ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable,
- s->matrix, s->matrix);
+ s->pred, s->matrix, s->matrix);
header_bits = put_bits_count(&pb);
@@ -319,12 +333,31 @@ fail:
return AVERROR(ENOMEM);
}
+#define OFFSET(x) offsetof(LJpegEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass ljpeg_class = {
+ .class_name = "ljpeg",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_ljpeg_encoder = {
.name = "ljpeg",
.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_LJPEG,
.priv_data_size = sizeof(LJpegEncContext),
+ .priv_class = &ljpeg_class,
.init = ljpeg_encode_init,
.encode2 = ljpeg_encode_frame,
.close = ljpeg_encode_close,
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index f15de58c2c..b751d1402a 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -253,12 +253,24 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
return ret;
}
+#define OFFSET(x) offsetof(MpegEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+FF_MPV_COMMON_OPTS
+{ "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 3, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, VE, "pred" },
+
+{ NULL},
+};
+
#if CONFIG_MJPEG_ENCODER
static const AVClass mjpeg_class = {
.class_name = "mjpeg encoder",
.item_name = av_default_item_name,
- .option = ff_mpv_generic_options,
+ .option = options,
.version = LIBAVUTIL_VERSION_INT,
};
@@ -268,6 +280,7 @@ AVCodec ff_mjpeg_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MJPEG,
.priv_data_size = sizeof(MpegEncContext),
+ .priv_class = &mjpeg_class,
.init = ff_mpv_encode_init,
.encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end,
@@ -282,7 +295,7 @@ AVCodec ff_mjpeg_encoder = {
static const AVClass amv_class = {
.class_name = "amv encoder",
.item_name = av_default_item_name,
- .option = ff_mpv_generic_options,
+ .option = options,
.version = LIBAVUTIL_VERSION_INT,
};
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 7dadda8bf9..099d817d5f 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -190,7 +190,7 @@ void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4
}
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
- ScanTable *intra_scantable,
+ ScanTable *intra_scantable, int pred,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64])
{
@@ -282,7 +282,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
put_bits(pb, 4, 0); /* AC huffman table index */
}
- put_bits(pb, 8, lossless ? avctx->prediction_method + 1 : 0); /* Ss (not used) */
+ put_bits(pb, 8, lossless ? pred : 0); /* Ss (not used) */
switch (avctx->codec_id) {
case AV_CODEC_ID_MJPEG: put_bits(pb, 8, 63); break; /* Se (not used) */
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index 924cb36262..6e51ca04f8 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -29,7 +29,7 @@
#include "put_bits.h"
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
- ScanTable *intra_scantable,
+ ScanTable *intra_scantable, int pred,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64]);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 5836afd034..6152238d55 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -419,6 +419,7 @@ typedef struct MpegEncContext {
/* MJPEG specific */
struct MJpegContext *mjpeg_ctx;
int esc_pos;
+ int pred;
/* MSMPEG4 specific */
int mv_table_index;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index fde3fd8cf9..a7e3206737 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1077,6 +1077,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->brd_scale)
s->brd_scale = avctx->brd_scale;
+
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method + 1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
@@ -3888,7 +3891,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
- s->intra_matrix, s->chroma_intra_matrix);
+ s->pred, s->intra_matrix, s->chroma_intra_matrix);
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index efe6d3c919..603a683c6a 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -246,10 +246,12 @@ static const AVOption avcodec_options[] = {
{"deblock", "use strong deblock filter for damaged MBs", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"},
{"favor_inter", "favor predicting from the previous frame", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_FAVOR_INTER }, INT_MIN, INT_MAX, V|D, "ec"},
{"bits_per_coded_sample", NULL, OFFSET(bits_per_coded_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
+#if FF_API_PRIVATE_OPT
{"pred", "prediction method", OFFSET(prediction_method), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "pred"},
{"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"},
{"plane", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},
{"median", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"},
+#endif
{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E},
{"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},
{"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index a6233075c1..e9e8bc2782 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -999,9 +999,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_huffyuvencdsp_init(&s->hdsp);
- s->filter_type = av_clip(avctx->prediction_method,
- PNG_FILTER_VALUE_NONE,
- PNG_FILTER_VALUE_MIXED);
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->filter_type = av_clip(avctx->prediction_method,
+ PNG_FILTER_VALUE_NONE,
+ PNG_FILTER_VALUE_MIXED);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (avctx->pix_fmt == AV_PIX_FMT_MONOBLACK)
s->filter_type = PNG_FILTER_VALUE_NONE;
@@ -1087,7 +1093,14 @@ static av_cold int png_enc_close(AVCodecContext *avctx)
static const AVOption options[] = {
{"dpi", "Set image resolution (in dots per inch)", OFFSET(dpi), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 0x10000, VE},
{"dpm", "Set image resolution (in dots per meter)", OFFSET(dpm), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 0x10000, VE},
- { NULL }
+ { "pred", "Prediction method", OFFSET(filter_type), AV_OPT_TYPE_INT, { .i64 = PNG_FILTER_VALUE_NONE }, PNG_FILTER_VALUE_NONE, PNG_FILTER_VALUE_MIXED, VE, "pred" },
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_NONE }, INT_MIN, INT_MAX, VE, "pred" },
+ { "sub", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_SUB }, INT_MIN, INT_MAX, VE, "pred" },
+ { "up", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_UP }, INT_MIN, INT_MAX, VE, "pred" },
+ { "avg", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_AVG }, INT_MIN, INT_MAX, VE, "pred" },
+ { "paeth", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_PAETH }, INT_MIN, INT_MAX, VE, "pred" },
+ { "mixed", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PNG_FILTER_VALUE_MIXED }, INT_MIN, INT_MAX, VE, "pred" },
+ { NULL},
};
static const AVClass pngenc_class = {
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index c72c121439..d126d68a49 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -187,6 +187,8 @@ typedef struct SnowContext{
AVMotionVector *avmv;
int avmv_index;
uint64_t encoding_error[AV_NUM_DATA_POINTERS];
+
+ int pred;
}SnowContext;
/* Tables */
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index ab707c86f4..b1d177d3b8 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -41,7 +41,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
int plane_index, ret;
int i;
- if(avctx->prediction_method == DWT_97
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->prediction_method)
+ s->pred = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if(s->pred == DWT_97
&& (avctx->flags & AV_CODEC_FLAG_QSCALE)
&& avctx->global_quality == 0){
av_log(avctx, AV_LOG_ERROR, "The 9/7 wavelet is incompatible with lossless mode.\n");
@@ -54,7 +61,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type
+ s->spatial_decomposition_type= s->pred; //FIXME add decorrelator type r transform_type
s->mv_scale = (avctx->flags & AV_CODEC_FLAG_QPEL) ? 2 : 4;
s->block_max_depth= (avctx->flags & AV_CODEC_FLAG_4MV ) ? 1 : 0;
@@ -1917,6 +1924,9 @@ static const AVOption options[] = {
{ "intra_penalty", "Penalty for intra blocks in block decission", OFFSET(intra_penalty), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "iterative_dia_size", "Dia size for the iterative ME", OFFSET(iterative_dia_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, VE },
+ { "pred", "Spatial decomposition type", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, DWT_97, DWT_53, VE, "pred" },
+ { "dwt97", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
+ { "dwt53", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
{ NULL },
};
diff --git a/libavcodec/utvideo.c b/libavcodec/utvideo.c
index 308adb75d9..b14e56e0d8 100644
--- a/libavcodec/utvideo.c
+++ b/libavcodec/utvideo.c
@@ -26,9 +26,11 @@
#include "utvideo.h"
+#if FF_API_PRIVATE_OPT
const int ff_ut_pred_order[5] = {
PRED_LEFT, PRED_MEDIAN, PRED_MEDIAN, PRED_NONE, PRED_GRADIENT
};
+#endif
const int ff_ut_rgb_order[4] = { 1, 2, 0, 3 }; // G, B, R, A
diff --git a/libavcodec/utvideo.h b/libavcodec/utvideo.h
index 78c3ec54dc..84eec66338 100644
--- a/libavcodec/utvideo.h
+++ b/libavcodec/utvideo.h
@@ -65,6 +65,7 @@ extern const int ff_ut_pred_order[5];
extern const int ff_ut_rgb_order[4];
typedef struct UtvideoContext {
+ const AVClass *class;
AVCodecContext *avctx;
BswapDSPContext bdsp;
HuffYUVEncDSPContext hdsp;
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index b8e1cc33e5..00185cfd9a 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -26,6 +26,8 @@
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "internal.h"
#include "bswapdsp.h"
@@ -111,6 +113,8 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
ff_bswapdsp_init(&c->bdsp);
ff_huffyuvencdsp_init(&c->hdsp);
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
/* Check the prediction method, and error out if unsupported */
if (avctx->prediction_method < 0 || avctx->prediction_method > 4) {
av_log(avctx, AV_LOG_WARNING,
@@ -126,7 +130,10 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
}
/* Convert from libavcodec prediction type to Ut Video's */
- c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+ if (avctx->prediction_method)
+ c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (c->frame_pred == PRED_GRADIENT) {
av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n");
@@ -629,12 +636,32 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
+#define OFFSET(x) offsetof(UtvideoContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+{ "pred", "Prediction method", OFFSET(frame_pred), AV_OPT_TYPE_INT, { .i64 = PRED_LEFT }, PRED_NONE, PRED_MEDIAN, VE, "pred" },
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_NONE }, INT_MIN, INT_MAX, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_LEFT }, INT_MIN, INT_MAX, VE, "pred" },
+ { "gradient", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_GRADIENT }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_MEDIAN }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass utvideo_class = {
+ .class_name = "utvideo",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_utvideo_encoder = {
.name = "utvideo",
.long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_UTVIDEO,
.priv_data_size = sizeof(UtvideoContext),
+ .priv_class = &utvideo_class,
.init = utvideo_encode_init,
.encode2 = utvideo_encode_frame,
.close = utvideo_encode_close,