Video processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202310535749.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-12
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2043-05-12
AI Technical Summary
[0004]但是,采用该方法对视频数据转换,需要对每个像素的U、V数据进行存取,数据存取效率较低,导致数据格式转换效率低
[0010]本申请提供的一种视频处理方法、装置、电子设备及计算机可读存储介质,在本申请中,将待处理视频帧对应的第二格式数据中的每一行数据以及第三格式数据中的每一行数据交错排列,得到待处理视频帧对应的预处理数据,在数据排列过程中,每次交错排列一行数据,而不是每个像素点各自的数据,提高了数据格式转换的速度,最后根据待处理视频帧对应的第一格式数据以及预处理数据,得到待处理视频帧对应的目标数据,从而确定目标视频对应的最终视频,提高了数据格式转换效率。
Smart Images

Figure CN116668774B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video processing technology, and more specifically, to a video processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] Currently, the video data acquired by the camera of electronic devices is in the YUV-NV12 format. However, in video mixing processing, the data format of the video after mixing the video and the foreground layer is YUV-I420. Therefore, it is necessary to convert the video from the YUV-I420 format to the YUV-NV12 format.
[0003] A video data conversion method is disclosed in the related technology. It reads the U data and V data corresponding to each video frame in the video, and then arranges the UV data of each pixel in the video frame in the order of pixel to form an arrangement such as U0V0, U1V1, U2V2... to realize the conversion of the U data and V data corresponding to each video frame into a combination of UV data to obtain the converted video frame data. Finally, the converted video frame data are summarized to obtain the converted video data.
[0004] However, using this method to convert video data requires storing and retrieving the U and V data of each pixel, which results in low data storage and retrieval efficiency and consequently low data format conversion efficiency. Summary of the Invention
[0005] This application proposes a video processing method, apparatus, electronic device, and computer-readable storage medium to improve the above-mentioned deficiencies.
[0006] In a first aspect, embodiments of this application provide a video processing method, the method comprising: acquiring first format data, second format data, and third format data corresponding to a video frame to be processed in a target video; the second format data and the third format data corresponding to the video frame to be processed having the same number of rows; interleaving each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed to obtain preprocessed data corresponding to the video frame to be processed; obtaining target data corresponding to the video frame to be processed based on the first format data and the preprocessed data corresponding to the video frame to be processed; and determining the final video corresponding to the target video based on the target data of each video frame to be processed in the target video.
[0007] Secondly, embodiments of this application also provide a video processing apparatus, the apparatus comprising: The acquisition module is used to acquire the first format data, second format data, and third format data corresponding to the video frames to be processed in the target video; the second format data and the third format data corresponding to the video frames to be processed have the same number of rows. The processing module is used to interleave each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed, so as to obtain the preprocessed data corresponding to the video frame to be processed. The first determining module is used to obtain the target data corresponding to the video frame to be processed based on the first format data and preprocessed data corresponding to the video frame to be processed. The second determining module is used to determine the final video corresponding to the target video based on the target data of each video frame to be processed in the target video.
[0008] Thirdly, embodiments of this application also provide an electronic device, characterized in that the electronic device includes: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more application programs are configured to perform the above-described methods.
[0009] Fourthly, embodiments of this application also provide a computer-readable storage medium storing processor-executable program code, which, when executed by the processor, causes the processor to perform the above-described method.
[0010] This application provides a video processing method, apparatus, electronic device, and computer-readable storage medium. In this application, each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed are interleaved to obtain the preprocessed data corresponding to the video frame to be processed. In the data arrangement process, one row of data is interleaved each time, instead of the data of each pixel individually, which improves the speed of data format conversion. Finally, based on the first format data and the preprocessed data corresponding to the video frame to be processed, the target data corresponding to the video frame to be processed is obtained, thereby determining the final video corresponding to the target video, which improves the efficiency of data format conversion.
[0011] Other features and advantages of the embodiments of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the embodiments of this application. The objects and other advantages of the embodiments of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A flowchart of a video processing method according to an embodiment of this application is shown.
[0014] Figure 2 A schematic diagram of YUV data in an embodiment of this application is shown.
[0015] Figure 3 It shows Figure 2 The diagram shows the correspondence between the components in the YUV data.
[0016] Figure 4 A schematic diagram of preprocessed data is shown in an embodiment of this application.
[0017] Figure 5 A schematic diagram of yet another data format is shown in an embodiment of this application.
[0018] Figure 6 It shows Figure 5 The data format shown illustrates the correspondence between y values and u and v values.
[0019] Figure 7 A flowchart of a video processing method according to yet another embodiment of this application is shown.
[0020] Figure 8 A schematic diagram of target data is shown in an embodiment of this application.
[0021] Figure 9 A structural block diagram of a video processing apparatus according to an embodiment of this application is shown.
[0022] Figure 10 A schematic diagram of an electronic device provided in an embodiment of this application is shown.
[0023] Figure 11 A structural block diagram of a computer-readable storage medium provided according to an embodiment of this application is shown. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. The components of the embodiments of the present application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without inventive effort are within the scope of protection of the present application.
[0025] It should be noted that similar reference numerals and letters in the following figures indicate clustered similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0026] In Android devices, the camera requires data in YUV-NV12 format. However, in video mixing, the data format of the video after mixing the video and the foreground layer is YUV-I420. Therefore, the video needs to be converted from YUV-I420 to YUV-NV12. Additionally, since the default camera orientation on Android devices is landscape, the video processed vertically and then sent to the camera needs to be rotated to landscape to match the default camera orientation.
[0027] Please see Figure 1 , Figure 1 A flowchart of a video processing method according to an embodiment of this application is shown, for use in an electronic device. The method includes: S101. Obtain the first format data, second format data, and third format data corresponding to the video frame to be processed in the target video; the second format data and the third format data corresponding to the video frame to be processed have the same number of rows.
[0028] The target video data format can be YUV-I420. The target video includes multiple video frames to be processed, and the format of each video frame to be processed is consistent with the data format of the target video.
[0029] The YUV-I420 format, also called IYUV, belongs to the YUV420P format. The YUV-I420 format includes three planes, which store the y, u, and v values respectively. Figure 2 As shown, for each pixel in an image (or a video frame to be processed), a corresponding y-value is calculated. The number of y-values calculated equals the number of pixels in each row. These y-values are stored as a consecutive row. For the pixels in the second row, the corresponding y-value is calculated and stored, and so on, until the y-values for all pixels in the entire image are obtained. Then, all odd-numbered rows in the image are processed from top to bottom. For each row, a u-value is calculated every two pixels from left to right. After calculating each row, a consecutive row of u-values is obtained, and all u-values in that row are stored consecutively. Similarly, all even-numbered rows in the image are processed from top to bottom. For each row, a v-value is calculated every two pixels from left to right. After calculating each row, a consecutive row of v-values is obtained, and all v-values in that row are stored consecutively. This data storage format is YUV-I420. In the YUV-I420 format, as shown... Figure 3As shown, every four y values share a set of u and v values.
[0030] YUV is a way of representing color pixels in computers, where y represents the luminance component and u and v represent different chrominance components.
[0031] In some implementations, the first format data can be a y value, the second format data can be either a u value or a v value, and the third format data can be either a u value or a v value.
[0032] In some implementations, the number of rows in the first format data corresponding to the video frame to be processed is twice the number of rows in the second format data, and the number of data items in each row of the first format data corresponding to the video frame to be processed is twice the number of data items in each row of the third format data.
[0033] S102. Interleave each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed to obtain the preprocessed data corresponding to the video frame to be processed.
[0034] Taking the second format data as u-values and the third format data as v-values as an example, such as Figure 4 As shown, arrange the u values in a row from top to bottom, then arrange the v values in a row, and so on. After arranging all the u and v values, you get region 410. Region 410 is the preprocessed data corresponding to the video frame to be processed.
[0035] S103. Based on the first format data corresponding to the video frame to be processed and the preprocessed data, obtain the target data corresponding to the video frame to be processed.
[0036] For example, such as Figure 4 As shown, Figure 4 Region 420 in the middle contains the first format data corresponding to the video frame to be processed. Figure 4 The middle region 410 contains the preprocessed data corresponding to the video frame to be processed.
[0037] In some implementations, the first format data corresponding to the video frame to be processed is stored in a first plane, the second format data corresponding to the video frame to be processed is stored in a second plane, and the third format data corresponding to the video frame to be processed is stored in a third plane; each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed are interleaved to obtain preprocessed data corresponding to the video frame to be processed; the target data corresponding to the video frame to be processed is obtained based on the first format data and the preprocessed data, including: interleaving each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed, and storing the interleaved result in a fourth plane to obtain the preprocessed data corresponding to the video frame to be processed; the target data corresponding to the video frame to be processed is obtained based on the data in the first plane and the data in the fourth plane.
[0038] In the second and third planes, the number of bytes per row (strides), width, and height are all half that of the first plane. In the fourth plane, the number of bytes per row (strides) and width are also half that of the first plane, but the height of the fourth plane is the same as that of the first plane.
[0039] The target data can be in YUV-NV12 format. YUV-NV12 belongs to the YUV420SP format and includes two planes, which store the y, u, and v values respectively. Figure 5 As shown, for each pixel in an image (or a video frame to be processed), a corresponding y-value is calculated. The number of y-values calculated equals the number of pixels in each row. These y-values are stored as a consecutive row. For the pixels in the second row, the corresponding y-value is calculated, and so on, until all the y-values for the entire image are obtained. Then, calculations are performed every two rows from top to bottom. First, in the first row (odd-numbered rows), a u-component is calculated for every two pixels, resulting in one row of u-values. Then, in the second row (even-numbered rows), a v-value is calculated for every two pixels, resulting in one row of v-values. The u-values and v-values in these two rows are then interleaved, i.e., u0, v0, u1, v1..., resulting in the u and v data rows for the two rows of pixels. This process is repeated for the remaining data, calculating u and v data rows for every two rows and storing them consecutively. This data storage format is YUV-NV12. In the YUV-NV12 format, as shown... Figure 6 As shown, every four y values share a set of u and v values.
[0040] S104. Determine the final video corresponding to the target video based on the target data of each video frame to be processed in the target video.
[0041] By obtaining the target data for each video frame in the target video—that is, converting each video frame from YUV-1420 format to YUV-NV12 format—the final video corresponding to the target video can be obtained. The data format of the final video corresponding to the target video is YUV-NV12 format.
[0042] In this embodiment, by acquiring the first format data, second format data, and third format data corresponding to the video frame to be processed in the target video, and then interleaving each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed, preprocessed data corresponding to the video frame to be processed is obtained. In the data arrangement process, one row of data is interleaved each time, instead of the data of each pixel individually, which improves the speed of data format conversion. Finally, based on the first format data and preprocessed data corresponding to the video frame to be processed, the target data corresponding to the video frame to be processed is obtained, thereby determining the final video corresponding to the target video and improving the efficiency of data format conversion.
[0043] Please see Figure 7 , Figure 7 This application illustrates a flowchart of a video processing method according to another embodiment, used in an electronic device. The method includes: S201. Obtain the first format data, second format data, and third format data corresponding to the video frame to be processed in the target video; the second format data and the third format data corresponding to the video frame to be processed have the same number of rows. S202. Interleave each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed to obtain the preprocessed data corresponding to the video frame to be processed.
[0044] The descriptions of S201 to S202 are the same as those of S101 to S102 above, and will not be repeated here.
[0045] S203. Rotate each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotation data corresponding to the video frame to be processed; rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
[0046] The target direction can be clockwise or counterclockwise.
[0047] by Figure 4 For example, Figure 4 Region 420 in the middle contains the first format data corresponding to the video frame to be processed. Figure 4Region 410 contains the preprocessed data corresponding to the video frame to be processed. Rotating each row of the first format data in region 420 counter-clockwise yields the following... Figure 8 The first rotated data shown in region 820 is obtained by rotating each row of the preprocessed data in region 410 counterclockwise, as shown in the figure. Figure 8 The second rotation data is shown in region 810.
[0048] Obtaining the first rotation data and the second rotation data is not enough; the rotation direction also needs to be determined, as well as the rotation center and rotation angle.
[0049] In some implementations, a target point is determined based on the number of data rows and the number of data items in each row of the first format data corresponding to the video frame to be processed; with the target point as the rotation center, each row of data in the first format data corresponding to the video frame to be processed is rotated in the target direction to obtain the first rotation data corresponding to the video frame to be processed.
[0050] The target point can be one or more data points at the center of the first format data, which can be set according to requirements.
[0051] In some implementations, a rotation point is determined based on the number of data rows in the preprocessed data corresponding to the video frame to be processed and the number of data in each data row; with the rotation point as the rotation center, each data row in the preprocessed data corresponding to the video frame to be processed is rotated in the target direction to obtain the second rotation data corresponding to the video frame to be processed.
[0052] The rotation point can be one or more data points at the very center of the preprocessed data, and can be set according to requirements.
[0053] In some implementations, each row of data in the first format data corresponding to the video frame to be processed is rotated by a target angle according to the target direction to obtain the first rotation data corresponding to the video frame to be processed; the target angle is any one of 90 degrees, 180 degrees and 270 degrees; each row of data in the preprocessed data corresponding to the video frame to be processed is rotated by a target angle according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
[0054] The target angle can also be any one of 90 degrees, 180 degrees, and 270 degrees plus or minus n times 360 degrees, where n is an integer, expressed in radians. .
[0055] like Figure 4 and Figure 8 As shown, Figure 8 The first rotation data in is to Figure 4 The data in the first format is obtained by rotating it 90° counterclockwise. Figure 8The preprocessed data in the process is to Figure 4 The data was obtained by rotating the preprocessed data 90° counterclockwise.
[0056] In some implementations, the libyuv library is used to rotate each row of data in the first format data corresponding to the video frame to be processed by a target angle according to the target direction to obtain the first rotation data corresponding to the video frame to be processed; the libyuv library is used to rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
[0057] libyuv is an open-source library from Google that implements various conversions, rotations, and scaling between YUV and RGB. It is cross-platform and can be compiled and executed on operating systems such as Windows, Linux, Mac, and Android. It supports SIMD instruction acceleration such as SSE, AVX, and NEON. However, the libyuv library cannot be used directly on Android devices and needs to be compiled.
[0058] In some implementations, a preset function can be used to rotate each row of data in the first format data corresponding to the video frame to be processed by a target angle according to the target direction to obtain the first rotation data corresponding to the video frame to be processed; and a preset function can be used to rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
[0059] Among them, the preset functions can be written according to requirements and can be directly applied to Android devices.
[0060] S204. Determine the target data corresponding to the video frame to be processed based on the first rotation data and the second rotation data corresponding to the video frame to be processed.
[0061] After obtaining the first rotation data and the second rotation data corresponding to the video frame to be processed, the target data corresponding to the video frame to be processed is obtained as follows: Figure 8 As shown, the target data corresponding to the video frame to be processed is horizontal.
[0062] S205. Determine the final video corresponding to the target video based on the target data of each video frame to be processed in the target video.
[0063] Each video frame to be processed in the target video has its own target data in the horizontal direction, and the final video corresponding to the target video is also in the horizontal direction, which is consistent with the default camera orientation of Android devices.
[0064] The description of S205 is the same as that of S104 above, and will not be repeated here.
[0065] In this embodiment, by acquiring the first format data, second format data, and third format data corresponding to the video frame to be processed in the target video, and then interleaving each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed, preprocessed data corresponding to the video frame to be processed is obtained. During the data arrangement process, one row of data is interleaved each time, instead of the data of each pixel individually, which improves the data format conversion speed. Then, the first format data and each row of data in the preprocessed data corresponding to the video frame to be processed are rotated according to the target direction to obtain the first rotation data and the second rotation data corresponding to the video frame to be processed. Finally, based on the first rotation data and the second rotation data corresponding to the video frame to be processed, the target data corresponding to the video frame to be processed is determined, thereby determining the final video corresponding to the target video. The direction of the final video obtained is consistent with the default camera direction of the Android device, and no additional rotation operation is required, which simplifies the data format conversion steps and improves the efficiency of data format conversion.
[0066] See appendix Figure 9 , Figure 9 This illustration shows a structural block diagram of a video processing apparatus according to an embodiment of this application. For use in an electronic device, the apparatus 900 includes: The acquisition module 901 is used to acquire the first format data, the second format data, and the third format data corresponding to the video frame to be processed in the target video; the second format data and the third format data corresponding to the video frame to be processed have the same number of rows. Processing module 902 is used to interleave each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed to obtain the preprocessed data corresponding to the video frame to be processed. The first determining module 903 is used to obtain the target data corresponding to the video frame to be processed based on the first format data and preprocessed data corresponding to the video frame to be processed. The second determining module 904 is used to determine the final video corresponding to the target video based on the target data of each video frame to be processed in the target video.
[0067] Optionally, the first determining module 903 is further configured to rotate each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotated data corresponding to the video frame to be processed; rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotated data corresponding to the video frame to be processed; and determine the target data corresponding to the video frame to be processed based on the first rotated data and the second rotated data corresponding to the video frame to be processed.
[0068] Optionally, the first determining module 903 is further configured to determine a target point based on the number of data rows and the number of data in each data row of the first format data corresponding to the video frame to be processed; and rotate each data row in the first format data corresponding to the video frame to be processed in the target direction with the target point as the rotation center to obtain the first rotation data corresponding to the video frame to be processed.
[0069] Optionally, the first determining module 903 is further configured to rotate each row of data in the first format data corresponding to the video frame to be processed by a target angle according to the target direction to obtain the first rotation data corresponding to the video frame to be processed; the target angle is any one of 90 degrees, 180 degrees and 270 degrees; and rotate each row of data in the preprocessed data corresponding to the video frame to be processed by a target angle according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
[0070] Optionally, the first determining module 903 is further configured to rotate each row of data in the first format data corresponding to the video frame to be processed by a target angle according to the target direction using the libyuv library to obtain the first rotation data corresponding to the video frame to be processed; and to rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction using the libyuv library to obtain the second rotation data corresponding to the video frame to be processed.
[0071] Optionally, the first format data corresponding to the video frame to be processed is stored in the first plane, the second format data corresponding to the video frame to be processed is stored in the second plane, and the third format data corresponding to the video frame to be processed is stored in the third plane; the first determining module 903 is further configured to interleave each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed to obtain preprocessed data corresponding to the video frame to be processed; and to obtain target data corresponding to the video frame to be processed based on the first format data and the preprocessed data, including: interleaving each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed, and storing the interleaving result in the fourth plane to obtain the preprocessed data corresponding to the video frame to be processed; and to obtain target data corresponding to the video frame to be processed based on the data in the first plane and the data in the fourth plane.
[0072] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0073] Furthermore, the functions in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module.
[0074] Please refer to Figure 10 This document illustrates a structural block diagram of an electronic device according to an embodiment of this application. The electronic device 1000 can be a smartphone, tablet computer, e-reader, vehicle, or other electronic device capable of running applications. The electronic device 1000 in this application may include one or more components: a processor 1010, a memory 1020, and one or more applications. One or more applications may be stored in the memory 1020 and configured to be executed by one or more processors 1010, and the one or more applications are configured to perform the methods described in the foregoing method embodiments.
[0075] The processor 1010 may include one or more processing cores. The processor 1010 connects to various parts within the electronic device 1000 using various interfaces and lines, and performs various functions and processes data of the electronic device 1000 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1020, and by calling data stored in the memory 1020. Optionally, the processor 1010 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 1010 may integrate one or more of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 1010 and may be implemented separately using a communication chip.
[0076] The memory 1020 may include random access memory (RAM) or read-only memory (ROM). The memory 1020 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 1020 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the methods described in the embodiments below. The data storage area may also store data created by the electronic device 1000 during use (such as phonebook data, audio and video data, chat log data, etc.).
[0077] See appendix Figure 11 , Figure 11 A structural block diagram of a computer-readable storage medium provided in an embodiment of this application is shown. The computer-readable storage medium 1100 stores program code that can be called by a processor to execute the methods described in the above method embodiments.
[0078] The computer-readable storage medium 1100 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 1100 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 1100 has storage space for program code 1110 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 1110 may, for example, be compressed in a suitable form.
[0079] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A video processing method, characterized in that, The method includes: Acquire first format data, second format data and third format data corresponding to the video frame to be processed in the target video; the second format data and the third format data corresponding to the video frame to be processed have the same number of rows, the first format data represents the luminance component, and the second format data and the third format data respectively represent different chrominance components. The preprocessed data corresponding to the video frame to be processed is obtained by interleaving each row of data in the second format data and each row of data in the third format data. Based on the first format data and preprocessed data corresponding to the video frame to be processed, the target data corresponding to the video frame to be processed is obtained; Based on the target data of each video frame to be processed in the target video, determine the final video corresponding to the target video; The step of obtaining the target data corresponding to the video frame to be processed based on the first format data and preprocessed data includes: Rotate each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotation data corresponding to the video frame to be processed. Rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotation data corresponding to the video frame to be processed. The target data corresponding to the video frame to be processed is determined based on the first rotation data and the second rotation data corresponding to the video frame to be processed.
2. The method according to claim 1, characterized in that, The step of rotating each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotation data corresponding to the video frame to be processed includes: The target point is determined based on the number of data rows and the number of data items in each data row of the first format data corresponding to the video frame to be processed; Using the target point as the rotation center, rotate each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotation data corresponding to the video frame to be processed.
3. The method according to claim 1, characterized in that, The step of rotating each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotated data corresponding to the video frame to be processed, and rotating each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotated data corresponding to the video frame to be processed, includes: The data in each row of the first format data corresponding to the video frame to be processed is rotated by a target angle according to the target direction to obtain the first rotation data corresponding to the video frame to be processed; the target angle is any one of 90 degrees, 180 degrees and 270 degrees. The data in each row of the preprocessed data corresponding to the video frame to be processed is rotated by the target angle according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
4. The method according to claim 1, characterized in that, The step of rotating each row of data in the first format data corresponding to the video frame to be processed according to the target direction to obtain the first rotated data corresponding to the video frame to be processed, and rotating each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotated data corresponding to the video frame to be processed, includes: The libyuv library is used to rotate each row of data in the first format data corresponding to the video frame to be processed by the target angle according to the target direction to obtain the first rotation data corresponding to the video frame to be processed. The libyuv library is used to rotate each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain the second rotation data corresponding to the video frame to be processed.
5. The method according to claim 1, characterized in that, The first format data corresponding to the video frame to be processed is stored in the first plane, the second format data corresponding to the video frame to be processed is stored in the second plane, and the third format data corresponding to the video frame to be processed is stored in the third plane. The preprocessed data corresponding to the video frame to be processed is obtained by interleaving each row of data in the second format data and each row of data in the third format data. Based on the first format data and preprocessed data corresponding to the video frame to be processed, the target data corresponding to the video frame to be processed is obtained, including: The data in the second format data and the data in the third format data corresponding to the video frame to be processed are interleaved, and the result of the interleaving is stored in the fourth plane to obtain the preprocessed data corresponding to the video frame to be processed. Based on the data in the first plane and the data in the fourth plane, the target data corresponding to the video frame to be processed is obtained; Wherein, the number of bytes per row in the second plane and the number of bytes per row in the third plane are half the number of bytes per row in the first plane, the width of the second plane and the width of the third plane are half the width of the first plane, the height of the second plane and the height of the third plane are half the height of the first plane, the number of bytes per row in the fourth plane is half the number of bytes per row in the first plane, the width of the fourth plane is half the width of the first plane, and the height of the fourth plane is the same as the height of the first plane.
6. The method according to claim 1, characterized in that, The number of rows in the first format data corresponding to the video frame to be processed is twice the number of rows in the second format data, and the number of data items in each row of the first format data corresponding to the video frame to be processed is twice the number of data items in each row of the third format data.
7. A video processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire first format data, second format data and third format data corresponding to the video frame to be processed in the target video; the second format data and the third format data corresponding to the video frame to be processed have the same number of rows, the first format data represents the luminance component, and the second format data and the third format data respectively represent different chrominance components. The processing module is used to interleave each row of data in the second format data and each row of data in the third format data corresponding to the video frame to be processed to obtain the preprocessed data corresponding to the video frame to be processed. A first determining module is configured to obtain target data corresponding to the video frame to be processed based on first format data and preprocessed data corresponding to the video frame to be processed; the step of obtaining target data corresponding to the video frame to be processed based on first format data and preprocessed data includes: rotating each row of data in the first format data corresponding to the video frame to be processed according to a target direction to obtain first rotated data corresponding to the video frame to be processed; rotating each row of data in the preprocessed data corresponding to the video frame to be processed according to the target direction to obtain second rotated data corresponding to the video frame to be processed; and determining target data corresponding to the video frame to be processed based on the first rotated data and second rotated data corresponding to the video frame to be processed. The second determining module is used to determine the final video corresponding to the target video based on the target data of each video frame to be processed in the target video.
8. An electronic device, characterized in that, include: One or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being configured to perform the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores processor-executable program code, which, when executed by the processor, causes the processor to perform the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method for generating vertical screen video stream, image processing method, electronic device and video system
CN108650542A
Image processing method, device and equipment and storage medium
CN111882479A