comparison vp3.c @ 11132:449c12b6c3a0 libavcodec

Implement CODEC_CAP_DRAW_HORIZ_BAND for VP3 decoder
author conrad
date Fri, 12 Feb 2010 22:01:35 +0000
parents 926f79d28a87
children cd2956d08cc1
comparison
equal deleted inserted replaced
11131:926f79d28a87 11132:449c12b6c3a0
133 AVFrame last_frame; 133 AVFrame last_frame;
134 AVFrame current_frame; 134 AVFrame current_frame;
135 int keyframe; 135 int keyframe;
136 DSPContext dsp; 136 DSPContext dsp;
137 int flipped_image; 137 int flipped_image;
138 int last_slice_end;
138 139
139 int qps[3]; 140 int qps[3];
140 int nqps; 141 int nqps;
141 int last_qps[3]; 142 int last_qps[3];
142 143
1448 fragment++; 1449 fragment++;
1449 } 1450 }
1450 } 1451 }
1451 } 1452 }
1452 1453
1454 /**
1455 * called when all pixels up to row y are complete
1456 */
1457 static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
1458 {
1459 int h, cy;
1460 int offset[4];
1461
1462 if(s->avctx->draw_horiz_band==NULL)
1463 return;
1464
1465 h= y - s->last_slice_end;
1466 y -= h;
1467
1468 if (!s->flipped_image) {
1469 if (y == 0)
1470 h -= s->height - s->avctx->height; // account for non-mod16
1471 y = s->height - y - h;
1472 }
1473
1474 cy = y >> 1;
1475 offset[0] = s->current_frame.linesize[0]*y;
1476 offset[1] = s->current_frame.linesize[1]*cy;
1477 offset[2] = s->current_frame.linesize[2]*cy;
1478 offset[3] = 0;
1479
1480 emms_c();
1481 s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);
1482 s->last_slice_end= y + h;
1483 }
1484
1453 /* 1485 /*
1454 * Perform the final rendering for a particular slice of data. 1486 * Perform the final rendering for a particular slice of data.
1455 * The slice number ranges from 0..(macroblock_height - 1). 1487 * The slice number ranges from 0..(macroblock_height - 1).
1456 */ 1488 */
1457 static void render_slice(Vp3DecodeContext *s, int slice) 1489 static void render_slice(Vp3DecodeContext *s, int slice)
1622 * dispatch (both last slice & 2nd-to-last slice); 1654 * dispatch (both last slice & 2nd-to-last slice);
1623 * else if (slice > 0) 1655 * else if (slice > 0)
1624 * dispatch (slice - 1); 1656 * dispatch (slice - 1);
1625 */ 1657 */
1626 1658
1627 emms_c(); 1659 // now that we've filtered the last rows, they're safe to display
1660 if (slice)
1661 vp3_draw_horiz_band(s, 16*slice);
1628 } 1662 }
1629 1663
1630 /* 1664 /*
1631 * This function computes the first pixel addresses for each fragment. 1665 * This function computes the first pixel addresses for each fragment.
1632 * This function needs to be invoked after the first frame is allocated 1666 * This function needs to be invoked after the first frame is allocated
2006 if (unpack_dct_coeffs(s, &gb)){ 2040 if (unpack_dct_coeffs(s, &gb)){
2007 av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n"); 2041 av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
2008 return -1; 2042 return -1;
2009 } 2043 }
2010 2044
2045 s->last_slice_end = 0;
2011 for (i = 0; i < s->macroblock_height; i++) 2046 for (i = 0; i < s->macroblock_height; i++)
2012 render_slice(s, i); 2047 render_slice(s, i);
2013 2048
2014 // filter the last row 2049 // filter the last row
2015 for (i = 0; i < 3; i++) { 2050 for (i = 0; i < 3; i++) {
2016 int row = (s->height >> (3+!!i)) - 1; 2051 int row = (s->height >> (3+!!i)) - 1;
2017 apply_loop_filter(s, i, row, row+1); 2052 apply_loop_filter(s, i, row, row+1);
2018 } 2053 }
2054 vp3_draw_horiz_band(s, s->height);
2019 2055
2020 *data_size=sizeof(AVFrame); 2056 *data_size=sizeof(AVFrame);
2021 *(AVFrame*)data= s->current_frame; 2057 *(AVFrame*)data= s->current_frame;
2022 2058
2023 /* release the last frame, if it is allocated and if it is not the 2059 /* release the last frame, if it is allocated and if it is not the
2365 sizeof(Vp3DecodeContext), 2401 sizeof(Vp3DecodeContext),
2366 theora_decode_init, 2402 theora_decode_init,
2367 NULL, 2403 NULL,
2368 vp3_decode_end, 2404 vp3_decode_end,
2369 vp3_decode_frame, 2405 vp3_decode_frame,
2370 CODEC_CAP_DR1, 2406 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
2371 NULL, 2407 NULL,
2372 .long_name = NULL_IF_CONFIG_SMALL("Theora"), 2408 .long_name = NULL_IF_CONFIG_SMALL("Theora"),
2373 }; 2409 };
2374 #endif 2410 #endif
2375 2411
2380 sizeof(Vp3DecodeContext), 2416 sizeof(Vp3DecodeContext),
2381 vp3_decode_init, 2417 vp3_decode_init,
2382 NULL, 2418 NULL,
2383 vp3_decode_end, 2419 vp3_decode_end,
2384 vp3_decode_frame, 2420 vp3_decode_frame,
2385 CODEC_CAP_DR1, 2421 CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
2386 NULL, 2422 NULL,
2387 .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), 2423 .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
2388 }; 2424 };