1/****************************************************************************** 2* 3* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore 4* 5* Licensed under the Apache License, Version 2.0 (the "License"); 6* you may not use this file except in compliance with the License. 7* You may obtain a copy of the License at: 8* 9* http://www.apache.org/licenses/LICENSE-2.0 10* 11* Unless required by applicable law or agreed to in writing, software 12* distributed under the License is distributed on an "AS IS" BASIS, 13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14* See the License for the specific language governing permissions and 15* limitations under the License. 16* 17******************************************************************************/ 18/** 19******************************************************************************* 20* @file 21* ihevc_inter_pred_filters.c 22* 23* @brief 24* Contains function definitions for inter prediction interpolation filters 25* 26* 27* @author 28* Srinivas T 29* 30* @par List of Functions: 31* - ihevc_inter_pred_luma_copy() 32* - ihevc_inter_pred_luma_horz() 33* - ihevc_inter_pred_luma_vert() 34* - ihevc_inter_pred_luma_copy_w16out() 35* - ihevc_inter_pred_luma_horz_w16out() 36* - ihevc_inter_pred_luma_vert_w16out() 37* - ihevc_inter_pred_luma_vert_w16inp() 38* - ihevc_inter_pred_luma_vert_w16inp_w16out() 39* - ihevc_inter_pred_chroma_copy() 40* - ihevc_inter_pred_chroma_horz() 41* - ihevc_inter_pred_chroma_vert() 42* - ihevc_inter_pred_chroma_copy_w16out() 43* - ihevc_inter_pred_chroma_horz_w16out() 44* - ihevc_inter_pred_chroma_vert_w16out() 45* - ihevc_inter_pred_chroma_vert_w16inp() 46* - ihevc_inter_pred_chroma_vert_w16inp_w16out() 47* 48* @remarks 49* None 50* 51******************************************************************************* 52*/ 53 54/*****************************************************************************/ 55/* File Includes */ 56/*****************************************************************************/ 57#include "ihevc_typedefs.h" 58#include "ihevc_defs.h" 59#include "ihevc_macros.h" 60#include "ihevc_platform_macros.h" 61#include "ihevc_func_selector.h" 62 63#include "ihevc_inter_pred.h" 64/*****************************************************************************/ 65/* Function Definitions */ 66/*****************************************************************************/ 67 68/** 69******************************************************************************* 70* 71* @brief 72* Interprediction luma function for copy 73* 74* @par Description: 75* Copies the array of width 'wd' and height 'ht' from the location pointed 76* by 'src' to the location pointed by 'dst' 77* 78* @param[in] pu1_src 79* UWORD8 pointer to the source 80* 81* @param[out] pu1_dst 82* UWORD8 pointer to the destination 83* 84* @param[in] src_strd 85* integer source stride 86* 87* @param[in] dst_strd 88* integer destination stride 89* 90* @param[in] pi1_coeff 91* WORD8 pointer to the filter coefficients 92* 93* @param[in] ht 94* integer height of the array 95* 96* @param[in] wd 97* integer width of the array 98* 99* @returns 100* 101* @remarks 102* None 103* 104******************************************************************************* 105*/ 106 107 108void ihevc_inter_pred_luma_copy(UWORD8 *pu1_src, 109 UWORD8 *pu1_dst, 110 WORD32 src_strd, 111 WORD32 dst_strd, 112 WORD8 *pi1_coeff, 113 WORD32 ht, 114 WORD32 wd) 115{ 116 WORD32 row, col; 117 UNUSED(pi1_coeff); 118 for(row = 0; row < ht; row++) 119 { 120 for(col = 0; col < wd; col++) 121 { 122 pu1_dst[col] = pu1_src[col]; 123 } 124 125 pu1_src += src_strd; 126 pu1_dst += dst_strd; 127 } 128} 129 130/** 131******************************************************************************* 132* 133* @brief 134* Interprediction luma filter for horizontal input 135* 136* @par Description: 137* Applies a horizontal filter with coefficients pointed to by 'pi1_coeff' 138* to the elements pointed by 'pu1_src' and writes to the location pointed 139* by 'pu1_dst' The output is downshifted by 6 and clipped to 8 bits 140* 141* @param[in] pu1_src 142* UWORD8 pointer to the source 143* 144* @param[out] pu1_dst 145* UWORD8 pointer to the destination 146* 147* @param[in] src_strd 148* integer source stride 149* 150* @param[in] dst_strd 151* integer destination stride 152* 153* @param[in] pi1_coeff 154* WORD8 pointer to the filter coefficients 155* 156* @param[in] ht 157* integer height of the array 158* 159* @param[in] wd 160* integer width of the array 161* 162* @returns 163* 164* @remarks 165* None 166* 167******************************************************************************* 168*/ 169 170void ihevc_inter_pred_luma_horz(UWORD8 *pu1_src, 171 UWORD8 *pu1_dst, 172 WORD32 src_strd, 173 WORD32 dst_strd, 174 WORD8 *pi1_coeff, 175 WORD32 ht, 176 WORD32 wd) 177{ 178 WORD32 row, col, i; 179 WORD16 i2_tmp; 180 181 for(row = 0; row < ht; row++) 182 { 183 for(col = 0; col < wd; col++) 184 { 185 i2_tmp = 0; 186 for(i = 0; i < NTAPS_LUMA; i++) 187 i2_tmp += pi1_coeff[i] * pu1_src[col + (i - 3)]; 188 189 i2_tmp = (i2_tmp + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 190 i2_tmp = CLIP_U8(i2_tmp); 191 192 pu1_dst[col] = (UWORD8)i2_tmp; 193 } 194 195 pu1_src += src_strd; 196 pu1_dst += dst_strd; 197 } 198 199} 200 201 202/** 203******************************************************************************* 204* 205* @brief 206* Interprediction luma filter for vertical input 207* 208* @par Description: 209* Applies a vertcal filter with coefficients pointed to by 'pi1_coeff' to 210* the elements pointed by 'pu1_src' and writes to the location pointed by 211* 'pu1_dst' The output is downshifted by 6 and clipped to 8 bits 212* 213* @param[in] pu1_src 214* UWORD8 pointer to the source 215* 216* @param[out] pu1_dst 217* UWORD8 pointer to the destination 218* 219* @param[in] src_strd 220* integer source stride 221* 222* @param[in] dst_strd 223* integer destination stride 224* 225* @param[in] pi1_coeff 226* WORD8 pointer to the filter coefficients 227* 228* @param[in] ht 229* integer height of the array 230* 231* @param[in] wd 232* integer width of the array 233* 234* @returns 235* 236* @remarks 237* None 238* 239******************************************************************************* 240*/ 241 242 243void ihevc_inter_pred_luma_vert(UWORD8 *pu1_src, 244 UWORD8 *pu1_dst, 245 WORD32 src_strd, 246 WORD32 dst_strd, 247 WORD8 *pi1_coeff, 248 WORD32 ht, 249 WORD32 wd) 250{ 251 WORD32 row, col, i; 252 WORD16 i2_tmp; 253 254 for(row = 0; row < ht; row++) 255 { 256 for(col = 0; col < wd; col++) 257 { 258 i2_tmp = 0; 259 for(i = 0; i < NTAPS_LUMA; i++) 260 i2_tmp += pi1_coeff[i] * pu1_src[col + (i - 3) * src_strd]; 261 262 i2_tmp = (i2_tmp + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 263 i2_tmp = CLIP_U8(i2_tmp); 264 265 pu1_dst[col] = (UWORD8)i2_tmp; 266 } 267 268 pu1_src += src_strd; 269 pu1_dst += dst_strd; 270 } 271 272} 273 274 275/** 276******************************************************************************* 277* 278* @brief 279* Interprediction luma filter for copy 16bit output 280* 281* @par Description: 282* Copies the array of width 'wd' and height 'ht' from the location pointed 283* by 'src' to the location pointed by 'dst' The output is upshifted by 6 284* bits and is used as input for vertical filtering or weighted prediction 285* 286* @param[in] pu1_src 287* UWORD8 pointer to the source 288* 289* @param[out] pi2_dst 290* WORD16 pointer to the destination 291* 292* @param[in] src_strd 293* integer source stride 294* 295* @param[in] dst_strd 296* integer destination stride 297* 298* @param[in] pi1_coeff 299* WORD8 pointer to the filter coefficients 300* 301* @param[in] ht 302* integer height of the array 303* 304* @param[in] wd 305* integer width of the array 306* 307* @returns 308* 309* @remarks 310* None 311* 312******************************************************************************* 313*/ 314 315 316void ihevc_inter_pred_luma_copy_w16out(UWORD8 *pu1_src, 317 WORD16 *pi2_dst, 318 WORD32 src_strd, 319 WORD32 dst_strd, 320 WORD8 *pi1_coeff, 321 WORD32 ht, 322 WORD32 wd) 323{ 324 WORD32 row, col; 325 UNUSED(pi1_coeff); 326 for(row = 0; row < ht; row++) 327 { 328 for(col = 0; col < wd; col++) 329 { 330 pi2_dst[col] = (pu1_src[col] << SHIFT_14_MINUS_BIT_DEPTH); 331 } 332 333 pu1_src += src_strd; 334 pi2_dst += dst_strd; 335 } 336 337} 338 339 340/** 341******************************************************************************* 342* 343* @brief 344* Interprediction luma filter for horizontal 16bit output 345* 346* @par Description: 347* Applies a horizontal filter with coefficients pointed to by 'pi1_coeff' 348* to the elements pointed by 'pu1_src' and writes to the location pointed 349* by 'pu1_dst' No downshifting or clipping is done and the output is used 350* as an input for vertical filtering or weighted prediction 351* 352* @param[in] pu1_src 353* UWORD8 pointer to the source 354* 355* @param[out] pi2_dst 356* WORD16 pointer to the destination 357* 358* @param[in] src_strd 359* integer source stride 360* 361* @param[in] dst_strd 362* integer destination stride 363* 364* @param[in] pi1_coeff 365* WORD8 pointer to the filter coefficients 366* 367* @param[in] ht 368* integer height of the array 369* 370* @param[in] wd 371* integer width of the array 372* 373* @returns 374* 375* @remarks 376* None 377* 378******************************************************************************* 379*/ 380 381 382void ihevc_inter_pred_luma_horz_w16out(UWORD8 *pu1_src, 383 WORD16 *pi2_dst, 384 WORD32 src_strd, 385 WORD32 dst_strd, 386 WORD8 *pi1_coeff, 387 WORD32 ht, 388 WORD32 wd) 389{ 390 WORD32 row, col, i; 391 WORD16 i2_tmp; 392 393 for(row = 0; row < ht; row++) 394 { 395 for(col = 0; col < wd; col++) 396 { 397 i2_tmp = 0; 398 for(i = 0; i < NTAPS_LUMA; i++) 399 i2_tmp += pi1_coeff[i] * pu1_src[col + (i - 3)]; 400 401 pi2_dst[col] = i2_tmp; 402 } 403 404 pu1_src += src_strd; 405 pi2_dst += dst_strd; 406 } 407 408} 409 410 411/** 412******************************************************************************* 413* 414* @brief 415* Interprediction luma filter for vertical 16bit output 416* 417* @par Description: 418* Applies a vertical filter with coefficients pointed to by 'pi1_coeff' to 419* the elements pointed by 'pu1_src' and writes to the location pointed by 420* 'pu1_dst' No downshifting or clipping is done and the output is used as 421* an input for weighted prediction 422* 423* @param[in] pu1_src 424* UWORD8 pointer to the source 425* 426* @param[out] pi2_dst 427* WORD16 pointer to the destination 428* 429* @param[in] src_strd 430* integer source stride 431* 432* @param[in] dst_strd 433* integer destination stride 434* 435* @param[in] pi1_coeff 436* WORD8 pointer to the filter coefficients 437* 438* @param[in] ht 439* integer height of the array 440* 441* @param[in] wd 442* integer width of the array 443* 444* @returns 445* 446* @remarks 447* None 448* 449******************************************************************************* 450*/ 451 452 453void ihevc_inter_pred_luma_vert_w16out(UWORD8 *pu1_src, 454 WORD16 *pi2_dst, 455 WORD32 src_strd, 456 WORD32 dst_strd, 457 WORD8 *pi1_coeff, 458 WORD32 ht, 459 WORD32 wd) 460{ 461 WORD32 row, col, i; 462 WORD16 i2_tmp; 463 464 for(row = 0; row < ht; row++) 465 { 466 for(col = 0; col < wd; col++) 467 { 468 i2_tmp = 0; 469 for(i = 0; i < NTAPS_LUMA; i++) 470 i2_tmp += pi1_coeff[i] * pu1_src[col + (i - 3) * src_strd]; 471 472 pi2_dst[col] = i2_tmp; 473 } 474 475 pu1_src += src_strd; 476 pi2_dst += dst_strd; 477 } 478 479} 480 481/** 482******************************************************************************* 483* 484* @brief 485* 486* Luma vertical filter for 16bit input. 487* 488* @par Description: 489* Applies a vertical filter with coefficients pointed to by 'pi1_coeff' to 490* the elements pointed by 'pu1_src' and writes to the location pointed by 491* 'pu1_dst' Input is 16 bits The filter output is downshifted by 12 and 492* clipped to lie between 0 and 255 493* 494* @param[in] pi2_src 495* WORD16 pointer to the source 496* 497* @param[out] pu1_dst 498* UWORD8 pointer to the destination 499* 500* @param[in] src_strd 501* integer source stride 502* 503* @param[in] dst_strd 504* integer destination stride 505* 506* @param[in] pi1_coeff 507* WORD8 pointer to the filter coefficients 508* 509* @param[in] ht 510* integer height of the array 511* 512* @param[in] wd 513* integer width of the array 514* 515* @returns 516* 517* @remarks 518* None 519* 520******************************************************************************* 521*/ 522 523void ihevc_inter_pred_luma_vert_w16inp(WORD16 *pi2_src, 524 UWORD8 *pu1_dst, 525 WORD32 src_strd, 526 WORD32 dst_strd, 527 WORD8 *pi1_coeff, 528 WORD32 ht, 529 WORD32 wd) 530{ 531 WORD32 row, col, i; 532 WORD32 i4_tmp; 533 534 for(row = 0; row < ht; row++) 535 { 536 for(col = 0; col < wd; col++) 537 { 538 i4_tmp = 0; 539 for(i = 0; i < NTAPS_LUMA; i++) 540 i4_tmp += pi1_coeff[i] * pi2_src[col + (i - 3) * src_strd]; 541 542 i4_tmp = ((i4_tmp >> SHIFT_14_MINUS_BIT_DEPTH) + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 543 i4_tmp = CLIP_U8(i4_tmp); 544 545 pu1_dst[col] = i4_tmp; 546 } 547 548 pi2_src += src_strd; 549 pu1_dst += dst_strd; 550 } 551 552} 553 554 555/** 556******************************************************************************* 557* 558* @brief 559* Luma prediction filter for vertical 16bit input & output 560* 561* @par Description: 562* Applies a vertical filter with coefficients pointed to by 'pi1_coeff' to 563* the elements pointed by 'pu1_src' and writes to the location pointed by 564* 'pu1_dst' Input is 16 bits The filter output is downshifted by 6 and 565* 8192 is subtracted to store it as a 16 bit number The output is used as 566* a input to weighted prediction 567* 568* @param[in] pi2_src 569* WORD16 pointer to the source 570* 571* @param[out] pi2_dst 572* WORD16 pointer to the destination 573* 574* @param[in] src_strd 575* integer source stride 576* 577* @param[in] dst_strd 578* integer destination stride 579* 580* @param[in] pi1_coeff 581* WORD8 pointer to the filter coefficients 582* 583* @param[in] ht 584* integer height of the array 585* 586* @param[in] wd 587* integer width of the array 588* 589* @returns 590* 591* @remarks 592* None 593* 594******************************************************************************* 595*/ 596 597 598void ihevc_inter_pred_luma_vert_w16inp_w16out(WORD16 *pi2_src, 599 WORD16 *pi2_dst, 600 WORD32 src_strd, 601 WORD32 dst_strd, 602 WORD8 *pi1_coeff, 603 WORD32 ht, 604 WORD32 wd) 605{ 606 WORD32 row, col, i; 607 WORD32 i4_tmp; 608 609 for(row = 0; row < ht; row++) 610 { 611 for(col = 0; col < wd; col++) 612 { 613 i4_tmp = 0; 614 for(i = 0; i < NTAPS_LUMA; i++) 615 i4_tmp += pi1_coeff[i] * pi2_src[col + (i - 3) * src_strd]; 616 617 i4_tmp = (i4_tmp >> SHIFT_14_MINUS_BIT_DEPTH) - OFFSET14; 618 619 pi2_dst[col] = i4_tmp; 620 } 621 622 pi2_src += src_strd; 623 pi2_dst += dst_strd; 624 } 625 626} 627 628 629 630/** 631******************************************************************************* 632* 633* @brief 634* Chroma interprediction filter for copy 635* 636* @par Description: 637* Copies the array of width 'wd' and height 'ht' from the location pointed 638* by 'src' to the location pointed by 'dst' 639* 640* @param[in] pu1_src 641* UWORD8 pointer to the source 642* 643* @param[out] pu1_dst 644* UWORD8 pointer to the destination 645* 646* @param[in] src_strd 647* integer source stride 648* 649* @param[in] dst_strd 650* integer destination stride 651* 652* @param[in] pi1_coeff 653* WORD8 pointer to the filter coefficients 654* 655* @param[in] ht 656* integer height of the array 657* 658* @param[in] wd 659* integer width of the array 660* 661* @returns 662* 663* @remarks 664* None 665* 666******************************************************************************* 667*/ 668 669 670void ihevc_inter_pred_chroma_copy(UWORD8 *pu1_src, 671 UWORD8 *pu1_dst, 672 WORD32 src_strd, 673 WORD32 dst_strd, 674 WORD8 *pi1_coeff, 675 WORD32 ht, 676 WORD32 wd) 677{ 678 WORD32 row, col; 679 UNUSED(pi1_coeff); 680 for(row = 0; row < ht; row++) 681 { 682 for(col = 0; col < 2 * wd; col++) 683 { 684 pu1_dst[col] = pu1_src[col]; 685 } 686 687 pu1_src += src_strd; 688 pu1_dst += dst_strd; 689 } 690} 691 692 693 694/** 695******************************************************************************* 696* 697* @brief 698* Chroma interprediction filter for horizontal input 699* 700* @par Description: 701* Applies a horizontal filter with coefficients pointed to by 'pi1_coeff' 702* to the elements pointed by 'pu1_src' and writes to the location pointed 703* by 'pu1_dst' The output is downshifted by 6 and clipped to 8 bits 704* 705* @param[in] pu1_src 706* UWORD8 pointer to the source 707* 708* @param[out] pu1_dst 709* UWORD8 pointer to the destination 710* 711* @param[in] src_strd 712* integer source stride 713* 714* @param[in] dst_strd 715* integer destination stride 716* 717* @param[in] pi1_coeff 718* WORD8 pointer to the filter coefficients 719* 720* @param[in] ht 721* integer height of the array 722* 723* @param[in] wd 724* integer width of the array 725* 726* @returns 727* 728* @remarks 729* None 730* 731******************************************************************************* 732*/ 733 734 735void ihevc_inter_pred_chroma_horz(UWORD8 *pu1_src, 736 UWORD8 *pu1_dst, 737 WORD32 src_strd, 738 WORD32 dst_strd, 739 WORD8 *pi1_coeff, 740 WORD32 ht, 741 WORD32 wd) 742{ 743 WORD32 row, col, i; 744 WORD16 i2_tmp_u, i2_tmp_v; 745 746 for(row = 0; row < ht; row++) 747 { 748 for(col = 0; col < 2 * wd; col += 2) 749 { 750 i2_tmp_u = 0; 751 i2_tmp_v = 0; 752 for(i = 0; i < NTAPS_CHROMA; i++) 753 { 754 i2_tmp_u += pi1_coeff[i] * pu1_src[col + (i - 1) * 2]; 755 i2_tmp_v += pi1_coeff[i] * pu1_src[col + 1 + (i - 1) * 2]; 756 } 757 758 i2_tmp_u = (i2_tmp_u + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 759 i2_tmp_u = CLIP_U8(i2_tmp_u); 760 i2_tmp_v = (i2_tmp_v + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 761 i2_tmp_v = CLIP_U8(i2_tmp_v); 762 763 764 pu1_dst[col] = (UWORD8)i2_tmp_u; 765 pu1_dst[col + 1] = (UWORD8)i2_tmp_v; 766 } 767 768 pu1_src += src_strd; 769 pu1_dst += dst_strd; 770 } 771} 772 773 774 775/** 776******************************************************************************* 777* 778* @brief 779* Chroma interprediction filter for vertical input 780* 781* @par Description: 782* Applies a vertcal filter with coefficients pointed to by 'pi1_coeff' to 783* the elements pointed by 'pu1_src' and writes to the location pointed by 784* 'pu1_dst' The output is downshifted by 6 and clipped to 8 bits 785* 786* 787* @param[in] pu1_src 788* UWORD8 pointer to the source 789* 790* @param[out] pu1_dst 791* UWORD8 pointer to the destination 792* 793* @param[in] src_strd 794* integer source stride 795* 796* @param[in] dst_strd 797* integer destination stride 798* 799* @param[in] pi1_coeff 800* WORD8 pointer to the filter coefficients 801* 802* @param[in] ht 803* integer height of the array 804* 805* @param[in] wd 806* integer width of the array 807* 808* @returns 809* 810* @remarks 811* None 812* 813******************************************************************************* 814*/ 815 816 817void ihevc_inter_pred_chroma_vert(UWORD8 *pu1_src, 818 UWORD8 *pu1_dst, 819 WORD32 src_strd, 820 WORD32 dst_strd, 821 WORD8 *pi1_coeff, 822 WORD32 ht, 823 WORD32 wd) 824{ 825 WORD32 row, col, i; 826 WORD16 i2_tmp; 827 828 for(row = 0; row < ht; row++) 829 { 830 for(col = 0; col < 2 * wd; col++) 831 { 832 i2_tmp = 0; 833 for(i = 0; i < NTAPS_CHROMA; i++) 834 { 835 i2_tmp += pi1_coeff[i] * pu1_src[col + (i - 1) * src_strd]; 836 } 837 838 i2_tmp = (i2_tmp + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 839 i2_tmp = CLIP_U8(i2_tmp); 840 841 pu1_dst[col] = (UWORD8)i2_tmp; 842 } 843 844 pu1_src += src_strd; 845 pu1_dst += dst_strd; 846 } 847} 848 849 850 851/** 852******************************************************************************* 853* 854* @brief 855* chroma interprediction filter for copying 16bit output 856* 857* @par Description: 858* Copies the array of width 'wd' and height 'ht' from the location pointed 859* by 'src' to the location pointed by 'dst' The output is upshifted by 6 860* bits and is used as input for vertical filtering or weighted prediction 861* 862* @param[in] pu1_src 863* UWORD8 pointer to the source 864* 865* @param[out] pi2_dst 866* WORD16 pointer to the destination 867* 868* @param[in] src_strd 869* integer source stride 870* 871* @param[in] dst_strd 872* integer destination stride 873* 874* @param[in] pi1_coeff 875* WORD8 pointer to the filter coefficients 876* 877* @param[in] ht 878* integer height of the array 879* 880* @param[in] wd 881* integer width of the array 882* 883* @returns 884* 885* @remarks 886* None 887* 888******************************************************************************* 889*/ 890 891 892void ihevc_inter_pred_chroma_copy_w16out(UWORD8 *pu1_src, 893 WORD16 *pi2_dst, 894 WORD32 src_strd, 895 WORD32 dst_strd, 896 WORD8 *pi1_coeff, 897 WORD32 ht, 898 WORD32 wd) 899{ 900 WORD32 row, col; 901 UNUSED(pi1_coeff); 902 for(row = 0; row < ht; row++) 903 { 904 for(col = 0; col < 2 * wd; col++) 905 { 906 pi2_dst[col] = (pu1_src[col] << SHIFT_14_MINUS_BIT_DEPTH); 907 } 908 909 pu1_src += src_strd; 910 pi2_dst += dst_strd; 911 } 912} 913 914 915 916/** 917******************************************************************************* 918* 919* @brief 920* chroma interprediction filter to store horizontal 16bit ouput 921* 922* @par Description: 923* Applies a horizontal filter with coefficients pointed to by 'pi1_coeff' 924* to the elements pointed by 'pu1_src' and writes to the location pointed 925* by 'pu1_dst' No downshifting or clipping is done and the output is used 926* as an input for vertical filtering or weighted prediction 927* 928* @param[in] pu1_src 929* UWORD8 pointer to the source 930* 931* @param[out] pi2_dst 932* WORD16 pointer to the destination 933* 934* @param[in] src_strd 935* integer source stride 936* 937* @param[in] dst_strd 938* integer destination stride 939* 940* @param[in] pi1_coeff 941* WORD8 pointer to the filter coefficients 942* 943* @param[in] ht 944* integer height of the array 945* 946* @param[in] wd 947* integer width of the array 948* 949* @returns 950* 951* @remarks 952* None 953* 954******************************************************************************* 955*/ 956 957 958void ihevc_inter_pred_chroma_horz_w16out(UWORD8 *pu1_src, 959 WORD16 *pi2_dst, 960 WORD32 src_strd, 961 WORD32 dst_strd, 962 WORD8 *pi1_coeff, 963 WORD32 ht, 964 WORD32 wd) 965{ 966 WORD32 row, col, i; 967 WORD16 i2_tmp_u, i2_tmp_v; 968 969 for(row = 0; row < ht; row++) 970 { 971 for(col = 0; col < 2 * wd; col += 2) 972 { 973 i2_tmp_u = 0; 974 i2_tmp_v = 0; 975 for(i = 0; i < NTAPS_CHROMA; i++) 976 { 977 i2_tmp_u += pi1_coeff[i] * pu1_src[col + (i - 1) * 2]; 978 i2_tmp_v += pi1_coeff[i] * pu1_src[col + 1 + (i - 1) * 2]; 979 } 980 981 pi2_dst[col] = i2_tmp_u; 982 pi2_dst[col + 1] = i2_tmp_v; 983 } 984 985 pu1_src += src_strd; 986 pi2_dst += dst_strd; 987 } 988} 989 990 991 992/** 993******************************************************************************* 994* 995* @brief 996* Interprediction chroma filter to store vertical 16bit ouput 997* 998* @par Description: 999* Applies a vertical filter with coefficients pointed to by 'pi1_coeff' to 1000* the elements pointed by 'pu1_src' and writes to the location pointed by 1001* 'pu1_dst' No downshifting or clipping is done and the output is used as 1002* an input for weighted prediction 1003* 1004* @param[in] pu1_src 1005* UWORD8 pointer to the source 1006* 1007* @param[out] pi2_dst 1008* WORD16 pointer to the destination 1009* 1010* @param[in] src_strd 1011* integer source stride 1012* 1013* @param[in] dst_strd 1014* integer destination stride 1015* 1016* @param[in] pi1_coeff 1017* WORD8 pointer to the filter coefficients 1018* 1019* @param[in] ht 1020* integer height of the array 1021* 1022* @param[in] wd 1023* integer width of the array 1024* 1025* @returns 1026* 1027* @remarks 1028* None 1029* 1030******************************************************************************* 1031*/ 1032 1033 1034void ihevc_inter_pred_chroma_vert_w16out(UWORD8 *pu1_src, 1035 WORD16 *pi2_dst, 1036 WORD32 src_strd, 1037 WORD32 dst_strd, 1038 WORD8 *pi1_coeff, 1039 WORD32 ht, 1040 WORD32 wd) 1041{ 1042 WORD32 row, col, i; 1043 WORD16 i2_tmp; 1044 1045 for(row = 0; row < ht; row++) 1046 { 1047 for(col = 0; col < 2 * wd; col++) 1048 { 1049 i2_tmp = 0; 1050 for(i = 0; i < NTAPS_CHROMA; i++) 1051 { 1052 i2_tmp += pi1_coeff[i] * pu1_src[col + (i - 1) * src_strd]; 1053 } 1054 1055 pi2_dst[col] = i2_tmp; 1056 } 1057 1058 pu1_src += src_strd; 1059 pi2_dst += dst_strd; 1060 } 1061} 1062 1063 1064/** 1065******************************************************************************* 1066* 1067* @brief 1068* chroma interprediction filter for vertical 16bit input 1069* 1070* @par Description: 1071* Applies a vertical filter with coefficients pointed to by 'pi1_coeff' to 1072* the elements pointed by 'pu1_src' and writes to the location pointed by 1073* 'pu1_dst' Input is 16 bits The filter output is downshifted by 12 and 1074* clipped to lie between 0 and 255 1075* 1076* @param[in] pi2_src 1077* WORD16 pointer to the source 1078* 1079* @param[out] pu1_dst 1080* UWORD8 pointer to the destination 1081* 1082* @param[in] src_strd 1083* integer source stride 1084* 1085* @param[in] dst_strd 1086* integer destination stride 1087* 1088* @param[in] pi1_coeff 1089* WORD8 pointer to the filter coefficients 1090* 1091* @param[in] ht 1092* integer height of the array 1093* 1094* @param[in] wd 1095* integer width of the array 1096* 1097* @returns 1098* 1099* @remarks 1100* None 1101* 1102******************************************************************************* 1103*/ 1104 1105void ihevc_inter_pred_chroma_vert_w16inp(WORD16 *pi2_src, 1106 UWORD8 *pu1_dst, 1107 WORD32 src_strd, 1108 WORD32 dst_strd, 1109 WORD8 *pi1_coeff, 1110 WORD32 ht, 1111 WORD32 wd) 1112{ 1113 WORD32 row, col, i; 1114 WORD32 i4_tmp; 1115 1116 for(row = 0; row < ht; row++) 1117 { 1118 for(col = 0; col < 2 * wd; col++) 1119 { 1120 i4_tmp = 0; 1121 for(i = 0; i < NTAPS_CHROMA; i++) 1122 { 1123 i4_tmp += pi1_coeff[i] * pi2_src[col + (i - 1) * src_strd]; 1124 } 1125 1126 i4_tmp = ((i4_tmp >> SHIFT_14_MINUS_BIT_DEPTH) + OFFSET_14_MINUS_BIT_DEPTH) >> SHIFT_14_MINUS_BIT_DEPTH; 1127 i4_tmp = CLIP_U8(i4_tmp); 1128 1129 pu1_dst[col] = i4_tmp; 1130 } 1131 1132 pi2_src += src_strd; 1133 pu1_dst += dst_strd; 1134 } 1135 1136} 1137 1138 1139/** 1140******************************************************************************* 1141* 1142* @brief 1143* 1144* Chroma interprediction filter for 16bit vertical input and output. 1145* 1146* @par Description: 1147* Applies a vertical filter with coefficients pointed to by 'pi1_coeff' to 1148* the elements pointed by 'pu1_src' and writes to the location pointed by 1149* 'pu1_dst' Input is 16 bits The filter output is downshifted by 6 and 1150* 8192 is subtracted to store it as a 16 bit number The output is used as 1151* a input to weighted prediction 1152* 1153* @param[in] pi2_src 1154* WORD16 pointer to the source 1155* 1156* @param[out] pi2_dst 1157* WORD16 pointer to the destination 1158* 1159* @param[in] src_strd 1160* integer source stride 1161* 1162* @param[in] dst_strd 1163* integer destination stride 1164* 1165* @param[in] pi1_coeff 1166* WORD8 pointer to the filter coefficients 1167* 1168* @param[in] ht 1169* integer height of the array 1170* 1171* @param[in] wd 1172* integer width of the array 1173* 1174* @returns 1175* 1176* @remarks 1177* None 1178* 1179******************************************************************************* 1180*/ 1181 1182void ihevc_inter_pred_chroma_vert_w16inp_w16out(WORD16 *pi2_src, 1183 WORD16 *pi2_dst, 1184 WORD32 src_strd, 1185 WORD32 dst_strd, 1186 WORD8 *pi1_coeff, 1187 WORD32 ht, 1188 WORD32 wd) 1189{ 1190 WORD32 row, col, i; 1191 WORD32 i4_tmp; 1192 1193 for(row = 0; row < ht; row++) 1194 { 1195 for(col = 0; col < 2 * wd; col++) 1196 { 1197 i4_tmp = 0; 1198 for(i = 0; i < NTAPS_CHROMA; i++) 1199 { 1200 i4_tmp += pi1_coeff[i] * pi2_src[col + (i - 1) * src_strd]; 1201 } 1202 1203 i4_tmp = (i4_tmp >> SHIFT_14_MINUS_BIT_DEPTH); 1204 1205 pi2_dst[col] = i4_tmp; 1206 } 1207 1208 pi2_src += src_strd; 1209 pi2_dst += dst_strd; 1210 } 1211 1212} 1213 1214 1215