summaryrefslogtreecommitdiff
path: root/libavcodec/utvideodec.c
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2012-08-20 12:15:34 +0300
committerAnton Khirnov <anton@khirnov.net>2012-08-20 11:22:59 +0200
commit1ab5a780424ae8755858e153def1173a50a44e4c (patch)
tree09c9bf900112cd918f78d14547ce163829a68408 /libavcodec/utvideodec.c
parent677e763a55dd882c08369f1b67277bf2f54387b7 (diff)
lavc: add Ut Video encoder
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/utvideodec.c')
-rw-r--r--libavcodec/utvideodec.c57
1 files changed, 12 insertions, 45 deletions
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 27980d8e5b..8b71d62886 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)
{
@@ -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);
}
}
}