diff options
-rw-r--r-- | DOCS/ChangeLog | 5 | ||||
-rw-r--r-- | codecctrl.c | 9 | ||||
-rw-r--r-- | libmpeg2/Makefile | 4 | ||||
-rw-r--r-- | libmpeg2/attributes.h | 8 | ||||
-rw-r--r-- | libmpeg2/decode.c | 174 | ||||
-rw-r--r-- | libmpeg2/header.c | 91 | ||||
-rw-r--r-- | libmpeg2/idct.c | 5 | ||||
-rw-r--r-- | libmpeg2/idct_mlib.c | 6 | ||||
-rw-r--r-- | libmpeg2/idct_mmx.c | 57 | ||||
-rw-r--r-- | libmpeg2/mmx.h | 8 | ||||
-rw-r--r-- | libmpeg2/motion_comp.c | 6 | ||||
-rw-r--r-- | libmpeg2/motion_comp_mlib.c | 4 | ||||
-rw-r--r-- | libmpeg2/motion_comp_mmx.c | 56 | ||||
-rw-r--r-- | libmpeg2/mpeg2.h | 92 | ||||
-rw-r--r-- | libmpeg2/mpeg2_internal.h | 177 | ||||
-rw-r--r-- | libmpeg2/slice.c | 928 | ||||
-rw-r--r-- | libmpeg2/stats.c | 9 | ||||
-rw-r--r-- | libmpeg2/vlc.h | 18 | ||||
-rw-r--r-- | mplayer.c | 13 |
19 files changed, 814 insertions, 856 deletions
diff --git a/DOCS/ChangeLog b/DOCS/ChangeLog index 1950b334ef..eb28d1d277 100644 --- a/DOCS/ChangeLog +++ b/DOCS/ChangeLog @@ -12,7 +12,10 @@ Note: If you've sent patches not applied in pre22, please send them again! *** 0.11 release is coming SOON!!! *** -v0.11-CVS: yeah, we moved to SourceForge CVS! +v0.11-pre26-CVS: + - updated libmpeg2 source to libmpeg2-0.2.0 version + +v0.11-pre25: yeah, we moved to SourceForge CVS! - DOCS updated (email address changed from arpi@* -> maillist) - LIRC fix, mplayer_lirc changed back to mplayer [Andreas Ackermann] - stream.c: unsigned int fixes, required for some strange .asf files diff --git a/codecctrl.c b/codecctrl.c index 23b424308f..756428d8b5 100644 --- a/codecctrl.c +++ b/codecctrl.c @@ -91,6 +91,12 @@ void send_cmd(int fd,int cmd){ // fflush(control_fifo); } +static const int frameratecode2framerate[16] = { + 0, 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, + 60*10000, 0,0,0,0,0,0,0 +}; + + void mpeg_codec_controller(vo_functions_t *video_out){ //================== CODEC Controller: ========================== signal(SIGTERM,codec_ctrl_sighandler); // set our SIGTERM handler @@ -145,8 +151,9 @@ void mpeg_codec_controller(vo_functions_t *video_out){ mpeg2_decode_data(video_out, videobuffer, videobuffer+len); t+=GetTimer(); send_cmd(control_fifo2,0); // FRAME_COMPLETED command - send_cmd(control_fifo2,picture->frame_rate); // fps + send_cmd(control_fifo2,frameratecode2framerate[picture->frame_rate_code]); // fps send_cmd(control_fifo2,100+picture->repeat_count);picture->repeat_count=0; +// send_cmd(control_fifo2,100); // FIXME! send_cmd(control_fifo2,t);t=0; } video_out->uninit(); diff --git a/libmpeg2/Makefile b/libmpeg2/Makefile index f599aecfd2..ccc2e2595a 100644 --- a/libmpeg2/Makefile +++ b/libmpeg2/Makefile @@ -3,8 +3,8 @@ LIBNAME = libmpeg2.a include ../config.mak -SRCS = decode.c header.c idct.c idct_mmx.c motion_comp.c motion_comp_mmx.c slice.c stats.c -OBJS = decode.o header.o idct.o idct_mmx.o motion_comp.o motion_comp_mmx.o slice.o stats.o +SRCS = header.c idct.c idct_mmx.c motion_comp.c motion_comp_mmx.c slice.c stats.c decode.c +OBJS = header.o idct.o idct_mmx.o motion_comp.o motion_comp_mmx.o slice.o stats.o decode.o INCLUDE = -I. -I../libvo -I.. CFLAGS = $(OPTFLAGS) $(INCLUDE) -DMPG12PLAY diff --git a/libmpeg2/attributes.h b/libmpeg2/attributes.h index dfbf129411..3e14cab271 100644 --- a/libmpeg2/attributes.h +++ b/libmpeg2/attributes.h @@ -1,6 +1,6 @@ /* * attributes.h - * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * @@ -19,11 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//use gcc attribs to align critical data structures - -/* maximum supported data alignment */ -#define ATTRIBUTE_ALIGNED_MAX 64 - +/* use gcc attribs to align critical data structures */ #ifdef ATTRIBUTE_ALIGNED_MAX #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) #else diff --git a/libmpeg2/decode.c b/libmpeg2/decode.c index e8bbb02112..9426f4ff59 100644 --- a/libmpeg2/decode.c +++ b/libmpeg2/decode.c @@ -3,8 +3,7 @@ /* mpeg2dec version: */ #define PACKAGE "mpeg2dec" -//#define VERSION "0.1.7-cvs" -#define VERSION "0.1.8-cvs" +#define VERSION "0.2.0-release" #include <stdio.h> #include <stdlib.h> @@ -14,7 +13,8 @@ #include "config.h" -//#include "video_out.h" +#include "video_out.h" +#include <inttypes.h> #include "mpeg2.h" #include "mpeg2_internal.h" @@ -32,6 +32,9 @@ #include "mmx.h" #endif +#include "mm_accel.h" + + //this is where we keep the state of the decoder //picture_t picture_data; //picture_t *picture=&picture_data; @@ -48,7 +51,9 @@ mpeg2_config_t config; static int drop_flag = 0; static int drop_frame = 0; +#ifdef POSTPROC int quant_store[MBR+1][MBC+1]; // [Review] +#endif void mpeg2_init (void) { @@ -73,7 +78,7 @@ void mpeg2_init (void) picture=shmem_alloc(sizeof(picture_t)); // !!! NEW HACK :) !!! header_state_init (picture); - picture->repeat_count=0; +// picture->repeat_count=0; picture->pp_options=0; @@ -81,10 +86,13 @@ void mpeg2_init (void) motion_comp_init (); } +static vo_frame_t frames[3]; + void mpeg2_allocate_image_buffers (picture_t * picture) { int frame_size,buff_size; unsigned char *base=NULL; + int i; // height+1 requires for yuv2rgb_mmx code (it reads next line after last) frame_size = picture->coded_picture_width * (1+picture->coded_picture_height); @@ -92,56 +100,44 @@ void mpeg2_allocate_image_buffers (picture_t * picture) buff_size = frame_size + (frame_size/4)*2; // 4Y + 1U + 1V // allocate images in YV12 format - base = shmem_alloc(buff_size); - picture->throwaway_frame[0] = base; - picture->throwaway_frame[1] = base + frame_size * 5 / 4; - picture->throwaway_frame[2] = base + frame_size; - - base = shmem_alloc(buff_size); - picture->backward_reference_frame[0] = base; - picture->backward_reference_frame[1] = base + frame_size * 5 / 4; - picture->backward_reference_frame[2] = base + frame_size; - - base = shmem_alloc(buff_size); - picture->forward_reference_frame[0] = base; - picture->forward_reference_frame[1] = base + frame_size * 5 / 4; - picture->forward_reference_frame[2] = base + frame_size; + for(i=0;i<3;i++){ + base = shmem_alloc(buff_size); + frames[i].base[0] = base; + frames[i].base[1] = base + frame_size * 5 / 4; + frames[i].base[2] = base + frame_size; + frames[i].copy = NULL; + frames[i].vo = NULL; + frames[i].slice=0; + } + + picture->forward_reference_frame=&frames[0]; + picture->backward_reference_frame=&frames[1]; + picture->current_frame=&frames[2]; +#ifdef POSTPROC base = shmem_alloc(buff_size); picture->pp_frame[0] = base; picture->pp_frame[1] = base + frame_size * 5 / 4; picture->pp_frame[2] = base + frame_size; +#endif } -static void decode_reorder_frames (void) -{ - if (picture->picture_coding_type != B_TYPE) { - - //reuse the soon to be outdated forward reference frame - picture->current_frame[0] = picture->forward_reference_frame[0]; - picture->current_frame[1] = picture->forward_reference_frame[1]; - picture->current_frame[2] = picture->forward_reference_frame[2]; +static void copy_slice (vo_frame_t * frame, uint8_t ** src){ + vo_functions_t * output = frame->vo; + int stride[3]; + int y=frame->slice*16; - //make the backward reference frame the new forward reference frame - picture->forward_reference_frame[0] = - picture->backward_reference_frame[0]; - picture->forward_reference_frame[1] = - picture->backward_reference_frame[1]; - picture->forward_reference_frame[2] = - picture->backward_reference_frame[2]; + stride[0]=picture->coded_picture_width; + stride[1]=stride[2]=stride[0]/2; - picture->backward_reference_frame[0] = picture->current_frame[0]; - picture->backward_reference_frame[1] = picture->current_frame[1]; - picture->backward_reference_frame[2] = picture->current_frame[2]; + output->draw_slice (src, stride, + picture->display_picture_width, + (y+16<=picture->display_picture_height) ? 16 : + picture->display_picture_height-y, + 0, y); - } else { - - picture->current_frame[0] = picture->throwaway_frame[0]; - picture->current_frame[1] = picture->throwaway_frame[1]; - picture->current_frame[2] = picture->throwaway_frame[2]; - - } + ++frame->slice; } static int in_slice_flag=0; @@ -156,43 +152,27 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer) if (is_frame_done) { in_slice_flag = 0; - if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field); +// if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field); - if ( ((HACK_MODE == 2) || (picture->mpeg1)) - && ((picture->picture_structure == FRAME_PICTURE) || + if (((picture->picture_structure == FRAME_PICTURE) || (picture->second_field)) - ) { - uint8_t ** bar; - int stride[3]; - - if (picture->picture_coding_type == B_TYPE) - bar = picture->throwaway_frame; - else - bar = picture->forward_reference_frame; - - stride[0]=picture->coded_picture_width; - stride[1]=stride[2]=stride[0]/2; - - if(picture->pp_options){ - // apply OpenDivX postprocess filter - postprocess(bar, stride[0], - picture->pp_frame, stride[0], - picture->coded_picture_width, picture->coded_picture_height, - &quant_store[1][1], (MBC+1), picture->pp_options); - output->draw_slice (picture->pp_frame, stride, - picture->display_picture_width, - picture->display_picture_height, 0, 0); - } else { - output->draw_slice (bar, stride, + ) { +#if 1 + if (picture->picture_coding_type != B_TYPE) { + int stride[3]; + stride[0]=picture->coded_picture_width; + stride[1]=stride[2]=stride[0]/2; + output->draw_slice (picture->forward_reference_frame->base, + stride, picture->display_picture_width, picture->display_picture_height, 0, 0); } - - } +#endif + } #ifdef ARCH_X86 - if (config.flags & MM_ACCEL_X86_MMX) emms (); + if (config.flags & MM_ACCEL_X86_MMX) emms(); #endif - output->flip_page (); + output->flip_page(); } switch (code) { @@ -227,40 +207,32 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer) if (!(in_slice_flag)) { in_slice_flag = 1; - if(!(picture->second_field)) decode_reorder_frames (); +// if(!(picture->second_field)) decode_reorder_frames (); + + // set current_frame pointer: + if (picture->second_field){ +// vo_field (picture->current_frame, picture->picture_structure); + } else { + if (picture->picture_coding_type == B_TYPE){ + picture->current_frame = &frames[2]; + picture->current_frame->copy=copy_slice; + } else { + picture->current_frame = picture->forward_reference_frame; + picture->forward_reference_frame = picture->backward_reference_frame; + picture->backward_reference_frame = picture->current_frame; + picture->current_frame->copy=NULL; + } + } + + picture->current_frame->vo=output; + picture->current_frame->slice=0; + } if (!drop_frame) { - uint8_t ** bar; slice_process (picture, code, buffer); - if ((HACK_MODE < 2) && (!(picture->mpeg1))) { - uint8_t * foo[3]; - uint8_t ** bar; - //frame_t * bar; - int stride[3]; - int offset; - - if (picture->picture_coding_type == B_TYPE) - bar = picture->throwaway_frame; - else - bar = picture->forward_reference_frame; - - offset = (code-1) * 4 * picture->coded_picture_width; - if ((! HACK_MODE) && (picture->picture_coding_type == B_TYPE)) - offset = 0; - - foo[0] = bar[0] + 4 * offset; - foo[1] = bar[1] + offset; - foo[2] = bar[2] + offset; - - stride[0]=picture->coded_picture_width; - stride[1]=stride[2]=stride[0]/2; - - output->draw_slice (foo, stride, - picture->display_picture_width, 16, 0, (code-1)*16); - } #ifdef ARCH_X86 if (config.flags & MM_ACCEL_X86_MMX) emms (); #endif diff --git a/libmpeg2/header.c b/libmpeg2/header.c index 8f5b34359e..852ff541bd 100644 --- a/libmpeg2/header.c +++ b/libmpeg2/header.c @@ -1,6 +1,6 @@ /* * slice.c - * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * @@ -26,7 +26,7 @@ #include "mpeg2_internal.h" #include "attributes.h" -// default intra quant matrix, in zig-zag order +/* default intra quant matrix, in zig-zag order */ static uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = { 8, 16, 16, @@ -47,7 +47,7 @@ static uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = { uint8_t scan_norm[64] ATTR_ALIGN(16) = { - // Zig-Zag scan pattern + /* Zig-Zag scan pattern */ 0, 1, 8,16, 9, 2, 3,10, 17,24,32,25,18,11, 4, 5, 12,19,26,33,40,48,41,34, @@ -60,7 +60,7 @@ uint8_t scan_norm[64] ATTR_ALIGN(16) = uint8_t scan_alt[64] ATTR_ALIGN(16) = { - // Alternate scan pattern + /* Alternate scan pattern */ 0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49, 41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43, 51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45, @@ -69,47 +69,34 @@ uint8_t scan_alt[64] ATTR_ALIGN(16) = void header_state_init (picture_t * picture) { - //FIXME we should set pointers to the real scan matrices here (mmx vs - //normal) instead of the ifdefs in header_process_picture_coding_extension - picture->scan = scan_norm; } -static const int frameratecode2framerate[16] = { - 0, 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, - 60*10000, 0,0,0,0,0,0,0 -}; - int header_process_sequence_header (picture_t * picture, uint8_t * buffer) { - unsigned int h_size; - unsigned int v_size; + int width, height; int i; if ((buffer[6] & 0x20) != 0x20) - return 1; // missing marker_bit + return 1; /* missing marker_bit */ - v_size = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2]; + height = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2]; - picture->display_picture_width = (v_size >> 12); - picture->display_picture_height = (v_size & 0xfff); + picture->display_picture_width = (height >> 12); + picture->display_picture_height = (height & 0xfff); - h_size = ((v_size >> 12) + 15) & ~15; - v_size = ((v_size & 0xfff) + 15) & ~15; + width = ((height >> 12) + 15) & ~15; + height = ((height & 0xfff) + 15) & ~15; - if ((h_size > 768) || (v_size > 576)) - return 1; // size restrictions for MP@ML or MPEG1 + if ((width > 768) || (height > 576)) + return 1; /* size restrictions for MP@ML or MPEG1 */ - //XXX this needs field fixups - picture->coded_picture_width = h_size; - picture->coded_picture_height = v_size; - picture->last_mba = ((h_size * v_size) >> 8) - 1; + picture->coded_picture_width = width; + picture->coded_picture_height = height; - // this is not used by the decoder + /* this is not used by the decoder */ picture->aspect_ratio_information = buffer[3] >> 4; picture->frame_rate_code = buffer[3] & 15; - picture->frame_rate = frameratecode2framerate[picture->frame_rate_code]; - picture->bitrate = (buffer[4]<<10)|(buffer[5]<<2)|(buffer[6]>>6); if (buffer[7] & 2) { @@ -132,15 +119,15 @@ int header_process_sequence_header (picture_t * picture, uint8_t * buffer) picture->non_intra_quantizer_matrix[i] = 16; } - // MPEG1 - for testing only + /* MPEG1 - for testing only */ picture->mpeg1 = 1; picture->intra_dc_precision = 0; picture->frame_pred_frame_dct = 1; picture->q_scale_type = 0; picture->concealment_motion_vectors = 0; - //picture->alternate_scan = 0; + /* picture->alternate_scan = 0; */ picture->picture_structure = FRAME_PICTURE; - //picture->second_field = 0; + /* picture->second_field = 0; */ return 0; } @@ -148,28 +135,20 @@ int header_process_sequence_header (picture_t * picture, uint8_t * buffer) static int header_process_sequence_extension (picture_t * picture, uint8_t * buffer) { - // MPEG1 - for testing only - picture->mpeg1 = 0; + /* check chroma format, size extensions, marker bit */ + if (((buffer[1] & 0x07) != 0x02) || (buffer[2] & 0xe0) || + ((buffer[3] & 0x01) != 0x01)) + return 1; - // check chroma format, size extensions, marker bit - if(((buffer[1]>>1)&3)!=1){ - printf("This CHROMA format not yet supported :(\n"); - return 1; - } - if ((buffer[1] & 1) || (buffer[2] & 0xe0)){ - printf("Big resolution video not yet supported :(\n"); - return 1; - } - if((buffer[3] & 0x01) != 0x01) return 1; // marker bit - - - // this is not used by the decoder + /* this is not used by the decoder */ picture->progressive_sequence = (buffer[1] >> 3) & 1; if (picture->progressive_sequence) picture->coded_picture_height = (picture->coded_picture_height + 31) & ~31; - picture->bitrate>>=1; // hack + + /* MPEG1 - for testing only */ + picture->mpeg1 = 0; return 0; } @@ -197,7 +176,7 @@ static int header_process_quant_matrix_extension (picture_t * picture, static int header_process_picture_coding_extension (picture_t * picture, uint8_t * buffer) { - //pre subtract 1 for use later in compute_motion_vector + /* pre subtract 1 for use later in compute_motion_vector */ picture->f_code[0][0] = (buffer[0] & 15) - 1; picture->f_code[0][1] = (buffer[1] >> 4) - 1; picture->f_code[1][0] = (buffer[1] & 15) - 1; @@ -210,12 +189,12 @@ static int header_process_picture_coding_extension (picture_t * picture, uint8_t picture->q_scale_type = (buffer[3] >> 4) & 1; picture->intra_vlc_format = (buffer[3] >> 3) & 1; - if (buffer[3] & 4) // alternate_scan + if (buffer[3] & 4) /* alternate_scan */ picture->scan = scan_alt; else picture->scan = scan_norm; - // these are not used by the decoder + /* these are not used by the decoder */ picture->top_field_first = buffer[3] >> 7; picture->repeat_first_field = (buffer[3] >> 1) & 1; picture->progressive_frame = buffer[4] >> 7; @@ -240,13 +219,13 @@ static int header_process_picture_coding_extension (picture_t * picture, uint8_t int header_process_extension (picture_t * picture, uint8_t * buffer) { switch (buffer[0] & 0xf0) { - case 0x10: // sequence extension + case 0x10: /* sequence extension */ return header_process_sequence_extension (picture, buffer); - case 0x30: // quant matrix extension + case 0x30: /* quant matrix extension */ return header_process_quant_matrix_extension (picture, buffer); - case 0x80: // picture coding extension + case 0x80: /* picture coding extension */ return header_process_picture_coding_extension (picture, buffer); } @@ -257,14 +236,14 @@ int header_process_picture_header (picture_t *picture, uint8_t * buffer) { picture->picture_coding_type = (buffer [1] >> 3) & 7; - // forward_f_code and backward_f_code - used in mpeg1 only + /* forward_f_code and backward_f_code - used in mpeg1 only */ picture->f_code[0][1] = (buffer[3] >> 2) & 1; picture->f_code[0][0] = (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1; picture->f_code[1][1] = (buffer[4] >> 6) & 1; picture->f_code[1][0] = ((buffer[4] >> 3) & 7) - 1; - // move in header_process_picture_header + /* move in header_process_picture_header */ picture->second_field = (picture->picture_structure != FRAME_PICTURE) && !(picture->second_field); diff --git a/libmpeg2/idct.c b/libmpeg2/idct.c index 7411e176dd..d78ad49e8d 100644 --- a/libmpeg2/idct.c +++ b/libmpeg2/idct.c @@ -1,6 +1,6 @@ /* * idct.c - * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * Portions of this code are from the MPEG software simulation group * idct implementation. This code will be replaced with a new @@ -52,8 +52,7 @@ #define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ #define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ - -// idct main entry point +/* idct main entry point */ void (*idct_block_copy) (int16_t * block, uint8_t * dest, int stride); void (*idct_block_add) (int16_t * block, uint8_t * dest, int stride); diff --git a/libmpeg2/idct_mlib.c b/libmpeg2/idct_mlib.c index 055ee75fa6..876ab574a4 100644 --- a/libmpeg2/idct_mlib.c +++ b/libmpeg2/idct_mlib.c @@ -1,6 +1,6 @@ /* * idct_mlib.c - * Copyright (C) 1999 Håkan Hjort <d95hjort@dtek.chalmers.se> + * Copyright (C) 1999-2001 Håkan Hjort <d95hjort@dtek.chalmers.se> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * @@ -38,8 +38,8 @@ void idct_block_copy_mlib (int16_t * block, uint8_t * dest, int stride) void idct_block_add_mlib (int16_t * block, uint8_t * dest, int stride) { - // Should we use mlib_VideoIDCT_IEEE_S16_S16 here ?? - // it's ~30% slower. + /* Should we use mlib_VideoIDCT_IEEE_S16_S16 here ?? */ + /* it's ~30% slower. */ mlib_VideoIDCT8x8_S16_S16 (block, block); mlib_VideoAddBlock_U8_S16 (dest, block, stride); } diff --git a/libmpeg2/idct_mmx.c b/libmpeg2/idct_mmx.c index 03ea5d7580..6c5d2ed96e 100644 --- a/libmpeg2/idct_mmx.c +++ b/libmpeg2/idct_mmx.c @@ -1,6 +1,6 @@ /* * idct_mmx.c - * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * @@ -37,7 +37,7 @@ #if 0 -// C row IDCT - its just here to document the MMXEXT and MMX versions +/* C row IDCT - its just here to document the MMXEXT and MMX versions */ static inline void idct_row (int16_t * row, int offset, int16_t * table, int32_t * rounder) { @@ -76,7 +76,7 @@ static inline void idct_row (int16_t * row, int offset, #endif -// MMXEXT row IDCT +/* MMXEXT row IDCT */ #define mmxext_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, -c4, -c2, \ c4, c6, c4, c6, \ @@ -155,7 +155,7 @@ static inline void mmxext_row_tail (int16_t * row, int store) movq_r2m (mm1, *(row+store)); // save y3 y2 y1 y0 pshufw_r2r (mm4, mm4, 0xb1); // mm4 = y7 y6 y5 y4 - // slot + /* slot */ movq_r2m (mm4, *(row+store+4)); // save y7 y6 y5 y4 } @@ -188,7 +188,7 @@ static inline void mmxext_row_mid (int16_t * row, int store, } -// MMX row IDCT +/* MMX row IDCT */ #define mmx_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, c4, c6, \ c4, c6, -c4, -c2, \ @@ -276,7 +276,7 @@ static inline void mmx_row_tail (int16_t * row, int store) por_r2r (mm4, mm7); // mm7 = y7 y6 y5 y4 - // slot + /* slot */ movq_r2m (mm7, *(row+store+4)); // save y7 y6 y5 y4 } @@ -320,10 +320,10 @@ static inline void mmx_row_mid (int16_t * row, int store, // C column IDCT - its just here to document the MMXEXT and MMX versions static inline void idct_col (int16_t * col, int offset) { -// multiplication - as implemented on mmx +/* multiplication - as implemented on mmx */ #define F(c,x) (((c) * (x)) >> 16) -// saturation - it helps us handle torture test cases +/* saturation - it helps us handle torture test cases */ #define S(x) (((x)>32767) ? 32767 : ((x)<-32768) ? -32768 : (x)) int16_t x0, x1, x2, x3, x4, x5, x6, x7; @@ -344,25 +344,25 @@ static inline void idct_col (int16_t * col, int offset) u04 = S (x0 + x4); v04 = S (x0 - x4); - u26 = S (F (T2, x6) + x2); // -0.5 - v26 = S (F (T2, x2) - x6); // -0.5 + u26 = S (F (T2, x6) + x2); + v26 = S (F (T2, x2) - x6); a0 = S (u04 + u26); a1 = S (v04 + v26); a2 = S (v04 - v26); a3 = S (u04 - u26); - u17 = S (F (T1, x7) + x1); // -0.5 - v17 = S (F (T1, x1) - x7); // -0.5 - u35 = S (F (T3, x5) + x3); // -0.5 - v35 = S (F (T3, x3) - x5); // -0.5 + u17 = S (F (T1, x7) + x1); + v17 = S (F (T1, x1) - x7); + u35 = S (F (T3, x5) + x3); + v35 = S (F (T3, x3) - x5); b0 = S (u17 + u35); b3 = S (v17 - v35); u12 = S (u17 - u35); v12 = S (v17 + v35); - u12 = S (2 * F (C4, u12)); // -0.5 - v12 = S (2 * F (C4, v12)); // -0.5 + u12 = S (2 * F (C4, u12)); + v12 = S (2 * F (C4, v12)); b1 = S (u12 + v12); b2 = S (u12 - v12); @@ -400,7 +400,6 @@ static inline void idct_col (int16_t * col, int offset) static short _T2[] ATTR_ALIGN(8) = {T2,T2,T2,T2}; static short _T3[] ATTR_ALIGN(8) = {T3,T3,T3,T3}; static short _C4[] ATTR_ALIGN(8) = {C4,C4,C4,C4}; - static mmx_t scratch0, scratch1; /* column code adapted from peter gubanov */ /* http://www.elecard.com/peter/idct.shtml */ @@ -428,7 +427,7 @@ static inline void idct_col (int16_t * col, int offset) paddsw_r2r (mm2, mm1); // mm1 = u17 pmulhw_r2r (mm6, mm7); // mm7 = (T3-1)*x5 - // slot + /* slot */ movq_r2r (mm4, mm2); // mm2 = T2 paddsw_r2r (mm3, mm5); // mm5 = T3*x3 @@ -448,7 +447,7 @@ static inline void idct_col (int16_t * col, int offset) psubsw_r2r (mm3, mm4); // mm4 = v26 paddsw_r2r (mm6, mm5); // mm5 = v12 - movq_r2m (mm0, scratch0); // save b3 + movq_r2m (mm0, *(col+offset+3*8)); // save b3 in scratch0 movq_r2r (mm1, mm6); // mm6 = u17 paddsw_m2r (*(col+offset+2*8), mm2);// mm2 = u26 @@ -463,7 +462,7 @@ static inline void idct_col (int16_t * col, int offset) movq_m2r (*_C4, mm0); // mm0 = C4/2 psubsw_r2r (mm5, mm7); // mm7 = u12-v12 - movq_r2m (mm6, scratch1); // save b0 + movq_r2m (mm6, *(col+offset+5*8)); // save b0 in scratch1 pmulhw_r2r (mm0, mm1); // mm1 = b1/2 movq_r2r (mm4, mm6); // mm6 = v26 @@ -496,7 +495,7 @@ static inline void idct_col (int16_t * col, int offset) psraw_i2r (COL_SHIFT, mm4); // mm4 = y1 psubsw_r2r (mm1, mm6); // mm6 = a1-b1 - movq_m2r (scratch1, mm1); // mm1 = b0 + movq_m2r (*(col+offset+5*8), mm1); // mm1 = b0 psubsw_r2r (mm7, mm2); // mm2 = a2-b2 psraw_i2r (COL_SHIFT, mm6); // mm6 = y6 @@ -508,7 +507,7 @@ static inline void idct_col (int16_t * col, int offset) movq_r2m (mm3, *(col+offset+2*8)); // save y2 paddsw_r2r (mm1, mm5); // mm5 = a0+b0 - movq_m2r (scratch0, mm4); // mm4 = b3 + movq_m2r (*(col+offset+3*8), mm4); // mm4 = b3 psubsw_r2r (mm1, mm7); // mm7 = a0-b0 psraw_i2r (COL_SHIFT, mm5); // mm5 = y0 @@ -538,17 +537,17 @@ static int32_t rounder0[] ATTR_ALIGN(8) = rounder ((1 << (COL_SHIFT - 1)) - 0.5); static int32_t rounder4[] ATTR_ALIGN(8) = rounder (0); static int32_t rounder1[] ATTR_ALIGN(8) = - rounder (1.25683487303); // C1*(C1/C4+C1+C7)/2 + rounder (1.25683487303); /* C1*(C1/C4+C1+C7)/2 */ static int32_t rounder7[] ATTR_ALIGN(8) = - rounder (-0.25); // C1*(C7/C4+C7-C1)/2 + rounder (-0.25); /* C1*(C7/C4+C7-C1)/2 */ static int32_t rounder2[] ATTR_ALIGN(8) = - rounder (0.60355339059); // C2 * (C6+C2)/2 + rounder (0.60355339059); /* C2 * (C6+C2)/2 */ static int32_t rounder6[] ATTR_ALIGN(8) = - rounder (-0.25); // C2 * (C6-C2)/2 + rounder (-0.25); /* C2 * (C6-C2)/2 */ static int32_t rounder3[] ATTR_ALIGN(8) = - rounder (0.087788325588); // C3*(-C3/C4+C3+C5)/2 + rounder (0.087788325588); /* C3*(-C3/C4+C3+C5)/2 */ static int32_t rounder5[] ATTR_ALIGN(8) = - rounder (-0.441341716183); // C3*(-C5/C4+C5-C3)/2 + rounder (-0.441341716183); /* C3*(-C5/C4+C5-C3)/2 */ #define declare_idct(idct,table,idct_row_head,idct_row,idct_row_tail,idct_row_mid) \ @@ -693,7 +692,7 @@ void idct_mmx_init (void) extern uint8_t scan_alt[64]; int i, j; - // the mmx/mmxext idct uses a reordered input, so we patch scan tables + /* the mmx/mmxext idct uses a reordered input, so we patch scan tables */ for (i = 0; i < 64; i++) { j = scan_norm[i]; diff --git a/libmpeg2/mmx.h b/libmpeg2/mmx.h index bab97b8b1f..ac23866690 100644 --- a/libmpeg2/mmx.h +++ b/libmpeg2/mmx.h @@ -1,6 +1,6 @@ /* * mmx.h - * Copyright (C) 1997-1999 H. Dietz and R. Fisher + * Copyright (C) 1997-2001 H. Dietz and R. Fisher * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * @@ -41,16 +41,16 @@ typedef union { #define mmx_i2r(op,imm,reg) \ __asm__ __volatile__ (#op " %0, %%" #reg \ : /* nothing */ \ - : "X" (imm) ) + : "i" (imm) ) #define mmx_m2r(op,mem,reg) \ __asm__ __volatile__ (#op " %0, %%" #reg \ : /* nothing */ \ - : "X" (mem)) + : "m" (mem)) #define mmx_r2m(op,reg,mem) \ __asm__ __volatile__ (#op " %%" #reg ", %0" \ - : "=X" (mem) \ + : "=m" (mem) \ : /* nothing */ ) #define mmx_r2r(op,regs,regd) \ diff --git a/libmpeg2/motion_comp.c b/libmpeg2/motion_comp.c index 816335c6dc..52e4655362 100644 --- a/libmpeg2/motion_comp.c +++ b/libmpeg2/motion_comp.c @@ -1,6 +1,6 @@ /* * motion_comp.c - * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * @@ -67,7 +67,7 @@ void motion_comp_init (void) #define put(predictor,i) dest[i] = predictor (i) #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) -// mc function template +/* mc function template */ #define MC_FUNC(op,xy) \ static void MC_##op##_##xy##16_c (uint8_t * dest, uint8_t * ref,\ @@ -111,7 +111,7 @@ static void MC_##op##_##xy##8_c (uint8_t * dest, uint8_t * ref, \ } while (--height); \ } -// definitions of the actual mc functions +/* definitions of the actual mc functions */ MC_FUNC (put,) MC_FUNC (avg,) |