From 1ab5a780424ae8755858e153def1173a50a44e4c Mon Sep 17 00:00:00 2001 From: Jan Ekström Date: Mon, 20 Aug 2012 12:15:34 +0300 Subject: lavc: add Ut Video encoder Signed-off-by: Anton Khirnov --- libavcodec/utvideodec.c | 57 +++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 45 deletions(-) (limited to 'libavcodec/utvideodec.c') 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); } } } -- cgit v1.2.3