Methods for determining frame resolution and apparatuses using the same
09749578 · 2017-08-29
Assignee
Inventors
Cpc classification
H04N7/0127
ELECTRICITY
International classification
H04N7/01
ELECTRICITY
Abstract
The invention introduces a method for determining frame resolution, performed by a processing unit, which contains at least the following steps: obtaining a YUV video file, which contains a video stream; selecting a plurality of frame resolutions from a frame resolution table as frame resolution candidates according to the length of the video stream; repeatedly executing a loop m times, and in each iteration, obtaining at least two frames of the video stream according to one unexamined frame resolution candidate and calculating the correlation between the obtained frames, wherein m represents the quantity of frame resolution candidates; determining the best frame resolution from the frame resolution candidates according to the calculated correlations; and outputting the best frame resolution, thereby enabling a video decoder to segment the video stream into frames according to the best frame resolution and decode the segmented frames.
Claims
1. A method for determining frame resolution, performed by a processing unit, comprising: obtaining a YUV video file, which comprises a video stream; selecting a plurality of frame resolutions from a frame resolution table as frame resolution candidates according to length of the video stream; repeatedly executing a loop m times, and in each iteration, obtaining at least two frames of the video stream according to one unexamined frame resolution candidate and calculating a correlation between the obtained frames, wherein m represents quantity of the frame resolution candidates; determining best frame resolution from the frame resolution candidates according to the calculated correlations; and outputting the best frame resolution, thereby enabling a video decoder to segment the video stream into frames according to the best frame resolution and decode the segmented frame, wherein the step for selecting a plurality of frame resolutions from a frame resolution table as frame resolution candidates according to length of the video stream comprises: calculating the j.sup.th frame resolution of the frame resolution table using an Equation, wherein j is an integer between 1 to k, and k represents quantity of all frame resolutions of the frame resolution table:
L/W.sub.j/H.sub.j/Rt=n.sub.j. . . r.sub.j L represents the length of the video stream of the YUV video file, W.sub.j represents a width of the j.sup.th frame resolution, H.sub.j represents a height of the j.sup.th frame resolution, Rt represents a default value associated with a particular video stream format, n.sub.j represents a quotient associated with the j.sup.th frame resolution, and r.sub.j represents a remainder associated with the j.sup.th frame resolution; and treating the frame resolutions with the remainder being 0 as the frame resolution candidates.
2. The method of claim 1, wherein the YUV video file comprises a header and the header does not contain frame resolution information.
3. The method of claim 2, wherein the step for outputting the best frame resolution comprises: writing the best frame resolution into the header or outputting the best frame resolution to the video decoder.
4. The method of claim 1, wherein the step for repeatedly executing a loop m times comprises: in each iteration, obtaining data of a p.sup.th frame and a (p+1).sup.th frame from the video stream according to one unexamined frame resolution candidate; and calculating a first correlation, a second correlation and a third correlation between the p.sup.th frame and the (p+1).sup.th frame, and wherein the step for determining the best frame resolution from the frame resolution candidates according to the calculated correlations comprises: selecting one frame resolution candidate with the highest first, second and third correlations between the p.sup.th frame and the (p+1).sup.th frame, each of which is greater than a threshold, as the best frame resolution.
5. The method of claim 4, wherein the first correlation indicates the similar extent of Y, U and V components between the p.sup.th frame and the (p+1).sup.th frame, the second correlation indicates the similar extent of Y, U and V components between odd rows of the p.sup.th frame and even rows of the (p+1).sup.th frame, and the third correlation indicates the similar extent of Y components between odd columns of the p.sup.th frame and even columns of the (p+1).sup.th frame.
6. The method of claim 5, wherein the first correlation is calculated in an Equation:
7. The method of claim 1, wherein the step for repeatedly executing a loop m times comprises: in each iteration, obtaining data of a p.sup.th frame, a (p+1).sup.th frame, a (p+2).sup.th frame and a (p+3).sup.th frame from the video stream according to one unexamined frame resolution candidate; and calculating a third correlation between the p.sup.th frame and the (p+1).sup.th frame, a third correlation between (p+1).sup.th frame and the (p+2).sup.th frame, and a third correlation between (p+2).sup.th frame and the (p+3).sup.th frame, and wherein the step for determining the best frame resolution from the frame resolution candidates according to the calculated correlations comprises: selecting one frame resolution candidate with the highest third correlation between the p.sup.th frame and the (p+1).sup.th frame, the highest third correlation between (p+1).sup.th frame and the (p+2).sup.th frame, and the highest third correlation between (p+2).sup.th frame and the (p+3).sup.th frame as the best frame resolution.
8. The method of claim 7, wherein the third correlation between the p.sup.th frame and the (p+1).sup.th frame indicates the similar extent of Y components between odd columns of the p.sup.th frame and even columns of the (p+1).sup.th frame, the third correlation between the (p+1).sup.th frame and the (p+2).sup.th frame indicates the similar extent of Y components between odd columns of the (p+1).sup.th frame and even columns of the (p+2).sup.th frame, and the third correlation between the (p+2).sup.th frame and the (p+3).sup.th frame indicates the similar extent of Y components between odd columns of the (p+2).sup.th frame and even columns of the (p+3).sup.th frame.
9. An apparatus for determining frame resolution, comprising: a processing unit and associated memory, obtaining a YUV video file, which comprises a video stream; selecting a plurality of frame resolutions from a frame resolution table as frame resolution candidates according to length of the video stream; repeatedly executing a loop m times, and in each iteration, obtaining at least two frames of the video stream according to one unexamined frame resolution candidate and calculating a correlation between the obtained frames, wherein m represents quantity of frame resolution candidates; determining the best frame resolution from the frame resolution candidates according to the calculated correlations; and outputting the best frame resolution, thereby enabling a video decoder to segment the video stream into frames according to the best frame resolution and decode the segmented frame, wherein the operation of selecting a plurality of frame resolutions from a frame resolution table as frame resolution candidates according to length of the video stream comprises: calculating the j.sup.th frame resolution of the frame resolution table using an Equation, wherein j is an integer between 1 to k, and k represents quantity of all frame resolutions of the frame resolution table:
L/W.sub.j/H.sub.j/Rt=n.sub.j. . . r.sub.j L represents the length of the video stream of the YUV video file, W.sub.j represents a width of the j.sup.th frame resolution, H.sub.j represents a height of the j.sup.th frame resolution, Rt represents a default value associated with a particular video stream format, n.sub.j represents a quotient associated with the j.sup.th frame resolution, and r.sub.j represents a remainder associated with the j.sup.th frame resolution; and treating the frame resolutions with the remainder being 0 as the frame resolution candidates.
10. The apparatus of claim 9, comprising: a storage device, storing the YUV video file and the frame resolution table, wherein the processing unit reads the YUV video file and the frame resolution table from the storage device.
11. The apparatus of claim 9, comprising: a storage device, storing the frame resolution table; and a communications interface, wherein the processing unit reads the frame resolution table from the storage device and obtains the YUV video file from an electronic apparatus via the communications interface.
12. The apparatus of claim 9, wherein the YUV video file comprises a header and the header does not contain frame resolution information.
13. The apparatus of claim 12, wherein the processing unit writes the best frame resolution into the header or outputs the best frame resolution to the video decoder.
14. The apparatus of claim 9, wherein the processing unit, in each iteration, obtains data of a p.sup.th frame and a (p+1).sup.th frame from the video stream according to one unexamined frame resolution candidate; calculates a first correlation, a second correlation and a third correlation between the p.sup.th frame and the (p+1).sup.th frame; and selects one frame resolution candidate with the highest first, second and third correlations between the p.sup.th frame and the (p+1).sup.th frame, each of which is greater than a threshold, as the best frame resolution.
15. The apparatus of claim 14, wherein the first correlation indicates the similar extent of Y, U and V components between the p.sup.th frame and the (p+1).sup.th frame, the second the p.sup.th frame and even rows of the (p+1).sup.th frame, and the third correlation indicates the similar extent of Y components between odd columns of the p.sup.th frame and even columns of the (p+1).sup.th frame.
16. The apparatus of claim 9, wherein the processing unit, in each iteration, obtains data of a p.sup.th frame, a (p+1).sup.th frame, a (p+2).sup.th frame and a (p+3).sup.th frame from the video stream according to one unexamined frame resolution candidate; calculates a third correlation between the p.sup.th frame and the (p+1).sup.th frame, a third correlation between (p+1).sup.th frame and the (p+2).sup.th frame, and a third correlation between (p+2).sup.th frame and the (p+3).sup.th frame; and selects one frame resolution candidate with the highest third correlation between the p.sup.th frame and the (p+1).sup.th frame, the highest third correlation between (p+1).sup.th frame and the (p+2).sup.th frame, and the highest third correlation between (p+2).sup.th frame and the (p+3).sup.th frame as the best frame resolution.
17. The apparatus of claim 16, wherein the third correlation between the p.sup.th frame and the (p+1).sup.th frame indicates the similar extent of Y components between odd columns of the p.sup.th frame and even columns of the (p+1).sup.th frame, the third correlation between the (p+1).sup.th frame and the (p+2).sup.th frame indicates the similar extent of Y components between odd columns of the (p+1).sup.th frame and even columns of the (p+2).sup.th frame, and the third correlation between the (p+2).sup.th frame and the (p+3).sup.th frame indicates the similar extent of Y components between odd columns of the (p+2).sup.th frame and even columns of the (p+3).sup.th frame.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) The present invention can be fully understood by reading the subsequent detailed description and examples with references made to the accompanying drawings, wherein:
(2)
(3)
(4)
DETAILED DESCRIPTION
(5) The following description is of the best-contemplated mode of carrying out the invention. This description is made for the purpose of illustrating the general principles of the invention and should not be taken in a limiting sense. The scope of the invention is best determined by reference to the appended claims.
(6) The present invention will be described with respect to particular embodiments and with reference to certain drawings, but the invention is not limited thereto and is only limited by the claims. It will be further understood that the terms “comprises,” “comprising,” “includes” and/or “including,” when used herein, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
(7) Use of ordinal terms such as “first”, “second”, “third”, etc., in the claims to modify a claim element does not by itself connote any priority, precedence, or order of one claim element over another or the temporal order in which acts of a method are performed, but are used merely as labels to distinguish one claim element having a certain name from another element having the same name (but for use of the ordinal term) to distinguish the claim elements.
(8)
(9)
(10) TABLE-US-00001 TABLE 1 Standard Width (W) Height (H) SVGA 800 600 WSVGA 1024 600 XGA 1024 768 XGA+ 1152 864 WXGA 1280 720 WXGA 1280 768 WXGA 1280 800 SXGA 1280 1024 HD 1360 768 HD 1366 768 WXGA+ 1440 900 HD+ 1600 900 UXGA 1600 1200 WSXGA+ 1680 1050 FHD 1920 1080 WUXGA 1920 1200 WQHD 2560 1440 WQXGA 2560 1600 UHD 3840 2160
The frame resolution table may be implemented in an electronic file of a file system, one or more data tables of a relational database, an electronic document of a document database, etc. The frame resolution table contains multiple records and each record stores frame resolution information for a standard, including width, height, and the like. Specifically, in step S220, it is determined whether each frame resolution of the frame resolution table is a frame resolution candidate using Equation (1):
L/W.sub.j/H.sub.j/Rt=n.sub.j. . . r.sub.j (1)
L represents the length of the video stream of the YUV video file (in bytes), W.sub.j represents the width of the j.sup.th frame resolution, H.sub.j represents the height of the j.sup.th frame resolution, Rt represents a default value associated with a particular video stream format, n.sub.j represents the calculated quotient associated with the j.sup.th frame resolution, and r.sub.j represents the calculated remainder associated with the j.sup.th frame resolution. For example, Rt may be set to 1 when the video stream format is YUV444. The variable j is an integer between 1 and k, and k represents the quantity of all frame resolutions of the frame resolution table. Rt may be set to 1 when the video stream format is YUV422. Rt may be set to 1.25 when the video stream format is YUV420. The processing unit 110 treats the frame resolutions with the calculated remainders being 0 as the frame resolution candidates. Next, the processing unit 110 determines whether the generation of the frame resolution candidates is successful (step S230). Specifically, the generation of the frame resolution candidates is unsuccessful if no frame resolution candidate can be found. When it is unsuccessful (the “No” path of step S230), the obtained file is designated as an incorrect YUV video file (step S240). In step S240, the processing unit 110 may store information indicates that this file is not correct YUV video file.
(11) Since information carried between frames has dependency, the correlations between each two divided frames from the video stream are high if a correct frame resolution is used to perform the division. Embodiments of the invention anticipate the correct frame resolution for a YUV video file in view of the aforementioned characteristics. Specifically, the generation of frame resolution candidates is successful (the “Yes” path of step S230), a loop is repeated executed m times, and in each iteration, data of at least two frames of the video stream is obtained according to one unexamined frame resolution candidate, and the correlation between the obtained frames is calculated, where m represents the quantity of frame resolution candidates (step S250). It is attempted to select one from the frame resolution candidates as the best frame resolution according to the calculated correlations (step S260) and determined whether the selection is successful (step S270). If so (the “Yes” path of step S270), the best frame resolution is output, thereby enabling a video decoder to segment the video stream into frames according to the best frame resolution and decode the segmented frames (step S280). In step S280, the best frame resolution is written into the header or output to the video decoder. Otherwise (the “No” path of step S270), the obtained file is designated as an incorrect YUV video file (step S240). In some embodiments of each iteration of step S250, the processing unit 110 may calculate three correlations between the p.sup.th frame and the (p+1).sup.th frame. The first correlation indicates the similar extent of Y, U and V components between this frame and the next frame and a higher value indicates a higher similarity than a lower one. The first correlation may be calculated in Equation (2):
(12)
R1 represents the first correlation, X.sub.i(Y) represents the i.sup.th Y component of this frame, X.sub.i(U) represents the i.sup.th U component of this frame, X.sub.i(V) represents the i.sup.th V component of this frame, Z.sub.i(Y) represents the i.sup.th Y component of the next frame, Z.sub.i(U) represents the i.sup.th U component of the next frame, Z.sub.i(V) represents the i.sup.th V component of the next frame,
(13)
R2 represents the second correlation, X.sub.i(Y) represents the i.sup.th Y component of even rows of this frame, X.sub.i(U) represents the i.sup.th U component of even rows of this frame, X.sub.i(V) represents the i.sup.th V component of even rows of this frame, Z.sub.i(Y) represents the i.sup.th Y component of odd rows of the next frame, Z.sub.i(U) represents the i.sup.th U component of odd rows of the next frame, Z.sub.i(V) represents the i.sup.th V component of odd rows of the next frame,
(14)
R3 represents the third correlation, X.sub.i(Y) represents the i.sup.th Y component of even columns of this frame, Z.sub.i(Y) represents the i.sup.th Y component of odd columns of the next frame,
(15) In some embodiments of each iteration of step S250, the processing unit 110 may calculate the correlations R3 between the p.sup.th frame and the (p+1).sup.th frame, the (p+1).sup.th frame and the (p+2).sup.th frame, and the (p+2).sup.th frame and the (p+3).sup.th frame. In step S260, one frame resolution candidate with the highest correlations R3 between the p.sup.th frame and the (p+1).sup.th frame, the (p+1).sup.th frame and the (p+2).sup.th frame, and the (p+2).sup.th frame and the (p+3).sup.th frame is determined as the best frame resolution. That is, the correlation R3 between the p.sup.th frame and the (p+1).sup.th frame for the best frame resolution is higher than that for the other frame resolution candidates. The correlation R3 between the (p+1).sup.th frame and the (p+2).sup.th frame for the best frame resolution is higher than that for the other frame resolution candidates. The correlation R3 between the (p+2).sup.th frame and the (p+3).sup.th frame for the best frame resolution is higher than that for the other frame resolution candidates. In step S270, it is determined that the selection is unsuccessful when no frame resolution candidate is found to have the highest correlations R3 between the p.sup.th frame and the (p+1).sup.th frame, the (p+1).sup.th frame and the (p+2).sup.th frame, and the (p+2).sup.th frame and the (p+3).sup.th frame.
(16) In some embodiments, the calculations of correlations (step S250) and the selection for the best frame resolution (step S260) may be divided into two phases.
(17) In some implementations, the method may divide video stream into frames according every frame resolution of the frame resolution table and determine whether every divided result is correct using an algorithm. Embodiments of the invention employ a calculation in step S220 to remove most of the improper frame resolutions in the frame resolution table from further consideration, so as to improve calculation efficiency.
(18) Although the embodiment has been described as having specific elements in
(19) While the invention has been described by way of example and in terms of the preferred embodiments, it should be understood that the invention is not limited to the disclosed embodiments. On the contrary, it is intended to cover various modifications and similar arrangements (as would be apparent to those skilled in the art). Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements.