TW202409960A - Method for handling irregular input for video processor - Google Patents

Method for handling irregular input for video processor Download PDF

Info

Publication number
TW202409960A
TW202409960A TW112119746A TW112119746A TW202409960A TW 202409960 A TW202409960 A TW 202409960A TW 112119746 A TW112119746 A TW 112119746A TW 112119746 A TW112119746 A TW 112119746A TW 202409960 A TW202409960 A TW 202409960A
Authority
TW
Taiwan
Prior art keywords
frame
input
buffer
output
frames
Prior art date
Application number
TW112119746A
Other languages
Chinese (zh)
Other versions
TWI844376B (en
Inventor
張智
林義峰
張孝恩
Original Assignee
聯詠科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 聯詠科技股份有限公司 filed Critical 聯詠科技股份有限公司
Publication of TW202409960A publication Critical patent/TW202409960A/en
Application granted granted Critical
Publication of TWI844376B publication Critical patent/TWI844376B/en

Links

Images

Abstract

An operational method for a video processor includes the following steps: receiving a series of input frames; calculating a buffer stage value according to the series of input frames, wherein the buffer stage value corresponds to a status of the input frames stored in a frame buffer of the video processor; and selecting a frame set from the input frames stored in the frame buffer for generating an interpolated frame as an output frame to be output by the video processor according to the buffer stage value.

Description

用來處理視訊處理器之不規則輸入的方法Method for processing irregular input of a video processor

本發明係指一種進行運動估計與運動補償(Motion Estimation and Motion Compensation,MEMC)的方法,尤指一種可在運動估計與運動補償中用來處理不規則輸入的方法。The present invention refers to a method for motion estimation and motion compensation (MEMC), and in particular, to a method that can be used to handle irregular inputs in motion estimation and motion compensation.

運動估計與運動補償(Motion Estimation and Motion Compensation,MEMC)是一種用於幀插補(frame interpolation)的技術,可讓一系列影像幀在較高幀率(frame rate)之下進行顯示。舉例來說,若30赫茲(Hz)的原始視訊(例如電影影片)需要以60赫茲的頻率顯示,則原始視訊的每二個相鄰輸入幀之間需加入一插補幀,進而實現兩倍的幀率。Motion Estimation and Motion Compensation (MEMC) is a technology used for frame interpolation, which allows a series of image frames to be displayed at a higher frame rate. For example, if a 30 Hz original video (such as a movie video) needs to be displayed at a frequency of 60 Hz, an interpolation frame needs to be added between every two adjacent input frames of the original video to achieve twice the frame rate.

假設來自於視訊提供單元的原始視訊具有24赫茲的幀率而欲在顯示面板上顯示的影像為60赫茲時,需透過幀轉換技術將每二個輸入幀轉換為五個輸出幀。為了避免輸出的畫面上出現抖動(judder),可利用影片模式(film mode)32的規律(cadence)來執行插補,其中,二輸入幀可合併以產生至少一插補幀。運動估計與運動補償技術使得視訊處理器可決定適合的輸入幀並利用正確的相位係數來執行插補,以輸出流暢的畫面。Assuming that the original video from the video provider has a frame rate of 24 Hz and the image to be displayed on the display panel is 60 Hz, frame conversion technology is used to convert every two input frames into five output frames. In order to avoid judder on the output picture, interpolation can be performed using the cadence of film mode 32, in which two input frames can be combined to generate at least one interpolated frame. Motion estimation and motion compensation technology allow the video processor to determine the appropriate input frame and perform interpolation using the correct phase coefficient to output a smooth picture.

傳統上,當視訊處理器取得輸入幀及輸出幀的資訊並據以決定影片模式時,可利用記錄有輸入幀及相關相位資訊的對應表來執行插補,且視訊處理器可透過查表來產生插補幀。然而,若輸入幀未遵循輸入規則但插補操作仍根據查表來進行的情況下,視訊處理器可能會拿取錯誤的來源輸入幀且/或採用錯誤的相位係數來執行插補,導致輸出的畫面出現抖動。舉例來說,若行動電話中的視訊處理器係根據行動產業處理器介面(Mobile Industry Processor Interface,MIPI)規範的指令模式來接收輸入幀,輸入幀的輸入時序容易受到中央處理單元(Central Processing Unit,CPU)或圖形處理單元(Graphics Processing Unit,GPU)的狀態干擾,因此當圖形處理單元過度忙碌的情況下會造成輸入影像的延遲。輸入時序的延遲或不規則通常難以預測,因此,習知透過查表的方法可能無法適當地處理這樣的不規則輸入問題。Traditionally, when the video processor obtains the information of the input frame and the output frame and determines the video mode based on it, a correspondence table recording the input frame and related phase information can be used to perform interpolation, and the video processor can perform interpolation by looking up the table. Generate interpolated frames. However, if the input frame does not follow the input rules but the interpolation operation is still based on a lookup table, the video processor may take the wrong source input frame and/or use the wrong phase coefficient to perform interpolation, resulting in the output The screen appears to be shaking. For example, if the video processor in a mobile phone receives input frames according to the instruction mode of the Mobile Industry Processor Interface (MIPI) specification, the input timing of the input frames is easily affected by the Central Processing Unit (Central Processing Unit). , CPU) or graphics processing unit (Graphics Processing Unit, GPU) state interference, so when the graphics processing unit is too busy, it will cause a delay in the input image. Delays or irregularities in input timing are often difficult to predict, and therefore conventional lookup table methods may not be able to properly handle such irregular input problems.

舉例來說,在24赫茲的輸入視訊轉換成60赫茲的輸出視訊的應用中,每2個輸入幀用來產生5個輸出幀,因此,用來指示輸入幀接收的輸入更新訊號通常具有重複序列“10010”,如表1所示。藉由查詢一參考表,可得到相位步階等於2/5,使得相位係數形成遞迴序列0、2/5、4/5、1/5及3/5,且插補幀係利用當前輸入幀及先前輸入幀以相對應的相位係數產生。 索引 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 輸入幀 A B C D E F 輸入更新訊號 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 相位步階 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 當前幀 A A A B B B C C D D E E E F F 先前幀 Z Z Z A A A B B C C D D D E E 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 表1 For example, in an application that converts 24 Hz input video to 60 Hz output video, every 2 input frames are used to generate 5 output frames. Therefore, the input update signal used to indicate the receipt of the input frame usually has a repeating sequence. "10010", as shown in Table 1. By querying a reference table, it can be obtained that the phase step is equal to 2/5, so that the phase coefficients form a recursive sequence of 0, 2/5, 4/5, 1/5 and 3/5, and the interpolation frame uses the current input The frame and the previous input frame are generated with corresponding phase coefficients. index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 input frame A B C D E F Enter update signal 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 phase step 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 current frame A A A B B B C C D D E E E F F previous frame Z Z Z A A A B B C C D D D E E Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 Table 1

然而,如表1所示,輸入幀C預期在索引6的輸出幀期間到達,但延遲到索引7的下一個輸出幀期間才到達。根據參考表,由於輸入幀C尚未到達,視訊處理器將從特定的幀緩衝器拿取輸入幀B及A以產生用於索引6的插補幀。因此,從索引5至索引6係選擇相同的幀組來執行插補,但相位係數從3/5變為0,使得輸出的畫面不正常地回退,容易導致輸出的畫面產生影像抖動。However, as shown in Table 1, input frame C is expected to arrive during the output frame at index 6, but is delayed until the next output frame at index 7. According to the reference table, since the input frame C has not yet arrived, the video processor will fetch the input frames B and A from the specific frame buffer to generate the interpolated frame for index 6. Therefore, the same frame group is selected from index 5 to index 6 to perform interpolation, but the phase coefficient changes from 3/5 to 0, causing the output picture to roll back abnormally and easily causing image jitter in the output picture.

同樣的問題亦可能發生在具有規律或下拉(pulldown)的應用,其中,輸入幀係以60赫茲的頻率接收重複幀,而輸出幀係以60赫茲的頻率輸出,如表2所示。 索引 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 輸入幀 A1 A2 A3 B1 B2 B3 C1 C2 D1 D2 E1 E2 E3 F1 F2 輸入更新訊號 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 幀差值 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 相位步階 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 當前幀 A A A B B B C C D D E E E F F 先前幀 Z Z Z A A A B B C C D D D E E 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 表2 The same problem can also occur in applications with regular or pulldown, where the input frame is received as a repeated frame at 60 Hz and the output frame is output at 60 Hz, as shown in Table 2. index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Input frame A1 A2 A3 B1 B2 B3 C1 C2 D1 D2 E1 E2 E3 F1 F2 Input update signal 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Frame Difference 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 Phase Step 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 Current frame A A A B B B C C D D E E E F F Previous frame Z Z Z A A A B B C C D D D E E Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 Table 2

在此例中,輸入幀A2及A3係藉由複製輸入幀A1而產生,輸入幀B2及B3係藉由複製輸入幀B1而產生,輸入幀C2係藉由複製輸入幀C1而產生,並以此類推。幀差值指示當前接收的輸入幀是否不同於前一輸入幀抑或由前一輸入幀複製而成。同樣地,由於輸入幀C1的延遲,在索引6的輸出幀期間出現輸出畫面的不正常回退。In this example, input frames A2 and A3 are generated by copying input frame A1, input frames B2 and B3 are generated by copying input frame B1, input frame C2 is generated by copying input frame C1, and And so on. The frame difference value indicates whether the currently received input frame is different from the previous input frame or is a copy of the previous input frame. Likewise, due to the delay of input frame C1, an abnormal rollback of the output picture occurs during the output frame of index 6.

有鑑於此,習知技術實有改進之必要。In view of this, there is a real need to improve learning technology.

因此,本發明之主要目的即在於提出一種用於視訊處理器的影像處理方法,以藉由判斷不正常的情形並對應選擇幀組和計算相位步階來處理不規則輸入的問題,進而解決上述問題。Therefore, the main purpose of the present invention is to propose an image processing method for a video processor to handle the problem of irregular input by judging abnormal situations and correspondingly selecting frame groups and calculating phase steps, thereby solving the above-mentioned problems. problem.

本發明之一實施例揭露一種用於視訊處理器的操作方法,包含有下列步驟:接收一系列輸入幀;根據該系列輸入幀來計算一緩衝級值(buffer stage value),其中,該緩衝級值對應於該視訊處理器中的一幀緩衝器所儲存的輸入幀的狀態;以及根據該緩衝級值,從該幀緩衝器所儲存的輸入幀中選擇一幀組用以產生一插補幀,作為該視訊處理器所輸出的一輸出幀。An embodiment of the present invention discloses an operating method for a video processor, which includes the following steps: receiving a series of input frames; calculating a buffer stage value according to the series of input frames, wherein the buffer stage value The value corresponds to the state of the input frame stored in a frame buffer in the video processor; and based on the buffer level value, a frame group is selected from the input frame stored in the frame buffer to generate an interpolation frame , as an output frame output by the video processor.

本發明之另一實施例揭露一種用於視訊處理器的操作方法,包含有下列步驟:接收一系列輸入幀;根據該系列輸入幀之一輸入幀率與該視訊處理器所輸出的一系列輸出幀之一輸出幀率的相對關係,判斷一預期輸入間距值;判斷一實際輸入間距值是否不同於該預期輸入間距值;當判斷該實際輸入間距值不同於該預期輸入間距值時,計算一相位步階並取得該相位步階,該相位步階不同於根據該輸入幀率與該輸出幀率的相對關係來決定的一正常相位步階;以及利用計算出的該相位步階,根據一所選幀組來產生一插補幀,作為該系列輸出幀中的一輸出幀進行輸出。Another embodiment of the present invention discloses an operating method for a video processor, which includes the following steps: receiving a series of input frames; and based on an input frame rate of one of the series of input frames and a series of outputs output by the video processor. The relative relationship between the output frame rate of one frame is used to determine an expected input spacing value; to determine whether an actual input spacing value is different from the expected input spacing value; when it is determined that the actual input spacing value is different from the expected input spacing value, calculate an Phase step and obtain the phase step, the phase step is different from a normal phase step determined according to the relative relationship between the input frame rate and the output frame rate; and using the calculated phase step, according to a The frame group is selected to generate an interpolated frame, which is output as an output frame in the series of output frames.

