comparison vp3.c @ 1406:ae5524a3cd08 libavcodec

MC rounding fixed? UMV still not bugfree :(
author michaelni
date Tue, 19 Aug 2003 17:10:00 +0000
parents e69f99ade5b0
children 69f4f4fb8a50
comparison
equal deleted inserted replaced
1405:e69f99ade5b0 1406:ae5524a3cd08
285 int first_coded_y_fragment; 285 int first_coded_y_fragment;
286 int first_coded_c_fragment; 286 int first_coded_c_fragment;
287 int last_coded_y_fragment; 287 int last_coded_y_fragment;
288 int last_coded_c_fragment; 288 int last_coded_c_fragment;
289 289
290 uint8_t edge_emu_buffer[9*2048]; //FIXME dynamic alloc
290 } Vp3DecodeContext; 291 } Vp3DecodeContext;
291 292
292 /************************************************************************ 293 /************************************************************************
293 * VP3 I/DCT 294 * VP3 I/DCT
294 ************************************************************************/ 295 ************************************************************************/
2338 unsigned char *golden_plane; 2339 unsigned char *golden_plane;
2339 int stride; 2340 int stride;
2340 int motion_x, motion_y; 2341 int motion_x, motion_y;
2341 int upper_motion_limit, lower_motion_limit; 2342 int upper_motion_limit, lower_motion_limit;
2342 int motion_halfpel_index; 2343 int motion_halfpel_index;
2343 unsigned int motion_source; 2344 uint8_t *motion_source;
2344 2345
2345 debug_vp3(" vp3: rendering final fragments for %s\n", 2346 debug_vp3(" vp3: rendering final fragments for %s\n",
2346 (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane"); 2347 (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane");
2347 2348
2348 /* set up plane-specific parameters */ 2349 /* set up plane-specific parameters */
2384 } 2385 }
2385 2386
2386 /* transform if this block was coded */ 2387 /* transform if this block was coded */
2387 if (s->all_fragments[i].coding_method != MODE_COPY) { 2388 if (s->all_fragments[i].coding_method != MODE_COPY) {
2388 2389
2389 motion_source = s->all_fragments[i].first_pixel; 2390 if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
2391 (s->all_fragments[i].coding_method == MODE_GOLDEN_MV))
2392 motion_source= golden_plane;
2393 else
2394 motion_source= last_plane;
2395
2396 motion_source += s->all_fragments[i].first_pixel;
2390 motion_halfpel_index = 0; 2397 motion_halfpel_index = 0;
2391 2398
2392 /* sort out the motion vector if this fragment is coded 2399 /* sort out the motion vector if this fragment is coded
2393 * using a motion vector method */ 2400 * using a motion vector method */
2394 if ((s->all_fragments[i].coding_method > MODE_INTRA) && 2401 if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
2395 (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) { 2402 (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
2403 int src_x, src_y;
2396 motion_x = s->all_fragments[i].motion_x; 2404 motion_x = s->all_fragments[i].motion_x;
2397 motion_y = s->all_fragments[i].motion_y; 2405 motion_y = s->all_fragments[i].motion_y;
2406 src_x= (motion_x>>1) + x;
2407 src_y= (motion_y>>1) + y;
2398 if ((motion_x == 0xbeef) || (motion_y == 0xbeef)) 2408 if ((motion_x == 0xbeef) || (motion_y == 0xbeef))
2399 printf (" help! got beefy vector! (%X, %X)\n", motion_x, motion_y); 2409 printf (" help! got beefy vector! (%X, %X)\n", motion_x, motion_y);
2400 2410
2401 if (motion_x >= 0) { 2411 if (motion_x >= 0) {
2402 motion_halfpel_index = motion_x & 0x01; 2412 motion_halfpel_index = motion_x & 0x01;
2415 motion_y = -motion_y; 2425 motion_y = -motion_y;
2416 motion_halfpel_index |= (motion_y & 0x01) << 1; 2426 motion_halfpel_index |= (motion_y & 0x01) << 1;
2417 motion_source -= (((motion_y + 1) >> 1) * stride); 2427 motion_source -= (((motion_y + 1) >> 1) * stride);
2418 } 2428 }
2419 2429
2420 /* if the are any problems with a motion vector, refuse 2430 if(src_x<0 || src_y<0 || src_x + 9 >= width || src_y + 9 >= height){
2421 * to render the block */ 2431 uint8_t *temp= s->edge_emu_buffer;
2422 if ((motion_source < upper_motion_limit) || 2432 if(stride<0) temp -= 9*stride;
2423 (motion_source > lower_motion_limit)) { 2433
2424 printf (" vp3: help! motion source (%d) out of range (%d..%d), fragment %d\n", 2434 ff_emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, width, height);
2425 motion_source, upper_motion_limit, lower_motion_limit, i); 2435 motion_source= temp;
2426 continue;
2427 } 2436 }
2428 } 2437 }
2429 2438
2430 /* first, take care of copying a block from either the 2439 /* first, take care of copying a block from either the
2431 * previous or the golden frame */ 2440 * previous or the golden frame */
2432 if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) || 2441 if (s->all_fragments[i].coding_method != MODE_INTRA) {
2433 (s->all_fragments[i].coding_method == MODE_GOLDEN_MV)) { 2442
2434 2443 s->dsp.put_no_rnd_pixels_tab[1][motion_halfpel_index](
2435 s->dsp.put_pixels_tab[1][motion_halfpel_index](
2436 output_plane + s->all_fragments[i].first_pixel, 2444 output_plane + s->all_fragments[i].first_pixel,
2437 golden_plane + motion_source, 2445 motion_source,
2438 stride, 8);
2439
2440 } else
2441 if (s->all_fragments[i].coding_method != MODE_INTRA) {
2442
2443 s->dsp.put_pixels_tab[1][motion_halfpel_index](
2444 output_plane + s->all_fragments[i].first_pixel,
2445 last_plane + motion_source,
2446 stride, 8); 2446 stride, 8);
2447 } 2447 }
2448 2448
2449 /* dequantize the DCT coefficients */ 2449 /* dequantize the DCT coefficients */
2450 debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n", 2450 debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n",