]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/indeo3.c
hevc: ppc: Add HEVC 4x4 IDCT for PowerPC
[ffmpeg] / libavcodec / indeo3.c
index f74ac42dede72257d6777bb3e07bc7b356fc68d6..1b5b6505d67dc0b1498ec7955dd5387297f140cb 100644 (file)
 
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+
 #include "avcodec.h"
+#include "bitstream.h"
 #include "bytestream.h"
-#include "get_bits.h"
 #include "hpeldsp.h"
 #include "internal.h"
 
@@ -52,7 +53,7 @@ enum {
 
 
 /* Some constants for parsing frame bitstream flags. */
-#define BS_8BIT_PEL     (1 << 1) ///< 8bit pixel bitdepth indicator
+#define BS_8BIT_PEL     (1 << 1) ///< 8-bit pixel bitdepth indicator
 #define BS_KEYFRAME     (1 << 2) ///< intra frame indicator
 #define BS_MV_Y_HALF    (1 << 4) ///< vertical mv halfpel resolution indicator
 #define BS_MV_X_HALF    (1 << 5) ///< horizontal mv halfpel resolution indicator
@@ -65,7 +66,7 @@ typedef struct Plane {
     uint8_t         *pixels[2]; ///< pointer to the actual pixel data of the buffers above
     uint32_t        width;
     uint32_t        height;
-    uint32_t        pitch;
+    ptrdiff_t       pitch;
 } Plane;
 
 #define CELL_STACK_MAX  20
@@ -83,7 +84,7 @@ typedef struct Indeo3DecodeContext {
     AVCodecContext *avctx;
     HpelDSPContext  hdsp;
 
-    GetBitContext   gb;
+    BitstreamContext bc;
     int             need_resync;
     int             skip_bits;
     const uint8_t   *next_cell_data;
@@ -151,7 +152,8 @@ static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx,
                                           AVCodecContext *avctx)
 {
     int p, luma_width, luma_height, chroma_width, chroma_height;
-    int luma_pitch, chroma_pitch, luma_size, chroma_size;
+    int luma_size, chroma_size;
+    ptrdiff_t luma_pitch, chroma_pitch;
 
     luma_width  = ctx->width;
     luma_height = ctx->height;
@@ -307,7 +309,7 @@ static inline uint32_t replicate32(uint32_t a) {
 }
 
 
-/* Fill n lines with 64bit pixel value pix */
+/* Fill n lines with 64-bit pixel value pix */
 static inline void fill_64(uint8_t *dst, const uint64_t pix, int32_t n,
                            int32_t row_offset)
 {
@@ -415,7 +417,7 @@ if (*data_ptr >= last_ptr) \
 
 static int decode_cell_data(Indeo3DecodeContext *ctx, Cell *cell,
                             uint8_t *block, uint8_t *ref_block,
-                            int pitch, int h_zoom, int v_zoom, int mode,
+                            ptrdiff_t row_offset, int h_zoom, int v_zoom, int mode,
                             const vqEntry *delta[2], int swap_quads[2],
                             const uint8_t **data_ptr, const uint8_t *last_ptr)
 {
@@ -426,9 +428,8 @@ static int decode_cell_data(Indeo3DecodeContext *ctx, Cell *cell,
     unsigned int  dyad1, dyad2;
     uint64_t      pix64;
     int           skip_flag = 0, is_top_of_cell, is_first_row = 1;
-    int           row_offset, blk_row_offset, line_offset;
+    int           blk_row_offset, line_offset;
 
-    row_offset     =  pitch;
     blk_row_offset = (row_offset << (2 + v_zoom)) - (cell->width << 2);
     line_offset    = v_zoom ? row_offset : 0;
 
@@ -725,8 +726,8 @@ enum {
     ctx->need_resync = 1
 
 #define RESYNC_BITSTREAM \
-    if (ctx->need_resync && !(get_bits_count(&ctx->gb) & 7)) { \
-        skip_bits_long(&ctx->gb, ctx->skip_bits);              \
+    if (ctx->need_resync && !(bitstream_tell(&ctx->bc) & 7)) { \
+        bitstream_skip(&ctx->bc, ctx->skip_bits);              \
         ctx->skip_bits   = 0;                                  \
         ctx->need_resync = 0;                                  \
     }
@@ -773,7 +774,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
 
     while (1) { /* loop until return */
         RESYNC_BITSTREAM;
-        switch (code = get_bits(&ctx->gb, 2)) {
+        switch (code = bitstream_read(&ctx->bc, 2)) {
         case H_SPLIT:
         case V_SPLIT:
             if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width))
@@ -785,7 +786,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
                 curr_cell.tree   = 1; /* enter the VQ tree */
             } else { /* VQ tree NULL code */
                 RESYNC_BITSTREAM;
-                code = get_bits(&ctx->gb, 2);
+                code = bitstream_read(&ctx->bc, 2);
                 if (code >= 2) {
                     av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code);
                     return AVERROR_INVALIDDATA;
@@ -805,7 +806,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
                 unsigned mv_idx;
                 /* get motion vector index and setup the pointer to the mv set */
                 if (!ctx->need_resync)
-                    ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3];
+                    ctx->next_cell_data = &ctx->bc.buffer[(bitstream_tell(&ctx->bc) + 7) >> 3];
                 mv_idx = *(ctx->next_cell_data++);
                 if (mv_idx >= ctx->num_vectors) {
                     av_log(avctx, AV_LOG_ERROR, "motion vector index out of range\n");
@@ -816,7 +817,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
                 UPDATE_BITPOS(8);
             } else { /* VQ tree DATA code */
                 if (!ctx->need_resync)
-                    ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3];
+                    ctx->next_cell_data = &ctx->bc.buffer[(bitstream_tell(&ctx->bc) + 7) >> 3];
 
                 CHECK_CELL
                 bytes_used = decode_cell(ctx, avctx, plane, &curr_cell,
@@ -831,8 +832,6 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
             break;
         }
     }//while
-
-    return 0;
 }
 
 
@@ -858,7 +857,7 @@ static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
     ctx->mc_vectors  = num_vectors ? data : 0;
 
     /* init the bitreader */
-    init_get_bits(&ctx->gb, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3);
+    bitstream_init(&ctx->bc, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3);
     ctx->skip_bits   = 0;
     ctx->need_resync = 0;
 
@@ -928,7 +927,7 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
     if (width != ctx->width || height != ctx->height) {
         int res;
 
-        av_dlog(avctx, "Frame dimensions changed!\n");
+        ff_dlog(avctx, "Frame dimensions changed!\n");
 
         if (width  < 16 || width  > 640 ||
             height < 16 || height > 480 ||
@@ -1011,11 +1010,11 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
  *  @param[in]  dst_height   output plane height
  */
 static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst,
-                         int dst_pitch, int dst_height)
+                         ptrdiff_t dst_pitch, int dst_height)
 {
     int             x,y;
     const uint8_t   *src  = plane->pixels[buf_sel];
-    uint32_t        pitch = plane->pitch;
+    ptrdiff_t       pitch = plane->pitch;
 
     dst_height = FFMIN(dst_height, plane->height);
     for (y = 0; y < dst_height; y++) {
@@ -1134,5 +1133,5 @@ AVCodec ff_indeo3_decoder = {
     .init           = decode_init,
     .close          = decode_close,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = AV_CODEC_CAP_DR1,
 };