Merge commit '2862b63783b5556f7f3fb2d097629bc6879f833a'

* commit '2862b63783b5556f7f3fb2d097629bc6879f833a':
  lavc: Move prediction_method to codec private options

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2016-02-03 16:49:19 +00:00
commit f3af379b5c
20 changed files with 225 additions and 34 deletions

View File

@ -1908,15 +1908,15 @@ typedef struct AVCodecContext {
* - decoding: Set by user (or 0). * - decoding: Set by user (or 0).
*/ */
int slice_count; int slice_count;
/**
* prediction method (needed for huffyuv) #if FF_API_PRIVATE_OPT
* - encoding: Set by user. /** @deprecated use encoder private options instead */
* - decoding: unused attribute_deprecated
*/
int prediction_method; int prediction_method;
#define FF_PRED_LEFT 0 #define FF_PRED_LEFT 0
#define FF_PRED_PLANE 1 #define FF_PRED_PLANE 1
#define FF_PRED_MEDIAN 2 #define FF_PRED_MEDIAN 2
#endif
/** /**
* slice offsets in the frame in bytes * slice offsets in the frame in bytes

View File

@ -319,7 +319,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
avctx->bits_per_coded_sample = s->bitstream_bpp; avctx->bits_per_coded_sample = s->bitstream_bpp;
s->decorrelate = s->bitstream_bpp >= 24 && !s->yuv && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR); 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; s->interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_ME ? 1 : 0;
if (s->context) { if (s->context) {
if (s->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) { 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", \ { "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism", \
OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 1 }, \ OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 1 }, \
0, 1, VE }, \ 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[] = { static const AVOption normal_options[] = {
COMMON_OPTIONS COMMON_OPTIONS

View File

@ -88,6 +88,7 @@ typedef struct {
Jpeg2000Tile *tile; Jpeg2000Tile *tile;
int format; int format;
int pred;
} Jpeg2000EncoderContext; } Jpeg2000EncoderContext;
@ -1069,6 +1070,13 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
s->avctx = avctx; s->avctx = avctx;
av_log(s->avctx, AV_LOG_DEBUG, "init\n"); 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: // defaults:
// TODO: implement setting non-standard precinct size // TODO: implement setting non-standard precinct size
memset(codsty->log2_prec_widths , 15, sizeof(codsty->log2_prec_widths )); 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->nreslevels = 7;
codsty->log2_cblk_width = 4; codsty->log2_cblk_width = 4;
codsty->log2_cblk_height = 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; 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" }, { "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_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, }, { "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 } { NULL }
}; };

View File

@ -35,6 +35,12 @@
#include "mjpegenc.h" #include "mjpegenc.h"
#include "jpegls.h" #include "jpegls.h"
typedef struct JPEGLSContext {
AVClass *class;
int pred;
} JPEGLSContext;
/** /**
* Encode error from regular symbol * 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, static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet) const AVFrame *pict, int *got_packet)
{ {
JPEGLSContext *ctx = avctx->priv_data;
const AVFrame *const p = pict; const AVFrame *const p = pict;
const int near = avctx->prediction_method;
PutBitContext pb, pb2; PutBitContext pb, pb2;
GetBitContext gb; GetBitContext gb;
uint8_t *buf2 = NULL; uint8_t *buf2 = NULL;
@ -262,6 +268,13 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
int i, size, ret; int i, size, ret;
int comps; 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 || if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16) avctx->pix_fmt == AV_PIX_FMT_GRAY16)
comps = 1; 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, i); // component ID
put_bits(&pb, 8, 0); // mapping index: none 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, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
put_bits(&pb, 8, 0); // point transform: none put_bits(&pb, 8, 0); // point transform: none
@ -309,7 +322,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
goto memfail; goto memfail;
/* initialize JPEG-LS state from JPEG parameters */ /* 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; state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
ff_jpegls_reset_coding_parameters(state, 0); ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state); ff_jpegls_init_state(state);
@ -432,11 +445,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0; 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 = { AVCodec ff_jpegls_encoder = {
.name = "jpegls", .name = "jpegls",
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS, .id = AV_CODEC_ID_JPEGLS,
.priv_data_size = sizeof(JPEGLSContext),
.priv_class = &jpegls_class,
.init = encode_init_ls, .init = encode_init_ls,
.capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY, .capabilities = AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_INTRA_ONLY,
.encode2 = encode_picture_ls, .encode2 = encode_picture_ls,

View File

@ -62,9 +62,11 @@ typedef struct {
} UtVideoExtra; } UtVideoExtra;
typedef struct { typedef struct {
const AVClass *c;
CCodec *codec; CCodec *codec;
unsigned int buf_size; unsigned int buf_size;
uint8_t *buffer; uint8_t *buffer;
int pred;
} UtVideoContext; } UtVideoContext;
#endif /* AVCODEC_LIBUTVIDEO_H */ #endif /* AVCODEC_LIBUTVIDEO_H */

View File

@ -73,8 +73,15 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL); 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 */ /* 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"); av_log(avctx, AV_LOG_ERROR, "Invalid prediction method.\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
@ -218,6 +225,28 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
return 0; 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 = { AVCodec ff_libutvideo_encoder = {
"libutvideo", "libutvideo",
NULL_IF_CONFIG_SMALL("Ut Video"), NULL_IF_CONFIG_SMALL("Ut Video"),
@ -233,7 +262,7 @@ AVCodec ff_libutvideo_encoder = {
NULL, /* sample_fmts */ NULL, /* sample_fmts */
NULL, /* channel_layouts */ NULL, /* channel_layouts */
0, /* max_lowres */ 0, /* max_lowres */
NULL, /* priv_class */ &utvideo_class, /* priv_class */
NULL, /* profiles */ NULL, /* profiles */
sizeof(UtVideoContext), sizeof(UtVideoContext),
NULL, /* next */ NULL, /* next */