第1圖為本發明實施例一顯示系統10之示意圖。如第1圖所示,顯示系統10可以是例如電視或螢幕,其可接收並顯示由一視訊提供單元12提供的具有一系列影像幀的原始視訊,視訊提供單元12可以是例如數位視訊光碟(Digital Video Disc,DVD)播放器或視訊串流服務提供者,其可和顯示系統10透過有線或無線網路進行通訊。顯示系統10包含有一視訊處理器106、一顯示驅動裝置108及一顯示面板110。一般來說,原始視訊的幀率不同於欲在顯示面板110上顯示的幀率。視訊處理器106可包含一視訊控制積體電路(Video Controller IC)及一幀率轉換積體電路(Frame Rate Converter IC,FRC IC),用來對幀率通常較低的原始視訊進行轉換以產生幀率較高的一系列輸出幀,以透過顯示面板110進行顯示。或者,視訊處理器106可以是具有幀率轉換功能的視訊控制積體電路,亦即,第1圖所示的幀率轉換器104可視為獨立的幀率轉換積體電路或是位於視訊控制積體電路內部的幀率轉換電路。在此例中,當幀率轉換器104接收到具有2個輸入幀A及B的24赫茲的輸入視訊時,可將2個輸入幀A及B轉換為60赫茲的5個影像幀A、A、A、B、B,且視訊處理器106可根據該些影像幀來執行運動估計與運動補償(Motion Estimation and Motion Compensation,MEMC),以產生適合的插補幀。Figure 1 is a schematic diagram of a display system 10 according to Embodiment 1 of the present invention. As shown in FIG. 1 , the display system 10 can be, for example, a television or a screen, which can receive and display original video having a series of image frames provided by a video providing unit 12 , which can be, for example, a digital video disc (digital video disc). Digital Video Disc (DVD) player or video streaming service provider, which can communicate with the display system 10 through a wired or wireless network. The display system 10 includes a video processor 106, a display driving device 108 and a display panel 110. Generally, the frame rate of the original video is different from the frame rate to be displayed on the display panel 110 . The video processor 106 may include a video control integrated circuit (Video Controller IC) and a frame rate converter IC (Frame Rate Converter IC, FRC IC) for converting original video with a usually low frame rate to generate A series of output frames with a higher frame rate are displayed through the display panel 110 . Alternatively, the video processor 106 can be a video control integrated circuit with a frame rate conversion function. That is, the frame rate converter 104 shown in Figure 1 can be regarded as an independent frame rate conversion integrated circuit or located in the video control integrated circuit. Frame rate conversion circuit inside the body circuit. In this example, when the frame rate converter 104 receives an input video of 24 Hz with 2 input frames A and B, it can convert the 2 input frames A and B into 5 image frames A, A of 60 Hz. , A, B, B, and the video processor 106 can perform motion estimation and motion compensation (MEMC) according to these image frames to generate appropriate interpolation frames.

在另一實施例中,視訊處理器106可包含圖形處理單元(Graphics Processing Unit,GPU)以及獨立的幀率轉換積體電路,或者視訊處理器106可以是一圖形處理單元,其內部包含有內建的幀率轉換電路。In another embodiment, the video processor 106 may include a graphics processing unit (GPU) and an independent frame rate conversion integrated circuit, or the video processor 106 may be a graphics processing unit including a built-in frame rate conversion circuit.

視訊處理器106另可包含一幀緩衝器105。幀緩衝器105可用來儲存所接收的輸入幀,使得視訊處理器106可從幀緩衝器105取得所選擇的輸入幀來執行插補。在此例中,幀緩衝器105係與視訊處理器106(如視訊控制積體電路)整合。在另一實施例中,視訊處理器106可從一或多個獨立的幀緩衝器存取輸入幀,此幀緩衝器為與視訊處理器106分離的外部記憶體裝置。The video processor 106 may also include a frame buffer 105 . The frame buffer 105 can be used to store the received input frames, so that the video processor 106 can obtain the selected input frames from the frame buffer 105 to perform interpolation. In this example, frame buffer 105 is integrated with video processor 106 (eg, a video control integrated circuit). In another embodiment, video processor 106 may access input frames from one or more independent frame buffers, which are external memory devices separate from video processor 106 .

顯示驅動裝置108可將影像資料轉換為資料電壓訊號,並透過資料電壓訊號來驅動顯示面板110顯示影像幀。顯示驅動裝置108可包含時序控制器、源極驅動裝置、閘極驅動裝置、及/或任何可用來驅動顯示面板110的其它裝置。顯示面板110可以是任何類型,如液晶顯示面板(Liquid Crystal Display,LCD)、發光二極體(Light-Emitting Diode,LED)顯示器、電漿顯示面板(Plasma Display Panel,PDP),但不限於此。The display driver 108 can convert the image data into a data voltage signal, and drive the display panel 110 to display the image frame through the data voltage signal. The display driver 108 can include a timing controller, a source driver, a gate driver, and/or any other device that can be used to drive the display panel 110. The display panel 110 can be of any type, such as a liquid crystal display panel (LCD), a light-emitting diode (LED) display, a plasma display panel (PDP), but is not limited thereto.

如上所述,習知的視訊處理器可取得一幀組並利用基於一參考表決定的相位係數來產生插補幀,其中,所選的幀及其相關的相位係數係根據輸入幀率與輸出幀率以及參考表所記載的資訊而預先決定的。因此,若輸入幀未能遵循預期的輸入時序之情況下,將無法正常產生輸出的影像幀。為了解決或減輕此問題,本發明提出了一種可在每一輸出幀期間內動態決定用於插補的幀組及相位步階/係數的方法,藉由適當地選擇用於插補的當前幀和先前幀並重新計算相位步階及相位係數,使得輸出的視訊更加流暢,進而使輸入時序不規則所造成的影響達到最小。As described above, conventional video processors can obtain a frame group and generate interpolated frames using phase coefficients determined based on a reference table, where the selected frames and their associated phase coefficients are determined based on the input frame rate and output The frame rate is determined in advance by referring to the information recorded in the table. Therefore, if the input frame fails to follow the expected input timing, the output image frame will not be generated normally. In order to solve or alleviate this problem, the present invention proposes a method that can dynamically determine the frame group and phase step/coefficient for interpolation within each output frame period, by appropriately selecting the current frame for interpolation and previous frames and recalculates the phase steps and phase coefficients to make the output video smoother and minimize the impact of irregular input timing.

第2圖為本發明實施例一影像處理流程20之流程圖。影像處理流程20可實現於一視訊處理器,如第1圖中的視訊處理器106。如第2圖所示,影像處理流程20包含有下列步驟:FIG. 2 is a flowchart of an image processing process 20 according to an embodiment of the present invention. The image processing process 20 can be implemented in a video processor, such as the video processor 106 in FIG. 1. As shown in FIG. 2, the image processing process 20 includes the following steps:

步驟200:  開始。Step 200: Start.

步驟202:  接收一系列輸入幀。Step 202: Receive a series of input frames.

步驟204:  根據該系列輸入幀來計算一緩衝級值(buffer stage value),其中,緩衝級值對應於視訊處理器中的一幀緩衝器所儲存的輸入幀的狀態。Step 204: Calculate a buffer stage value based on the series of input frames, wherein the buffer stage value corresponds to the status of the input frames stored in a frame buffer in the video processor.

步驟206:  根據緩衝級值,從幀緩衝器所儲存的輸入幀中選擇一幀組用以產生一插補幀,作為視訊處理器所輸出的一輸出幀。Step 206: According to the buffer level value, select a frame group from the input frames stored in the frame buffer to generate an interpolation frame as an output frame output by the video processor.

步驟208:  結束。Step 208: End.

根據影像處理流程20,視訊處理器可接收一系列輸入幀(步驟202)。在一實施例中,該系列輸入幀可由視訊處理器從一前端裝置接收,前端裝置可以是例如第1圖中的視訊提供單元12。According to the image processing process 20, the video processor may receive a series of input frames (step 202). In one embodiment, the series of input frames may be received by the video processor from a front-end device, such as the video providing unit 12 in FIG. 1 .

在有接收輸入幀或沒有接收輸入幀的每一輸出幀期間內,視訊處理器可根據輸入幀的接收來計算一緩衝級值(步驟204)。緩衝級值對應於視訊處理器的一幀緩衝器儲存的輸入幀的狀態。更明確來說,緩衝級值可代表幀緩衝器中尚未用來透過插補操作產生插補幀的輸入幀的數量。視訊處理器可利用緩衝級值來監看幀緩衝器的輸入幀儲存狀態。視訊處理器進而根據緩衝級值從幀緩衝器選擇幀組用來產生插補幀以作為一輸出幀(步驟206)。During each output frame with or without receiving an input frame, the video processor may calculate a buffer level value based on the reception of the input frame (step 204). The buffer level value corresponds to the status of the input frame stored in a frame buffer of the video processor. More specifically, the buffer level value may represent the number of input frames in the frame buffer that have not been used to generate interpolated frames through interpolation operations. The video processor can use the buffer level value to monitor the frame buffer's input frame storage status. The video processor then selects a frame group from the frame buffer according to the buffer level value to generate an interpolated frame as an output frame (step 206).

表3列出了一系列輸入幀的輸入時序之下多個連續輸出幀期間的緩衝級值,表3同時列出了每一輸出幀期間內用來產生插補幀的幀組(包含一當前幀及一先前幀)及其對應的相位係數,其中每一輸出幀期間以一索引值表示。插補幀可作為一輸出幀,由視訊處理器輸出至後端的顯示驅動裝置及顯示面板。一新相位起始指示與一緩衝級值同樣列於表3。表3顯示24赫茲的輸入視訊轉換為60赫茲的輸出視訊之情況,其相位步階為2/5,且相位係數具有遞迴的序列0、2/5、4/5、1/5及3/5。 索引 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 輸入幀 A B C D E F 輸入更新訊號 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 新相位起始指示 1 1 1 1 1 1 緩衝級值 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 當前幀 A A A B B C C C D D E E E F F 先前幀 Z Z Z A A B B B C C D D D E E 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 表3 Table 3 lists the buffer level values during multiple consecutive output frames under the input timing of a series of input frames. Table 3 also lists the frame group used to generate interpolation frames during each output frame (including a current frame and a previous frame) and their corresponding phase coefficients, where each output frame period is represented by an index value. The interpolation frame can be used as an output frame and is output by the video processor to the back-end display driver device and display panel. A new phase start indication and a buffer level value are also listed in Table 3. Table 3 shows the conversion of 24 Hz input video to 60 Hz output video with a phase step of 2/5 and a recursive sequence of phase coefficients of 0, 2/5, 4/5, 1/5 and 3. /5. index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 input frame A B C D E F Enter update signal 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 New phase start indication 1 1 1 1 1 1 buffer level value 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 current frame A A A B B C C C D D E E E F F previous frame Z Z Z A A B B B C C D D D E E Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 table 3

