Merge remote-tracking branch 'qatar/master'
[ffmpeg.git] / libavcodec / utvideodec.c
index ac1c5fe..1bd38dc 100644 (file)
 #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);
                 }
             }
         }