View File

@ -43,6 +43,7 @@
#include "mjpegenc.h" #include "mjpegenc.h"
typedef struct LJpegEncContext { typedef struct LJpegEncContext {
AVClass *class;
IDCTDSPContext idsp; IDCTDSPContext idsp;
ScanTable scantable; ScanTable scantable;
uint16_t matrix[64]; uint16_t matrix[64];
@ -56,6 +57,7 @@ typedef struct LJpegEncContext {
uint8_t huff_size_dc_chrominance[12]; uint8_t huff_size_dc_chrominance[12];
uint16_t (*scratch)[4]; uint16_t (*scratch)[4];
int pred;
} LJpegEncContext; } LJpegEncContext;
static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb, 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 height = frame->height;
const int linesize = frame->linesize[0]; const int linesize = frame->linesize[0];
uint16_t (*buffer)[4] = s->scratch; uint16_t (*buffer)[4] = s->scratch;
const int predictor = avctx->prediction_method+1;
int left[4], top[4], topleft[4]; int left[4], top[4], topleft[4];
int x, y, i; 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++) for (i = 0; i < 4; i++)
buffer[0][i] = 1 << (9 - 1); buffer[0][i] = 1 << (9 - 1);
for (y = 0; y < height; y++) { 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); uint8_t *ptr = frame->data[0] + (linesize * y);
if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < width * 4 * 4) { 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, static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb,
const AVFrame *frame) const AVFrame *frame)
{ {
const int predictor = avctx->prediction_method + 1;
LJpegEncContext *s = avctx->priv_data; LJpegEncContext *s = avctx->priv_data;
const int mb_width = (avctx->width + s->hsample[0] - 1) / s->hsample[0]; 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]; const int mb_height = (avctx->height + s->vsample[0] - 1) / s->vsample[0];
int mb_x, mb_y; 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++) { for (mb_y = 0; mb_y < mb_height; mb_y++) {
if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) < if (pb->buf_end - pb->buf - (put_bits_count(pb) >> 3) <
mb_width * 4 * 3 * s->hsample[0] * s->vsample[0]) { 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++) 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; return 0;
@ -237,7 +251,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
init_put_bits(&pb, pkt->data, pkt->size); init_put_bits(&pb, pkt->data, pkt->size);
ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable, 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); header_bits = put_bits_count(&pb);
@ -319,12 +333,31 @@ fail:
return AVERROR(ENOMEM); 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 = { AVCodec ff_ljpeg_encoder = {
.name = "ljpeg", .name = "ljpeg",
.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"), .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_LJPEG, .id = AV_CODEC_ID_LJPEG,
.priv_data_size = sizeof(LJpegEncContext), .priv_data_size = sizeof(LJpegEncContext),
.priv_class = &ljpeg_class,
.init = ljpeg_encode_init, .init = ljpeg_encode_init,
.encode2 = ljpeg_encode_frame, .encode2 = ljpeg_encode_frame,
.close = ljpeg_encode_close, .close = ljpeg_encode_close,

View File

@ -253,12 +253,24 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
return ret; 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 #if CONFIG_MJPEG_ENCODER
static const AVClass mjpeg_class = { static const AVClass mjpeg_class = {
.class_name = "mjpeg encoder", .class_name = "mjpeg encoder",
.item_name = av_default_item_name, .item_name = av_default_item_name,
.option = ff_mpv_generic_options, .option = options,
.version = LIBAVUTIL_VERSION_INT, .version = LIBAVUTIL_VERSION_INT,
}; };
@ -268,6 +280,7 @@ AVCodec ff_mjpeg_encoder = {
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_MJPEG, .id = AV_CODEC_ID_MJPEG,
.priv_data_size = sizeof(MpegEncContext), .priv_data_size = sizeof(MpegEncContext),
.priv_class = &mjpeg_class,
.init = ff_mpv_encode_init, .init = ff_mpv_encode_init,
.encode2 = ff_mpv_encode_picture, .encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end, .close = ff_mpv_encode_end,
@ -282,7 +295,7 @@ AVCodec ff_mjpeg_encoder = {
static const AVClass amv_class = { static const AVClass amv_class = {
.class_name = "amv encoder", .class_name = "amv encoder",
.item_name = av_default_item_name, .item_name = av_default_item_name,
.option = ff_mpv_generic_options, .option = options,
.version = LIBAVUTIL_VERSION_INT, .version = LIBAVUTIL_VERSION_INT,
}; };

View File

@ -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, 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 luma_intra_matrix[64],
uint16_t chroma_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, 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) { switch (avctx->codec_id) {
case AV_CODEC_ID_MJPEG: put_bits(pb, 8, 63); break; /* Se (not used) */ case AV_CODEC_ID_MJPEG: put_bits(pb, 8, 63); break; /* Se (not used) */

View File

@ -29,7 +29,7 @@
#include "put_bits.h" #include "put_bits.h"
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, 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 luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64]); uint16_t chroma_intra_matrix[64]);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits); void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);