詳細來說,視訊處理器接收一系列輸入幀A、B、C、D、E及F…。輸入更新訊號可用來指示輸入幀的接收,其中,數值1指示輸出幀期間內接收到一輸入幀,而數值0指示輸出幀期間內未接收到輸入幀。當前端的視訊提供單元發送一輸入幀至視訊處理器時,視訊提供單元可提供輸入更新訊號予視訊處理器以指示輸入幀的傳送。新相位起始指示可用來指示相位係數的狀態,其中,數值1指示前一個輸出幀的相位係數加上相位步階到達1或超過1,因而重新從0開始累加新的相位週期。緩衝級值可預先設定為一預設值,此例中的預設值為0。由於緩衝級值代表幀緩衝器中尚未用來產生插補幀的輸入幀數量,因此在新的輸入幀到達時可將緩衝級值加1,並且在新的相位週期起始而相位係數到達1且重新從0開始累加時可將緩衝級值減1。在此例中,新輸入幀的到達可由輸入更新訊號來指示,而新的相位週期可由為新相位起始指示來指示。Specifically, the video processor receives a series of input frames A, B, C, D, E and F.... The input update signal may be used to indicate the reception of an input frame, where a value of 1 indicates that an input frame was received during the output frame period, and a value of 0 indicates that no input frame was received during the output frame period. When the front-end video providing unit sends an input frame to the video processor, the video providing unit may provide an input update signal to the video processor to instruct the transmission of the input frame. The new phase start indication can be used to indicate the status of the phase coefficient, where a value of 1 indicates that the phase coefficient of the previous output frame plus the phase step reaches 1 or exceeds 1, thus re-starting the accumulation of the new phase period from 0. The buffer level value can be preset to a default value, which is 0 in this example. Since the buffer level value represents the number of input frames in the frame buffer that have not yet been used to generate interpolated frames, the buffer level value can be incremented by 1 when a new input frame arrives, and the phase coefficient reaches 1 at the beginning of a new phase period And when accumulating again from 0, the buffer level value can be reduced by 1. In this example, the arrival of a new input frame may be indicated by an input update signal, and a new phase period may be indicated by a new phase start indication.

更明確來說,若接收到新的輸入幀時,可在新的輸入幀進入幀緩衝器時將緩衝級值加1。若相位係數到達1且重新從0開始累加,意即插補幀係基於下一個輸入幀組來產生,此時由於幀緩衝器中增加了一個用來產生插補幀的輸入幀,因此可將緩衝級值減1。More specifically, if a new input frame is received, the buffer level value can be increased by 1 when the new input frame enters the frame buffer. If the phase coefficient reaches 1 and starts accumulating again from 0, it means that the interpolation frame is generated based on the next input frame group. At this time, since an input frame is added to the frame buffer to generate the interpolation frame, it can be Decrease the buffer level value by 1.

舉例來說,在索引4的輸出幀期間內,輸入幀B到達,因此緩衝級值加1;同時新的相位起始且相位係數從0開始重新累加,因此緩衝級值減1。加1和減1的運算相結合,可得到緩衝級值不變,亦即,在索引4的輸出幀期間內維持在0。同樣地,在索引6的輸出幀期間內,輸入幀C到達,因此緩衝級值加1;同時新的相位起始且相位係數回到0,因此緩衝級值減1。加1和減1的運算相結合,可得到緩衝級值維持不變且持續為0。For example, during the output frame period of index 4, input frame B arrives, so the buffer level value is increased by 1; at the same time, a new phase starts and the phase coefficient starts to accumulate again from 0, so the buffer level value is reduced by 1. The combination of the addition and subtraction operations results in the buffer level value remaining unchanged, that is, it remains at 0 during the output frame period of index 4. Similarly, during the output frame period of index 6, input frame C arrives, so the buffer level value is increased by 1; at the same time, a new phase starts and the phase coefficient returns to 0, so the buffer level value is reduced by 1. The combination of the addition and subtraction operations results in the buffer level value remaining unchanged and continuously at 0.

然而,在索引8的輸出幀期間內,輸入幀D到達的時間比預期的到達時間(即索引9)早。在此情況下,輸入更新訊號指示新的輸入幀到達,因此緩衝級值加1,同時相位係數增加到4/5但未進入新的相位週期。如此一來,緩衝級值在索引8的輸出幀期間變為1,且視訊處理器將根據緩衝級值來選擇用來產生插補幀的輸入幀組。However, within the output frame period at index 8, input frame D arrives earlier than the expected arrival time (i.e., index 9). In this case, the input update signal indicates the arrival of a new input frame, so the buffer level value is increased by 1, and the phase coefficient is increased to 4/5 but a new phase period is not entered. As a result, the buffer level value becomes 1 during the output frame at index 8, and the video processor will select the input frame group used to generate the interpolation frame based on the buffer level value.

更明確來說,若緩衝級值等於預設值時(例如0),視訊處理器可選擇新到達的輸入幀作為當前幀並選擇前一個接收的輸入幀(早於新到達的輸入幀)作為先前幀來產生插補幀。舉例來說,在索引4的輸出幀期間內,緩衝級值等於0,新到達/接收的輸入幀B被選為當前幀且其前一幀A被選為先前幀,用來執行插補以產生插補幀。在索引6的輸出幀期間內,緩衝級值等於0,新到達/接收的輸入幀C被選為當前幀且其前一幀B被選為先前幀,用來執行插補以產生插補幀。More specifically, if the buffer level value is equal to a preset value (e.g., 0), the video processor may select a newly arrived input frame as a current frame and select a previously received input frame (earlier than the newly arrived input frame) as a previous frame to generate an interpolation frame. For example, during an output frame of index 4, the buffer level value is equal to 0, the newly arrived/received input frame B is selected as the current frame and its previous frame A is selected as the previous frame to perform interpolation to generate an interpolation frame. During the output frame of index 6, the buffer level value is equal to 0, the newly arrived/received input frame C is selected as the current frame and its previous frame B is selected as the previous frame to perform interpolation to generate the interpolation frame.

若緩衝級值大於預設值時(如增加到1),視訊處理器可選擇先前接收的輸入幀作為當前幀並選擇另一個先前接收的輸入幀(其早於被選為當前幀的輸入幀)作為先前幀來產生插補幀。舉例來說,在索引8的輸出幀期間內,緩衝級值等於1,先前接收的輸入幀C被選為當前幀且其前一幀B被選為先前幀,用來執行插補以產生插補幀。If the buffer level value is greater than the default value (for example, increased to 1), the video processor can select the previously received input frame as the current frame and select another previously received input frame (which is earlier than the input frame selected as the current frame). ) as the previous frame to generate the interpolated frame. For example, during the output frame at index 8, the buffer level value is equal to 1, the previously received input frame C is selected as the current frame and its previous frame B is selected as the previous frame, used to perform interpolation to produce the interpolation Fill frame.

需注意的是,在下一個輸出幀期間內(即索引9),相位係數從0開始重新累加且新的相位週期開始,因此緩衝級值減為0。在此情形下,視訊處理器可選擇新到達的輸入幀D作為當前幀並選擇其前一幀C作為先前幀來產生插補幀。Note that, during the next output frame period (i.e., index 9), the phase coefficients are re-accumulated from 0 and a new phase period begins, so the buffer level value is reduced to 0. In this case, the video processor can select the newly arrived input frame D as the current frame and select its previous frame C as the previous frame to generate the interpolated frame.

在習知利用參考表來執行插補的選擇方案中,視訊處理器必定是取出新到達的輸入幀及其前一輸入幀作為幀組來執行插補,此插補方法在一輸入幀比預期時間更早到達的情況下可能產生畫面的異常回退。相較之下,根據本發明之實施例,視訊處理器可根據緩衝級值來選擇用於插補的輸入幀組,因此,所選擇的輸入幀組將會是正確的,特別是在一輸入幀提早到達的情況下,如此一來,插補幀能夠正常產生並流暢地顯示。In the conventional alternative of using a reference table to perform interpolation, the video processor must take out the newly arrived input frame and its previous input frame as a frame group to perform interpolation. In this interpolation method, one input frame is larger than expected. If the time arrives earlier, an abnormal rollback of the screen may occur. In contrast, according to embodiments of the present invention, the video processor can select the input frame group for interpolation based on the buffer level value. Therefore, the selected input frame group will be correct, especially for an input When frames arrive early, interpolated frames can be generated normally and displayed smoothly.

在一實施例中,緩衝級值亦可用來處理輸入幀延遲的情況。在緩衝級值為0的情況下(意即幀緩衝器中無任何輸入幀尚未用來執行插補),當相位係數欲超過1但沒有任何新到達的輸入幀時,視訊處理器無法取得新到達的輸入幀來執行插補。這樣的情形稱為“緩衝器下溢(buffer underflow)”,其代表預期在一輸出幀期間取用一輸入幀來產生插補幀但在該輸出幀期間尚未接收到該輸入幀。當發生緩衝器下溢時,視訊處理器仍可利用與前一輸出幀期間相同的輸入幀組來產生插補幀(即幀組維持不變),並設定相位係數強制到達最大值。In one embodiment, the buffer level value can also be used to handle the input frame delay situation. With a buffer level value of 0 (meaning there are no input frames in the frame buffer that have not yet been used to perform interpolation), when the phase coefficient is to exceed 1 but there are no new input frames arriving, the video processor cannot obtain the new Arriving input frames to perform interpolation. Such a situation is called "buffer underflow", which means that an input frame is expected to be taken during an output frame to generate an interpolation frame but the input frame has not been received during the output frame. When a buffer underflow occurs, the video processor can still generate interpolated frames using the same input frame group as during the previous output frame (i.e., the frame group remains unchanged), and set the phase coefficients to force the maximum value.

表4顯示因輸入幀D的延遲而發生緩衝器下溢的情況。在索引9的輸出幀期間內,輸入幀D預期被接收,但實際上未接收到任何輸入幀,且相位係數欲超過1而進入下一個相位週期。同時,緩衝級值等於最小值0,意即幀緩衝器內未儲存任何新的輸入幀能夠被取用為執行插補使用的新幀組,因此系統判斷發生緩衝器下溢。在此情況下,用於插補的幀組維持不變,其中,輸入幀C仍被選為當前幀而輸入幀B仍被選為先前幀。相位係數到達其最大值,如127/128,其為小於1的最大可能數值。在輸入幀D到達之前,最大相位係數的使用使得所產生的插補幀與輸入幀C相似。如此一來,可避免畫面的異常回退,且輸入幀延遲的影響可達到最小。 索引 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 輸入幀 A B C D E 輸入更新訊號 1 0 0 1 0 1 0 0 0 0 1 0 0 1 0 新相位起始指示 1 1 1 1 1 緩衝級值 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 當前幀 A A A B B C C C C C D D D E E 先前幀 Z Z Z A A B B B B B C C C D D 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 4/5 127/128 127/128 0 2/5 4/5 1/5 3/5 表4 Table 4 shows the case where a buffer underflow occurs due to the delay of input frame D. During the output frame period of index 9, input frame D is expected to be received, but no input frame is actually received, and the phase coefficient is about to exceed 1 and enter the next phase cycle. At the same time, the buffer level value is equal to the minimum value 0, which means that no new input frame is stored in the frame buffer that can be used as a new frame group for interpolation, so the system determines that a buffer underflow occurs. In this case, the frame group used for interpolation remains unchanged, where input frame C is still selected as the current frame and input frame B is still selected as the previous frame. The phase coefficient reaches its maximum value, such as 127/128, which is the maximum possible value less than 1. The use of the maximum phase coefficient makes the interpolated frame generated similar to the input frame C before the input frame D arrives. In this way, abnormal picture regression can be avoided and the impact of input frame delay can be minimized. index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Input frame A B C D E Input update signal 1 0 0 1 0 1 0 0 0 0 1 0 0 1 0 New phase start indication 1 1 1 1 1 Buffer level value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Current frame A A A B B C C C C C D D D E E Previous frame Z Z Z A A B B B B B C C C D D Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 4/5 127/128 127/128 0 2/5 4/5 1/5 3/5 Table 4

值得注意的是,用來執行插補的當前幀及先前幀皆取自於幀緩衝器。假設視訊處理器總共可存取N個幀緩衝器(或一個可容納N個輸入幀的幀緩衝器),若緩衝級值等於N-1時,所選擇的幀組包含有早於新到達輸入幀的前第(N-1)個輸入幀(作為當前幀)以及早於新到達輸入幀的前第N個輸入幀(作為先前幀)。後者會被新到達的輸入幀覆寫,造成視訊處理器取到錯誤的輸入幀來執行插補。It is worth noting that the current frame and previous frames used to perform interpolation are taken from the frame buffer. Assume that the video processor can access a total of N frame buffers (or a frame buffer that can accommodate N input frames). If the buffer level value is equal to N-1, the selected frame group contains input that is earlier than the new arrival. The (N-1)th input frame before the frame (as the current frame) and the Nth input frame earlier than the newly arrived input frame (as the previous frame). The latter will be overwritten by the newly arrived input frame, causing the video processor to obtain the wrong input frame to perform interpolation.

