openmax replied to your post “I liked it better when I didn’t have to worry about stupid boys!!!!”
Preach it sista
soul sista soul sista
seen from Peru
seen from Portugal
seen from Russia
seen from Germany

seen from Malaysia
seen from Maldives
seen from Maldives
seen from South Korea
seen from China
seen from Thailand
seen from China

seen from United States
seen from United States
seen from China
seen from China

seen from United States
seen from United States
seen from United States
seen from United States
seen from China
openmax replied to your post “I liked it better when I didn’t have to worry about stupid boys!!!!”
Preach it sista
soul sista soul sista
Yellow
YELLOW = I don’t know you at all.
fuck you max
openmax replied to your photoset “my hair’s a mess but i still love you”
wipe the smug fucking grin off your god damn photo-boothing face
i live for these
openmax replied to your photoset “its finally raining >:)”
disquesting
fight me
openmax replied to your photoset “guess who’s gonna be Kiki from Kiki’s Delivery Service this Halloween ”
Ew
i know :(((
Raspberry Pi: VideoCore #1
Raspberry Pi เป็นคอมพิวเตอร์ขนาดเล็กที่หน่วยประมวลผลที่อยู่ใน Raspberry Pi ไม่ได้มีประสิทธิภาพในการประมวลผลทั่วๆไปที่สูงนัก แต่หน่วยประมวลผลของ Raspberry Pi ได้มีการใส่ความสามารถในการทำงานบางอย่างเฉพาะทางเพิ่มเข้าไป หนึ่งในความสามารถเฉพาะที่ Raspberry Pi มีคือกลุ่มทีเรียกว่า VideoCore
VideoCore
VideoCore เป็นหน่วยประมวลผลด้าน Graphics หรืออาจจะเรียกสั้นๆว่า GPU ที่มีความสามารถหลากหลาย โดยออกแบบมาให้สนับสนุน Application สำหรับผู้ใช้งานทั่วไป (Consumer) ที่มักจะใช้คอมพิวเตอร์เพื่อเล่น Game, ดูหนังฟังเพลงมากกว่าการประมวลด้านอื่น VideoCore ทีอยู่ใน Raspberry Pi จึงมึความสามารถที่จะใช้ฮาร์ดแวร์เฉพาะเพื่อทำการเข้ารหัส (Encoding) ถอดรหัส (Decoding) วิดีโอ, แสดงภาพ 3 มีิติ หรือแสดงภาพ Graphics ความเร็วสูง โดยผู้ผลิตหน่วยประมวลเตรียมให้ทำการเรียกใช้งานความสามารถเหล่านี้ผ่านทาง OpenMAX, OpenGL ES, OpenVG และ EGL ซึ่งเป็นมาตรฐานเปิดไว้ให้
OpenMAX : Multimedia Video, Audio
OpenGL : 3D Graphics
OpenVG : 2D Graphics
EGL : bridge between 3D & 2D
OpenMAX
OpenMax เป็น framework เพื่อใช้งานการเร่งความเร็ว (Acceleration) สำหรับงาน Video, Audio รวมทั้งภาพนิ่ง OpenMAX มีการแบ่งวิธีการเข้าใช้งานเป็น 3 ระดับ คือ Application Layer (AL), Integration Layer (IL) และ Development Layer (DL) ใน Raspberry Pi นั้นตัวอย่างที่ถูกในมาใช้อย่างชัดเจนจะอยู่ในระดับ Integration Layer
OpenMAX IL
ใน OpenMAX IL จะมีการโครงสร้างสถาปัติยกรรมที่เป็นลักษณะ Component และเชื่อมต่อเป็น Pipe Line คล้ายๆกับทีมีใน GStreamer จุดเด่นที่เพิ่มเข้ามาอย่างชัดเจนคือ OpenMAX IL มีการเชื่อม Pipe Line ในลักษณะ Tunnel ซึ่งเป็นการต่อท่อตรงระหว่าง Component บางคู่ที่สามารถที่จะเชื่อมต่อกันได้ ทำสามารถส่งต่อการชื่อสารระหว่าง Component ได้อย่างมีประสิทธิภาพ จุดเชื่อมต่อที่อยู่กับ Component แต่ละตัวก็จะเรียกว่า Port
ภาพจาก OpenMAX IL Specification
การใช้งาน OpenMAX IL ก็ทำได้โดยการสร้าง Component นั้นขึ้นมาแล้วทำการเรียกใช้ Port ต่างๆ ที่ Component นั้นมี หรือจะทำ Tunnel เชื่อม Port ระหว่าง Component ก็ได้
Component ใน OpenMAX IL จะมี Stage ในการทำงานอยู่หลาย Stage ซึ่งหลักๆดังนี้
LOADED : ยังไม่ถือ Resource
IDLE : จอง Resource เตรียมทำงาน
EXECUTING : ทำงาน
PAUSE : หยุดทำงานชั่วคราว สามารถทำงานต่อจากจุดที่หยุดได้
INVALIDE : เกิดปัญหา
WAIT_FOR_RESOURCE : รอ Resource
การสั่งให้ Component ต่างๆที่เราสร้างขึ้นก็ทำได้โดยการสั่งเปลี่ยน (Transition) Stage เหล่านี้เช่นกัน
Example 1: Camera and Video Render
เพื่อทำความเข้าใจให้ขึ้นลองมาดูตัวอย่าง Code ที่เรียกใช้ OpenMAX IL บ้าง ในตัวอย่างนี้จะเป็นการสร้าง Component สองตัวชื่อ camera และ video_render ขึ้นมา ทำการสร้าง tunnel เข้าด้วยกัน เพื่อนำเอาภาพจากกล้อง Camera Module ไปแสดงที่หน้าจอ
ใน camera จะประกอบไปด้วย port หลาย port ที่ทำงานแตกต่างกัน (รายละเอียดให้ดูจาก openmax il document ของ Raspberry Pi https://github.com/raspberrypi/firmware/tree/master/documentation/ilcomponents ) ในตอนนี้เราจะเชื่อม port ที่เป็น camera preview_port (70) ไปยัง video_render port (90)
ซึ่งก็จะเขียน Code อย่างๆง่ายๆ (โดยใช้ library บางส่วนที่อยู่ใน /opt/vc/src/hello_pi) ได้ดังนี้
#include #include #include #include "bcm_host.h" #include "ilclient.h" static int camera_test() { COMPONENT_T *video_camera = NULL, *video_render = NULL; COMPONENT_T * list[3]; TUNNEL_T tunnel[2]; ILCLIENT_T *client; int status = 0; memset(list, 0, sizeof (list)); memset(tunnel, 0, sizeof (tunnel)); if ((client = ilclient_init()) == NULL) { return -3; } if (OMX_Init() != OMX_ErrorNone) { ilclient_destroy(client); return -4; } // create camera if (ilclient_create_component(client, &video_camera, "camera", ILCLIENT_DISABLE_ALL_PORTS) != 0) status = -14; list[0] = video_camera; // create video_render if (status == 0 && ilclient_create_component(client, &video_render, "video_render", ILCLIENT_DISABLE_ALL_PORTS) != 0) status = -14; list[1] = video_render; set_tunnel(tunnel, video_camera, 70, video_render, 90); ilclient_change_component_state(video_camera, OMX_StateIdle); ilclient_setup_tunnel(tunnel, 0, 0); ilclient_change_component_state(video_camera, OMX_StateExecuting); ilclient_change_component_state(video_render, OMX_StateExecuting); while(1){} ilclient_disable_tunnel(tunnel); ilclient_teardown_tunnels(tunnel); ilclient_state_transition(list, OMX_StateIdle); ilclient_state_transition(list, OMX_StateLoaded); ilclient_cleanup_components(list); OMX_Deinit(); ilclient_destroy(client); return status; } int main(int argc, char **argv) { printf("Running... \n"); bcm_host_init(); return camera_test(); }
gist
จาก code ก็จะเป็น - การสร้าง component สองตัว ทำการ - เตรียมการสร้าง tunnel ระหว่าง camera port 70 ไปยัง video_render port 90 - เปลี่ยน Stage ไปเป็น Idle - สร้าง tunnel - เปลี่ยน Stage ไป Execute - ลูปรอ
และถ้าสิ้นสุดลูป ก็จะทำการ - ปิด tunnel - เปลี่ยน stage ไปเป็น idle (หยุดการทำงาน) และ loaded (คืน Resource) - clean up ต่างๆ
เมื่อรับโปรแกรมก็จะได้ output ที่หน้าจอหลักดังนี้
ใน code ตัวอย่างนี้เป็น code ที่เขียนเพื่อให้ทำความเข้าใจการทำงานได้ง่ายขึ้นเท่านั้น ยังขาดส่วนปรับแต่งค่าต่างๆ อีกหลายส่วน
OpenMAX-IL