Design and Implementation of MKV Player Based on SMP86 54

Abstract: The MKV package format is a new multimedia package format developed by the open source organization. It has the advantages of being scalable and supporting multiple video and audio encoding formats. It is one of the main package formats used in HD movies. This paper designs and implements an MKV player based on SMP86 54 platform, which can support the playback of high-definition MKV files, and further optimizes the characteristics of embedded systems and HD media, which has certain engineering significance and market value.

0 Preface

With the advancement of electronic technology and multimedia technology, the resolution of digital video has gradually increased, and it has begun to evolve from SD (standard definition) to HD (high definition). With the development of large-screen liquid crystal display technology, high-definition movies have gradually entered the field of vision of consumers. The HD player supports a wide range of video and audio encoding formats, and can smoothly play 1080i/p resolution HD movies, and supports analog, digital, HDMI and other methods in output. In addition, in terms of price and film source, it has great advantages over Blu-ray players, and will gradually replace traditional players such as VCD and DVD, becoming the mainstream products of next-generation home entertainment.

MKV is a new multimedia package format that supports multiple video and audio encoding formats. It can pack up to 16 different formats of audio and subtitle streams in different languages ​​into one file. It is widely used in high definition movies. More and more videos and movies use MKV as their package format. The ability to support the MKV package format is an important indicator of HD player performance. This paper proposes a design and implementation scheme of MKV player based on SMP86 54 platform, and further optimizes the characteristics of embedded system and HD media, which can provide smooth playback of MKV files.

1 MKV package format

MKV is called Matroska Video and is a new multimedia package format. The multimedia encapsulation format, also known as Multimedia Container, is different from the encoding formats such as H264, MPEG-2, and MPEG-4. It only provides a "shell" for multimedia encoding, and does not involve encoding itself. MKV is a standard developed by the open source organization Matroska Development Team. It consists of three parts: MKV (Matroska Video), MKA (Matroska Audio) and MKS (Matroska Su^itles). The latter two formats are for audio and subtitles respectively. less. The purpose of MKV is to replace traditional packaging formats such as AVI. AVI is a package format that Microsoft introduced in 1992. The meaning is Audio Video Interactive, which is a combination of video and audio encoding. Microsoft introduced an improved version of AVI, AVl2.0, in 1996. There are more restrictions on the AVI format, only one video track and one audio track, and some additional tracks, such as text. The AVI format does not provide any control functions. In general, the traditional AVI-based package format is obsolete and can only contain a few audio and video formats, and is not open enough and has poor scalability. Because of this, it was the birth of a new multimedia packaging format such as Matroska.

Compared with the traditional package format, MKV has the following advantages: support variable bit rate (VBR), support for error detection and repair of soft subtitles, support for streaming, strong openness and cross-platform compatibility, support for more than 16 channels of audio. Stream and subtitle stream, etc. The biggest feature of Matroska is that it can accommodate almost all types of video, audio and subtitle streams, except H. In addition to 264, other video and audio formats such as MPEG4, MPEG2, Ac3, AAC, etc. can be included. Even the very closed RealMedia and QuicklTime are included, and their audio and video are reorganized to achieve better. effect.

Since the MKV package format itself has many advantages, with the popularity of the Internet and high-definition movies, the MKV format has been widely used, and more and more high-definition movies on the Internet use the MKV format. However, MKV is a standard developed and promoted by open source organizations, lacking the support of large commercial companies, resulting in the lack of a complete and effective design implementation of MKV file playback. This problem is particularly acute on embedded platforms with limited performance and resources. Although many high-definition players currently provide support for the MKV format, most of the implementation solutions have problems of imperfect support and low playback efficiency. When playing high-rate video, there will be fluency, video, etc. The problem affects the viewing effect. This paper proposes a design and implementation scheme of MKV player based on SMP8* platform, and optimizes the characteristics of embedded system, which better meets the requirements of smooth playback of MKV files.

2 hardware platform and software overall design