上述情形稱為“緩衝器溢出(buffer overflow)”,其代表儲存於幀緩衝器且預期被取用來產生插補幀之一先前接收的輸入幀被新到達/接收的輸入幀覆寫。為解決緩衝器溢出的問題,當緩衝級值到達N-1時(其中N為視訊處理器的幀緩衝器數量,用來指示視訊處理器的幀緩衝器具有儲存N個輸入幀的能力),可強制將緩衝級值減1,再據此選擇用來執行插補的輸入幀組。也就是說,視訊處理器可選擇儲存於幀緩衝器中但未被當前到達輸入幀覆寫的輸入幀作為幀組來執行插補,同時相位係數強制設定為從0開始重新累加。The above situation is called "buffer overflow", which means that a previously received input frame stored in the frame buffer and expected to be used to generate the interpolation frame is overwritten by the newly arrived/received input frame. To solve the problem of buffer overflow, when the buffer level value reaches N-1 (where N is the number of frame buffers of the video processor, indicating that the frame buffer of the video processor has the ability to store N input frames), the buffer level value can be forced to decrease by 1, and then the input frame group used to perform interpolation is selected accordingly. That is, the video processor can select the input frames stored in the frame buffer but not overwritten by the currently arriving input frame as a frame group to perform interpolation, and the phase coefficients are forced to be re-accumulated from 0.

表5顯示因輸入幀F及G的提早到達而發生緩衝器溢出的情況。在此例中,幀緩衝器數量為3,意即視訊處理器的幀緩衝器最多可儲存3個輸入幀,此幀緩衝器可包含3個緩衝器單元B0、B1及B2,如表5所示。因此,當緩衝級值到達2時會發生緩衝器溢出。 索引 6 7 8 9 10 11 12 13 14 15 16 17 輸入幀 C D E F G H 輸入更新訊號 1 0 0 1 0 1 1 1 0 0 1 0 新相位起始指示 1 1 1 0 0->1 1 緩衝級值 0 0 0 0 0 0 1 2->1 1 1 1 1 當前幀 C C C D D E E F F F G G 先前幀 B B B C C D D E E E F F 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 0 2/5 4/5 1/5 3/5 緩衝器單元B0 A A A D D D D G G G G G 緩衝器單元B1 B B B B B E E E E E H H 緩衝器單元B2 C C C C C C F F F F F F 表5 Table 5 shows the case where a buffer overflow occurs due to the early arrival of input frames F and G. In this example, the number of frame buffers is 3, which means that the frame buffer of the video processor can store up to 3 input frames, and the frame buffer may include 3 buffer units B0, B1, and B2, as shown in Table 5. Therefore, a buffer overflow occurs when the buffer level value reaches 2. index 6 7 8 9 10 11 12 13 14 15 16 17 Input frame C D E F G H Input update signal 1 0 0 1 0 1 1 1 0 0 1 0 New phase start indication 1 1 1 0 0->1 1 Buffer level value 0 0 0 0 0 0 1 2->1 1 1 1 1 Current frame C C C D D E E F F F G G Previous frame B B B C C D D E E E F F Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 0 2/5 4/5 1/5 3/5 Buffer unit B0 A A A D D D D G G G G G Buffer unit B1 B B B B B E E E E E H H Buffer unit B2 C C C C C C F F F F F F table 5

詳細來說,接收到的輸入幀依序疊代寫入緩衝器單元B0、B1及B2。在此例中,輸入幀D寫入緩衝器單元B0以覆蓋輸入幀A,輸入幀E寫入緩衝器單元B1以覆蓋輸入幀B,輸入幀F寫入緩衝器單元B2以覆蓋輸入幀C,輸入幀G寫入緩衝器單元B0以覆蓋輸入幀D。在索引12及13的輸出幀期間內,輸入幀F及G在早於預期的時間快速到達,且緩衝級值在輸入幀G到達時欲增加至2,此時判斷發生緩衝器溢出且緩衝器單元B0中的輸入幀D被輸入幀G覆寫。在此情況下,緩衝級值從2減為1,且視訊處理器基於減少後的緩衝級值1來選擇幀組,其選擇輸入幀F作為當前幀並選擇輸入幀E作為先前幀來執行插補。同時,根據新相位起始指示,相位係數被設定強制進入新的相位週期並從0開始重新累加。接著,後續輸入幀H的到達恢復為正常時序,因此,視訊處理器可根據緩衝級值以正常序列來選擇幀組,且相位係數以正常的相位步階2/5持續累加。In detail, the received input frames are sequentially and iteratively written into the buffer units B0, B1 and B2. In this example, input frame D is written to buffer unit B0 to overwrite input frame A, input frame E is written to buffer unit B1 to overwrite input frame B, input frame F is written to buffer unit B2 to overwrite input frame C, Input frame G is written to buffer unit B0 to overwrite input frame D. During the output frames at indexes 12 and 13, input frames F and G arrive faster than expected, and the buffer level value is about to increase to 2 when input frame G arrives. At this time, it is determined that a buffer overflow occurs and the buffer Input frame D in unit B0 is overwritten by input frame G. In this case, the buffer level value is reduced from 2 to 1, and the video processor selects a frame group based on the reduced buffer level value of 1, which selects input frame F as the current frame and input frame E as the previous frame to perform interpolation. Supplement. At the same time, according to the new phase start indication, the phase coefficient is set to force it to enter a new phase period and re-accumulate from 0. Then, the arrival of subsequent input frames H returns to normal timing. Therefore, the video processor can select the frame group in the normal sequence according to the buffer level value, and the phase coefficients continue to accumulate at the normal phase step 2/5.

在相同的範例中,若用於插補的幀組係在未考慮緩衝器溢出的情況下進行選擇,則在索引13的輸出幀期間內,視訊處理器預計取用儲存於緩衝器單元B1的輸入幀E作為當前幀並預計取用儲存於緩衝器單元B0的輸入幀D作為先前幀來執行插補(其中相位係數為4/5)。然而,儲存於緩衝器單元B0的輸入幀D已被提早到達的輸入幀G覆寫而造成溢出,導致其取到錯誤的輸入幀來執行插補。相較之下,本發明提出的緩衝器溢出判斷及其相關的操作方法可確保選到適合的輸入幀作為幀組來執行插補,使得輸出的畫面更加流暢。In the same example, if the frame group for interpolation is selected without considering the buffer overflow, during the output frame of index 13, the video processor expects to fetch the input frame E stored in the buffer unit B1 as the current frame and expects to fetch the input frame D stored in the buffer unit B0 as the previous frame to perform interpolation (where the phase coefficient is 4/5). However, the input frame D stored in the buffer unit B0 has been overwritten by the input frame G that arrived earlier, causing an overflow, resulting in it fetching an erroneous input frame to perform interpolation. In contrast, the buffer overflow judgment and related operation method proposed in the present invention can ensure that suitable input frames are selected as frame groups to perform interpolation, making the output picture smoother.

根據緩衝級值,視訊處理器可選擇適合的輸入幀來執行插補,而在有限的幀緩衝器數量之下,視訊處理器可在緩衝器溢出或下溢發生時採取適當的對策。緩衝器溢出或下溢的判斷可在每一輸出幀期間內動態執行,因此,緩衝級值應隨時更新,以可適性地選擇用於插補的幀組。即使在輸入不規則的情況較嚴重而輸入幀持續快速到達或者長時間無任何輸入幀到達的情況下,亦可在緩衝器溢出或下溢發生時良好地處理幀插補。上述方法使得視訊處理器能夠選擇最佳的幀組來執行插補,可確保輸出的畫面不會異常回退。另外,為使輸出的畫面更加流暢,本發明提出了一種可在不規則輸入發生時調整或修改相位步階的新式方法。According to the buffer level value, the video processor can select a suitable input frame to perform interpolation, and under a limited number of frame buffers, the video processor can take appropriate countermeasures when a buffer overflow or underflow occurs. The judgment of buffer overflow or underflow can be performed dynamically during each output frame, so the buffer level value should be updated at any time to adaptively select the frame group for interpolation. Even in the case of severe input irregularities and input frames continue to arrive quickly or no input frames arrive for a long time, frame interpolation can be handled well when a buffer overflow or underflow occurs. The above method enables the video processor to select the best frame group to perform interpolation, which can ensure that the output picture will not be abnormally regressed. In addition, in order to make the output picture smoother, the present invention proposes a new method for adjusting or modifying the phase step when irregular input occurs.

第3圖為本發明實施例一影像處理流程30之流程圖。影像處理流程30可實現於一視訊處理器,如第1圖中的視訊處理器106。如第3圖所示,影像處理流程30包含有下列步驟:FIG. 3 is a flowchart of an image processing process 30 according to an embodiment of the present invention. The image processing process 30 can be implemented in a video processor, such as the video processor 106 in FIG. 1. As shown in FIG. 3, the image processing process 30 includes the following steps:

步驟300:  開始。Step 300: Start.

步驟302:  接收一系列輸入幀。Step 302: Receive a series of input frames.

步驟304:  根據該系列輸入幀之一輸入幀率與視訊處理器所輸出的一系列輸出幀之一輸出幀率的相對關係,判斷一預期輸入間距值。Step 304: Determine an expected input spacing value based on the relative relationship between the input frame rate of one of the series of input frames and the output frame rate of one of the series of output frames output by the video processor.

步驟306:  判斷一實際輸入間距值是否不同於預期輸入間距值。Step 306: Determine whether an actual input spacing value is different from the expected input spacing value.

步驟308:  當判斷實際輸入間距值不同於預期輸入間距值時,計算一相位步階並取得相位步階,該相位步階不同於根據輸入幀率與輸出幀率的相對關係來決定的一正常相位步階。Step 308: When it is determined that the actual input spacing value is different from the expected input spacing value, calculate a phase step and obtain the phase step. The phase step is different from a normal phase step determined based on the relative relationship between the input frame rate and the output frame rate. Phase steps.

步驟310:  利用計算出的相位步階,根據一所選幀組來產生一插補幀,作為該系列輸出幀中的一輸出幀進行輸出。Step 310: Use the calculated phase step to generate an interpolation frame according to a selected frame group, and output it as an output frame in the series of output frames.

步驟312:  結束。Step 312: End.

根據影像處理流程30,視訊處理器可接收一系列輸入幀(步驟302)。在一實施例中,該系列輸入幀可由視訊處理器從一前端裝置接收,前端裝置可以是例如第1圖中的視訊提供單元12。According to the image processing flow 30, the video processor may receive a series of input frames (step 302). In one embodiment, the series of input frames may be received by the video processor from a front-end device, which may be, for example, the video providing unit 12 in FIG. 1.

對於所接收的每一輸入幀而言,視訊處理器可產生一預期輸入間距值(下文簡稱為“預期值”)及一實際輸入間距值(下文簡稱為“實際值”)。詳細來說,預期值係根據視訊處理器所接收的輸入幀之輸入幀率與視訊處理器所輸出的輸出幀之輸出幀率的相對關係來進行判斷(步驟304)。舉例來說,在30赫茲的輸入視訊轉換為60赫茲的輸出視訊之應用中,每一輸入幀的預期值皆為2;在24赫茲的輸入視訊轉換為60赫茲的輸出視訊之應用中,一系列輸入幀的預期值為3和2交替。For each received input frame, the video processor may generate an expected input spacing value (hereinafter referred to as the "expected value") and an actual input spacing value (hereinafter referred to as the "actual value"). Specifically, the expected value is determined based on the relative relationship between the input frame rate of the input frame received by the video processor and the output frame rate of the output frame output by the video processor (step 304). For example, in an application that converts a 30 Hz input video to a 60 Hz output video, the expected value of each input frame is 2; in an application that converts a 24 Hz input video to a 60 Hz output video, a The expected values for a series of input frames are 3 and 2 alternating.

