changeset 4001:fcb9de59245f libavformat

uses FF_ARRAY_ELEMS() where appropriate
author aurel
date Tue, 21 Oct 2008 21:40:24 +0000
parents f0580597dc48
children 65cb6eca2944
files img2.c isom.c matroskadec.c mxfenc.c utils.c
diffstat 5 files changed, 12 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/img2.c	Sun Oct 19 01:02:48 2008 +0000
+++ b/img2.c	Tue Oct 21 21:40:24 2008 +0000
@@ -88,7 +88,7 @@
 {
     int i;
 
-    for(i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++) {
+    for(i=0;i<FF_ARRAY_ELEMS(sizes);i++) {
         if ((sizes[i][0] * sizes[i][1]) == size) {
             *width_ptr = sizes[i][0];
             *height_ptr = sizes[i][1];
--- a/isom.c	Sun Oct 19 01:02:48 2008 +0000
+++ b/isom.c	Tue Oct 21 21:40:24 2008 +0000
@@ -248,7 +248,7 @@
     int i, code = 0;
 
     /* old way, only for QT? */
-    for (i = 0; !mp4 && (i < (sizeof(mov_mdhd_language_map)/sizeof(char *))); i++) {
+    for (i = 0; !mp4 && i < FF_ARRAY_ELEMS(mov_mdhd_language_map); i++) {
         if (mov_mdhd_language_map[i] && !strcmp(lang, mov_mdhd_language_map[i]))
             return i;
     }
@@ -284,7 +284,7 @@
         return 1;
     }
     /* old fashion apple lang code */
-    if (code >= (sizeof(mov_mdhd_language_map)/sizeof(char *)))
+    if (code >= FF_ARRAY_ELEMS(mov_mdhd_language_map))
         return 0;
     if (!mov_mdhd_language_map[code])
         return 0;
--- a/matroskadec.c	Sun Oct 19 01:02:48 2008 +0000
+++ b/matroskadec.c	Tue Oct 21 21:40:24 2008 +0000
@@ -226,8 +226,6 @@
     EbmlList blocks;
 } MatroskaCluster;
 
-#define ARRAY_SIZE(x)  (sizeof(x)/sizeof(*x))
-
 static EbmlSyntax ebml_header[] = {
     { EBML_ID_EBMLREADVERSION,        EBML_UINT, 0, offsetof(Ebml,version), {.u=EBML_VERSION} },
     { EBML_ID_EBMLMAXSIZELENGTH,      EBML_UINT, 0, offsetof(Ebml,max_size), {.u=8} },
@@ -980,7 +978,7 @@
     int i, j;
 
     for (i=0; i < list->nb_elem; i++) {
-        for (j=0; j < ARRAY_SIZE(metadata); j++){
+        for (j=0; j < FF_ARRAY_ELEMS(metadata); j++){
             if (!strcmp(tags[i].name, metadata[j].name)) {
                 int *ptr = (int *)((char *)s + metadata[j].offset);
                 if (*ptr)  continue;
@@ -1050,7 +1048,7 @@
     static const char * const aac_profiles[] = { "MAIN", "LC", "SSR" };
     int profile;
 
-    for (profile=0; profile<ARRAY_SIZE(aac_profiles); profile++)
+    for (profile=0; profile<FF_ARRAY_ELEMS(aac_profiles); profile++)
         if (strstr(codec_id, aac_profiles[profile]))
             break;
     return profile + 1;
@@ -1060,7 +1058,7 @@
 {
     int sri;
 
-    for (sri=0; sri<ARRAY_SIZE(ff_mpeg4audio_sample_rates); sri++)
+    for (sri=0; sri<FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++)
         if (ff_mpeg4audio_sample_rates[sri] == samplerate)
             break;
     return sri;
--- a/mxfenc.c	Sun Oct 19 01:02:48 2008 +0000
+++ b/mxfenc.c	Tue Oct 21 21:40:24 2008 +0000
@@ -74,8 +74,7 @@
 typedef struct MXFContext {
     int64_t footer_partition_offset;
     int essence_container_count;
-    uint8_t essence_containers_indices[sizeof(mxf_essence_container_uls)/
-                                       sizeof(*mxf_essence_container_uls)];
+    uint8_t essence_containers_indices[FF_ARRAY_ELEMS(mxf_essence_container_uls)];
 } MXFContext;
 
 static const uint8_t uuid_base[]            = { 0xAD,0xAB,0x44,0x24,0x2f,0x25,0x4d,0xc7,0x92,0xff,0x29,0xbd };
@@ -207,8 +206,7 @@
 static int mxf_get_essence_container_ul_index(enum CodecID id)
 {
     int i;
-    for (i = 0; i < sizeof(mxf_essence_container_uls)/
-                    sizeof(*mxf_essence_container_uls); i++)
+    for (i = 0; i < FF_ARRAY_ELEMS(mxf_essence_container_uls); i++)
         if (mxf_essence_container_uls[i].id == id)
             return i;
     return -1;
@@ -219,7 +217,7 @@
     ByteIOContext *pb = s->pb;
     int local_tag_number, i = 0;
 
-    local_tag_number = sizeof(mxf_local_tag_batch)/sizeof(*mxf_local_tag_batch);
+    local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch);
 
     put_buffer(pb, primer_pack_key, 16);
     klv_encode_ber_length(pb, local_tag_number * 18 + 8);
@@ -754,8 +752,7 @@
 {
     MXFContext *mxf = s->priv_data;
     int i;
-    uint8_t present[sizeof(mxf_essence_container_uls)/
-                    sizeof(*mxf_essence_container_uls)] = {0};
+    uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0};
 
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
--- a/utils.c	Sun Oct 19 01:02:48 2008 +0000
+++ b/utils.c	Tue Oct 21 21:40:24 2008 +0000
@@ -2904,7 +2904,7 @@
     q = NULL;
     if (!duration) {
         /* parse the year-month-day part */
-        for (i = 0; i < sizeof(date_fmt) / sizeof(date_fmt[0]); i++) {
+        for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
             q = small_strptime(p, date_fmt[i], &dt);
             if (q) {
                 break;
@@ -2928,7 +2928,7 @@
             p++;
 
         /* parse the hour-minute-second part */
-        for (i = 0; i < sizeof(time_fmt) / sizeof(time_fmt[0]); i++) {
+        for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
             q = small_strptime(p, time_fmt[i], &dt);
             if (q) {
                 break;