[FFmpeg-cvslog] avcodec/jpeg2000dwt: Factor dwt test code out so it can be easily used with the other dwts too
Michael Niedermayer
git at videolan.org
Sat Jun 20 02:33:53 CEST 2015
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jun 20 01:45:18 2015 +0200| [116e7d5418bcd984c65d289605d9658409172d5c] | committer: Michael Niedermayer
avcodec/jpeg2000dwt: Factor dwt test code out so it can be easily used with the other dwts too
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=116e7d5418bcd984c65d289605d9658409172d5c
---
libavcodec/jpeg2000dwt.c | 57 +++++++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 23 deletions(-)
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index e15f00e..4e7bfa1 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -614,12 +614,41 @@ void ff_dwt_destroy(DWTContext *s)
#define MAX_W 256
+static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_levels, int type) {
+ int ret, j;
+ DWTContext s1={{{0}}}, *s= &s1;
+
+ ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, type);
+ if (ret < 0) {
+ fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
+ return 1;
+ }
+ ret = ff_dwt_encode(s, array);
+ if (ret < 0) {
+ fprintf(stderr, "ff_dwt_encode failed\n");
+ return 1;
+ }
+ ret = ff_dwt_decode(s, array);
+ if (ret < 0) {
+ fprintf(stderr, "ff_dwt_encode failed\n");
+ return 1;
+ }
+ for (j = 0; j<MAX_W * MAX_W; j++)
+ if (array[j] != ref[j]) {
+ fprintf(stderr, "missmatch at %d (%d != %d) decomp:%d border %d %d %d %d\n",
+ j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]);
+ return 2;
+ }
+ ff_dwt_destroy(s);
+
+ return 0;
+}
+
int main(void) {
int array[MAX_W * MAX_W];
int ref [MAX_W * MAX_W];
AVLFG prng;
int i,j;
- DWTContext s1={{{0}}}, *s= &s1;
uint16_t border[2][2];
int ret, decomp_levels;
@@ -634,28 +663,10 @@ int main(void) {
if (border[0][0] >= border[0][1] || border[1][0] >= border[1][1])
continue;
decomp_levels = av_lfg_get(&prng) % FF_DWT_MAX_DECLVLS;
- ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, FF_DWT53);
- if (ret < 0) {
- fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
- return 1;
- }
- ret = ff_dwt_encode(s, array);
- if (ret < 0) {
- fprintf(stderr, "ff_dwt_encode failed\n");
- return 1;
- }
- ret = ff_dwt_decode(s, array);
- if (ret < 0) {
- fprintf(stderr, "ff_dwt_encode failed\n");
- return 1;
- }
- for (j = 0; j<MAX_W * MAX_W; j++)
- if (array[j] != ref[j]) {
- fprintf(stderr, "missmatch at %d (%d != %d) decomp:%d border %d %d %d %d\n",
- j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]);
- return 2;
- }
- ff_dwt_destroy(s);
+
+ ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53);
+ if (ret)
+ return ret;
}
return 0;
More information about the ffmpeg-cvslog
mailing list