[Swfed-svn] swfed-svn [72] Rev. 71 の改造をキャンセル ( パフォーマンス悪化の為)

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2008年 10月 14日 (火) 22:57:11 JST


Revision: 72
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=swfed&view=rev&rev=72
Author:   yoya
Date:     2008-10-14 22:57:11 +0900 (Tue, 14 Oct 2008)

Log Message:
-----------
Rev.71 の改造をキャンセル (パフォーマンス悪化の為)

Modified Paths:
--------------
    trunk/src/swf_object.c
    trunk/src/swf_object.h
    trunk/src/swf_tag.h
    trunk/src/swfed.c


-------------- next part --------------
Modified: trunk/src/swf_object.c
===================================================================
--- trunk/src/swf_object.c	2008-10-14 12:19:10 UTC (rev 71)
+++ trunk/src/swf_object.c	2008-10-14 13:57:11 UTC (rev 72)
@@ -26,28 +26,24 @@
 
 void
 swf_object_close(swf_object_t *swf) {
-    swf_tag_list_t *tag_list, *next_tag;
-    if (swf == NULL) {
+    swf_tag_t *tag, *next_tag;
+    if (! swf) {
         return ;
     }
-    for (tag_list = swf->tag_list; tag_list; tag_list = next_tag) {
-        next_tag = tag_list->next;
-        if (tag_list->node) {
-            swf_tag_destroy(tag_list->node);
-        }
-        free(tag_list);
+    for(tag = swf->tag; tag; tag = next_tag) {
+        next_tag = tag->next;
+        swf_tag_destroy(tag);
     }
     free(swf);
     malloc_debug_end(); /* DEBUG XXX */
     return ;
 }
-
 int
 swf_object_input(swf_object_t *swf, unsigned char *data,
                  unsigned long data_len) {
     int result;
     bitstream_t *bs = bitstream_open();
-    swf_tag_list_t *tag_list;
+    swf_tag_t **tag;
     bitstream_input(bs, data, data_len);
     result = swf_header_parse(bs, &swf->header);
     if (result) {
@@ -89,18 +85,18 @@
         bitstream_close(bs);
         return result;
     }
-    swf->tag_list = tag_list = calloc(sizeof(*tag_list), 1);
+    tag = &swf->tag;
     while(1) {
-        long pos = bitstream_getbytepos(bs);
+        long pos;
+        pos = bitstream_getbytepos(bs);
         if ((pos == -1) || ((long) swf->header.file_length <= pos)) {
             break;
         }
-        tag_list->node = swf_tag_create(bs);
-        if (tag_list->node == NULL) {
+        *tag = swf_tag_create(bs);
+        if (tag == NULL) {
             fprintf(stderr, "swf_object_input: swf_tag_create failed\n");
         }
-        tag_list->next = calloc(sizeof(*tag_list), 1);
-        tag_list = tag_list->next;
+        tag = &((*tag)->next);
     }
     bitstream_close(bs);
     return 0;
@@ -109,7 +105,7 @@
 unsigned char *
 swf_object_output(swf_object_t *swf, unsigned long *length) {
     int result;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     unsigned char *data;
     bitstream_t *bs = bitstream_open();
     *length = 0;
@@ -123,8 +119,8 @@
         bitstream_close(bs);
         return NULL;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node; tag_list = tag_list->next) {
-        swf_tag_build(bs, tag_list->node, swf);
+    for (tag = swf->tag; tag; tag = tag->next) {
+        swf_tag_build(bs, tag, swf);
     }
     swf->header.file_length = bitstream_getbytepos(bs);
     bitstream_setpos(bs, SWF_MAGIC_SIZE, 0);
@@ -166,17 +162,17 @@
 void
 swf_object_print(swf_object_t *swf) {
     int i;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     swf_header_print(&swf->header);
     swf_header_movie_print(&swf->header_movie);
-    tag_list = swf->tag_list;
-    for (i=0; tag_list && tag_list->node; i++) {
+    tag = swf->tag;
+    for (i=0; tag; i++) {
         printf("[%d] ", i);
-        swf_tag_print(tag_list->node, swf);
-        if (tag_list->node->tag == 0) { // END Tag
+        swf_tag_print(tag, swf);
+        if (tag->tag == 0) { // END Tag
             break;
         }
-        tag_list = tag_list->next;
+        tag = tag->next;
     }
 }
 
@@ -185,32 +181,29 @@
 
 unsigned char *
 swf_object_get_jpegdata(swf_object_t *swf, unsigned long *length, int image_id) {
-    swf_tag_list_t *tag_list;
-    swf_tag_t *tag_jpegtables = NULL;
+    swf_tag_t *tag, *tag_jpegtables = NULL;
     unsigned char *data = NULL;
     *length = 0;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_get_jpegdata: swf == NULL\n");
         return NULL;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node; tag_list = tag_list->next) {
-        if (tag_list->node->tag == 8) { // JPEGTables
-            tag_jpegtables = tag_list->node;
+    for (tag = swf->tag; tag; tag = tag->next) {
+        if (tag->tag == 8) { // JPEGTables
+            tag_jpegtables = tag;
             break;
         }
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node; tag_list = tag_list->next) {
-        if (tag_list->node->tag == 8) {
-            tag_jpegtables = tag_list->node;
+    for (tag = swf->tag; tag; tag = tag->next) {
+        if (tag->tag == 8) {
+            tag_jpegtables = tag;
             continue;
         }
         // DefineBitsJPEG(1),2,3
-        if ((tag_list->node->tag != 6) &&
-            (tag_list->node->tag != 21) &&
-            (tag_list->node->tag != 35)) {
+        if ((tag->tag != 6) && (tag->tag != 21) && (tag->tag != 35)) {
             continue;
         }
-        data = swf_tag_get_jpeg_data(tag_list->node, length, image_id, tag_jpegtables);
+        data = swf_tag_get_jpeg_data(tag, length, image_id, tag_jpegtables);
         if (data) {
             break;
         }
@@ -220,20 +213,18 @@
 
 unsigned char *
 swf_object_get_alphadata(swf_object_t *swf, unsigned long *length, int image_id) {
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     unsigned char *data = NULL;
     *length = 0;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_get_alphadata: swf == NULL\n");
         return NULL;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
-        if (tag_list->node->tag != 35) { // ! DefineBitsJPEG3
+    for (tag = swf->tag; tag; tag = tag->next) {
+        if (tag->tag != 35) { // ! DefineBitsJPEG3
             continue;
         }
-        data = swf_tag_get_alpha_data(tag_list->node, length,
-                                      image_id);
+        data = swf_tag_get_alpha_data(tag, length, image_id);
         if (data) {
             break;
         }
@@ -249,14 +240,13 @@
                             unsigned char *alpha_data,
                             unsigned long alpha_data_len) {
     int result = 1;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_replace_jpegdata: swf == NULL\n");
         return 1;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
-        result = swf_tag_replace_jpeg_data(tag_list->node, image_id,
+    for (tag = swf->tag; tag; tag = tag->next) {
+        result = swf_tag_replace_jpeg_data(tag, image_id,
                                            jpeg_data, jpeg_data_len,
                                            alpha_data, alpha_data_len);
         if (! result) {
@@ -269,21 +259,19 @@
 
 unsigned char *
 swf_object_get_pngdata(swf_object_t *swf, unsigned long *length, int image_id) {
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     unsigned char *data = NULL;
     *length = 0;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_get_pngdata: swf == NULL\n");
         return NULL;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
+    for (tag = swf->tag; tag; tag = tag->next) {
         // DefineBitsLossless(1),2
-        if ((tag_list->node->tag != 20) &&
-            (tag_list->node->tag != 36)) {
+        if ((tag->tag != 20) && (tag->tag != 36)) {
             continue;
         }
-        data = swf_tag_get_png_data(tag_list->node, length, image_id);
+        data = swf_tag_get_png_data(tag, length, image_id);
         if (data) {
             break;
         }
@@ -296,14 +284,13 @@
                             unsigned char *png_data,
                             unsigned long png_data_len) {
     int result = 1;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_replace_pngdata: swf == NULL\n");
         return 1;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
-        result = swf_tag_replace_png_data(tag_list->node, image_id,
+    for (tag = swf->tag; tag; tag = tag->next) {
+        result = swf_tag_replace_png_data(tag, image_id,
                                            png_data, png_data_len);
         if (! result) {
             break;
@@ -314,20 +301,19 @@
 
 unsigned char *
 swf_object_get_sounddata(swf_object_t *swf, unsigned long *length, int sound_id) {
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     unsigned char *data = NULL;
     *length = 0;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_get_sounddata: swf == NULL\n");
         return NULL;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
+    for (tag = swf->tag; tag; tag = tag->next) {
         // DefineSound
-        if (tag_list->node->tag != 14) {
+        if (tag->tag != 14) {
             continue;
         }
-        data = swf_tag_get_sound_data(tag_list->node, length, sound_id);
+        data = swf_tag_get_sound_data(tag, length, sound_id);
         if (data) {
             break;
         }
@@ -340,14 +326,13 @@
                             unsigned char *melo_data,
                             unsigned long melo_data_len) {
     int result = 1;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_replace_melodata: swf == NULL\n");
         return 1;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
-        result = swf_tag_replace_melo_data(tag_list->node, sound_id,
+    for (tag = swf->tag; tag; tag = tag->next) {
+        result = swf_tag_replace_melo_data(tag, sound_id,
                                            melo_data, melo_data_len);
         if (! result) {
             break;
@@ -360,15 +345,14 @@
 swf_object_get_editstring(swf_object_t *swf,
                           char *variable_name,
                           int variable_name_len) {
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     char *data = NULL;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_get_editstring: swf == NULL\n");
         return NULL;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
-        data = swf_tag_get_edit_string(tag_list->node, variable_name,
+    for (tag = swf->tag; tag; tag = tag->next) {
+        data = swf_tag_get_edit_string(tag, variable_name,
                                        variable_name_len, swf);
         if (data) {
             break;
@@ -383,15 +367,13 @@
                               char *initial_text,
                               int initial_text_len) {
     int result = 1;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     if (swf == NULL) {
         fprintf(stderr, "swf_object_replace_editstring: swf == NULL\n");
         return 1;
     }
-    for (tag_list = swf->tag_list; tag_list && tag_list->node;
-         tag_list = tag_list->next) {
-        result = swf_tag_replace_edit_string(tag_list->node,
-                                             variable_name,
+    for (tag = swf->tag; tag; tag = tag->next) {
+        result = swf_tag_replace_edit_string(tag, variable_name,
                                              variable_name_len,
                                              initial_text,
                                              initial_text_len,
@@ -405,24 +387,23 @@
 
 unsigned char *
 swf_object_get_actiondata(swf_object_t *swf, unsigned long *length, int tag_seqno) {
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     swf_tag_action_detail_t *swf_tag_action;
     int i = 0;
-    for(tag_list = swf->tag_list; tag_list && tag_list->node;
-        tag_list = tag_list->next) {
+    for(tag = swf->tag; tag; tag = tag->next) {
         if (i == tag_seqno) {
             break;
         }
         i++;
     }
-    if (tag_list == NULL) {
+    if (tag == NULL) {
         return NULL;
     }
-    if ((tag_list->node->tag != 12) &&  (tag_list->node->tag != 59)) { //  DoAction, DoInitAction
+    if ((tag->tag != 12) &&  (tag->tag != 59)) { //  DoAction, DoInitAction
         return NULL;
     }
-    swf_tag_create_detail(tag_list->node, swf);
-    swf_tag_action = (swf_tag_action_detail_t *) tag_list->node->detail;
+    swf_tag_create_detail(tag, swf);
+    swf_tag_action = (swf_tag_action_detail_t *) tag->detail;
     *length = swf_tag_action->action_record_len;
     return swf_tag_action->action_record;
 }

Modified: trunk/src/swf_object.h
===================================================================
--- trunk/src/swf_object.h	2008-10-14 12:19:10 UTC (rev 71)
+++ trunk/src/swf_object.h	2008-10-14 13:57:11 UTC (rev 72)
@@ -14,7 +14,7 @@
 typedef struct swf_object_ {
     swf_header_t header;
     swf_header_movie_t header_movie;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
 } swf_object_t;
 
 

Modified: trunk/src/swf_tag.h
===================================================================
--- trunk/src/swf_tag.h	2008-10-14 12:19:10 UTC (rev 71)
+++ trunk/src/swf_tag.h	2008-10-14 13:57:11 UTC (rev 72)
@@ -21,11 +21,6 @@
     struct swf_tag_ *next;
 } swf_tag_t;
 
-typedef struct swf_tag_list_ {
-    struct swf_tag_ *node;
-    struct swf_tag_list_ *next;
-} swf_tag_list_t;
-
 typedef struct swf_tag_detail_handler_ {
     void          * (*create)   (unsigned char *data,
                                  unsigned long length,

Modified: trunk/src/swfed.c
===================================================================
--- trunk/src/swfed.c	2008-10-14 12:19:10 UTC (rev 71)
+++ trunk/src/swfed.c	2008-10-14 13:57:11 UTC (rev 72)
@@ -318,26 +318,26 @@
     int i = 0;
     zval *data;
     swf_object_t *swf;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     swf_tag_info_t *tag_info;
     if (ZEND_NUM_ARGS() != 0) {
         WRONG_PARAM_COUNT;
         RETURN_FALSE; /* XXX */
     }
     swf = get_swf_object(getThis());
+    tag = swf->tag;
     array_init(return_value);
-    for(tag_list = swf->tag_list; tag_list && tag_list->node;
-        tag_list = tag_list->next) {
+    for(tag = swf->tag; tag; tag=tag->next) {
         ALLOC_INIT_ZVAL(data);
         array_init(data);
-        add_assoc_long(data, "tag", tag_list->node->tag);
-        tag_info = get_swf_tag_info(tag_list->node->tag);
+        add_assoc_long(data, "tag", tag->tag);
+        tag_info = get_swf_tag_info(tag->tag);
         if (tag_info && tag_info->name) {
             add_assoc_string_ex(data,
                                 "tagName", sizeof("tagName"),
                                 (char *)tag_info->name, 1);
         }
-        add_assoc_long(data, "length", tag_list->node->length);
+        add_assoc_long(data, "length", tag->length);
         if (tag_info && tag_info->detail_handler) {
             add_assoc_bool(data, "detail", 1);
         }
@@ -349,7 +349,7 @@
 PHP_METHOD(swfed, getTagDetail) {
     long tag_seqno;
     swf_object_t *swf;
-    swf_tag_list_t *tag_list;
+    swf_tag_t *tag;
     swf_tag_info_t *tag_info;
     int i;
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@@ -358,22 +358,21 @@
     }
     swf = get_swf_object(getThis());
     i = 0;
-    for (tag_list = swf->tag_list; tag_list && tag_list->node ;
-         tag_list = tag_list->next) {
+    for(tag = swf->tag; tag; tag = tag->next) {
         if (i == tag_seqno) {
             break;
         }
         i++;
     }
-    if (tag_list == NULL) {
+    if (tag == NULL) {
         RETURN_FALSE;
     }
-    tag_info = get_swf_tag_info(tag_list->node->tag);
+    tag_info = get_swf_tag_info(tag->tag);
     if ((tag_info == NULL) || (tag_info->detail_handler == NULL)) {
         RETURN_FALSE;
     }
-    swf_tag_create_detail(tag_list->node, swf);
-    switch (tag_list->node->tag) {
+    swf_tag_create_detail(tag, swf);
+    switch (tag->tag) {
         swf_tag_jpeg_detail_t     *tag_jpeg;
         swf_tag_lossless_detail_t *tag_lossless;
         swf_tag_edit_detail_t     *tag_edit;
@@ -382,7 +381,7 @@
       case 6:  // DefineBitsJPEG
       case 21: // DefineBitsJPEG2
       case 35: // DefineBitsJPEG3
-        tag_jpeg = tag_list->node->detail;
+        tag_jpeg = tag->detail;
         array_init(return_value);
         add_assoc_long(return_value, "image_id", tag_jpeg->image_id);
         add_assoc_long(return_value, "jpeg_data_len", tag_jpeg->jpeg_data_len);
@@ -393,7 +392,7 @@
         break;
       case 20: // DefineBitsLossless
       case 36: // DefineBitsLossless2
-        tag_lossless = tag_list->node->detail;
+        tag_lossless = tag->detail;
         array_init(return_value);
         add_assoc_long(return_value, "image_id", tag_lossless->image_id);
         add_assoc_long(return_value, "format", tag_lossless->format);
@@ -404,7 +403,7 @@
         }
         break;
     case 14: // DefineSound
-        tag_sound = tag_list->node->detail;
+        tag_sound = tag->detail;
         array_init(return_value);
         add_assoc_long(return_value, "sound_id", tag_sound->sound_id);
         add_assoc_long(return_value, "format", (unsigned long) tag_sound->sound_format);
@@ -416,9 +415,9 @@
         break;
     case 12: // DoAction
     case 59: // DoInitAction
-        tag_action = tag_list->node->detail;
+        tag_action = tag->detail;
         array_init(return_value);
-        if (tag_list->node->tag == 59) { // DoInitAction
+        if (tag->tag == 59) { // DoInitAction
             add_assoc_long(return_value, "action_sprite", tag_action->action_sprite);
         }
         if (tag_action->action_record && tag_action->action_record_len) {
@@ -426,7 +425,7 @@
         }
         break;
       case 37: // DefineEditText;
-        tag_edit = tag_list->node->detail;
+        tag_edit = tag->detail;
         array_init(return_value);
         add_assoc_long(return_value, "edit_id", tag_edit->edit_id);
         if (tag_edit->edit_variable_name && tag_edit->edit_variable_name[0]){


Swfed-svn メーリングリストの案内
アーカイブの一覧に戻る