WO2023246946A1 - 编解码资源分配方法、装置及电子设备 - Google Patents

编解码资源分配方法、装置及电子设备 Download PDF

Info

Publication number
WO2023246946A1
WO2023246946A1 PCT/CN2023/102242 CN2023102242W WO2023246946A1 WO 2023246946 A1 WO2023246946 A1 WO 2023246946A1 CN 2023102242 W CN2023102242 W CN 2023102242W WO 2023246946 A1 WO2023246946 A1 WO 2023246946A1
Authority
WO
WIPO (PCT)
Prior art keywords
resources
protocol
weight
target
decoding
Prior art date
Application number
PCT/CN2023/102242
Other languages
English (en)
French (fr)
Inventor
衣英林
朱昆朋
马强
Original Assignee
杭州海康威视数字技术股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州海康威视数字技术股份有限公司 filed Critical 杭州海康威视数字技术股份有限公司
Publication of WO2023246946A1 publication Critical patent/WO2023246946A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Definitions

  • the present application relates to the field of image processing technology, and in particular to a codec resource allocation method, device and electronic equipment.
  • some video recorders such as NVR (Network Video Recorder, network video recorder), use the same VCP (Video Codec Processor, video codec processor, referred to as hardware unit in this article).
  • VCP Video Codec Processor, video codec processor, referred to as hardware unit in this article.
  • the purpose of the embodiments of the present application is to provide a codec resource allocation method, device and electronic equipment to perform reasonable control and allocation of codec resources.
  • the specific technical solutions are as follows:
  • This embodiment of the present application provides a method for allocating codec resources.
  • the method includes:
  • the target protocol is a target encoding protocol or a target decoding protocol
  • the target resolution and the target frame rate determine the number of encoding and decoding resources that the first type of operation needs to consume, and use the obtained number as the number to be allocated;
  • the number of currently idle codec resources is not less than the number to be allocated, allocate the number of codec resources to be allocated to the media stream to be processed from the currently idle codec resources; and/or,
  • the method further includes:
  • the first type of operation is not performed based on the codec resources
  • processor resources to perform a second type of operation on the media stream to be processed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the method further includes:
  • the electronic device does not support processing the first type of operation, do not perform the first type of operation based on codec resources;
  • processor resources to perform a second type of operation on the media stream to be processed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the method further includes:
  • the processing capabilities of all codec resources are quantified to obtain the total number of all codec resources.
  • the processing capabilities of all codec resources are quantified to obtain the total number of all codec resources, including:
  • the model of the codec resource hardware determine the number of channels of reference media streams that are allowed to be processed simultaneously by all codec resources using the preset baseline encoding protocol or the preset baseline decoding protocol, and use the obtained number of channels as all The total number of codec resources, wherein the resolution of the reference media stream is a preset reference resolution, and the frame rate of the reference media stream is a preset reference frame rate.
  • the number of codec resources that the first type of operation needs to be consumed is determined based on the target protocol, the target resolution and the target frame rate, and the number to be allocated is obtained, include:
  • the predetermined first correspondence determine the weight of the target protocol relative to the preset reference encoding protocol or the preset reference decoding protocol to obtain the first weight, wherein the first correspondence includes various types of encoding
  • the weight of the protocol or decoding protocol relative to the preset base encoding protocol or the preset base decoding protocol which is the encoding protocol used when determining the total number of all encoding and decoding resources. or decode the protocol;
  • the frame rate of the reference media stream is a preset reference frame rate, and the reference media stream is the media stream used when determining the total number of all codec resources;
  • the first weight and the second weight calculate the number of codec resources that the first type of operation needs to consume, and obtain the number to be allocated; wherein, the number of codec resources that the first type of operation needs to consume
  • the quantity to be allocated is the product of the first weight and the second weight.
  • the number of codec resources that the first type of operation needs to be consumed is determined based on the target protocol, the target resolution and the target frame rate, and the number to be allocated is obtained, include:
  • the predetermined first weight table determine the weight of the target protocol relative to the preset reference encoding protocol or the preset reference decoding protocol to obtain the first weight; wherein, each type of protocol is recorded in the first weight table The weight of the encoding protocol or decoding protocol relative to the preset base encoding protocol or the preset base decoding protocol;
  • the first weight and the second weight calculate the number of codec resources that the first type of operation needs to consume, and obtain the number to be allocated; wherein, the number of codec resources that the first type of operation needs to consume
  • the quantity to be allocated is the product of the first weight and the second weight.
  • determining the weights of the target resolution and the target frame rate relative to the reference media stream to obtain the second weight includes:
  • the method further includes: determining the first weight corresponding to the target protocol based on the number of video frames after scalable video coding SVC gradation and the number of video frames before SVC gradation.
  • An embodiment of the present application also provides a device for allocating codec resources.
  • the device includes:
  • the acquisition module is used to obtain the first type of operation for the media stream to be processed
  • a first determination module configured to determine the target protocol, target resolution and target frame rate corresponding to the first type of operation, where the target protocol is a target encoding protocol or a target decoding protocol;
  • a second determination module configured to determine the number of encoding and decoding resources that the first type of operation needs to consume based on the target protocol, the target resolution, and the target frame rate, and use the obtained number as the number to be allocated;
  • An allocation module configured to allocate the number of codec resources to be allocated from the currently idle codec resources to the media stream to be processed when the number of currently idle codec resources is not less than the number to be allocated. ; and/or, a generating module configured to generate prompt information indicating insufficient coding and decoding resources when the number of currently idle coding and decoding resources is less than the number to be allocated.
  • the device further includes:
  • a first processing module configured to perform the first type of operation not based on the codec resources when the number of currently idle codec resources is less than the number to be allocated; and use processor resources to process the media stream to be processed.
  • a second type of operation is performed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the device further includes:
  • a second processing module configured to not perform the first type of operation based on coding and decoding resources when the first type of operation does not require consuming codec resources or the electronic device does not support processing of the first type of operation; Utilize processor resources to perform a second type of operation on the media stream to be processed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the device further includes:
  • the quantization module is used to quantify the processing capabilities of all encoding and decoding resources during the initialization process to obtain the total number of all encoding and decoding resources.
  • the quantization module is specifically used to:
  • the model of the codec resource hardware determine the number of channels of reference media streams that are allowed to be processed simultaneously by all codec resources using the preset baseline encoding protocol or the preset baseline decoding protocol, and use the obtained number of channels as all The total number of codec resources, wherein the resolution of the reference media stream is a preset reference resolution, and the frame rate of the reference media stream is a preset reference frame rate.
  • the second determination module includes:
  • the first determination sub-module is used to determine the weight of the target protocol relative to the preset reference encoding protocol or the preset reference decoding protocol according to the predetermined first correspondence relationship, and obtain the first weight, wherein the first weight A corresponding relationship includes weights of various types of encoding protocols or decoding protocols relative to a preset base encoding protocol or a preset base decoding protocol, and the preset base encoding protocol or the preset base decoding protocol
  • the quasi-decoding protocol is the encoding protocol or decoding protocol used when determining the total number of all encoding and decoding resources;
  • the second determination sub-module is used to determine the weight of the target resolution and the target frame rate relative to the reference media stream, and use the determined weight as the second weight, wherein the resolution of the reference media stream is the preset reference resolution, the frame rate of the reference media stream is the preset reference frame rate, and the reference media stream is the media stream used when determining the total number of all codec resources;
  • the calculation submodule is used to calculate the number of encoding and decoding resources that the first type of operation needs to consume according to the first weight and the second weight, and obtain the amount to be allocated; wherein, the first type of operation
  • the number of encoding and decoding resources that need to be consumed to be allocated is the product of the first weight and the second weight.
  • the second determination sub-module is specifically used to:
  • An embodiment of the present application also provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
  • Memory used to store computer programs
  • the processor is used to implement any of the above encoding and decoding resource allocation methods when executing a program stored in the memory.
  • Embodiments of the present application also provide a computer-readable storage medium.
  • a computer program is stored in the computer-readable storage medium.
  • the computer program is executed by a processor, any one of the above codec resource allocation methods is implemented.
  • Embodiments of the present application also provide a computer program product containing instructions that, when run on a computer, cause the computer to execute any one of the encoding and decoding resource allocation methods described above.
  • the codec resource allocation method, device and electronic equipment provided by the embodiments of this application first obtain the first type of operation for the media stream to be processed, and then determine the target protocol, target resolution and target frame rate corresponding to the first type of operation. According to the target protocol, target resolution and target frame rate, determine the number of codec resources that the first type of operation needs to consume, and obtain the number to be allocated. When the number of currently idle codec resources is not less than the number to be allocated, from Allocate a to-be-allocated number of codec resources among the currently idle codec resources for the media stream to be processed. When the number of currently idle codec resources is less than the number to be allocated, prompt information indicating insufficient codec resources is generated. By combining The target protocol, resolution, and frame rate are used to determine the codec resources required to perform operations requiring codec resources on the code stream to be processed, which can reduce resource calculation errors and achieve reasonable control and allocation of codec resources.
  • the processor resources are used to perform operations that do not require codec resources on the media stream to be processed. , Therefore, even if an operation that requires encoding and decoding resources cannot be performed due to insufficient current encoding and decoding resources, other operations that do not require encoding and decoding resources can be performed normally, thereby ensuring that the encoding and decoding related operation processes proceed more smoothly.
  • Figure 1 is a schematic flowchart of a first method for allocating codec resources provided by an embodiment of the present application
  • Figure 2 is a schematic flowchart of the second method for allocating codec resources provided by an embodiment of the present application
  • Figure 3 is a third flow diagram of a codec resource allocation method provided by an embodiment of the present application.
  • Figure 4 is a schematic flowchart of the fourth method for allocating codec resources provided by an embodiment of the present application.
  • Figure 5a is a schematic flowchart of the fifth method for allocating codec resources provided by an embodiment of the present application.
  • Figure 5b is a first schematic diagram showing prompt information of insufficient codec resources in the codec resource allocation method provided by the embodiment of the present application;
  • Figure 5c is a second schematic diagram showing prompt information of insufficient codec resources in the codec resource allocation method provided by the embodiment of the present application.
  • Figure 6 is a schematic structural diagram of a codec resource allocation device according to an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • embodiments of the present application provide a codec resource allocation method, device, electronic device, storage medium, and computer program product containing instructions.
  • the encoding and decoding resource allocation method provided by the embodiment of the present application is first introduced.
  • This method is applied to electronic devices.
  • the electronic device can be any electronic device that can provide media stream encoding and decoding resource allocation services, such as mobile phones, tablets, personal computers, servers, etc.
  • the encoding and decoding resource allocation method provided by the embodiments of the present application can be implemented by at least one of software, hardware circuits, and logic circuits provided in the electronic device.
  • Figure 1 is a schematic flowchart of a first method for allocating codec resources provided by an embodiment of the present application. The method includes:
  • the target protocol is a target encoding protocol or a target decoding protocol; where, for the encoding process, the target protocol (i.e. target encoding protocol ) is the coding standard that the first type of operation complies with, that is, the coding standard that the data after the first type of operation complies with, the target resolution is the resolution that the data after the first type of operation complies with, and the target frame rate is the The frame rate the data conforms to.
  • the target protocol i.e. target encoding protocol
  • the target resolution is the resolution that the data after the first type of operation complies with
  • the target frame rate is the The frame rate the data conforms to.
  • the target protocol i.e., the target decoding protocol
  • the target decoding protocol is the decoding standard that the first type of operation conforms to, that is, the data before the first type of operation conforms to the decoding standard
  • the target resolution is the data before the first type of operation conforms to.
  • target frame rate is the frame rate that the data before the first type of operation conforms to.
  • the number of encoding and decoding resources refers to the number of encoding and decoding resources that need to be used to perform the first type of operation, that is, how many encoding and decoding resources can be used to complete the first type of operation.
  • the number of currently idle codec resources refers to: the number of coding and decoding resources currently remaining in the electronic device, That is, the number of unoccupied encoding and decoding resources.
  • the media stream can be video or audio.
  • Some related operations of the media stream can be called second-category operations, such as: parsing, storage, forwarding, etc.
  • the second-category operations only require code stream parsing, storage and forwarding, and There is no need to preview, playback, etc., therefore, the second type of operation can be completed through processor resources or through encoding and decoding resources.
  • the second type of operation is defined as an operation completed through processor resources, and No codec resources are required.
  • some related operations of media streams can be called first-type operations, such as preview, playback, etc.
  • the first-type operations are operations that require encoding and decoding resources.
  • the number of encoding and decoding resources refers to a parameter obtained by quantifying encoding and decoding capabilities, and is used to measure the size of encoding and decoding capabilities. Quantifying encoding and decoding capabilities into computable units helps determine the match between resources and requirements.
  • codec in this article is a synonym for "encoding or decoding”. In the decoding scenario, this word means “decoding”; in the encoding scenario, it means “encoding”. the meaning of.
  • a coding and decoding resource allocation method can be understood as: a coding resource allocation method, or a decoding resource allocation method.
  • the embodiments given in this application and the solutions expected to be protected can be understood as a solution related to encoding or a solution related to decoding, and will not be described again here. Each complete program.
  • the above method further includes:
  • the above-mentioned first type of operation is not performed (that is, the above-mentioned first type of operation is not performed based on the codec resources); the above-mentioned media stream to be processed is received, and the processing
  • the processor resource performs the second type of operation on the above-mentioned media stream to be processed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the above method further includes:
  • the above-mentioned first type of operation does not require consuming codec resources, or the electronic device does not support processing the above-mentioned first type of operation
  • the above-mentioned first type of operation is not performed (that is, the above-mentioned first type of operation is not performed based on the codec resources); Receive the above-mentioned media stream to be processed, and use processor resources to perform a second type of operation on the above-mentioned media stream to be processed, wherein the second type of operation and the first type of operation are different operations, and the processor resources and codec resources are different Data processing resources.
  • the first type of operation does not require consuming encoding and decoding resources or the electronic device does not support processing the first type of operation, it will not be executed.
  • the first type of operation after receiving the media stream to be processed, uses the processor resources to perform the second type of operation on the media stream to be processed, such as parsing, storing, forwarding, etc.
  • the electronic device when the electronic device cannot support processing of the first type of operation, for example, the electronic device only supports processing of encoding and decoding operations of the H.264 and H.265 protocols, when the first type of operation is other than the H.264 and H.265 protocols. When encoding and decoding operations of other types of protocols, the electronic device does not support processing the first type of operation. After receiving the media stream to be processed, the electronic device uses processor resources to perform operations on the media stream to be processed.
  • the processor resources can still be reasonably used to maintain the parsing, storage, and forwarding of the code stream.
  • the above method further includes:
  • the processing capabilities of all codec resources are quantified to obtain the total number of all codec resources.
  • the processing capabilities of all codec resources need to be quantified to obtain the total number of all codec resources.
  • the processing capabilities of all codec resources are quantified to obtain the total number of all codec resources, including:
  • the model of the codec resource hardware determine the number of reference media streams that all codec resources are allowed to process simultaneously when using the preset reference encoding protocol or the preset reference decoding protocol, and obtain all The total number of codec resources, wherein the resolution of the above-mentioned reference media stream is the preset reference resolution, and the frame rate of the above-mentioned reference media stream is the preset reference frame rate.
  • first set a base media stream For example, use H.265 1080P@30FPS to decode the media stream as the base media stream. That is, set the resources occupied by decoding 1 channel of H.265 1080P@30FPS to KP (K Proportionality, proportional coefficient), then based on the benchmark media stream, determine the number of benchmark media streams that the codec resources allow to be processed simultaneously, so as to obtain the total number of all codec resources. For example, the total codec capability obtained is x ⁇ KP.
  • the total VCP decoding capability of a device is 16 channels of H.265 1080P@30FPS video
  • the total encoding and decoding capability is 16 ⁇ KP, that is, it can decode 16 channels of 1080P@30FPS media streams at the same time.
  • the setting of the reference media stream can be set based on the actual situation and is not limited here.
  • Figure 2 is a second flow diagram of the codec resource allocation method provided by the embodiment of the present application.
  • the above step S130 can be implemented through the following steps:
  • the preset reference encoding protocol or the preset reference decoding protocol determine the weight of the target protocol relative to the preset reference encoding protocol or the preset reference decoding protocol, and obtain the first weight, the above-mentioned preset reference encoding protocol Or the default base decoding protocol is the encoding protocol or decoding protocol used when determining the total number of all encoding and decoding resources;
  • S133 According to the above-mentioned first weight value and the above-mentioned second weight value, calculate the number of codec resources that need to be consumed by the above-mentioned first type of operation, and obtain the number to be allocated; wherein, the number of codec resources that need to be consumed by the first type of operation is to be allocated.
  • the quantity may be the product of the first weight and the second weight.
  • the number of codec resources is related to the target protocol, resolution and frame rate.
  • the weight of the target protocol relative to the default base encoding protocol or the default base decoding protocol can be determined, for example, using H.265 1080P@30FPS to decode the media stream is the base media stream, that is, setting the H.265 protocol as the base decoding protocol, then relative to the H.265 protocol, the weight of the target decoding protocol in the H.265 decoding scenario is 1, because the encoding performance consumption will be higher than If decoding is high, H.265 encoding can set different weights based on measured performance consumption.
  • the weight corresponding to H.264 encoding or decoding can be obtained through performance testing or theoretical calculation.
  • the SVC code stream in this application generally refers to Time domain grading, that is, some frames in the media stream can not be decoded to reduce decoding performance consumption, that is, the reduction of video frames mainly for encoding and decoding will not change the original data stream, and the target protocol is determined based on the number of video frames after SVC grading
  • the corresponding first weight for example, if the number of video frames after SVC classification is 1/2 of the original (that is, the number of video frames participating in encoding and decoding is 1/2 of the original number of video frames), then the first weight is 0.5; if the number of video frames is 1/4 of the original, the first weight is 0.25.
  • the second weight corresponding to the media stream to be processed is determined based on the resolution of the reference media stream, the frame rate of the reference media stream, the target resolution, and the target frame rate.
  • the calculation method for the second weight corresponding to the media stream to be processed can be: Divide the product of the resolution and the frame rate of the media stream to be processed by the product of the resolution of the base media stream and the frame rate of the base media stream.
  • step S132 can be implemented through the following steps:
  • the H.265 1080P@30FPS decoded media stream is used as the base media stream, and the resources occupied by decoding 1 channel of H.2651080P@30FPS are set to KP.
  • the pixels are CIF 10w
  • the media stream to be processed with a resolution of 352 ⁇ 288 and a frame rate of 30 has a weight of 352 ⁇ 288 ⁇ 30/(1920 ⁇ 1080 ⁇ 30) ⁇ 0.05.
  • the number of encoding and decoding resources that the first type of operation needs to consume based on the first weight and the second weight, and obtain the amount to be allocated.
  • the number of encoding and decoding resources that need to be consumed by the first type of operation i.e., the amount to be allocated
  • the amount to be allocated is the product of the first weight and the second weight.
  • H.265 1080P@30FPS decoded media stream For example, take the H.265 1080P@30FPS decoded media stream as the base media stream, and set the resources occupied by decoding 1 channel of H.265 1080P@30FPS to KP.
  • the decoding weight table (i.e., the second weight table) is shown in Table 1:
  • H.265 non-typical resolution frame rate video based on 1080P, divide the product of the resolution of the media stream to be processed and the frame rate by the product of the resolution of the base media stream and the frame rate of the base media stream, linearly calculate and then round.
  • the second weight corresponding to the media stream to be processed 1000 ⁇ 1000 ⁇ 25/(1920 ⁇ 1080 ⁇ 30) ⁇ 0.4, then the video of 1000 ⁇ 1000@25FPS will be decoded.
  • the resource is 0.4KP.
  • H.264 encoding or decoding meets the resolution and frame rate information in Table 1, you can directly multiply the first weight corresponding to H.264 encoding or decoding according to the second weight in Table 1; if it does not meet the resolution in Table 1 rate and frame rate information, then divide the product of the resolution of the media stream to be processed and the frame rate by the product of the resolution of the base media stream and the frame rate of the base media stream to obtain the second weight, and then multiply the second weight
  • the corresponding first weight is encoded or decoded in corresponding H.264.
  • the second weight corresponding to H.264/JPG is k1
  • m is the first weight corresponding to the H.264 encoding protocol
  • the resources occupied by H.264/JPG decoding KP2 (m ⁇ K1)KP.
  • this application manages encoding and decoding resources in a unified manner, reasonably plans encoding and decoding resources, and designs weight values based on various target protocols, resolutions, operating scenarios, etc., which can reduce resource calculation errors and achieve optimal encoding and decoding resources. Reasonably control distribution.
  • step S130 can be implemented through the following steps:
  • the weight value of the above-mentioned target protocol relative to the preset reference encoding protocol or the preset reference decoding protocol is determined to obtain the first weight value, wherein the above-mentioned first correspondence relationship includes various types of encoding protocols or The weight of the decoding protocol relative to the default base encoding protocol or the default base decoding protocol, which is the encoding protocol or decoding protocol used when determining the total number of all encoding and decoding resources.
  • the number of video frames corresponding to the type of encoding protocol or decoding protocol (that is, the number of video frames participating in encoding and decoding per unit time, that is, the number of all video frames or partial video frames in all video frames) is different from the default baseline encoding protocol or
  • the proportional relationship between the number of video frames corresponding to the preset reference decoding protocol (that is, the number of video frames participating in encoding and decoding per unit time, that is, the number of all video frames or partial video frames in all video frames) determines the first weight.
  • a preset baseline encoding protocol or preset assumee the ratio of the number of video frames participating in encoding or decoding (or the number of video frames not participating in encoding or decoding) of the benchmark decoding protocol to the number of all video frames, and the first weight is determined based on the relationship between these two ratios.
  • the ratio of the number of video frames participating in encoding or decoding of protocol type A to the number of all video frames is 100%, and the number of video frames participating in encoding or decoding of the default baseline encoding protocol or the preset baseline decoding protocol is 100%.
  • the ratio of the number of frames is 50%, then the first The weight is 2.
  • the ratio of the number of video frames participating in encoding or decoding of protocol type A to the number of all video frames is 25%, and the number of video frames participating in encoding or decoding of the default baseline encoding protocol or the preset baseline decoding protocol is 25%.
  • the ratio of the number of frames is 50%, then the first weight is 0.5.
  • the purpose of the first weight is to determine the encoding and decoding resources that are required for frames that actually need to participate in encoding and decoding. For example, see Table 2 for an example of the first correspondence relationship.
  • the resolution of the reference media stream is a preset reference resolution
  • the frame rate of the reference media stream is a preset Assuming the base frame rate, the above-mentioned base media stream is the media stream used when determining the total number of all codec resources;
  • first weight and the above-mentioned second weight calculate the number of codec resources that need to be consumed by the above-mentioned first type of operation, and obtain the number to be allocated; wherein, the number of codec resources that need to be consumed by the first type of operation to be allocated is The product of the first weight and the second weight.
  • the first correspondence relationship between the weights of various types of encoding protocols or decoding protocols with respect to the preset reference encoding protocol or the preset reference decoding protocol can be stored in advance. In this way, the target protocol can be determined directly according to the predetermined first correspondence relationship.
  • the first weight value is obtained based on the weight value of the default base encoding protocol or the default base decoding protocol, thereby reducing the amount of calculation.
  • the first correspondence relationship can be stored as the first weight table (that is, the first weight table and the first correspondence relationship can be the same, see Table 2), so that the target protocol relative relationship can be directly determined based on the first weight table.
  • the first weight is obtained based on the weight of the default base encoding protocol or the default base decoding protocol.
  • the first weight table records the weights of each type of encoding protocol or decoding protocol relative to the preset reference encoding protocol or the preset reference decoding protocol. After obtaining the target protocol, based on the target protocol type and the first weight table The corresponding encoding protocol or decoding protocol type is matched to determine the first weight corresponding to the target protocol.
  • the weights of the target resolution and the target frame rate relative to the reference media stream can also be determined according to the predetermined second correspondence relationship to obtain the second weight value.
  • the second correspondence relationship can be used as the second weight table. Storage, so that the second weight values of the target resolution and the target frame rate relative to the reference media stream can be directly determined based on the second weight table.
  • the second weight table records the weight of each resolution and frame rate relative to the reference media stream. After obtaining the target resolution and target frame rate, based on the target resolution and target frame rate and the second weight table The corresponding resolutions and frame rates are matched to determine the second weights of the target resolution and target frame rate relative to the reference media stream.
  • Figure 3 is a third flow diagram of the codec resource allocation method provided by the embodiment of the present application.
  • the above step S130 can be implemented through the following steps:
  • the first weight table and the second weight table may be different tables, or they may be the same table. No limitation is made here.
  • the second weight can be obtained directly from the second weight table.
  • the media stream to be processed is an unconventional
  • the second weight can be obtained through linear calculation, so that the media streams to be processed with typical resolutions and code streams can directly obtain the corresponding weights from the table, and the media streams with non-typical resolutions and code streams to be processed can directly obtain the corresponding weights from the table. Processing media streams is determined through calculations such as linear conversion, which can reduce resource calculation errors and formulate reasonable strategies for resource management.
  • target protocol target resolution and target frame rate
  • the number of codec resources consumed by the first type of operation can be directly obtained through the predetermined codec resource table. If the media stream to be processed is an unconventional media stream, then It can be determined by linear calculation, which can reduce resource calculation errors. In order to formulate reasonable strategies for resource management.
  • FIG. 4 is a schematic flow chart of the fourth method for allocating codec resources provided by embodiments of the present application.
  • this method includes:
  • Step S402 determine whether a preset situation is included; the preset situation includes special situations such as resolution not supported, virtual decoding, etc.
  • Virtual decoding means that no decoding operation is actually performed and decoding resources are not consumed; if so, execute step S408; if not, execute Step S403;
  • S403 determine the number of encoding and decoding resources that the decoding task needs to consume, and obtain the number to be allocated;
  • S405 Allocate a to-be-allocated number of codec resources for the media stream to be processed
  • the above preset when receiving an instruction to stop performing a preset operation on the media stream to be processed, the above preset Assume that the operation is an operation that requires encoding and decoding resources.
  • the above methods include:
  • codec resources When codec resources have been allocated, the allocated codec resources are released and the currently idle codec resources are updated.
  • Figure 5 is a schematic flowchart of the fifth codec resource allocation method provided by an embodiment of the present application. The method includes:
  • S501 Receive an instruction to stop decoding the media stream to be processed
  • S505 Use processor resources to perform the second type of operation on the media stream to be processed.
  • the encoding and decoding resource operation When it is necessary to close the encoding or decoding resource operation, first determine whether the current channel has occupied encoding and decoding resources. If it is occupied, the occupied encoding and decoding resources will be released. If the encoding and decoding resources are not occupied, the channel will be closed directly.
  • the method when the number of currently idle codec resources is less than the number to be allocated, after generating prompt information indicating insufficient codec resources, the method includes:
  • a prompt message indicating insufficient encoding and decoding resources is displayed in the preview window corresponding to the media stream to be processed.
  • NVR connects to digital cameras through the network, receives video and audio data from digital cameras, and analyzes, stores, forwards, previews, and plays back the video and audio data.
  • the NVR preview screen is related to the number of split screens configured by the NVR. If the number of split screens configured is 4, the preview screen window is 4 and distributed in 2*2; in addition, it is related to the number of split screens configured by the NVR.
  • the preview channel is also related. If channel 3 is configured in preview window 1, what preview window 1 sees is the media stream of channel 3.
  • window 1 corresponds to the media stream of playback channel 1
  • window 2 corresponds to the media stream of playback channel 2
  • window 3 corresponds to the media stream of playback channel 3
  • window 4 corresponds to the media stream of playback channel 4.
  • the prompt information indicating insufficient encoding and decoding resources will be displayed in the preview window corresponding to channel 3.
  • the prompt information can be any information that can represent insufficient encoding and decoding resources.
  • the prompt information directly indicates insufficient decoding performance; further, it can also Includes information reminding you to modify parameters, as shown in Figure 5b.
  • a window indicating insufficient system resources can also pop up directly on the NVR interface, as shown in Figure 5c.
  • the specific form of the prompt information for insufficient coding and decoding resources and how to display the prompt information for insufficient coding and decoding resources can be set according to actual needs and are not limited here.
  • Figure 6 is a schematic structural diagram of the codec resource allocation device provided by the embodiment of the present application.
  • the device may include :
  • the acquisition module 610 is used to acquire the first type of operation for the media stream to be processed
  • the first determination module 620 is used to determine the target protocol, target resolution and target frame rate corresponding to the above-mentioned first type of operation, Wherein, the target protocol is a target encoding protocol or a target decoding protocol;
  • the second determination module 630 is configured to determine the number of codec resources that need to be consumed by the above-mentioned first type of operation based on the above-mentioned target protocol, the above-mentioned target resolution, and the above-mentioned target frame rate, and obtain the number to be allocated;
  • Allocation module 640 configured to allocate the number of codecs to be allocated from the currently idle codec resources to the media stream to be processed when the number of currently idle codec resources is not less than the number to be allocated. resources; and/or, the generation module 650 is configured to generate prompt information indicating insufficient codec resources when the number of currently idle codec resources is less than the above-mentioned number to be allocated.
  • the above device further includes:
  • a first processing module configured to perform the first type of operation not based on the codec resources when the number of currently idle codec resources is less than the number to be allocated; and use processor resources to process the media stream to be processed.
  • a second type of operation is performed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the above device further includes:
  • a second processing module configured to not perform the first type of operation based on coding and decoding resources when the first type of operation does not require consuming codec resources or the electronic device does not support processing of the first type of operation; Utilize processor resources to perform a second type of operation on the media stream to be processed, wherein the second type of operation and the first type of operation are different operations, and the processor resource and the codec resource are different data processing resources.
  • the above device further includes:
  • the quantization module is used to quantify the processing capabilities of all encoding and decoding resources during the initialization process to obtain the total number of all encoding and decoding resources.
  • the above quantization module is specifically used to:
  • the model of the codec resource hardware determine the number of channels of reference media streams that are allowed to be processed simultaneously by all codec resources using the preset baseline encoding protocol or the preset baseline decoding protocol, and use the obtained number of channels as all The total number of codec resources, wherein the resolution of the reference media stream is a preset reference resolution, and the frame rate of the reference media stream is a preset reference frame rate.
  • the above-mentioned second determination module includes:
  • the first determination sub-module is used to determine the weight of the target protocol relative to the preset reference encoding protocol or the preset reference decoding protocol according to the predetermined first correspondence relationship, and obtain the first weight, wherein the first weight A corresponding relationship includes weights of various types of encoding protocols or decoding protocols relative to a preset base encoding protocol or a preset base decoding protocol that determines all encoding and decoding resources.
  • the second determination sub-module is used to determine the weight of the target resolution and the target frame rate relative to the reference media stream, and use the determined weight as the second weight, wherein the resolution of the reference media stream is the preset reference resolution, the frame rate of the reference media stream is the preset reference frame rate, and the reference media stream is the media stream used when determining the total number of all codec resources;
  • the calculation submodule is used to calculate the number of encoding and decoding resources that the first type of operation needs to consume according to the first weight and the second weight, and obtain the amount to be allocated; wherein, the first type of operation
  • the number of encoding and decoding resources that need to be consumed to be allocated is the product of the first weight and the second weight.
  • the above-mentioned second determination sub-module is specifically used to:
  • the embodiment of the present application also provides an electronic device, as shown in Figure 7, including a processor 701, a communication interface 702, a memory 703, and a communication bus 704.
  • the processor 701, the communication interface 702, and the memory 703 communicate through the communication bus 704. complete mutual communication,
  • Memory 703 used to store computer programs
  • the processor 701 is used to execute the program stored on the memory 703 to implement the following steps:
  • the target resolution and the target frame rate determine the number of codec resources that the first type of operation needs to consume, and obtain the number to be allocated;
  • processor 701 when used to execute the program stored on the memory 703, it can also implement any of the above encoding and decoding resource allocation methods.
  • the communication bus mentioned in the above-mentioned electronic equipment can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc.
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the communication bus can be divided into address bus, data bus, control bus, etc. For ease of presentation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
  • the communication interface is used for communication between the above-mentioned electronic devices and other devices.
  • the memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk memory.
  • RAM Random Access Memory
  • NVM Non-Volatile Memory
  • the memory may also be at least one storage device located far away from the aforementioned processor.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), special integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • CPU central processing unit
  • NP Network Processor
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a computer-readable storage medium is also provided.
  • the computer-readable storage medium A computer program is stored in the mass, and when the computer program is executed by the processor, the steps of any of the above encoding and decoding resource allocation methods are implemented.
  • a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the encoding and decoding resource allocation methods in the above embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本申请实施例提供编解码资源分配方法、装置及电子设备,先获取针对待处理媒体流的第一类操作,然后确定第一类操作对应的目标协议、目标分辨率及目标帧率,根据目标协议、目标分辨率及目标帧率,确定第一类操作需要消耗的编解码资源的数量,得到待分配数量,在当前空闲的编解码资源的数量不小于待分配数量的情况下,从当前空闲的编解码资源中为待处理媒体流分配待分配数量的编解码资源,在当前空闲的编解码资源的数量小于待分配数量的情况下,生成表示编解码资源不足的提示信息。通过结合目标协议、分辨率、帧率来确定对应的编解码资源,可以减少资源计算误差,实现对编解码资源的合理控制分配。

