Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(278436)

Side by Side Diff: src/pvq.c

Issue 1442: pvq: improve rounding bias for int max_theta
Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*Daala video codec 1 /*Daala video codec
2 Copyright (c) 2012 Daala project contributors. All rights reserved. 2 Copyright (c) 2012 Daala project contributors. All rights reserved.
3 3
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met: 5 modification, are permitted provided that the following conditions are met:
6 6
7 - Redistributions of source code must retain the above copyright notice, this 7 - Redistributions of source code must retain the above copyright notice, this
8 list of conditions and the following disclaimer. 8 list of conditions and the following disclaimer.
9 9
10 - Redistributions in binary form must reproduce the above copyright notice, 10 - Redistributions in binary form must reproduce the above copyright notice,
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 * 727 *
728 * @param [in] qcg quantized companded gain value 728 * @param [in] qcg quantized companded gain value
729 * @param [in] beta activity masking beta param 729 * @param [in] beta activity masking beta param
730 * @return max theta value 730 * @return max theta value
731 */ 731 */
732 int od_pvq_compute_max_theta(od_val32 qcg, double beta){ 732 int od_pvq_compute_max_theta(od_val32 qcg, double beta){
733 /* Set angular resolution (in ra) to match the encoded gain */ 733 /* Set angular resolution (in ra) to match the encoded gain */
734 #if defined(OD_FLOAT_PVQ) 734 #if defined(OD_FLOAT_PVQ)
735 int ts = (int)floor(.5 + qcg*OD_CGAIN_SCALE_1*M_PI/(2*beta)); 735 int ts = (int)floor(.5 + qcg*OD_CGAIN_SCALE_1*M_PI/(2*beta));
736 #else 736 #else
737 int ts = OD_SHR_ROUND((int)floor(.5 + qcg*OD_QCONST32(M_PI, 737 int ts = ((int)floor(.5 + qcg*OD_QCONST32(M_PI, OD_CGAIN_SHIFT)/(2*beta))
738 OD_CGAIN_SHIFT)/(2*beta)), OD_CGAIN_SHIFT*2); 738 - (1 << OD_CGAIN_SHIFT*2 >> 2)) >> OD_CGAIN_SHIFT*2;
jm 2016/08/23 15:19:18 This should probably be updated now that beta is f
739 #endif 739 #endif
740 /* Special case for low gains -- will need to be tuned anyway */ 740 /* Special case for low gains -- will need to be tuned anyway */
741 if (qcg < OD_QCONST32(1.4, OD_CGAIN_SHIFT)) ts = 1; 741 if (qcg < OD_QCONST32(1.4, OD_CGAIN_SHIFT)) ts = 1;
742 return ts; 742 return ts;
743 } 743 }
744 744
745 /** Decode quantized theta value from coded value 745 /** Decode quantized theta value from coded value
746 * 746 *
747 * @param [in] t quantized companded gain value 747 * @param [in] t quantized companded gain value
748 * @param [in] max_theta maximum theta value 748 * @param [in] max_theta maximum theta value
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 for (i = 0; i < n; i++) { 964 for (i = 0; i < n; i++) {
965 #if defined(OD_FLOAT_PVQ) 965 #if defined(OD_FLOAT_PVQ)
966 xcoeff[i] = (od_coeff)floor(.5 + (x[i]*(qm_inv[i]*OD_QM_INV_SCALE_1))); 966 xcoeff[i] = (od_coeff)floor(.5 + (x[i]*(qm_inv[i]*OD_QM_INV_SCALE_1)));
967 #else 967 #else
968 xcoeff[i] = OD_SHR_ROUND(x[i]*qm_inv[i], qshift); 968 xcoeff[i] = OD_SHR_ROUND(x[i]*qm_inv[i], qshift);
969 #endif 969 #endif
970 } 970 }
971 } 971 }
972 } 972 }
973 973
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld