詳細還是要看 原網站說明另外一個選擇是 partclone,是單一的程式,console mode。 clone partition 的 command 大概是:
$ partclone.extfs -b -d -s /dev/hda1 -o /dev/hdb1
ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上
詳細還是要看 原網站說明另外一個選擇是 partclone,是單一的程式,console mode。 clone partition 的 command 大概是:
$ partclone.extfs -b -d -s /dev/hda1 -o /dev/hdb1
/* Start codes. */ #define SEQ_END_CODE 0x000001b7 #define SEQ_START_CODE 0x000001b3 #define GOP_START_CODE 0x000001b8 #define PICTURE_START_CODE 0x00000100 #define SLICE_MIN_START_CODE 0x00000101 #define SLICE_MAX_START_CODE 0x000001af #define EXT_START_CODE 0x000001b5 #define USER_START_CODE 0x000001b2
$ gcc -Wall calc.c -lm -o calc (correct order)With some linkers the opposite ordering (placing the -lm option before the file which uses it) would result in an error,
$ cc -Wall -lm calc.c -o calc (incorrect order) main.o: In function `main': main.o(.text+0xf): undefined reference to `sqrt'因為command 的order,calc.c 後面沒有寫明任何 library,calc.c 使用到的sqrt 雖然有定義在 libm ,但是command 列在calc.c 之前,所以 linker 找不到。 When several libraries are being used, the same convention should be followed for the libraries themselves. A library which calls an external function defined in another library should appear before the library containing the function. 例如, data.c 使用到 linear programming library : library,library 又使用到 math library : libm。所以正確的linking order 是:
$ gcc -Wall data.c -lglpk -lmsince the object files in ‘libglpk.a’ use functions defined in ‘libm.a’. 目前大多數的 linker 都會(重複?)搜尋所有指定的 external library,所以 linking order 在目前似乎沒那麼重要。 但是當你在build 時遇到 undefined external,而你又確定該 symbol 是有定義的,或許試試是不是 linking order 的問題。
-lavdevice -lavformat -lavcodec -lavutil -lswscale -lm這樣那個 avcodec_sample_0.5.0.c 就可以 build 了。 ./a.exe 出現 segment fault. 用 dbg run
(gdb) run Starting program: c:\codepiece/a.exe [New thread 2472.0x6a0] Program received signal SIGSEGV, Segmentation fault. 0x0040cccd in url_open () (gdb) bt #0 0x0040cccd in url_open () #1 0x0040f399 in url_fopen () #2 0x004025c1 in av_open_input_file () #3 0x0040144c in main (argc=1, argv=0x3e2430) at avcodec_sample.c:51知道是因為沒給 argument,所以 open url,給定一個 mpg file後就 OK 了。 這個sample 會將 mpg 存為 6 個 ppm file...
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x4a57): undefined reference to `ff_epzs_motion_search' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x4bba): undefined reference to `ff_get_mb_score' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0xf64d): undefined reference to `ff_rate_estimate_qscale' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0xfb74): undefined reference to `h263_encode_init' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0xfc0f): undefined reference to `ff_rate_control_init' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x10894): undefined reference to `ff_rate_estimate_qscale' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x10ce0): undefined reference to `ff_init_me' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x1184d): undefined reference to `ff_rate_estimate_qscale' c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x11886): undefined reference to `ff_write_pass1_stats' collect2: ld returned 1 exit status所以重新打開好了...(雖然看起來好像開 h264 encoder就可以..)
$ ../ffmpeg-export-2009-09-02/configure --prefix=/mingw --disable-debug --disable-optimizations --disable-stripping --enabl e-memalign-hack --enable-gpl --enable-static --disable-shared --disable-ffserver --disable-altivec --disable-amd3dnow --dis able-mmx --disable-mmx2 --disable-sse --disable-ssse3 --disable-yasm --disable-encoders --disable-hwaccels --disable-indevs --disable-protocol=gopher --disable-protocol=http --disable-protocol=rtmp --disable-protocol=rtp --disable-protocol=tcp -- disable-protocol=udp --disable-network install prefix /mingw source path /c/ffmpeg/ffmpeg-export-2009-09-02 C compiler gcc .align is power-of-two no ARCH x86 (generic) big-endian no runtime cpu detection no yasm no MMX enabled no MMX2 enabled no 3DNow! enabled no 3DNow! extended enabled no SSE enabled no SSSE3 enabled no CMOV enabled no CMOV is fast no EBX available yes EBP available no 10 operands supported yes gprof enabled no debug symbols no strip symbols no optimizations no static yes shared no postprocessing support no new filter support no filters using lavformat no network support no threading support no SDL support yes Sun medialib support no AVISynth enabled no libdc1394 support no libdirac enabled no libfaac enabled no libfaad enabled no libfaad dlopened no libgsm enabled no libmp3lame enabled no libnut enabled no libopencore-amrnb support no libopencore-amrwb support no libopenjpeg enabled no libschroedinger enabled no libspeex enabled no libtheora enabled no libvorbis enabled no libx264 enabled no libxvid enabled no zlib enabled no bzlib enabled no Enabled decoders: aac ffv1 pcm_s32be aasc ffvhuff pcm_s32le ac3 flac pcm_s8 adpcm_4xm flic pcm_u16be adpcm_adx flv pcm_u16le adpcm_ct fourxm pcm_u24be adpcm_ea fraps pcm_u24le adpcm_ea_maxis_xa gif pcm_u32be adpcm_ea_r1 h261 pcm_u32le adpcm_ea_r2 h263 pcm_u8 adpcm_ea_r3 h263i pcm_zork adpcm_ea_xas h264 pcx adpcm_g726 huffyuv pgm adpcm_ima_amv idcin pgmyuv adpcm_ima_dk3 imc pgssub adpcm_ima_dk4 indeo2 ppm adpcm_ima_ea_eacs indeo3 ptx adpcm_ima_ea_sead interplay_dpcm qcelp adpcm_ima_iss interplay_video qdm2 adpcm_ima_qt jpegls qdraw adpcm_ima_smjpeg kmvc qpeg adpcm_ima_wav loco qtrle adpcm_ima_ws mace3 ra_144 adpcm_ms mace6 ra_288 adpcm_sbpro_2 mdec rawvideo adpcm_sbpro_3 mimic rl2 adpcm_sbpro_4 mjpeg roq adpcm_swf mjpegb roq_dpcm adpcm_thp mlp rpza adpcm_xa mmvideo rv10 adpcm_yamaha motionpixels rv20 alac mp1 rv30 amv mp2 rv40 ape mp3 sgi asv1 mp3adu shorten asv2 mp3on4 smackaud atrac3 mpc7 smacker avs mpc8 smc bethsoftvid mpeg1video snow bfi mpeg2video sol_dpcm bmp mpeg4 sonic c93 mpegvideo sp5x cavs msmpeg4v1 sunrast cinepak msmpeg4v2 svq1 cljr msmpeg4v3 svq3 cook msrle targa cscd msvideo1 theora cyuv mszh thp dca nellymoser tiertexseqvideo dnxhd nuv tiff dpx pam tmv dsicinaudio pbm truehd dsicinvideo pcm_alaw truemotion1 dvbsub pcm_bluray truemotion2 dvdsub pcm_dvd truespeech dvvideo pcm_f32be tta eac3 pcm_f32le twinvq eacmv pcm_f64be txd eamad pcm_f64le ulti eatgq pcm_mulaw v210 eatgv pcm_s16be v210x eatqi pcm_s16le vb eightbps pcm_s16le_planar vc1 eightsvx_exp pcm_s24be vcr1 eightsvx_fib pcm_s24daud vmdaudio escape124 pcm_s24le vmdvideo vmnc vqa wnv1 vorbis wavpack ws_snd1 vp3 wmav1 xan_dpcm vp5 wmav2 xan_wc3 vp6 wmv1 xl vp6a wmv2 xsub vp6f wmv3 Enabled encoders: Enabled hwaccels: Enabled parsers: aac dvdsub mpeg4video ac3 h261 mpegaudio cavsvideo h263 mpegvideo dca h264 pnm dirac mjpeg vc1 dnxhd mlp vp3 dvbsub Enabled demuxers: aac iss pcm_u24be ac3 lmlm4 pcm_u24le aiff m4v pcm_u32be amr matroska pcm_u32le apc mjpeg pcm_u8 ape mlp pva asf mm qcp ass mmf r3d au mov rawvideo avi mp3 rl2 avs mpc rm bethsoftvid mpc8 roq bfi mpegps rpl c93 mpegts segafilm cavsvideo mpegtsraw shorten daud mpegvideo siff dirac msnwc_tcp smacker dnxhd mtv sol dsicin mvi sox dts mxf str dv nc swf dxa nsv thp ea nut tiertexseq ea_cdata nuv tmv eac3 ogg truehd ffm oma tta flac pcm_alaw txd flic pcm_f32be vc1 flv pcm_f32le vc1t fourxm pcm_f64be vmd gsm pcm_f64le voc gxf pcm_mulaw vqf h261 pcm_s16be w64 h263 pcm_s16le wav h264 pcm_s24be wc3 idcin pcm_s24le wsaud iff pcm_s32be wsvqa image2 pcm_s32le wv image2pipe pcm_s8 xa ingenient pcm_u16be yuv4mpegpipe ipmovie pcm_u16le Enabled muxers: ac3 m4v pcm_mulaw adts matroska pcm_s16be aiff matroska_audio pcm_s16le amr mjpeg pcm_s24be asf mlp pcm_s24le asf_stream mmf pcm_s32be ass mov pcm_s32le au mp2 pcm_s8 avi mp3 pcm_u16be avm2 mp4 pcm_u16le crc mpeg1system pcm_u24be daud mpeg1vcd pcm_u24le dirac mpeg1video pcm_u32be dnxhd mpeg2dvd pcm_u32le dts mpeg2svcd pcm_u8 dv mpeg2video psp eac3 mpeg2vob rawvideo ffm mpegts rm flac mpjpeg roq flv mxf sox framecrc mxf_d10 spdif gif null swf gxf nut tg2 h261 ogg tgp h263 pcm_alaw truehd h264 pcm_f32be vc1t image2 pcm_f32le voc image2pipe pcm_f64be wav ipod pcm_f64le yuv4mpegpipe Enabled protocols: file pipe Enabled filters: crop Enabled bsfs: aac_adtstoasc mjpega_dump_header noise dump_extradata mov2textsub remove_extradata h264_mp4toannexb mp3_header_compress text2movsub imx_dump_header mp3_header_decompress Enabled indevs: Enabled outdevs: License: GPL version 2 or later Creating config.mak and config.h...
gcc testffmpeg.c -lavformat -lavcodec -lavutil -lz
$ make install install -d "/mingw/lib" install -m 644 libavfilter/libavfilter.a "/mingw/lib" ranlib "/mingw/lib/libavfilter.a" install -d "/mingw/lib" install -m 644 libavdevice/libavdevice.a "/mingw/lib" ranlib "/mingw/lib/libavdevice.a" install -d "/mingw/lib" install -m 644 libavformat/libavformat.a "/mingw/lib" ranlib "/mingw/lib/libavformat.a" install -d "/mingw/lib" install -m 644 libavcodec/libavcodec.a "/mingw/lib" ranlib "/mingw/lib/libavcodec.a" install -d "/mingw/lib" install -m 644 libavutil/libavutil.a "/mingw/lib" ranlib "/mingw/lib/libavutil.a" install -d "/mingw/lib" install -m 644 libswscale/libswscale.a "/mingw/lib" ranlib "/mingw/lib/libswscale.a" install -d "/mingw/include/libavfilter" install -d "/mingw/lib/pkgconfig" install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavfilter"/avfilter.h "/mingw/include/libavfilter" install -m 644 "/c/ffmpeg/build"/libavfilter/libavfilter.pc "/mingw/lib/pkgconfig" install -d "/mingw/include/libavdevice" install -d "/mingw/lib/pkgconfig" install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavdevice"/avdevice.h "/mingw/include/libavdevice" install -m 644 "/c/ffmpeg/build"/libavdevice/libavdevice.pc "/mingw/lib/pkgconfig" install -d "/mingw/include/libavformat" install -d "/mingw/lib/pkgconfig" install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavformat"/avformat.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavformat"/ avio.h "/mingw/include/libavformat" install -m 644 "/c/ffmpeg/build"/libavformat/libavformat.pc "/mingw/lib/pkgconfig" install -d "/mingw/include/libavcodec" install -d "/mingw/lib/pkgconfig" install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/avcodec.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/opt .h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/vdpau.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/xvmc.h "/mingw/in clude/libavcodec" install -m 644 "/c/ffmpeg/build"/libavcodec/libavcodec.pc "/mingw/lib/pkgconfig" install -d "/mingw/include/libavutil" install -d "/mingw/lib/pkgconfig" install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/adler32.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/avstr ing.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/avutil.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/base64.h "/c/ff mpeg/ffmpeg-export-2009-09-02/libavutil"/common.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/crc.h "/c/ffmpeg/ffmpeg-exp ort-2009-09-02/libavutil"/fifo.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/intfloat_readwrite.h "/c/ffmpeg/ffmpeg-expor t-2009-09-02/libavutil"/log.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/lzo.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libav util"/mathematics.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/md5.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/mem. h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/pixfmt.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/rational.h "/c/ffmp eg/ffmpeg-export-2009-09-02/libavutil"/sha1.h "/mingw/include/libavutil" install -m 644 "/c/ffmpeg/build"/libavutil/libavutil.pc "/mingw/lib/pkgconfig" install -d "/mingw/include/libswscale" install -d "/mingw/lib/pkgconfig" install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libswscale"/swscale.h "/mingw/include/libswscale" install -m 644 "/c/ffmpeg/build"/libswscale/libswscale.pc "/mingw/lib/pkgconfig" gcc -DHAVE_AV_CONFIG_H -I. -I"/c/ffmpeg/ffmpeg-export-2009-09-02" -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_B ITS=64 -D_LARGEFILE_SOURCE -std=c99 -fno-common -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdi sabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wundef -O3 -fno-math-er rno -fno-tree-vectorize -MMD -MF ffmpeg.d -MT ffmpeg.o -c -o ffmpeg.o /c/ffmpeg/ffmpeg-export-2009-09-02/ffmpeg.c gcc -L"/c/ffmpeg/build"/libavcodec -L"/c/ffmpeg/build"/libavdevice -L"/c/ffmpeg/build"/libavfilter -L"/c/ffmpeg/build"/libav format -L"/c/ffmpeg/build"/libavutil -L"/c/ffmpeg/build"/libpostproc -L"/c/ffmpeg/build"/libswscale -Wl,--warn-common -Wl,-- as-needed -Wl,-rpath-link,"/c/ffmpeg/build"/libpostproc -Wl,-rpath-link,"/c/ffmpeg/build"/libswscale -Wl,-rpath-link,"/c/ffm peg/build"/libavfilter -Wl,-rpath-link,"/c/ffmpeg/build"/libavdevice -Wl,-rpath-link,"/c/ffmpeg/build"/libavformat -Wl,-rpat h-link,"/c/ffmpeg/build"/libavcodec -Wl,-rpath-link,"/c/ffmpeg/build"/libavutil -Wl,-Bsymbolic -o ffmpeg_g.exe ffmpeg.o cmdu tils.o -lavfilter -lavdevice -lavformat -lavcodec -lavutil -lswscale -lz -lm -lvfw32 cp -p ffmpeg_g.exe ffmpeg.exe strip ffmpeg.exe install -d "/mingw/bin" install -c -m 755 ffmpeg.exe ffplay.exe "/mingw/bin" install -d "/mingw/share/ffmpeg" install -m 644 /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-baseline.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffp resets/libx264-default.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-fastfirstpass.ffpreset /c/ffmpeg/ffmpeg -export-2009-09-02/ffpresets/libx264-hq.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-ipod320.ffpreset /c/ff mpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-ipod640.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossle ss_fast.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_max.ffpreset /c/ffmpeg/ffmpeg-export-2009-09- 02/ffpresets/libx264-lossless_medium.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_slow.ffpreset /c /ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_slower.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/lib x264-lossless_ultrafast.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-main.ffpreset /c/ffmpeg/ffmpeg-export- 2009-09-02/ffpresets/libx264-max.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-normal.ffpreset /c/ffmpeg/ffm peg-export-2009-09-02/ffpresets/libx264-slowfirstpass.ffpreset "/mingw/share/ffmpeg"
SDL_Init(SDL_INIT_VIDEO);
然後create 一個你要的 surface,可以任意指定這個 video surface 的 format (color depth, color space(?), dimension):
SDL_Surface *screen;
screen = SDL_SetVideoMode(640,480,16,SDL_FULL_SCREEN);
接下來就跟 DirectDraw 很像..
surface 的 structure 中包含 surface 的 raw data arrary (就像是 framebuffer一樣),可以直接作read/write pixel 的動作。
但是在操作之前,要lock surface,操作完後 unlock:
Uint16 *raw_pixels;
SDL_LockSurface(screen);
raw_pixels = (Uint16 *)screen->pixels;
要"填寫" raw pixel value,可以利用 screen structure 中另一個資訊:format。
format 包涵 color bit 的 有效bit和 bit 位置的資料:
在 example program 可以看出來:
Uint value;
value = ((red >>fmt->Rloss) <<fmt->Rshift) +
....
R.G.B 三色分別有對應的無效 bit 數 (Xloss) 和位置(Xshift)
還有 raw_pixels[] array 的 x, y 對應,可以依照 screen structure 的 pitch 的資料。
pitch 代表 一條 y line 的 byte 數。
example code 中,填寫 (x,y) 點的 offset 是:
screen->pitch/2 * y + 1-- 因為 raw_pixels 是 Uint16,所以要/2。 畫完圖後SDL_Unlock(screen)。 再call SDL_UpdateRect(screen,0,0,0,0) 把 surface update 到真正的螢幕上。
#include "SDL.h"
Uint16 CreateHicolorPixel(SDL_PixelFormat *fmt, Uint8 red, Uint8 green, Uint8 blue)
{
Uint16 value;
value = ((red >>fmt->Rloss) << fmt->Rshift) +
((green>>fmt->Gloss) << fmt->Gshift) +
((blue >>fmt->Bloss) << fmt->Bshift);
return value;
}
int main(int argc,char* argv[])
{
SDL_Surface *screen;
Uint16 *raw_pixels;
int x,y;
SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
screen = SDL_SetVideoMode(640,480,16,SDL_FULLSCREEN);
SDL_LockSurface(screen);
raw_pixels = (Uint16*)screen->pixels;
for(x=0;x<256;x++){
for(y=0;y<256;y++){
Uint16 pixel_color;
int offset;
pixel_color=CreateHicolorPixel(screen->format,x,0,y);
offset=(screen->pitch/2 *y+x);
raw_pixels[offset]=pixel_color;
}
}
SDL_UnlockSurface(screen);
SDL_UpdateRect(screen,0,0,0,0);
SDL_Delay(3000);
return 0;
}
build command 可以利用 sdl-config 吐出 build optin:
gcc sdl1.c -o sdl1 `sdl-config --cflags --libs`
Developer options (useful when working on FFmpeg itself): --disable-debug disable debugging symbols --enable-debug=LEVEL set the debug level [] --enable-gprof enable profiling with gprof [] --disable-optimizations disable compiler optimizations --enable-extra-warnings enable more compiler warnings --disable-stripping disable stripping of executables and shared libraries所以重新configuer,加上 --disable-optimizations --disable-stripping。
/usr/local/include /usr/local/lib所以compile 的時候要加上 -I/usr/local/include -L/usr/local/lib -lavdevice -lavformat -lavcodec -lavutil -lswscale
Copy all the files from the lib folder to C:\msys\mingw\lib\. Copy the SDL folder from the include folder to C:\msys\mingw\include\. Copy all the files from the bin folder to C:\msys\mingw\bin\.其中的 path 應該是
C:\mingw\lib\. C:\mingw\include\. C:\mingw\bin\.因為follow default setting 的話, minGW 是 install 在 c:\mingw。
這一篇有圖文並茂的 msys, mingw的安裝教學 (我沒看 )而且mingw 比 msys 先安裝,要怎樣 install 到 msys 的 folder 中呢?