These pages are written by only Japanese.
|
Namazu for hns による簡易全文検索です。 詳細は 詳細指定/ヘルプをご参照下さい。 |
||||||||||||||||||||||||||||||||||||||||||||||||
png_color *palette = NULL; int palette_num = 0; png_get_PLTE(png_ptr, png_info, &palette, &palette_num);こんな感じに取得できて、
for (i = 0 ; i < palette_num ; i+=8 ) { printf("[%03d]", i); for (j = 0 ; (j < 8) && ((i+j) < palette_num) ; j++) { printf(" #%02x%02x%02x", palette[i+j].red, palette[i+j].green, palette[i+j].blue); } printf("\n"); }こんな感じで参照できます。
gcc png_dump.c bitstream.c -lpng以下のページでも動作を確認できます。PNG ファイルを放り込むと 内部で png_dump が動きます。
% php sample/swfdump.phps "魔理沙は大変なものを盗んでいきました.swf" > /dev/null malloc: ;_;えっと… swfed は -DMALLOC_DEBUG を付けてコンパイルすると、 free し忘れを検出する為に、malloc/free の管理テーブルを作ります。 そのサイズが足りませんでした。
% bcut game.swf 0 900000 > game-hankake.swf % php sample/swfdump.phps game-hankake.swf swf_object_input: uncompress failed by unknown reason magic=CWS version=9 file_length=1063877 rect=(0, 0)-(0, 0) (f_size=0) frame_rate=0.0 frame_count=0 XXX (3) ptr=0xb79ac008 (/home/yoya/svn/swfed/src/swf_object.c, 61)メモリリーク発見。(☆▽☆)
% php ~/svn/swfed/sample/swfdump.phps game-hankake.swf swf_object_input: uncompress failed by unknown reason magic=CWS version=9 file_length=1063877 rect=(0, 0)-(0, 0) (f_size=0) frame_rate=0.0 frame_count=0よしよし。
% bcut kuriboo4.png 0 166300 > kuriboo4-hankake.png % php sample/swfdump.phps game.swf <略> [38] tag=DefineBitsLossless2(36) length=110 image_id=30 format=3 width=62 height=18 colormap_count=16 rgba colormap exists indices exists <略> % php sample/swfreplacepngdata.phps game.swf 30 kuriboo4-hankake.png > /dev/null png_data_read_func: ! png_buff->data_offset(160789) + size(5516) <= png_buff->data_len(166301) libpng error: png_read_read_func failed アボートしましたあちゃー… でも、libpng のエラーハンドリングは setjmp 方式なんですよね…
See the discussion on libpng error handling in the Customizing Libpng section below for more information on the libpng error handling. If an error occurs, and libpng longjmp’s back to your setjmp, you will want to call png_destroy_read_struct() to free any memory. if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); fclose(fp); return (ERROR); }でもって、
If you read the file from different routines, you will need to update the jmpbuf field every time you enter a new rou- tine that will call a png_*() function.スコープがあってればイイじゃない。ってとこかしら。
png_bytepp png_image_data = NULL; <略> if (setjmp(png_jmpbuf(png_ptr))) { fprintf(stderr, "pngconv_png2lossless: libpng error jump occured\n"); png_destroy_read_struct(&png_ptr, &png_info, NULL); if (png_image_data) { for ( y = 0 ; y < png_height ; y++) { free(png_image_data[y]); } free(png_image_data); } return NULL; } <略> png_image_data = (png_bytepp) malloc(png_height * sizeof(png_bytep)); for (y=0; y < png_height; y++) { png_image_data[y] = (png_bytep) malloc(png_get_rowbytes(png_ptr, png_info)); }としてみたら、png_image_data が free 出来ず。 何でだろうと「setjmp ローカル変数」で google 様にお伺いを立てた所、
xにvolatileをつけ忘れると、こういうこと↑になります…ナルホド。最適化とレジスタの罠か… やっぱり setjmp キライ
/home/yoya/svn/swfed/src/swf_png.c: In function 'pngconv_png2lossless': /home/yoya/svn/swfed/src/swf_png.c:166: warning: passing argument 1 of 'png_destroy_read_struct' discards qualifiers from pointer target type /home/yoya/svn/swfed/src/swf_png.c:166: warning: passing argument 2 of 'png_destroy_read_struct' discards qualifiers from pointer target typevolatile つけたら怒られちゃった… ><
png_destroy_read_struct((png_structpp) &png_ptr, (png_infopp) &png_info, NULL);何だかなぁ…
/home/yoya/svn/swfed/src/swf_png.c:234: warning: argument 'image_data' might be clobbered by 'longjmp' or 'vfork'image_data は setjmp と関係ない所で使ってるのに… どうしよう…
地質学的には、両神山の多くの部分はチャート(SiO2 、水晶と同じ)という 成分で形成されている。チャートは数億年前に海底に沈んだプランクトン (放散虫)の化石から出来たもので、鉄よりも硬い(硬度7)。 4月下旬から5月中旬、山頂一帯にアカヤシオが咲く。自然林が多く残され、 紅葉が美しいことでも知られている。
両神山を形成する主な岩石は、チャートと呼ばれるもので、 角岩とも言い、火打ち石に使われたものも、この仲間だそうだ。 チャートは硬くて風化に強いので、ギザギザした尾根や絶壁を形成しやすい。 まさに、両神山の特徴ある地形は、このチャートの特性を表現しているわけだ。なるほど。
イザナギ・イザナミを祀ったのは、両神山と呼ばれるようになってからであって、 それ以前にはこの二神には何の関係もなかった。
八日見という山名の由来は、日本武尊が東夷征伐の時、 この山を8日間見給うたから、八日見山と名づけられたと伝えられる。 しかしそれはヨウカミに八日見と宛字したための伝説で、 ヨウカミという呼称はヤオガミから来たものである。 ヤオガミの「ヤ」は八の意、「オガミ」は大蛇の意で仏教でいう竜王のことである。 つまりヤオガミは8つの頭を持った竜王で、この山の古縁起に 「竜頭大明神を祭神とする」と記されてあるのと一致する。 (後略) ※出典:深田久弥『日本百名山』(1964年新潮社刊)の朝日文庫版から再録なるほど。なるほど。
\xe8\xb5\xa4\xe9\x9d\x92\xe9\xbb\x84\xe8\x89\xb2のような文字を submit すると、
赤青黄色が出力されます。
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 27944 yoya 15 0 94656 45m 13m S 41.9 4.6 11:01.74 skype問題なかったので、次はボットをつないで様子を見ます。
png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &trans_values); trans - array of transparent entries for palette (PNG_INFO_tRNS) trans_values - graylevel or color sample values of the single transparent color for non-paletted images (PNG_INFO_tRNS) num_trans - number of transparent entries (PNG_INFO_tRNS)
png_get_bKGD(png_ptr, info_ptr, &background); background - background color (PNG_VALID_bKGD) valid 16-bit red, green and blue values, regardless of color_typeとりあえず前者の tRNS を解析する事にしました。 png.h を見ると
extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values));となっているので、この型でやり取りすれば OK っぽいです。
png_color *palette = NULL; int palette_num = 0; png_bytep trans; int num_trans; png_color_16p trans_values; png_get_PLTE(png_ptr, png_info_ptr, &palette, &palette_num); printf(" palette_num=%d", palette_num); png_get_tRNS(png_ptr, png_info_ptr, &trans, &num_trans, &trans_values); printf(" num_trans=%d",num_trans);実験結果
palette_num=127 num_trans=127あってるっぽい。
gcc png_dump.c -lpng bitstream.c実行結果
(width, height)=(80,80) bpp=8 color_type=3(PALETTE) palette_num=127 num_trans=127 [000] #000000(00) #010101(20) #030202(11) #040404(3e) [004] #080706(52) #090605(2a) #140c0b(ff) #141111(72) [008] #350e0f(ff) #1b1b1b(9d) #241f1d(ff) #312020(5f)実験ページ
>>25 わかる 自分入れて4人になると、発言ターンを譲りっぱなしで発言できないwwwwww譲る気はないんだけど邪魔にならないタイミングを 探ってる間に次の話題に移ってる事が多いかな。○rz
mkdir trunk svn add trunk svn commit svn rename src trunk/src svn rename doc trunk/doc svn rename sample trunk/sample svn commit mkdir branches svn add branches svn commit
export SREPOS=https://svn.sourceforge.jp/svnroot/swfed svn copy $SREPOS/trunk $SREPOS/branches/mp3-dev \ -m "replaceMP3Data development" svn updatemp3 対応は目処が立っていないのと、 他にやる事沢山あるので実質塩漬けですが…
% cd htdocs % svn co http://svn.sourceforge.jp/svnroot/swfed/trunk/www % mv www swfed % cd swfed % vi define.php要望は随分前からあったので、対応が遅れたのはホントにごめんなさい。
checking for GLIB... no configure: error: glib-2.0, gobject-2.0 and gthread-2.0 >= 2.16 are required to build swfdecglib2-devel や gtk2-devel を yum install してもダメ。
checking for PANGO... no configure: error: pangocairo >= 1.16 is required to build swfdecCentOS だと 1.14 が入ってますね… これも外してみる…
checking for GTK... configure: error: Package requirements (gtk+-2.0 >= 2.8.0 libsoup-2.4) were not met: No package 'libsoup-2.4' foundlibsoup-2.4 を libsoup-2.2 に書き換えてと… φ。。
checking for ALSA... configure: error: Package requirements (alsa >= 1.0) were not met: No package 'alsa' found
yum install alsa-lib-devel
checking for LIBOIL... no configure: error: liboil-0.3 >= 0.3.1 is required to build swfdec
yum install liboil-devel
checking for CAIRO... no configure: error: cairo and cairo-png = 1.6.0 is required to build swfdec
Package cairo-devel - 1.2.4-5.el5.i386 is already installed.なので、
checking for GST... no configure: error: Couldn't find GStreamer 0.10.11 and gstreamer-pbutils 0.10.15.
yum install gstreamer-devel <略> Installed: gstreamer-devel.i386 0:0.10.9-3.el5 Complete!これもバージョンが古いか…
yum install gstreamer-plugins-base-develこれでもダメなので諦め。
./configure --disable-gstreamer
In file included from jpeg.c:10: /usr/include/stdlib.h:589: error: conflicting types for 'g_malloc' /usr/include/glib-2.0/glib/gmem.h:47: error: previous declaration of 'g_malloc' was hereglib-2.15 (2.16 は見つからず、かつ 2.2x はインターフェース変わってるので) を /usr/local に install してチャレンジ。
env \ GLIB_CFLAGS="-pthread -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" \ ./configure --disable-gstreamer --disable-gtk
jpeg.c: In function 'jpeg_decoder_verify_header': jpeg.c:68: error: 'G_STRFUNC' undeclared (first use in this function) jpeg.c:68: error: (Each undeclared identifier is reported only once jpeg.c:68: error: for each function it appears in.) jpeg.c: In function 'jpeg_decoder_init_decoder': jpeg.c:168: error: 'G_STRFUNC' undeclared (first use in this function)G_STRFUNC の定義は 2.12 ではあったけど、2.15 では消えてました。 でもって、2.2 でもないです。最新の 2.9.6 で発見したのでこれで…
In file included from jpeg.c:10: /usr/include/stdlib.h:589: error: conflicting types for 'g_malloc' /usr/local/include/glib-2.0/glib/gmem.h:47: error: previous declaration of 'g_malloc' was herestdlib.h より先に glib の define 置換を読み込んで malloc の名前が 変わってしまってる不具合発見。
#include <swfdec_debug.h> #include <stdlib.h> /* append by yoya */ #include <glib.h>
swfdec_as_context.c:1100: warning: implicit declaration of function 'g_ascii_strtoll' swfdec_as_context.c:1100: warning: nested extern declaration of 'g_ascii_strtoll' make[2]:むー… g_ascii_strtoll の定義は 2.12 ではあったけど 2.96 では消えてますね…
--TEST-- SWF Editor getJpegData: SWF Editor support for DefineBitsJPEG --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php echo "ok\n"; ?> --EXPECT-- okとりあえず ok だけ出力させて実行。
% make test ===================================================================== FAILED TEST SUMMARY --------------------------------------------------------------------- SWF Editor getJpegData: SWF Editor support for DefineBitsJPEG [tests/getjpeg.phpt] ========ダメらしい
---- EXPECTED OUTPUT ok ---- ACTUAL OUTPUT Warning: Module 'swfed' already loaded in Unknown on line 0 ok ---- FAILED… install 済みの so と作ったばかりの so がぶつかってるんだろうけど、 一体どうすれば…
% pkg-config --exists --print-errors "glib-2.0 >= 2.17.3 gobject-2.0 gmodule-no-export-2.0" Requested 'glib-2.0 >= 2.17.3' but version of GLib is 2.12.3って感じでチェックするので、/usr/local で頑張っても /usr に入ってる パッケージでバージョンチェックして跳ねられるんですよね。
% ls /usr/lib/pkgconfig/ ImageMagick.pc gnome-mime-data-2.0.pc pango.pc Wand.pc gnome-python-2.0.pc pangocairo.pc alsa.pc gnome-python-desktop-2.0.pc pangoft2.pc <略>こんななってて、pc ファイルの中は
% cat /usr/lib/pkgconfig/ImageMagick.pc prefix=/usr exec_prefix=/usr libdir=/usr/lib includedir=/usr/include Name: ImageMagick Description: ImageMagick - Convert, Edit, and Compose Images Version: 6.2.8 Libs: -L${libdir} -lWand -lMagick Cflags: -I${includedir}こんなです。
% /usr/local/bin/pkg-config --libs glib-2.0 -L/usr/local/lib -lglib-2.0これで、おk
% grep _VER= configure GLIB_VER=2.16 PANGO_VER=1.16 GTK_VER=2.8.0 LIBOIL_VER=0.3.1 CAIRO_VER=1.6.02.19 は開発版らしいので、とりあえず 2.18。 どうでもいいけど、GNOME のトップからダウンロードページを 探すのが大変なのですが… プレイヤーを動かす気はないので GTK は要らないかな。 あと、gstreamer も面倒なので後回し。
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure \ --disable-gtk --disable-gstreamer
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure
checking for cairo's image surface backend feature... checking for pixman... no no checking whether cairo's image surface backend feature could be enabled... no (requires pixman-1 >= 0.12.0 http://cairographics.org/releases/) configure: error: mandatory image surface backend feature could not be enabled怒られた…
env PKG_CONFIG=/usr/local/bin/pkg-config ./configureで make install
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure問題なし。順調。
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure <略> configure: WARNING: Could not find libpng in the pkg-config search path checking whether cairo's PNG functions feature could be enabled... no configure: error: recommended PNG functions feature could not be enabled/usr/local にも入れるか…
% ./configure
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure <略> configure: error: Cairo requires at least one native font backend. Please install FreeType and fontconfig and try again.ふーむw
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure <略> cairo (version 1.8.0 [release]) will be compiled with: The following surface backends: Image: yes (always builtin) Xlib: yes Xlib Xrender: yes Quartz: no (requires CoreGraphics framework) Quartz-image: no (disabled, use --enable-quartz-image to enable) XCB: no (disabled, use --enable-xcb to enable) Win32: no (requires a Win32 platform) OS2: no (disabled, use --enable-os2 to enable) PostScript: yes PDF: yes SVG: yes glitz: no (disabled, use --enable-glitz to enable) BeOS: no (disabled, use --enable-beos to enable) DirectFB: no (disabled, use --enable-directfb to enable) The following font backends: User: yes (always builtin) FreeType: yes Win32: no (requires a Win32 platform) Quartz: no (requires CoreGraphics framework) The following functions: PNG functions: yes And the following internal features: gcov support: no test surfaces: no (disabled, use --enable-test-surfaces to enable) ps testing: yes pdf testing: no (requires poppler-glib >= 0.9.2) svg testing: no (requires librsvg-2.0 >= 2.15.0)ふむ。
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure
env PKG_CONFIG=/usr/local/bin/pkg-config ./configure \ --disable-gtk --disable-gstreamer <略> checking for ALSA... configure: error: Package requirements (alsa >= 1.0) were not met: No package 'alsa' found面倒なので手抜き
# ln -s /usr/lib/pkgconfig/alsa.pc /usr/local/lib/pkgconfig/.これ、おk
% ./tools/dump ~/flash/chara.swf file: version: 6 rate : 30 fps size : 800x545 pixels objects: 1: SwfdecImage JPEG with global table 800 x 545 2: SwfdecShape 800x545 image 1 (no repeat, bilinear) 3: SwfdecFont _???? 11 characters 4: SwfdecTextField
$(PHP_EXECUTABLE) -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php -d 'extension_dir=modules/' -d `( . $(PHP_MODULES) ; echo extension=$$dlname)` tests/;なるほど。ここの extension 読み込みを削除しつつ、 so ファイルを install してから make test をすれば、OK と。
$ make test <略> ===================================================================== Running selected tests. PASS SWF Editor getJpegData: SWF Editor support for DefineBitsJPEG [tests/getjpeg.phpt] ===================================================================== Number of tests : 1 1 Tests skipped : 0 ( 0.0%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 0 ( 0.0%) ( 0.0%) Tests passed : 1 (100.0%) (100.0%) --------------------------------------------------------------------- Time taken : 0 seconds =====================================================================おk。テストパターンを書きまくろう。
-m Test for memory leaks with Valgrind.memory leak も見てくれるらしいので、install
# yum install valgrindさて…
rate = swfdec_player_get_rate(player); swfdec_player_get_default_size(player, &width, &height); printf("rate=%1.1f\n", rate); printf("width=%d height=%d\n", width, height);
% gcc swfdec_getheader.c `pkg-config --cflags --libs swfdec-0.8` \ -Wl,-rpath,/usr/local/lib % a.out ~/flash/chara.swf rate=30.0 width=800 height=545あっさり、frame_rate と rect が取れました。
% gcc png2rgb.c -lpng bitstream.c % ./aout test0.png > test0.rgb % rgb2gif -1 -s 512 382 test_0.rgb > test_0-2.gif