The hardware platform is based on the SMP86 54 chip, and is connected to peripherals such as RAM, SATA hard disk, flash memory, and input/output devices through a bus. The SMP86 54 is a multimedia playback SoC solution from Sigma Design that integrates a powerful multimedia processor, robust content assurance system, new DDR2 memory controller, multiple on-chip CPUs, and a complete system peripheral interface. From a media playback perspective, the SMP86 54 provides an advanced decoding engine that fully supports high-definition video decoding, supporting MPEG1, MPEG-2, MPEG-4, and H. Hardware decoding in formats such as 264, WMV9, VCl, and AVS, supports high-performance graphics acceleration, multi-standard audio decoding and advanced display processing capabilities. Siena Design provides chip-related development kits and development frameworks for developing applications for third-party vendors. The work of this paper is also based on this framework for secondary development. In terms of the software platform, since a complete playback system is already quite complicated, it is not suitable for directly manipulating the underlying hardware to perform functions, and requires the support of the operating system. The operating system in this project uses uclinux, and the file system uses Romfs. Uclinux is a Linux customized for embedded systems. It has the main advantages of standard Linux operating system stability and powerful network functions, but it is not as complicated as standard Li-nux, mainly for no MMU (memory management unit). Microcontroller. Romfs is a file system designed for embedded systems. It is small, reliable, and fast to read. It is a common file system for embedded systems.


The playback process of the media file generally includes the following steps: system initialization, determining file type, file parsing, setting hardware decoder and audio and video decoding, wherein file parsing and audio and video decoding are key parts. Since the SMP86 54 integrates a complete audio and video hardware decoder, the decoding is mainly done by hardware. We only need to send the audio and video data to the corresponding decoding buffer as required. The overall software architecture is shown in Figure 2.


3 system key technology design and implementation

3.1 MKV file parsing

MKV file parsing mainly analyzes the various constituent elements of the MKV format to obtain the necessary audio and video parameters and media data. MKV is a package format. The actual video and audio data are encapsulated into a sub-module. To obtain the actual data, the file must be parsed first, and the file parsing runs through the whole process. Whether it can be effectively and correctly parsed is related to the accuracy of reading data, which in turn affects the effect of playback. The MKV format uses variable-length encoding to reduce storage space, and on the other hand, it brings new problems to parsing.

The MKV file format is based on EBML (Extensible Binary MetaLanguagel, an extensible binary meta-language similar to XML format, which uses variable-length integer storage to save space. The basic structure of EBML is a typical TLV structure. There are three parts:


The ID flag attribute type, size is the size of the data part, the data part is the actual data of the attribute identified by the ID, and the ID and size are integers of variable length coding. The length of the integer is length=1+[number of leading zero bits]. The number of zeros in front is up to seven, that is, an integer that can represent up to 56 bits. A number greater than 56 bits is not allowed in the file.


The distinguishing feature of the MKV file format is modular, structured storage. Each higher level element consists of several levels of elements up to the most basic constituent elements, each of which is a TLV structure. A standard MKV file consists of two parts: EBML Header and Segment. The EBML Header is composed of sub-elements such as EBMLVersion and DocType, and contains information such as the version of the file and the type of the document. The Segment part saves the actual data of the video and audio of the media file, and its data part can be divided into several sub-elements such as SeekHead, Tracks, and Cluster (Table 1). All elements can be processed in a single process. We can follow the idea of ​​layering TCP/IP protocol, using a function for each function of each layer, using lower-level functions to complete this function, and can be called by higher-level functions. When parsing a file, starting from the top of the file, whenever the element of the previous level is parsed to have a child element, the function is called to perform the next level of parsing, and then until the end of the file, the parsing of the file can be completed. The parsing call process of the entire MKV is shown in Figure 3. Hea-der Parse and Segment Parse are the uppermost element analytic functions of the file, and Cluster Parse and Tracks_Parse are the analytic functions of the next-level constituent elements. Ebml_read_ele-ment_idebml read element length is the analytic function of the bottommost basic constituent elements.


3.2 Setting the hardware decoder audio and video core parameters

Tracks are used to describe the information of each multimedia stream contained in the file. A multimedia stream is described by a TrackEntry, and all tracks are described in a single Tracks. A TrackEntry mainly contains: TrackNumber (determining which ID of the stream belongs), TrackType (video, audio or su^itle), TimeScale (timestamp unit), CodecID (encoding format); CodecPrivate (private encoding required for different encoding formats) Data), etc.; for video, it also contains the following information: PixelWidth, PixelHeight, and so on. For audio, the track also contains the following information: channels, Sampling Frequency, and more. These are the key parameters about whether audio and video can be correctly decoded and played. They need to be obtained during parsing and then set by hardware manipulation function.