View File

@ -419,6 +419,7 @@ typedef struct MpegEncContext {
/* MJPEG specific */ /* MJPEG specific */
struct MJpegContext *mjpeg_ctx; struct MJpegContext *mjpeg_ctx;
int esc_pos; int esc_pos;
int pred;
/* MSMPEG4 specific */ /* MSMPEG4 specific */
int mv_table_index; int mv_table_index;

View File

@ -1077,6 +1077,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_DISABLE_DEPRECATION_WARNINGS FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->brd_scale) if (avctx->brd_scale)
s->brd_scale = avctx->brd_scale; s->brd_scale = avctx->brd_scale;
if (avctx->prediction_method)
s->pred = avctx->prediction_method + 1;
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
@ -3888,7 +3891,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
case FMT_MJPEG: case FMT_MJPEG:
if (CONFIG_MJPEG_ENCODER) if (CONFIG_MJPEG_ENCODER)
ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable, 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; break;
case FMT_H261: case FMT_H261:
if (CONFIG_H261_ENCODER) if (CONFIG_H261_ENCODER)

View File

@ -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"}, {"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"}, {"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}, {"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"}, {"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"}, {"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"}, {"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"}, {"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}, {"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"}, {"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"}, {"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},

View File

@ -999,9 +999,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_huffyuvencdsp_init(&s->hdsp); ff_huffyuvencdsp_init(&s->hdsp);
s->filter_type = av_clip(avctx->prediction_method, #if FF_API_PRIVATE_OPT
PNG_FILTER_VALUE_NONE, FF_DISABLE_DEPRECATION_WARNINGS
PNG_FILTER_VALUE_MIXED); 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) if (avctx->pix_fmt == AV_PIX_FMT_MONOBLACK)
s->filter_type = PNG_FILTER_VALUE_NONE; s->filter_type = PNG_FILTER_VALUE_NONE;
@ -1087,7 +1093,14 @@ static av_cold int png_enc_close(AVCodecContext *avctx)
static const AVOption options[] = { static const AVOption options[] = {
{"dpi", "Set image resolution (in dots per inch)", OFFSET(dpi), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 0x10000, VE}, {"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}, {"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 = { static const AVClass pngenc_class = {

View File

@ -187,6 +187,8 @@ typedef struct SnowContext{
AVMotionVector *avmv; AVMotionVector *avmv;
int avmv_index; int avmv_index;
uint64_t encoding_error[AV_NUM_DATA_POINTERS]; uint64_t encoding_error[AV_NUM_DATA_POINTERS];
int pred;
}SnowContext; }SnowContext;
/* Tables */ /* Tables */

View File

@ -41,7 +41,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
int plane_index, ret; int plane_index, ret;
int i; 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->flags & AV_CODEC_FLAG_QSCALE)
&& avctx->global_quality == 0){ && avctx->global_quality == 0){
av_log(avctx, AV_LOG_ERROR, "The 9/7 wavelet is incompatible with lossless mode.\n"); 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 FF_ENABLE_DEPRECATION_WARNINGS
#endif #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->mv_scale = (avctx->flags & AV_CODEC_FLAG_QPEL) ? 2 : 4;
s->block_max_depth= (avctx->flags & AV_CODEC_FLAG_4MV ) ? 1 : 0; 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 }, { "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 }, { "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 }, { "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 }, { NULL },
}; };

View File

@ -26,9 +26,11 @@
#include "utvideo.h" #include "utvideo.h"
#if FF_API_PRIVATE_OPT
const int ff_ut_pred_order[5] = { const int ff_ut_pred_order[5] = {
PRED_LEFT, PRED_MEDIAN, PRED_MEDIAN, PRED_NONE, PRED_GRADIENT 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 const int ff_ut_rgb_order[4] = { 1, 2, 0, 3 }; // G, B, R, A

View File

@ -65,6 +65,7 @@ extern const int ff_ut_pred_order[5];
extern const int ff_ut_rgb_order[4]; extern const int ff_ut_rgb_order[4];
typedef struct UtvideoContext { typedef struct UtvideoContext {
const AVClass *class;
AVCodecContext *avctx; AVCodecContext *avctx;
BswapDSPContext bdsp; BswapDSPContext bdsp;
HuffYUVEncDSPContext hdsp; HuffYUVEncDSPContext hdsp;

View File

@ -26,6 +26,8 @@
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "avcodec.h" #include "avcodec.h"
#include "internal.h" #include "internal.h"
#include "bswapdsp.h" #include "bswapdsp.h"
@ -111,6 +113,8 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
ff_bswapdsp_init(&c->bdsp); ff_bswapdsp_init(&c->bdsp);
ff_huffyuvencdsp_init(&c->hdsp); ff_huffyuvencdsp_init(&c->hdsp);
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
/* Check the prediction method, and error out if unsupported */ /* Check the prediction method, and error out if unsupported */
if (avctx->prediction_method < 0 || avctx->prediction_method > 4) { if (avctx->prediction_method < 0 || avctx->prediction_method > 4) {
av_log(avctx, AV_LOG_WARNING, 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 */ /* 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) { if (c->frame_pred == PRED_GRADIENT) {
av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n"); av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n");
@ -629,12 +636,32 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0; 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 = { AVCodec ff_utvideo_encoder = {
.name = "utvideo", .name = "utvideo",
.long_name = NULL_IF_CONFIG_SMALL("Ut Video"), .long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_UTVIDEO, .id = AV_CODEC_ID_UTVIDEO,
.priv_data_size = sizeof(UtvideoContext), .priv_data_size = sizeof(UtvideoContext),
.priv_class = &utvideo_class,
.init = utvideo_encode_init, .init = utvideo_encode_init,
.encode2 = utvideo_encode_frame, .encode2 = utvideo_encode_frame,
.close = utvideo_encode_close, .close = utvideo_encode_close,

View File

@ -37,7 +37,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_rgba_median
fate-utvideoenc_rgba_median: OPTS = -pix_fmt rgba -pred median fate-utvideoenc_rgba_median: OPTS = -pix_fmt rgba -pred median
FATE_UTVIDEOENC += fate-utvideoenc_rgba_none FATE_UTVIDEOENC += fate-utvideoenc_rgba_none
fate-utvideoenc_rgba_none: OPTS = -pix_fmt rgba -pred 3 fate-utvideoenc_rgba_none: OPTS = -pix_fmt rgba -pred none
FATE_UTVIDEOENC += fate-utvideoenc_rgb_left FATE_UTVIDEOENC += fate-utvideoenc_rgb_left
fate-utvideoenc_rgb_left: OPTS = -pix_fmt rgb24 -pred left fate-utvideoenc_rgb_left: OPTS = -pix_fmt rgb24 -pred left
@ -46,7 +46,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_rgb_median
fate-utvideoenc_rgb_median: OPTS = -pix_fmt rgb24 -pred median fate-utvideoenc_rgb_median: OPTS = -pix_fmt rgb24 -pred median
FATE_UTVIDEOENC += fate-utvideoenc_rgb_none FATE_UTVIDEOENC += fate-utvideoenc_rgb_none
fate-utvideoenc_rgb_none: OPTS = -pix_fmt rgb24 -pred 3 fate-utvideoenc_rgb_none: OPTS = -pix_fmt rgb24 -pred none
FATE_UTVIDEOENC += fate-utvideoenc_yuv420_left FATE_UTVIDEOENC += fate-utvideoenc_yuv420_left
fate-utvideoenc_yuv420_left: OPTS = -pix_fmt yuv420p -pred left fate-utvideoenc_yuv420_left: OPTS = -pix_fmt yuv420p -pred left
@ -55,7 +55,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_yuv420_median
fate-utvideoenc_yuv420_median: OPTS = -pix_fmt yuv420p -pred median fate-utvideoenc_yuv420_median: OPTS = -pix_fmt yuv420p -pred median
FATE_UTVIDEOENC += fate-utvideoenc_yuv420_none FATE_UTVIDEOENC += fate-utvideoenc_yuv420_none
fate-utvideoenc_yuv420_none: OPTS = -pix_fmt yuv420p -pred 3 fate-utvideoenc_yuv420_none: OPTS = -pix_fmt yuv420p -pred none
FATE_UTVIDEOENC += fate-utvideoenc_yuv422_left FATE_UTVIDEOENC += fate-utvideoenc_yuv422_left
fate-utvideoenc_yuv422_left: OPTS = -pix_fmt yuv422p -pred left fate-utvideoenc_yuv422_left: OPTS = -pix_fmt yuv422p -pred left
@ -64,7 +64,7 @@ FATE_UTVIDEOENC += fate-utvideoenc_yuv422_median
fate-utvideoenc_yuv422_median: OPTS = -pix_fmt yuv422p -pred median fate-utvideoenc_yuv422_median: OPTS = -pix_fmt yuv422p -pred median
FATE_UTVIDEOENC += fate-utvideoenc_yuv422_none FATE_UTVIDEOENC += fate-utvideoenc_yuv422_none
fate-utvideoenc_yuv422_none: OPTS = -pix_fmt yuv422p -pred 3 fate-utvideoenc_yuv422_none: OPTS = -pix_fmt yuv422p -pred none
$(FATE_UTVIDEOENC): $(VREF) $(FATE_UTVIDEOENC): $(VREF)