除此之外,視訊處理器可根據輸入幀的輸入時序來判斷實際值,並持續監看實際值以判斷每一實際值相同或不同於對應的預期值(步驟306)。若輸入幀是以輸入序列的正常時序到達,實際值將持續相同於對應的預期值;若一輸入幀早於或晚於其預期的到達時間到達,則不規則的輸入時序將造成實際值不同於預期值。In addition, the video processor can determine the actual value based on the input timing of the input frame, and continuously monitor the actual value to determine whether each actual value is the same or different from the corresponding expected value (step 306). If the input frame arrives at the normal timing of the input sequence, the actual value will continue to be the same as the corresponding expected value; if an input frame arrives earlier or later than its expected arrival time, the irregular input timing will cause the actual value to be different from the expected value.

當實際值相同於預期值的情況下,可採用正常相位步階。舉例來說,在24赫茲的輸入視訊轉換為60赫茲的輸出視訊之應用中,視訊處理器可採用相位步階2/5;而在30赫茲的輸入視訊轉換為60赫茲的輸出視訊之應用中,視訊處理器可採用相位步階1/2。另一方面,當視訊處理器判斷實際值不同於預期值的情況下,可因應不規則的輸入時序來重新計算相位步階(步驟308),所計算出的相位步階應不同於根據輸入幀率與輸出幀率的相對關係來決定的正常相位步階。視訊處理器進而利用計算出的相位步階,根據所選幀組(其可根據緩衝級值來決定,如上述實施例之說明)來產生一插補幀,作為一輸出幀加以輸出(步驟310)。換句話說,在正常輸入時序之下,相位步階具有正常值;而當不規則輸入時序發生時,相位步階需重新計算而具有不同於其正常值的另一數值。相位步階的數值可根據輸入幀的實際輸入時序來動態計算,如後詳述。When the actual value is the same as the expected value, the normal phase step can be used. For example, in an application that converts a 24 Hz input video to a 60 Hz output video, the video processor can use a phase step of 2/5; and in an application that converts a 30 Hz input video to a 60 Hz output video , the video processor can use a phase step of 1/2. On the other hand, when the video processor determines that the actual value is different from the expected value, the phase step can be recalculated according to the irregular input timing (step 308). The calculated phase step should be different from the phase step based on the input frame. The normal phase step is determined by the relative relationship between the frame rate and the output frame rate. The video processor then uses the calculated phase step to generate an interpolated frame according to the selected frame group (which can be determined according to the buffer level value, as explained in the above embodiment), and outputs it as an output frame (step 310 ). In other words, under normal input timing, the phase step has a normal value; and when irregular input timing occurs, the phase step needs to be recalculated and has another value different from its normal value. The value of the phase step can be dynamically calculated based on the actual input timing of the input frame, as detailed below.

表6列出了連續多個輸出幀期間內接收的一系列輸入幀所對應的預期值及實際值。表6顯示輸入幀的輸入時序,並包含各項參數,如輸入更新訊號、用來產生插補幀的當前幀及先前幀(即幀組)、以及用於插補的相位係數。這些參數相同於前述表格的內容,在此不詳述。 索引 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 輸入幀 A B C D E F 輸入更新訊號 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 幀計數值 0 1 2 0 1 0 1 2 0 1 0 1 2 0 1 實際值 2 3 2 3 2 3 預期值 2 3 2 3 2 3 當前幀 A A A B B C C C D D E E E F F 先前幀 Z Z Z A A B B B C C D D D E E 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 表6 Table 6 lists the expected and actual values corresponding to a series of input frames received during multiple consecutive output frames. Table 6 shows the input timing of the input frame and includes various parameters, such as the input update signal, the current frame and the previous frame (i.e., frame group) used to generate the interpolated frame, and the phase coefficient used for interpolation. These parameters are the same as the contents of the previous table and will not be described in detail here. index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 input frame A B C D E F Enter update signal 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 frame count value 0 1 2 0 1 0 1 2 0 1 0 1 2 0 1 actual value 2 3 2 3 2 3 expected value 2 3 2 3 2 3 current frame A A A B B C C C D D E E E F F previous frame Z Z Z A A B B B C C D D D E E Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 3/5 Table 6

表6另列出了一幀計數值,其可用來計算從接收到先前輸入幀之後的輸出幀期間的數量。幀計數值係在新的輸入幀到達時重置為0,並接著開始計數,以該新到達的輸入幀作為先前輸入幀。幀計數值可到達的一數值,其代表新到達的當前輸入幀與先前輸入幀之間的輸出幀期間的數量。Table 6 also lists a frame count value that can be used to count the number of output frame periods since the previous input frame was received. The frame count value is reset to 0 when a new input frame arrives, and then starts counting, using the newly arrived input frame as the previous input frame. The frame count is a value that represents the number of output frame periods between the newly arrived current input frame and the previous input frame.

因此,基於預期接收的輸入幀及實際接收的輸入幀,可利用幀計數值的計數結果來分別計算預期值及實際值。更明確來說,預期值可代表從先前輸入幀的接收到當前輸入幀的接收之間預期經過的輸出幀期間的數量。在輸入幀率為24赫茲而輸出幀率為60赫茲的實施例中,預期值為3和2交替。舉例來說,對應輸入幀A的預期值為2,對應輸入幀B的預期值為3,對應輸入幀C的預期值為2,並以此類推。Therefore, based on the input frames expected to be received and the input frames actually received, the counting results of the frame count values can be used to calculate the expected value and the actual value respectively. More specifically, the expected value may represent the amount of output frame period that is expected to elapse between receipt of the previous input frame and receipt of the current input frame. In an embodiment where the input frame rate is 24 Hz and the output frame rate is 60 Hz, the expected values are 3 and 2 alternating. For example, the expected value corresponding to input frame A is 2, the expected value corresponding to input frame B is 3, the expected value corresponding to input frame C is 2, and so on.

實際值可代表從先前輸入幀的接收到當前輸入幀的接收之間實際經過的輸出幀期間的數量。因此,實際值會在新的輸入幀到達時更新。如表6所示的實施例中,輸入幀遵循正常的時序到達,因此實際值皆相同於預期值。在此情況下,視訊處理器可利用依據正常相位步階(即2/5)計算的相位係數來執行插補,此正常相位步階係根據24赫茲的輸入幀率與60赫茲的輸出幀率的相對關係來決定。The actual value may represent the number of output frame periods that have actually elapsed between the reception of the previous input frame and the reception of the current input frame. Therefore, the actual value is updated when a new input frame arrives. In the embodiment shown in Table 6, the input frames arrive following normal timing, so the actual values are all the same as the expected values. In this case, the video processor may perform interpolation using a phase coefficient calculated based on a normal phase step (i.e., 2/5), which is determined based on the relative relationship between the input frame rate of 24 Hz and the output frame rate of 60 Hz.

表7顯示本發明實施例因輸入幀的不規則輸入時序而造成實際值不同於預期值的情況。在表7中,輸入幀F在索引13的輸出幀期間提早到達,造成對應輸入幀F的實際值不同於預期值。更明確來說,根據24赫茲對60赫茲的轉換應用所對應的輸入時序,輸入幀F的預期值為3,但提早到達的輸入幀F使得輸入幀F的實際值為2。當視訊處理器偵測到實際值不同於預期值之後,可重新計算相位步階並得到相位步階等於9/20,接著根據重新計算出的相位步階9/20來產生後續的相位係數。 索引 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 輸入幀 C D E F G H 輸入更新訊號 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 幀計數值 0 1 2 0 1 0 1 0 1 2 0 1 0 1 2 實際值 2 3 2 2 3 2 預期值 2 3 2 3 3 2 新相位起始指示 1 1 1 1 1 1 剩餘輸入幀數 2 1 2 1+1 1 2 剩餘輸出幀數 5 4 3 2 1 5 4 3 2+2 3 2 1 5 4 3 相位步階 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 9/ 20 9/ 20 9/ 20 9/ 20 2/5 2/5 當前幀 C C C D D E E E F F G G H H H 先前幀 B B B C C D D D E E F F G G G 相位係數 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 13/20 2/ 20 11/20 0 2/5 4/5 表7 Table 7 shows the situation in which the actual value is different from the expected value due to the irregular input timing of the input frame in the embodiment of the present invention. In Table 7, the input frame F arrives early during the output frame period of index 13, causing the actual value of the corresponding input frame F to be different from the expected value. More specifically, according to the input timing corresponding to the 24 Hz to 60 Hz conversion application, the expected value of the input frame F is 3, but the early arrival of the input frame F makes the actual value of the input frame F 2. When the video processor detects that the actual value is different from the expected value, it can recalculate the phase step and obtain a phase step equal to 9/20, and then generate the subsequent phase coefficient according to the recalculated phase step 9/20. index 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Input frame C D E F G H Input update signal 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 Frame count value 0 1 2 0 1 0 1 0 1 2 0 1 0 1 2 Actual value 2 3 2 2 3 2 Expected value 2 3 2 3 3 2 New phase start indication 1 1 1 1 1 1 Remaining input frames 2 1 2 1+1 1 2 Remaining output frames 5 4 3 2 1 5 4 3 2+2 3 2 1 5 4 3 Phase Step 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 2/5 9/ 20 9/ 20 9/ 20 9/ 20 2/5 2/5 Current frame C C C D D E E E F F G G H H H Previous frame B B B C C D D D E E F F G G G Phase coefficient 0 2/5 4/5 1/5 3/5 0 2/5 4/5 1/5 13/20 2/ 20 11/20 0 2/5 4/5 Table 7

在採用重新計算的相位步階9/20之數個輸出幀期間之後,視訊處理器可得知相位係數回到0,且輸入幀回復成遵循正常時序。因此,視訊處理器重新開始利用正常相位步階2/5,以適合的幀組來繼續執行插補。After a few output frames using the recalculated phase step 9/20, the video processor knows that the phase coefficient has returned to 0 and the input frames are back to following normal timing. Therefore, the video processor restarts interpolation with the appropriate frame group using the normal phase step 2/5.

表7另列出了二個參數:剩餘輸入幀數及剩餘輸出幀數。剩餘輸入幀數代表在根據輸入幀率與輸出幀率的相對關係所決定的週期內,用來產生插補幀的剩餘輸入幀的數量;而剩餘輸出幀數代表在相同週期內,欲產生並輸出的剩餘輸出幀的數量。換句話說,剩餘輸入幀數是指此週期的剩餘輸出幀期間內欲用來執行插補的輸入幀,而剩餘輸出幀數是指此週期的剩餘輸出幀期間內欲輸出的輸出幀。在輸入幀率為24赫茲而輸出幀率為60赫茲的實施例中,每一週期包含有5個輸出幀期間。因此,在輸入幀正常到達的週期當中,剩餘輸入幀數隨著新相位起始指示從2開始倒數(新相位起始指示代表相位進入新的相位週期且用於插補的幀組被更新),且剩餘輸出幀數在一輸出幀被輸出的每一輸出幀期間從5開始倒數。Table 7 lists two other parameters: the remaining input frames and the remaining output frames. The remaining input frames represent the number of remaining input frames used to generate interpolation frames within a cycle determined by the relative relationship between the input frame rate and the output frame rate; while the remaining output frames represent the number of remaining output frames to be generated and output within the same cycle. In other words, the remaining input frames refer to the input frames to be used for interpolation within the remaining output frame period of this cycle, and the remaining output frames refer to the output frames to be output within the remaining output frame period of this cycle. In an embodiment where the input frame rate is 24 Hz and the output frame rate is 60 Hz, each cycle includes 5 output frame periods. Therefore, in the cycle where the input frame arrives normally, the remaining input frame number starts to count down from 2 with the new phase start indication (the new phase start indication represents that the phase enters a new phase cycle and the frame group used for interpolation is updated), and the remaining output frame number starts to count down from 5 in each output frame period where an output frame is output.

當輸入幀發生不規則到達時,視訊處理器可根據剩餘輸入幀數及剩餘輸出幀數來計算相位步階。舉例來說,在索引13的輸出幀期間內,視訊處理器得知實際值不同於預期值,進而開始執行重新計算相位步階的程序。視訊處理器可根據輸入幀、輸出幀及相位係數的當前狀態,先更新剩餘輸入幀數及剩餘輸出幀數的數值。When input frames arrive irregularly, the video processor can calculate the phase step based on the number of remaining input frames and the number of remaining output frames. For example, during the output frame period of index 13, the video processor learns that the actual value is different from the expected value, and then begins to execute the process of recalculating the phase step. The video processor can first update the values of the remaining input frames and the remaining output frames based on the current status of the input frames, output frames and phase coefficients.

