From 276a73e2f29cce0c0e2dc18aa0e9e804b812762b Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 8 Mar 2009 13:32:42 +0000 Subject: Remove internal NuppelVideo decoder, the code in libavcodec can decode those files and some more and is far more maintainable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28888 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/native/nuppelvideo.c | 114 --- libmpcodecs/native/rtjpegn.c | 1670 ++++---------------------------------- libmpcodecs/native/rtjpegn.h | 2 - libmpcodecs/vd.c | 2 - libmpcodecs/vd_nuv.c | 54 -- 5 files changed, 145 insertions(+), 1697 deletions(-) delete mode 100644 libmpcodecs/native/nuppelvideo.c delete mode 100644 libmpcodecs/vd_nuv.c (limited to 'libmpcodecs') diff --git a/libmpcodecs/native/nuppelvideo.c b/libmpcodecs/native/nuppelvideo.c deleted file mode 100644 index 8128f85c47..0000000000 --- a/libmpcodecs/native/nuppelvideo.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * NuppelVideo 0.05 file parser - * for MPlayer - * by Panagiotis Issaris - * - * Reworked by alex - */ - -#include -#include -#include -#include - -#include "config.h" -#include "mp_msg.h" -#include "mpbswap.h" - -#include "libvo/fastmemcpy.h" - -#include "libmpdemux/nuppelvideo.h" -#include "rtjpegn.h" -#include "libavutil/lzo.h" - -#define KEEP_BUFFER - -void decode_nuv( unsigned char *encoded, int encoded_size, - unsigned char *decoded, int width, int height) -{ - int r; - unsigned int out_len = width * height + ( width * height ) / 2; - struct rtframeheader *encodedh = ( struct rtframeheader* ) encoded; - static unsigned char *buffer = 0; /* for RTJpeg with LZO decompress */ -#ifdef KEEP_BUFFER - static unsigned char *previous_buffer = 0; /* to support Last-frame-copy */ -#endif - -// printf("frametype: %c, comtype: %c, encoded_size: %d, width: %d, height: %d\n", -// encodedh->frametype, encodedh->comptype, encoded_size, width, height); - - le2me_rtframeheader(encodedh); - switch(encodedh->frametype) - { - case 'D': /* additional data for compressors */ - { - /* tables are in encoded */ - if (encodedh->comptype == 'R') - { - RTjpeg_init_decompress ( (unsigned long *)(encoded+12), width, height ); - mp_msg(MSGT_DECVIDEO, MSGL_V, "Found RTjpeg tables (size: %d, width: %d, height: %d)\n", - encoded_size-12, width, height); - } - break; - } - case 'V': - { - int in_len = encodedh->packetlength; -#ifdef KEEP_BUFFER - if (!previous_buffer) - previous_buffer = ( unsigned char * ) malloc ( out_len + AV_LZO_OUTPUT_PADDING ); -#endif - - switch(encodedh->comptype) - { - case '0': /* raw YUV420 */ - fast_memcpy(decoded, encoded + 12, out_len); - break; - case '1': /* RTJpeg */ - RTjpeg_decompressYUV420 ( ( __s8 * ) encoded + 12, decoded ); - break; - case '2': /* RTJpeg with LZO */ - if (!buffer) - buffer = ( unsigned char * ) malloc ( out_len + AV_LZO_OUTPUT_PADDING ); - if (!buffer) - { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n"); - break; - } - r = av_lzo1x_decode ( buffer, &out_len, encoded + 12, &in_len ); - if ( r ) - { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n"); - break; - } - RTjpeg_decompressYUV420 ( ( __s8 * ) buffer, decoded ); - break; - case '3': /* raw YUV420 with LZO */ - r = av_lzo1x_decode ( decoded, &out_len, encoded + 12, &in_len ); - if ( r ) - { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n"); - break; - } - break; - case 'N': /* black frame */ - memset ( decoded, 0, width * height ); - memset ( decoded + width * height, 127, width * height / 2); - break; - case 'L': /* copy last frame */ -#ifdef KEEP_BUFFER - fast_memcpy ( decoded, previous_buffer, width*height*3/2); -#endif - break; - } - -#ifdef KEEP_BUFFER - fast_memcpy(previous_buffer, decoded, width*height*3/2); -#endif - break; - } - default: - mp_msg(MSGT_DECVIDEO, MSGL_V, "Nuppelvideo: unknwon frametype: %c\n", - encodedh->frametype); - } -} diff --git a/libmpcodecs/native/rtjpegn.c b/libmpcodecs/native/rtjpegn.c index 3aa1faac74..0eea073b61 100644 --- a/libmpcodecs/native/rtjpegn.c +++ b/libmpcodecs/native/rtjpegn.c @@ -293,152 +293,6 @@ fprintf(stdout, "\n\n"); return (int)co; } -/* +++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* Stream to Block (decoding) */ -/* */ - -static int RTjpeg_s2b(__s16 *data, __s8 *strm, __u8 bt8, __u32 *qtbl) -{ - int ci; - register int co; - register int i; - register unsigned char bitten; - register unsigned char bitoff; - - /* first byte always read */ - i=RTjpeg_ZZ[0]; - data[i]=((__u8)strm[0])*qtbl[i]; - - /* we start at the behind */ - - bitten = ((unsigned char)strm[1]) >> 2; - co = 63; - for(; co > bitten; co--) { - - data[RTjpeg_ZZ[co]] = 0; - - } - - if (co==0) { - ci = 2; - goto AUTOBAHN; - } - - /* we have to read the last 2 bits of the second byte */ - ci=1; - bitoff = 0; - - for(; co>0; co--) { - - bitten = ((unsigned char)strm[ci]) >> bitoff; - bitten &= 0x03; - - i=RTjpeg_ZZ[co]; - - switch( bitten ) { - case 0x03: - data[i]= -qtbl[i]; - break; - case 0x02: - goto FUSSWEG; - break; - case 0x01: - data[i]= qtbl[i]; - break; - case 0x00: - data[i]= 0; - break; - default: - break; - } - - if( bitoff == 0 ) { - bitoff = 8; - ci++; - } - bitoff -= 2; - } - /* co is 0 now */ - /* data is written properly */ - - /* if bitoff!=6 then ci is the index, but should be the byte count, so we increment by 1 */ - if (bitoff!=6) ci++; - - goto AUTOBAHN; - - -FUSSWEG: -/* correct bitoff to nibble */ - switch(bitoff){ - case 4: - case 6: - bitoff = 0; - break; - case 2: - case 0: - /* we have to read from the next byte */ - ci++; - bitoff = 4; - break; - default: - break; - } - - for(; co>0; co--) { - - bitten = ((unsigned char)strm[ci]) >> bitoff; - bitten &= 0x0f; - - i=RTjpeg_ZZ[co]; - - if( bitten == 0x08 ) { - goto STRASSE; - } - - /* the compiler cannot do sign extension for signed nibbles */ - if( bitten & 0x08 ) { - bitten |= 0xf0; - } - /* the unsigned char bitten now is a valid signed char */ - - data[i]=((signed char)bitten)*qtbl[i]; - - if( bitoff == 0 ) { - bitoff = 8; - ci++; - } - bitoff -= 4; - } - /* co is 0 */ - - /* if bitoff!=4 then ci is the index, but should be the byte count, so we increment by 1 */ - if (bitoff!=4) ci++; - - goto AUTOBAHN; - -STRASSE: - ci++; - - for(; co>0; co--) { - i=RTjpeg_ZZ[co]; - data[i]=strm[ci++]*qtbl[i]; - } - - /* ci now is the count, because it points to next element => no incrementing */ - -AUTOBAHN: - -#ifdef SHOWBLOCK -fprintf(stdout, "\nci = '%d'\n", ci); - for (i=0; i < 64; i++) { - fprintf(stdout, "%d ", data[RTjpeg_ZZ[i]]); - } -fprintf(stdout, "\n\n"); -#endif - - return ci; -} - #else static int RTjpeg_b2s(__s16 *data, __s8 *strm, __u8 bt8) @@ -1536,1355 +1390,183 @@ static void RTjpeg_dctY(__u8 *idata, __s16 *odata, int rskip) #endif } -#define FIX_1_082392200 ((__s32) 277) /* FIX(1.082392200) */ -#define FIX_1_414213562 ((__s32) 362) /* FIX(1.414213562) */ -#define FIX_1_847759065 ((__s32) 473) /* FIX(1.847759065) */ -#define FIX_2_613125930 ((__s32) 669) /* FIX(2.613125930) */ - -#define DESCALE(x) (__s16)( ((x)+4) >> 3) - -/* clip yuv to 16..235 (should be 16..240 for cr/cb but ... */ - -#define RL(x) ((x)>235) ? 235 : (((x)<16) ? 16 : (x)) -#define MULTIPLY(var,const) (((__s32) ((var) * (const)) + 128)>>8) - -static void RTjpeg_idct_init(void) -{ - int i; - - for(i=0; i<64; i++) - { - RTjpeg_liqt[i]=((__u64)RTjpeg_liqt[i]*RTjpeg_aan_tab[i])>>32; - RTjpeg_ciqt[i]=((__u64)RTjpeg_ciqt[i]*RTjpeg_aan_tab[i])>>32; - } -} - -static void RTjpeg_idct(__u8 *odata, __s16 *data, int rskip) -{ -#if HAVE_MMX - -static mmx_t fix_141 = {0x5a825a825a825a82LL}; -static mmx_t fix_184n261 = {0xcf04cf04cf04cf04LL}; -static mmx_t fix_184 = {0x7641764176417641LL}; -static mmx_t fix_n184 = {0x896f896f896f896fLL}; -static mmx_t fix_108n184 = {0xcf04cf04cf04cf04LL}; - - mmx_t workspace[64]; - mmx_t *wsptr = workspace; - register mmx_t *dataptr = (mmx_t *)odata; - mmx_t *idata = (mmx_t *)data; - - rskip = rskip>>3; /* - * Perform inverse DCT on one block of coefficients. - */ - - /* Odd part */ - - movq_m2r(*(idata+10), mm1); // load idata[DCTSIZE*5] - - movq_m2r(*(idata+6), mm0); // load idata[DCTSIZE*3] - - movq_m2r(*(idata+2), mm3); // load idata[DCTSIZE*1] - - movq_r2r(mm1, mm2); // copy tmp6 /* phase 6 */ - - movq_m2r(*(idata+14), mm4); // load idata[DCTSIZE*7] - - paddw_r2r(mm0, mm1); // z13 = tmp6 + tmp5; - - psubw_r2r(mm0, mm2); // z10 = tmp6 - tmp5 - psllw_i2r(2, mm2); // shift z10 - movq_r2r(mm2, mm0); // copy z10 - - pmulhw_m2r(fix_184n261, mm2); // MULTIPLY( z12, FIX_1_847759065); /* 2*c2 */ - movq_r2r(mm3, mm5); // copy tmp4 - - pmulhw_m2r(fix_n184, mm0); // MULTIPLY(z10, -FIX_1_847759065); /* 2*c2 */ - paddw_r2r(mm4, mm3); // z11 = tmp4 + tmp7; - - movq_r2r(mm3, mm6); // copy z11 /* phase 5 */ - psubw_r2r(mm4, mm5); // z12 = tmp4 - tmp7; +Main Routines - psubw_r2r(mm1, mm6); // z11-z13 - psllw_i2r(2, mm5); // shift z12 +This file contains most of the initialisation and control functions - movq_m2r(*(idata+12), mm4); // load idata[DCTSIZE*6], even part - movq_r2r(mm5, mm7); // copy z12 +(C) Justin Schoeman 1998 - pmulhw_m2r(fix_108n184, mm5); // MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; /* 2*(c2-c6) */ even part - paddw_r2r(mm1, mm3); // tmp7 = z11 + z13; +*/ - //ok +/* - /* Even part */ - pmulhw_m2r(fix_184, mm7); // MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; /* -2*(c2+c6) */ - psllw_i2r(2, mm6); +Private function - movq_m2r(*(idata+4), mm1); // load idata[DCTSIZE*2] +Initialise all the cache-aliged data blocks - paddw_r2r(mm5, mm0); // tmp10 +*/ - paddw_r2r(mm7, mm2); // tmp12 +static void RTjpeg_init_data(void) +{ + unsigned long dptr; + + dptr=(unsigned long)&(RTjpeg_alldata[0]); + dptr+=32; + dptr=dptr>>5; + dptr=dptr<<5; /* cache align data */ + + RTjpeg_block=(__s16 *)dptr; + dptr+=sizeof(__s16)*64; + RTjpeg_lqt=(__s32 *)dptr; + dptr+=sizeof(__s32)*64; + RTjpeg_cqt=(__s32 *)dptr; + dptr+=sizeof(__s32)*64; + RTjpeg_liqt=(__u32 *)dptr; + dptr+=sizeof(__u32)*64; + RTjpeg_ciqt=(__u32 *)dptr; +} - pmulhw_m2r(fix_141, mm6); // tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - psubw_r2r(mm3, mm2); // tmp6 = tmp12 - tmp7 +/* - movq_r2r(mm1, mm5); // copy tmp1 - paddw_r2r(mm4, mm1); // tmp13= tmp1 + tmp3; /* phases 5-3 */ +External Function - psubw_r2r(mm4, mm5); // tmp1-tmp3 - psubw_r2r(mm2, mm6); // tmp5 = tmp11 - tmp6; +Re-set quality factor - movq_r2m(mm1, *(wsptr)); // save tmp13 in workspace - psllw_i2r(2, mm5); // shift tmp1-tmp3 - - movq_m2r(*(idata), mm7); // load idata[DCTSIZE*0] +Input: buf -> pointer to 128 ints for quant values store to pass back to + init_decompress. + Q -> quality factor (192=best, 32=worst) +*/ - pmulhw_m2r(fix_141, mm5); // MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - paddw_r2r(mm6, mm0); // tmp4 = tmp10 + tmp5; +static void RTjpeg_init_Q(__u8 Q) +{ + int i; + __u64 qual; + + qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */ - movq_m2r(*(idata+8), mm4); // load idata[DCTSIZE*4] - - psubw_r2r(mm1, mm5); // tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ + for(i=0; i<64; i++) + { + RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3); + if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1; + RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3); + if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1; + RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3); + RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3); + RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3; + RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3; + } + + RTjpeg_lb8=0; + while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); + RTjpeg_lb8--; + RTjpeg_cb8=0; + while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); + RTjpeg_cb8--; - movq_r2m(mm0, *(wsptr+4)); // save tmp4 in workspace - movq_r2r(mm7, mm1); // copy tmp0 /* phase 3 */ + RTjpeg_dct_init(); + RTjpeg_quant_init(); +} - movq_r2m(mm5, *(wsptr+2)); // save tmp12 in workspace - psubw_r2r(mm4, mm1); // tmp11 = tmp0 - tmp2; +/* - paddw_r2r(mm4, mm7); // tmp10 = tmp0 + tmp2; - movq_r2r(mm1, mm5); // copy tmp11 - - paddw_m2r(*(wsptr+2), mm1); // tmp1 = tmp11 + tmp12; - movq_r2r(mm7, mm4); // copy tmp10 /* phase 2 */ +External Function - paddw_m2r(*(wsptr), mm7); // tmp0 = tmp10 + tmp13; +Initialise compression. - psubw_m2r(*(wsptr), mm4); // tmp3 = tmp10 - tmp13; - movq_r2r(mm7, mm0); // copy tmp0 +Input: buf -> pointer to 128 ints for quant values store to pass back to + init_decompress. + width -> width of image + height -> height of image + Q -> quality factor (192=best, 32=worst) + +*/ - psubw_m2r(*(wsptr+2), mm5); // tmp2 = tmp11 - tmp12; - paddw_r2r(mm3, mm7); // wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); - - psubw_r2r(mm3, mm0); // wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); +void RTjpeg_init_compress(__u32 *buf, int width, int height, __u8 Q) +{ + int i; + __u64 qual; + + RTjpeg_init_data(); + + RTjpeg_width=width; + RTjpeg_height=height; + RTjpeg_Ywidth = RTjpeg_width>>3; + RTjpeg_Ysize=width * height; + RTjpeg_Cwidth = RTjpeg_width>>4; + RTjpeg_Csize= (width>>1) * height; - movq_r2m(mm7, *(wsptr)); // wsptr[DCTSIZE*0] - movq_r2r(mm1, mm3); // copy tmp1 + qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */ - movq_r2m(mm0, *(wsptr+14)); // wsptr[DCTSIZE*7] - paddw_r2r(mm2, mm1); // wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); + for(i=0; i<64; i++) + { + RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3); + if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1; + RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3); + if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1; + RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3); + RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3); + RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3; + RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3; + } + + RTjpeg_lb8=0; + while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); + RTjpeg_lb8--; + RTjpeg_cb8=0; + while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); + RTjpeg_cb8--; + + RTjpeg_dct_init(); + RTjpeg_quant_init(); - psubw_r2r(mm2, mm3); // wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); + for(i=0; i<64; i++) + buf[i]=le2me_32(RTjpeg_liqt[i]); + for(i=0; i<64; i++) + buf[64+i]=le2me_32(RTjpeg_ciqt[i]); +} - movq_r2m(mm1, *(wsptr+2)); // wsptr[DCTSIZE*1] - movq_r2r(mm4, mm1); // copy tmp3 +int RTjpeg_compressYUV420(__s8 *sp, unsigned char *bp) +{ + __s8 * sb; + register __s8 * bp1 = bp + (RTjpeg_width<<3); + register __s8 * bp2 = bp + RTjpeg_Ysize; + register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1); + register int i, j, k; - movq_r2m(mm3, *(wsptr+12)); // wsptr[DCTSIZE*6] +#if HAVE_MMX + emms(); +#endif + sb=sp; +/* Y */ + for(i=RTjpeg_height>>1; i; i-=8) + { + for(j=0, k=0; j 0; ctr--) { - - if ((inptr[8] | inptr[16] | inptr[24] | - inptr[32] | inptr[40] | inptr[48] | inptr[56]) == 0) { - dcval = inptr[0]; - wsptr[0] = dcval; - wsptr[8] = dcval; - wsptr[16] = dcval; - wsptr[24] = dcval; - wsptr[32] = dcval; - wsptr[40] = dcval; - wsptr[48] = dcval; - wsptr[56] = dcval; - - inptr++; - wsptr++; - continue; - } - - tmp0 = inptr[0]; - tmp1 = inptr[16]; - tmp2 = inptr[32]; - tmp3 = inptr[48]; - - tmp10 = tmp0 + tmp2; - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; - tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - tmp4 = inptr[8]; - tmp5 = inptr[24]; - tmp6 = inptr[40]; - tmp7 = inptr[56]; - - z13 = tmp6 + tmp5; - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[0] = (__s32) (tmp0 + tmp7); - wsptr[56] = (__s32) (tmp0 - tmp7); - wsptr[8] = (__s32) (tmp1 + tmp6); - wsptr[48] = (__s32) (tmp1 - tmp6); - wsptr[16] = (__s32) (tmp2 + tmp5); - wsptr[40] = (__s32) (tmp2 - tmp5); - wsptr[32] = (__s32) (tmp3 + tmp4); - wsptr[24] = (__s32) (tmp3 - tmp4); - - inptr++; - wsptr++; - } - - wsptr = workspace; - for (ctr = 0; ctr < 8; ctr++) { - outptr = &(odata[ctr*rskip]); - - tmp10 = wsptr[0] + wsptr[4]; - tmp11 = wsptr[0] - wsptr[4]; - - tmp13 = wsptr[2] + wsptr[6]; - tmp12 = MULTIPLY(wsptr[2] - wsptr[6], FIX_1_414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - z13 = wsptr[5] + wsptr[3]; - z10 = wsptr[5] - wsptr[3]; - z11 = wsptr[1] + wsptr[7]; - z12 = wsptr[1] - wsptr[7]; - - tmp7 = z11 + z13; - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - outptr[0] = RL(DESCALE(tmp0 + tmp7)); - outptr[7] = RL(DESCALE(tmp0 - tmp7)); - outptr[1] = RL(DESCALE(tmp1 + tmp6)); - outptr[6] = RL(DESCALE(tmp1 - tmp6)); - outptr[2] = RL(DESCALE(tmp2 + tmp5)); - outptr[5] = RL(DESCALE(tmp2 - tmp5)); - outptr[4] = RL(DESCALE(tmp3 + tmp4)); - outptr[3] = RL(DESCALE(tmp3 - tmp4)); - - wsptr += 8; - } -#endif -} -/* - -Main Routines - -This file contains most of the initialisation and control functions - -(C) Justin Schoeman 1998 - -*/ - -/* - -Private function - -Initialise all the cache-aliged data blocks - -*/ - -static void RTjpeg_init_data(void) -{ - unsigned long dptr; - - dptr=(unsigned long)&(RTjpeg_alldata[0]); - dptr+=32; - dptr=dptr>>5; - dptr=dptr<<5; /* cache align data */ - - RTjpeg_block=(__s16 *)dptr; - dptr+=sizeof(__s16)*64; - RTjpeg_lqt=(__s32 *)dptr; - dptr+=sizeof(__s32)*64; - RTjpeg_cqt=(__s32 *)dptr; - dptr+=sizeof(__s32)*64; - RTjpeg_liqt=(__u32 *)dptr; - dptr+=sizeof(__u32)*64; - RTjpeg_ciqt=(__u32 *)dptr; -} - -/* - -External Function - -Re-set quality factor - -Input: buf -> pointer to 128 ints for quant values store to pass back to - init_decompress. - Q -> quality factor (192=best, 32=worst) -*/ - -static void RTjpeg_init_Q(__u8 Q) -{ - int i; - __u64 qual; - - qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */ - - for(i=0; i<64; i++) - { - RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3); - if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1; - RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3); - if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1; - RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3); - RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3); - RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3; - RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3; - } - - RTjpeg_lb8=0; - while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); - RTjpeg_lb8--; - RTjpeg_cb8=0; - while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); - RTjpeg_cb8--; - - RTjpeg_dct_init(); - RTjpeg_idct_init(); - RTjpeg_quant_init(); -} - -/* - -External Function - -Initialise compression. - -Input: buf -> pointer to 128 ints for quant values store to pass back to - init_decompress. - width -> width of image - height -> height of image - Q -> quality factor (192=best, 32=worst) - -*/ - -void RTjpeg_init_compress(__u32 *buf, int width, int height, __u8 Q) -{ - int i; - __u64 qual; - - RTjpeg_init_data(); - - RTjpeg_width=width; - RTjpeg_height=height; - RTjpeg_Ywidth = RTjpeg_width>>3; - RTjpeg_Ysize=width * height; - RTjpeg_Cwidth = RTjpeg_width>>4; - RTjpeg_Csize= (width>>1) * height; - - qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */ - - for(i=0; i<64; i++) - { - RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3); - if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1; - RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3); - if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1; - RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3); - RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3); - RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3; - RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3; - } - - RTjpeg_lb8=0; - while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); - RTjpeg_lb8--; - RTjpeg_cb8=0; - while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); - RTjpeg_cb8--; - - RTjpeg_dct_init(); - RTjpeg_quant_init(); - - for(i=0; i<64; i++) - buf[i]=le2me_32(RTjpeg_liqt[i]); - for(i=0; i<64; i++) - buf[64+i]=le2me_32(RTjpeg_ciqt[i]); -} - -void RTjpeg_init_decompress(__u32 *buf, int width, int height) -{ - int i; - - RTjpeg_init_data(); - - RTjpeg_width=width; - RTjpeg_height=height; - RTjpeg_Ywidth = RTjpeg_width>>3; - RTjpeg_Ysize=width * height; - RTjpeg_Cwidth = RTjpeg_width>>4; - RTjpeg_Csize= (width>>1) * height; - - for(i=0; i<64; i++) - { - RTjpeg_liqt[i]=le2me_32(buf[i]); - RTjpeg_ciqt[i]=le2me_32(buf[i+64]); - } - - RTjpeg_lb8=0; - while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8); - RTjpeg_lb8--; - RTjpeg_cb8=0; - while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8); - RTjpeg_cb8--; - - RTjpeg_idct_init(); -} - -int RTjpeg_compressYUV420(__s8 *sp, unsigned char *bp) -{ - __s8 * sb; - register __s8 * bp1 = bp + (RTjpeg_width<<3); - register __s8 * bp2 = bp + RTjpeg_Ysize; - register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1); - register int i, j, k; - -#if HAVE_MMX - emms(); -#endif - sb=sp; -/* Y */ - for(i=RTjpeg_height>>1; i; i-=8) - { - for(j=0, k=0; j>1); - int i, j,k; - -#if HAVE_MMX - emms(); -#endif - -/* Y */ - for(i=RTjpeg_height>>1; i; i-=8) - { - for(k=0, j=0; j>1); - } - if(*sp==-1)sp++; - else - { - sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt); - RTjpeg_idct(bp3+k, RTjpeg_block, RTjpeg_width>>1); - } - } - bp+=RTjpeg_width<<4; - bp1+=RTjpeg_width<<4; - bp2+=RTjpeg_width<<2; - bp3+=RTjpeg_width<<2; - } -#if HAVE_MMX - emms(); -#endif -} - /* External Function diff --git a/libmpcodecs/native/rtjpegn.h b/libmpcodecs/native/rtjpegn.h index 4ffcdfa39d..859b8238f8 100644 --- a/libmpcodecs/native/rtjpegn.h +++ b/libmpcodecs/native/rtjpegn.h @@ -36,9 +36,7 @@ #define __s64 int64_t void RTjpeg_init_compress(__u32 *buf, int width, int height, __u8 Q); -void RTjpeg_init_decompress(__u32 *buf, int width, int height); int RTjpeg_compressYUV420(__s8 *sp, unsigned char *bp); -void RTjpeg_decompressYUV420(__s8 *sp, __u8 *bp); void RTjpeg_init_mcompress(void); int RTjpeg_mcompressYUV420(__s8 *sp, unsigned char *bp, __u16 lmask, __u16 cmask); diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index b47f85357b..fa2f74ef00 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -35,7 +35,6 @@ extern vd_functions_t mpcodecs_vd_vfwex; extern vd_functions_t mpcodecs_vd_raw; extern vd_functions_t mpcodecs_vd_hmblck; extern vd_functions_t mpcodecs_vd_xanim; -extern vd_functions_t mpcodecs_vd_nuv; extern vd_functions_t mpcodecs_vd_mpng; extern vd_functions_t mpcodecs_vd_ijpg; extern vd_functions_t mpcodecs_vd_mtga; @@ -70,7 +69,6 @@ const vd_functions_t * const mpcodecs_vd_drivers[] = { &mpcodecs_vd_lzo, &mpcodecs_vd_raw, &mpcodecs_vd_hmblck, - &mpcodecs_vd_nuv, #ifdef CONFIG_XANIM &mpcodecs_vd_xanim, #endif diff --git a/libmpcodecs/vd_nuv.c b/libmpcodecs/vd_nuv.c deleted file mode 100644 index cb89ddb391..0000000000 --- a/libmpcodecs/vd_nuv.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -#include "config.h" -#include "mp_msg.h" - -#include "vd_internal.h" - -static vd_info_t info = { - "NuppelVideo decoder", - "nuv", - "A'rpi", - "Alex & Panagiotis Issaris ", - "native codecs" -}; - -LIBVD_EXTERN(nuv) - -// to set/get/query special features/parameters -static int control(sh_video_t *sh,int cmd,void* arg,...){ - return CONTROL_UNKNOWN; -} - -// init driver -static int init(sh_video_t *sh){ - return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420); -} - -// uninit driver -static void uninit(sh_video_t *sh){ -} - -//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); - -void decode_nuv( - unsigned char *encoded, - int encoded_size, - unsigned char *decoded, - int width, - int height); - -// decode a frame -static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ - mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame - - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0, - sh->disp_w, sh->disp_h); - if(!mpi) return NULL; - - decode_nuv(data, len, mpi->planes[0], sh->disp_w, sh->disp_h); - - return mpi; -} -- cgit v1.2.3