The Cluster contains the actual data, a Cluster block, usually a media data spanned by a few seconds, and a file with thousands of Clusters. Each Cluster has several BlockGroups. Based on the starting pts and duration of the Cluster and BlockGroup, the actual pts of the current block can be calculated. PTS is important data used to determine the playback time, and is also the key information for audio and video synchronization. This part of the information is to set the hardware decoder while feeding video or audio data.

3.3 Performance Optimization

MKV-packaged movies are usually HD movies with a resolution of 1920×1080, even with H. Advanced coding formats such as 264, the code rate is still very high. At the same time, MKV supports variable bit rate, variable code rate can reduce the file size, but the violent fluctuation of the code rate will make the playback not smooth. In high-definition files, the code rate is generally between 10 and 30 M/ps, and the highest is 60 Mp/s. With such a high bit rate, if no special processing is performed, it is easy to appear during playback, and the playback is not smooth. To solve this problem, we consider it from two aspects.

In terms of parsing, the efficiency of parsing is related to whether the data can be read into the buffer as soon as possible. If the processing time is too long, the buffer will be empty for a period of time, and then there will be a jam. The MKV file usually contains one channel of video, multiple channels of audio and multiple subtitles. Only one channel of audio and one subtitle are selected during playback. The data of other channels can be regarded as invalid data. When parsing, it can be judged according to the flag of the block header whether the data is valid data or invalid data required for current playback. If it is valid data, continue to parse and send audio and video data to the buffer. If it is invalid data, without parsing, move the file pointer directly to the next block, which can greatly speed up file parsing and data reading.

In terms of playback, usually the processing flow during playback is to read one frame of data, and then send it to the hardware decoder, and wait until the hardware decoder is empty, and then read the data of the next frame. If it is to deal with the playback of low-rate files, this will not be a problem, but when the file resolution is higher and the code rate is higher, the parsing read time and decoding time will increase, which will cause the card to be stuck. To solve this problem, we have designed a buffer FIFO in memory, which is equivalent to a sliding window (Figure 4). The buffer can store several frames (one frame is a block, and the number of buffers stored according to the size of the frame is not Wait). When the buffer is not full, it reads a block in the file and parses it, then passes the actual data to the end of the buffer. When the hardware buffer is found to be idle, the data of the FIFO leader is sent directly from the memory into the hardware buffer, and there is no need to read the file. Since there are multiple frames in the buffer, it can provide a certain buffer, so that the data can be provided in time when the code rate fluctuates, avoiding the problem that the hardware buffer is empty and the playback is not smooth.


4 Conclusion

This article details the features of the MKV package format. Based on SMP86 54, a design and implementation scheme of MKV player is proposed. After verification, it can achieve smooth playback of high-definition MKV files and has been applied to products. Next, we will do further research. Based on the MKV player, we will design a universal media player framework for multiple package formats, and integrate other formats such as FLV and FLAC, and provide better scalability. It is convenient to expand other package formats later.



:
0 times
Window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": " 0", "bdSize": "24" }, "share": {}, "image": { "viewList": ["qzone", "tsina", "tqq", "renren", "weixin"], "viewText": "Share to:", "viewSize": "16" }, "selectShare": { "bdContainerClass": null, "bdSelectMiniList": ["qzone", "tsina", "tqq", "renren" , "weixin"] } }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share. Baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];

Digital currency transactions allow users to convert existing digital currencies into other digital currencies. The entire transaction does not involve any legal tender. Because of the relatively loose regulation, the mainstream digital currency trading platform also opened this function.Digital Asset Exchange (DAE) is a platform for matching transactions between digital currencies, digital currencies and legal currencies. It is the main place for encrypting the circulation and price determination of digital currency transactions.

Compared with traditional stock exchanges, digital asset trading platform not only matches transactions, but also plays the role of market maker and investment bank. The role of the market maker in the trading platform can increase the liquidity of the market, and the trading platform can earn the transaction price difference. The role of the investment bank of the trading platform is to provide services such as issuance and underwriting of digital currency, from which the trading platform collects money fees, or collects deposits in the form of community voting of the trading platform.

Currency Exchange

Currency Exchange,Digital Currency Exchange,Virtual Digital Currency Exchange,Display Currency Exchange

China youbi digital assets limited , http://www.ubcoinchina.com