更明確來說,視訊處理器可將剩餘輸入幀數加1以產生一更新剩餘輸入幀數,並將當前的實際值(即實際輸入間距值)加上剩餘輸出幀數以產生一更新剩餘輸出幀數。在表7的實施例中,上述運算係在索引14的輸出幀期間進行,其中,剩餘輸入幀數加上1,而剩餘輸出幀數加上2,其為對應於提早到達的輸入幀F的實際值。More specifically, the video processor may add 1 to the remaining input frame number to generate an updated remaining input frame number, and add the current actual value (i.e., the actual input spacing value) to the remaining output frame number to generate an updated remaining output frame number. In the embodiment of Table 7, the above operation is performed during the output frame period of index 14, wherein the remaining input frame number is added by 1, and the remaining output frame number is added by 2, which is the actual value corresponding to the input frame F that arrives early.

因此,相位步階(Phase_Step)可由更新剩餘輸入幀數(Rest_Input_Frame_Cnt)減去當前的相位係數(Present_Phase)再除以更新剩餘輸出幀數(Rest_Output_Frame_Cnt)而得,其公式如下: Therefore, the phase step (Phase_Step) can be obtained by subtracting the current phase coefficient (Present_Phase) from the number of remaining input frames to be updated (Rest_Input_Frame_Cnt) and then divided by the number of remaining output frames to be updated (Rest_Output_Frame_Cnt). The formula is as follows: .

值得注意的是,正常相位步階基本上是根據輸入幀率與輸出幀率的相對關係來決定的。透過相位步階,運動估計與運動補償操作使得一或多個輸入幀的影像資訊可依據其幀率平均分布在多個輸出幀上,進而產生具有較高幀率且流暢的輸出畫面。在本發明之實施例中,相位步階的重新計算亦符合相似的概念,亦即,不規則到達的輸入幀的影像資訊亦應平均分布在多個輸出幀上,使得不規則到達對輸出視訊造成的影響最小化,而基於剩餘輸入幀數及剩餘輸出幀數的計算有助於達到此目的。It is worth noting that the normal phase step is basically determined based on the relative relationship between the input frame rate and the output frame rate. Through the phase step, motion estimation and motion compensation operations enable the image information of one or more input frames to be evenly distributed on multiple output frames according to their frame rates, thereby generating an output picture with a higher frame rate and smoothness. In the embodiment of the present invention, the recalculation of the phase step also conforms to a similar concept, that is, the image information of irregularly arriving input frames should also be evenly distributed on multiple output frames, so that the impact of irregular arrival on the output video is minimized, and the calculation based on the remaining input frame number and the remaining output frame number helps to achieve this goal.

舉例來說,在表7的實施例中,輸入幀F在索引13的輸出幀期間提早到達,因此,用來產生插補幀的相位係數應加速滾動以因應提早到達的輸入幀F,因而應採用較大的相位步階。在此例中,所取得的相位步階等於9/20,其略大於正常相位步階2/5。詳細來說,剩餘輸入幀數係用來監看輸入的狀態,剩餘輸入幀數加1表示下一個輸入幀G被列入考慮以重新計算相位係數。接著,更新剩餘輸入幀數扣除當前相位係數(即1/5),意即已通過的相位值被排除在計算之外,僅留下剩餘相位值。剩餘輸出幀數係用來監看輸出的狀態,對應地,作為用來計算相位步階的公式的分母,剩餘輸出幀數需加上實際值(即2)以產生更新剩餘輸出幀數,其等於4,意即對應於輸入幀G的下一個相位週期被列入考慮以分散不規則輸入的影響。在此例中,相位步階可計算並取得如下: For example, in the embodiment of Table 7, the input frame F arrives early during the output frame of index 13, so the phase coefficient used to generate the interpolated frame should be accelerated to cope with the early arrival of the input frame F, and thus a larger phase step should be used. In this example, the phase step obtained is equal to 9/20, which is slightly larger than the normal phase step of 2/5. In detail, the remaining input frame number is used to monitor the status of the input, and the remaining input frame number plus 1 indicates that the next input frame G is taken into consideration to recalculate the phase coefficient. Next, the remaining input frame number is updated to deduct the current phase coefficient (i.e., 1/5), which means that the phase value that has passed is excluded from the calculation, leaving only the remaining phase value. The remaining output frames are used to monitor the status of the output. Accordingly, as the denominator of the formula used to calculate the phase step, the remaining output frames need to be added to the actual value (i.e. 2) to generate the updated remaining output frames, which is equal to 4, which means that the next phase cycle corresponding to the input frame G is taken into account to disperse the impact of irregular input. In this example, the phase step can be calculated and obtained as follows: .

在此情況下,此相位步階可用於後續的4個輸出幀期間,其係由更新剩餘輸出幀數的數值4來指示。換句話說,所計算出來的相位步階持續有效,直到剩餘輸出幀數趨向0並回到其最大值5為止。舉例來說,在表7的實施例中,相位步階9/20用於索引15~18的4個輸出幀期間,且相位係數將回到0。接著,由於後續的輸入幀皆以正常時序接收,因此視訊處理器重新開始利用正常相位步階2/5來執行插補。In this case, this phase step is available for the next 4 output frame periods, which is indicated by updating the value 4 for the number of remaining output frames. In other words, the calculated phase step continues to be valid until the number of remaining output frames approaches 0 and returns to its maximum value of 5. For example, in the embodiment of Table 7, phase step 9/20 is used for the four output frame periods of indexes 15 to 18, and the phase coefficient will return to 0. Then, since subsequent input frames are received with normal timing, the video processor restarts interpolation using normal phase step 2/5.

在此例中,不規則的輸入幀F在索引13的輸出幀期間到達,視訊處理器接著在索引14的下一個輸出幀期間更新剩餘輸入幀數及剩餘輸出幀數,以計算並取得相位步階。此計算相位步階接著開始用於索引15的下一個輸出幀期間。基於此相位步階計算的相關規則,可將不規則輸入的影響平均分散到多個輸出影像幀,使得輸出視訊更加流暢且不規則輸入的影響達到最小。除此之外,相位步階及其相關的相位係數可根據輸入幀的時序而動態決定,因此,在任意的不規則情況之下皆能夠取得適合的相位步階。換句話說,計算相位步階的方法可應用於各種不規則的情境,例如輸入幀提早到達以及輸入幀延遲。用來計算相位步階的參數使得相位係數可在相位調整期間結束時收斂到0。如此一來,後續的相位係數仍可根據正常相位步階來正常地持續滾動。In this example, the irregular input frame F arrives during the output frame at index 13. The video processor then updates the remaining input frame number and the remaining output frame number during the next output frame at index 14 to calculate and obtain the phase step. level. This calculated phase step then begins for the next output frame period at index 15. Based on the relevant rules of this phase step calculation, the impact of irregular input can be evenly distributed to multiple output image frames, making the output video smoother and minimizing the impact of irregular input. In addition, the phase step and its related phase coefficients can be dynamically determined according to the timing of the input frame, so a suitable phase step can be obtained under any irregular conditions. In other words, the method of calculating phase steps can be applied to various irregular situations, such as input frames arriving early and input frames being delayed. The parameters used to calculate the phase step are such that the phase coefficient converges to 0 at the end of the phase adjustment period. In this way, subsequent phase coefficients can still continue to roll normally according to the normal phase steps.

除此之外,動態計算相位步階的方法亦可應用於更複雜的情況。舉例來說,若相位步階係依據第一個不規則的輸入幀來進行計算或調整,且第二個不規則的輸入幀在上述相位調整期間內到達,則相位步階另可重新計算以因應第二個不規則的輸入幀,同時相位係數將遵循新計算出的相位步階,直到輸入幀回到原先的規律且相位係數回復正常為止。In addition, the method of dynamically calculating phase steps can also be applied to more complex situations. For example, if the phase step is calculated or adjusted based on the first irregular input frame, and the second irregular input frame arrives during the above-mentioned phase adjustment period, the phase step can be recalculated to In response to the second irregular input frame, the phase coefficient will follow the newly calculated phase step until the input frame returns to the original pattern and the phase coefficient returns to normal.

如上所述,傳統的相位步階係藉由根據輸入幀率及輸出幀率查找參考表來決定。即使在不規則輸入的問題發生且輸入幀以不規則的時序到達的情況下,參考表僅能夠應用於少數典型的情況。相較之下,本發明之影像處理方法可動態監看輸入狀態(如監看實際值及預期值)並根據參數(如剩餘輸入幀數及剩餘輸出幀數)來對應計算相位步階。因此,視訊處理器可在不同情境之下計算並取得適合的相位步階,其不限於參考表可預測的情況。在此情形下,本發明可處理更複雜的輸入不規則情況,優於傳統上使用參考表的方法。As mentioned above, the traditional phase step is determined by looking up the reference table according to the input frame rate and the output frame rate. Even when the problem of irregular input occurs and input frames arrive with irregular timing, the reference table can only be applied to a few typical cases. In contrast, the image processing method of the present invention can dynamically monitor the input status (such as monitoring the actual value and the expected value) and correspondingly calculate the phase step according to the parameters (such as the number of remaining input frames and the number of remaining output frames). Therefore, the video processor can calculate and obtain appropriate phase steps under different situations, which are not limited to situations that can be predicted by the reference table. In this case, the present invention can handle more complex input irregularities better than the traditional method using a reference table.

值得注意的是,本發明之目的在於提出一種可用來處理不規則輸入的影像處理方法以及相關的視訊處理器。本領域具通常知識者當可據以進行修飾或變化,而不限於此。舉例來說,在上述實施例中,輸出幀率為60赫茲,且輸入幀是以24赫茲且無規律(cadence)或下拉(pulldown)的情況接收。在另一實施例中,本發明之影像處理方法亦可應用於具有規律或下拉的輸入幀,其可以60赫茲的幀率接收,如輸入序列A1、A2、A3、B1、B2…。舉例來說,在一實施例中,可利用幀差值來推算幀計數值,進而判斷實際值,因此,視訊處理器可透過相同方式來判斷不規則輸入和計算相位步階。It is worth noting that the purpose of the present invention is to provide an image processing method and a related video processor that can be used to process irregular input. Those skilled in the art can make modifications or changes accordingly, but are not limited to this. For example, in the above embodiment, the output frame rate is 60 Hz, and the input frame is received at 24 Hz without cadence or pulldown. In another embodiment, the image processing method of the present invention can also be applied to input frames with regularity or pulldown, which can be received at a frame rate of 60 Hz, such as the input sequence A1, A2, A3, B1, B2... For example, in one embodiment, the frame difference value can be used to infer the frame count value and then determine the actual value. Therefore, the video processor can determine the irregular input and calculate the phase step in the same way.

同樣地,具有規律的輸入幀亦可應用於根據緩衝級值來選擇用於插補的幀組之實施例。在一示例性實施例中,重複的輸入幀可寫入相同的緩衝器單元。舉例來說,輸入幀A2係用來覆寫其前一個輸入幀A1,且輸入幀A3係用來覆寫其前一個輸入幀A2,下一個輸入幀B1則寫入另一個緩衝器單元。根據上述將輸入幀寫入幀緩衝器的規則,可透過相同方式來計算緩衝級值,並據以選擇用來執行插補的幀組。緩衝器溢出和緩衝器下溢亦可利用相同方式根據緩衝級值來進行判斷。Similarly, input frames with regularity can also be applied to the embodiment of selecting the frame group for interpolation based on the buffer level value. In an exemplary embodiment, repeated input frames may be written to the same buffer unit. For example, input frame A2 is used to overwrite its previous input frame A1, and input frame A3 is used to overwrite its previous input frame A2, and the next input frame B1 is written into another buffer unit. According to the above rules for writing input frames to the frame buffer, the buffer level value can be calculated in the same way and used to select the frame group for interpolation. Buffer overflow and buffer underflow can also be determined based on the buffer level value in the same way.

