[FFmpeg-devel] [PATCH] replace magic number with size of array

2015-11-23 Thread webmaster
From: Mohammad Ghasembeigi 

---
 libavcodec/dsicinvideo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c
index f95cbc7..cb5baf8 100644
--- a/libavcodec/dsicinvideo.c
+++ b/libavcodec/dsicinvideo.c
@@ -100,7 +100,7 @@ static int cin_decode_huffman(const unsigned char *src, int 
src_size,
 unsigned char *dst_end   = dst + dst_size;
 const unsigned char *src_end = src + src_size;
 
-memcpy(huff_code_table, src, 15);
+memcpy(huff_code_table, src, sizeof(huff_code_table));
 src += 15;
 
 while (src < src_end) {
-- 
1.9.5.msysgit.1

___
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Remove size magic number (15) and use sizeof instead

2015-11-24 Thread webmaster
From: Mohammad Ghasembeigi 

---
 libavcodec/dsicinvideo.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c
index f95cbc7..dc9ae7d 100644
--- a/libavcodec/dsicinvideo.c
+++ b/libavcodec/dsicinvideo.c
@@ -100,12 +100,12 @@ static int cin_decode_huffman(const unsigned char *src, 
int src_size,
 unsigned char *dst_end   = dst + dst_size;
 const unsigned char *src_end = src + src_size;
 
-memcpy(huff_code_table, src, 15);
-src += 15;
+memcpy(huff_code_table, src, sizeof(huff_code_table));
+src += sizeof(huff_code_table);
 
 while (src < src_end) {
 huff_code = *src++;
-if ((huff_code >> 4) == 15) {
+if ((huff_code >> 4) == sizeof(huff_code_table)) {
 b  = huff_code << 4;
 huff_code  = *src++;
 *dst_cur++ = b | (huff_code >> 4);
@@ -114,8 +114,8 @@ static int cin_decode_huffman(const unsigned char *src, int 
src_size,
 if (dst_cur >= dst_end)
 break;
 
-huff_code &= 15;
-if (huff_code == 15) {
+huff_code &= sizeof(huff_code_table);
+if (huff_code == sizeof(huff_code_table)) {
 *dst_cur++ = *src++;
 } else
 *dst_cur++ = huff_code_table[huff_code];
-- 
1.9.5.msysgit.1

___
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel