Skip to content

Commit 6a58326

Browse files
committed
avcodec/proresdec : add 12b prores idct
based on patch by Kieran Kunhya
1 parent fddc92d commit 6a58326

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

libavcodec/proresdsp.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,61 @@
2929

3030
#define CLIP_MIN (1 << 2) ///< minimum value for clipping resulting pixels
3131
#define CLIP_MAX_10 (1 << 10) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels
32+
#define CLIP_MAX_12 (1 << 12) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels
3233

3334
#define CLIP_10(x) (av_clip((x), CLIP_MIN, CLIP_MAX_10))
35+
#define CLIP_12(x) (av_clip((x), CLIP_MIN, CLIP_MAX_12))
3436

3537
/**
3638
* Add bias value, clamp and output pixels of a slice
3739
*/
38-
static void put_pixels_10(uint16_t *dst, ptrdiff_t linesize, const int16_t *in)
39-
{
40+
41+
static inline void put_pixel(uint16_t *dst, ptrdiff_t linesize, const int16_t *in, int bits_per_raw_sample) {
4042
int x, y, src_offset, dst_offset;
4143

4244
for (y = 0, dst_offset = 0; y < 8; y++, dst_offset += linesize) {
4345
for (x = 0; x < 8; x++) {
4446
src_offset = (y << 3) + x;
4547

46-
dst[dst_offset + x] = CLIP_10(in[src_offset]);
48+
if (bits_per_raw_sample == 10) {
49+
dst[dst_offset + x] = CLIP_10(in[src_offset]);
50+
} else {//12b
51+
dst[dst_offset + x] = CLIP_12(in[src_offset]);
52+
}
4753
}
4854
}
4955
}
5056

57+
static void put_pixels_10(uint16_t *dst, ptrdiff_t linesize, const int16_t *in)
58+
{
59+
put_pixel(dst, linesize, in, 10);
60+
}
61+
62+
static void put_pixels_12(uint16_t *dst, ptrdiff_t linesize, const int16_t *in)
63+
{
64+
put_pixel(dst, linesize, in, 12);
65+
}
66+
5167
static void prores_idct_put_10_c(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat)
5268
{
5369
ff_prores_idct_10(block, qmat);
5470
put_pixels_10(out, linesize >> 1, block);
5571
}
5672

73+
static void prores_idct_put_12_c(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat)
74+
{
75+
ff_prores_idct_12(block, qmat);
76+
put_pixels_12(out, linesize >> 1, block);
77+
}
78+
5779
av_cold int ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
5880
{
5981
if (avctx->bits_per_raw_sample == 10) {
6082
dsp->idct_put = prores_idct_put_10_c;
6183
dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
84+
} else if (avctx->bits_per_raw_sample == 12) {
85+
dsp->idct_put = prores_idct_put_12_c;
86+
dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
6287
} else {
6388
return AVERROR_BUG;
6489
}

libavcodec/simple_idct.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,19 @@ void ff_prores_idct_10(int16_t *block, const int16_t *qmat)
251251
idctSparseCol_extrashift_10(block + i);
252252
}
253253
}
254+
255+
void ff_prores_idct_12(int16_t *block, const int16_t *qmat)
256+
{
257+
int i;
258+
259+
for (i = 0; i < 64; i++)
260+
block[i] *= qmat[i];
261+
262+
for (i = 0; i < 8; i++)
263+
idctRowCondDC_int16_12bit(block + i*8, 0);
264+
265+
for (i = 0; i < 8; i++) {
266+
block[i] += 8192;
267+
idctSparseCol_int16_12bit(block + i);
268+
}
269+
}

libavcodec/simple_idct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void ff_simple_idct_int16_12bit(int16_t *block);
5353
* for larger scale of input coefficients.
5454
*/
5555
void ff_prores_idct_10(int16_t *block, const int16_t *qmat);
56+
void ff_prores_idct_12(int16_t *block, const int16_t *qmat);
5657

5758
void ff_simple_idct248_put(uint8_t *dest, ptrdiff_t line_size, int16_t *block);
5859

0 commit comments

Comments
 (0)