在一實施例中,選擇用來執行插補的幀組之方法以及計算相位步階之方法可共同執行以實現完整的影像處理流程。第4圖為本發明實施例一影像處理流程40之流程圖。影像處理流程40可以是幀組選擇以及相位步階計算的實施方式的結合,其亦可實現於一視訊處理器,如第1圖中的視訊處理器106。如第4圖所示,影像處理流程40包含有下列步驟:In one embodiment, the method of selecting the frame group to perform interpolation and the method of calculating the phase step can be performed together to implement a complete image processing flow. Figure 4 is a flow chart of an image processing process 40 according to an embodiment of the present invention. The image processing flow 40 may be a combination of frame group selection and phase step calculation implementations, and may also be implemented in a video processor, such as the video processor 106 in Figure 1 . As shown in Figure 4, the image processing process 40 includes the following steps:

步驟402:  接收一輸入幀。Step 402: Receive an input frame.

步驟404:  計算相位步階。Step 404: Calculate the phase step.

步驟406:  根據相位步階來計算相位係數。Step 406: Calculate the phase coefficient according to the phase step.

步驟408:  根據儲存於幀緩衝器的輸入幀來計算緩衝級值。Step 408: Calculate the buffer level value based on the input frame stored in the frame buffer.

步驟410:  根據緩衝級值來偵測緩衝器溢出及緩衝器下溢。Step 410: Detect buffer overflow and buffer underflow based on the buffer level value.

步驟412:  根據緩衝級值以及緩衝器溢出和緩衝器下溢的偵測結果,選擇用來執行插補的幀組並調整相位係數。Step 412: Based on the buffer level value and the detection results of buffer overflow and buffer underflow, select the frame group used to perform interpolation and adjust the phase coefficient.

步驟414:  偵測不規則的輸入幀。Step 414: Detect irregular input frames.

步驟416:  若輸入幀不規則,則動態計算相位步階。Step 416: If the input frame is irregular, dynamically calculate the phase step.

步驟418:  若輸入幀正常輸入,則採用正常相位步階。Step 418: If the input frame is input normally, use the normal phase step.

步驟420:  執行運動估計與運動補償以產生一插補幀。Step 420: Perform motion estimation and motion compensation to generate an interpolated frame.

步驟422:  輸出插補幀作為一輸出幀。Step 422: Output the interpolated frame as an output frame.

需注意的是,本發明之影像處理方法可在每一輸出幀期間內動態進行,因此影像處理流程40代表視訊處理器在一輸出幀期間內的操作。首先,視訊處理器可接收一輸入幀並將輸入幀寫入幀緩衝器(步驟402)。輸入幀可在部分輸出幀期間內接收(無下拉的情況)或在每一輸出幀期間內接收(具有下拉的情況)。接著,視訊處理器根據輸入幀率與輸出幀率的相對關係來計算正常相位步階(步驟404)。因此,透過相位步階的累加可計算相位係數,其中,當前相位係數等於先前相位係數加上相位步階(步驟406)。It should be noted that the image processing method of the present invention can be performed dynamically during each output frame period, so the image processing flow 40 represents the operation of the video processor during an output frame period. First, the video processor can receive an input frame and write the input frame into the frame buffer (step 402). The input frame can be received during a portion of the output frame period (without pull-down) or during each output frame period (with pull-down). Then, the video processor calculates a normal phase step based on the relative relationship between the input frame rate and the output frame rate (step 404). Therefore, the phase coefficient can be calculated by accumulating the phase step, where the current phase coefficient is equal to the previous phase coefficient plus the phase step (step 406).

接著,視訊處理器根據儲存於幀緩衝器的輸入幀的狀態來計算緩衝級值(步驟408)。更明確來說,緩衝級值可在一輸入幀到達/接收時加1,並且在新的相位週期開始時減1。根據動態改變的緩衝級值,視訊處理器可偵測緩衝器溢出及緩衝器下溢是否發生(步驟410)。緩衝器溢出及下溢代表輸入幀及插補幀(即輸出幀)處於不平衡的狀態。緩衝器溢出表示當輸入幀到達的速度相較於插補幀的產生更快使得預期用於插補的一先前輸入幀被新到達的輸入幀覆寫。緩衝器下溢表示當輸入幀的延遲過長使得預期用於當前插補的輸入幀尚未被接收並寫入幀緩衝器。Next, the video processor calculates the buffer level value based on the status of the input frame stored in the frame buffer (step 408). More specifically, the buffer level value can be incremented by one when an input frame arrives/received, and decremented by one at the beginning of a new phase period. Based on the dynamically changing buffer level value, the video processor can detect whether buffer overflow and buffer underflow occur (step 410). Buffer overflow and underflow represent that the input frame and the interpolation frame (i.e., the output frame) are in an unbalanced state. Buffer overflow occurs when input frames arrive faster than interpolation frames are produced such that a previous input frame intended for interpolation is overwritten by a newly arriving input frame. Buffer underflow occurs when the delay in the input frame is so long that the input frame expected for the current interpolation has not yet been received and written to the frame buffer.

接下來,視訊處理器根據緩衝級值來選擇用來執行插補的幀組,若上述偵測結果指示緩衝器溢出或下溢發生,則可對相位係數進行調整(步驟412)。當緩衝器溢出發生時,用來執行插補的幀組可改為採用所儲存的輸入幀中尚未被當前到達的輸入幀覆寫者,且相位係數強制設定為起始新的相位週期。當緩衝器下溢發生時,視訊處理器取用與前一輸出幀期間相同的輸入幀組來執行插補,且相位係數強制設定為其最大值。Next, the video processor selects a frame group to perform interpolation according to the buffer level value. If the above detection result indicates that buffer overflow or underflow occurs, the phase coefficient can be adjusted (step 412). When a buffer overflow occurs, the frame group used to perform interpolation can be changed to use the stored input frames that have not been overwritten by the currently arriving input frame, and the phase coefficients are forced to start a new phase period. When buffer underflow occurs, the video processor performs interpolation using the same set of input frames as during the previous output frame, and the phase coefficients are forced to their maximum values.

視訊處理器接著偵測並判斷輸入幀的接收是否正常或不規則(步驟414)。若輸入幀未在預期的輸出幀期間內到達則代表發生不規則輸入,可透過實際值與預期值的比較來得知。若判斷輸入幀的輸入正常(即在預期的輸出幀期間到達),視訊處理器採用正常相位步階來計算下一個輸出幀期間的相位係數(步驟418)。若判斷輸入幀的輸入不規則(即在非預期的輸出幀期間到達),視訊處理器可動態調整並計算相位步階以用於計算下一個輸出幀期間的相位係數(步驟416)。相位步階可參考剩餘輸入幀數及剩餘輸出幀數來進行計算。The video processor then detects and determines whether the reception of the input frame is normal or irregular (step 414). If the input frame does not arrive within the expected output frame period, it represents an irregular input, which can be known by comparing the actual value with the expected value. If it is determined that the input of the input frame is normal (ie, arrives during the expected output frame), the video processor uses the normal phase step to calculate the phase coefficient during the next output frame (step 418). If it is determined that the input of the input frame is irregular (ie, arrives during an unexpected output frame), the video processor can dynamically adjust and calculate the phase step for calculating the phase coefficient during the next output frame (step 416). The phase step can be calculated with reference to the number of remaining input frames and the number of remaining output frames.

接下來,基於上述選擇方案所取得的幀組以及利用基於上述程序計算出的相位步階及相位係數,視訊處理器可執行運動估計與運動補償以產生插補幀(步驟420),插補幀可作為一輸出幀以輸出至顯示面板(步驟422)。Next, based on the frame group obtained by the above selection scheme and using the phase step and phase coefficient calculated based on the above procedure, the video processor can perform motion estimation and motion compensation to generate an interpolation frame (step 420), and the interpolation frame It can be used as an output frame to be output to the display panel (step 422).

綜上所述,本發明提出了一種可用於視訊處理器的影像處理方法,用來處理不規則輸入的問題。在一實施例中,視訊處理器可監看緩衝級值,緩衝級值指示幀緩衝器所儲存的輸入幀的狀態。根據緩衝級值,視訊處理器可選擇適合的輸入幀作為幀組來執行插補,並判斷是否發生緩衝器溢出或緩衝器下溢,進而採取適當的對策。在一實施例中,視訊處理器可偵測輸入幀的輸入時序以判斷輸入幀是否遵循正常時序。若不規則輸入發生時,視訊處理器可據以計算相位步階,使得不規則輸入的影響平均分配到多個後續的輸出幀,進而使輸出畫面流暢且不規則輸入的影響達到最小。To sum up, the present invention proposes an image processing method that can be used in a video processor to deal with the problem of irregular input. In one embodiment, the video processor may monitor a buffer level value that indicates the status of the input frame stored in the frame buffer. Based on the buffer level value, the video processor can select appropriate input frames as frame groups to perform interpolation, determine whether buffer overflow or buffer underflow occurs, and then take appropriate countermeasures. In one embodiment, the video processor can detect the input timing of the input frame to determine whether the input frame follows normal timing. If irregular input occurs, the video processor can calculate the phase step accordingly, so that the impact of the irregular input is evenly distributed to multiple subsequent output frames, thereby making the output picture smooth and minimizing the impact of the irregular input.

除此之外,在一實施例中,視訊處理器可先根據幀緩衝器的狀態來判斷並處理緩衝器溢出或緩衝器下溢的情況,以決定適合的幀組,其中,當緩衝器溢出或下溢發生時亦應良好控制相位係數。視訊處理器可接著判斷不規則輸入是否發生。若不規則輸入未造成緩衝器溢出或下溢,意即此不規則輸入可透過現有的幀緩衝器來處理,可採用本發明之相位步階的計算方案來產生適合的相位步階及相位係數。在此情況下,藉由動態決定用來執行插補的幀組並計算相位步階同時考慮幀緩衝器的狀態,本發明之視訊處理器可處理各種不規則的情境。因此,針對每一輸出幀期間內執行的運動估計與運動補償操作,視訊處理器可從幀緩衝器中選出最佳的幀組,同時計算並取得適合的相位步階。如此一來,視訊處理器在任何不規則輸入的情境之下皆能夠產生流暢的輸出畫面,且不規則輸入的影響可達到最小。 以上所述僅為本發明之較佳實施例,凡依本發明申請專利範圍所做之均等變化與修飾,皆應屬本發明之涵蓋範圍。 In addition, in one embodiment, the video processor can first determine and handle the buffer overflow or buffer underflow situation according to the status of the frame buffer to determine a suitable frame group, wherein when the buffer overflows The phase coefficient should also be well controlled when underflow or underflow occurs. The video processor can then determine whether irregular input occurs. If the irregular input does not cause buffer overflow or underflow, it means that the irregular input can be processed by the existing frame buffer, and the phase step calculation scheme of the present invention can be used to generate appropriate phase steps and phase coefficients. . In this case, by dynamically determining the frame group used to perform interpolation and calculating the phase step while taking into account the status of the frame buffer, the video processor of the present invention can handle various irregular situations. Therefore, for the motion estimation and motion compensation operations performed during each output frame, the video processor can select the best frame group from the frame buffer and calculate and obtain the appropriate phase step. In this way, the video processor can produce a smooth output picture under any irregular input situation, and the impact of irregular input can be minimized. The above are only preferred embodiments of the present invention, and all equivalent changes and modifications made in accordance with the patentable scope of the present invention shall fall within the scope of the present invention.

10:顯示系統 12:視訊提供單元 104:幀率轉換器 105:幀緩衝器 106:視訊處理器 108:顯示驅動裝置 110:顯示面板 20, 30, 40:影像處理流程 200~208, 300~312, 402~422:步驟 10:Display system 12: Video providing unit 104: Frame rate converter 105: Frame buffer 106:Video processor 108:Display driver 110:Display panel 20, 30, 40: Image processing process 200~208, 300~312, 402~422: steps

