2009年3月26日 星期四
2009年3月23日 星期一
Java初探
好幾年前就想要用Java,只是工作上一直沒機會用上.
最近想要用Java applet加強web server的功能就著手來study囉
1.Java 既是編譯也是直譯式語言
編譯式語言的優點 : 較有效率及執行速度快
直譯式語言的優點 : 跨平台的可移植性佳
Java Source Code -> [ Compile ] -> Java Instruction Binary
Java Instruction Binary -> [ Interpreter ] -> Running on Java Virtual Machine
2.Java沒有指標 (pointer)
Java使用參考(reference)來達到指標的功能.
參考的好處是有型別處理的能力,因此安全性增加許多
3.Java會紀錄run time type
有了 run time type, Java 可以安全的做多型及強制轉型
4.Java具有真正的資料安全措施
在C++可以透過private宣告保護data / function member.
但這種保護可以透過指標便可輕易的存取.常聽到的溢位攻擊大致上就是運用這種惡意指標的方式
Java 有三層安全性保護
Byte-code verifier, class loader, security manager
其中Byte-code verifier就能防止溢位存取的發生
Security manager能限制程式的執行,例如不允許程式網路連線.
5.Java不支援運算子overload
6.Java中的陣列是特殊的物件型態
宣告型別為String的陣列變數 String [] arrayStr;
arrayStr此時還沒有陣列實體
Alloc陣列實體 arrayStr = new String [10];
陣列中的元素是該陣列型別的reference,並非實體
因此陣列初始的元素都是null reference
anonymous array
Func( new String [] { "string 0", "string 1", "string 2"});
7.Java中local variable必須明確賦值初始化
最近想要用Java applet加強web server的功能就著手來study囉
1.Java 既是編譯也是直譯式語言
編譯式語言的優點 : 較有效率及執行速度快
直譯式語言的優點 : 跨平台的可移植性佳
Java Source Code -> [ Compile ] -> Java Instruction Binary
Java Instruction Binary -> [ Interpreter ] -> Running on Java Virtual Machine
2.Java沒有指標 (pointer)
Java使用參考(reference)來達到指標的功能.
參考的好處是有型別處理的能力,因此安全性增加許多
3.Java會紀錄run time type
有了 run time type, Java 可以安全的做多型及強制轉型
4.Java具有真正的資料安全措施
在C++可以透過private宣告保護data / function member.
但這種保護可以透過指標便可輕易的存取.常聽到的溢位攻擊大致上就是運用這種惡意指標的方式
Java 有三層安全性保護
Byte-code verifier, class loader, security manager
其中Byte-code verifier就能防止溢位存取的發生
Security manager能限制程式的執行,例如不允許程式網路連線.
5.Java不支援運算子overload
6.Java中的陣列是特殊的物件型態
宣告型別為String的陣列變數 String [] arrayStr;
arrayStr此時還沒有陣列實體
Alloc陣列實體 arrayStr = new String [10];
陣列中的元素是該陣列型別的reference,並非實體
因此陣列初始的元素都是null reference
anonymous array
Func( new String [] { "string 0", "string 1", "string 2"});
7.Java中local variable必須明確賦值初始化
2009年3月18日 星期三
VT300 Screen Shot
Graphic User Interface System Information
Resolution : 480 x 272 16bits
Low level engine : Nano-X
Font : FireFly (UTF-8)
Features :
1.Window Manager
2.Alpha Blending Window
3.Break edge window
4.Shadow Font
5.Scale jpeg image
6.Editor, Menu, Radio Button, Combo Box, Tab Window
2009年3月1日 星期日
轉載 max mp3 frame size
[mad-dev] max mp3 frame size?
Rob Leslie rob@mars.orgThu, 17 Jan 2002 16:54:05 -0800
- Previous message: [mad-dev] max mp3 frame size?
- Next message: [mad-dev] max mp3 frame size?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Joshua Haberman wrote:
> Currently Audacity uses a 64k input buffer when reading mp3s with libmad.
> This has worked great for the most part, but I've received a report that
> one particular mp3 will put Audacity into an infinite loop upon import.
> Since a trace revealed that the input callback was looping endlessly, I
> suspected that the buffer wasn't big enough to hold an entire frame, and
> the input callback was sending libmad the same partial frame over and over.
>
> I suggested that this user double the input buffer size, and that fixed
> the problem.
>
> Earlier when I asked you about this issue, you said mp3 frames are
> relatively small (around 418 bytes) so I'm very surprised that 64k wasn't
> big enough to hold an entire frame. Can you think of any other reason why
> increasing the buffer size would solve this problem?
Sounds like it could be a bug in your input/streaming code, triggered by the
unlucky buffer size? Out of curiosity, what bitrate and sampling frequency was
the mp3 that caused problems?
> Is there a maximum size for mp3 frames that I could safely set as the
> buffer size, or would I have to dynamically size the buffer to be
> completely safe?
The absolute theoretical maximum frame size is 2881 bytes: MPEG 2.5 Layer II,
8000 Hz @ 160 kbps, with a padding slot. (Such a frame is unlikely, but it was
a useful exercise to compute all possible frame sizes.) Add to this an 8 byte
MAD_BUFFER_GUARD, and the minimum buffer size you should be streaming to
libmad in the general case is 2889 bytes.
Theoretical frame sizes for Layer III range from 24 to 1441 bytes, but there
is a "soft" limit imposed by the standard of 960 bytes. Nonetheless MAD can
decode frames of any size as long as they fit entirely in the buffer you pass,
not including the MAD_BUFFER_GUARD bytes.
A 64K buffer is surely large enough, which makes me think you have a different
kind of problem...
--
Rob Leslie
rob@mars.org
2009年2月24日 星期二
popen and mmap
轉載
http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/113038b65f4d3257
On Sat, 24 Jan 2009 12:32:40 -0800 (PST) spasmous2 <spasm...@gmail.com> wrote:
| I want to pipe the output of a system utility to a C program I'm
| writing. I tried popen() and it works nicely. The return type is a
| FILE* which I would like to map to memory using mmap() in the
| following way:
|
| file = popen(command,"r");
|
| data = (char*)mmap(NULL, size, PROT_READ, MAP_PRIVATE, fileno
| (file), 0);
|
| However the mmap command returns an error 'No such device', which I
| looked up to mean 'The fildes parameter does not refer to a *TYPE2
| stream file (*STMF) in the "root" (/), QOpenSys, or user-defined file
| systems.'
|
| I am unsure really what this means - do you know if it's a deal
| breaker or is there a solution?
If you want random memory access to data from another program, what you want
is a shared mapping between these programs. There are a couple ways to do
that between processes. Or you could use threads (if willing to spend time
to understand the complexities of threads).
以上的意思是說mmap不能用在任何streaming的應用
殘念
http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/113038b65f4d3257
On Sat, 24 Jan 2009 12:32:40 -0800 (PST) spasmous2 <spasm...@gmail.com> wrote:
| I want to pipe the output of a system utility to a C program I'm
| writing. I tried popen() and it works nicely. The return type is a
| FILE* which I would like to map to memory using mmap() in the
| following way:
|
| file = popen(command,"r");
|
| data = (char*)mmap(NULL, size, PROT_READ, MAP_PRIVATE, fileno
| (file), 0);
|
| However the mmap command returns an error 'No such device', which I
| looked up to mean 'The fildes parameter does not refer to a *TYPE2
| stream file (*STMF) in the "root" (/), QOpenSys, or user-defined file
| systems.'
|
| I am unsure really what this means - do you know if it's a deal
| breaker or is there a solution?
You've been told by another followup that you cannot mmap a pipe. The reason
you cannot do this is because a pipe is not data storage that can be accessed
by random position. In an extreme way, a tape could be, but even it does not
work that way with existing drivers. A pipe is a _sequential_ data stream
produced by the writing of another program.
If you want random memory access to data from another program, what you want
is a shared mapping between these programs. There are a couple ways to do
that between processes. Or you could use threads (if willing to spend time
to understand the complexities of threads).
以上的意思是說mmap不能用在任何streaming的應用
殘念
2009年2月18日 星期三
PXA255 uboot
patch uboot
+===================================================================
+--- u-boot-1.1.6.orig/board/pxa255_idp/memsetup.S
++++ u-boot-1.1.6/board/pxa255_idp/memsetup.S
+@@ -41,8 +41,8 @@ DRAM_SIZE: .long CFG_DRAM_SIZE
+ /*
+ * Memory setup
+ */
+-.globl memsetup
+-memsetup:
++.globl lowlevel_init
++lowlevel_init:
+
+ mov r10, lr
+
+Index: u-boot-1.1.6/include/configs/pxa255_idp.h
+===================================================================
+--- u-boot-1.1.6.orig/include/configs/pxa255_idp.h
++++ u-boot-1.1.6/include/configs/pxa255_idp.h
+@@ -41,7 +41,7 @@
+ * If we are developing, we might want to start armboot from ram
+ * so we MUST NOT initialize critical regs like mem-timing ...
+ */
+-#define CONFIG_INIT_CRITICAL /* undef for developing */
++#undef CONFIG_INIT_CRITICAL /* undef for developing */
+
+ /*
+ * define the following to enable debug blinks. A debug blink function
============================================================
CROSS_COMPILE=arm-linux-uclibc-
make pxa255_idp_config
make all
2009年2月16日 星期一
mipsel linux mplayer
Download MPlayer-1.0rc2
偶只想要decoder,所以拿掉encoder
./configure --enable-cross-compile --target=mips-linux --cc=mipsel-linux-uclibc-gcc --host-cc=gcc --disable-mencoder
make
然後錯誤出現囉
修改libavutil/internal.h
加入以下function
#if !HAVE_LLRINT
static av_always_inline long long llrint(double x)
{
return rint(x);
}
#endif /* HAVE_LLRINT */
#if !HAVE_LRINT
static av_always_inline long int lrint(double x)
{
return rint(x);
}
#endif /* HAVE_LRINT */
#if !HAVE_ROUND
static av_always_inline double round(double x)
{
return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
}
#endif /* HAVE_ROUND */
#if !HAVE_ROUNDF
static av_always_inline float roundf(float x)
{
return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
}
#endif /* HAVE_ROUNDF */
#if !HAVE_TRUNCF
static av_always_inline float truncf(float x)
{
return (x > 0) ? floor(x) : ceil(x);
}
#endif /* HAVE_TRUNCF */
降樣子就OK囉
mipsel-linux-uclibc-strip mplayer
將mplayer丟到target上執行
video out to framebuffer & no sound
./mplayer -vo fbdev -nosound 0001.AVI
允許丟棄frame
./mplayer -vo fbdev -nosound -framedrop ./鐵鉆山老二-43.29.mpeg
rescale to 320x240 frame rate 5, -ni是在處理不正確的avi format
./mplayer -vf scale=320:240 -fps 5 -zoom -vo fbdev -nosound -ni ./luna.avi
./mplayer -vo fbdev -nosound ./32.70_0002.wmv
連WMV都可以play,真是讚啊
Internet radio
./mplayer -playlist ../tunein-station-4.pls
# ./mplayer -vo fbdev -nosound -framedrop 五分山20080921-小黑-Skorpion001.mpeg
MPlayer 1.0rc2-3.4.6 (C) 2000-2007 MPlayer Team
CPU: SGI MIPS
Playing 五分山20080921-小黑-Skorpion001.mpeg.
MPEG-PS file format detected.
VIDEO: MPEG1 352x240 (aspect 12) 29.970 fps 1152.0 kbps (144.0 kbyte/s)
==========================================================================
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 352 x 240 (preferred colorspace: Mpeg PES)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDecoder init failed :(
Opening video decoder: [libmpeg2] MPEG 1/2 Video decoder libmpeg2-v0.4.0b
Selected video codec: [mpeg12] vfm: libmpeg2 (MPEG-1 or 2 (libmpeg2))
==========================================================================
Audio: no sound
Starting playback...
VDec: vo config request - 352 x 240 (preferred colorspace: Planar YV12)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.30:1 - prescaling to correct movie aspect.
[swscaler @ 0xaa7440]No accelerated colorspace conversion found
[swscaler @ 0xaa7440]SwScaler: using unscaled yuv420p -> bgr565 special converter
VO: [fbdev] 352x240 => 352x270 BGR 16-bit
V: 10.5 296/296 105% 74% 0.0% 0 0
如果使用libmad
執行時加上 -ac mad
Reference
http://amoi.it168.com/blog.php?tid=321580
http://www.oppo.com/index.php?q=oppoblog/view/11752
http://people.bath.ac.uk/enpsgp/floating_point.html
http://cha.homeip.net/blog/archives/2008/03/mplayerffmpeg.html
http://blog.chinaunix.net/u1/34961/showart_494026.html
偶只想要decoder,所以拿掉encoder
./configure --enable-cross-compile --target=mips-linux --cc=mipsel-linux-uclibc-gcc --host-cc=gcc --disable-mencoder
make
然後錯誤出現囉
修改libavutil/internal.h
加入以下function
#if !HAVE_LLRINT
static av_always_inline long long llrint(double x)
{
return rint(x);
}
#endif /* HAVE_LLRINT */
#if !HAVE_LRINT
static av_always_inline long int lrint(double x)
{
return rint(x);
}
#endif /* HAVE_LRINT */
#if !HAVE_ROUND
static av_always_inline double round(double x)
{
return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
}
#endif /* HAVE_ROUND */
#if !HAVE_ROUNDF
static av_always_inline float roundf(float x)
{
return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
}
#endif /* HAVE_ROUNDF */
#if !HAVE_TRUNCF
static av_always_inline float truncf(float x)
{
return (x > 0) ? floor(x) : ceil(x);
}
#endif /* HAVE_TRUNCF */
降樣子就OK囉
mipsel-linux-uclibc-strip mplayer
將mplayer丟到target上執行
video out to framebuffer & no sound
./mplayer -vo fbdev -nosound 0001.AVI
允許丟棄frame
./mplayer -vo fbdev -nosound -framedrop ./鐵鉆山老二-43.29.mpeg
rescale to 320x240 frame rate 5, -ni是在處理不正確的avi format
./mplayer -vf scale=320:240 -fps 5 -zoom -vo fbdev -nosound -ni ./luna.avi
./mplayer -vo fbdev -nosound ./32.70_0002.wmv
連WMV都可以play,真是讚啊
Internet radio
./mplayer -playlist ../tunein-station-4.pls
# ./mplayer -vo fbdev -nosound -framedrop 五分山20080921-小黑-Skorpion001.mpeg
MPlayer 1.0rc2-3.4.6 (C) 2000-2007 MPlayer Team
CPU: SGI MIPS
Playing 五分山20080921-小黑-Skorpion001.mpeg.
MPEG-PS file format detected.
VIDEO: MPEG1 352x240 (aspect 12) 29.970 fps 1152.0 kbps (144.0 kbyte/s)
==========================================================================
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 352 x 240 (preferred colorspace: Mpeg PES)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDecoder init failed :(
Opening video decoder: [libmpeg2] MPEG 1/2 Video decoder libmpeg2-v0.4.0b
Selected video codec: [mpeg12] vfm: libmpeg2 (MPEG-1 or 2 (libmpeg2))
==========================================================================
Audio: no sound
Starting playback...
VDec: vo config request - 352 x 240 (preferred colorspace: Planar YV12)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.30:1 - prescaling to correct movie aspect.
[swscaler @ 0xaa7440]No accelerated colorspace conversion found
[swscaler @ 0xaa7440]SwScaler: using unscaled yuv420p -> bgr565 special converter
VO: [fbdev] 352x240 => 352x270 BGR 16-bit
V: 10.5 296/296 105% 74% 0.0% 0 0
如果使用libmad
執行時加上 -ac mad
Reference
http://amoi.it168.com/blog.php?tid=321580
http://www.oppo.com/index.php?q=oppoblog/view/11752
http://people.bath.ac.uk/enpsgp/floating_point.html
http://cha.homeip.net/blog/archives/2008/03/mplayerffmpeg.html
http://blog.chinaunix.net/u1/34961/showart_494026.html
訂閱:
文章 (Atom)