X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Futvideoenc.c;h=ef51ed06dd90bba7d238af6e8d195038be479f30;hb=83678dbbae64ad8c501e0c732c1117e642c25dae;hp=9af0f66a71371819921f5f76562ee5c755831289;hpb=059a934806d61f7af9ab3fd9f74994b838ea5eba;p=ffmpeg diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index 9af0f66a713..ef51ed06dd9 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"); @@ -153,7 +160,7 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - /* extradata size is 4 * 32bit */ + /* extradata size is 4 * 32 bits */ avctx->extradata_size = 16; avctx->extradata = av_mallocz(avctx->extradata_size + @@ -227,8 +234,9 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx) return 0; } -static void mangle_rgb_planes(uint8_t *dst[4], int dst_stride, uint8_t *src, - int step, int stride, int width, int height) +static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride, + uint8_t *src, int step, ptrdiff_t stride, + int width, int height) { int i, j; int k = 2 * dst_stride; @@ -261,7 +269,7 @@ static void mangle_rgb_planes(uint8_t *dst[4], int dst_stride, uint8_t *src, } /* Write data to a plane with left prediction */ -static void left_predict(uint8_t *src, uint8_t *dst, int stride, +static void left_predict(uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height) { int i, j; @@ -278,8 +286,8 @@ static void left_predict(uint8_t *src, uint8_t *dst, int stride, } /* Write data to a plane with median prediction */ -static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, int stride, - int width, int height) +static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst, + ptrdiff_t stride, int width, int height) { int i, j; int A, B; @@ -364,7 +372,7 @@ static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, src += width; } - /* Pad output to a 32bit boundary */ + /* Pad output to a 32-bit boundary */ count = put_bits_count(&pb) & 0x1F; if (count) @@ -380,7 +388,7 @@ static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, } static int encode_plane(AVCodecContext *avctx, uint8_t *src, - uint8_t *dst, int stride, + uint8_t *dst, ptrdiff_t stride, int width, int height, PutByteContext *pb) { UtvideoContext *c = avctx->priv_data; @@ -604,7 +612,7 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } /* - * Write frame information (LE 32bit unsigned) + * Write frame information (LE 32-bit unsigned) * into the output packet. * Contains the prediction method. */ @@ -631,12 +639,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,