第1圖為本發明實施例一顯示系統之示意圖。 第2圖為本發明實施例一影像處理流程之流程圖。 第3圖為本發明實施例另一影像處理流程之流程圖。 第4圖為本發明實施例又一影像處理流程之流程圖。 FIG. 1 is a schematic diagram of a display system of an embodiment of the present invention. FIG. 2 is a flow chart of an image processing process of an embodiment of the present invention. FIG. 3 is a flow chart of another image processing process of an embodiment of the present invention. FIG. 4 is a flow chart of another image processing process of an embodiment of the present invention.

20:影像處理流程 20:Image processing process

200~208:步驟 200~208: steps

Claims (19)

一種用於視訊處理器的操作方法,包含有: 接收一系列輸入幀; 根據該系列輸入幀來計算一緩衝級值(buffer stage value),其中,該緩衝級值對應於該視訊處理器中的一幀緩衝器所儲存的輸入幀的狀態;以及 根據該緩衝級值,從該幀緩衝器所儲存的該輸入幀中選擇一幀組用以產生一插補幀,作為該視訊處理器所輸出的一輸出幀。 An operating method for a video processor, including: Receive a series of input frames; Calculate a buffer stage value based on the series of input frames, where the buffer stage value corresponds to the state of the input frames stored in a frame buffer in the video processor; and According to the buffer level value, a frame group is selected from the input frames stored in the frame buffer to generate an interpolation frame as an output frame output by the video processor. 如請求項1所述之方法,其中該緩衝級值代表儲存於該幀緩衝器但尚未用來產生該插補幀的該輸入幀的數量。The method of claim 1, wherein the buffer level value represents the number of input frames stored in the frame buffer but not yet used to generate the interpolation frame. 如請求項1所述之方法,其中該緩衝級值在該系列輸入幀中新的一輸入幀到達時加1,且該緩衝級值在新的一相位週期開始時減1。The method of claim 1, wherein the buffer level value is increased by 1 when a new input frame in the series of input frames arrives, and the buffer level value is decreased by 1 at the beginning of a new phase period. 如請求項1所述之方法,其中從該幀緩衝器所儲存的該輸入幀中選擇該幀組用以產生該插補幀之步驟包含有: 當該緩衝級值等於一預設值時,選擇該系列輸入幀中的一新到達輸入幀作為一當前幀,並選擇該系列輸入幀中的一先前接收輸入幀作為一先前幀,用以產生該插補幀。 The method of claim 1, wherein the step of selecting the frame group from the input frames stored in the frame buffer to generate the interpolation frame includes: When the buffer level value is equal to a preset value, a newly arrived input frame in the series of input frames is selected as a current frame, and a previously received input frame in the series of input frames is selected as a previous frame to generate The interpolated frame. 如請求項4所述之方法,其中該預設值為0。The method as described in claim 4, wherein the default value is 0. 如請求項4所述之方法,其中從該幀緩衝器所儲存的該輸入幀中選擇該幀組用以產生該插補幀之步驟另包含有: 當該緩衝級值大於該預設值時,選擇該系列輸入幀中的一第一先前接收輸入幀作為該當前幀,並選擇該第一輸入幀之前的一第二先前接收輸入幀作為該先前幀,用以產生該插補幀。 The method as described in claim 4, wherein the step of selecting the frame group from the input frame stored in the frame buffer for generating the interpolation frame further includes: When the buffer level value is greater than the preset value, selecting a first previously received input frame in the series of input frames as the current frame, and selecting a second previously received input frame before the first input frame as the previous frame, for generating the interpolation frame. 如請求項1所述之方法,另包含有: 根據該緩衝級值來判斷是否發生一緩衝器下溢(buffer underflow),其中,該緩衝器下溢代表該系列輸入幀中預期在一輸出幀期間內被取用來產生該插補幀的一輸入幀在該輸出幀期間尚未被接收。 The method as described in claim 1 further comprises: Determining whether a buffer underflow occurs according to the buffer level value, wherein the buffer underflow represents that an input frame in the series of input frames that is expected to be taken during an output frame period to generate the interpolation frame has not been received during the output frame period. 如請求項7所述之方法,其中當判斷該緩衝器下溢發生時,一相位係數到達一最大值,且用來產生該插補幀的該幀組維持不變。A method as described in claim 7, wherein when it is determined that the buffer underflow occurs, a phase coefficient reaches a maximum value and the frame group used to generate the interpolated frame remains unchanged. 如請求項1所述之方法,另包含有: 根據該緩衝級值來判斷是否發生一緩衝器溢出(buffer overflow),其中,該緩衝器溢出代表該系列輸入幀中儲存於該幀緩衝器且預期被取用來產生該插補幀的一先前接收輸入幀被該系列輸入幀中的一新接收輸入幀覆寫。 The method described in request 1 also includes: Determine whether a buffer overflow has occurred according to the buffer level value, where the buffer overflow represents a previous frame in the series of input frames that is stored in the frame buffer and is expected to be accessed to generate the interpolation frame. The receive input frame is overwritten by a new receive input frame in the series of input frames. 如請求項9所述之方法,其中根據該緩衝級值來判斷是否發生該緩衝器溢出之步驟包含有: 當該緩衝級值等於該視訊處理器的一幀緩衝器數減1時,判斷發生該緩衝器溢出。 The method described in request item 9, wherein the step of determining whether the buffer overflow occurs based on the buffer level value includes: When the buffer level value is equal to the number of one frame buffer of the video processor minus 1, it is determined that the buffer overflow has occurred. 如請求項9所述之方法,其中當判斷發生該緩衝器溢出時,該緩衝級值強制減1,接著根據該緩衝級值來選擇該幀組。The method of claim 9, wherein when it is determined that the buffer overflow occurs, the buffer level value is forcibly decremented by 1, and then the frame group is selected based on the buffer level value. 一種用於視訊處理器的操作方法,包含有: 接收一系列輸入幀; 根據該系列輸入幀之一輸入幀率與該視訊處理器所輸出的一系列輸出幀之一輸出幀率的相對關係,判斷一預期輸入間距值; 判斷一實際輸入間距值是否不同於該預期輸入間距值; 當判斷該實際輸入間距值不同於該預期輸入間距值時,計算一相位步階並取得該相位步階,該相位步階不同於根據該輸入幀率與該輸出幀率的相對關係來決定的一正常相位步階;以及 利用計算出的該相位步階,根據一所選幀組來產生一插補幀,作為該系列輸出幀中的一輸出幀進行輸出。 An operating method for a video processor, comprising: receiving a series of input frames; judging an expected input spacing value based on a relative relationship between an input frame rate of the series of input frames and an output frame rate of a series of output frames output by the video processor; judging whether an actual input spacing value is different from the expected input spacing value; when judging that the actual input spacing value is different from the expected input spacing value, calculating a phase step and obtaining the phase step, the phase step being different from a normal phase step determined based on the relative relationship between the input frame rate and the output frame rate; and Using the calculated phase step, an interpolated frame is generated according to a selected frame group and output as an output frame in the series of output frames. 如請求項12所述之方法,其中該預期輸入間距值代表從該系列輸入幀中一先前輸入幀的接收到該系列輸入幀中一當前輸入幀的接收之期間內預期經過的輸出幀期間的數量,且該實際輸入間距值代表從該先前輸入幀的接收到該當前輸入幀的接收之期間內實際經過的輸出幀期間的數量。The method of claim 12, wherein the expected input spacing value represents an expected elapsed output frame period from the reception of a previous input frame in the series of input frames to the reception of a current input frame in the series of input frames. quantity, and the actual input spacing value represents the number of actual elapsed output frame periods from the reception of the previous input frame to the reception of the current input frame. 如請求項12所述之方法,其中計算該相位步階之步驟包含有: 根據一剩餘輸入幀數及一剩餘輸出幀數來計算該相位步階,其中,該剩餘輸入幀數代表根據該輸入幀率與該輸出幀率的相對關係來決定的一週期內,用來產生該插補幀的剩餘輸入幀的數量,且該剩餘輸出幀數代表該週期內剩餘的輸出幀的數量。 The method as described in claim 12, wherein the step of calculating the phase step comprises: Calculating the phase step according to a remaining input frame number and a remaining output frame number, wherein the remaining input frame number represents the number of remaining input frames used to generate the interpolation frame in a cycle determined according to the relative relationship between the input frame rate and the output frame rate, and the remaining output frame number represents the number of remaining output frames in the cycle. 如請求項14所述之方法,其中當判斷該實際輸入間距值不同於該預期輸入間距值時,將該剩餘輸入幀數加1以產生一更新剩餘輸入幀數,且當前的該實際輸入間距值加入該剩餘輸出幀數以產生一更新剩餘輸出幀數。The method of claim 14, wherein when it is determined that the actual input distance value is different from the expected input distance value, the remaining input frame number is increased by 1 to generate an updated remaining input frame number, and the current actual input distance value The value is added to the number of remaining output frames to produce an updated number of remaining output frames. 如請求項15所述之方法,其中該相位步階之計算方式為,將該更新剩餘輸入幀數減去一當前相位係數之後再除以該更新剩餘輸出幀數。A method as described in claim 15, wherein the phase step is calculated by subtracting a current phase coefficient from the updated residual input frame number and then dividing the result by the updated residual output frame number. 如請求項12所述之方法,其中計算出的該相位步階持續有效,直到該剩餘輸出幀數趨向於0且回復到一最大值為止。The method of claim 12, wherein the calculated phase step continues to be valid until the remaining output frame number approaches 0 and returns to a maximum value. 如請求項12所述之方法,其中不同於該預期輸入間距值的該實際輸入間距值指示該系列輸入幀中的一輸入幀具有不規則的輸入時序。The method of claim 12, wherein the actual input spacing value that is different from the expected input spacing value indicates that an input frame in the series of input frames has irregular input timing. 如請求項12所述之方法,另包含有: 當判斷該實際輸入間距值與該預期輸入間距值相同時,採用該正常相位步階。 The method described in request 12 also includes: When it is determined that the actual input distance value is the same as the expected input distance value, the normal phase step is adopted.
TW112119746A 2022-08-16 2023-05-26 Method for handling irregular input for video processor TWI844376B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
US17/889,368 2022-08-16

Publications (2)

Publication Number Publication Date
TW202409960A true TW202409960A (en) 2024-03-01
TWI844376B TWI844376B (en) 2024-06-01

Family

ID=

Similar Documents

Publication Publication Date Title
CN111312191B (en) Time schedule controller, gray scale voltage adjusting method and liquid crystal display panel
US10380019B2 (en) Dynamically adjusting the number of flows allowed in a flow table cache
JP4079793B2 (en) Display method, display device, and data writing circuit usable for the same
JP4291796B2 (en) Display device
WO2016199477A1 (en) Image processing device and image processing method
US20170262955A1 (en) Scene-Aware Power Manager For GPU
JP2009276500A (en) Display device, program and information recording medium
US20150206596A1 (en) Managing a ring buffer shared by multiple processing engines
US20120274854A1 (en) Video signal processing apparatus performing gamma correction by cubic interpolation computation, and method thereof
US20100115142A1 (en) Semiconductor memory device and method of operating the semiconductor memory device
JPH11339464A (en) Fifo memory circuit
JP2018105958A (en) Data transfer device and data transfer method
JPH11126052A (en) Driving device and driving method for liquid crystal display panel
TW202409960A (en) Method for handling irregular input for video processor
US11032511B1 (en) Frame interpolation method and related video processor
TWI812483B (en) Method of memc and related video processor
US11871146B1 (en) Video processor for handling irregular input
WO2008017227A1 (en) A method, apparatus for realizing frame frequency conversion
JP4748223B2 (en) Image processing apparatus and method, and program
JP5155221B2 (en) Memory control device
JP2012123620A (en) Data transfer device, data transfer method and semiconductor device
JP5259300B2 (en) Servo control device
JP6557524B2 (en) Receiving apparatus and image transmission system using the same
US11503247B1 (en) Method of MEMC and related video processor
JP2009049752A (en) Video signal processing device, video signal processing method and display device