Author Archive: Yumi Chan

Embedded Linux: 如何讓海思Hi3518開機後自動執行Shell Script?


已經了解了Hi3518一段時間,目前需要它於開機啟動時自動插入一些驅動和程序,所以小小研究了一下要怎麼做。首先,因為有一系列的指令要做,所以就給它寫了個Shell Script(腳本),讓它可以一次過運行我所有的指令,之後再放入Startup。至於Shell Script要怎麼寫,我暫時就不多說了,因為我知的也不多~ 哈哈~

0. 基礎知識

/etc/init.d/ : init.d 是一個用來存放Unix/Linux Shell Script的文件夾,如果你的內核有開啟 init.d 的話,系統啟動時,會在登入前自行執行存放在這裡的腳本。一般系統上所有服務的啟動腳本都會放在這裡,一般是Linux系統的話,應該都會看到它的蹤影。

Avoid writing 0x0A as 0x0D0A: Be careful of File Access Mode

When dealing with file I/O in C/C++, we should first open a file with fopen:
FILE * fopen ( const char * filename, const char * mode )
The parameter mode refers to “File Access Mode“. You have the following options (from

“r” read: Open file for input operations. The file must exist.
“w” write: Create an empty file for output operations. If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file.
“a” append: Open file for output at the end of a file. Output operations always write data at the end of the file, expanding it. Repositioning operations (fseek, fsetpos, rewind) are ignored. The file is created if it does not exist.
“r+” read/update: Open a file for update (both for input and output). The file must exist.
“w+” write/update: Create an empty file and open it for update (both for input and output). If a file with the same name already exists its contents are discarded and the file is treated as a new empty file.
“a+” append/update: Open a file for update (both for input and output) with all output operations writing data at the end of the file. Repositioning operations (fseek, fsetpos, rewind) affects the next input operations, but output operations move the position back to the end of file. The file is created if it does not exist.


Introduction to H.264: (2) SODB vs RBSP vs EBSP

Here is a summary of the relationship between SODB, RBSP, EBSP, NALU and H.264 Byte Stream.
SODB: String of Data Bits
RBSP: Raw Byte Sequence Payload
EBSP: Encapsulate Byte Sequence Payload

SODB + RBSP Stop bit + 0 bit(s) => RBSP

RBSP part 1 + 0x03 + RBSP part 2 + 0x03 + … + RBSP part n => EBSP

NALU Header + EBSP => NALU

In Byte Stream Format (Annex B),

Start CodeNALU + … + Start CodeNALU => H.264 Byte Stream

String of Data Bits (SODB)


3.149  string of data bits (SODB): A sequence of some number of bits representing syntax elements present within a raw byte sequence payload prior to the raw byte sequence payload stop bit. Within an SODB, the left-most bit is considered to be the first and most significant bit, and the right-most bit is considered to be the last and least significant bit.


Introduction to H.264: (1) NAL Unit

H.264 / MPEG-4 Part 10, Advanced Video Coding (MPEG-4 AVC) is a common video compression format developed by ITU-T Video Coding Experts Group (VCEG) and ISO/IEC JTC1 Moving Picture Experts Group (MPEG). Network Abstraction Layer (NAL) and Video Coding Layer (VCL) are the two main concepts in H.264. A H.264 file consists of a number of NAL units (NALU) and each NALU can be classified as VCL or non-VCL. Video data is processed by the codec and packed into NAL units.

NALU in Packet-Transport Protocol V.S. Byte-Stream Format

There are two ways to pack a NAL unit for different systems, Packet-Transport System and Byte-Stream Format. For Packet-Transport systems like RTP, the transport system protocol frames the coded data into different pieces. Hence, the system can easily identify the boundaries of NAL units and we don’t need to add extra start code, which is a waste of resources. This method is usually used in streaming.


免費下載:H.264和MP4文件格式的標準/規範 官方文件


對於要學習 H.264 和 MP4 文件格式的人來說,看懂官方的標準/規範是十分重要的。以下是有提供免費下載的鏈接:

H.264 (MPEG-4 Part 10 / MPEG-4 AVC), Advanced Video Coding

ITU-T 和 ISO 網站中均有提供。在ITU-TH.264 被分類在 Series H: Audiovisual and multimedia systems 中而在ISO,它是在ISO/IEC 14496 (MPEG-4)中(Part 10)。如果要學習H.264和MP4的關係,Part 15也有參考價值,但需付費購買。


Free Download: H.264 and MP4 file format Standard / Specification

Studying the standard is very important for learning H.264 and MP4 container format. Here are the download links of the free official documents.

H.264 (MPEG-4 Part 10 / MPEG-4 AVC), Advanced Video Coding

It is available on both ITU-T and ISO website. H.264 is in Series H: Audiovisual and multimedia systems in ITU-T while it is in Part 10 of ISO/IEC 14496 (MPEG-4) in ISO. If you need to study the relationship between H.264 and MP4 container, you should also refer to Part 15 (not free).


Free online Youtube video downloader –

Home Page of

I started downloading videos online, 8 or 9 years ago. I used to study the website source code and found out the direct link of the video. I saved lots of videos successfully. But it’s hard to do the same thing on Youtube (at least for me at that time.. when I was in secondary 1…). I looked for online downloader then and tried several sites. Yet, most of them are not available anymore, like kissyoutube. Some time later, I used JDownloader instead. Over the years, Youtube also keeps changing the video retrieving method and I doubt it brings some challenges to those downloaders. Recently, I reset my computer and I am lazy to reinstall JDownloader. So I look for online application again. I found then. It’s good because many online video downloaders only provide downloading video (without sound) or audio only. But helps you to combine both tracks so that you can download the video with sound directly. You can also choose the resolution of a video clip.

Explanation of Descriptors in the ITU-T Publication on H.264 Coding Standard / Recommendation (with example)

[:en]This text will be displayed in English[/:en]

I have started to learn H.264 for a week. My job required me to decode some H.264 video clips streamed from a media processor Hi3518 manufactured by Hisilicon. Yet, I have no background in video coding and it is a hard time for me now. I will keep writing and organizing the related materials for my revision and also for your reference. In this section, I am going to explain the descriptors used in the ITU-T official Publication on H.264 Coding Recommendation: Advanced video coding for generic audiovisual services and illustrate with some example. It is the basic thing you need to understand first before you could understand how to decode a H.264 video clip. There are 10 main descriptors, which are as follows (extracted from the document, edition 2013):

The following descriptors specify the parsing process of each syntax element. For some syntax elements, two descriptors, separated by a vertical bar, are used. In these cases, the left descriptors apply when entropy_coding_mode_flag is equal to 0 and the right descriptor applies when entropy_coding_mode_flag is equal to 1.