comparison vp3.c @ 7995:1fbfce20cb79 libavcodec

Move VP3 loop filter to DSPContext
author conrad
date Sat, 04 Oct 2008 10:26:17 +0000
parents 6cf217dad67d
children 28d9f91aeb28
comparison
equal deleted inserted replaced
7994:ecade9a77827 7995:1fbfce20cb79
1281 } 1281 }
1282 } 1282 }
1283 } 1283 }
1284 } 1284 }
1285 1285
1286
1287 static void horizontal_filter(unsigned char *first_pixel, int stride,
1288 int *bounding_values);
1289 static void vertical_filter(unsigned char *first_pixel, int stride,
1290 int *bounding_values);
1291
1292 /* 1286 /*
1293 * Perform the final rendering for a particular slice of data. 1287 * Perform the final rendering for a particular slice of data.
1294 * The slice number ranges from 0..(macroblock_height - 1). 1288 * The slice number ranges from 0..(macroblock_height - 1).
1295 */ 1289 */
1296 static void render_slice(Vp3DecodeContext *s, int slice) 1290 static void render_slice(Vp3DecodeContext *s, int slice)
1493 */ 1487 */
1494 1488
1495 emms_c(); 1489 emms_c();
1496 } 1490 }
1497 1491
1498 static void horizontal_filter(unsigned char *first_pixel, int stride,
1499 int *bounding_values)
1500 {
1501 unsigned char *end;
1502 int filter_value;
1503
1504 for (end= first_pixel + 8*stride; first_pixel != end; first_pixel += stride) {
1505 filter_value =
1506 (first_pixel[-2] - first_pixel[ 1])
1507 +3*(first_pixel[ 0] - first_pixel[-1]);
1508 filter_value = bounding_values[(filter_value + 4) >> 3];
1509 first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value);
1510 first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value);
1511 }
1512 }
1513
1514 static void vertical_filter(unsigned char *first_pixel, int stride,
1515 int *bounding_values)
1516 {
1517 unsigned char *end;
1518 int filter_value;
1519 const int nstride= -stride;
1520
1521 for (end= first_pixel + 8; first_pixel < end; first_pixel++) {
1522 filter_value =
1523 (first_pixel[2 * nstride] - first_pixel[ stride])
1524 +3*(first_pixel[0 ] - first_pixel[nstride]);
1525 filter_value = bounding_values[(filter_value + 4) >> 3];
1526 first_pixel[nstride] = av_clip_uint8(first_pixel[nstride] + filter_value);
1527 first_pixel[0] = av_clip_uint8(first_pixel[0] - filter_value);
1528 }
1529 }
1530
1531 static void apply_loop_filter(Vp3DecodeContext *s) 1492 static void apply_loop_filter(Vp3DecodeContext *s)
1532 { 1493 {
1533 int plane; 1494 int plane;
1534 int x, y; 1495 int x, y;
1535 int *bounding_values= s->bounding_values_array+127; 1496 int *bounding_values= s->bounding_values_array+127;
1567 1528
1568 for (x = 0; x < width; x++) { 1529 for (x = 0; x < width; x++) {
1569 /* do not perform left edge filter for left columns frags */ 1530 /* do not perform left edge filter for left columns frags */
1570 if ((x > 0) && 1531 if ((x > 0) &&
1571 (s->all_fragments[fragment].coding_method != MODE_COPY)) { 1532 (s->all_fragments[fragment].coding_method != MODE_COPY)) {
1572 horizontal_filter( 1533 s->dsp.vp3_h_loop_filter(
1573 plane_data + s->all_fragments[fragment].first_pixel, 1534 plane_data + s->all_fragments[fragment].first_pixel,
1574 stride, bounding_values); 1535 stride, bounding_values);
1575 } 1536 }
1576 1537
1577 /* do not perform top edge filter for top row fragments */ 1538 /* do not perform top edge filter for top row fragments */
1578 if ((y > 0) && 1539 if ((y > 0) &&
1579 (s->all_fragments[fragment].coding_method != MODE_COPY)) { 1540 (s->all_fragments[fragment].coding_method != MODE_COPY)) {
1580 vertical_filter( 1541 s->dsp.vp3_v_loop_filter(
1581 plane_data + s->all_fragments[fragment].first_pixel, 1542 plane_data + s->all_fragments[fragment].first_pixel,
1582 stride, bounding_values); 1543 stride, bounding_values);
1583 } 1544 }
1584 1545
1585 /* do not perform right edge filter for right column 1546 /* do not perform right edge filter for right column
1586 * fragments or if right fragment neighbor is also coded 1547 * fragments or if right fragment neighbor is also coded
1587 * in this frame (it will be filtered in next iteration) */ 1548 * in this frame (it will be filtered in next iteration) */
1588 if ((x < width - 1) && 1549 if ((x < width - 1) &&
1589 (s->all_fragments[fragment].coding_method != MODE_COPY) && 1550 (s->all_fragments[fragment].coding_method != MODE_COPY) &&
1590 (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { 1551 (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {
1591 horizontal_filter( 1552 s->dsp.vp3_h_loop_filter(
1592 plane_data + s->all_fragments[fragment + 1].first_pixel, 1553 plane_data + s->all_fragments[fragment + 1].first_pixel,
1593 stride, bounding_values); 1554 stride, bounding_values);
1594 } 1555 }
1595 1556
1596 /* do not perform bottom edge filter for bottom row 1557 /* do not perform bottom edge filter for bottom row
1597 * fragments or if bottom fragment neighbor is also coded 1558 * fragments or if bottom fragment neighbor is also coded
1598 * in this frame (it will be filtered in the next row) */ 1559 * in this frame (it will be filtered in the next row) */
1599 if ((y < height - 1) && 1560 if ((y < height - 1) &&
1600 (s->all_fragments[fragment].coding_method != MODE_COPY) && 1561 (s->all_fragments[fragment].coding_method != MODE_COPY) &&
1601 (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { 1562 (s->all_fragments[fragment + width].coding_method == MODE_COPY)) {
1602 vertical_filter( 1563 s->dsp.vp3_v_loop_filter(
1603 plane_data + s->all_fragments[fragment + width].first_pixel, 1564 plane_data + s->all_fragments[fragment + width].first_pixel,
1604 stride, bounding_values); 1565 stride, bounding_values);
1605 } 1566 }
1606 1567
1607 fragment++; 1568 fragment++;