[Swfed-svn] swfed-svn [390] - identity を廃止

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 3月 7日 (月) 23:00:14 JST


Revision: 390
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=390
Author:   yoya
Date:     2011-03-07 23:00:14 +0900 (Mon, 07 Mar 2011)

Log Message:
-----------
- identity を廃止
- get_cid, replace_cid を追加

Modified Paths:
--------------
    trunk/src/swf_define.h
    trunk/src/swf_object.c
    trunk/src/swf_tag.c
    trunk/src/swf_tag.h
    trunk/src/swf_tag_action.c
    trunk/src/swf_tag_action.h
    trunk/src/swf_tag_edit.c
    trunk/src/swf_tag_edit.h
    trunk/src/swf_tag_jpeg.c
    trunk/src/swf_tag_jpeg.h
    trunk/src/swf_tag_lossless.c
    trunk/src/swf_tag_lossless.h
    trunk/src/swf_tag_place.c
    trunk/src/swf_tag_shape.c
    trunk/src/swf_tag_shape.h
    trunk/src/swf_tag_sound.c
    trunk/src/swf_tag_sound.h
    trunk/src/swf_tag_sprite.c
    trunk/src/swf_tag_sprite.h


-------------- next part --------------
Modified: trunk/src/swf_define.h
===================================================================
--- trunk/src/swf_define.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_define.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -62,6 +62,8 @@
 #define GetULongLE(data) ((unsigned long) GV4B(data[3], data[2], data[1], data[0]))
 #define GetDoubleIEEE(data) ((double) GV8B(data[4], data[5], data[6], data[7], data[0], data[1], data[2], data[3]))
 
+#define PutUShortLE(data, value) ((data[0] = (value & 0xff)), (data[1] = (value >> 16)))
+
 // tag
 
 // DefineBitsJPEG1,2,3

