[x264-devel] commit: Eliminate intentional array overflow in quant matrix handling ( Jason Garrett-Glaser )
git version control
git at videolan.org
Thu Jan 14 05:51:08 CET 2010
x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Wed Jan 13 20:21:31 2010 -0500| [3d0f1108f982867dde5079bbbf90553487de2ed0] | committer: Jason Garrett-Glaser
Eliminate intentional array overflow in quant matrix handling
While it probably never caused problems, it was incredibly ugly and evil.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=3d0f1108f982867dde5079bbbf90553487de2ed0
---
common/set.c | 38 +++++++++++++++++++++-----------------
1 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/common/set.c b/common/set.c
index a7bca7d..f9379f0 100644
--- a/common/set.c
+++ b/common/set.c
@@ -184,26 +184,30 @@ fail:
return -1;
}
+#define CQM_DELETE( n, max )\
+ for( i = 0; i < max; i++ )\
+ {\
+ for( j = 0; j < i; j++ )\
+ if( h->quant##n##_mf[i] == h->quant##n##_mf[j] )\
+ break;\
+ if( j == i )\
+ {\
+ x264_free( h-> quant##n##_mf[i] );\
+ x264_free( h->dequant##n##_mf[i] );\
+ x264_free( h->unquant##n##_mf[i] );\
+ }\
+ for( j = 0; j < i; j++ )\
+ if( h->quant##n##_bias[i] == h->quant##n##_bias[j] )\
+ break;\
+ if( j == i )\
+ x264_free( h->quant##n##_bias[i] );\
+ }
+
void x264_cqm_delete( x264_t *h )
{
int i, j;
- for( i = 0; i < 6; i++ )
- {
- for( j = 0; j < i; j++ )
- if( h->quant4_mf[i] == h->quant4_mf[j] )
- break;
- if( j == i )
- {
- x264_free( h-> quant4_mf[i] );
- x264_free( h->dequant4_mf[i] );
- x264_free( h->unquant4_mf[i] );
- }
- for( j = 0; j < i; j++ )
- if( h->quant4_bias[i] == h->quant4_bias[j] )
- break;
- if( j == i )
- x264_free( h->quant4_bias[i] );
- }
+ CQM_DELETE( 4, 4 );
+ CQM_DELETE( 8, 2 );
}
static int x264_cqm_parse_jmlist( x264_t *h, const char *buf, const char *name,
More information about the x264-devel
mailing list