00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "proresdsp.h"
00024 #include "simple_idct.h"
00025 #include "libavutil/common.h"
00026
00027 #define BIAS (1 << (PRORES_BITS_PER_SAMPLE - 1))
00028 #define CLIP_MIN (1 << (PRORES_BITS_PER_SAMPLE - 8))
00029 #define CLIP_MAX (1 << PRORES_BITS_PER_SAMPLE) - CLIP_MIN - 1
00030
00031 #define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX))
00032
00033 #if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
00034
00037 static void put_pixels(uint16_t *dst, int stride, const DCTELEM *in)
00038 {
00039 int x, y, src_offset, dst_offset;
00040
00041 for (y = 0, dst_offset = 0; y < 8; y++, dst_offset += stride) {
00042 for (x = 0; x < 8; x++) {
00043 src_offset = (y << 3) + x;
00044
00045 dst[dst_offset + x] = CLIP_AND_BIAS(in[src_offset]);
00046 }
00047 }
00048 }
00049
00050 static void prores_idct_put_c(uint16_t *out, int linesize, DCTELEM *block, const int16_t *qmat)
00051 {
00052 ff_prores_idct(block, qmat);
00053 put_pixels(out, linesize >> 1, block);
00054 }
00055 #endif
00056
00057 #if CONFIG_PRORES_KOSTYA_ENCODER
00058 static void prores_fdct_c(const uint16_t *src, int linesize, DCTELEM *block)
00059 {
00060 int x, y;
00061 const uint16_t *tsrc = src;
00062
00063 for (y = 0; y < 8; y++) {
00064 for (x = 0; x < 8; x++)
00065 block[y * 8 + x] = tsrc[x];
00066 tsrc += linesize >> 1;
00067 }
00068 ff_jpeg_fdct_islow_10(block);
00069 }
00070 #endif
00071
00072 void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
00073 {
00074 #if CONFIG_PRORES_DECODER | CONFIG_PRORES_LGPL_DECODER
00075 dsp->idct_put = prores_idct_put_c;
00076 dsp->idct_permutation_type = FF_NO_IDCT_PERM;
00077
00078 if (HAVE_MMX) ff_proresdsp_x86_init(dsp, avctx);
00079
00080 ff_init_scantable_permutation(dsp->idct_permutation,
00081 dsp->idct_permutation_type);
00082 #endif
00083 #if CONFIG_PRORES_KOSTYA_ENCODER
00084 dsp->fdct = prores_fdct_c;
00085 dsp->dct_permutation_type = FF_NO_IDCT_PERM;
00086 ff_init_scantable_permutation(dsp->dct_permutation,
00087 dsp->dct_permutation_type);
00088 #endif
00089 }