200408278200408278
【發明所屬之技術領域】 本發明是在提供一種MPEG資料格式轉換方法,特 " 別是指一種能將MPEG-1資料格式轉換為MPEG-2資料格 式之轉換方法。 5【先前技術】 MPEG為國際標準組織(ISO)所制定的一種系統、影像 、聲音之壓縮格式,一般可分為三種規格:MPEG-1、 MPEG-2,及 MPEG-4。其中則以 MPEG-1 與 MPEG-2 最廣 ί 被使用。 10 MPEG-1是在1988年由IS0/IEC對於動態視訊及語音 壓縮標準所提出之壓縮準則,並已被廣泛地使用在CD-ROM上,即俗稱之影像光碟(VCD)。而MPEG-2則是以 MPEG-1為基礎,並增加了視訊應用範圍,故MPEG-1與 MPEG-2最大之差別在於資料傳輸之速率以及應用層面的不 15 同。 以MPEG-1為例,其所定義之解析度為352X240,相 參 當於一般VHS之晝質,而其資料傳輸速率為1.5Mb/s。 MPEG-2具備有720X480之解析度,並能夠擁有10Mb/s之 傳輸速率,故MPEG-2較MPEG-1之晝質為佳但資料量也 20 大幅增加。近年來,由於具備高儲存容量之DVD(數位影像 光碟)的出現,使得MPEG-2除了在高晝質電視(HDTV)之應 用範_以外,更為一般大眾所普遍接受與使用。 為了使得經由MPEG壓縮後之資料呈現在使用者面前 ,故常需要一具備解碼功能之軟體或硬體來進行。特別是 200408278 在一般支援播放VCD、DVD之資訊家電平台上,囿於製造 成本上的考量,故常採較低階的處理器作為處理核心,至 於運算量較大之視訊解碼部分,則需以另外的硬體解碼電 路來執行。 5 參閱第一圖,無論是MPEG-1或是MPEG-2之視訊資 料,其解碼步驟皆為:可變長度解碼(Variable Length Decoding, VLD)-> 反量化運算(Inverse Quantization,Q_1)-> 逆向離散餘弦轉換編碼(Inverse,IDCT)->動態補償(Motion Compensation, MC)等四個步驟。為了同時具備MPEG-1與 10 MPEG-2解碼功能,故在解碼電路中對應上述各個步驟設置 有兩組不同的電路方塊,一組職司 MPEG-1資料串流 (datastream)的解碼(電路方塊11〜14),另一組則負責 MPEG-2資料串流的解碼(電路方塊21〜24)。 吾人了解,理想上最佳的設計方法是讓MPEG-1與 15 MPEG-2之資料共用相同的電路,以達節省成本之目的。然 而,雖然概念上MPEG-2為MPEG-1之超集合(super set), 但由於MPEG-1與MPEG-2在實行細節上之定義並不完全 相同,因此對應於第一圖中各個步驟的解碼電路,除了逆 向離散餘弦轉換電路(IDCT)部分之相似度較高可互相轉用 20 之外,其餘電路並無法完全直接共用,故目前為了同時具 備有MPEG-1與MPEG-2之解碼功能,皆採用第一圖所示 之分離設計。 另一方面,為了節省部分硬體成本以及避免增加處理 器之負擔,亦有將前端運算量較低之可變長度(VLD)解碼交 200408278 ' 由軟體來執行者,然而,即便如此,亦需將MPEG-1與 MPEG-2之解碼電路分離設計,故僅能解決部分問題而非最 佳解決方案。 【發明内容】 5 因此,本發明之一目的即在提供一種將MPEG-1資料 格式轉換為MPEG-2資料格式之轉換方法。 本發明之另一目的即在提供一種利用前述之轉換方法 之解碼系統,其僅需一組MPEG-2解碼電路即能夠對 φ MPEG-1資料流已及MPEG-2資料流進行解碼。 10 是故’在本發明之一第一較佳實施例中,本發明之[Technical field to which the invention belongs] The present invention is to provide a method for converting MPEG data format, in particular, a conversion method capable of converting MPEG-1 data format to MPEG-2 data format. 5 [Previous Technology] MPEG is a system, video, and audio compression format developed by the International Standards Organization (ISO). Generally it can be divided into three specifications: MPEG-1, MPEG-2, and MPEG-4. Among them, MPEG-1 and MPEG-2 are the most widely used. 10 MPEG-1 is a compression standard proposed by IS0 / IEC for dynamic video and speech compression standards in 1988, and has been widely used on CD-ROM, commonly known as video compact disc (VCD). MPEG-2 is based on MPEG-1 and increases the scope of video applications. Therefore, the biggest difference between MPEG-1 and MPEG-2 lies in the data transmission rate and application level. Taking MPEG-1 as an example, the defined resolution is 352X240, which corresponds to the day quality of ordinary VHS, and its data transmission rate is 1.5Mb / s. MPEG-2 has a resolution of 720X480 and a transmission rate of 10Mb / s. Therefore, MPEG-2 has better day quality than MPEG-1 but the amount of data has increased significantly. In recent years, due to the emergence of DVDs (digital video discs) with high storage capacity, MPEG-2 has been widely accepted and used by the general public in addition to its application in high-quality television (HDTV). In order to make the data compressed by MPEG appear to the user, software or hardware with decoding function is often required to perform it. In particular, 200,408,278, on information appliances platforms that generally support the playback of VCDs and DVDs, due to manufacturing cost considerations, a lower-level processor is often used as the processing core. As for the video decoding part with a large amount of calculation, it is necessary to use another Hardware decoding circuit to perform. 5 Referring to the first picture, whether it is MPEG-1 or MPEG-2 video data, the decoding steps are: Variable Length Decoding (VLD)-> Inverse Quantization (Q_1)- > Inverse discrete cosine transform coding (Inverse, IDCT)-> Motion Compensation (MC) and other four steps. In order to have both MPEG-1 and 10 MPEG-2 decoding functions, two sets of different circuit blocks and one set of MPEG-1 datastream decoding (circuit blocks) are provided in the decoding circuit corresponding to the above steps. 11 ~ 14), the other group is responsible for decoding the MPEG-2 data stream (circuit blocks 21 ~ 24). I understand that ideally the best design method is to let the data of MPEG-1 and 15 MPEG-2 share the same circuit, in order to achieve the purpose of saving costs. However, although MPEG-2 is conceptually a super set of MPEG-1, since the implementation details of MPEG-1 and MPEG-2 are not exactly the same, they correspond to the steps in the first figure. Decoding circuit, except for the inverse discrete cosine conversion circuit (IDCT), which has a high degree of similarity and can be used interchangeably with each other, the other circuits cannot be directly shared. Therefore, in order to have both MPEG-1 and MPEG-2 decoding functions , All adopt the separation design shown in the first figure. On the other hand, in order to save some hardware costs and avoid increasing the burden on the processor, there is also a variable-length (VLD) decoding with a lower front-end calculation amount to 200408278 'to be executed by software, however, even so, it is necessary to Separately design the decoding circuit of MPEG-1 and MPEG-2, so it can only solve some problems instead of the best solution. [Summary of the Invention] Therefore, an object of the present invention is to provide a conversion method for converting an MPEG-1 data format into an MPEG-2 data format. Another object of the present invention is to provide a decoding system utilizing the aforementioned conversion method, which can decode a φ MPEG-1 data stream and an MPEG-2 data stream with only one set of MPEG-2 decoding circuits. 10 is therefore 'In one of the first preferred embodiments of the present invention,
J MPEG資料格式轉換方法係進行步驟A)接收一 MPEG-1資 料流;步驟B)轉換該MPEG_1資料流之序列表頭、圖像群組 (GOP)表頭,以及圖像(PIC)表頭為相對應之MPEG-2表頭; • 以及步驟C)映射該MPEG-1資料流中之圖像資料成為 15 MPEG-2格式之圖像資料。 更佳地,在本發明之一第二較佳實施例中,本發明亦 • 提供一種利用上述方法之解碼系統,該解碼系統包含一轉 換裝置與一解碼裝置。 轉換裝置是用以將一 MPEG-1資料流轉換為一 MPEG-2 20 資料流,並具有相耦接之一轉換單元與一映射單元。轉換 單元可接收該MPEG-1資料流,並將該MPEG-1資料流中 序列階層之表頭、圖像組階層之表頭,以及圖像階層之表 頭轉換為相對應之MPEG-2表頭格式。而映射單元是接收 經該轉換單元轉換後之MPEG-1資料流,並對該轉換後之 200408278 MPEG-l資料流之圖像資料進行可變長度(VLD)解碼成為 MPEG-2之圖像資料。解碼裝置則接收該MPEG-2資料流並 加以解碼為原始資料。 【實施方式】 本發明之前述以及其他技術内容、特點與優點,在以 下配合參考圖式之三個較佳實施例的詳細說明中,將可清 楚的明白。 參閱第二圖,在MPEG(MPEG-l/MPEG-2)之資料流 (datastream/bitstream)中,其資料結構皆是由一個或一個 10 以上之序列(sequence)所構成,而在每個序列之中則包含 了複數個圖像群組(picture of group,GOP)。所謂的圖像群 組指的是由許多圖像(picture)(或稱晝面,frame)所構成之 群組’而晝面依其功能可分為三種:交互晝面(I frame)、 預測晝面(P frame),以及雙向晝面(B frame)影像。藉由晝 15 面之連續播放,故呈現在使用者面前即為動態之影像。 而每個晝面又可細分為數個像條(slice),像條中又可 再分為數個巨集像塊(MacroBlock,MB)。而巨集像塊可由 四個亮度(Luminance)像塊及數個彩度(chrominance)像塊 所組成,最後,每一像塊(block)具有8X8像素,並定義 2〇 為MPEG之資料結構中之最小編碼單位。 在MPEG之壓縮標準中’每一個晝面即為一主要的 編碼單元’特別是對於交互晝面而言,由於預測晝面係以 交互晝面作為參考畫面來進行動作預測,而雙向晝面係以 交互晝面與預測晝面二者來作為參考晝面,故皆以交互晝 200408278 、 面作為起始影像壓縮之切入點。 故將一原始之影像資料以MPEG-1或MPEG-2之格式 •,壓縮時,是先將交互畫面中之每一個像塊定義出來,接著 對每一像塊之像素資料施以離散餘弦轉換(DCT),即把像 5 素資料由時域轉換為頻域’並去除掉人眼較不敏感之高頻 部分。接著再施以量化(quantization),使得許多經過離散 餘弦轉換之DCT係數量化為零。接著再以交錯掃瞄(Zig-zag scan)來將量化後之DCT係數重新排列,將低頻係數 | 排列在前而高頻係數排列在後。最後在經交錯掃瞄過後之 10 DCT係數中,將DC係數進行差動信號調變編碼(DPCM) ,並對AC係數進行動態長度編碼(run length encoding, RLE),最後再對二者進行可變長度編碼(variable length coding, VLC),即完成 MPEG-1/MPEG-2 格式的壓縮。 參閱第三圖,是故,在MPEG之標準架構中,可將 15 資料依序分為序列階層(sequence layer)、圖像群組階層、 圖像階層、像條階層、巨集像塊階層,以及像塊階層。在 瞻每一階層之資料中,則又包含了表頭(header)與資料内容 。例如在序列階層中,每一序列即包含了一序列表頭與一 序列資料,其中,序列表頭記載了相關的MPEG資訊, 20 例如起始碼(start code)、串流認證碼(stream ID)、影像參 數(video parameter)、串流參數(bitstream parameter)等等 ,而跟隨在序列表頭後之序列資料則包含了數個圖像組 (G〇P0、GOP1、GOP2......)。當然,如圖所示,每一圖像 組階層又可分為圖像組表頭以及圖像組資料,而每一圖像 10 200408278 組資料包含了數個圖像(PICl、PIC2、PIC3......),如此細 分而下,最後到達像塊階層,也就是進行編碼的最小單位 。當然,在每一階層之表頭中,皆記載了每一階層不同的 相關資訊,為簡化說明起見,在此並不多加詳述,但熟於 5 此技者應了解上述資料皆已清楚載於MPEG-1之ISO/IEC 11172規格書,以及MPEG-2之ISO/IEC 18838規格書中 〇 因此,在遵循此標準架構之前提下,參閱第四圖,在 一第一較佳實施例中,本發明係提供一種MPEG資料格 10 式轉換方法,可將MPEG-1之資料流轉換為MPEG-2之資 料流,並依下述步驟進行: 首先,如步驟31所示,接受一 MPEG-1資料流,此 資料流可以由一儲存媒體(例如硬碟、光碟片)中擷取而得 ,或是透過網際網路及其它相關之通訊裝置所傳送而得。 15 接著,如步驟32,轉換該MPEG-1資料流之序列表 / . 頭、圖像群組表頭,以及圖像表頭成為相對應之MPEG-2 表頭格式,在此並詳細說明如下。 如前所述,由於MPEG-2乃為MPEG-1之超集合,故 在國際標準組織(ISO)定義MPEG-2之格式時,即已使得 20 MPEG-2除了具備MPEG-1之格式外,更增加了許多延伸 (extension)之資料格式以增加其應用範圍。 故在此步驟32中,配合第五(A)圖所示,當接收 MPEG-1之資料流後,由於是先讀入MPEG-1之序列表頭 ,而吾人了解MPEG-2與MPEG-1之序列表頭差異在於: 200408278 、 MPEG-2 之序列表頭中增加了序列延伸(sequence extension)、以及顯示延伸(display extension)欄位,但由 於顯示延伸攔位乃為一選擇性(optional)之欄位,故為簡化 起見,在此僅填入延伸欄位使MPEG-1之序列表頭轉換為 5 MPEG-2之序列表頭。 更詳述之,序列延伸欄位中包含了「延伸起始碼」 (extension start code)、「描述及階層」(profile and level)、 「漸近式序列」(progressive sequence)、「色度格式」 , (chroma format)、「垂直大小」(vertical size)、「水平大小 10 」(horizontal size).......等等次攔位。故在·此較佳實施例 中,是將「延伸起始碼」4個位元填入0001以符合於 MPEG-2格式。並由於MPEG-1之格式是相容於MPEG-2 之Main@Main,故將「描述及階層」指定為main profile 與main level。而在「漸近式序列」方面係指MPEG-2可 15 以指定兩種輸出格式(漸近式與非漸近式)供選擇,但由於 MPEG-1僅支援漸近式,故將「漸近式序列」設定為1, •也就是指定為漸近式輸出。 「色度格式」係指晝面色彩之表現模式,在MPEG-2 中可用之色彩表現模式具有4:2:0、4:2:2與4:4:4三種。 20 但在MPEG-1之格式中,由於僅能使用4··2··0之表現模式 ,故將「色度格式」設定為4:2:0。而在「垂直大小」與 「水平大小」方面,由於在MPEG-1格式中,晝面之大小 僅以12bit來表示,而MPEG-2格式則進一步擴充為14bit 來表示,而此額外之雨個bit即放入至「垂直大小」與「 12 200408278 水平大小」之攔位中,故在此將「垂直大小」與「水平大 小」填入0即可。 5 10 15 20 接著’當MPEG-1之序列表頭已轉換為MpEG_2之序 列表頭後,又由於位於序列表頭後之序列資料包含有複數 圖像群組,而每-圖像群組則又包含_圖像群組表頭與— 個以上之圖像資料,故如第五⑻圖所示,料 圖像群組階層之圖像群組f料進行處理,而由於在 MPEG-2之圖像群組階層中,圖像群組表頭已為非必要(選The J MPEG data format conversion method performs step A) receiving an MPEG-1 data stream; step B) converting a sequence header, a group of pictures (GOP) header, and a picture (PIC) header of the MPEG_1 data stream Is the corresponding MPEG-2 header; and step C) maps the image data in the MPEG-1 data stream into 15 MPEG-2 format image data. More preferably, in a second preferred embodiment of the present invention, the present invention also provides a decoding system using the above method, the decoding system includes a conversion device and a decoding device. The conversion device is used to convert an MPEG-1 data stream into an MPEG-2 20 data stream, and has a conversion unit and a mapping unit coupled to each other. The conversion unit can receive the MPEG-1 data stream, and convert the header of the sequence hierarchy, the header of the picture group hierarchy, and the header of the picture hierarchy into the corresponding MPEG-2 table in the MPEG-1 data stream. Header format. The mapping unit receives the MPEG-1 data stream converted by the conversion unit, and performs variable-length (VLD) decoding on the converted image data of the 200408278 MPEG-1 data stream into MPEG-2 image data. . The decoding device receives the MPEG-2 data stream and decodes it into the original data. [Embodiment] The foregoing and other technical contents, features, and advantages of the present invention will be clearly understood in the following detailed description of the three preferred embodiments with reference to the drawings. Referring to the second figure, in the datastream / bitstream of MPEG (MPEG-1 / MPEG-2), the data structure is composed of one or a sequence of 10 or more, and in each sequence It contains a plurality of picture groups (GOP). The so-called image group refers to a group composed of many pictures (or daylight frames), and the daylight surface can be divided into three types according to its function: interactive daylight frame (I frame), prediction Day frame (P frame) and bidirectional day frame (B frame) image. With continuous playback on 15 sides of the day, the dynamic image is presented to the user. Each diurnal surface can be subdivided into several slices, and the slice can be further divided into several macroblocks (MacroBlock, MB). The macro block can be composed of four Luminance blocks and several chrominance blocks. Finally, each block has 8 × 8 pixels and defines 20 as the data structure of MPEG. The smallest coding unit. In the MPEG compression standard, 'Each day is a major coding unit', especially for the interactive day, because the prediction day is based on the interactive day as the reference picture for motion prediction, and the bidirectional day is Both the interactive diurnal plane and the predicted diurnal plane are used as reference diurnal planes. Therefore, the interactive diurnal 200408278 plane is used as the starting point for image compression. Therefore, the original image data is in the format of MPEG-1 or MPEG-2. When compressing, first define each image block in the interactive picture, and then apply discrete cosine transform to the pixel data of each image block. (DCT), that is, converting 5 pixel data from the time domain to the frequency domain 'and removing the less sensitive high-frequency parts of the human eye. Then quantization is applied, so that many DCT coefficients subjected to discrete cosine transform are quantized to zero. Then use Zig-zag scan to rearrange the quantized DCT coefficients, arrange the low-frequency coefficients | in the front and the high-frequency coefficients in the back. Finally, among the 10 DCT coefficients after interlaced scanning, the DC coefficients are subjected to differential signal modulation coding (DPCM), and the AC coefficients are run length encoded (RLE). Variable length coding (VLC), which completes the compression of the MPEG-1 / MPEG-2 format. Refer to the third figure. Therefore, in the standard structure of MPEG, 15 data can be sequentially divided into sequence layer (sequence layer), image group layer, image layer, stripe layer, and macro block layer. As well as the block hierarchy. In looking at the data of each level, it includes the header and data content. For example, in the sequence hierarchy, each sequence includes a sequence header and a sequence of data, where the sequence header records related MPEG information, such as a start code and a stream ID. ), Video parameters, bitstream parameters, etc., and the sequence data following the sequence list header contains several image groups (G0P0, GOP1, GOP2, ... .). Of course, as shown in the figure, each picture group hierarchy can be divided into picture group headers and picture group data, and each picture 10 200408278 group data contains several pictures (PIC1, PIC2, PIC3. .....), subdivided in this way, and finally reach the block level, which is the smallest unit for encoding. Of course, in the header of each level, different relevant information for each level is recorded. To simplify the description, it is not described in detail here, but those skilled in 5 should understand that the above information is clear Contained in the ISO / IEC 11172 specification of MPEG-1 and the ISO / IEC 18838 specification of MPEG-2. Therefore, before following the standard architecture, refer to the fourth figure for a first preferred embodiment. In the present invention, a MPEG data format 10 conversion method is provided, which can convert an MPEG-1 data stream into an MPEG-2 data stream, and performs the following steps: First, as shown in step 31, an MPEG data stream is accepted. -1 data stream. This data stream can be obtained from a storage medium (such as a hard disk, a compact disc) or transmitted through the Internet and other related communication devices. 15 Next, according to step 32, convert the sequence list /. Header of the MPEG-1 data stream, the picture group header, and the picture header into the corresponding MPEG-2 header format. The details are described below. . As mentioned earlier, since MPEG-2 is a superset of MPEG-1, when the International Standards Organization (ISO) defined the MPEG-2 format, it had already made 20 MPEG-2 in addition to the MPEG-1 format. Many extension data formats have been added to increase its scope of application. Therefore, in this step 32, as shown in Figure 5 (A), after receiving the MPEG-1 data stream, because the sequence header of MPEG-1 is read first, we understand MPEG-2 and MPEG-1 The sequence header differences are as follows: sequence extension and display extension fields have been added to the sequence header of 200408278 and MPEG-2, but the display extension stop is optional. For the sake of simplicity, just fill in the extension field to convert the sequence header of MPEG-1 to the sequence header of 5 MPEG-2. In more detail, the sequence extension field contains "extension start code", "profile and level", "progressive sequence", and "chroma format" , (chroma format), "vertical size", "horizontal size 10" ......... and so on. Therefore, in this preferred embodiment, 4 bits of "Extended Start Code" are filled in 0001 to conform to the MPEG-2 format. And because the format of MPEG-1 is compatible with Main @ Main of MPEG-2, "Description and Hierarchy" is designated as main profile and main level. In terms of "asymptotic sequence", it means that MPEG-2 can specify two output formats (asymptotic and non-asymptotic) for selection. However, since MPEG-1 only supports asymptotic sequence, the "asymptotic sequence" is set. Is 1, which is designated as an asymptotic output. "Chroma format" refers to the day-to-day color expression mode. The color expression modes available in MPEG-2 have three types: 4: 2: 0, 4: 2: 2, and 4: 4: 4. 20 However, in the MPEG-1 format, only the 4 · 2 ·· 0 expression mode can be used, so the "chroma format" is set to 4: 2: 0. In terms of "vertical size" and "horizontal size", in the MPEG-1 format, the size of the day surface is only represented by 12bit, while the MPEG-2 format is further expanded to 14bit to represent, and this additional rain The bit is placed in the blocks of "Vertical Size" and "12 200408278 Horizontal Size", so here you can fill in "Vertical Size" and "Horizontal Size" with 0. 5 10 15 20 Then 'When the sequence header of MPEG-1 has been converted to the sequence header of MpEG_2, because the sequence data located behind the sequence header contains a plurality of image groups, and each-image group is It also contains the _image group header and more than one image data, so as shown in the fifth figure, the image group f of the image group hierarchy is processed. In the image group hierarchy, the image group header is optional (select
擇性),故在此階層巾,是將刪w之圖像群組表頭刪 去以轉換為MPEG-2之圖像群組階層資料。 更進一步’如第五(C)圖所示,在圖像階層中,類似 於上述序列階層中之概念,故在此將刪㈤之圖像表頭 中填入圖像編碼延伸(PIC CC)ding extensi(m)攔位以轉換為 MPEG-2之圖像表頭。當然,此圖像編石馬延伸搁位包含有 「順向水平編碼」(f—hor—c〇d)、「順向垂直編碼」 (f—ver—code)、「逆向水平編碼」(b—h〇r—c〇de)、「逆向垂直 、扁馬」(b—ver一code) ......等次攔位。由於MPEG-1之格 式中僅有一組順向編碼(f—c〇de)來作動態補償之向量計算 ,而MPEG-2中則擴充為垂直向量與水平向量匕組,故在 此僅需將MPEG]之圖像表頭中的順向編碼内容複製到此 圖像編碼攔位中,即可將刪G]之圖像表頭轉換為 MPEG-2之圖像表頭。 、(Optional), so in this hierarchy, the deleted image group header is deleted to be converted into MPEG-2 image group hierarchical data. Furthermore, as shown in the fifth (C) diagram, in the image hierarchy, similar to the concept in the sequence hierarchy described above, the pruned image header is filled with the image coding extension (PIC CC). ding extensi (m) block to convert to MPEG-2 picture header. Of course, this image editing stone horse extension shelf includes "forward horizontal coding" (f-hor-c0d), "forward vertical coding" (f-ver-code), and "reverse horizontal coding" (b —H〇r — code), “reverse vertical, flat horse” (b-ver-code) ... and other stop. In the MPEG-1 format, there is only one set of forward encoding (f-code) for vector calculation of dynamic compensation, while in MPEG-2, it is extended to a set of vertical and horizontal vectors, so here only the The forward-coded content in the picture header of MPEG] is copied to this picture coding block, and the picture header of G] can be converted into the picture header of MPEG-2. ,
故如表一所示, 之序列階層、圖像階 其係表示經由整理而得之在MPEG-1 層,以及圖像階層中,所要新增或刪 13 200408278 去之欄位: 表一 序列 表頭 序列延伸欄位(增加) Extension Profile Startcode & level Progressive Chroma Sequence format … 顯示延伸欄位(選擇性—不增加) Video Color format Description Color Primary Transfer Charactor … 圖像 群組 表頭 刪除 圖像 表頭 圖像延伸欄位(增加) F for cod F ver cod e e B for co de B for c ode … 然而,惟需指明者,上述之序列延伸欄位中,尚有諸 如「水平大小延伸」(hor_size ext.)、「垂直大小延伸」 (ver_size ext·)、「位元率延伸」(bitrate ext.).......等次攔位 5 ;而圖像延伸欄位中尚具有「内部 dc 預測」 (intra—dc一prec.)、「圖像結構」(picture structure).......等次 鲁 欄位。由於此為熟習此技藝者所能輕易了解且為簡化說明 起見,在此不再——說明,但吾人可利用上述相同之概念 來將序列延伸欄位以及圖像延伸欄位之各個次欄位填入相 10 對應之資料,即可將MPEG-1之序列表頭、圖像群組表頭 ,以及圖像表頭轉換為MPEG-2各階層之相對應表頭。 再者,由於在像條階層以下之MPEG-1資料格式係與 MPEG-2資料格式相同,換言之,即包含有複數像條之圖像 資料係為相同,其差異僅在於最後可變長度編碼(VLC)之不 14 200408278 同。原因在於進行可變長度編碼時,MPEG-1係採用 ISO/IEC 11172規格書中所指定之一 MPEG-1可變長度編碼 表(VLC table)來進行編碼而得,而MPEG-2則在其ISO/IEC 18838規格書中引入一全新之MPEG-2可變長度編碼表 5 (intra VLC table)來進行可變長度編碼。 故在此步驟33中,參閱第六圖,係先(1)對應於 MPEG-1可變長度編碼表,以映射方式將MPEG-1圖像資料 以下之資料解碼為(run,level)型式之序列信號。接著,(2) 對應於MPEG-2可變長度編碼表,再將序列信號以參照編 10 碼表之方式來作編碼,故將MPEG-1之圖像資料轉換為 MPEG-2格式之圖像資料。 因此,綜合上述步驟3 1〜33,步驟32將序列表頭、圖 像組表頭與圖像表頭加以轉換,再加上步驟33將圖像資料 加以轉換,即能將一 MPEG-1之資料流轉換為MPEG-2之 15 資料流,確實達到本發明之目的。 另外,參閱第七圖,在一第二較佳實施例中,本發明 亦提供一種利用上述MPEG資料格式轉換方法之解碼系統5 ,可應用於一單晶片(system on a chip,SOC)系統或資訊家 電(ΙΑ)中。此解碼系統包含一轉換模組51,及一解碼模組 20 52。 轉換模組51具有相耦接之一轉換單元511及一映射單 元512,其中,轉換單元511是用以接收一 MPEG-1資料流 ,並將一 MPEG-1資料流之序列表頭(Sequence header)、圖 像組(GOP)表頭,以及圖像(PIC)表頭轉換為相對應之 15 200408278 . MPEG-2表頭格式,換言之,轉換單元511係可進行前述之 步驟32。 而映射單元512則具有一 MPEG-1可變長度編碼表及 一 MPEG-2可變長度編碼表,並可接受來自於轉換單元511 5 轉換後之MPEG_1資料流,並將此資料流中之圖像資料先 對應於MPEG-1.之可變長度編碼表,解碼為(run,level)型式 之序列信號,再對應於MPEG-2之可變長度編碼表,將 (mn,level)型式之序列信號再編碼為MPEG-2格式之圖像資 • 料。 10 解碼模組52,在本實施例中,係指一 MPEG-2解碼電 路,可接收一 MPEG-2資料流並將其解碼為原始之影像資 料。當然,此解碼模組52具有一可變長度解碼(VLD)單元 — 521、一反量化運算(Q-1)單元522、一逆向離散餘弦轉換編 - 碼(IDCT)單元523,及一動態補償(MC)單元524,由於此乃 15 習用電路,故不再贅述。 較佳地,在本實施例中,轉換模組51係以軟體方式被 φ 編窝成複數指令,並可被編譯為電腦程式碼後儲存在一電 腦可讀取之記錄媒體中,例如唯讀記憶體、快閃記憶體、 硬碟或其它相類似之光學或磁性儲存媒體中,並當被處理 20 器(圖未示)載入而加以執行時,即能夠執行上述功能。 故當MPEG資料流進入此解碼系統5時,首先讀入序 頭表頭,並以序列表頭中所包含之資料(stream ID)來判斷是 MPEG-1或MPEG-2之資料流。若為MPEG-1之資料流,則 交予轉換模組51加以轉換為MPEG-2之資料流後,再傳送 16 200408278 給解碼模組52加以解碼成為影像資料。當然,若是MPEG-2之資料流,則直接由解碼模組52加以解碼成為原始之影 像資料。 必需說明的是,在本實施例中,雖是以軟體來進行 5 MPEG-1資料流之轉換,但由於在將MPEG-1資料流轉換為 MPEG-2資料流之過程中,僅需進行表頭之轉換與可變長度 編碼之解碼,而不需進行最耗費處理器(圖未示)資源的「反 量化運算」、「逆向離散餘弦轉換」,以及「動態補償」等步 驟,換言之,雖此三者佔了 MPEG解碼總運算量之90%以 10 上,但此處並不加以進行,僅單純施以表頭之轉換與可變 長度編碼之映射動作即能完成MPEG_1之資料格式轉換。 故在不增加處理器過多負載之前提下,僅以一組MPEG-2 解碼電路並搭配上述MPEG資料格式轉換方法即能同時達 到MPEG-1與MPEG-2資料流之解碼功能,故相對於習知 15 技術而言,能夠以較低之硬體成本來建構一單晶片系統或 資訊家電。 此外.,參閱第八圖,在一第三較佳實施例中,揭示一 種以上述概念所得之電子裝置6,此電子裝置6具有一作業 系統61、一處理器62、一讀取模組63、一解碼模組64, 20 一顯示器65,及一轉換模組66。同時此電子裝置6内並建 置有複數應用程式67供使用者所使用。實體上,作業系統 61與應用程式67係儲存在一儲存媒體中,例如記憶體、硬 碟、光碟片,或其它相類似之磁性或光學儲存媒體上。解 碼模組64在此亦指一 MPEG-2解碼電路。 17 200408278 、 轉換模組66可採應用程式介面(API)來加速程式之編寫 ,並已成為應用程式其中之一。由於關於轉換模組66之技 術已詳細揭露於上述之第一、第二較佳實施例中,故不再 贅述。故當使用者藉由一讀取模組63(例如光碟機)自一儲 5 存媒體7中讀入MPEG資料流時,若為MPEG-1之資料流 則藉由轉換模組66加以轉換(由處理器62加以執行)為 MPEG-2資料流後,再傳送至解碼模組64加以解碼為原始 影像資料後,最後透過顯示器65顯示在使用者面前;若是 p MPEG-2之資料流則直接交予解碼模組64(由作業系統61指 10 派、管理)加以解碼,故僅需具備一組解碼模組64即能使電 子裝置6同時具備有MPEG-1與MPEG-2資料流之影像播 放功能。 綜合上述,本發明提供一種能在不大幅增加處理器負 載之前提下加以實現之MPEG資料格式轉換方法,更佳的 15 是,利用此方法,故僅需一組MPEG-2解碼電路即能具備 有MPEG-1與MPEG-2資料流之解碼功能,確實達到節省 • 硬體成本之目的。 惟以上所述者,僅為本發明之較佳實施例而已,當不 能以此限定本發明實施之範圍,即大凡依本發明申請專利 20 範圍及發明說明書内容所作之簡單的等效變化與修飾,皆 應仍屬本發明專利涵蓋之範圍内。 【圖式簡單說明】 第一圖是一示意圖,說明習知之MPEG-1與MPEG-2 解碼電路」 18 200408278 第二圖是一示意圖,說明MPEG規格之資料結構; 第三圖是一示圖,說明MPEG各階層之資料結構; 第四圖是一流程圖,說明本發明MPEG資料格式轉換 方法之步驟; 5 第五(A)〜(C)圖是在序列階層、圖像群組階層、圖像階 層中,MPEG-1與MPEG-2格式差異處之示意圖; 第六圖是一示意圖,說明以映射方式將MPEG-1之圖 像資料轉換為MPEG-2之圖像資料; 第七圖是一示意圖,說明本發明之一第二較佳實施例 10 ;及 第八圖是一示意圖,說明本發明之一第三較佳實施例Therefore, as shown in Table 1, the sequence level and image level indicate the fields that need to be added or deleted in the MPEG-1 layer and the image level after finishing. Header Sequence Extension Field (Addition) Extension Profile Startcode & level Progressive Chroma Sequence format… Show Extension Field (optional-no increase) Video Color format Description Color Primary Transfer Charactor… Image Group Header Delete Image Header Image extension field (increase) F for cod F ver cod ee B for co de B for co ode… However, if you need to specify, the above sequence extension field still has such things as "hor_size ext" .), "Vertical size extension" (ver_size ext ·), "bitrate extension" (bitrate ext.) ... etc. 5th stop 5; and the image extension field still has "internal dc" Prediction "(intra-dc-prec.)," Picture structure "(...) and so on. As this is easily understood by those skilled in this art and for the sake of simplicity, it will not be described here anymore, but I can use the same concept as above to extend the sequence extension field and each sub-field of the image extension field. Fill in the data corresponding to phase 10 to convert the sequence header, image group header, and image header of MPEG-1 into corresponding headers of each layer of MPEG-2. Moreover, since the MPEG-1 data format below the strip level is the same as the MPEG-2 data format, in other words, the image data containing the plural strips is the same, and the difference is only in the final variable length encoding ( VLC) No. 14 200408278 Same. The reason is that when performing variable-length encoding, MPEG-1 uses one of the MPEG-1 variable-length encoding tables (VLC tables) specified in the ISO / IEC 11172 specification for encoding. MPEG-2 A new MPEG-2 variable length coding table 5 (intra VLC table) is introduced in the ISO / IEC 18838 specification for variable length coding. Therefore, in this step 33, referring to the sixth figure, first (1) corresponds to the MPEG-1 variable-length encoding table, and maps the data below the MPEG-1 image data into a (run, level) type. Sequence signals. Next, (2) Corresponds to the MPEG-2 variable-length encoding table, and then encodes the sequence signal by referring to the 10-code table. Therefore, the MPEG-1 image data is converted into an MPEG-2 format image. data. Therefore, by synthesizing the above steps 3 1 to 33, step 32 converts the sequence table header, the image group header and the image header, plus step 33 to convert the image data, which can convert an MPEG-1 The conversion of a data stream into a 15 data stream of MPEG-2 does indeed achieve the object of the present invention. In addition, referring to the seventh figure, in a second preferred embodiment, the present invention also provides a decoding system 5 using the above-mentioned MPEG data format conversion method, which can be applied to a single-chip (system on a chip, SOC) system or Information appliances (ΙΑ). The decoding system includes a conversion module 51 and a decoding module 20 52. The conversion module 51 has a conversion unit 511 and a mapping unit 512 which are coupled to each other. The conversion unit 511 is used to receive an MPEG-1 data stream and send a Sequence header of the MPEG-1 data stream. ), The picture group (GOP) header, and the picture (PIC) header are converted to the corresponding 15 200408278. MPEG-2 header format, in other words, the conversion unit 511 can perform step 32 described above. The mapping unit 512 has an MPEG-1 variable-length encoding table and an MPEG-2 variable-length encoding table. The mapping unit 512 can accept the MPEG_1 data stream converted from the conversion unit 51 15 and map the data in the data stream. The image data first corresponds to the variable length encoding table of MPEG-1. It is decoded into a sequence signal of (run, level) type, and then corresponds to the variable length encoding table of MPEG-2. The sequence of (mn, level) type is The signal is re-encoded as image data in MPEG-2 format. 10 Decoding module 52, in this embodiment, refers to an MPEG-2 decoding circuit that can receive an MPEG-2 data stream and decode it into the original image data. Of course, this decoding module 52 has a variable length decoding (VLD) unit-521, an inverse quantization operation (Q-1) unit 522, an inverse discrete cosine transform coding-coding (IDCT) unit 523, and a dynamic compensation (MC) unit 524. Since this is a 15 conventional circuit, it will not be described again. Preferably, in this embodiment, the conversion module 51 is compiled into a plurality of instructions by φ in software, and can be compiled into a computer program code and stored in a computer-readable recording medium, such as read-only The memory, flash memory, hard disk, or other similar optical or magnetic storage media can execute the above functions when they are loaded and executed by a processing device (not shown). Therefore, when the MPEG data stream enters the decoding system 5, the sequence header is first read, and the data (stream ID) contained in the sequence header is used to judge whether it is an MPEG-1 or MPEG-2 data stream. If it is an MPEG-1 data stream, it is passed to the conversion module 51 to be converted into an MPEG-2 data stream, and then 16 200408278 is transmitted to the decoding module 52 to be decoded into image data. Of course, if it is an MPEG-2 data stream, it is directly decoded by the decoding module 52 into the original video data. It must be noted that in this embodiment, although the conversion of 5 MPEG-1 data streams is performed by software, only the table is needed in the process of converting MPEG-1 data streams to MPEG-2 data streams. The conversion of the header and the decoding of the variable-length encoding do not require the steps of "inverse quantization operation", "inverse discrete cosine conversion", and "dynamic compensation" that consume the most processor (not shown) resources. In other words, although These three account for 90% or more of the total calculation amount of MPEG decoding, but they are not carried out here. Only the conversion of the header and the mapping action of variable length coding can complete the data format conversion of MPEG_1. Therefore, before increasing the processor's excessive load, it is possible to achieve the decoding function of MPEG-1 and MPEG-2 data streams with only one set of MPEG-2 decoding circuits and the above-mentioned MPEG data format conversion method. In terms of technology, a single-chip system or an information appliance can be constructed at a lower hardware cost. In addition, referring to the eighth figure, in a third preferred embodiment, an electronic device 6 obtained by the above concept is disclosed. The electronic device 6 has an operating system 61, a processor 62, and a reading module 63. , A decoding module 64, 20 a display 65, and a conversion module 66. At the same time, a plurality of application programs 67 are built in the electronic device 6 for use by users. Physically, the operating system 61 and the application program 67 are stored in a storage medium, such as a memory, a hard disk, an optical disc, or other similar magnetic or optical storage media. The decoding module 64 is also referred to herein as an MPEG-2 decoding circuit. 17 200408278 、 Conversion module 66 can adopt application programming interface (API) to accelerate the writing of programs, and has become one of the applications. Since the technology of the conversion module 66 has been disclosed in detail in the first and second preferred embodiments described above, it will not be described again. Therefore, when the user reads the MPEG data stream from a storage 5 storage medium 7 through a reading module 63 (such as an optical disc drive), if it is an MPEG-1 data stream, it is converted by the conversion module 66 ( It is executed by the processor 62). After being MPEG-2 data stream, it is transmitted to the decoding module 64 to be decoded into the original image data, and then displayed to the user through the display 65; if it is a p MPEG-2 data stream, it is directly Handed to the decoding module 64 (delivered and managed by the operating system 61 refers to 10), so only one set of decoding module 64 is needed to enable the electronic device 6 to have both MPEG-1 and MPEG-2 data streams. Play function. In summary, the present invention provides an MPEG data format conversion method that can be implemented without significantly increasing the processor load. A better 15 is that with this method, only one set of MPEG-2 decoding circuits is needed. With MPEG-1 and MPEG-2 data stream decoding function, it can achieve the goal of saving hardware cost. However, the above are only the preferred embodiments of the present invention. When the scope of implementation of the present invention cannot be limited by this, that is, the simple equivalent changes and modifications made according to the scope of the patent application 20 of the present invention and the contents of the invention specification , All should still fall within the scope of the invention patent. [Brief description of the diagram] The first diagram is a diagram illustrating the conventional MPEG-1 and MPEG-2 decoding circuits. "18 200408278 The second diagram is a diagram illustrating the data structure of the MPEG specification. The third diagram is a diagram. Describe the data structure of each layer of MPEG; The fourth diagram is a flowchart illustrating the steps of the MPEG data format conversion method of the present invention; 5 The fifth (A) ~ (C) diagram is at the sequence level, image group level, In the image hierarchy, the schematic diagram of the differences between the MPEG-1 and MPEG-2 formats; The sixth diagram is a diagram illustrating the mapping of MPEG-1 image data to MPEG-2 image data; the seventh diagram is A schematic diagram illustrating a second preferred embodiment 10 of the present invention; and an eighth diagram is a schematic diagram illustrating a third preferred embodiment of the present invention
19 200408278 【圖式之主要元件代表符號簡單說明】 11 MPEG-1可變長度解碼電路 52 解碼裝置 12 MPEG-1反量化運算電路 13 MPEG-1逆向離散餘弦轉換 電路 14 MPEG-1動態補償電路 21 MPEG-2可變長度解碼電路 22 MPEG-2反量化運算電路 23 MPEG-2逆向離散餘弦轉換 電路 24 MPEG-2動態補償電路 31 步驟 32 步驟 33 步驟 51 轉換裝置 511 轉換單元 512 映射單元19 200408278 [Simplified explanation of the main symbols of the diagram] 11 MPEG-1 variable length decoding circuit 52 Decoding device 12 MPEG-1 inverse quantization operation circuit 13 MPEG-1 inverse discrete cosine conversion circuit 14 MPEG-1 dynamic compensation circuit 21 MPEG-2 variable-length decoding circuit 22 MPEG-2 inverse quantization operation circuit 23 MPEG-2 inverse discrete cosine conversion circuit 24 MPEG-2 dynamic compensation circuit 31 step 32 step 33 step 51 conversion device 511 conversion unit 512 mapping unit
521 MPEG-2可變長度解碼單元 522 MPEG_2反量化運算單元 523 MPEG-2逆向離散餘弦轉換 trti 一 早兀 524 MPEG-2動態補償單元 6 具影像播放功能之電子裝 置 61 作業系統 62 處理器 63 讀取模組 64 解碼模組 65 顯示器 66 轉換模組 67 應用程式 20521 MPEG-2 variable-length decoding unit 522 MPEG_2 inverse quantization operation unit 523 MPEG-2 inverse discrete cosine conversion trti early 524 MPEG-2 dynamic compensation unit 6 electronic device with video playback function 61 operating system 62 processor 63 read Module 64 Decoding module 65 Display 66 Conversion module 67 Application 20