#include #include #include #include #include //#define NEWDCT #include "frame.c" void print_mat(short *data,int width) { for(int i=0; i < 8; i++) printf("%hd %hd %hd %hd %hd %hd %hd %hd\n", data[i*width], data[i*width+1], data[i*width+2], data[i*width+3], data[i*width+4], data[i*width+5], data[i*width+6], data[i*width+7]); } int compare(Frame *f1, Frame *f2) { u_char * f1y, *f2y, *f1u, *f2u, *f1v, *f2v; int rc = 0; f1y = f1->Getydata(); f1u = f1->Getudata(); f1v = f1->Getvdata(); f2y = f2->Getydata(); f2u = f2->Getudata(); f2v = f2->Getvdata(); if((rc=memcmp(f1y, f2y, CIF_YSIZE))) return 4; if((rc=memcmp(f1u, f2u, CIF_USIZE))) return 5; if((rc=memcmp(f1v, f2v, CIF_VSIZE))) return 6; return 0; } int main(void) { static Frame *n_xn = new Frame(CIF_ROWS, CIF_COLS); static Frame *n_xn2 = new Frame(CIF_ROWS, CIF_COLS); static Frame *n_xn3 = new Frame(CIF_ROWS, CIF_COLS); static PicInfo *p = new PicInfo(CIF_FORMAT); u_char *xy, *xu, *xv; int rc = 0; xy = n_xn->Getydata(); xu = n_xn->Getudata(); xv = n_xn->Getvdata(); for(int i=0; i < CIF_YSIZE; i++) *xy++ = u_char(rand() >> 25); for(int i=0; i < CIF_USIZE; i++) *xu++ = u_char(rand() >> 25); for(int i=0; i < CIF_VSIZE; i++) *xv++ = u_char(rand() >> 25); char2shortframe(p->pixdata, n_xn); short2charframe(n_xn3, p->pixdata); // short2charframe(n_xn2, p->pixdata); rc = compare(n_xn, n_xn3); printf("xn, xn3 comparison = %d\n", rc); for(int gobnum=0; gobnum < NUM_CIFGBS; gobnum++) { for(int mbnum=0; mbnum < MBS_IN_GOB; mbnum++) { int mbcol, row, col, yoffset, uvoffset; int framewidth = CIF_COLS; mbcol = mbnum % MBCOLS_IN_GOB; row = (gobnum /2) * MBROWS_IN_GOB + mbnum/MBCOLS_IN_GOB; col = (gobnum %2) * MBCOLS_IN_GOB + mbcol; yoffset = row * YBLKELEMS * framewidth + col * YBLKELEMS; uvoffset = row * UVBLKELEMS * framewidth/2 + col * UVBLKELEMS; char2shortframe(p->pixdata, n_xn, yoffset, uvoffset); short2charframe(n_xn2, p->pixdata, yoffset, uvoffset); } } rc = compare(n_xn, n_xn2); printf("xn, xn2 comparison = %d\n", rc); // print_mat(data, width); return 0; }