This reduces code duplication and differences with the fork.
Unified · Split
| @@ -30,8 +30,8 @@ · 29 unmodified lines | |||
| 30 | #include "idctdsp_arm.h" | 30 | #include "idctdsp_arm.h" |
| 31 | 31 | ||
| 32 | /* XXX: local hack */ | 32 | /* XXX: local hack */ |
| 33 | static void (*ff_put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size); | 33 | static void (*put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size); |
| 34 | static void (*ff_add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size); | 34 | static void (*add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size); |
| 35 | 35 | ||
| 36 | void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest, | 36 | void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest, |
| 37 | int line_size); | 37 | int line_size); |
| @@ -41,25 +41,25 @@ void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest, · 3 unmodified lines | |||
| 41 | static void j_rev_dct_arm_put(uint8_t *dest, int line_size, int16_t *block) | 41 | static void j_rev_dct_arm_put(uint8_t *dest, int line_size, int16_t *block) |
| 42 | { | 42 | { |
| 43 | ff_j_rev_dct_arm(block); | 43 | ff_j_rev_dct_arm(block); |
| 44 | ff_put_pixels_clamped(block, dest, line_size); | 44 | put_pixels_clamped(block, dest, line_size); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static void j_rev_dct_arm_add(uint8_t *dest, int line_size, int16_t *block) | 47 | static void j_rev_dct_arm_add(uint8_t *dest, int line_size, int16_t *block) |
| 48 | { | 48 | { |
| 49 | ff_j_rev_dct_arm(block); | 49 | ff_j_rev_dct_arm(block); |
| 50 | ff_add_pixels_clamped(block, dest, line_size); | 50 | add_pixels_clamped(block, dest, line_size); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | static void simple_idct_arm_put(uint8_t *dest, int line_size, int16_t *block) | 53 | static void simple_idct_arm_put(uint8_t *dest, int line_size, int16_t *block) |
| 54 | { | 54 | { |
| 55 | ff_simple_idct_arm(block); | 55 | ff_simple_idct_arm(block); |
| 56 | ff_put_pixels_clamped(block, dest, line_size); | 56 | put_pixels_clamped(block, dest, line_size); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | static void simple_idct_arm_add(uint8_t *dest, int line_size, int16_t *block) | 59 | static void simple_idct_arm_add(uint8_t *dest, int line_size, int16_t *block) |
| 60 | { | 60 | { |
| 61 | ff_simple_idct_arm(block); | 61 | ff_simple_idct_arm(block); |
| 62 | ff_add_pixels_clamped(block, dest, line_size); | 62 | add_pixels_clamped(block, dest, line_size); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx, | 65 | av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx, |
| @@ -67,8 +67,8 @@ av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx, · 1 unmodified line | |||
| 67 | { | 67 | { |
| 68 | int cpu_flags = av_get_cpu_flags(); | 68 | int cpu_flags = av_get_cpu_flags(); |
| 69 | 69 | ||
| 70 | ff_put_pixels_clamped = c->put_pixels_clamped; | 70 | put_pixels_clamped = c->put_pixels_clamped; |
| 71 | ff_add_pixels_clamped = c->add_pixels_clamped; | 71 | add_pixels_clamped = c->add_pixels_clamped; |
| 72 | 72 | ||
| 73 | if (!avctx->lowres && !high_bit_depth) { | 73 | if (!avctx->lowres && !high_bit_depth) { |
| 74 | if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & CODEC_FLAG_BITEXACT)) || | 74 | if ((avctx->idct_algo == FF_IDCT_AUTO && !(avctx->flags & CODEC_FLAG_BITEXACT)) || |
| @@ -80,6 +80,27 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, · 79 unmodified lines | |||
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void ff_put_pixels_clamped(const int16_t *block, uint8_t *av_restrict pixels, | ||
| 84 | int line_size) | ||
| 85 | { | ||
| 86 | int i; | ||
| 87 | |||
| 88 | /* read the pixels */ | ||
| 89 | for (i = 0; i < 8; i++) { | ||
| 90 | pixels[0] = av_clip_uint8(block[0]); | ||
| 91 | pixels[1] = av_clip_uint8(block[1]); | ||
| 92 | pixels[2] = av_clip_uint8(block[2]); | ||
| 93 | pixels[3] = av_clip_uint8(block[3]); | ||
| 94 | pixels[4] = av_clip_uint8(block[4]); | ||
| 95 | pixels[5] = av_clip_uint8(block[5]); | ||
| 96 | pixels[6] = av_clip_uint8(block[6]); | ||
| 97 | pixels[7] = av_clip_uint8(block[7]); | ||
| 98 | |||
| 99 | pixels += line_size; | ||
| 100 | block += 8; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 83 | static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, | 104 | static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, |
| 84 | int line_size) | 105 | int line_size) |
| 85 | { | 106 | { |
| @@ -133,6 +154,26 @@ static void put_signed_pixels_clamped_c(const int16_t *block, · 47 unmodified lines | |||
| 133 | } | 154 | } |
| 134 | } | 155 | } |
| 135 | 156 | ||
| 157 | void ff_add_pixels_clamped(const int16_t *block, uint8_t *av_restrict pixels, | ||
| 158 | int line_size) | ||
| 159 | { | ||
| 160 | int i; | ||
| 161 | |||
| 162 | /* read the pixels */ | ||
| 163 | for (i = 0; i < 8; i++) { | ||
| 164 | pixels[0] = av_clip_uint8(pixels[0] + block[0]); | ||
| 165 | pixels[1] = av_clip_uint8(pixels[1] + block[1]); | ||
| 166 | pixels[2] = av_clip_uint8(pixels[2] + block[2]); | ||
| 167 | pixels[3] = av_clip_uint8(pixels[3] + block[3]); | ||
| 168 | pixels[4] = av_clip_uint8(pixels[4] + block[4]); | ||
| 169 | pixels[5] = av_clip_uint8(pixels[5] + block[5]); | ||
| 170 | pixels[6] = av_clip_uint8(pixels[6] + block[6]); | ||
| 171 | pixels[7] = av_clip_uint8(pixels[7] + block[7]); | ||
| 172 | pixels += line_size; | ||
| 173 | block += 8; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 136 | static void add_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, | 177 | static void add_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, |
| 137 | int line_size) | 178 | int line_size) |
| 138 | { | 179 | { |
| @@ -166,13 +207,13 @@ static void add_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pix · 27 unmodified lines | |||
| 166 | static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block) | 207 | static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block) |
| 167 | { | 208 | { |
| 168 | ff_j_rev_dct(block); | 209 | ff_j_rev_dct(block); |
| 169 | put_pixels_clamped_c(block, dest, line_size); | 210 | ff_put_pixels_clamped(block, dest, line_size); |
| 170 | } | 211 | } |
| 171 | 212 | ||
| 172 | static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block) | 213 | static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block) |
| 173 | { | 214 | { |
| 174 | ff_j_rev_dct(block); | 215 | ff_j_rev_dct(block); |
| 175 | add_pixels_clamped_c(block, dest, line_size); | 216 | ff_add_pixels_clamped(block, dest, line_size); |
| 176 | } | 217 | } |
| 177 | static void ff_jref_idct4_put(uint8_t *dest, int line_size, int16_t *block) | 218 | static void ff_jref_idct4_put(uint8_t *dest, int line_size, int16_t *block) |
| 178 | { | 219 | { |
| @@ -255,9 +296,9 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) · 76 unmodified lines | |||
| 255 | } | 296 | } |
| 256 | } | 297 | } |
| 257 | 298 | ||
| 258 | c->put_pixels_clamped = put_pixels_clamped_c; | 299 | c->put_pixels_clamped = ff_put_pixels_clamped; |
| 259 | c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; | 300 | c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; |
| 260 | c->add_pixels_clamped = add_pixels_clamped_c; | 301 | c->add_pixels_clamped = ff_add_pixels_clamped; |
| 261 | 302 | ||
| 262 | if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID) | 303 | if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID) |
| 263 | ff_xvididct_init(c, avctx); | 304 | ff_xvididct_init(c, avctx); |
| @@ -48,6 +48,11 @@ void ff_init_scantable_permutation(uint8_t *idct_permutation, · 47 unmodified lines | |||
| 48 | int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, | 48 | int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, |
| 49 | enum idct_permutation_type perm_type); | 49 | enum idct_permutation_type perm_type); |
| 50 | 50 | ||
| 51 | void ff_put_pixels_clamped(const int16_t *block, uint8_t *av_restrict pixels, | ||
| 52 | int line_size); | ||
| 53 | void ff_add_pixels_clamped(const int16_t *block, uint8_t *av_restrict pixels, | ||
| 54 | int line_size); | ||
| 55 | |||
| 51 | typedef struct IDCTDSPContext { | 56 | typedef struct IDCTDSPContext { |
| 52 | /* pixel ops : interface with DCT */ | 57 | /* pixel ops : interface with DCT */ |
| 53 | void (*put_pixels_clamped)(const int16_t *block /* align 16 */, | 58 | void (*put_pixels_clamped)(const int16_t *block /* align 16 */, |
| @@ -106,45 +111,4 @@ void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx, · 52 unmodified lines | |||
| 106 | void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, | 111 | void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, |
| 107 | unsigned high_bit_depth); | 112 | unsigned high_bit_depth); |
| 108 | 113 | ||
| 109 | static inline void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, | ||
| 110 | int line_size) | ||
| 111 | { | ||
| 112 | int i; | ||
| 113 | |||
| 114 | /* read the pixels */ | ||
| 115 | for (i = 0; i < 8; i++) { | ||
| 116 | pixels[0] = av_clip_uint8(block[0]); | ||
| 117 | pixels[1] = av_clip_uint8(block[1]); | ||
| 118 | pixels[2] = av_clip_uint8(block[2]); | ||
| 119 | pixels[3] = av_clip_uint8(block[3]); | ||
| 120 | pixels[4] = av_clip_uint8(block[4]); | ||
| 121 | pixels[5] = av_clip_uint8(block[5]); | ||
| 122 | pixels[6] = av_clip_uint8(block[6]); | ||
| 123 | pixels[7] = av_clip_uint8(block[7]); | ||
| 124 | |||
| 125 | pixels += line_size; | ||
| 126 | block += 8; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | static inline void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, | ||
| 131 | int line_size) | ||
| 132 | { | ||
| 133 | int i; | ||
| 134 | |||
| 135 | /* read the pixels */ | ||
| 136 | for (i = 0; i < 8; i++) { | ||
| 137 | pixels[0] = av_clip_uint8(pixels[0] + block[0]); | ||
| 138 | pixels[1] = av_clip_uint8(pixels[1] + block[1]); | ||
| 139 | pixels[2] = av_clip_uint8(pixels[2] + block[2]); | ||
| 140 | pixels[3] = av_clip_uint8(pixels[3] + block[3]); | ||
| 141 | pixels[4] = av_clip_uint8(pixels[4] + block[4]); | ||
| 142 | pixels[5] = av_clip_uint8(pixels[5] + block[5]); | ||
| 143 | pixels[6] = av_clip_uint8(pixels[6] + block[6]); | ||
| 144 | pixels[7] = av_clip_uint8(pixels[7] + block[7]); | ||
| 145 | pixels += line_size; | ||
| 146 | block += 8; | ||
| 147 | } | ||
| 148 | } | ||
| 149 | |||
| 150 | #endif /* AVCODEC_IDCTDSP_H */ | 114 | #endif /* AVCODEC_IDCTDSP_H */ |
| @@ -25,13 +25,13 @@ · 24 unmodified lines | |||
| 25 | static void idct_xvid_put(uint8_t *dest, int line_size, int16_t *block) | 25 | static void idct_xvid_put(uint8_t *dest, int line_size, int16_t *block) |
| 26 | { | 26 | { |
| 27 | ff_idct_xvid(block); | 27 | ff_idct_xvid(block); |
| 28 | put_pixels_clamped_c(block, dest, line_size); | 28 | ff_put_pixels_clamped(block, dest, line_size); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | static void idct_xvid_add(uint8_t *dest, int line_size, int16_t *block) | 31 | static void idct_xvid_add(uint8_t *dest, int line_size, int16_t *block) |
| 32 | { | 32 | { |
| 33 | ff_idct_xvid(block); | 33 | ff_idct_xvid(block); |
| 34 | add_pixels_clamped_c(block, dest, line_size); | 34 | ff_add_pixels_clamped(block, dest, line_size); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) | 37 | av_cold void ff_xvididct_init(IDCTDSPContext *c, AVCodecContext *avctx) |