Modified: trunk/src/swf_object.c
===================================================================
--- trunk/src/swf_object.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_object.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -262,7 +262,7 @@
     swf_tag_t *tag;
     tag = swf->tag;
     while (tag) {
-        if (swf_tag_identity(tag, cid) == 0) {
+        if (swf_tag_get_cid(tag) == cid) {
             break; // match
         }
         tag = tag->next;
@@ -295,7 +295,7 @@
     swf_tag_t *tag;
     tag = swf->tag;
     while (tag) {
-        if (swf_tag_identity(tag, cid) == 0) {
+        if (swf_tag_get_cid(tag) == cid) {
             break; // match
         }
         tag = tag->next;
@@ -324,7 +324,7 @@
     swf_tag_t *tag;
     tag = swf->tag;
     while (tag) {
-        if (swf_tag_identity(tag, cid) == 0) {
+        if (swf_tag_get_cid(tag) == cid) {
             break; // match
         }
         tag = tag->next;
@@ -361,7 +361,7 @@
     swf_tag_t *tag;
     tag = swf->tag;
     while (tag) {
-        if (swf_tag_identity(tag, cid) == 0) {
+        if (swf_tag_get_cid(tag) ==  cid) {
             break; // match
         }
         tag = tag->next;
@@ -399,7 +399,7 @@
     for (tag=swf->tag ; tag ; tag=tag->next) {
         register int tag_code = tag->tag;
         if (isBitmapTag(tag_code)) {
-            if (swf_tag_identity(tag, bitmap_id) == 0) {
+            if (swf_tag_get_cid(tag) == bitmap_id) {
                 return tag; // match
             }
         }
@@ -887,7 +887,7 @@
     }
     for (tag=swf->tag ; tag ; tag=tag->next) {
         if (isSpriteTag(tag->tag)) {
-            if (swf_tag_identity(tag, cid) == 0) {
+            if (swf_tag_get_cid(tag) ==  cid) {
                 sprite_tag = tag;
                 break;
             }

Modified: trunk/src/swf_tag.c
===================================================================
--- trunk/src/swf_tag.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -268,22 +268,31 @@
 }
 
 int
-swf_tag_identity(swf_tag_t *tag, int cid) {
+swf_tag_get_cid(swf_tag_t *tag) {
     swf_tag_info_t *tag_info;
     tag_info = get_swf_tag_info(tag->tag);
     if (tag_info && tag_info->detail_handler) {
         swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
-        if (detail_handler->identity) {
-            if (detail_handler->identity(tag, cid)) {
-                return 1; // no match
-            } else{
-                return 0; // match
-            }
+        if (detail_handler->get_cid) {
+            return detail_handler->get_cid(tag);
         }
     }
-    return 1; // no match - no identity method
+    return -1; // no cid tag
 }
 
+int
+swf_tag_replace_cid(swf_tag_t *tag, int cid) {
+    swf_tag_info_t *tag_info;
+    tag_info = get_swf_tag_info(tag->tag);
+    if (tag_info && tag_info->detail_handler) {
+        swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
+        if (detail_handler->replace_cid) {
+            return detail_handler->replace_cid(tag, cid);
+        }
+    }
+    return 1; // no cid tag
+}
+
 /* bitmap */
 
 int
@@ -344,7 +353,6 @@
 
 unsigned char *
 swf_tag_get_alpha_data(swf_tag_t *tag, unsigned long *length, int image_id) {
-    swf_tag_info_t *tag_info;
     *length = 0;
     if (tag == NULL) {
         fprintf(stderr, "swf_tag_get_alpha_data: tag == NULL\n");
@@ -353,14 +361,8 @@
     if (tag->tag != 35) { // ! DefineBitsJPEG3
         return NULL;
     }
-    tag_info = get_swf_tag_info(tag->tag);
-    if (tag_info && tag_info->detail_handler) {
-        swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
-        if (detail_handler->identity) {
-            if (detail_handler->identity(tag, image_id)) {
-                return NULL;
-            }
-        }
+    if (swf_tag_get_cid(tag) != image_id) {
+        return NULL;
     }
     if (! tag->detail) {
         swf_tag_create_input_detail(tag, NULL);
@@ -390,7 +392,7 @@
     }
     tag_info = get_swf_tag_info(tag->tag); // Bitmap Tag
     detail_handler = tag_info->detail_handler();
-    if (detail_handler->identity(tag, image_id)) {
+    if (detail_handler->get_cid(tag) !=  image_id) {
         return 1;
     }
 
@@ -465,7 +467,7 @@
     }
     tag_info = get_swf_tag_info(tag->tag); // Bitmap Tag
     detail_handler = tag_info->detail_handler();
-    if (detail_handler->identity(tag, image_id)) {
+    if (detail_handler->get_cid(tag) != image_id) {
         return 1;
     }
     
@@ -518,7 +520,7 @@
     }
     tag_info = get_swf_tag_info(tag->tag); // Bitmap Tag
     detail_handler = tag_info->detail_handler();
-    if (detail_handler->identity(tag, image_id)) {
+    if (detail_handler->get_cid(tag) != image_id) {
         return 1;
     }
     
@@ -583,7 +585,6 @@
 swf_tag_replace_melo_data(swf_tag_t *tag, int sound_id,
                           unsigned char *melo_data,
                           unsigned long melo_data_len) {
-    swf_tag_info_t *tag_info;
     int result;
     if (tag == NULL) {
         fprintf(stderr, "swf_tag_replace_melo_data: tag == NULL\n");
@@ -592,14 +593,8 @@
     if (tag->tag != 14) { // DefineSound
         return 1;
     }
-    tag_info = get_swf_tag_info(tag->tag);
-    if (tag_info && tag_info->detail_handler) {
-        swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
-        if (detail_handler->identity) {
-            if (detail_handler->identity(tag, sound_id)) {
-                return 1;
-            }
-        }
+    if (swf_tag_get_cid(tag) != sound_id) {
+        return 1;
     }
     if (! tag->detail) {
         swf_tag_create_input_detail(tag, NULL);
@@ -680,7 +675,6 @@
                                   double rotate_rad,
                                   signed int trans_x, signed int trans_y,
                                   struct swf_object_ *swf) {
-    swf_tag_info_t *tag_info;
     int result;
     if (tag == NULL) {
         fprintf(stderr, "swf_tag_apply_shape_matrix_factor: tag == NULL\n");
@@ -691,14 +685,8 @@
         // ! DefineShape1,2,3, DefineMorphShape
         return 1;
     }
-    tag_info = get_swf_tag_info(tag->tag);
-    if (tag_info && tag_info->detail_handler) {
-        swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
-        if (detail_handler->identity) {
-            if (detail_handler->identity(tag, shape_id)) {
-                return 1;
-            }
-        }
+    if (swf_tag_get_cid(tag) != shape_id) {
+        return 1;
     }
     if (! tag->detail) {
         swf_tag_create_input_detail(tag, swf);
@@ -724,7 +712,6 @@
                                   double scale_x, double scale_y,
                                   signed int trans_x, signed int trans_y,
                                   struct swf_object_ *swf) {
-    swf_tag_info_t *tag_info;
     int result;
     if (tag == NULL) {
         fprintf(stderr, "swf_tag_apply_shape_rect_factor: tag == NULL\n");
@@ -735,14 +722,8 @@
         // ! DefineShape1,2,3, DefineMorphShape
         return 1;
     }
-    tag_info = get_swf_tag_info(tag->tag);
-    if (tag_info && tag_info->detail_handler) {
-        swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
-        if (detail_handler->identity) {
-            if (detail_handler->identity(tag, shape_id)) {
-                return 1;
-            }
-        }
+    if (swf_tag_get_cid(tag) != shape_id) {
+        return 1;
     }
     if (! tag->detail) {
         swf_tag_create_input_detail(tag, swf);
@@ -765,7 +746,6 @@
 int
 swf_tag_apply_shape_type_tilled(swf_tag_t *tag, int shape_id,
                                 struct swf_object_ *swf) {
-    swf_tag_info_t *tag_info;
     int result;
     if (tag == NULL) {
         fprintf(stderr, "swf_tag_apply_shape_type_tylled: tag == NULL\n");
@@ -776,14 +756,8 @@
         // ! DefineShape1,2,3, DefineMorphShape
         return 1;
     }
-    tag_info = get_swf_tag_info(tag->tag);
-    if (tag_info && tag_info->detail_handler) {
-        swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
-        if (detail_handler->identity) {
-            if (detail_handler->identity(tag, shape_id)) {
-                return 1;
-            }
-        }
+    if (swf_tag_get_cid(tag) != shape_id) {
+        return 1;
     }
     if (! tag->detail) {
         swf_tag_create_input_detail(tag, swf);

Modified: trunk/src/swf_tag.h
===================================================================
--- trunk/src/swf_tag.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -26,7 +26,8 @@
 typedef struct swf_tag_detail_handler_ {
     void          * (*create)   (void);
     int             (*input)    (swf_tag_t *tag, struct swf_object_ *swf);
-    int             (*identity) (swf_tag_t *tag, int id);
+    int             (*get_cid)  (swf_tag_t *tag);
+    int             (*replace_cid) (swf_tag_t *tag, int cid);
     unsigned char * (*output)   (swf_tag_t *tag, unsigned long *length,
                                  struct swf_object_ *swf);
     void            (*print)    (swf_tag_t *tag, struct swf_object_ *swf,
@@ -47,7 +48,8 @@
 extern int swf_tag_build(bitstream_t *bs, swf_tag_t *tag, struct swf_object_ *swf);
 extern void swf_tag_print(swf_tag_t *tag, struct swf_object_ *swf, int indent_depth);
 
-extern int swf_tag_identity(swf_tag_t *tag, int cid);
+extern int swf_tag_get_cid(swf_tag_t *tag);
+extern int swf_tag_replace_cid(swf_tag_t *tag, int cid);
 
 /* image */
 

Modified: trunk/src/swf_tag_action.c
===================================================================
--- trunk/src/swf_tag_action.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_action.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -16,7 +16,8 @@
 swf_tag_action_detail_handler(void) {
     action_detail_handler.create   = swf_tag_action_create_detail;
     action_detail_handler.input    = swf_tag_action_input_detail;
-    action_detail_handler.identity = swf_tag_action_identity_detail;
+    action_detail_handler.get_cid  = NULL;
+    action_detail_handler.replace_cid  = NULL;
     action_detail_handler.output   = swf_tag_action_output_detail;
     action_detail_handler.print    = swf_tag_action_print_detail;
     action_detail_handler.destroy  = swf_tag_action_destroy_detail;
@@ -66,12 +67,6 @@
     return 0;
 }
 
-int swf_tag_action_identity_detail(swf_tag_t *tag, int id) {
-    (void) tag;
-    (void) id;
-    return 1;
-}
-
 unsigned char *
 swf_tag_action_output_detail(swf_tag_t *tag, unsigned long *length,
                              struct swf_object_ *swf) {

Modified: trunk/src/swf_tag_action.h
===================================================================
--- trunk/src/swf_tag_action.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_action.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -21,7 +21,8 @@
 extern void *swf_tag_action_create_detail(void);
 extern int swf_tag_action_input_detail(swf_tag_t *tag,
                                        struct swf_object_ *swf);
-extern int swf_tag_action_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_action_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_action_replace_cid_detail(swf_tag_t *tag, int id);
 extern unsigned char *swf_tag_action_output_detail(swf_tag_t *tag,
                                                    unsigned long *length,
                                                    struct swf_object_ *swf);

Modified: trunk/src/swf_tag_edit.c
===================================================================
--- trunk/src/swf_tag_edit.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_edit.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -17,7 +17,8 @@
 swf_tag_edit_detail_handler(void) {
     edit_detail_handler.create   = swf_tag_edit_create_detail;
     edit_detail_handler.input    = swf_tag_edit_input_detail;
-    edit_detail_handler.identity = swf_tag_edit_identity_detail;
+    edit_detail_handler.get_cid  = swf_tag_edit_get_cid_detail;
+    edit_detail_handler.replace_cid = swf_tag_edit_replace_cid_detail;
     edit_detail_handler.output   = swf_tag_edit_output_detail;
     edit_detail_handler.print    = swf_tag_edit_print_detail;
     edit_detail_handler.destroy  = swf_tag_edit_destroy_detail;
@@ -100,27 +101,31 @@
     return 0;
 }
 
-int swf_tag_edit_identity_detail(swf_tag_t *tag, int id) {
+int swf_tag_edit_get_cid_detail(swf_tag_t *tag) {
     unsigned char *data = tag->data;
-    bitstream_t *bs;
-    int edit_id;
     if (tag->detail) {
         swf_tag_edit_detail_t *swf_tag_edit = (swf_tag_edit_detail_t *) tag->detail;
-        if (swf_tag_edit->edit_id == id) {
-            return 0;
-        }        
-        return 1;
+        return swf_tag_edit->edit_id;
     }
-    bs = bitstream_open();
-    bitstream_input(bs, data, 2);
-    edit_id = bitstream_getbytesLE(bs, 2);
-    bitstream_close(bs);
-    if (id == edit_id) {
-        return 0;
-    }        
-    return 1;
+    if (data == NULL) {
+        fprintf(stderr, "swf_tag_edit_get_cid_detail: data == NULL\n");
+        return -1;
+    }
+    return GetUShortLE(data); // edit_id;
 }
 
+int swf_tag_edit_replace_cid_detail(swf_tag_t *tag, int id) {
+    unsigned char *data = tag->data;
+    if (tag->detail) {
+        swf_tag_edit_detail_t *swf_tag_edit = (swf_tag_edit_detail_t *) tag->detail;
+        swf_tag_edit->edit_id = id;
+    }
+    if (data) {
+        PutUShortLE(data, id);
+    }
+    return 0; // always 0
+}
+
 unsigned char *
 swf_tag_edit_output_detail(swf_tag_t *tag, unsigned long *length,
                            struct swf_object_ *swf) {

Modified: trunk/src/swf_tag_edit.h
===================================================================
--- trunk/src/swf_tag_edit.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_edit.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -51,7 +51,8 @@
 
 extern void *swf_tag_edit_create_detail(void);
 extern int swf_tag_edit_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
-extern int swf_tag_edit_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_edit_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_edit_replace_cid_detail(swf_tag_t *tag, int id);
 extern unsigned char *swf_tag_edit_output_detail(swf_tag_t *tag,
                                                  unsigned long *length,
                                                  struct swf_object_ *swf);

Modified: trunk/src/swf_tag_jpeg.c
===================================================================
--- trunk/src/swf_tag_jpeg.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_jpeg.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -23,7 +23,8 @@
 swf_tag_detail_handler_t *swf_tag_jpeg_detail_handler(void) {
     jpeg_detail_handler.create   = swf_tag_jpeg_create_detail;
     jpeg_detail_handler.input    = swf_tag_jpeg_input_detail;
-    jpeg_detail_handler.identity = swf_tag_jpeg_identity_detail;
+    jpeg_detail_handler.get_cid  = swf_tag_jpeg_get_cid_detail;
+    jpeg_detail_handler.replace_cid = swf_tag_jpeg_replace_cid_detail;
     jpeg_detail_handler.output   = swf_tag_jpeg_output_detail;
     jpeg_detail_handler.print    = swf_tag_jpeg_print_detail;
     jpeg_detail_handler.destroy  = swf_tag_jpeg_destroy_detail;
@@ -33,7 +34,8 @@
 swf_tag_detail_handler_t *swf_tag_jpegt_detail_handler(void) {
     jpegt_detail_handler.create   = swf_tag_jpeg_create_detail;
     jpegt_detail_handler.input    = swf_tag_jpegt_input_detail;
-    jpegt_detail_handler.identity = swf_tag_jpegt_identity_detail;
+    jpegt_detail_handler.get_cid  = NULL;
+    jpegt_detail_handler.replace_cid = NULL;
     jpegt_detail_handler.output   = swf_tag_jpegt_output_detail;
     jpegt_detail_handler.print    = swf_tag_jpeg_print_detail;
     jpegt_detail_handler.destroy  = swf_tag_jpeg_destroy_detail;
@@ -43,7 +45,8 @@
 swf_tag_detail_handler_t *swf_tag_jpeg3_detail_handler(void) {
     jpeg3_detail_handler.create   = swf_tag_jpeg_create_detail;
     jpeg3_detail_handler.input    = swf_tag_jpeg3_input_detail;
-    jpeg3_detail_handler.identity = swf_tag_jpeg_identity_detail;
+    jpeg3_detail_handler.get_cid  = swf_tag_jpeg_get_cid_detail;
+    jpeg3_detail_handler.replace_cid = swf_tag_jpeg_replace_cid_detail;
     jpeg3_detail_handler.output   = swf_tag_jpeg3_output_detail;
     jpeg3_detail_handler.print    = swf_tag_jpeg_print_detail;
     jpeg3_detail_handler.destroy  = swf_tag_jpeg_destroy_detail;
@@ -174,34 +177,30 @@
 }
 
 int
-swf_tag_jpeg_identity_detail(swf_tag_t *tag, int id) {
+swf_tag_jpeg_get_cid_detail(swf_tag_t *tag) {
     unsigned char *data = tag->data;
-    int image_id;
     if (tag->detail) {
         swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;        
-        if (swf_tag_jpeg->image_id == id) {
-            return 0;
-        }        
-        return 1;
+        return swf_tag_jpeg->image_id;
     }
     if (data == NULL) {
-        fprintf(stderr, "swf_tag_jpeg_identity_detail: data==NULL\n");
-        return 1;
+        fprintf(stderr, "swf_tag_jpeg_get_cid_detail: data==NULL\n");
+        return -1;
     }
-    image_id = GetUShortLE(data);
-    if (id == image_id) {
-        return 0;
-    }        
-    return 1;
+    return GetUShortLE(data); // image_id;
 }
-
 int
-swf_tag_jpegt_identity_detail(swf_tag_t *tag, int id) {
-    (void) tag;
-    (void) id;
-    return 1; // always no match
+swf_tag_jpeg_replace_cid_detail(swf_tag_t *tag, int image_id) {
+    unsigned char *data = tag->data;
+    if (tag->detail) {
+        swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) tag->detail;        
+        swf_tag_jpeg->image_id = image_id;
+    }
+    if (data) {
+        PutUShortLE(data, image_id);
+    }
+    return 0; // always 0
 }
-
 unsigned char *
 swf_tag_jpeg_output_detail(swf_tag_t *tag, unsigned long *length,
                            struct swf_object_ *swf) {

Modified: trunk/src/swf_tag_jpeg.h
===================================================================
--- trunk/src/swf_tag_jpeg.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_jpeg.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -27,8 +27,8 @@
 extern int swf_tag_jpeg_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
 extern int swf_tag_jpegt_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
 extern int swf_tag_jpeg3_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
-extern int swf_tag_jpeg_identity_detail(swf_tag_t *tag, int id);
-extern int swf_tag_jpegt_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_jpeg_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_jpeg_replace_cid_detail(swf_tag_t *tag, int id);
 extern unsigned char *swf_tag_jpeg_output_detail(swf_tag_t *tag,
                                                  unsigned long *length,
                                                  struct swf_object_ *swf);

Modified: trunk/src/swf_tag_lossless.c
===================================================================
--- trunk/src/swf_tag_lossless.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_lossless.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -19,7 +19,8 @@
 swf_tag_detail_handler_t *swf_tag_lossless_detail_handler(void) {
     lossless_detail_handler.create   = swf_tag_lossless_create_detail;
     lossless_detail_handler.input    = swf_tag_lossless_input_detail;
-    lossless_detail_handler.identity = swf_tag_lossless_identity_detail;
+    lossless_detail_handler.get_cid  = swf_tag_lossless_get_cid_detail;
+    lossless_detail_handler.replace_cid = swf_tag_lossless_replace_cid_detail;
     lossless_detail_handler.output   = swf_tag_lossless_output_detail;
     lossless_detail_handler.print    = swf_tag_lossless_print_detail;
     lossless_detail_handler.destroy  = swf_tag_lossless_destroy_detail;
@@ -176,27 +177,32 @@
 }
 
 int
-swf_tag_lossless_identity_detail(swf_tag_t *tag, int id) {
+swf_tag_lossless_get_cid_detail(swf_tag_t *tag) {
     unsigned char *data = tag->data;
-    int image_id;
     if (tag->detail) {
         swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
-        if (swf_tag_lossless->image_id == id) {
-            return 0;
-        }        
-        return 1;
+        return swf_tag_lossless->image_id;
     }
     if (data == NULL) {
-        fprintf(stderr, "swf_tag_lossless_identity_detail: data==NULL at line(%d)\n", __LINE__);
-        return 1;
+        fprintf(stderr, "swf_tag_lossless_get_cid_detail: data==NULL at line(%d)\n", __LINE__);
+        return -1;
     }
-    image_id = GetUShortLE(data);
-    if (id == image_id) {
-        return 0;
-    }        
-    return 1;
+    return GetUShortLE(data); // image_id;
 }
 
+int
+swf_tag_lossless_replace_cid_detail(swf_tag_t *tag, int id) {
+    unsigned char *data = tag->data;
+    if (tag->detail) {
+        swf_tag_lossless_detail_t *swf_tag_lossless = (swf_tag_lossless_detail_t *) tag->detail;
+        swf_tag_lossless->image_id = id;
+    }
+    if (data) {
+        PutUShortLE(data, id);
+    }
+    return 0; // always 0
+}
+
 unsigned char *
 swf_tag_lossless_output_detail(swf_tag_t *tag, unsigned long *length,
                                struct swf_object_ *swf) {

Modified: trunk/src/swf_tag_lossless.h
===================================================================
--- trunk/src/swf_tag_lossless.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_lossless.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -32,7 +32,8 @@
 extern void *swf_tag_lossless_create_detail(void);
 extern int swf_tag_lossless_input_detail(swf_tag_t *tag,
                                          struct swf_object_ *swf);
-extern int swf_tag_lossless_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_lossless_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_lossless_replace_cid_detail(swf_tag_t *tag, int id);
 extern unsigned char *swf_tag_lossless_output_detail(swf_tag_t *tag,
                                                      unsigned long *length,
                                                      struct swf_object_ *swf);

Modified: trunk/src/swf_tag_place.c
===================================================================
--- trunk/src/swf_tag_place.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_place.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -16,7 +16,8 @@
 swf_tag_place_detail_handler(void) {
     place_detail_handler.create   = swf_tag_place_create_detail;
     place_detail_handler.input    = swf_tag_place_input_detail;
-    place_detail_handler.identity = NULL;
+    place_detail_handler.get_cid  = NULL;
+    place_detail_handler.replace_cid = NULL;
     place_detail_handler.output   = swf_tag_place_output_detail;
     place_detail_handler.print    = swf_tag_place_print_detail;
     place_detail_handler.destroy  = swf_tag_place_destroy_detail;

Modified: trunk/src/swf_tag_shape.c
===================================================================
--- trunk/src/swf_tag_shape.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_shape.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -17,7 +17,8 @@
 swf_tag_shape_detail_handler(void) {
     shape_detail_handler.create   = swf_tag_shape_create_detail;
     shape_detail_handler.input    = swf_tag_shape_input_detail;
-    shape_detail_handler.identity = swf_tag_shape_identity_detail;
+    shape_detail_handler.get_cid  = swf_tag_shape_get_cid_detail;
+    shape_detail_handler.replace_cid = swf_tag_shape_replace_cid_detail;
     shape_detail_handler.output   = swf_tag_shape_output_detail;
     shape_detail_handler.print    = swf_tag_shape_print_detail;
     shape_detail_handler.destroy  = swf_tag_shape_destroy_detail;
@@ -111,27 +112,31 @@
     return 0;
 }
 
-int swf_tag_shape_identity_detail(swf_tag_t *tag, int id) {
+int swf_tag_shape_get_cid_detail(swf_tag_t *tag) {
     unsigned char *data = tag->data;
-    bitstream_t *bs;
-    int shape_id;
     if (tag->detail) {
         swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
-        if (swf_tag_shape->shape_id == id) {
-            return 0;
-        }        
-        return 1;
+        return swf_tag_shape->shape_id;
     }
-    bs = bitstream_open();
-    bitstream_input(bs, data, 2);
-    shape_id = bitstream_getbytesLE(bs, 2);
-    bitstream_close(bs);
-    if (id == shape_id) {
-        return 0;
-    }        
-    return 1;
+    if (data == NULL) {
+        fprintf(stderr, "swf_tag_shape_get_cid_detail: data == NULL\n");
+        return -1;
+    }
+    return GetUShortLE(data); // shape_id;
 }
 
+int swf_tag_shape_replace_cid_detail(swf_tag_t *tag, int id) {
+    unsigned char *data = tag->data;
+    if (tag->detail) {
+        swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail;
+        swf_tag_shape->shape_id = id;
+    }
+    if (data) {
+        PutUShortLE(data, id);
+    }
+    return 0; // always 0
+}
+
 int swf_tag_shape_bitmap_identity(swf_tag_t *tag, int bitmap_id) {
     swf_tag_shape_detail_t *swf_tag_shape;
     int i, ret;

Modified: trunk/src/swf_tag_shape.h
===================================================================
--- trunk/src/swf_tag_shape.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_shape.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -48,7 +48,8 @@
 
 extern void *swf_tag_shape_create_detail(void);
 extern int swf_tag_shape_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
-extern int swf_tag_shape_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_shape_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_shape_replace_cid_detail(swf_tag_t *tag, int id);
 extern int swf_tag_shape_bitmap_identity(swf_tag_t *tag, int bitmap_id);
 extern unsigned char *swf_tag_shape_output_detail(swf_tag_t *tag,
                                                    unsigned long *length,

Modified: trunk/src/swf_tag_sound.c
===================================================================
--- trunk/src/swf_tag_sound.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_sound.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -16,7 +16,8 @@
 swf_tag_sound_detail_handler(void) {
     sound_detail_handler.create   = swf_tag_sound_create_detail;
     sound_detail_handler.input    = swf_tag_sound_input_detail;
-    sound_detail_handler.identity = swf_tag_sound_identity_detail;
+    sound_detail_handler.get_cid  = swf_tag_sound_get_cid_detail;
+    sound_detail_handler.replace_cid = swf_tag_sound_replace_cid_detail;
     sound_detail_handler.output   = swf_tag_sound_output_detail;
     sound_detail_handler.print    = swf_tag_sound_print_detail;
     sound_detail_handler.destroy  = swf_tag_sound_destroy_detail;
@@ -72,25 +73,32 @@
 }
 
 int
-swf_tag_sound_identity_detail(swf_tag_t *tag, int id) {
+swf_tag_sound_get_cid_detail(swf_tag_t *tag) {
     int sound_id;
     unsigned char *data = tag->data;
     if (tag->detail) {
         swf_tag_sound_detail_t *swf_tag_sound = (swf_tag_sound_detail_t *) tag->detail;
-        if (swf_tag_sound->sound_id == id) {
-            return 0;
-        }        
-        return 1;
+        return swf_tag_sound->sound_id;
     }
     if (data == NULL) {
-        fprintf(stderr, "swf_tag_sound_identity_detail: data==NULL\n");
-        return 1;
+        fprintf(stderr, "swf_tag_sound_get_cid_detail: data==NULL\n");
+        return -1;
     }
     sound_id = GetUShortLE(data);
-    if (id == sound_id) {
-        return 0;
+    return sound_id;
+}
+
+int
+swf_tag_sound_replace_cid_detail(swf_tag_t *tag, int id) {
+    unsigned char *data = tag->data;
+    if (tag->detail) {
+        swf_tag_sound_detail_t *swf_tag_sound = (swf_tag_sound_detail_t *) tag->detail;
+        swf_tag_sound->sound_id = id;
+    }
+    if (data == NULL) {
+        PutUShortLE(data, id);
     }        
-    return 1;
+    return 0; // always 0
 }
 
 unsigned char *

Modified: trunk/src/swf_tag_sound.h
===================================================================
--- trunk/src/swf_tag_sound.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_sound.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -24,7 +24,8 @@
 
 extern void *swf_tag_sound_create_detail(void);
 extern int swf_tag_sound_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
-extern int swf_tag_sound_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_sound_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_sound_replace_cid_detail(swf_tag_t *tag, int id);
 extern unsigned char *swf_tag_sound_output_detail(swf_tag_t *tag,
                                                   unsigned long *length,
                                                   struct swf_object_ *swf);

Modified: trunk/src/swf_tag_sprite.c
===================================================================
--- trunk/src/swf_tag_sprite.c	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_sprite.c	2011-03-07 14:00:14 UTC (rev 390)
@@ -16,7 +16,8 @@
 swf_tag_sprite_detail_handler(void) {
     sprite_detail_handler.create   = swf_tag_sprite_create_detail;
     sprite_detail_handler.input    = swf_tag_sprite_input_detail;
-    sprite_detail_handler.identity = swf_tag_sprite_identity_detail;
+    sprite_detail_handler.get_cid  = swf_tag_sprite_get_cid_detail;
+    sprite_detail_handler.replace_cid = swf_tag_sprite_replace_cid_detail;
     sprite_detail_handler.output   = swf_tag_sprite_output_detail;
     sprite_detail_handler.print    = swf_tag_sprite_print_detail;
     sprite_detail_handler.destroy  = swf_tag_sprite_destroy_detail;
@@ -68,25 +69,29 @@
     return 0;
 }
 
-int swf_tag_sprite_identity_detail(swf_tag_t *tag, int id) {
+int swf_tag_sprite_get_cid_detail(swf_tag_t *tag) {
     unsigned char *data = tag->data;
-    bitstream_t *bs;
-    int sprite_id;
     if (tag->detail) {
         swf_tag_sprite_detail_t *swf_tag_sprite = (swf_tag_sprite_detail_t *) tag->detail;
-        if (swf_tag_sprite->sprite_id == id) {
-            return 0;
-        }        
-        return 1;
+        return swf_tag_sprite->sprite_id;
     }
-    bs = bitstream_open();
-    bitstream_input(bs, data, 2);
-    sprite_id = bitstream_getbytesLE(bs, 2);
-    bitstream_close(bs);
-    if (id == sprite_id) {
-        return 0;
+    if (data == NULL) {
+        fprintf(stderr, "swf_tag_sprite_get_cid_detail: data == NULL\n");
+        return -1;
+    }
+    return GetUShortLE(data); // sprite_id;
+}
+
+int swf_tag_sprite_replace_cid_detail(swf_tag_t *tag, int id) {
+    unsigned char *data = tag->data;
+    if (tag->detail) {
+        swf_tag_sprite_detail_t *swf_tag_sprite = (swf_tag_sprite_detail_t *) tag->detail;
+        swf_tag_sprite->sprite_id = id;
+    }
+    if (data) {
+        PutUShortLE(data, id);
     }        
-    return 1;
+    return 0; // always 0
 }
 
 unsigned char *

Modified: trunk/src/swf_tag_sprite.h
===================================================================
--- trunk/src/swf_tag_sprite.h	2011-03-07 05:25:00 UTC (rev 389)
+++ trunk/src/swf_tag_sprite.h	2011-03-07 14:00:14 UTC (rev 390)
@@ -19,7 +19,8 @@
 
 extern void *swf_tag_sprite_create_detail(void);
 extern int swf_tag_sprite_input_detail(swf_tag_t *tag, struct swf_object_ *swf);
-extern int swf_tag_sprite_identity_detail(swf_tag_t *tag, int id);
+extern int swf_tag_sprite_get_cid_detail(swf_tag_t *tag);
+extern int swf_tag_sprite_replace_cid_detail(swf_tag_t *tag, int id);
 extern unsigned char *swf_tag_sprite_output_detail(swf_tag_t *tag,
                                                    unsigned long *length,
                                                    struct swf_object_ *swf);



Swfed-svn メーリングリストの案内
Back to archive index