mirror of https://github.com/FFmpeg/FFmpeg.git
* commit 'e6bc38fd49c94726b45d5d5cc2b756ad8ec49ee0': wmv2: move IDCT to its own DSP context. Conflicts: libavcodec/dsputil.h tests/ref/seek/vsynth2-wmv2 tests/ref/vsynth/vsynth1-wmv2 tests/ref/vsynth/vsynth2-wmv2 Merged-by: Michael Niedermayer <michaelni@gmx.at>pull/11/head
commit
db23d5de27
11 changed files with 224 additions and 121 deletions
@ -0,0 +1,145 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "libavutil/common.h" |
||||
#include "avcodec.h" |
||||
#include "wmv2dsp.h" |
||||
|
||||
#define W0 2048 |
||||
#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ |
||||
#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ |
||||
#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ |
||||
#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ |
||||
#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ |
||||
#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ |
||||
#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ |
||||
|
||||
static void wmv2_idct_row(short * b) |
||||
{ |
||||
int s1, s2; |
||||
int a0, a1, a2, a3, a4, a5, a6, a7; |
||||
|
||||
/* step 1 */ |
||||
a1 = W1 * b[1] + W7 * b[7]; |
||||
a7 = W7 * b[1] - W1 * b[7]; |
||||
a5 = W5 * b[5] + W3 * b[3]; |
||||
a3 = W3 * b[5] - W5 * b[3]; |
||||
a2 = W2 * b[2] + W6 * b[6]; |
||||
a6 = W6 * b[2] - W2 * b[6]; |
||||
a0 = W0 * b[0] + W0 * b[4]; |
||||
a4 = W0 * b[0] - W0 * b[4]; |
||||
|
||||
/* step 2 */ |
||||
s1 = (181 * (a1 - a5 + a7 - a3) + 128) >> 8; // 1, 3, 5, 7
|
||||
s2 = (181 * (a1 - a5 - a7 + a3) + 128) >> 8; |
||||
|
||||
/* step 3 */ |
||||
b[0] = (a0 + a2 + a1 + a5 + (1 << 7)) >> 8; |
||||
b[1] = (a4 + a6 + s1 + (1 << 7)) >> 8; |
||||
b[2] = (a4 - a6 + s2 + (1 << 7)) >> 8; |
||||
b[3] = (a0 - a2 + a7 + a3 + (1 << 7)) >> 8; |
||||
b[4] = (a0 - a2 - a7 - a3 + (1 << 7)) >> 8; |
||||
b[5] = (a4 - a6 - s2 + (1 << 7)) >> 8; |
||||
b[6] = (a4 + a6 - s1 + (1 << 7)) >> 8; |
||||
b[7] = (a0 + a2 - a1 - a5 + (1 << 7)) >> 8; |
||||
} |
||||
|
||||
static void wmv2_idct_col(short * b) |
||||
{ |
||||
int s1, s2; |
||||
int a0, a1, a2, a3, a4, a5, a6, a7; |
||||
|
||||
/* step 1, with extended precision */ |
||||
a1 = (W1 * b[8 * 1] + W7 * b[8 * 7] + 4) >> 3; |
||||
a7 = (W7 * b[8 * 1] - W1 * b[8 * 7] + 4) >> 3; |
||||
a5 = (W5 * b[8 * 5] + W3 * b[8 * 3] + 4) >> 3; |
||||
a3 = (W3 * b[8 * 5] - W5 * b[8 * 3] + 4) >> 3; |
||||
a2 = (W2 * b[8 * 2] + W6 * b[8 * 6] + 4) >> 3; |
||||
a6 = (W6 * b[8 * 2] - W2 * b[8 * 6] + 4) >> 3; |
||||
a0 = (W0 * b[8 * 0] + W0 * b[8 * 4] ) >> 3; |
||||
a4 = (W0 * b[8 * 0] - W0 * b[8 * 4] ) >> 3; |
||||
|
||||
/* step 2 */ |
||||
s1 = (181 * (a1 - a5 + a7 - a3) + 128) >> 8; |
||||
s2 = (181 * (a1 - a5 - a7 + a3) + 128) >> 8; |
||||
|
||||
/* step 3 */ |
||||
b[8 * 0] = (a0 + a2 + a1 + a5 + (1 << 13)) >> 14; |
||||
b[8 * 1] = (a4 + a6 + s1 + (1 << 13)) >> 14; |
||||
b[8 * 2] = (a4 - a6 + s2 + (1 << 13)) >> 14; |
||||
b[8 * 3] = (a0 - a2 + a7 + a3 + (1 << 13)) >> 14; |
||||
|
||||
b[8 * 4] = (a0 - a2 - a7 - a3 + (1 << 13)) >> 14; |
||||
b[8 * 5] = (a4 - a6 - s2 + (1 << 13)) >> 14; |
||||
b[8 * 6] = (a4 + a6 - s1 + (1 << 13)) >> 14; |
||||
b[8 * 7] = (a0 + a2 - a1 - a5 + (1 << 13)) >> 14; |
||||
} |
||||
|
||||
static void wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < 64; i += 8) |
||||
wmv2_idct_row(block + i); |
||||
for (i = 0; i < 8; i++) |
||||
wmv2_idct_col(block + i); |
||||
|
||||
for (i = 0; i < 8; i++) { |
||||
dest[0] = av_clip_uint8(dest[0] + block[0]); |
||||
dest[1] = av_clip_uint8(dest[1] + block[1]); |
||||
dest[2] = av_clip_uint8(dest[2] + block[2]); |
||||
dest[3] = av_clip_uint8(dest[3] + block[3]); |
||||
dest[4] = av_clip_uint8(dest[4] + block[4]); |
||||
dest[5] = av_clip_uint8(dest[5] + block[5]); |
||||
dest[6] = av_clip_uint8(dest[6] + block[6]); |
||||
dest[7] = av_clip_uint8(dest[7] + block[7]); |
||||
dest += line_size; |
||||
block += 8; |
||||
} |
||||
} |
||||
|
||||
static void wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < 64; i += 8) |
||||
wmv2_idct_row(block + i); |
||||
for (i = 0; i < 8; i++) |
||||
wmv2_idct_col(block + i); |
||||
|
||||
for (i = 0; i < 8; i++) { |
||||
dest[0] = av_clip_uint8(block[0]); |
||||
dest[1] = av_clip_uint8(block[1]); |
||||
dest[2] = av_clip_uint8(block[2]); |
||||
dest[3] = av_clip_uint8(block[3]); |
||||
dest[4] = av_clip_uint8(block[4]); |
||||
dest[5] = av_clip_uint8(block[5]); |
||||
dest[6] = av_clip_uint8(block[6]); |
||||
dest[7] = av_clip_uint8(block[7]); |
||||
dest += line_size; |
||||
block += 8; |
||||
} |
||||
} |
||||
|
||||
av_cold void ff_wmv2dsp_init(WMV2DSPContext *c) |
||||
{ |
||||
c->idct_add = wmv2_idct_add_c; |
||||
c->idct_put = wmv2_idct_put_c; |
||||
c->idct_perm = FF_NO_IDCT_PERM; |
||||
} |
@ -0,0 +1,34 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_WMV2DSP_H |
||||
#define AVCODEC_WMV2DSP_H |
||||
|
||||
#include <stdint.h> |
||||
#include "dsputil.h" |
||||
|
||||
typedef struct WMV2DSPContext { |
||||
void (*idct_add)(uint8_t *dest, int line_size, DCTELEM *block); |
||||
void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block); |
||||
|
||||
int idct_perm; |
||||
} WMV2DSPContext; |
||||
|
||||
void ff_wmv2dsp_init(WMV2DSPContext *c); |
||||
|
||||
#endif /* AVCODEC_WMV2DSP_H */ |
@ -1,4 +1,4 @@ |
||||
532f99495482015c12a2773ec1065a4d *tests/data/fate/vsynth1-wmv2.avi |
||||
659832 tests/data/fate/vsynth1-wmv2.avi |
||||
3354066ebdd8cd8098394be2384744e7 *tests/data/fate/vsynth1-wmv2.out.rawvideo |
||||
stddev: 7.97 PSNR: 30.09 MAXDIFF: 110 bytes: 7603200/ 7603200 |
||||
4ab9357e6369c81fecb1ebcbc7551f0c *tests/data/fate/vsynth1-wmv2.avi |
||||
659138 tests/data/fate/vsynth1-wmv2.avi |
||||
8a6061ef825e79d887705db656d51247 *tests/data/fate/vsynth1-wmv2.out.rawvideo |
||||
stddev: 7.97 PSNR: 30.09 MAXDIFF: 105 bytes: 7603200/ 7603200 |
||||
|
@ -1,4 +1,4 @@ |
||||
f2a29f4e98a526e104067ca381716e47 *tests/data/fate/vsynth2-wmv2.avi |
||||
129834 tests/data/fate/vsynth2-wmv2.avi |
||||
dec44e3c04db4fef49a7728f164d9159 *tests/data/fate/vsynth2-wmv2.out.rawvideo |
||||
stddev: 5.33 PSNR: 33.60 MAXDIFF: 77 bytes: 7603200/ 7603200 |
||||
1b0e968e180346914c11875f4eec57eb *tests/data/fate/vsynth2-wmv2.avi |
||||
129852 tests/data/fate/vsynth2-wmv2.avi |
||||
b4de16a0d302c52702f7a4362da989bc *tests/data/fate/vsynth2-wmv2.out.rawvideo |
||||
stddev: 5.33 PSNR: 33.59 MAXDIFF: 77 bytes: 7603200/ 7603200 |
||||
|
Loading…
Reference in new issue