Description

编解码资源分配方法、装置及电子设备 技术领域
本申请涉及图像处理技术领域,特别是涉及一种编解码资源分配方法、装置及电子设备。
背景技术
在图像的编码、解码和传输过程中,某些录像机,例如NVR(Network Video Recorder,网络视频录像机),通过使用同一个VCP(Video Codec Processor,视频编解码处理器,本文称为硬件单元)来实现编码功能和解码功能,在硬件单元已经达到瓶颈的情况下,若仍然需要使用硬件单元实现预览等操作时,会影响正在进行操作的编解码性能及处理效果,例如可能会带来预览卡顿,数据异常,数据丢失等后果。
发明内容
本申请实施例的目的在于提供一种编解码资源分配方法、装置及电子设备,用以对编解码资源进行合理的控制分配。具体技术方案如下:
本申请实施例提供了一种编解码资源分配方法,所述方法包括:
获取针对待处理媒体流的第一类操作;
确定所述第一类操作对应的目标协议、目标分辨率和目标帧率,其中,所述目标协议为目标编码协议或目标解码协议;
根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,将得到的数量作为待分配数量;
在当前空闲的编解码资源的数量不小于所述待分配数量的情况下,从当前空闲的编解码资源中为所述待处理媒体流分配所述待分配数量的编解码资源;和/或,
在当前空闲的编解码资源的数量小于所述待分配数量的情况下,生成表示编解码资源不足的提示信息。
在一种可能的实施方式中,所述方法还包括:
在当前空闲的编解码资源的数量小于所述待分配数量的情况下,不基于编解码资源执行所述第一类操作;
利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
在一种可能的实施方式中,所述方法还包括:
在所述第一类操作不需要消耗编解码资源,或电子设备不支持处理所述第一类操作的情况下,不基于编解码资源执行所述第一类操作;
利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
在一种可能的实施方式中,所述方法还包括:
在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量。
在一种可能的实施方式中,所述对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量,包括:
根据编解码资源硬件的型号,确定全部的编解码资源在采用预设基准编码协议或预设基准解码协议的情况下,允许同时处理的基准媒体流的路数,将得到的路数作为全部的编解码资源的总数量,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率。
在一种可能的实施方式中,所述根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,得到待分配数量,包括:
按照预先确定的第一对应关系,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,其中,所述第一对应关系包括各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,所述预设基准编码协议或预设基准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;
确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,将确定的权值作为第二权值,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率,所述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
在一种可能的实施方式中,所述根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,得到待分配数量,包括:
按照预先确定的第一权重表,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值;其中,所述第一权重表中记录各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值;
判断预先确定的第二权重表中是否存在所述目标分辨率及所述目标帧率相对于基准媒体流的第二权值;其中,所述第二权重表中记录各分辨率及帧率相对于基准媒体流的权值;若存在,则基于所述第二权重表确定所述目标分辨率及所述目标帧率相对于基准媒体流的第二权值;和/或,若不存在,则将所述目标分辨率与所述目标帧率的乘积除以基准媒体流的分辨率与基准媒体流的帧率的乘积,得到第二权值;
根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
在一种可能的实施方式中,所述确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,得到第二权值,包括:
计算所述目标分辨率与所述目标帧率的乘积,得到第一乘积;
计算所述预设基准分辨率与所述预设基准帧率的乘积,得到第二乘积;
计算所述第一乘积与所述第二乘积的比值,得到第二权值。
在一种可能的实施方式中,所述方法还包括:基于可分级视频编码SVC分级后视频帧个数和SVC分级前视频帧个数确定目标协议对应的第一权值。
本申请实施例还提供了一种编解码资源分配装置,所述装置包括:
获取模块,用于获取针对待处理媒体流的第一类操作;
第一确定模块,用于确定所述第一类操作对应的目标协议、目标分辨率和目标帧率,其中,所述目标协议为目标编码协议或目标解码协议;
第二确定模块,用于根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,将得到的数量作为待分配数量;
分配模块,用于在当前空闲的编解码资源的数量不小于所述待分配数量的情况下,从当前空闲的编解码资源中为所述待处理媒体流分配所述待分配数量的编解码资源;和/或,生成模块,用于在当前空闲的编解码资源的数量小于所述待分配数量的情况下,生成表示编解码资源不足的提示信息。
在一种可能的实施方式中,所述装置还包括:
第一处理模块,用于在当前空闲的编解码资源的数量小于所述待分配数量的情况下,不基于编解码资源执行所述第一类操作;利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
在一种可能的实施方式中,所述装置还包括:
第二处理模块,用于在所述第一类操作不需要消耗编解码资源,或电子设备不支持处理所述第一类操作的情况下,不基于编解码资源执行所述第一类操作;利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
在一种可能的实施方式中,所述装置还包括:
量化模块,用于在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量。
在一种可能的实施方式中,所述量化模块具体用于:
根据编解码资源硬件的型号,确定全部的编解码资源在采用预设基准编码协议或预设基准解码协议的情况下,允许同时处理的基准媒体流的路数,将得到的路数作为全部的编解码资源的总数量,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率。
在一种可能的实施方式中,所述第二确定模块,包括:
第一确定子模块,用于按照预先确定的第一对应关系,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,其中,所述第一对应关系包括各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,所述预设基准编码协议或预设基 准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;
第二确定子模块,用于确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,将确定的权值作为第二权值,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率,所述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
计算子模块,用于根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
在一种可能的实施方式中,所述第二确定子模块具体用于:
计算所述目标分辨率与所述目标帧率的乘积,得到第一乘积;
计算所述预设基准分辨率与所述预设基准帧率的乘积,得到第二乘积;
计算所述第一乘积与所述第二乘积的比值,得到第二权值。
本申请实施例还提供了一种电子设备,包括:处理器、通信接口、存储器和通信总线,其中,所述处理器,通信接口,存储器通过通信总线完成相互间的通信;
存储器,用于存放计算机程序;
处理器,用于执行存储器上所存放的程序时,实现上述任一所述的编解码资源分配方法。
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述任一所述的编解码资源分配方法。
本申请实施例还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述任一所述的编解码资源分配方法。
本申请实施例有益效果:
本申请实施例提供的编解码资源分配方法、装置及电子设备,通过先获取针对待处理媒体流的第一类操作,然后确定第一类操作对应的目标协议、目标分辨率及目标帧率,根据目标协议、目标分辨率及目标帧率,确定第一类操作需要消耗的编解码资源的数量,得到待分配数量,在当前空闲的编解码资源的数量不小于待分配数量的情况下,从当前空闲的编解码资源中为待处理媒体流分配待分配数量的编解码资源,在当前空闲的编解码资源的数量小于待分配数量的情况下,生成表示编解码资源不足的提示信息,通过结合目标协议、分辨率、帧率来确定对待处理码流执行需要编解码资源的操作所需的编解码资源,可以减少资源计算误差,实现对编解码资源的合理控制分配。
而且,在当前空闲的编解码资源的数量小于待分配数量的情况下,不执行第一类操作,同时接收待处理媒体流,并利用处理器资源对待处理媒体流执行不需要编解码资源的操作,因此,即便需要编解码资源的操作因为当前编解码资源不足而无法进行,其它不需要编解码资源的操作也可以正常进行,从而保证了编解码相关操作流程更流畅进行。
当然,实施本申请的任一产品或方法并不一定需要同时达到以上所述的所有优点。
附图说明
图1为本申请实施例提供的编解码资源分配方法的第一种流程示意图;
图2为本申请实施例提供的编解码资源分配方法的第二种流程示意图;
图3为本申请实施例提供的编解码资源分配方法的第三种流程示意图;
图4为本申请实施例提供的编解码资源分配方法的第四种流程示意图;
图5a为本申请实施例提供的编解码资源分配方法的第五种流程示意图;
图5b为本申请实施例提供的编解码资源分配方法中展示编解码资源不足的提示信息的第一种示意图;
图5c为本申请实施例提供的编解码资源分配方法中展示编解码资源不足的提示信息的第二种示意图;
图6为本申请实施例的编解码资源分配装置的一种结构示意图;
图7为本申请实施例提供的电子设备的一种结构示意图。
具体实施方式
为了实现对编解码资源进行合理的控制分配,本申请实施例提供了一种编解码资源分配方法、装置、电子设备、存储介质及包含指令的计算机程序产品。
下面,首先对本申请实施例提供的编解码资源分配方法进行介绍。该方法应用于电子设备,具体的,该电子设备可以为任一种可以提供媒体流编解码资源分配服务的电子设备,例如,手机,平板,个人计算机、服务器等。本申请实施例所提供的编解码资源分配方法可以被设置于电子设备中的软件、硬件电路和逻辑电路中的至少一种实现。
如图1所示,图1为本申请实施例提供的编解码资源分配方法的第一种流程示意图,该方法包括:
S110,获取针对待处理媒体流的第一类操作;
S120,确定上述第一类操作对应的目标协议、目标分辨率及目标帧率,其中,该目标协议为目标编码协议或目标解码协议;其中,针对编码过程来说,目标协议(即目标编码协议)是第一类操作符合的编码标准,即第一类操作后的数据符合的编码标准,目标分辨率是第一类操作后的数据符合的分辨率,目标帧率是第一类操作后的数据符合的帧率。针对解码过程来说,目标协议(即目标解码协议)是第一类操作符合的解码标准,即第一类操作前的数据符合的解码标准,目标分辨率是第一类操作前的数据符合的分辨率,目标帧率是第一类操作前的数据符合的帧率。
S130,根据上述目标协议、上述目标分辨率及上述目标帧率,确定上述第一类操作需要消耗的编解码资源的数量,将得到的数量作为待分配数量;其中,第一类操作需要消耗的编解码资源的数量是指:执行第一类操作时需要使用的编解码资源的数量,即使用多少编解码资源能够完成第一类操作。
S140,在当前空闲的编解码资源的数量不小于上述待分配数量的情况下,从当前空闲的编解码资源中为上述待处理媒体流分配上述待分配数量的编解码资源;
S150,在当前空闲的编解码资源的数量小于上述待分配数量的情况下,生成表示编解码资源不足的提示信息。其中,当前空闲的编解码资源的数量是指:电子设备当前剩余的编解码资源的数量, 即未被占用的编解码资源的数量。
媒体流可以为视频,也可以为音频,媒体流的部分相关操作可以称为第二类操作,如:解析,存储,转发等,第二类操作只需要进行码流解析、存储及转发,并不需要进行预览、回放等,因此,第二类操作可以通过处理器资源完成,也可以通过编解码资源完成,本实施例中,将第二类操作定义为通过处理器资源完成的操作,而不需要编解码资源。此外,媒体流的部分相关操作可以称为第一类操作,如预览、回放等,第一类操作是需要编解码资源完成的操作。所以,编解码资源相关操作开启时,先判断待处理媒体流的操作是第一类操作还是第二类操作,如果是需要消耗编解码资源的第一类操作,即需要消耗编解码资源时,需要根据目标协议、目标分辨率及目标帧率计算其需要消耗的编解码资源的数量,然后判断系统是否有足够的编解码资源可以使用,如果足够,则为其分配编解码资源,进一步的,在为其分配编解码资源后,需要更新当前空闲的编解码资源,如果编解码资源不足,则生成表示编解码资源不足的提示信息。
需要说明的是,编解码资源的数量,指的是对编解码能力进行量化所得到的一种参数,用于衡量编解码能力的大小。将编解码能力量化为可进行计算的单位,有助于判断资源和需求之间的匹配度。另外,还需要说明的是,本文中的“编解码”是对“编码或者解码”的一种代称,该词语在解码场景中,取“解码”的意思;在编码场景中,取“编码”的意思。例如,一种编解码资源分配方法,可理解为:一种编码资源分配方法,或者,一种解码资源分配方法。对应地,本申请中所给出的实施例以及期望保护的方案,均可以对应地理解为是一种与编码相关的方案,或者是一种与解码相关的方案,在此不再一一赘述每个完整的方案。
通过结合目标协议、分辨率、帧率来确定对待处理码流执行需要编解码资源的操作所需的编解码资源,可以减少资源计算误差,实现对编解码资源的合理控制分配。
在一种可能的实施方式中,上述方法还包括:
在当前空闲的编解码资源的数量小于上述待分配数量的情况下,不执行上述第一类操作(即不基于编解码资源执行上述第一类操作);接收上述待处理媒体流,并利用处理器资源对上述待处理媒体流执行第二类操作,其中,第二类操作与第一类操作为不同的操作,处理器资源与编解码资源为不同的数据处理资源。
在当前空闲的编解码资源的数量小于待分配数量的情况下,说明当前已没有足够的编解码资源可以使用,而对媒体流的解析、存储、转发等操作来说,虽然需要编解码资源来完成,但是,也可以通过处理器资源来完成,因此,既然已经没有足够的编解码资源可以使用,所以此时不执行编码或解码的操作,而是接收待处理媒体流,利用处理器资源来对待处理媒体流执行操作,例如,解析、存储、转发,如此在编解码资源不足时,即便不进行编解码操作,仍能合理使用处理器资源保持码流的解析、存储、转发。
在一种可能的实施方式中,上述方法还包括:
在上述第一类操作不需要消耗编解码资源,或电子设备不支持处理上述第一类操作的情况下,不执行上述第一类操作(即不基于编解码资源执行上述第一类操作);接收上述待处理媒体流,并利用处理器资源对上述待处理媒体流执行第二类操作,其中,第二类操作与第一类操作为不同的操作,处理器资源与编解码资源为不同的数据处理资源。
在第一类操作不需要消耗编解码资源或者电子设备不支持处理第一类操作的情况下,则不执行 第一类操作,而是在接收待处理媒体流后,利用处理器资源对待处理媒体流执行第二类操作,例如,解析、存储、转发等。
或者当电子设备无法支持处理第一类操作时,例如,电子设备仅支持处理H.264、H.265协议的编解码操作,当第一类操作为除H.264、H.265协议外的其它类型协议的编解码操作时,则电子设备不支持处理该第一类操作,电子设备接收待处理媒体流后,利用处理器资源对待处理媒体流执行操作。如此第一类操作不需要消耗编解码资源,或者电子设备不支持处理第一类操作的情况下,即便不进行编解码操作,仍能合理使用处理器资源保持码流的解析、存储、转发。
在一种可能的实施方式中,上述方法还包括:
在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量。
在初始化启动后,需要对全部的编解码资源的处理能力进行量化,以得到全部的编解码资源的总数量。在对全部的编解码资源的处理能力进行量化时,可以先设定一个基准媒体流,基于基准媒体流来对全部的编解码资源的处理能力进行量化,为了方案清楚以及布局清晰,下文结合另一实施例进行详细说明。
在一种可能的实施方式中,上述在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量,包括:
在初始化过程中,根据编解码资源硬件的型号,确定全部的编解码资源在采用预设基准编码协议或预设基准解码协议的情况下,允许同时处理的基准媒体流的路数,得到全部的编解码资源的总数量,其中,上述基准媒体流的分辨率为预设基准分辨率,上述基准媒体流的帧率为预设基准帧率。
在初始化过程中,先设定一个基准媒体流,例如,采用H.265 1080P@30FPS解码媒体流为基准媒体流,即,设定对1路H.265 1080P@30FPS进行解码所占用资源为KP(K Proportionality,比例系数),则基于该基准媒体流,确定编解码资源允许同时处理的基准媒体流的路数,以得到全部的编解码资源的总数量,例如,得到的总编解码能力为x×KP。例如,一台设备VCP总解码能力为16路H.265 1080P@30FPS视频,则总编解码能力为16×KP,即能同时解码16路1080P@30FPS的媒体流。基准媒体流的设置可以基于实际情况进行设置,在此不作限定。
基于图1的实施例,参见图2,图2为本申请实施例提供的编解码资源分配方法的第二种流程示意图,上述步骤S130可以通过以下步骤实现:
S131,基于目标协议、预设基准编码协议或预设基准解码协议,确定目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,上述预设基准编码协议或预设基准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;
S132,确定上述目标分辨率及上述目标帧率相对于基准媒体流的权值,得到第二权值,其中,上述基准媒体流的分辨率为预设基准分辨率,上述基准媒体流的帧率为预设基准帧率,上述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
S133,根据上述第一权值及上述第二权值,计算上述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,第一类操作需要消耗的编解码资源的待分配数量可以为第一权值与第二权值的乘积。
获取了待处理媒体流后,若对该待处理媒体流进行第一类操作,则第一类操作需要消耗的 编解码资源的数量与目标协议、分辨率及帧率有关。
在设定了预设基准编码协议或预设基准解码协议之后,可以确定目标协议相对于预设基准编码协议或预设基准解码协议的权值,例如,采用H.265 1080P@30FPS解码媒体流为基准媒体流,即,设定H.265协议为基准解码协议,则相对于H.265协议而言,H.265解码场景中的目标解码协议的权值为1,因为编码性能消耗会比解码高,则H.265编码可以根据实测性能消耗设定不同权值。
针对H.264编解码,因为H.264的性能消耗会比H.265高,而且编码性能消耗会比解码高,H.264编码或解码对应的权值可以通过性能测试或理论计算得出。
针对特性码流处理,例如SVC(Scalable Video Coding,可分级视频编码)码流,因为SVC码流主要由时域分级和空域分级,主要作用是压缩媒体流,本申请中的SVC码流泛指时域分级,即媒体流中部分帧可以不做解码,减少解码性能消耗,即针对主要在于编码解码的视频帧减少,不会改变原始数据流,基于SVC分级后视频帧个数确定其目标协议对应的第一权值,例如,如果SVC分级后视频帧个数为原来的1/2(即参与编解码的视频帧数量为原有视频帧数量的1/2),则第一权值为0.5;如果视频帧个数为原来1/4,则第一权值为0.25。
基于基准媒体流的分辨率、基准媒体流的帧率、目标分辨率及目标帧率确定待处理媒体流对应的第二权值,待处理媒体流对应的第二权值的计算方式可以为:将待处理媒体流分辨率与帧率的乘积除以基准媒体流的分辨率与基准媒体流的帧率的乘积。
在一种可能的实施方式中,上述步骤S132可以通过以下步骤实现:
计算上述目标分辨率与上述目标帧率的乘积,得到第一乘积;
计算上述预设基准分辨率与上述预设基准帧率的乘积,得到第二乘积;
计算上述第一乘积与上述第二乘积的比值,得到第二权值。
同样以采用H.265 1080P@30FPS解码媒体流为基准媒体流,设定对1路H.2651080P@30FPS进行解码所占用资源为KP,则针对H.265解码场景而言,针对像素为CIF 10w,分辨率为352×288,帧率为30的待处理媒体流,其权值为352×288×30/(1920×1080×30)≈0.05。
根据第一权值及第二权值计算第一类操作需要消耗的编解码资源的数量,得到待分配数量,具体的,第一类操作需要消耗的编解码资源的数量(即待分配数量)为第一权值与第二权值的乘积。
例如,以H.265 1080P@30FPS解码媒体流为基准媒体流,设定对1路H.265 1080P@30FPS进行解码所占用资源为KP,针对H.265解码典型场景:
其中,解码权值表(即第二权重表)如表1所示:
表1

针对H.265其它解码场景:
H.265非典型分辨率帧率视频,以1080P为基准,将待处理媒体流分辨率与帧率的乘积除以基准媒体流的分辨率与基准媒体流的帧率的乘积线性计算后取整,例如1000×1000@25FPS的视频,该待处理媒体流对应的第二权值=1000×1000×25/(1920×1080×30)≈0.4,则1000×1000@25FPS的视频进行解码所占用资源为0.4KP。
针对H.264编码、解码:
H.264编码或解码如果符合表1中分辨率、帧率信息,可以直接根据表1中第二权值乘以H.264编码或解码对应的第一权值;如果不符合表1中分辨率、帧率信息,则将待处理媒体流分辨率与帧率的乘积除以基准媒体流的分辨率与基准媒体流的帧率的乘积得到第二权值,然后再将第二权值乘以相应H.264编码或解码对应的第一权值。
例如,H.264/JPG对应的第二权值为k1,m为H.264编码协议对应的第一权值,则H.264/JPG解码所占用资源KP2=(m×K1)KP。H.264/JPG编码所占用资源KP3=n×KP2,其中n为编码相对于解码的比例系数。
本申请针对硬件单元特性,将编码和解码资源统一管理,合理规划编解码资源,结合各种目标协议,分辨率,操作场景等设计权重值,可以减少资源计算误差,从而实现对编解码资源的合理控制分配。
基于图1的实施例,在一种可能的实施方式中,上述步骤S130可以通过以下步骤实现:
按照预先确定的第一对应关系,确定上述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,其中,上述第一对应关系包括各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,上述预设基准编码协议或预设基准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;比如说,由于有些编码协议或解码协议不需要对所有视频帧进行编码或解码操作,而是对部分视频帧进行编码或解码操作,因此,针对某个类型的编码协议或解码协议,基于该类型的编码协议或解码协议对应的视频帧个数(即单位时间内参与编解码的视频帧的数量,即所有视频帧中的全部视频帧或者部分视频帧的数量)与预设基准编码协议或预设基准解码协议对应的视频帧个数(即单位时间内参与编解码的视频帧的数量,即所有视频帧中的全部视频帧或者部分视频帧的数量)之间的比例关系确定第一权值,或者,基于该类型的编码协议或解码协议的参与编码或解码视频帧个数(或未参与编码或解码视频帧个数)与全部视频帧个数的比例、预设基准编码协议或预设基准解码协议的参与编码或解码视频帧个数(或未参与编码或解码视频帧个数)与全部视频帧个数的比例,通过这两个比例之间的关系确定第一权值。比如说,协议类型A的参与编码或解码视频帧个数与全部视频帧个数的比例为100%,预设基准编码协议或预设基准解码协议的参与编码或解码视频帧个数与全部视频帧个数的比例为50%,则第一 权值为2。又例如,协议类型A的参与编码或解码视频帧个数与全部视频帧个数的比例为25%,预设基准编码协议或预设基准解码协议的参与编码或解码视频帧个数与全部视频帧个数的比例为50%,则第一权值为0.5。其中,第一权值的目的是为了确定清楚实际需要参与编解码的帧所需要占用的编解码资源,比如说,参见表2所示,为第一对应关系的示例。
表2
确定上述目标分辨率及上述目标帧率相对于基准媒体流的权值,得到第二权值,其中,上述基准媒体流的分辨率为预设基准分辨率,上述基准媒体流的帧率为预设基准帧率,上述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
根据上述第一权值及上述第二权值,计算上述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,第一类操作需要消耗的编解码资源的待分配数量为第一权值与第二权值的乘积。
可以预先存储各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值的第一对应关系,这样,可以直接按照预先确定的第一对应关系来确定目标协议相对于预设基准编码协议或预设基准解码协议的权值得到第一权值,从而可以减少计算量。
具体的,可以将第一对应关系作为第一权重表(即第一权重表与第一对应关系可以相同,参见表2所示)进行存储,如此可以基于第一权重表来直接确定目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值。具体的,第一权重表中记录各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,在获取了目标协议后,基于目标协议类型与第一权重表中对应的编码协议或解码协议类型进行匹配,从而确定出目标协议对应的第一权值。
当然,也可以按照预先确定的第二对应关系确定目标分辨率及目标帧率相对于基准媒体流的权值,得到第二权值,具体的,可以将第二对应关系作为第二权重表进行存储,如此可以基于第二权重表来直接确定目标分辨率及目标帧率相对于基准媒体流的第二权值。具体的,第二权重表中记录各分辨率及帧率相对于基准媒体流的权值,在获取了目标分辨率及目标帧率后,基于目标分辨率及目标帧率与第二权重表中对应的分辨率及帧率进行匹配,从而确定出目标分辨率及目标帧率相对于基准媒体流的第二权值。
基于图1的实施例,参见图3,图3为本申请实施例提供的编解码资源分配方法的第三种流程示意图,上述步骤S130可以通过以下步骤实现:
S1310,按照预先确定的第一权重表,确定上述目标协议相对于预设基准编码协议或预设基准解码协议的权值得到第一权值;
S1320,判断预先确定的第二权重表中是否存在目标分辨率及目标帧率相对于基准媒体流的第二权值;
S1330,若存在,则基于第二权重表确定目标分辨率及目标帧率相对于基准媒体流的第二权值;
S1340,若不存在,则将目标媒体流分辨率与目标帧率的乘积除以基准媒体流的分辨率与基准媒体流的帧率的乘积,得到第二权值。
其中,第一权重表与第二权重表可以为不同的表,也可以为同一个表。在此不作限定。
如果第二权重表中存在目标分辨率及目标帧率相对于基准媒体流的第二权值,则可以直接从第二权值表中获取第二权值,如果待处理媒体流为非常规的媒体流,则可以通过线性计算的方式来获取第二权值,以此使得典型分辨率、码流的待处理媒体流可以从表格中直接获取对应的权重,非典型分辨率、码流的待处理媒体流通过线性换算等计算来确定,以此可以减少资源计算误差,从而制定合理策略进行资源管理。
在一种可能的实施方式中,根据目标协议、目标分辨率及目标帧率,确定第一类操作需要消耗的编解码资源的数量,得到待分配数量,包括:
判断预先确定的编解码资源表中是否存在第一类操作需要消耗的编解码资源的数量;
若存在,则基于预先确定的编解码资源表确定第一类操作需要消耗的编解码资源的数量;
若不存在,则按照上述任一实施例所述的方法确定第一类操作需要消耗的编解码资源的数量。
如果待处理媒体流为常规的媒体流,则可以通过预先确定的编解码资源表来直接获取第一类操作需要消耗的编解码资源的数量,如果待处理媒体流为非常规的媒体流,则可以通过线性计算的方式来来确定,以此可以减少资源计算误差。从而制定合理策略进行资源管理。
基于上述实施例,本申请实施例提供了编解码资源分配方法,如图4所示,图4为本申请实施例提供的编解码资源分配方法的第四种流程示意图,本方法中以解码操作为例,该方法包括:
S401,获取针对待处理媒体流的解码任务;
S402,判断是否包括预设情况;预设情况包括分辨率不支持、虚拟解码等特殊情况,虚拟解码指的是实际不进行解码操作,不消耗解码资源;若是,则执行步骤S408,若否则执行步骤S403;
S403,确定解码任务需要消耗的编解码资源的数量,得到待分配数量;
S404,判断当前空闲的编解码资源的数量是否不小于待分配数量;若是,则执行步骤S405,若否则执行步骤S408;
S405,为待处理媒体流分配待分配数量的编解码资源;
S406,更新当前空闲的编解码资源的数量;
S407,解码;
S408,不需要编解码资源的操作;
上述方法中,即便需要编解码资源的操作因为当前系统编解码资源不足而无法进行时,其它不需要解码资源的操作也可以正常进行,从而保证了编解码相关操作流程更流程进行。
在一种可能的实施方式中,当接收到停止对待处理媒体流执行预设操作的指令时,上述预 设操作为需要编解码资源的操作,上述方法包括:
判断是否已为上述待处理媒体流分配编解码资源;
在未分配编解码资源的情况下,利用处理器资源对上述待处理媒体流执行第二类操作,其中,所述第二类操作为不需要编解码资源的操作;
在已分配编解码资源的情况下,释放已分配的编解码资源,并更新当前空闲的编解码资源。
具体如图5所示,图5为本申请实施例提供的编解码资源分配方法的第五种流程示意图,该方法包括:
S501,接收到停止对待处理媒体流执行解码操作的指令;
S502,判断是否占有编解码资源;若是,则执行步骤S503,若否,则执行步骤S505;
S503,释放占有的编解码资源;
S504,更新当前空闲的编解码资源;
S505,利用处理器资源对待处理媒体流执行第二类操作。
当需要关闭编码或解码资源操作时,先判断当前通道是否有占用编解码资源,如果占用的话,则将占用的编解码资源释放,如果未占用编解码资源,则直接关闭通道。
在一种可能的实施中,在当前空闲的编解码资源的数量小于待分配数量的情况下,生成表示编解码资源不足的提示信息之后,该方法包括:
在待处理媒体流对应的预览窗口处展示编解码资源不足的提示信息。
NVR通过网络与数字摄像机进行连接,接收来自数字摄像机的视音频数据,对视音频数据进行解析、存储、转发及预览、回放等。其中,在预览时,NVR预览画面与NVR配置的分屏数有关,若分屏数配置的是4,则预览画面窗口为4,且呈2*2分布;除此之外,与NVR配置的预览通道也有关,假如预览画面窗口1中配置的是通道3,则预览画面窗口1看到的是通道3的媒体流。
例如,目前有4个预览窗口,其中窗口1对应播放通道1的媒体流,窗口2对应播放通道2的媒体流,窗口3对应播放通道3的媒体流,窗口4对应播放通道4的媒体流,在对通道3对应的媒体流的编解码时,如果在当前空闲的编解码资源的数量小于待分配数量,即表示目前编解码资源无法满足对通道3对应的媒体流对应的媒体流进行编解码的要求,则在通道3对应的预览窗口展示编解码资源不足的提示信息,该提示信息可以为任意可以表征编解码资源不足的信息,例如:提示信息直接为解码性能不足;进一步的,还可以包括提醒修改参数的信息,具体如图5b所示。
当然,当一个通道也无法开启时,也可以直接在NVR界面弹出系统资源不足的窗口,具体如图5c所示。编解码资源不足的提示信息的具体形式以及如何展示编解码资源不足的提示信息可以根据实际需求进行设定,在此不作限定。
基于上述方法实施例,本申请实施例提供了一种编解码资源分配装置,如图6所示,图6为本申请实施例提供的编解码资源分配装置的一种结构示意图,该装置可以包括:
获取模块610,用于获取针对待处理媒体流的第一类操作;
第一确定模块620,用于确定上述第一类操作对应的目标协议、目标分辨率及目标帧率, 其中,所述目标协议为目标编码协议或目标解码协议;
第二确定模块630,用于根据上述目标协议、上述目标分辨率及上述目标帧率,确定上述第一类操作需要消耗的编解码资源的数量,得到待分配数量;
分配模块640,用于在当前空闲的编解码资源的数量不小于所述待分配数量的情况下,从当前空闲的编解码资源中为所述待处理媒体流分配所述待分配数量的编解码资源;和/或,生成模块650,用于在当前空闲的编解码资源的数量小于上述待分配数量的情况下,生成表示编解码资源不足的提示信息。
在一种可能的实施方式中,上述装置还包括:
第一处理模块,用于在当前空闲的编解码资源的数量小于所述待分配数量的情况下,不基于编解码资源执行所述第一类操作;利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
在一种可能的实施方式中,上述装置还包括:
第二处理模块,用于在所述第一类操作不需要消耗编解码资源,或电子设备不支持处理所述第一类操作的情况下,不基于编解码资源执行所述第一类操作;利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
在一种可能的实施方式中,上述装置还包括:
量化模块,用于在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量。
在一种可能的实施方式中,上述量化模块具体用于:
根据编解码资源硬件的型号,确定全部的编解码资源在采用预设基准编码协议或预设基准解码协议的情况下,允许同时处理的基准媒体流的路数,将得到的路数作为全部的编解码资源的总数量,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率。
在一种可能的实施方式中,上述第二确定模块,包括:
第一确定子模块,用于按照预先确定的第一对应关系,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,其中,所述第一对应关系包括各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,所述预设基准编码协议或预设基准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;
第二确定子模块,用于确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,将确定的权值作为第二权值,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率,所述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
计算子模块,用于根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
在一种可能的实施方式中,上述第二确定子模块具体用于:
计算上述目标分辨率与上述目标帧率的乘积,得到第一乘积;
计算上述预设基准分辨率与上述预设基准帧率的乘积,得到第二乘积;
计算上述第一乘积与上述第二乘积的比值,得到第二权值。
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。
本申请实施例还提供了一种电子设备,如图7所示,包括处理器701、通信接口702、存储器703和通信总线704,其中,处理器701,通信接口702,存储器703通过通信总线704完成相互间的通信,
存储器703,用于存放计算机程序;
处理器701,用于执行存储器703上所存放的程序时,实现如下步骤:
获取针对待处理媒体流的第一类操作;
确定所述第一类操作对应的目标协议、目标分辨率及目标帧率;
根据所述目标协议、所述目标分辨率及所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;
在当前空闲的编解码资源的数量不小于所述待分配数量的情况下,从当前空闲的编解码资源中为所述待处理媒体流分配所述待分配数量的编解码资源;
在当前空闲的编解码资源的数量小于所述待分配数量的情况下,生成表示编解码资源不足的提示信息。
可选的,处理器701,用于执行存储器703上所存放的程序时,还可以实现上述任一编解码资源分配方法。
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
通信接口用于上述电子设备与其他设备之间的通信。
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。
上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
在本申请提供的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介 质内存储有计算机程序,所述计算机程序被处理器执行时实现上述任一编解码资源分配方法的步骤。
在本申请提供的又一实施例中,还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例中任一编解码资源分配方法。

Claims (17)

  1. 一种编解码资源分配方法,其特征在于,所述方法包括:
    获取针对待处理媒体流的第一类操作;
    确定所述第一类操作对应的目标协议、目标分辨率和目标帧率,其中,所述目标协议为目标编码协议或目标解码协议;
    根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,将得到的数量作为待分配数量;
    在当前空闲的编解码资源的数量不小于所述待分配数量的情况下,从当前空闲的编解码资源中为所述待处理媒体流分配所述待分配数量的编解码资源;和/或,
    在当前空闲的编解码资源的数量小于所述待分配数量的情况下,生成表示编解码资源不足的提示信息。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在当前空闲的编解码资源的数量小于所述待分配数量的情况下,不基于编解码资源执行所述第一类操作;
    利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在所述第一类操作不需要消耗编解码资源,或电子设备不支持处理所述第一类操作的情况下,不基于编解码资源执行所述第一类操作;
    利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量。
  5. 根据权利要求4所述的方法,其特征在于,所述对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量,包括:
    根据编解码资源硬件的型号,确定全部的编解码资源在采用预设基准编码协议或预设基准解码协议的情况下,允许同时处理的基准媒体流的路数,将得到的路数作为全部的编解码资源的总数量,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率。
  6. 根据权利要求1所述的方法,其特征在于,所述根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,得到待分配数量,包括:
    按照预先确定的第一对应关系,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,其中,所述第一对应关系包括各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,所述预设基准编码协议或预设基准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;
    确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,将确定的权值作为第二权值,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率,所述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
    根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
  7. 根据权利要求1所述的方法,其特征在于,所述根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,得到待分配数量,包括:
    按照预先确定的第一权重表,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值;其中,所述第一权重表中记录各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值;
    判断预先确定的第二权重表中是否存在所述目标分辨率及所述目标帧率相对于基准媒体流的第二权值;其中,所述第二权重表中记录各分辨率及帧率相对于基准媒体流的权值;若存在,则基于所述第二权重表确定所述目标分辨率及所述目标帧率相对于基准媒体流的第二权值;和/或,若不存在,则将所述目标分辨率与所述目标帧率的乘积除以基准媒体流的分辨率与基准媒体流的帧率的乘积,得到第二权值;
    根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
  8. 根据权利要求6或7所述的方法,其特征在于,所述确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,得到第二权值,包括:
    计算所述目标分辨率与所述目标帧率的乘积,得到第一乘积;
    计算所述预设基准分辨率与所述预设基准帧率的乘积,得到第二乘积;
    计算所述第一乘积与所述第二乘积的比值,得到第二权值。
  9. 根据权利要求6或7所述的方法,其特征在于,所述方法还包括:基于可分级视频编码SVC分级后视频帧个数和SVC分级前视频帧个数确定目标协议对应的第一权值。
  10. 一种编解码资源分配装置,其特征在于,所述装置包括:
    获取模块,用于获取针对待处理媒体流的第一类操作;
    第一确定模块,用于确定所述第一类操作对应的目标协议、目标分辨率和目标帧率,其中,所述目标协议为目标编码协议或目标解码协议;
    第二确定模块,用于根据所述目标协议、所述目标分辨率和所述目标帧率,确定所述第一类操作需要消耗的编解码资源的数量,将得到的数量作为待分配数量;
    分配模块,用于在当前空闲的编解码资源的数量不小于所述待分配数量的情况下,从当前空闲的编解码资源中为所述待处理媒体流分配所述待分配数量的编解码资源;和/或,生成模块,用于在当前空闲的编解码资源的数量小于所述待分配数量的情况下,生成表示编解码资源不足的提示信息。
  11. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    第一处理模块,用于在当前空闲的编解码资源的数量小于所述待分配数量的情况下,不基于编解码资源执行所述第一类操作;利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
  12. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    第二处理模块,用于在所述第一类操作不需要消耗编解码资源,或电子设备不支持处理所述第一类操作的情况下,不基于编解码资源执行所述第一类操作;利用处理器资源对所述待处理媒体流执行第二类操作,其中,所述第二类操作与所述第一类操作为不同的操作,所述处理器资源与所述编解码资源为不同的数据处理资源。
  13. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    量化模块,用于在初始化过程中,对全部的编解码资源的处理能力进行量化,得到全部的编解码资源的总数量。
  14. 根据权利要求13所述的装置,其特征在于,所述量化模块具体用于:
    根据编解码资源硬件的型号,确定全部的编解码资源在采用预设基准编码协议或预设基准解码协议的情况下,允许同时处理的基准媒体流的路数,将得到的路数作为全部的编解码资源的总数量,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率。
  15. 根据权利要求10所述的装置,其特征在于,所述第二确定模块,包括:
    第一确定子模块,用于按照预先确定的第一对应关系,确定所述目标协议相对于预设基准编码协议或预设基准解码协议的权值,得到第一权值,其中,所述第一对应关系包括各类型的编码协议或解码协议相对于预设基准编码协议或预设基准解码协议的权值,所述预设基准编码协议或预设基准解码协议为确定全部的编解码资源的总数量时所使用的编码协议或解码协议;
    第二确定子模块,用于确定所述目标分辨率及所述目标帧率相对于基准媒体流的权值,将确定的权值作为第二权值,其中,所述基准媒体流的分辨率为预设基准分辨率,所述基准媒体流的帧率为预设基准帧率,所述基准媒体流为确定全部的编解码资源的总数量时所使用的媒体流;
    计算子模块,用于根据所述第一权值及所述第二权值,计算所述第一类操作需要消耗的编解码资源的数量,得到待分配数量;其中,所述第一类操作需要消耗的编解码资源的待分配数量为所述第一权值与所述第二权值的乘积。
  16. 根据权利要求15所述的装置,其特征在于,所述第二确定子模块具体用于:
    计算所述目标分辨率与所述目标帧率的乘积,得到第一乘积;
    计算所述预设基准分辨率与所述预设基准帧率的乘积,得到第二乘积;
    计算所述第一乘积与所述第二乘积的比值,得到第二权值。
  17. 一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;
    存储器,用于存放计算机程序;
    处理器,用于执行存储器上所存放的程序时,实现权利要求1-9任一所述的方法步骤。
PCT/CN2023/102242 2022-06-24 2023-06-25 编解码资源分配方法、装置及电子设备 WO2023246946A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210730289.7A CN115129470A (zh) 2022-06-24 2022-06-24 编解码资源分配方法、装置及电子设备
CN202210730289.7 2022-06-24

Publications (1)

Publication Number Publication Date
WO2023246946A1 true WO2023246946A1 (zh) 2023-12-28

Family

ID=83380708

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/102242 WO2023246946A1 (zh) 2022-06-24 2023-06-25 编解码资源分配方法、装置及电子设备

Country Status (2)

Country Link
CN (1) CN115129470A (zh)
WO (1) WO2023246946A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115129470A (zh) * 2022-06-24 2022-09-30 杭州海康威视数字技术股份有限公司 编解码资源分配方法、装置及电子设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014183566A1 (zh) * 2013-11-20 2014-11-20 中兴通讯股份有限公司 一种图片播放的方法、装置、计算机存储介质及机顶盒
CN107155093A (zh) * 2017-06-21 2017-09-12 普联技术有限公司 一种视频预览方法、装置及设备
CN108289228A (zh) * 2017-01-09 2018-07-17 阿里巴巴集团控股有限公司 一种全景视频转码方法、装置和设备
CN112399252A (zh) * 2019-08-14 2021-02-23 浙江宇视科技有限公司 软硬解码控制方法、装置及电子设备
CN113722058A (zh) * 2021-06-16 2021-11-30 荣耀终端有限公司 一种资源调用方法及电子设备
CN115129470A (zh) * 2022-06-24 2022-09-30 杭州海康威视数字技术股份有限公司 编解码资源分配方法、装置及电子设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014183566A1 (zh) * 2013-11-20 2014-11-20 中兴通讯股份有限公司 一种图片播放的方法、装置、计算机存储介质及机顶盒
CN108289228A (zh) * 2017-01-09 2018-07-17 阿里巴巴集团控股有限公司 一种全景视频转码方法、装置和设备
CN107155093A (zh) * 2017-06-21 2017-09-12 普联技术有限公司 一种视频预览方法、装置及设备
CN112399252A (zh) * 2019-08-14 2021-02-23 浙江宇视科技有限公司 软硬解码控制方法、装置及电子设备
CN113722058A (zh) * 2021-06-16 2021-11-30 荣耀终端有限公司 一种资源调用方法及电子设备
CN115129470A (zh) * 2022-06-24 2022-09-30 杭州海康威视数字技术股份有限公司 编解码资源分配方法、装置及电子设备

Also Published As

Publication number Publication date
CN115129470A (zh) 2022-09-30

Similar Documents

Publication Publication Date Title
US8947492B2 (en) Combining multiple bit rate and scalable video coding
WO2021008424A1 (zh) 图像合成方法、装置、电子设备及存储介质
EP3138289B1 (en) Method and system to combine multiple encoded videos for decoding via a video decoder
US8717404B2 (en) Recording a videoconference based on recording configurations
US8948822B2 (en) Coordinating power management functions in a multi-media device
WO2016138844A1 (zh) 音视频文件直播方法和系统、服务器
WO2023246946A1 (zh) 编解码资源分配方法、装置及电子设备
CN107155093B (zh) 一种视频预览方法、装置及设备
US20110317763A1 (en) Information processing apparatus and information processing method
US10432543B2 (en) Dual jitter buffers
WO2017080175A1 (zh) 用于多机位的视频播放器、播放系统及播放方法
US20230096562A1 (en) Method and system for transmitting and reproducing video of dynamic bitrate with a plurality of channels
WO2023040825A1 (zh) 媒体信息的传输方法、计算设备及存储介质
US8665281B2 (en) Buffer management for real-time streaming
US11689749B1 (en) Centralized streaming video composition
CN114025202B (zh) 视频处理方法、装置及存储介质
CN109587561B (zh) 视频处理方法、装置、电子设备及存储介质
CN111405347B (zh) 画面显示方法、装置、电子设备及可读存储介质
CN116980662A (zh) 流媒体播放方法、装置、电子设备、存储介质及程序产品
US10356439B2 (en) Flexible frame referencing for display transport
CN112911390B (zh) 一种视频数据的播放方法及终端设备
US9667683B2 (en) Scalable architecture for media mixing
US10887660B2 (en) Collaborative media quality determination
WO2020175176A1 (ja) 情報処理装置および方法、並びに、再生装置および方法
US11785281B2 (en) System and method for decimation of image data for multiviewer display

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23826590

Country of ref document: EP

Kind code of ref document: A1