Coding method, device, electronic device and computer readable storage medium
By obtaining the graphics card driver version number and selecting a matching encoding software development toolkit, the problem of the graphics card performance and characteristics cannot be fully utilized, and the efficient performance application of graphics card in audio and video encoding and decoding is achieved.
Patent Information
- Application Number
- CN202110281670.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-16
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-03-16
Smart Images

Figure CN113032041B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of coding technology, and in particular to a coding method, device, electronic device and computer-readable storage medium. Background Art
[0002] As people's requirements for audio and video quality become higher and higher, and hardware computing power continues to increase, audio and video codec technology is also constantly iterating and developing. From 2014 to date, Nvidia has officially released 11 video codec-related NVENC / VideoCodecSDK versions, each with features and performance improvements that match the new generation of hardware. However, these versions are not backward compatible, and each has a restricted range for the driver version. In actual application, one of these versions is used. If a newer version is selected, the graphics card with a relatively low driver version will not be able to use the codec capabilities; conversely, the graphics card with a newer driver version will not be able to fully utilize the performance of the new version and apply new features. Summary of the invention
[0003] The present invention provides a coding method, device, electronic device and computer-readable storage medium, wherein the method enables the graphics card of each coding device to exert the full performance of the new version and apply new features.
[0004] To solve the above technical problems, the first technical solution provided by the present invention is: providing an encoding method, comprising: in response to encoding the data to be encoded, obtaining the graphics card driver version number of the encoding device; selecting an encoding software development tool kit matching the graphics card from multiple encoding software development tool kits based on the graphics card driver version number; and encoding the data to be encoded using the encoding software development tool kit.
[0005] Wherein, before the step of obtaining the version number of the graphics card driver of the encoding device in response to encoding the data to be encoded, it includes: obtaining an encoding application program interface; encapsulating the encoding application program interface to obtain the multiple encoding software development kits.
[0006] The step of obtaining the coding application program interface includes: obtaining the coding application program interface by dynamically introducing the coding application program interface.
[0007] Among them, the method of obtaining the coding application interface by dynamic introduction includes: using the coding application interface to load the program library to obtain the handle of the dynamic link library; detecting the return value of the dynamic link library, and if the return value shows that the loading is successful, obtaining the coding application interface.
[0008] Among them, the encapsulating the coding application program interface to obtain the multiple coding software development kits includes: encapsulating the coding application program interface by using space naming; and separately compiling the encapsulated coding application program interface to obtain the multiple coding software development kits.
[0009] Wherein, the method further comprises: packaging the plurality of encoding software development kits by applying a packaging scale.
[0010] Wherein, in response to encoding the data to be encoded, obtaining the graphics card driver version number of the encoding device includes: reading registry information to obtain the graphics card driver version number of the encoding device; or reading system files to obtain the graphics card driver version number of the encoding device.
[0011] Wherein, in response to encoding the data to be encoded, obtaining the graphics card driver version number of the encoding device includes: executing the graphics card driver module in the graphics card component and intercepting the return information during the execution process, thereby obtaining the graphics card driver version number of the encoding device.
[0012] Among them, the execution of the graphics card driver module in the graphics card component and intercepting the return information during the execution process to obtain the graphics card driver version number of the encoding device include: creating a data transmission channel and a read-write handle so that the graphics card driver module outputs execution information through the data transmission channel, and reads and writes the execution information through the read-write handle; judging whether the graphics card driver module is successfully executed according to the execution information; if so, closing the transmission channel and the write handle, reading the return information in the execution information based on the read handle, and closing the read handle; obtaining the graphics card driver version number of the encoding device according to the return information.
[0013] To solve the above technical problems, the first technical solution provided by the present invention is: to provide an encoding device, comprising: an acquisition module, used to obtain the graphics card driver version number of the encoding device in response to encoding the data to be encoded; a selection module, used to select an encoding software development tool kit matching the graphics card from multiple encoding software development tool kits based on the graphics card driver version number; an encoding module, used to encode the data to be encoded using the encoding software development tool kit.
[0014] To solve the above technical problems, the third technical solution provided by the present invention is: to provide an electronic device, comprising: a memory and a processor, wherein the memory stores program instructions, and the processor calls the program instructions from the memory to execute any of the methods described above.
[0015] In order to solve the above technical problems, the fourth technical solution provided by the present invention is: providing a computer-readable storage medium storing a program file, wherein the program file can be executed to implement any of the methods described above.
[0016] The beneficial effect of the present invention is different from the prior art. In response to encoding the data to be encoded, the present invention obtains the version number of the graphics card driver of the encoding device; selects the encoding software development tool kit matching the graphics card from multiple encoding software development tool kits based on the graphics card driver version number; and encodes the data to be encoded using the encoding software development tool kit. In this way, the graphics card of each encoding device can exert the full performance of the new version and apply new features. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0018] Figure 1 It is a schematic diagram of the flow chart of the first embodiment of the encoding method of the present invention;
[0019] Figure 2 is a schematic flow chart of a second embodiment of an encoding method of the present invention;
[0020] Figure 3 is a schematic structural diagram of an embodiment of an encoding device of the present invention;
[0021] Figure 4 It is a structural schematic diagram of an embodiment of an electronic device of the present invention;
[0022] Figure 5 It is a schematic diagram of the structure of an embodiment of a computer-readable storage medium of the present invention. DETAILED DESCRIPTION
[0023] The terms "first", "second", "third" in this application are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second", "third" can expressly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the embodiments of this application, all directional indications (such as up, down, left, right, front, back...) are only used to explain the relative position relationship, movement, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication also changes accordingly. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the steps or units listed, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0024] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] See also Figure 1 , is a flow chart of the first embodiment of the encoding method of the present invention. Specifically, it includes:
[0027] Step S11: in response to encoding the data to be encoded, obtaining a version number of a graphics card driver of the encoding device.
[0028] Specifically, when encoding the data to be encoded, the version number of the graphics card driver of the encoding device is obtained. The data to be encoded can be video data or audio data. The encoding device can be a mobile phone, a computer, or other device with a graphics card encoding function.
[0029] Since the graphics card does not provide an interface for directly obtaining the driver version number, other methods need to be used to obtain the driver version. In one embodiment, the registry information can be read to obtain the graphics card driver version number of the encoding device. Alternatively, the system file can be read to obtain the graphics card driver version number of the encoding device.
[0030] In another embodiment, the graphics card driver module under the graphics card component directory can also be executed by calling the command execution pipeline, and the return information during the execution process can be intercepted to obtain the graphics card driver version number of the encoding device. Specifically, a data transmission channel and a read-write handle are created so that the graphics card driver module outputs execution information through the data transmission channel, and reads and writes the execution information through the read-write handle. Specifically, whether the graphics card driver module is successfully executed is determined based on the execution information; if the driver module is successfully executed, the transmission channel and the write handle are closed, the return information in the execution information is read based on the read handle, and the read handle is closed; the graphics card driver version number of the encoding device is obtained based on the return information.
[0031] Step S12: selecting an encoding software development kit that matches the graphics card from a plurality of encoding software development kits based on the graphics card driver version number.
[0032] Specifically, after the graphics card driver version number is obtained, an encoding software development kit matching the graphics card is selected from a plurality of encoding software development kits according to the graphics card driver version number.
[0033] Step S13: Encode the data to be encoded using the encoding software development kit.
[0034] Encode the data to be encoded using the encoding SDK of your choice.
[0035] The method shown in this embodiment can select an encoding software development kit suitable for the graphics card according to the driver version number of the graphics card, so that the graphics card can fully exert the performance of the new version and apply new features when performing data encoding.
[0036] See also Figure 2 , is a flow chart of a second embodiment of the encoding method of the present invention. Specifically, steps S23, S24 and S25 in this embodiment are the same as those in the above-mentioned Figure 1 Step S11, step S12 and step S13 in the first embodiment shown in the figure are the same as those in the above Figure 1 The difference of the first embodiment shown is that before step S23, it also includes:
[0037] Step S21: Obtain the coding application program interface.
[0038] Specifically, on the Windows platform, the Nvidia graphics card manufacturer has encapsulated the library files related to encoding and decoding in the application layer. These library files are used to deal with the hardware interface. After the corresponding Nvidia graphics card driver is installed, the library files related to encoding and decoding exist in the system environment. When encoding, it is necessary to select a suitable hardware interface. Specifically, the encoding application program interface is obtained. In one embodiment, the encoding application program interface can be obtained by dynamic introduction. The library file used here is nvEncodeAPI.dll. The dynamic introduction method is to use the encoding application program interface of Windows to load the program library and obtain the handle of the dynamic link library. In this way, it is not necessary to list all the routines to be introduced at the beginning of the program, and only need to introduce them before calling. And the loading program library can specify the handles of different dynamic link libraries. If the specified dynamic link library fails, it is only the failure to call the encoding application program interface, which will not cause the program to be terminated. Therefore, it is necessary to detect the return value of the dynamic link library. If the return value shows that the loading is successful, the encoding application program interface is obtained. If the return value shows that the loading fails, the current process is exited.
[0039] Step S22: Encapsulate the coding application program interface to obtain the multiple coding software development kits.
[0040] Specifically, the coding application program interface can be encapsulated by using a spatial naming method. In one embodiment, the obtained coding application program interface has its corresponding header file, and each header file can be encapsulated by using a spatial naming method so that each coding application program interface has its unique naming file. Furthermore, the encapsulated coding application program interface can be compiled separately to obtain the multiple coding software development kits, so that the multiple coding software development kits can be compiled into static libraries without interfering with each other.
[0041] In another embodiment, the plurality of encoding software development kits may be packaged by using an application packaging scale. Specifically, when the application packaging scale is created, the graphics card driver version number of the current encoding device is obtained, so that when encoding is performed, a matching encoding software development kit may be selected according to the graphics card driver version number.
[0042] This embodiment is encapsulated through packaging methods such as space naming, static library, and application packaging scale, to achieve a highly compatible multi-version encoding software development toolkit. When encoding, the encoding software development toolkit suitable for the graphics card is selected according to the driver version number of the graphics card, so that the graphics card can exert the full performance of the new version and apply new features when encoding data.
[0043] See also Figure 3, is a schematic diagram of the structure of an embodiment of an encoding device of the present invention. Specifically, the encoding device 30 of this embodiment includes an acquisition module 31, a selection module 32 and an encoding module 33.
[0044] The acquisition module 31 is used for acquiring a graphics card driver version number of the encoding device in response to encoding the data to be encoded.
[0045] Specifically, when encoding the data to be encoded, the version number of the graphics card driver of the encoding device is obtained. The data to be encoded can be video data or audio data. The encoding device can be a mobile phone, a computer, or other device with a graphics card encoding function.
[0046] Since the graphics card does not provide an interface for directly obtaining the driver version number, other methods need to be used to obtain the driver version. In one embodiment, the registry information can be read to obtain the graphics card driver version number of the encoding device. Alternatively, the system file can be read to obtain the graphics card driver version number of the encoding device.
[0047] In another embodiment, the graphics card driver module under the graphics card component directory can also be executed by calling the command execution pipeline, and the return information during the execution process can be intercepted to obtain the graphics card driver version number of the encoding device. Specifically, a data transmission channel and a read-write handle are created so that the graphics card driver module outputs execution information through the data transmission channel, and reads and writes the execution information through the read-write handle. Specifically, whether the graphics card driver module is successfully executed is determined based on the execution information; if the driver module is successfully executed, the transmission channel and the write handle are closed, the return information in the execution information is read based on the read handle, and the read handle is closed; the graphics card driver version number of the encoding device is obtained based on the return information.
[0048] Furthermore, in one embodiment, the acquisition module 31 is also used to acquire a coding application program interface.
[0049] Specifically, on the Windows platform, the Nvidia graphics card manufacturer has encapsulated the library files related to encoding and decoding in the application layer. These library files are used to deal with the hardware interface. After the corresponding Nvidia graphics card driver is installed, the library files related to encoding and decoding exist in the system environment. When encoding, it is necessary to select a suitable hardware interface. Specifically, the encoding application program interface is obtained. In one embodiment, the encoding application program interface can be obtained by dynamic introduction. The library file used here is nvEncodeAPI.dll. The dynamic introduction method is to use the encoding application program interface of Windows to load the program library and obtain the handle of the dynamic link library. In this way, it is not necessary to list all the routines to be introduced at the beginning of the program, and only need to introduce them before calling. And the loading program library can specify the handles of different dynamic link libraries. If the specified dynamic link library fails, it is only the failure to call the encoding application program interface, which will not cause the program to be terminated. Therefore, it is necessary to detect the return value of the dynamic link library. If the return value shows that the loading is successful, the encoding application program interface is obtained. If the return value shows that the loading fails, the current process is exited.
[0050] Furthermore, in one embodiment, the acquisition module 31 is also used to encapsulate the coding application program interface to obtain the multiple coding software development kits.
[0051] Specifically, the coding application program interface can be encapsulated by using a spatial naming method. In one embodiment, the obtained coding application program interface has its corresponding header file, and each header file can be encapsulated by using a spatial naming method so that each coding application program interface has its unique naming file. Furthermore, the encapsulated coding application program interface can be compiled separately to obtain the multiple coding software development kits, so that the multiple coding software development kits can be compiled into static libraries without interfering with each other.
[0052] In another embodiment, the plurality of encoding software development kits may be packaged by using an application packaging scale. Specifically, when the application packaging scale is created, the graphics card driver version number of the current encoding device is obtained, so that when encoding is performed, a matching encoding software development kit may be selected according to the graphics card driver version number.
[0053] The selection module 32 is used to select an encoding software development tool kit that matches the graphics card from multiple encoding software development tool kits based on the graphics card driver version number.
[0054] Specifically, after the graphics card driver version number is obtained, an encoding software development kit matching the graphics card is selected from a plurality of encoding software development kits according to the graphics card driver version number.
[0055] The encoding module 33 is used to encode the data to be encoded using the encoding software development kit.
[0056] Encode the data to be encoded using the encoding SDK of your choice.
[0057] The encoding device shown in this embodiment can select an encoding software development kit suitable for the graphics card according to the driver version number of the graphics card, so that the graphics card can exert the full performance of the new version and apply new features when performing data encoding.
[0058] See also Figure 4 , is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention, the electronic device includes a memory 202 and a processor 201 connected to each other.
[0059] The memory 202 is used to store program instructions for implementing any one of the above methods.
[0060] The processor 201 is used to execute program instructions stored in the memory 202 .
[0061] The processor 201 may also be referred to as a CPU (Central Processing Unit). The processor 201 may be an integrated circuit chip having signal processing capabilities. The processor 201 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0062] The memory 202 can be a memory stick, a TF card, etc., which can store all the information in the electronic device of the device, including the input raw data, computer programs, intermediate operation results and final operation results are all stored in the memory. It stores and retrieves information according to the location specified by the controller. With the memory, the electronic device has a memory function to ensure normal operation. The memory of the electronic device can be divided into main memory (internal memory) and auxiliary memory (external memory) according to its use. There is also a classification method of dividing it into external memory and internal memory. External memory is usually a magnetic medium or an optical disk, etc., which can store information for a long time. Memory refers to the storage component on the motherboard, which is used to store the data and programs currently being executed, but is only used to temporarily store programs and data. If the power is turned off or the power is cut off, the data will be lost.
[0063] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0064] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0065] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0066] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a system server, or a network device, etc.) or a processor to execute all or part of the steps of the various implementation methods of the present application.
[0067] See also Figure 5, which is a schematic diagram of the structure of the computer-readable storage medium of the present invention. The storage medium of the present application stores a program file 203 that can implement all the above methods, wherein the program file 203 can be stored in the above storage medium in the form of a software product, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of each implementation method of the present application. The aforementioned storage device includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, etc., which can store program codes, or terminal devices such as computers, servers, mobile phones, and tablets.
[0068] The above are only implementation modes of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A coding method, characterized in that: include: Get the encoding API; Encapsulating the coding application program interface to obtain multiple coding software development kits; Specifically, the method comprises: encapsulating the coding application program interface by using a spatial naming method; separately compiling the encapsulated coding application program interface to obtain the plurality of coding software development toolkits; wherein the plurality of coding software development toolkits do not interfere with each other; In response to encoding the data to be encoded, obtaining a version number of a graphics card driver of the encoding device; Selecting an encoding software development kit that matches the graphics card from the plurality of encoding software development kits based on the graphics card driver version number; The data to be encoded is encoded using the encoding software development kit.
2. The encoding method according to claim 1, characterized in that The acquisition coding application program interface includes: The encoding application program interface is obtained by dynamically introducing the encoding application program interface.
3. The encoding method according to claim 2, characterized in that The method of obtaining the coding application program interface by dynamically introducing the coding application program interface includes: Using the coded application program interface to load a program library to obtain a handle to a dynamic link library; The return value of the dynamic link library is detected, and if the return value indicates that the loading is successful, the coding application program interface is obtained.
4. The encoding method according to claim 1, characterized in that In response to encoding the data to be encoded, obtaining the version number of the graphics card driver of the encoding device includes: Reading registry information to obtain the graphics card driver version number of the encoding device; or The system file is read to obtain the version number of the graphics card driver of the encoding device.
5. The encoding method according to claim 1, characterized in that: In response to encoding the data to be encoded, obtaining the version number of the graphics card driver of the encoding device includes: The graphics card driver module in the graphics card component is executed, and the return information during the execution process is intercepted to obtain the graphics card driver version number of the encoding device.
6. The method according to claim 5, characterized in that The step of executing the graphics card driver module in the graphics card component and intercepting the return information during the execution process to obtain the graphics card driver version number of the encoding device includes: Creating a data transmission channel and a read / write handle, so that the graphics card driver module outputs execution information through the data transmission channel, and reads and writes the execution information through the read / write handle; Determining whether the graphics card driver module is successfully executed according to the execution information; If yes, close the transmission channel and the write handle, read the return information in the execution information based on the read handle, and close the read handle; The graphics card driver version number of the encoding device is obtained according to the returned information.
7. A coding device, characterized in that: include: An acquisition module, used for acquiring a coding application program interface; It is also used to encapsulate the coding application program interface to obtain multiple coding software development kits; Specifically, the method comprises: encapsulating the coding application program interface by using a spatial naming method; separately compiling the encapsulated coding application program interface to obtain the plurality of coding software development toolkits; wherein the plurality of coding software development toolkits do not interfere with each other; The acquisition module is further used to acquire a graphics card driver version number of the encoding device in response to encoding the data to be encoded; A selection module, configured to select an encoding software development kit matching the graphics card from the plurality of encoding software development kits based on the graphics card driver version number; The encoding module is used to encode the data to be encoded using the encoding software development toolkit.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: A program file is stored, and the program file can be executed to implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image processing method
CN101216929A
Built-in real tri-dimension driving method for computer display card
CN101477702A
Method and system for drive protection
CN102902910A
