comparison mpegvideo.c @ 485:20108840b0e5 libavcodec

grayscale only decoding
author michaelni
date Sun, 09 Jun 2002 13:35:56 +0000
parents 29a7e17d19dd
children cee02f2f4a5a
comparison
equal deleted inserted replaced
484:f8bbc8976247 485:20108840b0e5
153 pict_start = (w >> shift) * (EDGE_WIDTH >> shift) + (EDGE_WIDTH >> shift); 153 pict_start = (w >> shift) * (EDGE_WIDTH >> shift) + (EDGE_WIDTH >> shift);
154 154
155 CHECKED_ALLOCZ(pict, c_size) 155 CHECKED_ALLOCZ(pict, c_size)
156 s->last_picture_base[i] = pict; 156 s->last_picture_base[i] = pict;
157 s->last_picture[i] = pict + pict_start; 157 s->last_picture[i] = pict + pict_start;
158 if(i>0) memset(s->last_picture_base[i], 128, c_size);
158 159
159 CHECKED_ALLOCZ(pict, c_size) 160 CHECKED_ALLOCZ(pict, c_size)
160 s->next_picture_base[i] = pict; 161 s->next_picture_base[i] = pict;
161 s->next_picture[i] = pict + pict_start; 162 s->next_picture[i] = pict + pict_start;
163 if(i>0) memset(s->next_picture_base[i], 128, c_size);
162 164
163 if (s->has_b_frames || s->codec_id==CODEC_ID_MPEG4) { 165 if (s->has_b_frames || s->codec_id==CODEC_ID_MPEG4) {
164 /* Note the MPEG4 stuff is here cuz of buggy encoders which dont set the low_delay flag but 166 /* Note the MPEG4 stuff is here cuz of buggy encoders which dont set the low_delay flag but
165 do low-delay encoding, so we cant allways distinguish b-frame containing streams from low_delay streams */ 167 do low-delay encoding, so we cant allways distinguish b-frame containing streams from low_delay streams */
166 CHECKED_ALLOCZ(pict, c_size) 168 CHECKED_ALLOCZ(pict, c_size)
167 s->aux_picture_base[i] = pict; 169 s->aux_picture_base[i] = pict;
168 s->aux_picture[i] = pict + pict_start; 170 s->aux_picture[i] = pict + pict_start;
171 if(i>0) memset(s->aux_picture_base[i], 128, c_size);
169 } 172 }
170 } 173 }
171 174
172 if (s->encoding) { 175 if (s->encoding) {
173 int j; 176 int j;
884 ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset; 887 ptr = ref_picture[0] + (src_y * linesize) + (src_x) + src_offset;
885 dest_y += dest_offset; 888 dest_y += dest_offset;
886 pix_op[dxy](dest_y, ptr, linesize, h); 889 pix_op[dxy](dest_y, ptr, linesize, h);
887 pix_op[dxy](dest_y + 8, ptr + 8, linesize, h); 890 pix_op[dxy](dest_y + 8, ptr + 8, linesize, h);
888 891
892 if(s->flags&CODEC_FLAG_GRAY) return;
893
889 if (s->out_format == FMT_H263) { 894 if (s->out_format == FMT_H263) {
890 dxy = 0; 895 dxy = 0;
891 if ((motion_x & 3) != 0) 896 if ((motion_x & 3) != 0)
892 dxy |= 1; 897 dxy |= 1;
893 if ((motion_y & 3) != 0) 898 if ((motion_y & 3) != 0)
947 qpix_op[dxy](dest_y , ptr , linesize, linesize, motion_x&3, motion_y&3); 952 qpix_op[dxy](dest_y , ptr , linesize, linesize, motion_x&3, motion_y&3);
948 qpix_op[dxy](dest_y + 8, ptr + 8, linesize, linesize, motion_x&3, motion_y&3); 953 qpix_op[dxy](dest_y + 8, ptr + 8, linesize, linesize, motion_x&3, motion_y&3);
949 qpix_op[dxy](dest_y + linesize*8 , ptr + linesize*8 , linesize, linesize, motion_x&3, motion_y&3); 954 qpix_op[dxy](dest_y + linesize*8 , ptr + linesize*8 , linesize, linesize, motion_x&3, motion_y&3);
950 qpix_op[dxy](dest_y + linesize*8 + 8, ptr + linesize*8 + 8, linesize, linesize, motion_x&3, motion_y&3); 955 qpix_op[dxy](dest_y + linesize*8 + 8, ptr + linesize*8 + 8, linesize, linesize, motion_x&3, motion_y&3);
951 956
957 if(s->flags&CODEC_FLAG_GRAY) return;
958
952 mx= (motion_x>>1) | (motion_x&1); 959 mx= (motion_x>>1) | (motion_x&1);
953 my= (motion_y>>1) | (motion_y&1); 960 my= (motion_y>>1) | (motion_y&1);
954 961
955 dxy = 0; 962 dxy = 0;
956 if ((mx & 3) != 0) 963 if ((mx & 3) != 0)
1035 1042
1036 ptr = ref_picture[0] + (src_y * s->linesize) + (src_x); 1043 ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
1037 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize; 1044 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
1038 pix_op[dxy](dest, ptr, s->linesize, 8); 1045 pix_op[dxy](dest, ptr, s->linesize, 8);
1039 } 1046 }
1047
1048 if(s->flags&CODEC_FLAG_GRAY) break;
1040 /* In case of 8X8, we construct a single chroma motion vector 1049 /* In case of 8X8, we construct a single chroma motion vector
1041 with a special rounding */ 1050 with a special rounding */
1042 mx = 0; 1051 mx = 0;
1043 my = 0; 1052 my = 0;
1044 for(i=0;i<4;i++) { 1053 for(i=0;i<4;i++) {
1290 add_dequant_dct(s, block[0], 0, dest_y, dct_linesize); 1299 add_dequant_dct(s, block[0], 0, dest_y, dct_linesize);
1291 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize); 1300 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize);
1292 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 1301 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
1293 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 1302 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
1294 1303
1295 add_dequant_dct(s, block[4], 4, dest_cb, s->linesize >> 1); 1304 if(!(s->flags&CODEC_FLAG_GRAY)){
1296 add_dequant_dct(s, block[5], 5, dest_cr, s->linesize >> 1); 1305 add_dequant_dct(s, block[4], 4, dest_cb, s->linesize >> 1);
1306 add_dequant_dct(s, block[5], 5, dest_cr, s->linesize >> 1);
1307 }
1297 } else { 1308 } else {
1298 add_dct(s, block[0], 0, dest_y, dct_linesize); 1309 add_dct(s, block[0], 0, dest_y, dct_linesize);
1299 add_dct(s, block[1], 1, dest_y + 8, dct_linesize); 1310 add_dct(s, block[1], 1, dest_y + 8, dct_linesize);
1300 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 1311 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
1301 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 1312 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
1302 1313
1303 add_dct(s, block[4], 4, dest_cb, s->linesize >> 1); 1314 if(!(s->flags&CODEC_FLAG_GRAY)){
1304 add_dct(s, block[5], 5, dest_cr, s->linesize >> 1); 1315 add_dct(s, block[4], 4, dest_cb, s->linesize >> 1);
1316 add_dct(s, block[5], 5, dest_cr, s->linesize >> 1);
1317 }
1305 } 1318 }
1306 } else { 1319 } else {
1307 /* dct only in intra block */ 1320 /* dct only in intra block */
1308 put_dct(s, block[0], 0, dest_y, dct_linesize); 1321 put_dct(s, block[0], 0, dest_y, dct_linesize);
1309 put_dct(s, block[1], 1, dest_y + 8, dct_linesize); 1322 put_dct(s, block[1], 1, dest_y + 8, dct_linesize);
1310 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 1323 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
1311 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 1324 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
1312 1325
1313 put_dct(s, block[4], 4, dest_cb, s->linesize >> 1); 1326 if(!(s->flags&CODEC_FLAG_GRAY)){
1314 put_dct(s, block[5], 5, dest_cr, s->linesize >> 1); 1327 put_dct(s, block[4], 4, dest_cb, s->linesize >> 1);
1328 put_dct(s, block[5], 5, dest_cr, s->linesize >> 1);
1329 }
1315 } 1330 }
1316 } 1331 }
1317 the_end: 1332 the_end:
1318 emms_c(); //FIXME remove 1333 emms_c(); //FIXME remove
1319 } 1334 }