Commit 1ab5a780 authored by Jan Ekström's avatar Jan Ekström Committed by Anton Khirnov

lavc: add Ut Video encoder

Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 677e763a
......@@ -43,6 +43,7 @@ version <next>:
- RTMPTE protocol support
- Canopus Lossless Codec decoder
- avconv -shortest option is now per-output file
- Ut Video encoder
version 0.8:
......
......@@ -620,7 +620,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 v410 QuickTime uncompressed 4:4:4 10-bit @tab X @tab X
@item VBLE Lossless Codec @tab @tab X
......
......@@ -377,7 +377,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_V410_DECODER) += v410dec.o
......
......@@ -209,7 +209,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 (V410, v410);
......
/*
* Common Ut Video code
* Copyright (c) 2011 Konstantin Shishkov
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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 Libav; 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;
}
/*
* Common Ut Video header
* Copyright (c) 2011 Konstantin Shishkov
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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 Libav; 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 */
......@@ -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)
{
......@@ -434,20 +399,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);
}
}
}
......
This diff is collapsed.
......@@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 25
#define LIBAVCODEC_VERSION_MINOR 26
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment