comparison libmpeg2/decode.c @ 41:0d76b2b962ad

added mpeg 1/2 postprocessing
author arpi_esp
date Mon, 05 Mar 2001 23:02:30 +0000
parents 846535ace7a2
children b7b038ee3fde
comparison
equal deleted inserted replaced
40:2fed43f60181 41:0d76b2b962ad
49 //static uint32_t shift = 0; 49 //static uint32_t shift = 0;
50 50
51 static int drop_flag = 0; 51 static int drop_flag = 0;
52 static int drop_frame = 0; 52 static int drop_frame = 0;
53 53
54 #ifdef POSTPROC 54 #ifdef MPEG12_POSTPROC
55 int quant_store[MBR+1][MBC+1]; // [Review] 55 int quant_store[MBR+1][MBC+1]; // [Review]
56 #endif 56 #endif
57 57
58 void mpeg2_init (void) 58 void mpeg2_init (void)
59 { 59 {
84 84
85 idct_init (); 85 idct_init ();
86 motion_comp_init (); 86 motion_comp_init ();
87 } 87 }
88 88
89 static vo_frame_t frames[3]; 89 static vo_frame_t frames[4];
90 90
91 void mpeg2_allocate_image_buffers (picture_t * picture) 91 void mpeg2_allocate_image_buffers (picture_t * picture)
92 { 92 {
93 int frame_size,buff_size; 93 int frame_size,buff_size;
94 unsigned char *base=NULL; 94 unsigned char *base=NULL;
98 frame_size = picture->coded_picture_width * (1+picture->coded_picture_height); 98 frame_size = picture->coded_picture_width * (1+picture->coded_picture_height);
99 frame_size = (frame_size+31)&(~31); // align to 32 byte boundary 99 frame_size = (frame_size+31)&(~31); // align to 32 byte boundary
100 buff_size = frame_size + (frame_size/4)*2; // 4Y + 1U + 1V 100 buff_size = frame_size + (frame_size/4)*2; // 4Y + 1U + 1V
101 101
102 // allocate images in YV12 format 102 // allocate images in YV12 format
103 #ifdef MPEG12_POSTPROC
104 for(i=0;i<4;i++){
105 #else
103 for(i=0;i<3;i++){ 106 for(i=0;i<3;i++){
107 #endif
104 base = shmem_alloc(buff_size); 108 base = shmem_alloc(buff_size);
105 frames[i].base[0] = base; 109 frames[i].base[0] = base;
106 frames[i].base[1] = base + frame_size * 5 / 4; 110 frames[i].base[1] = base + frame_size * 5 / 4;
107 frames[i].base[2] = base + frame_size; 111 frames[i].base[2] = base + frame_size;
108 frames[i].copy = NULL; 112 frames[i].copy = NULL;
111 } 115 }
112 116
113 picture->forward_reference_frame=&frames[0]; 117 picture->forward_reference_frame=&frames[0];
114 picture->backward_reference_frame=&frames[1]; 118 picture->backward_reference_frame=&frames[1];
115 picture->current_frame=&frames[2]; 119 picture->current_frame=&frames[2];
116
117 #ifdef POSTPROC
118 base = shmem_alloc(buff_size);
119 picture->pp_frame[0] = base;
120 picture->pp_frame[1] = base + frame_size * 5 / 4;
121 picture->pp_frame[2] = base + frame_size;
122 #endif
123 120
124 } 121 }
125 122
126 static void copy_slice (vo_frame_t * frame, uint8_t ** src){ 123 static void copy_slice (vo_frame_t * frame, uint8_t ** src){
127 vo_functions_t * output = frame->vo; 124 vo_functions_t * output = frame->vo;
155 // if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field); 152 // if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field);
156 153
157 if (((picture->picture_structure == FRAME_PICTURE) || 154 if (((picture->picture_structure == FRAME_PICTURE) ||
158 (picture->second_field)) 155 (picture->second_field))
159 ) { 156 ) {
157 #ifdef MPEG12_POSTPROC
158 if(picture->pp_options){
159 // apply OpenDivX postprocess filter
160 int stride[3];
161 stride[0]=picture->coded_picture_width;
162 stride[1]=stride[2]=stride[0]/2;
163 postprocess((picture->picture_coding_type == B_TYPE) ?
164 picture->current_frame->base :
165 picture->forward_reference_frame->base,
166 stride[0], frames[3].base, stride[0],
167 picture->coded_picture_width, picture->coded_picture_height,
168 &quant_store[1][1], (MBC+1), picture->pp_options);
169 output->draw_slice (frames[3].base, stride,
170 picture->display_picture_width,
171 picture->display_picture_height, 0, 0);
172 } else
173 #endif
160 #if 1 174 #if 1
161 if (picture->picture_coding_type != B_TYPE) { 175 if (picture->picture_coding_type != B_TYPE) {
162 int stride[3]; 176 int stride[3];
163 stride[0]=picture->coded_picture_width; 177 stride[0]=picture->coded_picture_width;
164 stride[1]=stride[2]=stride[0]/2; 178 stride[1]=stride[2]=stride[0]/2;
213 if (picture->second_field){ 227 if (picture->second_field){
214 // vo_field (picture->current_frame, picture->picture_structure); 228 // vo_field (picture->current_frame, picture->picture_structure);
215 } else { 229 } else {
216 if (picture->picture_coding_type == B_TYPE){ 230 if (picture->picture_coding_type == B_TYPE){
217 picture->current_frame = &frames[2]; 231 picture->current_frame = &frames[2];
232 #ifdef MPEG12_POSTPROC
233 if(picture->pp_options)
234 picture->current_frame->copy=NULL; else
235 #endif
218 picture->current_frame->copy=copy_slice; 236 picture->current_frame->copy=copy_slice;
219 } else { 237 } else {
220 picture->current_frame = picture->forward_reference_frame; 238 picture->current_frame = picture->forward_reference_frame;
221 picture->forward_reference_frame = picture->backward_reference_frame; 239 picture->forward_reference_frame = picture->backward_reference_frame;
222 picture->backward_reference_frame = picture->current_frame; 240 picture->backward_reference_frame = picture->current_frame;