svnno****@sourc*****
svnno****@sourc*****
2011年 3月 8日 (火) 22:16:19 JST
Revision: 400 http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=400 Author: yoya Date: 2011-03-08 22:16:19 +0900 (Tue, 08 Mar 2011) Log Message: ----------- - cxformwithalpha の処理ルーチンを追加 - swf_tag_place で PlaceObject2 の時の処理を cxformwithalpha を使うよう修正 Modified Paths: -------------- trunk/src/config.m4 trunk/src/swf_tag_place.c trunk/src/swf_tag_place.h Added Paths: ----------- trunk/src/swf_cxformwithalpha.c trunk/src/swf_cxformwithalpha.h -------------- next part -------------- Modified: trunk/src/config.m4 =================================================================== --- trunk/src/config.m4 2011-03-08 01:22:06 UTC (rev 399) +++ trunk/src/config.m4 2011-03-08 13:16:19 UTC (rev 400) @@ -74,6 +74,6 @@ swf_shape_record_edge.c swf_gradient.c swf_gradient_record.c \ swf_tag_jpeg.c swf_tag_edit.c swf_tag_action.c swf_tag_lossless.c \ swf_tag_sound.c swf_tag_sprite.c swf_tag_shape.c y_keyvalue.c \ - swf_tag_place.c swf_cxform.c trans_table.c \ + swf_tag_place.c swf_cxform.c swf_cxformwithalpha.c trans_table.c \ , $ext_shared) fi Added: trunk/src/swf_cxformwithalpha.c =================================================================== --- trunk/src/swf_cxformwithalpha.c (rev 0) +++ trunk/src/swf_cxformwithalpha.c 2011-03-08 13:16:19 UTC (rev 400) @@ -0,0 +1,75 @@ +#include <stdio.h> +#include "bitstream.h" +#include "swf_cxformwithalpha.h" + +int +swf_cxformwithalpha_parse(bitstream_t *bs, swf_cxformwithalpha_t *cx) { + int ret, nbits; + bitstream_align(bs); + cx->has_add_terms = bitstream_getbit(bs); + cx->has_mult_terms = bitstream_getbit(bs); + nbits = bitstream_getbits(bs, 4); + cx->nbits = nbits; + if (cx->has_mult_terms) { + cx->red_mult_term = bitstream_getbits(bs, nbits); + cx->green_mult_term = bitstream_getbits(bs, nbits); + cx->blue_mult_term = bitstream_getbits(bs, nbits); + ret = bitstream_getbits(bs, nbits); + if (ret == -1) { + return 1; + } + cx->alpha_mult_term = ret; + } + if (cx->has_add_terms) { + cx->red_add_term = bitstream_getbits(bs, nbits); + cx->green_add_term = bitstream_getbits(bs, nbits); + cx->blue_add_term = bitstream_getbits(bs, nbits); + ret = bitstream_getbits(bs, nbits); + if (ret == -1) { + return 1; + } + cx->alpha_add_term = ret; + } + return 0; +} + +int +swf_cxformwithalpha_build(bitstream_t *bs, swf_cxformwithalpha_t *cx) { + int nbits; + bitstream_align(bs); + bitstream_putbit(bs, cx->has_add_terms); + bitstream_putbit(bs, cx->has_mult_terms); + nbits = cx->nbits; + bitstream_putbits(bs, nbits, 4); + if (cx->has_mult_terms) { + bitstream_putbits(bs, cx->red_mult_term, nbits); + bitstream_putbits(bs, cx->green_mult_term, nbits); + bitstream_putbits(bs, cx->blue_mult_term, nbits); + bitstream_putbits(bs, cx->alpha_mult_term, nbits); + } + if (cx->has_add_terms) { + bitstream_putbits(bs, cx->red_add_term, nbits); + bitstream_putbits(bs, cx->green_add_term, nbits); + bitstream_putbits(bs, cx->blue_add_term, nbits); + bitstream_putbits(bs, cx->alpha_add_term, nbits); + } + return 0; +} + +int +swf_cxformwithalpha_print(swf_cxformwithalpha_t *cx, int indent_depth) { + print_indent(indent_depth); + printf("CXFORMWITHALPHA:"); + if (cx->has_mult_terms) { + printf(" MultTerm:%02x%02x%02x", + cx->red_mult_term, cx->green_mult_term, cx->blue_mult_term, + cx->alpha_mult_term); + } + if (cx->has_add_terms) { + printf(" AddTerm:%02x%02x%02x(%02x)", + cx->red_add_term, cx->green_add_term, cx->blue_add_term, + cx->alpha_add_term); + } + printf("\n"); + return 0; +} Added: trunk/src/swf_cxformwithalpha.h =================================================================== --- trunk/src/swf_cxformwithalpha.h (rev 0) +++ trunk/src/swf_cxformwithalpha.h 2011-03-08 13:16:19 UTC (rev 400) @@ -0,0 +1,31 @@ +/* + +----------------------------------------------------------------------+ + | Author: yoya****@awm***** | + +----------------------------------------------------------------------+ +*/ + +#ifndef __SWF_CXFORMWITHALPHA_H__ +#define __SWF_CXFORMWITHALPHA_H__ + +typedef struct swf_cxformwithalpha_ { + unsigned char has_add_terms; + unsigned char has_mult_terms; + unsigned char nbits; + // multiply value + unsigned int red_mult_term; + unsigned int green_mult_term; + unsigned int blue_mult_term; + unsigned int alpha_mult_term; + // addition value + unsigned int red_add_term; + unsigned int green_add_term; + unsigned int blue_add_term; + unsigned int alpha_add_term; +} swf_cxformwithalpha_t; + + +extern int swf_cxformwithalpha_parse(bitstream_t *bs, swf_cxformwithalpha_t *color); +extern int swf_cxformwithalpha_build(bitstream_t *bs, swf_cxformwithalpha_t *color); +extern int swf_cxformwithalpha_print(swf_cxformwithalpha_t *color, int indent_depth); + +#endif /* __SWF_CXFORMWITHALPHA_H__ */ Modified: trunk/src/swf_tag_place.c =================================================================== --- trunk/src/swf_tag_place.c 2011-03-08 01:22:06 UTC (rev 399) +++ trunk/src/swf_tag_place.c 2011-03-08 13:16:19 UTC (rev 400) @@ -74,7 +74,7 @@ swf_tag_place->flag_has_color_transform = bitstream_getbit(bs); swf_tag_place->flag_has_matrix = bitstream_getbit(bs); swf_tag_place->flag_has_character = bitstream_getbit(bs); - swf_tag_place->flag_has_movie = bitstream_getbit(bs); + swf_tag_place->flag_has_move = bitstream_getbit(bs); swf_tag_place->depth = bitstream_getbytesLE(bs, 2); if (swf_tag_place->flag_has_character) { swf_tag_place->character_id = bitstream_getbytesLE(bs, 2); @@ -90,7 +90,7 @@ } } if (swf_tag_place->flag_has_color_transform) { - ret = swf_cxform_parse(bs, &(swf_tag_place->color_transform)); + ret = swf_cxformwithalpha_parse(bs, &(swf_tag_place->color_transform_with_alpha)); if (ret) { fprintf(stderr, "ERROR: swf_tag_place_input_detail: swf_tag_place->color_transform parse failed. character_id=%d\n", swf_tag_place->character_id); bitstream_close(bs); @@ -151,8 +151,10 @@ bitstream_putbit(bs, swf_tag_place->flag_has_color_transform); bitstream_putbit(bs, swf_tag_place->flag_has_matrix); bitstream_putbit(bs, swf_tag_place->flag_has_character); - bitstream_putbit(bs, swf_tag_place->flag_has_movie); + bitstream_putbit(bs, swf_tag_place->flag_has_move); + bitstream_putbytesLE(bs, swf_tag_place->depth, 2); + if (swf_tag_place->flag_has_character) { bitstream_putbytesLE(bs, swf_tag_place->character_id, 2); } @@ -165,7 +167,7 @@ } } if (swf_tag_place->flag_has_color_transform) { - ret = swf_cxform_build(bs, &(swf_tag_place->color_transform)); + ret = swf_cxformwithalpha_build(bs, &(swf_tag_place->color_transform_with_alpha)); if (ret) { fprintf(stderr, "ERROR: swf_tag_place_output_detail: swf_tag_place->color_transform build failed. character_id=%d\n", swf_tag_place->character_id); bitstream_close(bs); @@ -203,7 +205,7 @@ swf_matrix_print(&(swf_tag_place->matrix), indent_depth); swf_cxform_print(&(swf_tag_place->color_transform), indent_depth); } else if (tag->tag == 26) { // PlaceObject2 - printf("(clipact,clipdepth,name,ratio,coltrans,mat,cid,movie)=(%d,%d,%d,%d,%d,%d,%d,%d)\n", + printf("(clipact,clipdepth,name,ratio,coltrans,mat,cid,move)=(%d,%d,%d,%d,%d,%d,%d,%d)\n", swf_tag_place->flag_has_clip_action, swf_tag_place->flag_has_clip_depth, swf_tag_place->flag_has_name, @@ -211,7 +213,7 @@ swf_tag_place->flag_has_color_transform, swf_tag_place->flag_has_matrix, swf_tag_place->flag_has_character, - swf_tag_place->flag_has_movie); + swf_tag_place->flag_has_move); if (swf_tag_place->flag_has_character) { print_indent(indent_depth); printf("character_id=%d\n", swf_tag_place->character_id); @@ -220,7 +222,7 @@ swf_matrix_print(&(swf_tag_place->matrix), indent_depth); } if (swf_tag_place->flag_has_color_transform) { - swf_cxform_print(&(swf_tag_place->color_transform), indent_depth); + swf_cxformwithalpha_print(&(swf_tag_place->color_transform_with_alpha), indent_depth); } if (swf_tag_place->flag_has_ratio) { print_indent(indent_depth); Modified: trunk/src/swf_tag_place.h =================================================================== --- trunk/src/swf_tag_place.h 2011-03-08 01:22:06 UTC (rev 399) +++ trunk/src/swf_tag_place.h 2011-03-08 13:16:19 UTC (rev 400) @@ -9,10 +9,11 @@ #include "swf_matrix.h" #include "swf_cxform.h" +#include "swf_cxformwithalpha.h" #include "swf_tag.h" typedef struct swf_tag_place_detail_ { - int character_id; // Shape2 optional. + int character_id; // optional if PlaceObject2 int flag_has_clip_action; int flag_has_clip_depth; int flag_has_name; @@ -20,13 +21,14 @@ int flag_has_color_transform; int flag_has_matrix; int flag_has_character; - int flag_has_movie; + int flag_has_move; int depth; swf_matrix_t matrix; - swf_cxform_t color_transform; - int ratio; - char *name; - int clip_depth; + swf_cxform_t color_transform; // PlaceObject + swf_cxformwithalpha_t color_transform_with_alpha; // PlaceObject2 + int ratio; // PlaceObject2 + char *name; // PlaceObject2 + int clip_depth; // PlaceObject2 } swf_tag_place_detail_t; extern swf_tag_detail_handler_t *swf_tag_place_detail_handler(void);