summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog1
-rw-r--r--cmdutils.c3
-rw-r--r--cmdutils.h3
-rw-r--r--doc/general.texi2
-rw-r--r--ffmpeg_opt.c98
-rw-r--r--ffplay.c4
-rw-r--r--ffprobe.c2
-rw-r--r--ffserver.c3
-rw-r--r--libavcodec/Makefile3
-rw-r--r--libavcodec/allcodecs.c2
-rw-r--r--libavcodec/utvideo.c39
-rw-r--r--libavcodec/utvideo.h91
-rw-r--r--libavcodec/utvideodec.c57
-rw-r--r--libavcodec/utvideoenc.c735
-rw-r--r--libavcodec/version.h2
-rw-r--r--tests/fate/utvideo.mak42
-rw-r--r--tests/ref/fate/utvideoenc_rgb_left51
-rw-r--r--tests/ref/fate/utvideoenc_rgb_median51
-rw-r--r--tests/ref/fate/utvideoenc_rgb_none51
-rw-r--r--tests/ref/fate/utvideoenc_rgba_left51
-rw-r--r--tests/ref/fate/utvideoenc_rgba_median51
-rw-r--r--tests/ref/fate/utvideoenc_rgba_none51
-rw-r--r--tests/ref/fate/utvideoenc_yuv420_left51
-rw-r--r--tests/ref/fate/utvideoenc_yuv420_median51
-rw-r--r--tests/ref/fate/utvideoenc_yuv420_none51
-rw-r--r--tests/ref/fate/utvideoenc_yuv422_left51
-rw-r--r--tests/ref/fate/utvideoenc_yuv422_median51
-rw-r--r--tests/ref/fate/utvideoenc_yuv422_none51
28 files changed, 1612 insertions, 87 deletions
diff --git a/Changelog b/Changelog
index 14e01f3870..06089ec8f9 100644
--- a/Changelog
+++ b/Changelog
@@ -51,6 +51,7 @@ version next:
- framestep filter
- ffmpeg -shortest option is now per-output file
- volume measurement filter
+- Ut Video encoder
version 0.11:
diff --git a/cmdutils.c b/cmdutils.c
index 0d8b426183..ed856301d7 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -142,7 +142,7 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
}
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
- int rej_flags)
+ int rej_flags, int alt_flags)
{
const OptionDef *po;
int first;
@@ -152,6 +152,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
char buf[64];
if (((po->flags & req_flags) != req_flags) ||
+ (alt_flags && !(po->flags & alt_flags)) ||
(po->flags & rej_flags))
continue;
diff --git a/cmdutils.h b/cmdutils.h
index 84ef3718df..fc36331cb1 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -178,9 +178,10 @@ typedef struct {
* @param msg title of this group. Only printed if at least one option matches.
* @param req_flags print only options which have all those flags set.
* @param rej_flags don't print options which have any of those flags set.
+ * @param alt_flags print only options that have at least one of those flags set
*/
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
- int rej_flags);
+ int rej_flags, int alt_flags);
/**
* Show help for all options with given flags in class and all its
diff --git a/doc/general.texi b/doc/general.texi
index 9a224d823d..419eac7ae1 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -666,7 +666,7 @@ following image formats are supported:
@tab encoding supported through external library libtheora
@item Tiertex Limited SEQ video @tab @tab X
@tab Codec used in DOS CD-ROM FlashBack game.
-@item Ut Video @tab @tab X
+@item Ut Video @tab X @tab X
@item v210 QuickTime uncompressed 4:2:2 10-bit @tab X @tab X
@item v308 QuickTime uncompressed 4:4:4 @tab X @tab X
@item v408 QuickTime uncompressed 4:4:4:4 @tab X @tab X
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 02137b9bff..dc83e52e34 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -2141,32 +2141,68 @@ static int opt_filter_complex(const char *opt, const char *arg)
void show_help_default(const char *opt, const char *arg)
{
- int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
+ /* per-file options have at least one of those set */
+ const int per_file = OPT_SPEC | OPT_OFFSET | OPT_FUNC2;
+ int show_advanced = 0, show_avoptions = 0;
+
+ if (opt) {
+ if (!strcmp(opt, "long"))
+ show_advanced = 1;
+ else if (!strcmp(opt, "full"))
+ show_advanced = show_avoptions = 1;
+ else
+ av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
+ }
show_usage();
+
+ printf("Getting help:\n"
+ " -h -- print basic options\n"
+ " -h long -- print more options\n"
+ " -h full -- print all options (including all format and codec specific options, very long)\n"
+ " See man %s for detailed description of the options.\n"
+ "\n", program_name);
+
show_help_options(options, "Print help / information / capabilities:",
- OPT_EXIT, 0);
- show_help_options(options, "Main options:",
- 0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
- OPT_EXIT);
- show_help_options(options, "Advanced options:",
- OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+ OPT_EXIT, 0, 0);
+
+ show_help_options(options, "Global options (affect whole program "
+ "instead of just one file:",
+ 0, per_file | OPT_EXIT | OPT_EXPERT, 0);
+ if (show_advanced)
+ show_help_options(options, "Advanced global options:", OPT_EXPERT,
+ per_file | OPT_EXIT, 0);
+
+ show_help_options(options, "Per-file main options:", 0,
+ OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
+ OPT_EXIT, per_file);
+ if (show_advanced)
+ show_help_options(options, "Advanced per-file options:",
+ OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE, per_file);
+
show_help_options(options, "Video options:",
- OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
- show_help_options(options, "Advanced Video options:",
- OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
+ OPT_VIDEO, OPT_EXPERT | OPT_AUDIO, 0);
+ if (show_advanced)
+ show_help_options(options, "Advanced Video options:",
+ OPT_EXPERT | OPT_VIDEO, OPT_AUDIO, 0);
+
show_help_options(options, "Audio options:",
- OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
- show_help_options(options, "Advanced Audio options:",
- OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
+ OPT_AUDIO, OPT_EXPERT | OPT_VIDEO, 0);
+ if (show_advanced)
+ show_help_options(options, "Advanced Audio options:",
+ OPT_EXPERT | OPT_AUDIO, OPT_VIDEO, 0);
show_help_options(options, "Subtitle options:",
- OPT_SUBTITLE, 0);
+ OPT_SUBTITLE, 0, 0);
printf("\n");
- show_help_children(avcodec_get_class(), flags);
- show_help_children(avformat_get_class(), flags);
- show_help_children(sws_get_class(), flags);
- show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
- show_help_children(avfilter_get_class(), AV_OPT_FLAG_FILTERING_PARAM);
+
+ if (show_avoptions) {
+ int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
+ show_help_children(avcodec_get_class(), flags);
+ show_help_children(avformat_get_class(), flags);
+ show_help_children(sws_get_class(), flags);
+ show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
+ show_help_children(avfilter_get_class(), AV_OPT_FLAG_FILTERING_PARAM);
+ }
}
void show_usage(void)
@@ -2229,15 +2265,15 @@ const OptionDef options[] = {
"set the limit file size in bytes", "limit_size" },
{ "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(start_time) },
"set the start time offset", "time_off" },
- { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(input_ts_offset) },
+ { "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_EXPERT,{ .off = OFFSET(input_ts_offset) },
"set the input ts offset", "time_off" },
- { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC, { .off = OFFSET(ts_scale) },
+ { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC | OPT_EXPERT,{ .off = OFFSET(ts_scale) },
"set the input ts scale", "scale" },
{ "timestamp", HAS_ARG | OPT_FUNC2, { .func2_arg = opt_recording_timestamp },
"set the recording timestamp ('now' to set the current time)", "time" },
{ "metadata", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(metadata) },
"add metadata", "string=string" },
- { "dframes", HAS_ARG | OPT_FUNC2, { .func2_arg = opt_data_frames },
+ { "dframes", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, { .func2_arg = opt_data_frames },
"set the number of data frames to record", "number" },
{ "benchmark", OPT_BOOL | OPT_EXPERT, { &do_benchmark },
"add timings for benchmarking" },
@@ -2247,7 +2283,7 @@ const OptionDef options[] = {
"write program-readable progress information", "url" },
{ "stdin", OPT_BOOL | OPT_EXPERT, { &stdin_interaction },
"enable or disable interaction on standard input" },
- { "timelimit", HAS_ARG, { .func_arg = opt_timelimit },
+ { "timelimit", HAS_ARG | OPT_EXPERT, { .func_arg = opt_timelimit },
"set max runtime in seconds", "limit" },
{ "dump", OPT_BOOL | OPT_EXPERT, { &do_pkt_dump },
"dump each input packet" },
@@ -2274,13 +2310,13 @@ const OptionDef options[] = {
"timestamp discontinuity delta threshold", "threshold" },
{ "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold },
"timestamp error delta threshold", "threshold" },
- { "xerror", OPT_BOOL, { &exit_on_error },
+ { "xerror", OPT_BOOL | OPT_EXPERT, { &exit_on_error },
"exit on error", "error" },
{ "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC, { .off = OFFSET(copy_initial_nonkeyframes) },
"copy initial non-keyframes" },
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, { .off = OFFSET(max_frames) },
"set the number of frames to record", "number" },
- { "tag", OPT_STRING | HAS_ARG | OPT_SPEC, { .off = OFFSET(codec_tags) },
+ { "tag", OPT_STRING | HAS_ARG | OPT_SPEC | OPT_EXPERT,{ .off = OFFSET(codec_tags) },
"force codec tag/fourcc", "fourcc/tag" },
{ "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC,{ .off = OFFSET(qscale) },
"use fixed quality scale (VBR)", "q" },
@@ -2294,9 +2330,9 @@ const OptionDef options[] = {
"create a complex filtergraph", "graph_description" },
{ "stats", OPT_BOOL, { &print_stats },
"print progress report during encoding", },
- { "attach", HAS_ARG | OPT_FUNC2, { .func2_arg = opt_attach },
+ { "attach", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, { .func2_arg = opt_attach },
"add an attachment to the output file", "filename" },
- { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(dump_attachment) },
+ { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC |OPT_EXPERT,{ .off = OFFSET(dump_attachment) },
"extract an attachment into a file", "filename" },
{ "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts },
"print timestamp debugging info" },
@@ -2342,9 +2378,9 @@ const OptionDef options[] = {
"rate control override for specific intervals", "override" },
{ "vcodec", OPT_VIDEO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_video_codec },
"force video codec ('copy' to copy stream)", "codec" },
- { "sameq", OPT_VIDEO | OPT_BOOL, { &same_quant },
+ { "sameq", OPT_VIDEO | OPT_BOOL | OPT_EXPERT , { &same_quant },
"use same quantizer as source (implies VBR)" },
- { "same_quant", OPT_VIDEO | OPT_BOOL , { &same_quant },
+ { "same_quant", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &same_quant },
"use same quantizer as source (implies VBR)" },
{ "timecode", OPT_VIDEO | HAS_ARG | OPT_FUNC2, { .func2_arg = opt_timecode },
"set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
@@ -2431,7 +2467,7 @@ const OptionDef options[] = {
{ "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, { .off = OFFSET(mux_preload) },
"set the initial demux-decode delay", "seconds" },
- { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(bitstream_filters) },
+ { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT, { .off = OFFSET(bitstream_filters) },
"A comma-separated list of bitstream filters", "bitstream_filters" },
{ "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_FUNC2, { .func2_arg = opt_old2new },
"deprecated", "audio bitstream_filters" },
@@ -2447,7 +2483,7 @@ const OptionDef options[] = {
{ "fpre", HAS_ARG | OPT_EXPERT| OPT_FUNC2, { .func2_arg = opt_preset },
"set options from indicated preset file", "filename" },
/* data codec support */
- { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, { .func2_arg = opt_data_codec },
+ { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2 | OPT_EXPERT, { .func2_arg = opt_data_codec },
"force data codec ('copy' to copy stream)", "codec" },
{ "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET, { .off = OFFSET(data_disable) },
"disable data" },
diff --git a/ffplay.c b/ffplay.c
index 2907948689..f81bd7c84e 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3025,8 +3025,8 @@ void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:", 0, OPT_EXPERT);
- show_help_options(options, "Advanced options:", OPT_EXPERT, 0);
+ show_help_options(options, "Main options:", 0, OPT_EXPERT, 0);
+ show_help_options(options, "Advanced options:", OPT_EXPERT, 0, 0);
printf("\n");
show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM);
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
diff --git a/ffprobe.c b/ffprobe.c
index c1a90de692..196ee40280 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2076,7 +2076,7 @@ void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
show_usage();
- show_help_options(options, "Main options:", 0, 0);
+ show_help_options(options, "Main options:", 0, 0, 0);
printf("\n");
show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
diff --git a/ffserver.c b/ffserver.c
index 0e25f24b5d..f8649027b9 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -4650,8 +4650,7 @@ void show_help_default(const char *opt, const char *arg)
printf("usage: ffserver [options]\n"
"Hyper fast multi format Audio/Video streaming server\n");
printf("\n");
- show_help_options(options, "Main options:", 0, 0);
- return 0;
+ show_help_options(options, "Main options:", 0, 0, 0);
}
static const OptionDef options[] = {
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e4113da808..566b709e7e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -432,7 +432,8 @@ OBJS-$(CONFIG_TTA_DECODER) += tta.o
OBJS-$(CONFIG_TWINVQ_DECODER) += twinvq.o celp_math.o
OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o
OBJS-$(CONFIG_ULTI_DECODER) += ulti.o
-OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o
+OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o utvideo.o
+OBJS-$(CONFIG_UTVIDEO_ENCODER) += utvideoenc.o utvideo.o
OBJS-$(CONFIG_V210_DECODER) += v210dec.o
OBJS-$(CONFIG_V210_ENCODER) += v210enc.o
OBJS-$(CONFIG_V308_DECODER) += v308dec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 00f44a57a6..dcff2e833a 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -229,7 +229,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (TSCC2, tscc2);
REGISTER_DECODER (TXD, txd);
REGISTER_DECODER (ULTI, ulti);
- REGISTER_DECODER (UTVIDEO, utvideo);
+ REGISTER_ENCDEC (UTVIDEO, utvideo);
REGISTER_ENCDEC (V210, v210);
REGISTER_DECODER (V210X, v210x);
REGISTER_ENCDEC (V308, v308);
diff --git a/libavcodec/utvideo.c b/libavcodec/utvideo.c
new file mode 100644
index 0000000000..308adb75d9
--- /dev/null
+++ b/libavcodec/utvideo.c
@@ -0,0 +1,39 @@
+/*
+ * Common Ut Video code
+ * Copyright (c) 2011 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Common Ut Video code
+ */
+
+#include "utvideo.h"
+
+const int ff_ut_pred_order[5] = {
+ PRED_LEFT, PRED_MEDIAN, PRED_MEDIAN, PRED_NONE, PRED_GRADIENT
+};
+
+const int ff_ut_rgb_order[4] = { 1, 2, 0, 3 }; // G, B, R, A
+
+int ff_ut_huff_cmp_len(const void *a, const void *b)
+{
+ const HuffEntry *aa = a, *bb = b;
+ return (aa->len - bb->len)*256 + aa->sym - bb->sym;
+}
diff --git a/libavcodec/utvideo.h b/libavcodec/utvideo.h
new file mode 100644
index 0000000000..00c44be9a9
--- /dev/null
+++ b/libavcodec/utvideo.h
@@ -0,0 +1,91 @@
+/*
+ * Common Ut Video header
+ * Copyright (c) 2011 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_UTVIDEO_H
+#define AVCODEC_UTVIDEO_H
+
+/**
+ * @file
+ * Common Ut Video header
+ */
+
+#include "libavutil/common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+
+enum {
+ PRED_NONE = 0,
+ PRED_LEFT,
+ PRED_GRADIENT,
+ PRED_MEDIAN,
+};
+
+enum {
+ COMP_NONE = 0,
+ COMP_HUFF,
+};
+
+/*
+ * "Original format" markers.
+ * Based on values gotten from the official VFW encoder.
+ * They are not used during decoding, but they do have
+ * an informative role on seeing what was input
+ * to the encoder.
+ */
+enum {
+ UTVIDEO_RGB = MKTAG(0x00, 0x00, 0x01, 0x18),
+ UTVIDEO_RGBA = MKTAG(0x00, 0x00, 0x02, 0x18),
+ UTVIDEO_420 = MKTAG('Y', 'V', '1', '2'),
+ UTVIDEO_422 = MKTAG('Y', 'U', 'Y', '2'),
+};
+
+/* Mapping of libavcodec prediction modes to Ut Video's */
+extern const int ff_ut_pred_order[5];
+
+/* Order of RGB(A) planes in Ut Video */
+extern const int ff_ut_rgb_order[4];
+
+typedef struct UtvideoContext {
+ AVCodecContext *avctx;
+ AVFrame pic;
+ DSPContext dsp;
+
+ uint32_t frame_info_size, flags, frame_info;
+ int planes;
+ int slices;
+ int compression;
+ int interlaced;
+ int frame_pred;
+
+ uint8_t *slice_bits, *slice_buffer;
+ int slice_bits_size;
+} UtvideoContext;
+
+typedef struct HuffEntry {
+ uint8_t sym;
+ uint8_t len;
+ uint32_t code;
+} HuffEntry;
+
+/* Compare huffman tree nodes */
+int ff_ut_huff_cmp_len(const void *a, const void *b);
+
+#endif /* AVCODEC_UTVIDEO_H */
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index ac1c5fed3e..1bd38dca3e 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -32,40 +32,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "thread.h"
-
-enum {
- PRED_NONE = 0,
- PRED_LEFT,
- PRED_GRADIENT,
- PRED_MEDIAN,
-};
-
-typedef struct UtvideoContext {
- AVCodecContext *avctx;
- AVFrame pic;
- DSPContext dsp;
-
- uint32_t frame_info_size, flags, frame_info;
- int planes;
- int slices;
- int compression;
- int interlaced;
- int frame_pred;
-
- uint8_t *slice_bits;
- int slice_bits_size;
-} UtvideoContext;
-
-typedef struct HuffEntry {
- uint8_t sym;
- uint8_t len;
-} HuffEntry;
-
-static int huff_cmp(const void *a, const void *b)
-{
- const HuffEntry *aa = a, *bb = b;
- return (aa->len - bb->len)*256 + aa->sym - bb->sym;
-}
+#include "utvideo.h"
static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
{
@@ -82,7 +49,7 @@ static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
he[i].sym = i;
he[i].len = *src++;
}
- qsort(he, 256, sizeof(*he), huff_cmp);
+ qsort(he, 256, sizeof(*he), ff_ut_huff_cmp_len);
if (!he[0].len) {
*fsym = he[0].sym;
@@ -216,8 +183,6 @@ fail:
return AVERROR_INVALIDDATA;
}
-static const int rgb_order[4] = { 1, 2, 0, 3 };
-
static void restore_rgb_planes(uint8_t *src, int step, int stride, int width,
int height)
{
@@ -432,20 +397,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
case PIX_FMT_RGB24:
case PIX_FMT_RGBA:
for (i = 0; i < c->planes; i++) {
- ret = decode_plane(c, i, c->pic.data[0] + rgb_order[i], c->planes,
- c->pic.linesize[0], avctx->width, avctx->height,
- plane_start[i], c->frame_pred == PRED_LEFT);
+ ret = decode_plane(c, i, c->pic.data[0] + ff_ut_rgb_order[i],
+ c->planes, c->pic.linesize[0], avctx->width,
+ avctx->height, plane_start[i],
+ c->frame_pred == PRED_LEFT);
if (ret)
return ret;
if (c->frame_pred == PRED_MEDIAN) {
if (!c->interlaced) {
- restore_median(c->pic.data[0] + rgb_order[i], c->planes,
- c->pic.linesize[0], avctx->width,
+ restore_median(c->pic.data[0] + ff_ut_rgb_order[i],
+ c->planes, c->pic.linesize[0], avctx->width,
avctx->height, c->slices, 0);
} else {
- restore_median_il(c->pic.data[0] + rgb_order[i], c->planes,
- c->pic.linesize[0], avctx->width,
- avctx->height, c->slices, 0);
+ restore_median_il(c->pic.data[0] + ff_ut_rgb_order[i],
+ c->planes, c->pic.linesize[0],
+ avctx->width, avctx->height, c->slices,
+ 0);
}
}
}
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
new file mode 100644
index 0000000000..1e7c12b768
--- /dev/null
+++ b/libavcodec/utvideoenc.c
@@ -0,0 +1,735 @@
+/*
+ * Ut Video encoder
+ * Copyright (c) 2012 Jan Ekström
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Ut Video encoder
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "internal.h"
+#include "bytestream.h"
+#include "put_bits.h"
+#include "dsputil.h"
+#include "mathops.h"
+#include "utvideo.h"
+
+/* Compare huffentry symbols */
+static int huff_cmp_sym(const void *a, const void *b)
+{
+ const HuffEntry *aa = a, *bb = b;
+ return aa->sym - bb->sym;
+}
+
+static av_cold int utvideo_encode_close(AVCodecContext *avctx)
+{
+ UtvideoContext *c = avctx->priv_data;
+
+ av_freep(&avctx->coded_frame);
+ av_freep(&c->slice_bits);
+ av_freep(&c->slice_buffer);
+
+ return 0;
+}
+
+static av_cold int utvideo_encode_init(AVCodecContext *avctx)
+{
+ UtvideoContext *c = avctx->priv_data;
+
+ uint32_t original_format;
+
+ c->avctx = avctx;
+ c->frame_info_size = 4;
+
+ switch (avctx->pix_fmt) {
+ case PIX_FMT_RGB24:
+ c->planes = 3;
+ avctx->codec_tag = MKTAG('U', 'L', 'R', 'G');
+ original_format = UTVIDEO_RGB;
+ break;
+ case PIX_FMT_RGBA:
+ c->planes = 4;
+ avctx->codec_tag = MKTAG('U', 'L', 'R', 'A');
+ original_format = UTVIDEO_RGBA;
+ break;
+ case PIX_FMT_YUV420P:
+ if (avctx->width & 1 || avctx->height & 1) {
+ av_log(avctx, AV_LOG_ERROR,
+ "4:2:0 video requires even width and height.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ c->planes = 3;
+ avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
+ original_format = UTVIDEO_420;
+ break;
+ case PIX_FMT_YUV422P:
+ if (avctx->width & 1) {
+ av_log(avctx, AV_LOG_ERROR,
+ "4:2:2 video requires even width.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ c->planes = 3;
+ avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
+ original_format = UTVIDEO_422;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown pixel format: %d\n",
+ avctx->pix_fmt);
+ return AVERROR_INVALIDDATA;
+ }
+
+ ff_dsputil_init(&c->dsp, avctx);
+
+ /* Check the prediction method, and error out if unsupported */
+ if (avctx->prediction_method < 0 || avctx->prediction_method > 4) {
+ av_log(avctx, AV_LOG_WARNING,
+ "Prediction method %d is not supported in Ut Video.\n",
+ avctx->prediction_method);
+ return AVERROR_OPTION_NOT_FOUND;
+ }
+
+ if (avctx->prediction_method == FF_PRED_PLANE) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Plane prediction is not supported in Ut Video.\n");
+ return AVERROR_OPTION_NOT_FOUND;
+ }
+
+ /* Convert from libavcodec prediction type to Ut Video's */
+ c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+
+ if (c->frame_pred == PRED_GRADIENT) {
+ av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n");
+ return AVERROR_OPTION_NOT_FOUND;
+ }
+
+ avctx->coded_frame = avcodec_alloc_frame();
+
+ if (!avctx->coded_frame) {
+ av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
+ utvideo_encode_close(avctx);
+ return AVERROR(ENOMEM);
+ }
+
+ /* extradata size is 4 * 32bit */
+ avctx->extradata_size = 16;
+
+ avctx->extradata = av_mallocz(avctx->extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!avctx->extradata) {
+ av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n");
+ utvideo_encode_close(avctx);
+ return AVERROR(ENOMEM);
+ }
+
+ c->slice_buffer = av_malloc(avctx->width * avctx->height +
+ FF_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!c->slice_buffer) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 1.\n");
+ utvideo_encode_close(avctx);
+ return AVERROR(ENOMEM);
+ }
+
+ /*
+ * Set the version of the encoder.
+ * Last byte is "implementation ID", which is
+ * obtained from the creator of the format.
+ * Libavcodec has been assigned with the ID 0xF0.
+ */
+ AV_WB32(avctx->extradata, MKTAG(1, 0, 0, 0xF0));
+
+ /*
+ * Set the "original format"
+ * Not used for anything during decoding.
+ */
+ AV_WL32(avctx->extradata + 4, original_format);
+
+ /* Write 4 as the 'frame info size' */
+ AV_WL32(avctx->extradata + 8, c->frame_info_size);
+
+ /*
+ * Set how many slices are going to be used.
+ * Set one slice for now.
+ */
+ c->slices = 1;
+
+ /* Set compression mode */
+ c->compression = COMP_HUFF;
+
+ /*
+ * Set the encoding flags:
+ * - Slice count minus 1
+ * - Interlaced encoding mode flag, set to zero for now.
+ * - Compression mode (none/huff)
+ * And write the flags.
+ */
+ c->flags = (c->slices - 1) << 24;
+ c->flags |= 0 << 11; // bit field to signal interlaced encoding mode
+ c->flags |= c->compression;
+
+ AV_WL32(avctx->extradata + 12, c->flags);
+
+ return 0;
+}
+
+static void mangle_rgb_planes(uint8_t *src, int step, int stride, int width,
+ int height)
+{
+ int i, j;
+ uint8_t r, g, b;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width * step; i += step) {
+ r = src[i];
+ g = src[i + 1];
+ b = src[i + 2];
+
+ src[i] = r - g + 0x80;
+ src[i + 2] = b - g + 0x80;
+ }
+ src += stride;
+ }
+}
+
+/* Write data to a plane, no prediction applied */
+static void write_plane(uint8_t *src, uint8_t *dst, int step, int stride,
+ int width, int height)
+{
+ int i, j;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width * step; i += step)
+ *dst++ = src[i];
+
+ src += stride;
+ }
+}
+
+/* Write data to a plane with left prediction */
+static void left_predict(uint8_t *src, uint8_t *dst, int step, int stride,
+ int width, int height)
+{
+ int i, j;
+ uint8_t prev;
+
+ prev = 0x80; /* Set the initial value */
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width * step; i += step) {
+ *dst++ = src[i] - prev;
+ prev = src[i];
+ }
+ src += stride;
+ }
+}
+
+/* Write data to a plane with median prediction */
+static void median_predict(uint8_t *src, uint8_t *dst, int step, int stride,
+ int width, int height)
+{
+ int i, j;
+ int A, B, C;
+ uint8_t prev;
+
+ /* First line uses left neighbour prediction */
+ prev = 0x80; /* Set the initial value */
+ for (i = 0; i < width * step; i += step) {
+ *dst++ = src[i] - prev;
+ prev = src[i];
+ }
+
+ if (height == 1)
+ return;
+
+ src += stride;
+
+ /*
+ * Second line uses top prediction for the first sample,
+ * and median for the rest.
+ */
+ C = src[-stride];
+ *dst++ = src[0] - C;
+ A = src[0];
+ for (i = step; i < width * step; i += step) {
+ B = src[i - stride];
+ *dst++ = src[i] - mid_pred(A, B, (A + B - C) & 0xFF);
+ C = B;
+ A = src[i];
+ }
+
+ src += stride;
+
+ /* Rest of the coded part uses median prediction */
+ for (j = 2; j < height; j++) {
+ for (i = 0; i < width * step; i += step) {
+ B = src[i - stride];
+ *dst++ = src[i] - mid_pred(A, B, (A + B - C) & 0xFF);
+ C = B;
+ A = src[i];
+ }
+ src += stride;
+ }
+}
+
+/* Count the usage of values in a plane */
+static void count_usage(uint8_t *src, int width,
+ int height, uint32_t *counts)
+{
+ int i, j;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ counts[src[i]]++;
+ }
+ src += width;
+ }
+}
+
+static uint32_t add_weights(uint32_t w1, uint32_t w2)
+{
+ uint32_t max = (w1 & 0xFF) > (w2 & 0xFF) ? (w1 & 0xFF) : (w2 & 0xFF);
+
+ return ((w1 & 0xFFFFFF00) + (w2 & 0xFFFFFF00)) | (1 + max);
+}
+
+static void up_heap(uint32_t val, uint32_t *heap, uint32_t *weights)
+{
+ uint32_t initial_val = heap[val];
+
+ while (weights[initial_val] < weights[heap[val >> 1]]) {
+ heap[val] = heap[val >> 1];
+ val >>= 1;
+ }
+
+ heap[val] = initial_val;
+}
+
+static void down_heap(uint32_t nr_heap, uint32_t *heap, uint32_t *weights)
+{
+ uint32_t val = 1;
+ uint32_t val2;
+ uint32_t initial_val = heap[val];
+
+ while (1) {
+ val2 = val << 1;
+
+ if (val2 > nr_heap)
+ break;
+
+ if (val2 < nr_heap && weights[heap[val2 + 1]] < weights[heap[val2]])
+ val2++;
+
+ if (weights[initial_val] < weights[heap[val2]])
+ break;
+
+ heap[val] = heap[val2];
+
+ val = val2;
+ }
+
+ heap[val] = initial_val;
+}
+
+/* Calculate the huffman code lengths from value counts */
+static void calculate_code_lengths(uint8_t *lengths, uint32_t *counts)
+{
+ uint32_t nr_nodes, nr_heap, node1, node2;
+ int i, j;
+ int32_t k;
+
+ /* Heap and node entries start from 1 */
+ uint32_t weights[512];
+ uint32_t heap[512];
+ int32_t parents[512];
+
+ /* Set initial weights */
+ for (i = 0; i < 256; i++)
+ weights[i + 1] = (counts[i] ? counts[i] : 1) << 8;
+
+ nr_nodes = 256;
+ nr_heap = 0;
+
+ heap[0] = 0;
+ weights[0] = 0;
+ parents[0] = -2;
+
+ /* Create initial nodes */
+ for (i = 1; i <= 256; i++) {
+ parents[i] = -1;
+
+ heap[++nr_heap] = i;
+ up_heap(nr_heap, heap, weights);
+ }
+
+ /* Build the tree */
+ while (nr_heap > 1) {
+ node1 = heap[1];
+ heap[1] = heap[nr_heap--];
+
+ down_heap(nr_heap, heap, weights);
+
+ node2 = heap[1];
+ heap[1] = heap[nr_heap--];
+
+ down_heap(nr_heap, heap, weights);
+
+ nr_nodes++;
+
+ parents[node1] = parents[node2] = nr_nodes;
+ weights[nr_nodes] = add_weights(weights[node1], weights[node2]);
+ parents[nr_nodes] = -1;
+
+ heap[++nr_heap] = nr_nodes;
+
+ up_heap(nr_heap, heap, weights);
+ }
+
+ /* Generate lengths */
+ for (i = 1; i <= 256; i++) {
+ j = 0;
+ k = i;
+
+ while (parents[k] >= 0) {
+ k = parents[k];
+ j++;
+ }
+
+ lengths[i - 1] = j;
+ }
+}
+
+/* Calculate the actual huffman codes from the code lengths */
+static void calculate_codes(HuffEntry *he)
+{
+ int last, i;
+ uint32_t code;
+
+ qsort(he, 256, sizeof(*he), ff_ut_huff_cmp_len);
+
+ last = 255;
+ while (he[last].len == 255 && last)
+ last--;
+
+ code = 1;
+ for (i = last; i >= 0; i--) {
+ he[i].code = code >> (32 - he[i].len);
+ code += 0x80000000u >> (he[i].len - 1);
+ }
+
+ qsort(he, 256, sizeof(*he), huff_cmp_sym);
+}
+
+/* Write huffman bit codes to a memory block */
+static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size,
+ int width, int height, HuffEntry *he)
+{
+ PutBitContext pb;
+ int i, j;
+ int count;
+
+ init_put_bits(&pb, dst, dst_size);
+
+ /* Write the codes */
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++)
+ put_bits(&pb, he[src[i]].len, he[src[i]].code);
+
+ src += width;
+ }
+
+ /* Pad output to a 32bit boundary */
+ count = put_bits_count(&pb) & 0x1F;
+
+ if (count)
+ put_bits(&pb, 32 - count, 0);
+
+ /* Get the amount of bits written */
+ count = put_bits_count(&pb);
+
+ /* Flush the rest with zeroes */
+ flush_put_bits(&pb);
+
+ return count;
+}
+
+static int encode_plane(AVCodecContext *avctx, uint8_t *src,
+ uint8_t *dst, int step, int stride,
+ int width, int height, PutByteContext *pb)
+{
+ UtvideoContext *c = avctx->priv_data;
+ uint8_t lengths[256];
+ uint32_t counts[256] = { 0 };
+
+ HuffEntry he[256];
+
+ uint32_t offset = 0, slice_len = 0;
+ int i, sstart, send = 0;
+ int symbol;
+
+ /* Do prediction / make planes */
+ switch (c->frame_pred) {
+ case PRED_NONE:
+ for (i = 0; i < c->slices; i++) {
+ sstart = send;
+ send = height * (i + 1) / c->slices;
+ write_plane(src + sstart * stride, dst + sstart * width,
+ step, stride, width, send - sstart);
+ }
+ break;
+ case PRED_LEFT:
+ for (i = 0; i < c->slices; i++) {
+ sstart = send;
+ send = height * (i + 1) / c->slices;
+ left_predict(src + sstart * stride, dst + sstart * width,
+ step, stride, width, send - sstart);
+ }
+ break;
+ case PRED_MEDIAN:
+ for (i = 0; i < c->slices; i++) {
+ sstart = send;
+ send = height * (i + 1) / c->slices;
+ median_predict(src + sstart * stride, dst + sstart * width,
+ step, stride, width, send - sstart);
+ }
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n",
+ c->frame_pred);
+ return AVERROR_OPTION_NOT_FOUND;
+ }
+
+ /* Count the usage of values */
+ count_usage(dst, width, height, counts);
+
+ /* Check for a special case where only one symbol was used */
+ for (symbol = 0; symbol < 256; symbol++) {
+ /* If non-zero count is found, see if it matches width * height */
+ if (counts[symbol]) {
+ /* Special case if only one symbol was used */
+ if (counts[symbol] == width * height) {
+ /*
+ * Write a zero for the single symbol
+ * used in the plane, else 0xFF.
+ */
+ for (i = 0; i < 256; i++) {
+ if (i == symbol)
+ bytestream2_put_byte(pb, 0);
+ else
+ bytestream2_put_byte(pb, 0xFF);
+ }
+
+ /* Write zeroes for lengths */
+ for (i = 0; i < c->slices; i++)
+ bytestream2_put_le32(pb, 0);
+
+ /* And that's all for that plane folks */
+ return 0;
+ }
+ break;
+ }
+ }
+
+ /* Calculate huffman lengths */
+ calculate_code_lengths(lengths, counts);
+
+ /*
+ * Write the plane's header into the output packet:
+ * - huffman code lengths (256 bytes)
+ * - slice end offsets (gotten from the slice lengths)
+ */
+ for (i = 0; i < 256; i++) {
+ bytestream2_put_byte(pb, lengths[i]);
+
+ he[i].len = lengths[i];
+ he[i].sym = i;
+ }
+
+ /* Calculate the huffman codes themselves */
+ calculate_codes(he);
+
+ send = 0;
+ for (i = 0; i < c->slices; i++) {
+ sstart = send;
+ send = height * (i + 1) / c->slices;
+
+ /*
+ * Write the huffman codes to a buffer,
+ * get the offset in bits and convert to bytes.
+ */
+ offset += write_huff_codes(dst + sstart * width, c->slice_bits,
+ width * (send - sstart), width,
+ send - sstart, he) >> 3;
+
+ slice_len = offset - slice_len;
+
+ /* Byteswap the written huffman codes */
+ c->dsp.bswap_buf((uint32_t *) c->slice_bits,
+ (uint32_t *) c->slice_bits,
+ slice_len >> 2);
+
+ /* Write the offset to the stream */
+ bytestream2_put_le32(pb, offset);
+
+ /* Seek to the data part of the packet */
+ bytestream2_seek_p(pb, 4 * (c->slices - i - 1) +
+ offset - slice_len, SEEK_CUR);
+
+ /* Write the slices' data into the output packet */
+ bytestream2_put_buffer(pb, c->slice_bits, slice_len);
+
+ /* Seek back to the slice offsets */
+ bytestream2_seek_p(pb, -4 * (c->slices - i - 1) - offset,
+ SEEK_CUR);
+
+ slice_len = offset;
+ }
+
+ /* And at the end seek to the end of written slice(s) */
+ bytestream2_seek_p(pb, offset, SEEK_CUR);
+
+ return 0;
+}
+
+static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pic, int *got_packet)
+{
+ UtvideoContext *c = avctx->priv_data;
+ PutByteContext pb;
+
+ uint32_t frame_info;
+
+ uint8_t *dst;
+
+ int width = avctx->width, height = avctx->height;
+ int i, ret = 0;
+
+ /* Allocate a new packet if needed, and set it to the pointer dst */
+ ret = ff_alloc_packet(pkt, (256 + 4 * c->slices + width * height) *
+ c->planes + 4);
+
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Error allocating the output packet, or the provided packet "
+ "was too small.\n");
+ return ret;
+ }
+
+ dst = pkt->data;
+
+ bytestream2_init_writer(&pb, dst, pkt->size);
+
+ av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
+ width * height + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!c->slice_bits) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n");
+ return AVERROR(ENOMEM);
+ }
+
+ /* In case of RGB, mangle the planes to Ut Video's format */
+ if (avctx->pix_fmt == PIX_FMT_RGBA || avctx->pix_fmt == PIX_FMT_RGB24)
+ mangle_rgb_planes(pic->data[0], c->planes, pic->linesize[0], width,
+ height);
+
+ /* Deal with the planes */
+ switch (avctx->pix_fmt) {
+ case PIX_FMT_RGB24:
+ case PIX_FMT_RGBA:
+ for (i = 0; i < c->planes; i++) {
+ ret = encode_plane(avctx, pic->data[0] + ff_ut_rgb_order[i],
+ c->slice_buffer, c->planes, pic->linesize[0],
+ width, height, &pb);
+
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
+ return ret;
+ }
+ }
+ break;
+ case PIX_FMT_YUV422P:
+ for (i = 0; i < c->planes; i++) {
+ ret = encode_plane(avctx, pic->data[i], c->slice_buffer, 1,
+ pic->linesize[i], width >> !!i, height, &pb);
+
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
+ return ret;
+ }
+ }
+ break;
+ case PIX_FMT_YUV420P:
+ for (i = 0; i < c->planes; i++) {
+ ret = encode_plane(avctx, pic->data[i], c->slice_buffer, 1,
+ pic->linesize[i], width >> !!i, height >> !!i,
+ &pb);
+
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Error encoding plane %d.\n", i);
+ return ret;
+ }
+ }
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown pixel format: %d\n",
+ avctx->pix_fmt);
+ return AVERROR_INVALIDDATA;
+ }
+
+ /*
+ * Write frame information (LE 32bit unsigned)
+ * into the output packet.
+ * Contains the prediction method.
+ */
+ frame_info = c->frame_pred << 8;
+ bytestream2_put_le32(&pb, frame_info);
+
+ /*
+ * At least currently Ut Video is IDR only.
+ * Set flags accordingly.
+ */
+ avctx->coded_frame->reference = 0;
+ avctx->coded_frame->key_frame = 1;
+ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+
+ pkt->size = bytestream2_tell_p(&pb);
+ pkt->flags |= AV_PKT_FLAG_KEY;
+
+ /* Packet should be done */
+ *got_packet = 1;
+
+ return 0;
+}
+
+AVCodec ff_utvideo_encoder = {
+ .name = "utvideo",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_UTVIDEO,
+ .priv_data_size = sizeof(UtvideoContext),
+ .init = utvideo_encode_init,
+ .encode2 = utvideo_encode_frame,
+ .close = utvideo_encode_close,
+ .pix_fmts = (const enum PixelFormat[]) {
+ PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_YUV422P,
+ PIX_FMT_YUV420P, PIX_FMT_NONE
+ },
+ .long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
+};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7f4db0b566..bf741020fa 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR 53
+#define LIBAVCODEC_VERSION_MINOR 54
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/tests/fate/utvideo.mak b/tests/fate/utvideo.mak
index 4e350f722e..991072ef47 100644
--- a/tests/fate/utvideo.mak
+++ b/tests/fate/utvideo.mak
@@ -24,3 +24,45 @@ fate-utvideo_yuv422_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_yuv422_
FATE_SAMPLES_AVCONV += $(FATE_UTVIDEO)
fate-utvideo: $(FATE_UTVIDEO)
+
+fate-utvideoenc%: CMD = framemd5 -f image2 -vcodec pgmyuv -i $(TARGET_PATH)/tests/vsynth1/%02d.pgm -vcodec utvideo -f avi ${OPTS}
+fate-utvideoenc%: tests/vsynth1/00.pgm
+
+FATE_UTVIDEOENC += fate-utvideoenc_rgba_none
+fate-utvideoenc_rgba_none: OPTS = -pix_fmt rgba -pred 3
+
+FATE_UTVIDEOENC += fate-utvideoenc_rgba_left
+fate-utvideoenc_rgba_left: OPTS = -pix_fmt rgba -pred left
+
+FATE_UTVIDEOENC += fate-utvideoenc_rgba_median
+fate-utvideoenc_rgba_median: OPTS = -pix_fmt rgba -pred median
+
+FATE_UTVIDEOENC += fate-utvideoenc_rgb_none
+fate-utvideoenc_rgb_none: OPTS = -pix_fmt rgb24 -pred 3
+
+FATE_UTVIDEOENC += fate-utvideoenc_rgb_left
+fate-utvideoenc_rgb_left: OPTS = -pix_fmt rgb24 -pred left
+
+FATE_UTVIDEOENC += fate-utvideoenc_rgb_median
+fate-utvideoenc_rgb_median: OPTS = -pix_fmt rgb24 -pred median
+
+FATE_UTVIDEOENC += fate-utvideoenc_yuv420_none
+fate-utvideoenc_yuv420_none: OPTS = -pix_fmt yuv420p -pred 3
+
+FATE_UTVIDEOENC += fate-utvideoenc_yuv420_left
+fate-utvideoenc_yuv420_left: OPTS = -pix_fmt yuv420p -pred left
+
+FATE_UTVIDEOENC += fate-utvideoenc_yuv420_median
+fate-utvideoenc_yuv420_median: OPTS = -pix_fmt yuv420p -pred median
+
+FATE_UTVIDEOENC += fate-utvideoenc_yuv422_none
+fate-utvideoenc_yuv422_none: OPTS = -pix_fmt yuv422p -pred 3
+
+FATE_UTVIDEOENC += fate-utvideoenc_yuv422_left
+fate-utvideoenc_yuv422_left: OPTS = -pix_fmt yuv422p -pred left
+
+FATE_UTVIDEOENC += fate-utvideoenc_yuv422_median
+fate-utvideoenc_yuv422_median: OPTS = -pix_fmt yuv422p -pred median
+
+FATE_AVCONV += $(FATE_UTVIDEOENC)
+fate-utvideoenc: $(FATE_UTVIDEOENC)
diff --git a/tests/ref/fate/utvideoenc_rgb_left b/tests/ref/fate/utvideoenc_rgb_left
new file mode 100644
index 0000000000..4f090398aa
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_rgb_left
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 168240, 116019db2e5350536a51e8d7a609c2b9
+0, 1, 1, 1, 167868, 0700499b0f8b9b09601b969caa2c2efd
+0, 2, 2, 1, 169216, 890e18b99ccca7601d1f68efd19e906b
+0, 3, 3, 1, 168156, b9bf194312e492f1cf3ee624e08bb30a
+0, 4, 4, 1, 167680, 53383c3fc77f6e35b58525ab2440fe85
+0, 5, 5, 1, 168516, 8c7150e8246b8c9a2f1985a0f80d68a7
+0, 6, 6, 1, 167712, d46508dad0cf7cd3f7e1aca50a16537b
+0, 7, 7, 1, 168172, 1b2643b67d0dddc04e65ff1e751b11ba
+0, 8, 8, 1, 167388, 0104ea69082aac2190a96bbe7971eac7
+0, 9, 9, 1, 168300, 6768cdc8383c4abdee474edddaab452b
+0, 10, 10, 1, 167960, ef3e8ed5dfc2dbdae9ac818b0c9964f7
+0, 11, 11, 1, 168024, 98d0fd2d82c43cabc4be25a304aa3e3a
+0, 12, 12, 1, 166460, db5cf5154a710972d2f2468cf1e5694c
+0, 13, 13, 1, 167284, 7caf2ab0d10c138a06846680145e18de
+0, 14, 14, 1, 168788, f7c071cc22bc822cd780df2ae761c98f
+0, 15, 15, 1, 168312, defc3b454e98c362e155e63765e5e7fe
+0, 16, 16, 1, 167888, 37713f91a4d342fab759a390eb0e5858
+0, 17, 17, 1, 167428, 56c9e1e039ec4ca3bad163c5f7356398
+0, 18, 18, 1, 166792, a67cc85635ff5c706c37273c8f6ace48
+0, 19, 19, 1, 167220, 797aa3302fa9b865e28ac517beff2fe7
+0, 20, 20, 1, 166612, 160d49cb2b549972ed15165221392fe8
+0, 21, 21, 1, 166676, fcd0bdcae5b009f34074b56ab566d92f
+0, 22, 22, 1, 167792, cdc6496a8ca7e41c8f23e56a2f995a07
+0, 23, 23, 1, 168040, 0c56322c9cde9e76f3a6a732fdb861bc
+0, 24, 24, 1, 168656, ed627dd70d9f1335c844ee7a62db29a0
+0, 25, 25, 1, 168456, b3282f8f1792206c4fed9101213032da
+0, 26, 26, 1, 168120, 43b3094cfa9e5985fa447bf25e0a8bcc
+0, 27, 27, 1, 167480, c1a58fd31844b0fa99a323921c4c3269
+0, 28, 28, 1, 165320, b0f33fddd18a2a74177721e8d1cb13e3
+0, 29, 29, 1, 165104, 2413e9a95b02a64629cd7ce6d4de799b
+0, 30, 30, 1, 166604, b17539db5a3f394632f9afadcaeaca38
+0, 31, 31, 1, 167500, 178dd023eee970d729089e0172659c27
+0, 32, 32, 1, 167264, ff5afb31aff707ded3c472044f685ddc
+0, 33, 33, 1, 169008, 99edb6139d09310a3fc686e76f982ae9
+0, 34, 34, 1, 168108, 66a41bba03235e2a501520198a415a7a
+0, 35, 35, 1, 168016, 028d708a5fcd6e708a3ae471052f5f00
+0, 36, 36, 1, 166984, 585c78a2e01493581dfbb395db7be582
+0, 37, 37, 1, 167388, 4ae14a7cb1016a19ff3bfc067797e774
+0, 38, 38, 1, 165388, fa0f0cc6c5efcdea4c15033ff104aee1
+0, 39, 39, 1, 165524, 868c476a1a007be410b05ba24f9d3efc
+0, 40, 40, 1, 165784, 4bfbcdcd82bb04c9aaf0a8f192b67d52
+0, 41, 41, 1, 166404, 09ff4d32a36dd63b035e2b430b790687
+0, 42, 42, 1, 166872, 3ef565aac161a5d9eb91b74496669a68
+0, 43, 43, 1, 166772, 1d7e9b7115408887a564bff985e92da3
+0, 44, 44, 1, 166588, 48e3e7c6b5f98e206f3837ef163d26ab
+0, 45, 45, 1, 164396, ff338e650a3475185f03842d7a691680
+0, 46, 46, 1, 163504, 21cba98fb1c03ffc149e582a4e70404c
+0, 47, 47, 1, 164248, f92c93800bff6486f09e170bead7f470
+0, 48, 48, 1, 164444, dc04c0e3b86bf42363046a2a56c76c82
+0, 49, 49, 1, 163844, 48007251ab2dd2d0228ac9095b190718
diff --git a/tests/ref/fate/utvideoenc_rgb_median b/tests/ref/fate/utvideoenc_rgb_median
new file mode 100644
index 0000000000..7a5febc7d9
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_rgb_median
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 149240, 7a580af923f79d740391481f44080fb8
+0, 1, 1, 1, 148992, 5083a5e7c7ba433a157441aeb93cec33
+0, 2, 2, 1, 150648, 05657dc59cf5f9c0b1eb4ec875000cb8
+0, 3, 3, 1, 149716, 8a7742db11d0d35f5b575423099b5bd7
+0, 4, 4, 1, 149272, f437090e4782d65f65b06eb1d47c9aa0
+0, 5, 5, 1, 150044, d8d00cf8ae06b6ca8d30a89e7c9666f8
+0, 6, 6, 1, 149532, 4abc60d6ea18bffe28151e0f4549aa95
+0, 7, 7, 1, 149316, a12ddb15795b63b7bf1ce8a66fa1815e
+0, 8, 8, 1, 149516, 3752007da5c2c1963314d35e2d580783
+0, 9, 9, 1, 149520, 419534098fa161671528cc77e307cf79
+0, 10, 10, 1, 149444, 383a3b79634d6aeecfc7eb0a5a5c9b7b
+0, 11, 11, 1, 149164, 5a5901882e8b9aa5a6300b7d786c2b16
+0, 12, 12, 1, 147996, fe9fb5d4cd97c7ad7f11c87b9f75b0a9
+0, 13, 13, 1, 149152, 83e0c36884b91263d2d235fab9a3b3e7
+0, 14, 14, 1, 149640, 366bdff8c41cb2f5a90810f719661bcc
+0, 15, 15, 1, 149600, e72f5f3e18b7a98443094d6e34d5286c
+0, 16, 16, 1, 148916, a94a62b5647365d13081a6c3398b127d
+0, 17, 17, 1, 149520, fdbc007fb7443b5bfd388d273413d20b
+0, 18, 18, 1, 148468, bc4c7b5324fe5658c15e8540dbc7130a
+0, 19, 19, 1, 148388, e9caa4e18c0bffb07039427d0a98798d
+0, 20, 20, 1, 147772, 3eb6bde758e13296e61911d6f574a49f
+0, 21, 21, 1, 148128, 64cc6d5c819d10e725c30fe69ef040ae
+0, 22, 22, 1, 148200, d5b8a93061a70e55b8b751d3c1a4ac5c
+0, 23, 23, 1, 149312, ef912e5a3640992dd2948037535b0341
+0, 24, 24, 1, 149244, 8df2d35148b9d934f79566cf6371af89
+0, 25, 25, 1, 149040, 27f1c2a77ae36fa23bd36ecf4df67fb8
+0, 26, 26, 1, 149020, 995370b34bd96cd5004ba5c4d449fd3f
+0, 27, 27, 1, 148308, b0a7cd8ee1db8fd0d1324450386de11c
+0, 28, 28, 1, 148016, 6d211a6b4e790e9c46757053782e6713
+0, 29, 29, 1, 147324, 730619aa336408d3d5694eb8e3ea2d71
+0, 30, 30, 1, 148104, 34c53deccc3be58bdc4cd9c0e3f19918
+0, 31, 31, 1, 149004, 710a4724ffac1457b8437f94c8e97b8b
+0, 32, 32, 1, 148452, be7c947371e8a434233eb7eaeef95c8d
+0, 33, 33, 1, 149076, 694fc1872869e16aaf176473f2094c52
+0, 34, 34, 1, 148952, f35b66ac7f42cbaf849a41536306cb85
+0, 35, 35, 1, 149012, 3f5d904d5a8b3d169f8c87f21b712ef6
+0, 36, 36, 1, 148464, 363df43764cb27a2d2a16e9246bf2c76
+0, 37, 37, 1, 148968, 2e08d0c96fdc99b091ad20c1aed208b6
+0, 38, 38, 1, 147744, 15412763aec2d25f9a23de4fa3cf60dc
+0, 39, 39, 1, 148124, f76679ddeaf18af0ef9563c7b7d86636
+0, 40, 40, 1, 147800, 3195234ce043d883252fbe7a01dbe86c
+0, 41, 41, 1, 148528, dd4b892d143ebd326452f5504d23d794
+0, 42, 42, 1, 147752, eb8c442bcc34a8a38e5101c1e00615c9
+0, 43, 43, 1, 147832, d834c5e4e0a1ab0a31c13eb7ac40fbc1
+0, 44, 44, 1, 148000, 9761129bd0122132d2154a56c2ceec62
+0, 45, 45, 1, 147344, 9b76ab62f501f0714076d9f94bb4374a
+0, 46, 46, 1, 146744, 184298b63c13730635f347eecdb506dd
+0, 47, 47, 1, 145980, ef4f03747a2a76016fc66df7a32a57b8
+0, 48, 48, 1, 146228, e2618fe6c95722d63cbce7ae5021ed16
+0, 49, 49, 1, 145756, 9f9187896e840d163ad955c1a37756fe
diff --git a/tests/ref/fate/utvideoenc_rgb_none b/tests/ref/fate/utvideoenc_rgb_none
new file mode 100644
index 0000000000..4b74a224f8
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_rgb_none
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 302912, d2964d8013869388b92b546f105a7541
+0, 1, 1, 1, 302880, a06917f2dd5905034b78d80b4702ade9
+0, 2, 2, 1, 302740, b8af48307700460aed09e61ff43297d8
+0, 3, 3, 1, 302784, d8bec7604718716daf04814fb889064d
+0, 4, 4, 1, 302824, d1f2f9055165254003868dcde305c423
+0, 5, 5, 1, 302796, c18722063e9cf19ee8cdcb69266c722a
+0, 6, 6, 1, 302796, cf00264e1e5f43890b5be16dc2aa0a75
+0, 7, 7, 1, 302860, d9b305b43c36ed06fa347e04daa26772
+0, 8, 8, 1, 302892, f69c6b0c027ac5f3d7e9e56609b36559
+0, 9, 9, 1, 302896, f81634542eb893a8150edfd91168d91e
+0, 10, 10, 1, 302776, 91509d83dc2c9308d9e29ed2b3c49b44
+0, 11, 11, 1, 302792, 7109c49d3c65cdc9afd8f0f3917dc36f
+0, 12, 12, 1, 302908, db307334fe92965b4500fb7f67ce4ffd
+0, 13, 13, 1, 302784, d18a2017145423cd7f5880cb44e34c4b
+0, 14, 14, 1, 302668, 1b2362477600ad99fdcca3bc2167be9e
+0, 15, 15, 1, 302696, cf38dc4d728a291f6206ee0dc4dec00c
+0, 16, 16, 1, 302788, d1d7743274cef21e137d9aa512ca1edc
+0, 17, 17, 1, 302840, 89d46fec602e9ebe4cae55961da71f4c
+0, 18, 18, 1, 302928, 46e55d9667f21cd14184bad89de32971
+0, 19, 19, 1, 302984, 8f25e47871bace8b39a2709f49cef11d
+0, 20, 20, 1, 302936, 6dff8cb7bb9fe294fcc79a713a983fb1
+0, 21, 21, 1, 302980, 26191c78d0e2901404776791397c4f83
+0, 22, 22, 1, 302996, 9f414291a8ea4537ac991675034db64b
+0, 23, 23, 1, 302912, d274f2535d109f9b8601f175fcd858cb
+0, 24, 24, 1, 302964, 1d70b563670a33267ae2f6644e1c8e95
+0, 25, 25, 1, 303028, 9d14b635403c286ca9d60fa700e30888
+0, 26, 26, 1, 302988, 8a3a45138a29d38ac70f1fb9f3147c1a
+0, 27, 27, 1, 303056, 2378954ac18fb9b01feb937b76c08a55
+0, 28, 28, 1, 302996, 675d4b6b235c374da450cf00e240185b
+0, 29, 29, 1, 303072, 77a7205787f1e7cca59dd239f6c0591a
+0, 30, 30, 1, 303084, 551c987cb8a574f999577a9e630a5df4
+0, 31, 31, 1, 303024, 73451fc3927d329fe407def293b5467d
+0, 32, 32, 1, 302972, 03c69d8fdebeb8c3ba31e99142e68144
+0, 33, 33, 1, 302904, 5949ab8ff47e72933e4668cf46a76d95
+0, 34, 34, 1, 302828, a9197dd2e0496fce0e8de9950466dc6e
+0, 35, 35, 1, 302972, 9c8c24df0e0196453f7db3182561879a
+0, 36, 36, 1, 303052, 849f0f23b6d2e6af74bff2a45b5d8a63
+0, 37, 37, 1, 303028, 16acb86039a38dbfac48e2a04a48d9ea
+0, 38, 38, 1, 303088, eb5336a28c2b99dd6e4e9f90a5fb5d96
+0, 39, 39, 1, 303048, 5a637b3e6b7b3c4b7aa58f4ffd8c5e29
+0, 40, 40, 1, 303120, f31ef0195ba9c70c5e6dc84ed4e9928a
+0, 41, 41, 1, 303056, 3f73ef08146c697fcec3aa16805aac92
+0, 42, 42, 1, 303092, 89e2ac83290eef0f589d67e3adad2d30
+0, 43, 43, 1, 303140, cde3a48e309c3ca6a3843d2d5aaade79
+0, 44, 44, 1, 303116, 5456c19ccc38237a09986c962350ef60
+0, 45, 45, 1, 303156, 419e78d98541dfd1a9d29a04cf985cf9
+0, 46, 46, 1, 303148, 9b7a7559370798cfae2ccb1731cd89c0
+0, 47, 47, 1, 303196, d9590fdf48bc3be1a4956fb5da3584dd
+0, 48, 48, 1, 303256, e6c90aa1753fc7d6b04cfc7e92b53af1
+0, 49, 49, 1, 303228, 941f240dc62777aba1792f36b70e1f48
diff --git a/tests/ref/fate/utvideoenc_rgba_left b/tests/ref/fate/utvideoenc_rgba_left
new file mode 100644
index 0000000000..eb0112bbff
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_rgba_left
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 181176, da7b045edf219bced5b152791b10c87f
+0, 1, 1, 1, 180804, b06bd1fe1a00a21efe0df3eabb909c9f
+0, 2, 2, 1, 182152, 75e86b780b70de0510be70278b8005d7
+0, 3, 3, 1, 181092, 70beeae6c87daac962fa67a5ef72f250
+0, 4, 4, 1, 180616, b0b8fda4db6828360d67556c8d90ea4f
+0, 5, 5, 1, 181452, 434daeeac59b17aaa3717ae9e5e5a3d7
+0, 6, 6, 1, 180648, c70e591fc050a7d8b88efed67a78c119
+0, 7, 7, 1, 181108, a84cd2efe629a710bf8f2118686ec8e3
+0, 8, 8, 1, 180324, 9e1559a606140bbad9d268d1453e26f8
+0, 9, 9, 1, 181236, 8daa9a96816335c58b88223d8c54f4a0
+0, 10, 10, 1, 180896, 5566aaf2bfb0a5f8601abb55496b0373
+0, 11, 11, 1, 180960, 67eb48372ea714bfb6b962029fa67328
+0, 12, 12, 1, 179396, 49bc20f86bd85dddea8085238ca3221a
+0, 13, 13, 1, 180220, aa783168cf3753dcc68d90155505081e
+0, 14, 14, 1, 181724, cef5a732a3308f7803d36d06e22f2490
+0, 15, 15, 1, 181248, a5bd0e1d9ea5130b35d084929fcb3f1d
+0, 16, 16, 1, 180824, 7ea8991f802ed2db13f12478b8445d96
+0, 17, 17, 1, 180364, f9065f42a52f4485347dfe667101bf3c
+0, 18, 18, 1, 179728, e88bf6901809ff965b76dad488a6dced
+0, 19, 19, 1, 180156, f054de2239e20e776663de033608e0c0
+0, 20, 20, 1, 179548, a328018fc852bb3f8a0a64b30d051d02
+0, 21, 21, 1, 179612, b865fd5fcbe5b6d7ca3e111048ecc3b2
+0, 22, 22, 1, 180728, 8a0a4c6933f8b6323426272fb64722de
+0, 23, 23, 1, 180976, c4a788e3c7b81070013934df31299208
+0, 24, 24, 1, 181592, 9fab2972676d67f86ec7b319ffb78e59
+0, 25, 25, 1, 181392, 7d762db7b2651f259d32a882a499c156
+0, 26, 26, 1, 181056, 1620dc2804ca0d9a48097db7f91bf6bc
+0, 27, 27, 1, 180416, 62dcb666136de841db99096e7c5fadb0
+0, 28, 28, 1, 178256, 27b01db3cf22c2a982b73861d3eb6add
+0, 29, 29, 1, 178040, ef78cd2d2091c03e90ab3feae0b2adcf
+0, 30, 30, 1, 179540, f026cc6577c8fd8ec685a45b88b31b62
+0, 31, 31, 1, 180436, af692865fb34b1418b756e794a9c1c3b
+0, 32, 32, 1, 180200, e65b58ef8e13e67a4c0c45086d299818
+0, 33, 33, 1, 181944, 6eae7d0bf76bf06da71186671901e698
+0, 34, 34, 1, 181044, 740dadcf236ca0af236c09d29b312940
+0, 35, 35, 1, 180952, 5badcbb17e97be7b54fa1e9e49f677ed
+0, 36, 36, 1, 179920, 8827a40f0c1e0b04f6085a7146955e2f
+0, 37, 37, 1, 180324, 9d42e2532a48c4972cb71ac541c3ea57
+0, 38, 38, 1, 178324, 31db217d6e574bf83279288f0b36a628
+0, 39, 39, 1, 178460, 8fdc5e7be532e05ddff2e10064113882
+0, 40, 40, 1, 178720, 28fdeaf450edd61a5a0f0dbc75aefe99
+0, 41, 41, 1, 179340, 2988ec8ce759703ef975c55a22ed3cd4
+0, 42, 42, 1, 179808, e27ed3b49dd8c3ef98e3526d9d691b65
+0, 43, 43, 1, 179708, 14415299804aa63cb7b262af6869a371
+0, 44, 44, 1, 179524, bb75948719d5af9e48543fa0c932f746
+0, 45, 45, 1, 177332, b0984e1db78dcc3d44a010444d87cf78
+0, 46, 46, 1, 176440, bd57710508310a95ad41cd056b715e12
+0, 47, 47, 1, 177184, f81326c0bce9ca0efe7edae7659d0e8b
+0, 48, 48, 1, 177380, edf7f2fd74be9992edda43ea87e524b7
+0, 49, 49, 1, 176780, 8902e18670264eec47294ffde934fcb9
diff --git a/tests/ref/fate/utvideoenc_rgba_median b/tests/ref/fate/utvideoenc_rgba_median
new file mode 100644
index 0000000000..5b2386c62c
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_rgba_median
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 162176, 56d4b5bfb2f08741c34ebb18dc5baf13
+0, 1, 1, 1, 161928, ac877a6e1afeb6813e5b79110dd5b847
+0, 2, 2, 1, 163584, 0559b537142474bdebc6fa2af9cca544
+0, 3, 3, 1, 162652, 3c36b59df75490a091035dfd6ebcbe01
+0, 4, 4, 1, 162208, d411c2aacdbdb828dae6bcd522a8b5d3
+0, 5, 5, 1, 162980, 658724afc8be5ceff75cb308a99267cb
+0, 6, 6, 1, 162468, 9dcb4ed413892aae0f3490d9baca4ddd
+0, 7, 7, 1, 162252, 2bc2f2fa252036ddf8241a0f1956ea8c
+0, 8, 8, 1, 162452, 4d41518201cb1295aad71df4fb1fedb9
+0, 9, 9, 1, 162456, 6811e63d77b8e842c13fba38afd65017
+0, 10, 10, 1, 162380, 710437537764369906cdf1858aea9e70
+0, 11, 11, 1, 162100, 60d1d475a78e1222a3f116db88d6dc8c
+0, 12, 12, 1, 160932, d9b8588ab35792e70c51354faea611cc
+0, 13, 13, 1, 162088, 3d88ee1f80ae7877afc5c142758a9346
+0, 14, 14, 1, 162576, e3357aea30458fb86c05d2a9cb5f3c8e
+0, 15, 15, 1, 162536, 117a4eae0ed02bb6ae32d23e591a3ae4
+0, 16, 16, 1, 161852, fa14269ae83e546dbbfa40f1aaf82bc8
+0, 17, 17, 1, 162456, 8c40b4e6507f7af04b1cae3848d6cfcc
+0, 18, 18, 1, 161404, 7211261a35fef4fae67b160eac1eb259
+0, 19, 19, 1, 161324, cd634211ef67871bd6860ec005ac0118
+0, 20, 20, 1, 160708, 8b65a6f7459670dd8ba5fb01b1344065
+0, 21, 21, 1, 161064, 85203e969ec6e8081c7cea4bb65de1cf
+0, 22, 22, 1, 161136, 296f3621d6b7f630768e5d7437629c42
+0, 23, 23, 1, 162248, ce43a1896160c289bbe5d56dafeeebc7
+0, 24, 24, 1, 162180, 0411ba4d9bdb8ea145a38214cab93aff
+0, 25, 25, 1, 161976, e6bb765a977e81afff62aab1a1a2ca2f
+0, 26, 26, 1, 161956, 8528eee65853c2e7298eb9e3c6ca9fa2
+0, 27, 27, 1, 161244, 332fa087a6ceceb610f3895ca5d81e4c
+0, 28, 28, 1, 160952, 4f3b0b92e63bdd0fd3f102e968e6f432
+0, 29, 29, 1, 160260, dd2de3bce5b80161547e33a748ce6b6a
+0, 30, 30, 1, 161040, 1306d4826a20d22810f19579e93d0f63
+0, 31, 31, 1, 161940, 1724203fd332573e778624d61c3251b0
+0, 32, 32, 1, 161388, da336f3865edf7e54ae14ca6d01de859
+0, 33, 33, 1, 162012, 2a04855ce96edec00e1860722e0f23a2
+0, 34, 34, 1, 161888, 4e525c0ff2ddfe1dd74f655037c52f39
+0, 35, 35, 1, 161948, 4a4723b617c8b142a3d9a1b30bf0c99c
+0, 36, 36, 1, 161400, a8250f7d6da6e7eb91c5b042679737e2
+0, 37, 37, 1, 161904, 15f4274bbaaa517865d0e212a03ee5fa
+0, 38, 38, 1, 160680, f7ee2864aa4c1c555fe0176b1b886294
+0, 39, 39, 1, 161060, 0f9eb1b9a798fe070d5d5b1587106e12
+0, 40, 40, 1, 160736, 988f20899af28deb7187cb89268fac7a
+0, 41, 41, 1, 161464, c279f41499a76c4548200859a3990d8b
+0, 42, 42, 1, 160688, 6d730f0c2a195845050af864af9f6bf1
+0, 43, 43, 1, 160768, ae1a3ad132c3ad269ca156d4948df74e
+0, 44, 44, 1, 160936, 32d6264955012575fad51675ef40b72b
+0, 45, 45, 1, 160280, aabff2df269f802b05d07c2bdcd7deae
+0, 46, 46, 1, 159680, 57f2bf1bca662fd2652dc9a04b883295
+0, 47, 47, 1, 158916, 5dfd2f6a29c73972d7f7431bc4e7f099
+0, 48, 48, 1, 159164, 1eeee6293474fc26cefad5cb2174d088
+0, 49, 49, 1, 158692, 56cee1ab036ccdfc9de75475d31fc221
diff --git a/tests/ref/fate/utvideoenc_rgba_none b/tests/ref/fate/utvideoenc_rgba_none
new file mode 100644
index 0000000000..1991ba63e1
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_rgba_none
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 303172, abd9a3e31bc4b3c4103eb95e21dd74e6
+0, 1, 1, 1, 303140, 29e62ca01ba6520da8c35442ddfa7bec
+0, 2, 2, 1, 303000, 03bc2de7e91ef1e929c4032a1469465f
+0, 3, 3, 1, 303044, d7316b5074897ceb5861de482006ec07
+0, 4, 4, 1, 303084, 8a29268305ef904301658ec2664241c7
+0, 5, 5, 1, 303056, 975dd2ac1e4b6dcd2a909889bac98604
+0, 6, 6, 1, 303056, b3ccb6e7a35e44616dc246b747edcb23
+0, 7, 7, 1, 303120, 593e11ab37e42cf285f9a13bf671b60e
+0, 8, 8, 1, 303152, 542aeb683f988532116f29fb3cc0a41c
+0, 9, 9, 1, 303156, f42a3e67219288391cdd131c12c2da87
+0, 10, 10, 1, 303036, a37840b759223d8d7e18902fb6073247
+0, 11, 11, 1, 303052, bbb27328a3d8949923daaa0b5ed28b3d
+0, 12, 12, 1, 303168, 522b1e74feb75bd7c4a71e5d85a3fda2
+0, 13, 13, 1, 303044, 961add62cf8853b41d281164344716be
+0, 14, 14, 1, 302928, 01b5005db00eb6dde2d8231e797ab40d
+0, 15, 15, 1, 302956, 6d448f007b545f370d2dffff0fb57e00
+0, 16, 16, 1, 303048, 942ec6895f66b5f08ee6cdc5604641ad
+0, 17, 17, 1, 303100, d83c9630bedd853cac07e26b6f99f77d
+0, 18, 18, 1, 303188, 6b9a7a78b71e64ed9a6c33a844387db4
+0, 19, 19, 1, 303244, bfa627071fd9be90f752d44a933aa89b
+0, 20, 20, 1, 303196, b1ec566949ac10d73bc16b3025cbeae4
+0, 21, 21, 1, 303240, d63e8b323bcff8a00cf7cbe99dc35a7f
+0, 22, 22, 1, 303256, 75fd6c994639c9e135d5030f31d8b21d
+0, 23, 23, 1, 303172, ac0e8390b59c639daba597c1b61fd6cb
+0, 24, 24, 1, 303224, 507bbfb7401ad63ddf318ef152615873
+0, 25, 25, 1, 303288, 5f223867377e295e954407632ccddcbb
+0, 26, 26, 1, 303248, 14c1be3751f3e05894e286e870f9d8ce
+0, 27, 27, 1, 303316, 9d924c4c4603ac5d9c2659f13cbcf928
+0, 28, 28, 1, 303256, c05f5d99182899aefb57e914e336e0ba
+0, 29, 29, 1, 303332, 41a65ae85522875f582de0487b0afab0
+0, 30, 30, 1, 303344, 749dc30e61b9d5a179c3513b5e6ca052
+0, 31, 31, 1, 303284, 958be38d742fb0c5fce50a50bcbe91e2
+0, 32, 32, 1, 303232, df178e2c1819c832d9a468e22f0d6bed
+0, 33, 33, 1, 303164, db6061112448b9b29c84e9c045561dde
+0, 34, 34, 1, 303088, c3e0f93fd01155c0d4671a24ba82e4c3
+0, 35, 35, 1, 303232, 5b2254a77fbbd0066fcacf1593c92f8f
+0, 36, 36, 1, 303312, ed9c65e2d573a7491b964d8cd160df9c
+0, 37, 37, 1, 303288, 9cf8fa422d4fc4e458cab411614c4e47
+0, 38, 38, 1, 303348, 9e00fe9b2003d28d97c3c766d6eaf6b6
+0, 39, 39, 1, 303308, 4abeab3a986bcaa2cdc6a3898fb7aea0
+0, 40, 40, 1, 303380, 4fefa9101b72a398a411348a5ac0f398
+0, 41, 41, 1, 303316, cbc28418d47be7ac8f7d3922cfd382a9
+0, 42, 42, 1, 303352, e365776166badae59207351c5302c4ee
+0, 43, 43, 1, 303400, 7d207922a9ff4a64c9fc08d32d53541e
+0, 44, 44, 1, 303376, fa84592162246745c77a528301f30532
+0, 45, 45, 1, 303416, 29013e5e5ef8a0f5de63f8946386eeed
+0, 46, 46, 1, 303408, e56901bf9b5559ba91105fe6f388ea41
+0, 47, 47, 1, 303456, 12958be8a6f6beadd9b94db6d4295b6c
+0, 48, 48, 1, 303516, bf8175a090ee88158f26a3eaff0ae79c
+0, 49, 49, 1, 303488, 964be87620c228652924bfd68faa25d9
diff --git a/tests/ref/fate/utvideoenc_yuv420_left b/tests/ref/fate/utvideoenc_yuv420_left
new file mode 100644
index 0000000000..fe6c3c5314
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_yuv420_left
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 59820, db20782033a18141a292da3f1a1c1782
+0, 1, 1, 1, 60040, c2f90e3de0c305ab8aac2530e3cd0e41
+0, 2, 2, 1, 61072, 97b0337a4185ef9d8e2533649860ad9a
+0, 3, 3, 1, 59680, 876d24900ef83e7958c9a1e54c82f330
+0, 4, 4, 1, 58620, 7732915d2a50f38951d46e36dcd49236
+0, 5, 5, 1, 60276, 343ef35f003da592451cab1ffbf158aa
+0, 6, 6, 1, 60504, 6823f1ef02f27719bb602911aa8caab5
+0, 7, 7, 1, 59916, 5f9ce306dc27d84d1af6d378b385c715
+0, 8, 8, 1, 60104, bac83cb16811318ad602ff391fdc94c7
+0, 9, 9, 1, 60352, bbd85ee4ccaad1b30b74d9edd1916291
+0, 10, 10, 1, 60324, 950230449f907a0615139fe2e1033a47
+0, 11, 11, 1, 60312, 8ba4355ecf4d738524bd331b98e87af7
+0, 12, 12, 1, 59196, 1efcac9ee097b0e027cc4e9d9d61037c
+0, 13, 13, 1, 59684, 9815ca06f7a99fb648f8f2856441517f
+0, 14, 14, 1, 61028, e4d684a1106cf78cd19ed87bd7ff7bab
+0, 15, 15, 1, 61116, 60f20615fb500d1baf9b1d07aa0f62f4
+0, 16, 16, 1, 60096, 35bc9f5e7f8a34c4221840f556d99df8
+0, 17, 17, 1, 59900, c8f756e698eeff9b55d83319f96865ce
+0, 18, 18, 1, 59424, 3ac4bb99ded21039ec65b1959c27347e
+0, 19, 19, 1, 59100, ff576160ae91bd8466f6d33b5750cce9
+0, 20, 20, 1, 58768, 86ed0e0c1a0f23ee6f3beabd0cc5691d
+0, 21, 21, 1, 58604, c0674d3c5973ff503e736a984326b42d
+0, 22, 22, 1, 58984, ec47ecc40d18b5e5216572db7aca4399
+0, 23, 23, 1, 59724, 119c234e452012e4475d09698e859dbc
+0, 24, 24, 1, 60688, 6720b72beefcdaa5355a68b763b8c7ca
+0, 25, 25, 1, 59768, 2dc4e643f97f9123842836df17a165ce
+0, 26, 26, 1, 59116, 3660544cdd5c0424578aa2cf6edc93d5
+0, 27, 27, 1, 58776, 465d3d35793fd088644746fc2b941a3c
+0, 28, 28, 1, 56948, c452face29e359c118cb206b8a99330e
+0, 29, 29, 1, 56984, d8c15040ca27d8cbf5e0f4a9464de289
+0, 30, 30, 1, 58172, 930839ebaa292a9f3348da3ba58a8c1f
+0, 31, 31, 1, 59008, bb9d062bf494bc1d4a0056dd8790bb25
+0, 32, 32, 1, 59568, e3f0f969063c614f7fefbc0269c4c029
+0, 33, 33, 1, 61276, f2e98cab7a320a9748c943910d0eda1d
+0, 34, 34, 1, 60056, 6875b10061cb1c303a18f186d65247ed
+0, 35, 35, 1, 59272, ad3f45ed83560479904c6395f857c95b
+0, 36, 36, 1, 58592, eca4f8faa40a737f56f6e492d98845c1
+0, 37, 37, 1, 58764, fa68a3723ba5b965532768b41dc73b60
+0, 38, 38, 1, 58300, 741a2ae174d721e3f3c0d13e54132095
+0, 39, 39, 1, 58260, 3546ddc2620a4c9fa415c0252a5eb9a4
+0, 40, 40, 1, 57324, f11c6053a5448e9b4830ef4fe833e5de
+0, 41, 41, 1, 58988, 6ae00a0b48f5ecdafcfd958684a21bcb
+0, 42, 42, 1, 58828, 6239ee212ca7decde8ad4cb304f0f786
+0, 43, 43, 1, 58736, 279226528c101b94f4e458151e7f5383
+0, 44, 44, 1, 58160, 2e8427fd4f232a7798488dfbbbc93db0
+0, 45, 45, 1, 56796, fab0929df1bfa6d4f09d962defaa58e7
+0, 46, 46, 1, 55932, 71da16ee5673bdbc5b69f01da23725d3
+0, 47, 47, 1, 56368, 20a7d362adb0f920f792106d034630fe
+0, 48, 48, 1, 56424, ba44ca273348efefafb5e73df81e26e9
+0, 49, 49, 1, 55508, e6df309da7552a2676e82f1f4644a694
diff --git a/tests/ref/fate/utvideoenc_yuv420_median b/tests/ref/fate/utvideoenc_yuv420_median
new file mode 100644
index 0000000000..b5288d38cd
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_yuv420_median
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 62916, e8443c85edaa534618869eb50a54d8ee
+0, 1, 1, 1, 62856, 0b9504992a19ffbe5a1f12d823a15f0f
+0, 2, 2, 1, 64112, 609f1d6cfd57fc87565f3078c48c06f0
+0, 3, 3, 1, 62748, e57217dc1de96a6c9494ceea126e71a1
+0, 4, 4, 1, 61696, d3bba27c92b9cc4503274dffdcb7de3e
+0, 5, 5, 1, 63320, f84c26950c6aa2a29af17a923723ea18
+0, 6, 6, 1, 63556, 2f2b60577616ea085b77b0154b8eb935
+0, 7, 7, 1, 62812, c2cd5836f6ea3bcbf5affdfb623e1aab
+0, 8, 8, 1, 63204, 010dd4c0a5681507f96502abfe1a8b55
+0, 9, 9, 1, 63516, 69b945a7afd1efad7c473c1113f66c5f
+0, 10, 10, 1, 63356, 05c2acb737b75e96d757fbd4270d9109
+0, 11, 11, 1, 63364, f63b1184912c6f25fce3f5fd166fc90c
+0, 12, 12, 1, 62416, 3bb6161920400a4535188103e5ee9b64
+0, 13, 13, 1, 62980, 6482cec5429083c3759588a2d81c2dc8
+0, 14, 14, 1, 63964, 8567a41bc0e6a6acef2c5b9991a370da
+0, 15, 15, 1, 64044, a80fc046d821bb7d3b1d0732b5528a0d
+0, 16, 16, 1, 62976, 623d43978c0255d7ad94dbbb08911c74
+0, 17, 17, 1, 63084, 1459781283da8935125776f157db1fc9
+0, 18, 18, 1, 62436, e9c751f7690590affd7e85775fe21fca
+0, 19, 19, 1, 62168, 948822a3568448032d2d0742031c6a33
+0, 20, 20, 1, 61724, 724e7f5384f8a9c7a03cba49abc1bef1
+0, 21, 21, 1, 61736, 3b0a781f947af472439852fd70d7e235
+0, 22, 22, 1, 62000, 0e41647e42cecc7644a42e3d96f34cfb
+0, 23, 23, 1, 62848, 1fc1813e6b44d573f3327533c161a262
+0, 24, 24, 1, 63504, 96c17ee6abc37fa6db608716d02b8ac7
+0, 25, 25, 1, 62732, 2cbeaaddd16d4686a3abdfaba7309107
+0, 26, 26, 1, 62288, b7263b7119853aee434290fb3cd30a16
+0, 27, 27, 1, 61788, e915b09f59360c1ffb92c2b80499e020
+0, 28, 28, 1, 60272, 0aab9182c5fb047344bdae541fb1befb
+0, 29, 29, 1, 60268, bc1bf979670850c37ab31e329dd909a6
+0, 30, 30, 1, 61268, 74a62d3c1363ea38d2a8687ac39a4112
+0, 31, 31, 1, 62264, 5b689d5835044b1582f664c1a3c3f336
+0, 32, 32, 1, 62668, 10638908ec2b59e0b75168ed7cce4141
+0, 33, 33, 1, 63864, 78bac64552f0a2450fc87fe8153a6774
+0, 34, 34, 1, 63032, befb82196b484ec3bb9d0eb57beb3c42
+0, 35, 35, 1, 62512, aea5110ce91111c9ce93865a82134125
+0, 36, 36, 1, 61772, 2744a404a3448db9db6214c688b4ed9f
+0, 37, 37, 1, 62044, c712fbf903d575fd4adc926470f99799
+0, 38, 38, 1, 61780, 97664d4ecf4492e0b8aa3ca025730158
+0, 39, 39, 1, 61724, 4b89a0cb4f99398e412eb4c4b8268fad
+0, 40, 40, 1, 60560, db2de1312d493917ebd805972a0d0086
+0, 41, 41, 1, 62284, b85ab454e9599ca9b52fc4e3ad2faaec
+0, 42, 42, 1, 61864, ae717317d753d6334d317abff4c51491
+0, 43, 43, 1, 61728, 70d6c4c68a112fde735195c5177123c8
+0, 44, 44, 1, 61252, 14b9a9e1686a1787991dfd40ed871184
+0, 45, 45, 1, 60224, ad1094331e5b2c27381e4e1781baa85c
+0, 46, 46, 1, 59416, a7b2ef933eaf0c8706bcf1f1f06dc01e
+0, 47, 47, 1, 59656, 89ff0f1c3ded6aa335f9c3ee66dead8e
+0, 48, 48, 1, 59616, 5fc6c44004562ed74b536374059a8bdd
+0, 49, 49, 1, 58836, feb32d803459a18e487f87c02ec1bf5c
diff --git a/tests/ref/fate/utvideoenc_yuv420_none b/tests/ref/fate/utvideoenc_yuv420_none
new file mode 100644
index 0000000000..981339140d
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_yuv420_none
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 144516, 8b4c8d3ae74da0306cbb7c6709f16ec5
+0, 1, 1, 1, 144504, 041bcfd819fec93241baa2797e2c97c2
+0, 2, 2, 1, 144384, 9a3efab6db020060e877bcd68f6153b5
+0, 3, 3, 1, 144428, d650148e1b29eaf2ada94bad59214b06
+0, 4, 4, 1, 144596, 8a070f1c074181d3ebc8ff93d8218c91
+0, 5, 5, 1, 144456, d53157d4f6d4c97452061b05e9bd4589
+0, 6, 6, 1, 144424, fc15bb77ea351dcb8790f6a228d9a899
+0, 7, 7, 1, 144416, 36d9f2deea7d96c8c694a0464fbfb6f6
+0, 8, 8, 1, 144328, 07850891af07fd9491b7d4957309c59a
+0, 9, 9, 1, 144328, 98ec846ba6a928f1f8feaceffdc2ca47
+0, 10, 10, 1, 144252, eecbc81aeef72a557681fff3ade0e1ea
+0, 11, 11, 1, 144176, 716f45f97fbbee271c756b51c1442a04
+0, 12, 12, 1, 144460, 4b53f968b67f0a3fcc751551685dc616
+0, 13, 13, 1, 144320, a0989eba4abc67fc3f97286b5ebb6b6f
+0, 14, 14, 1, 144256, b565b531adde9de04ac8dd18441f4b10
+0, 15, 15, 1, 144240, 93866939e1799cc7a638e684d583c3fc
+0, 16, 16, 1, 144320, 6289947dfb7c1c56f7f38c293325b08d
+0, 17, 17, 1, 144360, d348dba72b01e64687d9772c6e408f16
+0, 18, 18, 1, 144356, a7285a69d3351c0ff37fc4e052e4445e
+0, 19, 19, 1, 144368, 6fc446cf8455acec4422dc87c9c3fd9a
+0, 20, 20, 1, 144388, 54d73f606e23d78675cf505a2e877e2f
+0, 21, 21, 1, 144424, 2d55f4fc58a611608c814bf624671103
+0, 22, 22, 1, 144352, ccd87aa111216071adba2ac6867e5a70
+0, 23, 23, 1, 144384, 5a159db181501aafac455eb6ec37645b
+0, 24, 24, 1, 144384, 0cd8523c88838fb4e59200d324206fc5
+0, 25, 25, 1, 144328, 7a537ae88e6b91ee637415fc1bdfdfb3
+0, 26, 26, 1, 144416, 2beb77ab1ec30d463442ba1b0b995a22
+0, 27, 27, 1, 144524, 032209c413e2906cea0ac1f229e731b0
+0, 28, 28, 1, 144680, 370581756f4df5ecb7127d9bad3f219d
+0, 29, 29, 1, 144656, b43f514332e63452f08cfcecca2c2820
+0, 30, 30, 1, 144500, 8debbbdf18df1a82161356f93aa5da22
+0, 31, 31, 1, 144504, 04b1d817b10d4529d0108311e131a395
+0, 32, 32, 1, 144380, f64c22d9b822b2b7744ed17dc93c0fea
+0, 33, 33, 1, 144176, b7fe2a1d51921876dc3294a28a8b73f4
+0, 34, 34, 1, 144188, bdbaf871cf4f0f9762d487719bd5d70d
+0, 35, 35, 1, 144356, b90c993423632180fcc924fb687a6e2b
+0, 36, 36, 1, 144556, 2d88e31846cdb41ab346dd94fc473854
+0, 37, 37, 1, 144524, 95b4f8749ee5dbeda91c0e650b13c250
+0, 38, 38, 1, 144540, c34b4aa099ec50f3f10d52670a8e3d2e
+0, 39, 39, 1, 144460, a4f79bdebaed29910d148293c6909766
+0, 40, 40, 1, 144540, c359072ba35fb124eb6da7a74e7d746b
+0, 41, 41, 1, 144356, 6c759d3621208fe60018d0bac631fbe3
+0, 42, 42, 1, 144340, 421a7417934af7f46c121c45b7ee9d28
+0, 43, 43, 1, 144436, 7954efe1687e9d823018aef879ac5958
+0, 44, 44, 1, 144488, 338bfdc6ac006a086c19ba256226d4f8
+0, 45, 45, 1, 144604, ff31f6f7706968bb150c98fd17ce59ac
+0, 46, 46, 1, 144600, a532db975d958b0b17406b3e7cae78a5
+0, 47, 47, 1, 144520, b1c007e9f754c2ddf039f3d4767cdcb1
+0, 48, 48, 1, 144472, a03290fb08b8b054f18fee2209f5bd13
+0, 49, 49, 1, 144508, 7d9eda64f4fc11c95dcd63a1130cb5ab
diff --git a/tests/ref/fate/utvideoenc_yuv422_left b/tests/ref/fate/utvideoenc_yuv422_left
new file mode 100644
index 0000000000..f8ec6112dc
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_yuv422_left
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 93168, 083b68ac10646d425382cd3aed5d0ef0
+0, 1, 1, 1, 93400, f8d2b0fed320270c980140d187d01a25
+0, 2, 2, 1, 94536, f66ff5cccd63a468feb84aa22dae1c7c
+0, 3, 3, 1, 92928, 255ea0d934558adc2e2637bddb1284cf
+0, 4, 4, 1, 91800, 864d823c5885003e72f41a869c74d769
+0, 5, 5, 1, 93468, c6bfb70c03a7cfb4ec09acf2d7ec4f91
+0, 6, 6, 1, 93460, 6a5834ca48a2707e456d8c9c67b2cebb
+0, 7, 7, 1, 93132, 2c3968dc6af9917bee1846e1c85c5e99
+0, 8, 8, 1, 93252, a6739a7d07fd86f135c79e271da1789c
+0, 9, 9, 1, 93580, 8b587ed5fc102e2a0fff55674b1ada23
+0, 10, 10, 1, 93548, 4a87d1f0f5a1c3047aa77fc6d10cb6d1
+0, 11, 11, 1, 93520, 520bfaebdf5d972dae3671626374bed4
+0, 12, 12, 1, 92168, cc7c57ef93047aa13cf3fc5872564563
+0, 13, 13, 1, 92860, 8851d9930079a406d9cba89ce00a7feb
+0, 14, 14, 1, 94380, 2eb1d9ef63a0e74487f36f3e97bdf291
+0, 15, 15, 1, 94392, 2c9e589c3ccece6541193b7e61bf28d9
+0, 16, 16, 1, 93360, e138b833f6af0d0e189e8c3879af4cdd
+0, 17, 17, 1, 93108, 597e4c457845667e553c96b02acc40c3
+0, 18, 18, 1, 92568, 1623855c558e4b779bada7149adcb752
+0, 19, 19, 1, 92232, 78666f67c9b6eeff682f5ebf2e2b5145
+0, 20, 20, 1, 91696, aba549ebc0337df1aa5708cde9c4650d
+0, 21, 21, 1, 91688, cc7b65f321a50e117168b0be6a2c4a0f
+0, 22, 22, 1, 92164, 29b235028ca0bf6d9b752069529e2105
+0, 23, 23, 1, 92812, a23ca4b1b02965afc8cddf4b6022e9c1
+0, 24, 24, 1, 93960, afc0e5e4d45f9af68555cfff9e7f2e5d
+0, 25, 25, 1, 92892, 16d1afc5c8aa8b3b55e52e91e5baed53
+0, 26, 26, 1, 92248, a4dd3afd173d419eaec5f9632e64da0f
+0, 27, 27, 1, 91864, 614063fe03b92352d05d746dcabbbd10
+0, 28, 28, 1, 89756, 5a963cfeabc03d1409533bf2e5dd700b
+0, 29, 29, 1, 89812, f4fea21c34be3e85ba0790ef1e992214
+0, 30, 30, 1, 91184, 7aaad112ebb7fa15612fa63c8b313f80
+0, 31, 31, 1, 92076, de3c4aefe9c84b73b9c9494c09a0b22c
+0, 32, 32, 1, 92532, 4f445ee8eeaf323a9ff012a05ca1d3e2
+0, 33, 33, 1, 94572, 00cd8ab5abe5faa6cf59e54f3871a242
+0, 34, 34, 1, 93368, a303dd519e8ff023f488e4e2ee33e256
+0, 35, 35, 1, 92420, efce365314ac4d9e40959de0fc6fc01b
+0, 36, 36, 1, 91696, bb00659a54d8ded77615403962765238
+0, 37, 37, 1, 91912, b0e97a8ef2c73cd3d3b6a2d0bf08a1df
+0, 38, 38, 1, 91080, ff5e3be417b46de0bd9af03fb0ac7429
+0, 39, 39, 1, 91124, 9bca613b7f5a6543b63ad15c2198c037
+0, 40, 40, 1, 90188, 89b0ca054eead42930b946f7199b4fba
+0, 41, 41, 1, 91888, eda5dc80817de04c2528872e773bf3a9
+0, 42, 42, 1, 91832, eaea94320b6a85179a63b6330663d439
+0, 43, 43, 1, 91760, 412fca7fd02727857d4440cec3d4c0df
+0, 44, 44, 1, 91108, 9718c1bf512ee2be617bbc526211e8e0
+0, 45, 45, 1, 89544, b225acdf63a0183d00cd1f04ec0e49c9
+0, 46, 46, 1, 88544, 4ed88cdc92c56f872e5e696fb4da6f0d
+0, 47, 47, 1, 88960, 8b907526f25008a30e5c333867a21f54
+0, 48, 48, 1, 89068, 3bc4c3f7cb75befba57895b6c9e1d64e
+0, 49, 49, 1, 88012, 90132fa682959e1e3a1484b174cb2041
diff --git a/tests/ref/fate/utvideoenc_yuv422_median b/tests/ref/fate/utvideoenc_yuv422_median
new file mode 100644
index 0000000000..9981e06cfc
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_yuv422_median
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 90796, f90f29632eceac669132286385798866
+0, 1, 1, 1, 90652, 62890a83da5b9226ff197a0508d0db21
+0, 2, 2, 1, 91856, 815baaed2e42f9bf201f0b4630f265b9
+0, 3, 3, 1, 90572, 5e94b63fea1cb60f32f66a23ea97ea4d
+0, 4, 4, 1, 89580, ec8d444349c59dfbafd57095d0cab03a
+0, 5, 5, 1, 91148, 51be2db33b11859938c3162b02d2b183
+0, 6, 6, 1, 91212, 32df9c063904005a6c5a3a91b2e57b0d
+0, 7, 7, 1, 90376, 9959a40ad11a0a7e6f98a3bb2e1842cd
+0, 8, 8, 1, 90856, d03fa2bf67361ae27167ca61e0fa37da
+0, 9, 9, 1, 91356, ea2b8edf132d0492d6241f655a291a0c
+0, 10, 10, 1, 91032, 6204ddfa158037ee362920176597d85e
+0, 11, 11, 1, 91004, d210d0cc04e423e59fac9aaaf9bf01bd
+0, 12, 12, 1, 90096, 615dbf6c64f6165902a25970d226feb8
+0, 13, 13, 1, 90832, 66858d96fdb0dc8d89f1902591ccc886
+0, 14, 14, 1, 91688, 34a7ad1554020c4c78319803b41281d9
+0, 15, 15, 1, 91796, fd7cb3faaab8ca700dd0854915f72bb0
+0, 16, 16, 1, 90836, 983958df5d66c85194c2e2e7b27cf91b
+0, 17, 17, 1, 90848, 09d8051c04533059768b75967509c752
+0, 18, 18, 1, 90088, cf3fb73f2382063aa76bcdbe00739a9f
+0, 19, 19, 1, 89892, e6c2ec30ea12db29eedd649aa9a62476
+0, 20, 20, 1, 89304, 19603c655f5445bd4dadd4b88e482096
+0, 21, 21, 1, 89560, 0e842bf72ce795b37dcd588874913d2b
+0, 22, 22, 1, 89604, 83320a47a9882645aee67e8d343aee07
+0, 23, 23, 1, 90684, c45b3a01ab736a363f4771a277d3bf37
+0, 24, 24, 1, 91224, dbaf3f033273748bba13bc3332f399d5
+0, 25, 25, 1, 90480, de5b49620f1242f24250721dab315f71
+0, 26, 26, 1, 89988, a0d8ff14f468c5281c7bb80524743cbc
+0, 27, 27, 1, 89636, 68ca298fa61d18c963c0b9610dfb48bf
+0, 28, 28, 1, 88168, 22128400447fe0fcc9f067e1430e462e
+0, 29, 29, 1, 88188, 0816840bbd1b2857e99973a69e65c26a
+0, 30, 30, 1, 89068, bcf924eea0f45a9eeb01a886a154d969
+0, 31, 31, 1, 90104, 1b19dd4e4ed22e56b707f63f559174c6
+0, 32, 32, 1, 90344, 0142df8c6dfb99108622e8e7c8ebfd6d
+0, 33, 33, 1, 91348, 031e49bf9dc9e2c9ac6a86ab5bdba307
+0, 34, 34, 1, 90740, 5d4428cb9a61a57bfa724e0aea500db1
+0, 35, 35, 1, 90204, ad8a5494a7145e13aa3eb811f0af5843
+0, 36, 36, 1, 89708, 2421d07a9ed208f993d92c7d1f9c3fac
+0, 37, 37, 1, 90036, c4edb940ea1f10b716100fde23a5cb08
+0, 38, 38, 1, 89560, f6ba26af186ee1c7189603e6335281a8
+0, 39, 39, 1, 89464, aa77758a59ab9a7a3952dd9456040a5d
+0, 40, 40, 1, 88380, 78cd903ba608c770aeec39f13bd44896
+0, 41, 41, 1, 89872, 21e9e482d36a30bbff9ad897a2bda3f4
+0, 42, 42, 1, 89504, 9149a892a42e065079d614fba1e367c8
+0, 43, 43, 1, 89408, b5ed6ff8f7682a71ca2ca2bca5b1dbc0
+0, 44, 44, 1, 88916, 712d9669ad046b3993371cfb618c934e
+0, 45, 45, 1, 87948, 47c9bfa99221085efffe30e7b335beaa
+0, 46, 46, 1, 87284, 821cc4427f2649322950116caad44e96
+0, 47, 47, 1, 87424, 0d072e86818957bc3c40ffeb090dbcd8
+0, 48, 48, 1, 87296, 05bfe7d720b225ffc6b09a4ddf6ffa36
+0, 49, 49, 1, 86416, 85df53da921ba046d8e1d07349819236
diff --git a/tests/ref/fate/utvideoenc_yuv422_none b/tests/ref/fate/utvideoenc_yuv422_none
new file mode 100644
index 0000000000..e926f5341d
--- /dev/null
+++ b/tests/ref/fate/utvideoenc_yuv422_none
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0, 0, 0, 1, 191788, ff02a91e03b0a94b37af9ea51ab68242
+0, 1, 1, 1, 191808, 655052bb397edc4391f1eb650dc47871
+0, 2, 2, 1, 191652, fa6238888b811ede6e9c9f62e70dd0f7
+0, 3, 3, 1, 191680, 54d54092523e7930aa4a8f9368512281
+0, 4, 4, 1, 191964, 5ef03667afca82f49916ae83e195882a
+0, 5, 5, 1, 191748, dac12c404963c2e0ae5b48a7fdf73e77
+0, 6, 6, 1, 191708, 040941871e8c877f187bcf6bf4ced7e9
+0, 7, 7, 1, 191676, 9743925e523417ebb8bc67398db998bb
+0, 8, 8, 1, 191564, 1ed1955e9917b449820910a7f0b32ccf
+0, 9, 9, 1, 191548, d5c4c8105156760a0ec6fe301ecdf21c
+0, 10, 10, 1, 191456, dbc73bc7e39f40fc270bf679f581d4dd
+0, 11, 11, 1, 191276, a824fb35c5ae1373cc7bf21b07cc8c76
+0, 12, 12, 1, 191688, bdb5ef586ef4ff64c4f4bde0ce0bfc51
+0, 13, 13, 1, 191412, 1639afbba6e6b5781355377e450cf8b4
+0, 14, 14, 1, 191408, 086b3cef987cc05cde1ab4e65a08eaa0
+0, 15, 15, 1, 191404, 72ba9aa193eb87d7ac7631abc1a57926
+0, 16, 16, 1, 191488, 20b5d383654a24966ae8cef0bb9797d9
+0, 17, 17, 1, 191568, 73a64fc6f24d33dc66c3f250bb2bb780
+0, 18, 18, 1, 191592, c53abd778e04e5c7872cc683f14d1573
+0, 19, 19, 1, 191604, 49a74ad438ecf106c5f463293b2b244c
+0, 20, 20, 1, 191588, 73424c3524c45610276116f947acf453
+0, 21, 21, 1, 191648, 931d156f5077fafc3d3de5992924bf04
+0, 22, 22, 1, 191536, 07e2afbbb3089ebe578606190c13d1d9
+0, 23, 23, 1, 191584, c4612e5016957be04efde7ed617ef366
+0, 24, 24, 1, 191636, dc050ed93382112e04c70671527a30f5
+0, 25, 25, 1, 191512, 185b3fce35bd0daec1863a867924e0af
+0, 26, 26, 1, 191632, 3943a51c9b74627cfb957ed48e2f05c9
+0, 27, 27, 1, 191796, 0b9f806f55ee7a4e3da57d020f55a506
+0, 28, 28, 1, 192012, 682a5ccd7ceabd0b78e082db56d0cdea
+0, 29, 29, 1, 191952, 125f8574ea41e351197a5ea19fdef534
+0, 30, 30, 1, 191724, 37a0f598b5499d8f87bc59e3533ae865
+0, 31, 31, 1, 191780, 4af30d848aae71f6b771772650f19855
+0, 32, 32, 1, 191624, 253d25de282366630257cc475bc25406
+0, 33, 33, 1, 191392, 00e0e8f4e9e957b11d8cd06c808564c3
+0, 34, 34, 1, 191328, a920f74d3c03b861156509dc1056bb15
+0, 35, 35, 1, 191532, bd46443a91845d421a1d602884c2752f
+0, 36, 36, 1, 191844, b1e04afa26a9bee13fc7cc2736987d8e
+0, 37, 37, 1, 191824, 611a706a43ad910e90bf8fd3818ca987
+0, 38, 38, 1, 191800, a810b661c6be0257df68252b36f7cf3d
+0, 39, 39, 1, 191692, 4560e8f9db047066e5140d59f408c82c
+0, 40, 40, 1, 191804, 1ba3a85b5a3f4ca503aa2ef4ae3a7b79
+0, 41, 41, 1, 191540, e739afb686e4d0d7ae2817ecc5fba584
+0, 42, 42, 1, 191536, fbb2e21954ff43b603c932ca03dd71d0
+0, 43, 43, 1, 191680, ee91c6758842419248ed5ecbdbdfaf89
+0, 44, 44, 1, 191784, 8137a4fd101c279d62ab23ef08bc763a
+0, 45, 45, 1, 191936, 838ee8574f632222c45866841749cd9c
+0, 46, 46, 1, 191912, 80f414eca8c544d09acac6696314a74b
+0, 47, 47, 1, 191772, 5e457f447e765b2f13e8e9a9af359ec8
+0, 48, 48, 1, 191704, 501ce8349316c6ab1c3100eecb31b551
+0, 49, 49, 1, 191720, 3999f5d44150a6e44cf4fe55a3d146e0