[Swfed-svn] swfed-svn [73] create_detail を create_detail (=calloc) と input_detail (= parse) に分解

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 14日 (火) 23:20:05 JST


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

Log Message:
-----------
create_detail を create_detail(=calloc)と input_detail(=parse)に分解

Modified Paths:
--------------
    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_sound.c
    trunk/src/swf_tag_sound.h
    trunk/src/swfed.c


-------------- next part --------------
Modified: trunk/src/swf_object.c
===================================================================
--- trunk/src/swf_object.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_object.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -402,7 +402,7 @@
     if ((tag->tag != 12) &&  (tag->tag != 59)) { //  DoAction, DoInitAction
         return NULL;
     }
-    swf_tag_create_detail(tag, swf);
+    swf_tag_create_input_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_tag.c
===================================================================
--- trunk/src/swf_tag.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -215,7 +215,7 @@
     printf("\n");
     if (tag_info && tag_info->detail_handler) {
         if (tag->detail == NULL) {
-            swf_tag_create_detail(tag, swf);
+            swf_tag_create_input_detail(tag, swf);
         }
         swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
         if (detail_handler->print) {
@@ -224,25 +224,31 @@
     }
 }
 
-int swf_tag_create_detail(swf_tag_t *tag, struct swf_object_ *swf) {
+int swf_tag_create_input_detail(swf_tag_t *tag, struct swf_object_ *swf) {
     swf_tag_info_t *tag_info;
     if (tag == NULL) {
-        fprintf(stderr, "swf_tag_create_detail: tag == NULL\n");
+        fprintf(stderr, "swf_tag_create_input_detail: tag == NULL\n");
         return 1;
     }
     tag_info = get_swf_tag_info(tag->tag);
     if (tag_info && tag_info->detail_handler) {
+        int result;
         swf_tag_detail_handler_t * detail_handler = tag_info->detail_handler();
         if (detail_handler->create == NULL) {
             fprintf(stderr, "detail_handler->create == NULL (tag=%d)\n",
                     tag->tag);
             return 1;
         }
-        tag->detail = detail_handler->create(tag->data, tag->length, tag, swf);
+        tag->detail = detail_handler->create();
         if (tag->detail == NULL) {
             fprintf(stderr, "can't create tag detail (tag=%d)\n", tag->tag);
             return 1;
         }
+        result = detail_handler->input(tag->data, tag->length, tag, swf);
+        if (result) {
+            fprintf(stderr, "can't input tag detail (result=%d)\n", result);
+            return 1;
+        }
     }
     return 1;
 }
@@ -260,7 +266,7 @@
         return NULL;
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_get_jpeg_data: Can't create tag\n");
@@ -297,7 +303,7 @@
         }
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_get_alpha_data: Can't create tag\n");
@@ -331,7 +337,7 @@
         }
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_replace_jpeg_data: Can't create tag\n");
@@ -361,7 +367,7 @@
         return NULL;
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_get_png_data: Can't create tag\n");
@@ -393,7 +399,7 @@
         }
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_replace_png_data: Can't create tag\n");
@@ -426,7 +432,7 @@
         return NULL;
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_get_sound_data: Can't create tag detail\n");
@@ -458,7 +464,7 @@
         }
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, NULL);
+        swf_tag_create_input_detail(tag, NULL);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_replace_melog_data: Can't create tag\n");
@@ -486,7 +492,7 @@
         return NULL;
     }
     if (! tag->detail) {
-        swf_tag_create_detail(tag, swf);
+        swf_tag_create_input_detail(tag, swf);
     }
     if (! tag->detail) {
         fprintf(stderr, "Can't create tag\n");
@@ -512,7 +518,7 @@
     }
     
     if (! tag->detail) {
-        swf_tag_create_detail(tag, swf);
+        swf_tag_create_input_detail(tag, swf);
     }
     if (! tag->detail) {
         fprintf(stderr, "swf_tag_replace_edit_string: Can't create tag\n");

Modified: trunk/src/swf_tag.h
===================================================================
--- trunk/src/swf_tag.h	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag.h	2008-10-14 14:20:05 UTC (rev 73)
@@ -22,7 +22,8 @@
 } swf_tag_t;
 
 typedef struct swf_tag_detail_handler_ {
-    void          * (*create)   (unsigned char *data,
+    void          * (*create)   (void);
+    int             (*input)    (unsigned char *data,
                                  unsigned long length,
                                  swf_tag_t *tag,
                                  struct swf_object_ *swf);

Modified: trunk/src/swf_tag_action.c
===================================================================
--- trunk/src/swf_tag_action.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_action.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -15,6 +15,7 @@
 swf_tag_detail_handler_t *
 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.output   = swf_tag_action_output_detail;
     action_detail_handler.print    = swf_tag_action_print_detail;
@@ -23,19 +24,33 @@
 }
 
 void *
-swf_tag_action_create_detail(unsigned char *data,
-                             unsigned long length,
-                             swf_tag_t *tag,
-                             struct swf_object_ *swf) {
+swf_tag_action_create_detail(void) {
     swf_tag_action_detail_t *swf_tag_action;
-    bitstream_t *bs;
-    unsigned long pos, len;
-    (void) swf;
     swf_tag_action = calloc(sizeof(*swf_tag_action), 1);
     if (swf_tag_action == NULL) {
         fprintf(stderr, "ERROR: swf_tag_action_create_detail: can't calloc\n");
         return NULL;
     }
+    swf_tag_action->action_sprite = 0;
+    swf_tag_action->action_record = NULL;
+    swf_tag_action->action_record_len = 0;
+    return swf_tag_action;
+}
+
+int
+swf_tag_action_input_detail(unsigned char *data,
+                            unsigned long length,
+                            swf_tag_t *tag,
+                            struct swf_object_ *swf) {
+    swf_tag_action_detail_t *swf_tag_action;
+    bitstream_t *bs;
+    unsigned long pos, len;
+    (void) swf;
+    swf_tag_action = tag->detail;
+    if (swf_tag_action == NULL) {
+        fprintf(stderr, "ERROR: swf_tag_action_create_detail: swf_tag_action == NULL\n");
+        return 1;
+    }
     bs = bitstream_open();
     bitstream_input(bs, data, length);
 
@@ -49,7 +64,7 @@
     swf_tag_action->action_record = bitstream_output_sub(bs, pos, len);
     swf_tag_action->action_record_len = len;
     bitstream_close(bs);
-    return (void *) swf_tag_action;
+    return 0;
 }
 
 int swf_tag_action_identity_detail(unsigned char *data, int id,

Modified: trunk/src/swf_tag_action.h
===================================================================
--- trunk/src/swf_tag_action.h	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_action.h	2008-10-14 14:20:05 UTC (rev 73)
@@ -18,10 +18,11 @@
 
 extern swf_tag_detail_handler_t *swf_tag_action_detail_handler(void);
 
-extern void *swf_tag_action_create_detail(unsigned char *data,
-                                          unsigned long length,
-                                          swf_tag_t *tag,
-                                          struct swf_object_ *swf);
+extern void *swf_tag_action_create_detail(void);
+extern int swf_tag_action_input_detail(unsigned char *data,
+                                        unsigned long length,
+                                        swf_tag_t *tag,
+                                        struct swf_object_ *swf);
 extern int swf_tag_action_identity_detail(unsigned char *data, int id,
                                           swf_tag_t *tag);
 extern unsigned char *swf_tag_action_output_detail(void *detail,

Modified: trunk/src/swf_tag_edit.c
===================================================================
--- trunk/src/swf_tag_edit.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_edit.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -16,6 +16,7 @@
 swf_tag_detail_handler_t *
 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.output   = swf_tag_edit_output_detail;
     edit_detail_handler.print    = swf_tag_edit_print_detail;
@@ -23,17 +24,29 @@
     return &edit_detail_handler;
 }
 
+
 void *
-swf_tag_edit_create_detail(unsigned char *data, unsigned long length,
+swf_tag_edit_create_detail(void) {
+    swf_tag_edit_detail_t *swf_tag_edit;
+    swf_tag_edit = calloc(sizeof(*swf_tag_edit), 1);
+    if (swf_tag_edit == NULL) {
+        fprintf(stderr, "ERROR: swf_tag_edit_create_detail: can't calloc\n");
+        return NULL;
+    }
+    return swf_tag_edit;
+}
+
+int
+swf_tag_edit_input_detail(unsigned char *data, unsigned long length,
                            swf_tag_t *tag,
                            struct swf_object_ *swf) {
     swf_tag_edit_detail_t *swf_tag_edit;
     bitstream_t *bs;
     (void) tag;
-    swf_tag_edit = calloc(sizeof(*swf_tag_edit), 1);
+    swf_tag_edit = tag->detail;
     if (swf_tag_edit == NULL) {
-        fprintf(stderr, "ERROR: swf_tag_edit_create_detail: can't calloc\n");
-        return NULL;
+        fprintf(stderr, "ERROR: swf_tag_edit_input_detail: swf_tag_edit == NULL\n");
+        return 1;
     }
     bs = bitstream_open();
     bitstream_input(bs, data, length);
@@ -86,7 +99,7 @@
     }
     
     bitstream_close(bs);
-    return (void *) swf_tag_edit;
+    return 0;
 }
 
 int swf_tag_edit_identity_detail(unsigned char *data, int id,

Modified: trunk/src/swf_tag_edit.h
===================================================================
--- trunk/src/swf_tag_edit.h	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_edit.h	2008-10-14 14:20:05 UTC (rev 73)
@@ -49,10 +49,11 @@
 
 extern swf_tag_detail_handler_t *swf_tag_edit_detail_handler(void);
 
-extern void *swf_tag_edit_create_detail(unsigned char *data,
-                                        unsigned long length,
-                                        swf_tag_t *tag,
-                                        struct swf_object_ *swf);
+extern void *swf_tag_edit_create_detail(void);
+extern int swf_tag_edit_input_detail(unsigned char *data,
+                                     unsigned long length,
+                                     swf_tag_t *tag,
+                                     struct swf_object_ *swf);
 extern int swf_tag_edit_identity_detail(unsigned char *data, int id,
                                         swf_tag_t *tag);
 extern unsigned char *swf_tag_edit_output_detail(void *detail,

Modified: trunk/src/swf_tag_jpeg.c
===================================================================
--- trunk/src/swf_tag_jpeg.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_jpeg.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -19,6 +19,7 @@
 
 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.output   = swf_tag_jpeg_output_detail;
     jpeg_detail_handler.print    = swf_tag_jpeg_print_detail;
@@ -27,7 +28,8 @@
 }
 
 swf_tag_detail_handler_t *swf_tag_jpeg3_detail_handler(void) {
-    jpeg_detail_handler.create   = swf_tag_jpeg3_create_detail;
+    jpeg_detail_handler.create   = swf_tag_jpeg_create_detail;
+    jpeg_detail_handler.input    = swf_tag_jpeg3_input_detail;
     jpeg_detail_handler.identity = swf_tag_jpeg_identity_detail;
     jpeg_detail_handler.output   = swf_tag_jpeg3_output_detail;
     jpeg_detail_handler.print    = swf_tag_jpeg_print_detail;
@@ -36,17 +38,34 @@
 }
 
 void *
-swf_tag_jpeg_create_detail(unsigned char *data, unsigned long length,
+swf_tag_jpeg_create_detail(void) {
+    swf_tag_jpeg_detail_t *swf_tag_jpeg;
+    bitstream_t *bs;
+    swf_tag_jpeg = calloc(sizeof(*swf_tag_jpeg), 1);
+    if (swf_tag_jpeg == NULL) {
+        fprintf(stderr, "ERROR: swf_tag_jpeg_create_detail: can't calloc\n");
+        return NULL;
+    }
+    swf_tag_jpeg->image_id = -1;
+    swf_tag_jpeg->jpeg_data = NULL;
+    swf_tag_jpeg->jpeg_data_len = 0;
+    swf_tag_jpeg->alpha_data = NULL;
+    swf_tag_jpeg->alpha_data_len = 0;
+    return (void *) swf_tag_jpeg;
+}
+
+int
+swf_tag_jpeg_input_detail(unsigned char *data, unsigned long length,
                            swf_tag_t *tag,
                            struct swf_object_ *swf) {
     swf_tag_jpeg_detail_t *swf_tag_jpeg;
     bitstream_t *bs;
     (void) tag;
     (void) swf;
-    swf_tag_jpeg = calloc(sizeof(*swf_tag_jpeg), 1);
+    swf_tag_jpeg = tag->detail;
     if (swf_tag_jpeg == NULL) {
-        fprintf(stderr, "ERROR: swf_tag_jpeg_create_detail: can't calloc\n");
-        return NULL;
+        fprintf(stderr, "ERROR: swf_tag_jpeg_input_detail: swf_tag_jpeg == NULL\n");
+        return 1;
     }
     bs = bitstream_open();
     bitstream_input(bs, data, length);
@@ -56,14 +75,14 @@
     swf_tag_jpeg->alpha_data = NULL;
     swf_tag_jpeg->alpha_data_len = 0;
     bitstream_close(bs);
-    return (void *) swf_tag_jpeg;
+    return 0;
 }
 
-void *
-swf_tag_jpeg3_create_detail(unsigned char *data,
-                            unsigned long length,
-                            swf_tag_t *tag,
-                            struct swf_object_ *swf) {
+int
+swf_tag_jpeg3_input_detail(unsigned char *data,
+                           unsigned long length,
+                           swf_tag_t *tag,
+                           struct swf_object_ *swf) {
     swf_tag_jpeg_detail_t *swf_tag_jpeg;
     unsigned long offset_to_alpha;
     bitstream_t *bs;
@@ -73,10 +92,10 @@
     int result;
     (void) tag;
     (void) swf;
-    swf_tag_jpeg = calloc(sizeof(*swf_tag_jpeg), 1);
+    swf_tag_jpeg = tag->detail;
     if (swf_tag_jpeg == NULL) {
-        fprintf(stderr, "swf_tag_jpeg_create_detail: can't calloc\n");
-        return NULL;
+        fprintf(stderr, "ERROR: swf_tag_jpeg3_input_detail: swf_tag_jpeg == NULL\n");
+        return 1;
     }
     bs = bitstream_open();
     bitstream_input(bs, data, length);
@@ -88,19 +107,18 @@
         free(swf_tag_jpeg);
         bitstream_close(bs);
         fprintf(stderr, "swf_tag_jpeg3_create_detail: swf_tag_jpeg->jpeg_data\n");
-        return NULL;
+        return 1;
     }
     
     swf_tag_jpeg->jpeg_data_len = offset_to_alpha;
     offset = 2 + 4 + offset_to_alpha;
     alpha_data_len = length - offset;
     origsize = 256 * alpha_data_len;
-    new_buff = malloc(origsize);
+    new_buff = malloc(origsize); // enough size
     old_buff_ref = bitstream_buffer(bs, offset);
     result = uncompress(new_buff, &origsize, old_buff_ref, alpha_data_len);
     if (result == Z_OK) {
         swf_tag_jpeg->alpha_data = realloc(new_buff, origsize);
-        swf_tag_jpeg->alpha_data = new_buff;
         swf_tag_jpeg->alpha_data_len = origsize;
     } else {
         if (result == Z_MEM_ERROR) {
@@ -115,7 +133,8 @@
         free(new_buff);
     }
     bitstream_close(bs);
-    return (void *) swf_tag_jpeg;
+    (void *) swf_tag_jpeg;
+    return 0;
 }
 
 int
@@ -281,7 +300,7 @@
                                unsigned long jpeg_data_len,
                                unsigned char *alpha_data,
                                unsigned long alpha_data_len,
-                                          swf_tag_t *tag) {
+                               swf_tag_t *tag) {
     swf_tag_jpeg_detail_t *swf_tag_jpeg = (swf_tag_jpeg_detail_t *) detail;
     if (detail == NULL) {
         fprintf(stderr, "swf_tag_jpeg_replace_jpeg_data: detail == NULL\n");

Modified: trunk/src/swf_tag_jpeg.h
===================================================================
--- trunk/src/swf_tag_jpeg.h	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_jpeg.h	2008-10-14 14:20:05 UTC (rev 73)
@@ -21,10 +21,16 @@
 extern swf_tag_detail_handler_t *swf_tag_jpeg_detail_handler(void);
 extern swf_tag_detail_handler_t *swf_tag_jpeg3_detail_handler(void);
 
-extern void *swf_tag_jpeg_create_detail(unsigned char *data,
-                                        unsigned long length,
-                                        swf_tag_t *tag,
-                                        struct swf_object_ *swf);
+extern void *swf_tag_jpeg_create_detail(void);
+
+extern int swf_tag_jpeg_input_detail(unsigned char *data,
+                                     unsigned long length,
+                                     swf_tag_t *tag,
+                                     struct swf_object_ *swf);
+extern int swf_tag_jpeg3_input_detail(unsigned char *data,
+                                      unsigned long length,
+                                      swf_tag_t *tag,
+                                      struct swf_object_ *swf);
 extern int swf_tag_jpeg_identity_detail(unsigned char *data, int id,
                                         swf_tag_t *tag);
 extern void *swf_tag_jpeg3_create_detail(unsigned char *data,

Modified: trunk/src/swf_tag_lossless.c
===================================================================
--- trunk/src/swf_tag_lossless.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_lossless.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -17,6 +17,7 @@
 
 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.output   = swf_tag_lossless_output_detail;
     lossless_detail_handler.print    = swf_tag_lossless_print_detail;
@@ -25,7 +26,18 @@
 }
 
 void *
-swf_tag_lossless_create_detail(unsigned char *data,
+swf_tag_lossless_create_detail(void) {
+    swf_tag_lossless_detail_t *swf_tag_lossless;
+    swf_tag_lossless = calloc(sizeof(*swf_tag_lossless), 1);
+    if (swf_tag_lossless == NULL) {
+        fprintf(stderr, "swf_tag_lossless_create_detail: can't calloc swf_tag_lossless\n");
+        return NULL;
+    }
+    return swf_tag_lossless;
+}
+
+int
+swf_tag_lossless_input_detail(unsigned char *data,
                                unsigned long length,
                                swf_tag_t *tag,
                                struct swf_object_ *swf) {
@@ -36,12 +48,12 @@
     unsigned char *tmp_buff, *old_buff_ref;
     unsigned long origsize, old_size, offset;
     int result;
-    
-    swf_tag_lossless = calloc(sizeof(*swf_tag_lossless), 1);
+    swf_tag_lossless = tag->detail;
     if (swf_tag_lossless == NULL) {
-        fprintf(stderr, "swf_tag_lossless_create_detail: can't calloc swf_tag_lossless\n");
-        return NULL;
+        fprintf(stderr, "swf_tag_lossless_input_detail: swf_tag_lossless == NULL\n");
+        return 1;
     }
+
     bs = bitstream_open();
     bitstream_input(bs, data, length);
     swf_tag_lossless->image_id = bitstream_getbytesLE(bs, 2);
@@ -76,7 +88,7 @@
             }
             free(tmp_buff);
             bitstream_close(bs);
-            return NULL;
+            return 1;
         }
         if (indices_len != origsize - bytes_per_color * swf_tag_lossless->colormap_count) {
             fprintf(stderr, "swf_tag_lossless_create_detail: indices_len(%lu) != origsize(%lu) - %d * swf_tag_lossless->colormap_count(%d) at line(%d)\n",
@@ -84,7 +96,7 @@
                     swf_tag_lossless->colormap_count, __LINE__);
             free(tmp_buff);
             bitstream_close(bs);
-            return NULL;
+            return 1;
         }
         bs2 = bitstream_open();
         bitstream_input(bs2, tmp_buff, origsize);
@@ -128,7 +140,7 @@
             }
             free(tmp_buff);
             bitstream_close(bs);
-            return NULL;
+            return 1;
         }
         bs2 = bitstream_open();
         bitstream_input(bs2, tmp_buff, origsize);
@@ -149,7 +161,8 @@
         free(tmp_buff);
     }
     bitstream_close(bs);
-    return (void *) swf_tag_lossless;
+    return 0;
+
 }
 
 int

Modified: trunk/src/swf_tag_lossless.h
===================================================================
--- trunk/src/swf_tag_lossless.h	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_lossless.h	2008-10-14 14:20:05 UTC (rev 73)
@@ -29,24 +29,17 @@
 
 extern swf_tag_detail_handler_t *swf_tag_lossless_detail_handler(void);
 
-extern void *swf_tag_lossless_create_detail(unsigned char *data,
-                                            unsigned long length,
-                                            swf_tag_t *tag,
-                                            struct swf_object_ *swf);
-extern void *swf_tag_lossless2_create_detail(unsigned char *data,
-                                             unsigned long length,
-                                             swf_tag_t *tag,
-                                             struct swf_object_ *swf);
+extern void *swf_tag_lossless_create_detail(void);
+extern int swf_tag_lossless_input_detail(unsigned char *data,
+                                         unsigned long length,
+                                         swf_tag_t *tag,
+                                         struct swf_object_ *swf);
 extern int swf_tag_lossless_identity_detail(unsigned char *data, int id,
                                             swf_tag_t *tag);
 extern unsigned char *swf_tag_lossless_output_detail(void *detail,
                                                      unsigned long *length,
                                                      swf_tag_t *tag,
                                                      struct swf_object_ *swf);
-extern unsigned char *swf_tag_lossless2_output_detail(void *detail,
-                                                      unsigned long *length,
-                                                      swf_tag_t *tag,
-                                                      struct swf_object_ *swf);
 extern void swf_tag_lossless_print_detail(void *detail,
                                           swf_tag_t *tag,
                                           struct swf_object_ *swf);

Modified: trunk/src/swf_tag_sound.c
===================================================================
--- trunk/src/swf_tag_sound.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_sound.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -15,6 +15,7 @@
 swf_tag_detail_handler_t *
 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.output   = swf_tag_sound_output_detail;
     sound_detail_handler.print    = swf_tag_sound_print_detail;
@@ -23,19 +24,29 @@
 }
 
 void *
-swf_tag_sound_create_detail(unsigned char *data, unsigned long length,
-                           swf_tag_t *tag,
-                           struct swf_object_ *swf) {
+swf_tag_sound_create_detail(void) {
     swf_tag_sound_detail_t *swf_tag_sound;
+    swf_tag_sound = calloc(sizeof(*swf_tag_sound), 1);
+    if (swf_tag_sound == NULL) {
+        fprintf(stderr, "ERROR: swf_tag_sound_create_detail: can't calloc\n");
+        return NULL;
+    }
+}
+
+int
+swf_tag_sound_input_detail(unsigned char *data, unsigned long length,
+                            swf_tag_t *tag,
+                            struct swf_object_ *swf) {
+    swf_tag_sound_detail_t *swf_tag_sound;
     bitstream_t *bs;
     unsigned long sound_data_len;
     unsigned char *sound_data_ref;
     (void) tag;
     (void) swf;
-    swf_tag_sound = calloc(sizeof(*swf_tag_sound), 1);
+    swf_tag_sound = tag->detail;
     if (swf_tag_sound == NULL) {
-        fprintf(stderr, "ERROR: swf_tag_sound_create_detail: can't calloc\n");
-        return NULL;
+        fprintf(stderr, "ERROR: swf_tag_sound_input_detail: swf_tag_sound == NULL\n");
+        return 1;
     }
     bs = bitstream_open();
     bitstream_input(bs, data, length);
@@ -51,13 +62,13 @@
         fprintf(stderr, "swf_tag_sound_create_detail: swf_tag_sound->sound_data == NULL at line(%d): sound_data_len=%lu\n",
                 __LINE__, sound_data_len);
         bitstream_close(bs);
-        return NULL;
+        return 1;
     }
     sound_data_ref = bitstream_buffer(bs, bitstream_getbytepos(bs));
     memcpy(swf_tag_sound->sound_data, sound_data_ref, sound_data_len);
     swf_tag_sound->sound_data_len = sound_data_len;
     bitstream_close(bs);
-    return (void *) swf_tag_sound;
+    return 0;
 }
 
 int

Modified: trunk/src/swf_tag_sound.h
===================================================================
--- trunk/src/swf_tag_sound.h	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swf_tag_sound.h	2008-10-14 14:20:05 UTC (rev 73)
@@ -22,10 +22,11 @@
 
 extern swf_tag_detail_handler_t *swf_tag_sound_detail_handler(void);
 
-extern void *swf_tag_sound_create_detail(unsigned char *data,
-                                         unsigned long length,
-                                         swf_tag_t *tag,
-                                         struct swf_object_ *swf);
+extern void *swf_tag_sound_create_detail(void);
+extern int swf_tag_sound_input_detail(unsigned char *data,
+                                      unsigned long length,
+                                      swf_tag_t *tag,
+                                      struct swf_object_ *swf);
 extern int swf_tag_sound_identity_detail(unsigned char *data, int id,
                                          swf_tag_t *tag);
 extern unsigned char *swf_tag_sound_output_detail(void *detail,

Modified: trunk/src/swfed.c
===================================================================
--- trunk/src/swfed.c	2008-10-14 13:57:11 UTC (rev 72)
+++ trunk/src/swfed.c	2008-10-14 14:20:05 UTC (rev 73)
@@ -371,7 +371,7 @@
     if ((tag_info == NULL) || (tag_info->detail_handler == NULL)) {
         RETURN_FALSE;
     }
-    swf_tag_create_detail(tag, swf);
+    swf_tag_create_input_detail(tag, swf);
     switch (tag->tag) {
         swf_tag_jpeg_detail_t     *tag_jpeg;
         swf_tag_lossless_detail_t *tag_lossless;


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