WO2019007149A1 - 一种数据编码方法、装置、终端设备及计算机可读存储介质 - Google Patents

一种数据编码方法、装置、终端设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2019007149A1
WO2019007149A1 PCT/CN2018/086681 CN2018086681W WO2019007149A1 WO 2019007149 A1 WO2019007149 A1 WO 2019007149A1 CN 2018086681 W CN2018086681 W CN 2018086681W WO 2019007149 A1 WO2019007149 A1 WO 2019007149A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
control unit
rate control
length
rate
Prior art date
Application number
PCT/CN2018/086681
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 腾讯科技(深圳)有限公司
Priority to JP2019554773A priority Critical patent/JP6909308B2/ja
Priority to EP18827343.7A priority patent/EP3651464B1/en
Priority to KR1020197029189A priority patent/KR102306485B1/ko
Publication of WO2019007149A1 publication Critical patent/WO2019007149A1/zh
Priority to US16/400,334 priority patent/US11363263B2/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/115Selection of the code volume for a coding unit prior to coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • H04N19/114Adapting the group of pictures [GOP] structure, e.g. number of B-frames between two anchor frames
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/15Data rate or code amount at the encoder output by monitoring actual compressed data size at the memory before deciding storage at the transmission buffer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/172Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a picture, frame or field
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/177Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a group of pictures [GOP]

Definitions

  • the present application relates to the field of information processing technologies, and in particular, to a data encoding method, apparatus, terminal device, and computer readable storage medium.
  • the video transmitting end needs to encode the video data, and then send the encoded video data.
  • the video transmitting end needs to first allocate the encoding code rate, and then encode the video data according to the encoding code rate.
  • the video sender uses a group of picture (GOP) video frames as a rate control unit, first assigns a code rate to each GOP video frame, and then encodes each frame of video data before encoding.
  • the code rate is assigned to the video data of the current frame, and finally the actual code rate of one GOP video frame is close to the code rate allocated for the GOP video frame.
  • the smoothness of the short time code rate is not considered.
  • An embodiment of the present application provides a data encoding method, apparatus, storage device, and terminal device, which implements a first difference between an actual code rate of a data frame of a control unit and a second target code rate according to a second code rate.
  • the first target code rate of the control unit data frame is adjusted.
  • An embodiment of the present application provides a data encoding method, including:
  • the data transmitting end determines the length of the current first rate control unit data frame in the data to be transmitted, where the length of the first rate control unit data frame is less than or equal to the length of a group of picture GOP data frames;
  • the data transmitting end determines, according to the length of the first code rate control unit data frame, the target code rate of the data to be transmitted, and the frame rate of the data to be transmitted, the first data rate control unit data frame a target bit rate;
  • the second rate control unit data frame is a previous rate control unit data frame of the first rate control unit in the data to be transmitted;
  • the data transmitting end encodes the first rate control unit data frame according to the adjusted first target code rate.
  • An embodiment of the present application provides a data encoding apparatus, including:
  • a length determining unit configured to determine a length of a current first rate control unit data frame in the data to be transmitted, where a length of the first rate control unit data frame is less than or equal to a length of a group of picture GOP data frames;
  • a code rate determining unit configured to determine, according to a length of the first code rate control unit data frame, a target code rate of the data to be transmitted, and a frame rate of the data to be transmitted, the first data rate control unit data frame a target bit rate;
  • an adjusting unit configured to: when the first difference between the actual code rate of the second rate control unit data frame and the second target code rate is greater than zero, adjust the first target code rate according to the first difference,
  • the second rate control unit data frame is a previous rate control unit data frame of the first rate control unit in the data to be transmitted;
  • a coding unit configured to encode the first rate control unit data frame according to the adjusted first target code rate.
  • the embodiment of the present application provides a non-transitory computer readable storage medium storing a plurality of instructions, the instructions being adapted to be loaded by a processor and executed as in the embodiment of the present application.
  • the embodiment of the present application provides a terminal device, including a processor and a storage device, where the processor is configured to implement each instruction;
  • the storage device is configured to store a plurality of instructions for loading and executing a data encoding method according to the first aspect of the embodiments of the present application.
  • each time the data transmitting end encodes a data rate control unit (such as the first rate control unit), the current first rate control unit is determined according to actual requirements.
  • the first rate control unit data frame is encoded according to the adjusted first target code rate.
  • the length of the data frame of the first rate control unit can be flexibly set, for example, less than or equal to the length of a group of picture GOP data frames, and the first target code is obtained by actually coding the data frame of the previous code rate control unit.
  • the rate is adjusted so that the first code rate control unit is finally encoded according to the adjusted first target code rate, and the requirement for the code rate of any duration, especially the short-term code rate, can be satisfied.
  • FIG. 1 is a flowchart of a method for data encoding provided by an embodiment of the present application
  • FIG. 2 is a flowchart of a method for determining, by a data sending end, a length of a data frame of a first rate control unit according to an embodiment of the present application;
  • FIG. 3 is a schematic diagram of a scenario of application of a data encoding method according to an embodiment of the present application
  • FIG. 4 is a flowchart of a method for data encoding provided by an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a data encoding apparatus according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
  • the data encoding method provided by the embodiment of the present application is mainly applied to a process in which a data transmitting end sends data to be transmitted to a data receiving end.
  • the data transmitting end needs to first encode each group of GOP data frames in the data to be transmitted. And then send the encoded data to the data receiver.
  • the length of the first rate control unit data frame is less than or equal to the length of a group of picture GOP data frames, and controlling the unit data according to the first code rate Determining a first target code rate of the first rate control unit data frame when the length of the frame, the target code rate of the data to be transmitted, and the frame rate of the data to be transmitted; and the actual code rate of the data frame of the second rate control unit
  • the first difference between the two target code rates is greater than zero, and the first target code rate is adjusted according to the first difference, and the second rate control unit data frame is the previous code rate of the first rate control unit in the data to be transmitted.
  • Control unit data frame encoding the first rate control unit data frame according to the adjusted first target code rate.
  • the data transmitting end can flexibly set the length of the data frame of the first rate control unit, such as less than or equal to the length of a group of picture GOP data frames, and pass the actual coding of the data frame of the previous code rate control unit.
  • a target bit rate is adjusted so that the first rate control unit is finally encoded according to the adjusted first target rate, and the requirement for the code rate of any duration, especially the short-term code rate, can be satisfied.
  • the embodiment of the present application provides a data encoding method, which is mainly a method performed by the data sending end, wherein the data sending end may be a video data sending end, such as a WeChat client, and the flowchart is as shown in FIG. 1 , and includes:
  • Step 101 Determine a length of a current first rate control unit data frame in the data to be transmitted, where a length of the first rate control unit data frame is less than or equal to a length of a group of GOP data frames.
  • the data to be transmitted needs to be encoded first, and generally the multiple rate control included in the data to be transmitted is based on a data rate control unit data frame as a basic unit.
  • the unit performs coding one by one. Specifically, a target code rate is first determined for a rate control unit data frame, such that the actual code rate of the data rate control unit data frame is close to the target code rate of the data rate control unit data frame.
  • the code rate of a data rate control unit data frame refers to the total amount of data included in the data rate control unit data frame.
  • Steps 101 to 104 of the present embodiment are encoding methods performed for a data rate control unit (i.e., the current first rate control unit) data frame.
  • the data to be transmitted is composed of multiple groups of GOP data frames, and each group of GOP data frames includes an I frame, a P frame, and a B frame.
  • the first data frame is an I frame, which is a key frame.
  • the main information of the group of GOP data frames is concentrated in the I frame;
  • the P frame is a difference frame, indicating the difference between the frame and the previous key frame;
  • the B frame is A two-way difference frame indicating the difference between the frame and the preceding and succeeding frames.
  • the length of a group of GOP data frames may be represented by an I frame interval, and may specifically be n data frames.
  • the length of the first rate control unit data frame determined by the data sending end may be shorter than the length of a group of GOP data frames, and may be a short duration (such as 1 second or 2 seconds) with a smooth rate requirement.
  • the requirement for the stability of the short-term code rate is relatively high, and when the data to be transmitted is the video data of the real-time call, the length of the data frame of the first rate control unit can be determined as the code rate stationarity. The number of data frames included in the duration of the demand.
  • Step 102 Determine, according to the length of the data frame of the first code rate control unit, the target code rate of the data to be transmitted, and the frame rate of the data to be transmitted (that is, the number of data frames included per second), determine the data frame of the first rate control unit.
  • the first target bit rate is, according to the length of the data frame of the first code rate control unit, the target code rate of the data to be transmitted, and the frame rate of the data to be transmitted (that is, the number of data frames included per second), determine the data frame of the first rate control unit. The first target bit rate.
  • the first target code rate is the product of the target code rate of the data to be transmitted and the length of the first rate control unit data frame, and then the quotient of the frame rate of the data to be transmitted.
  • Step 103 When the first difference between the actual code rate of the second rate control unit data frame and the second target code rate is greater than zero, adjust the first target code rate according to the first difference, where the second code rate is The control unit data frame is a previous rate control unit data frame of the first rate control unit in the data to be transmitted.
  • the data transmitting end may appropriately reduce the first target code rate of the data frame of the first rate control unit, and specifically reduce the amount.
  • the determination may be based on a first difference between the actual code rate of the second rate control unit and its second target code rate.
  • the actual code rate of the data frame of the second rate control unit refers to the actual data included in the second rate control unit data frame after the data transmitting end encodes the second rate control unit data frame according to the second target code rate. The total amount of data.
  • the first target code rate obtained in step 102 is subtracted from the first difference to obtain the adjusted first target code rate. If the first difference is greater than the preset difference, calculating a weighted value of the second difference between the first difference and the preset difference; then subtracting the preset difference from the first target code rate, and then subtracting The weighted value is obtained to obtain the adjusted first target code rate.
  • the preset difference may be a fixed value set at the data transmitting end, or may be a value that changes as the length of the data frame of the first rate control unit changes. Specifically, before performing this step 103, the data transmitting end may first determine that the preset difference is the product of the average lowest code rate per frame and the length of the first rate control unit data frame.
  • Step 104 Code the first rate control unit data frame according to the adjusted first target code rate in step 103 above, so that the actual code rate of the first rate control unit data frame is close to the first target code rate.
  • the data transmitting end does not determine the first step of step 102 above.
  • the target bit rate is adjusted, and the first rate control unit data frame is directly encoded according to the first target code rate.
  • the length of the data frame of a rate control unit (such as the first rate control unit) can be changed according to the actual situation at any time, and the first code is according to the adjusted first target code rate.
  • the rate control unit data frame is encoded.
  • each time the data transmitting end encodes a data rate control unit (such as the first rate control unit), the current first rate control unit is determined according to actual requirements.
  • the first rate control unit data frame is encoded according to the adjusted first target code rate.
  • the length of the data frame of the first rate control unit can be flexibly set, for example, less than or equal to the length of a group of picture GOP data frames, and the first target code is obtained by actually coding the data frame of the previous code rate control unit.
  • the rate is adjusted so that the first code rate control unit is finally encoded according to the adjusted first target code rate, and the requirement for the code rate of any duration, especially the short-term code rate, can be satisfied.
  • Step 201 Set a duration of a smooth rate requirement of the data to be transmitted. If the number of data frames included in the duration of the smooth rate requirement is greater than or equal to the length r of a group of GOP data frames, step 202 is performed.
  • the data transmitting end performs step 203, and in another case, the data transmitting end performs In step 204, in other cases, the data sending end performs step 205 or 206.
  • the duration of the smooth rate requirement of the code rate refers to a relatively high requirement period for the stability of the code rate, and can be set according to the specific application of the data to be transmitted.
  • the duration of the smooth rate requirement can be 1 Seconds or 2 seconds, and for some non-real-time video data, the stability of the short-term code rate is not high, and the length of the data rate of the first rate control unit can be directly determined as one without setting the duration of the smooth rate requirement.
  • the length r of the group GOP data frame is 1 Seconds or 2 seconds
  • the number of data frames included in the duration of the smooth rate requirement may be obtained according to the duration of the smooth rate requirement of the code rate and the frame rate of the data to be transmitted, specifically the product of the duration of the rate requirement and the frame rate of the data to be transmitted. .
  • Step 202 Determine the length of the first rate control unit data frame as the length r of a group of GOP data frames.
  • Step 203 if the length r of a group of GOP data frames is an integer multiple of the number m of data frames determined above; or if the length r of a group of GOP data frames is not an integer multiple of the number m of the data frames, and the first code
  • the rate control unit data frame is the last rate control unit data frame included in a group of GOP data frames, and the number of data frames included in the duration of the code rate smooth requirement is determined as the length of the first rate control unit data frame.
  • the data to be transmitted is composed of multiple groups of GOP data frames
  • the length of the data rate control unit data frame is the number m of data frames determined above, the m is smaller than the length of a group of GOP data frames.
  • each group of GOP data frames can be divided into multiple rate control unit data frames, so that the length of the last rate control unit data frame included in a group of GOP data frames may be smaller than the above-mentioned rate requirement.
  • the number of data frames included in the duration is m.
  • the data sender will perform step 204.
  • Step 204 Determine the length of the first rate control unit data frame as the length r of a group of GOP data frames and the data rate control unit data frames of the group of GOP data frames except the first rate control unit data frame. The difference in length.
  • the length of each of the rate control unit data frames except the first rate control unit data frame in the group of GOP data frames may be the number m of the determined data frames.
  • the length r of a group of GOP data frames is not an integer multiple of the determined number of data frames m, and the last two rate control unit data frames in a group of GOP data frames are sequentially a rate control unit data frame and a third rate control unit data frame, that is, the first rate control unit data frame is a previous rate control unit data frame of the third rate control unit data frame, and the data transmitting end can pass
  • the length of the first rate control unit data frame is determined by the following steps 205 or 206 (the dotted arrow in FIG. 2 refers to the portion):
  • Step 205 If the third difference between the length r of the set of GOP data frames and the length of the fourth rate control unit data frame is an integer multiple of 2, determine the length of the first rate control unit data frame and the third code rate.
  • the control unit data frames have the same length and are half of the third difference.
  • the fourth rate control unit data frame is a data rate control unit data frame of the GOP data frame except the first rate control unit data frame and the third rate control unit data frame.
  • Step 206 If the third difference between the length r of the set of GOP data frames and the length of the fourth rate control unit data frame is not an integer multiple of 2, determine that the length of the first rate control unit data frame is the third difference. After adding 1 to the quotient of 2, the length of the data rate frame of the third rate control unit is the quotient of the third difference minus 1 and 2 pairs.
  • the data encoding method of the present application is described in a specific embodiment.
  • the method in this embodiment is mainly applied to a video call scenario of a WeChat client, and the data sending end is a WeChat client, and the data to be transmitted is video data to be transmitted.
  • the data to be transmitted is video data to be transmitted.
  • the local WeChat client collects the video data of the local end, and the video data includes multiple groups of GOP data frames. .
  • the local WeChat client first encodes the collected video data, and then sends the encoded video data to the peer WeChat client.
  • the following steps can be implemented.
  • the flowchart is as shown in FIG. 4, and includes:
  • Step 301 The WeChat client determines the length of the current first rate control unit data frame in the video data to be transmitted, and records it as Frame_Unit.
  • the WeChat client first sets a duration of a smooth rate requirement according to the video data to be transmitted. Since the video data to be transmitted is real-time video data, the corresponding required rate of the code rate can be set to be 1 second or 2 seconds; then, according to the frame rate of the video data, the number of data frames included in the duration of the smooth rate requirement of the code rate is determined.
  • the length of the first rate control unit data frame is determined as a set of GOP data.
  • the length of the frame, Frame_Unit GOP_size.
  • the first rate control unit data frame is the last rate control unit data frame included in a group of GOP data frames, and the first rate control is performed.
  • the length of a group of GOP data frames can be as follows:
  • FU 1 , FU 2 , . . . , FU n-1 , FU n a plurality of rate control unit data frames into which a group of GOP data frames are divided are respectively referred to as FU 1 , FU 2 , . . . , FU n-1 , FU n , wherein the first rate control unit data
  • the frame and the third rate control unit data frame are not denoted as FU n-1 , FU n , then:
  • the WeChat client may not follow the above ( The method of 41) or (42) determines the length of the first rate control unit data frame, but determines that the length of the first rate control unit data frame is m, and the length of the third rate control unit data frame is GOP_size- Tm.
  • lFU i represents the length of a code rate control unit data frame FU i , where i is any natural number between 1 and n.
  • Step 302 The WeChat client determines that the first target code rate of the first rate control unit data frame (referred to as Bit'Target_i ) is specifically the target code rate of the video data to be transmitted (referred to as BitRate Target ) and is determined by step 301 above.
  • the first rate control unit multiplies the length of the data frame and then the quotient of the frame rate of the video data (denoted as fps). That is:
  • Step 303 Determine whether the actual code rate of the data frame of the second rate control unit is greater than the second target code rate. If yes, perform step 305 to step 306; if less than or equal to the second target code rate, perform step 304 directly.
  • the second rate control unit data frame is a previous rate control unit data frame of the first rate control unit in the video data to be transmitted.
  • Step 304 The first target code rate determined in the above step 302 is used as a code rate for encoding the first code rate control unit data frame.
  • Step 305 The WeChat client controls the actual code rate (denoted as Bit Real_i-1 ) of the data frame of the previous code rate control unit (ie, the second rate control unit) of the first code rate control unit and its second target code rate ( The first difference is recorded as Bit Target_i-1 ), and the first target code rate is adjusted.
  • Bit Real_i-1 the actual code rate of the data frame of the previous code rate control unit (ie, the second rate control unit) of the first code rate control unit and its second target code rate ( The first difference is recorded as Bit Target_i-1 ), and the first target code rate is adjusted.
  • the first target code rate is reduced.
  • the first target code rate obtained by the first difference is obtained as Bit Target_i .
  • is a weighting coefficient of the second difference, which may be greater than or equal to zero and less than 1, and the preset difference TH Bit may be changed according to a change of the length of the data frame of the first code rate control unit, specifically Ground:
  • TH Bit_frame is the average lowest bit rate per frame.
  • Step 306 The WeChat client encodes the first rate control unit data frame according to the adjusted first target code rate.
  • the WeChat client repeatedly performs the above steps 301 to 306 until all rate control unit data frames included in the video data to be transmitted are encoded.
  • the embodiment of the present application further provides a data encoding device, such as the above-mentioned data sending end, and a schematic structural diagram thereof is shown in FIG. 5, which may specifically include:
  • a length determining unit 10 configured to determine a length of a current first rate control unit data frame in the data to be transmitted, where a length of the first rate control unit data frame is less than or equal to a length of a group of picture GOP data frames;
  • the code rate determining unit 11 is configured to determine, according to the length of the first rate control unit data frame determined by the length determining unit 10, the target code rate of the data to be transmitted, and the frame rate of the data to be transmitted. Rate control unit data frame first target code rate;
  • the adjusting unit 12 is configured to: when the first difference between the actual code rate of the second rate control unit data frame and the second target code rate is greater than zero, determine the code rate determining unit 11 according to the first difference The first target rate is adjusted, and the second rate control unit data frame is a previous rate control unit data frame of the first rate control unit in the data to be transmitted;
  • the encoding unit 13 is configured to encode the first rate control unit data frame according to the adjusted first target code rate of the adjusting unit 12.
  • the encoding unit 13 is further configured to: if the first difference between the actual code rate of the second rate control unit data frame and the second target code rate is less than or equal to zero, the first determined by the code rate determining unit 11
  • the first rate control unit data frame is encoded by a target bit rate.
  • the length determining unit 10 determines the current first according to actual requirements.
  • the code rate controls the length of the data frame
  • the first target code rate of the first rate control unit is determined by the code rate determining unit 11, and then the adjusting unit 12 controls the unit according to the previous rate (ie, the second rate control unit)
  • the encoding unit 13 encodes the first rate control unit data frame according to the adjusted first target code rate.
  • the length of the data frame of the first rate control unit can be flexibly set, for example, less than or equal to the length of a group of picture GOP data frames, and the first target code is obtained by actually coding the data frame of the previous code rate control unit.
  • the rate is adjusted so that the first code rate control unit is finally encoded according to the adjusted first target code rate, and the requirement for the code rate of any duration, especially the short-term code rate, can be satisfied.
  • the length determining unit 10 is specifically configured to set a duration of a smooth rate requirement of the data to be transmitted, if the duration of the code rate is required to be greater than or equal to the number of data frames. Determining the length of the set of picture GOP data frames, determining that the length of the first rate control unit data frame is the length of a group of picture GOP data frames;
  • the length determining unit 10 is further configured to: if the number of data frames included in the duration of the code rate smooth requirement is less than the length of the set of picture GOP data frames, if the length of the set of picture GOP data frames is An integer multiple of the number of data frames; or, if the length of the set of picture GOP data frames is not an integer multiple of the number of data frames, and the first rate control unit data frame is not the set.
  • the last rate control unit data frame included in the picture GOP data frame determines the number of data frames included in the duration of the code rate smoothing requirement as the length of the data frame of the first rate control unit; otherwise,
  • the first rate control unit data frame is the last rate control unit included in the set of picture GOP data frames Determining, by the data frame, a length of the first rate control unit data frame as a length of a group of picture GOP data frames and a code rate other than the first rate control unit data frame in the group of picture GOP data frames The difference in length of the control unit data frame.
  • the length determining unit 10 is further configured to: if the length of the set of picture GOP data frames is not an integer multiple of the number of data frames, and the last two of the set of picture GOP data frames
  • the code rate control unit data frame is sequentially the first rate control unit data frame and the third rate control unit data frame in sequence, then:
  • the rate control unit data frames have the same length, and are all half of the third difference value;
  • the fourth rate control unit data frame is the first code rate control unit data in the set of picture GOP data frames a frame rate and a third rate control unit data frame other than the data rate control unit data frame; if the third difference between the length of the set of picture GOP data frames and the length of the fourth rate control unit data frame is not 2
  • An integer multiple of the data rate of the first rate control unit is determined to be a quotient of the third difference plus one after the pair 2, and the length of the third rate control unit data frame is the third difference
  • the value of minus 1 is the quotient of 2.
  • the code rate determining unit 11 is specifically configured to determine that the first target code rate is the target code rate of the to-be-transmitted data and the first rate control unit data frame. The product of the length and the quotient of the frame rate of the data to be transmitted.
  • the adjusting unit 12 is specifically configured to: if the first difference is greater than zero, and less than or equal to a preset difference, subtract the first target code rate from the first difference The value is adjusted to the first target code rate; if the first difference is greater than the preset difference, calculating a weighted value of the second difference between the first difference and the preset difference And subtracting the preset difference from the first target code rate, and subtracting the weighted value to obtain an adjusted first target code rate.
  • the adjusting unit 12 is further configured to: before adjusting the first target code rate according to the first difference, adjust the preset difference to be a length of a data frame of the first rate control unit The product of the lowest bit rate per frame average.
  • the embodiment of the present application further provides a data encoding apparatus, such as the foregoing data sending end, the data encoding apparatus includes: at least one memory and at least one processor, where:
  • the at least one memory is for storing computer instructions
  • the at least one processor is configured to invoke computer instructions stored in the at least one memory, including:
  • the first target code rate is adjusted according to the first difference, wherein the second rate control unit data
  • the frame is a previous rate control unit data frame of the first rate control unit in the data to be transmitted;
  • the first rate control unit data frame is encoded according to the adjusted first target code rate.
  • the computer instruction for determining the length of the current first rate control unit data frame in the data to be transmitted may specifically include the following computer instructions:
  • determining the data rate of the first rate control unit The length is the length of a set of picture data frames
  • the length of the data rate smoothing requirement includes less than the length of the set of picture data frames: if the length of the set of picture data frames is an integer multiple of the number of the data frames; or if a group The length of the picture data frame is not an integer multiple of the number of data frames, and the first rate control unit data frame is the last rate control unit data frame included in the non-set of picture data frames, and the data transmitting end sets the code
  • the number of data frames included in the duration of the smooth demand is determined as the length of the data frame of the first rate control unit; otherwise,
  • the length of the set of picture data frames is not an integer multiple of the number of data frames, and the first rate control unit data frame is the last rate control unit data frame included in the set of picture data frames, determining the first The length of the data rate control unit data frame is the difference between the length of the set of picture data frames and the length of the data rate control unit data frames of the set of picture data frames except the first rate control unit data frame. value.
  • the computer instruction further comprises: if the third difference between the length of the set of picture data frames and the length of the fourth rate control unit data frame is an integer multiple of 2, determining the first rate control The length of the unit data frame is the same as the length of the third rate control unit data frame, and is half of the third difference; the fourth rate control unit data frame is the first rate control unit data in the group of picture data frames.
  • the length of the first rate control unit data frame is the quotient of the third difference plus one and the pair 2
  • the length of the third rate control unit data frame is the quotient of the third difference minus 1 and then 2.
  • the computer instruction of the first target bit rate may specifically include: determining a first target code rate as a product of a target code rate of the data to be transmitted and a length of the first frame rate control unit data frame, and then a frame rate of the data to be transmitted. Business value.
  • the computer instruction for adjusting the first target code rate according to the first difference may specifically include: if the first difference is greater than zero and less than or equal to the preset difference, the data is sent.
  • the terminal subtracts the first target code rate from the first difference to obtain an adjusted first target code rate; if the first difference is greater than the preset difference, the data sending end calculates the first difference and the preset The weighted value of the second difference of the difference values; the first target code rate is subtracted from the preset difference value, and the weighted value is subtracted to obtain the adjusted first target code rate.
  • the computer instruction further includes: determining the preset difference as a product of a length of the first rate control unit data frame and an average lowest frame rate per frame.
  • the computer instruction may further include: when the first difference between the actual code rate of the second rate control unit data frame and the second target code rate is less than or equal to zero, the first target to be determined
  • the code rate is used as a code rate for encoding the first rate control unit data frame, and encodes the first rate control unit data frame.
  • the embodiment of the present application further provides a terminal device, which is shown in FIG. 6.
  • the terminal device may have a large difference due to different configurations or performances, and may include one or more central processing units (central processing units, CPU) 20 (eg, one or more processors) and memory 21, one or more storage media 22 that store application 221 or data 222 (eg, one or one storage device in Shanghai).
  • the memory 21 and the storage medium 22 may be short-term storage or persistent storage.
  • the program stored on the storage medium 22 may include one or more modules (not shown), each of which may include a series of instruction operations in the terminal device.
  • central processor 20 may be arranged to communicate with storage medium 22 to perform a series of instruction operations in storage medium 22 on the terminal device.
  • the application 221 stored in the storage medium 22 includes a data-encoded application
  • the program may include the length determining unit 10, the code rate determining unit 11, the adjusting unit 12, and the encoding unit 13 in the above-described data encoding device, I will not repeat them here.
  • the central processor 20 may be arranged to communicate with the storage medium 22 to perform a series of operations corresponding to the data encoded application stored in the storage medium 22 on the terminal device.
  • the terminal device may also include one or more power sources 23, one or more wired or wireless network interfaces 24, one or more input and output interfaces 25, and/or one or more operating systems 223, such as Windows ServerTM, Mac OS. XTM, UnixTM, LinuxTM, FreeBSDTM and more.
  • the steps performed by the data transmitting end described in the foregoing method embodiments may be based on the structure of the terminal device shown in FIG. 6.
  • the embodiment of the present application further provides a non-transitory computer readable storage medium storing a plurality of instructions, the instructions being adapted to be loaded and executed by a processor as in the above embodiment.
  • the data encoding method performed by the data sender.
  • the embodiment of the present application further provides a terminal device, including a processor and a storage device, where the processor is configured to implement each instruction;
  • the storage device is configured to store a plurality of instructions for loading and executing by the processor and performing a data encoding method performed by the data transmitting end in the above embodiment.
  • the program may be stored in a computer readable storage medium, and the storage medium may include: Read only memory (ROM), random access memory (RAM), magnetic or optical disk, and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本申请实施例公开了一种数据编码方法、装置、存储设备及终端设备,应用于信息处理技术领域。所述方法包括:数据发送端根据实际需求确定第一码率控制单元数据帧的长度,并确定第一码率控制单元的第一目标码率,然后根据前一码率控制单元(即第二码率控制单元)数据帧的实际码率与其第二目标码率的第一差值对第一目标码率进行调整后,根据调整后的第一目标码率对第一码率控制单元数据帧进行编码。本申请实施例可以灵活地设置第一码率控制单元数据帧的长度,并通过对前一码率控制单元数据帧的实际编码情况对第一目标码率进行调整,使得最终根据调整后第一目标码率对第一码率控制单元进行编码后,满足对任何时长的码率特别是短时码率平稳性的要求。

Description

一种数据编码方法、装置、终端设备及计算机可读存储介质
本申请要求于2017年7月6日提交中国专利局、申请号为201710544962.7、发明名称为“一种数据编码方法、装置及存储设备和终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及信息处理技术领域,尤其涉及一种数据编码方法、装置、终端设备及计算机可读存储介质。
技术背景
在视频传输过程中,需要视频发送端先对视频数据进行编码,然后再将编码后的视频数据发送出去。其中对视频数据进行编码时,需要视频发送端先分配编码码率,然后根据编码码率对视频数据进行编码。
在现有技术中,视频发送端会以一组图片(Group of Picture,GOP)视频帧为码率控制单元,先为每个GOP视频帧分配码率,然后在对每帧视频数据进行编码前为当前帧的视频数据分配码率,最终使得一个GOP视频帧的实际码率接近为该GOP视频帧分配的码率。但是,当一个GOP视频帧比较大时,虽然该GOP视频帧的整体码率可达到目标码率,但没有考虑到短时码率的平稳性。
技术内容
本申请实施例提供一种数据编码方法、装置、存储设备及终端设备,实现了根据第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值对第一码率控制单元数据帧的第一目标码率进行调整。
本申请实施例提供一种数据编码方法,包括:
数据发送端确定待传输数据中当前的第一码率控制单元数据帧的长度,所述第一码率控制单元数据帧的长度小于或等于一组图片GOP数据帧的长度;
所述数据发送端根据所述第一码率控制单元数据帧的长度,所述待传输数据的目标码率及所述待传输数据的帧率确定所述第一码率控制单元数据帧的第一目标码率;
当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,所述数据发送端根据所述第一差值对所述第一目标码率进行调整,所述第二码率控制单元数据帧是所述待传输数据中第一码率控制单元的前一码率控制单元数据帧;
所述数据发送端根据所述调整后的第一目标码率对所述第一码率控制单元数据帧进行编码。
本申请实施例提供一种数据编码装置,包括:
长度确定单元,用于确定待传输数据中当前的第一码率控制单元数据帧的长度,所述第一码率控制单元数据帧的长度小于或等于一组图片GOP数据帧的长度;
码率确定单元,用于根据所述第一码率控制单元数据帧的长度,待传输数据的目标码率及所述待传输数据的帧率确定所述第一码率控制单元数据帧的第一目标码率;
调整单元,用于当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,根据所述第一差值对所述第一目标码率进行调整,所述第二码率控制单元数据帧是所述待传输数据中第一码率控制单元的前一码率控制单元数据帧;
编码单元,用于根据所述调整后的第一目标码率对所述第一码率控制单元数据帧进行编码。
本申请实施例提供一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质储存多条指令,所述指令适于由处理器加载并执行如本申请实施例第一方面所述的数据编码方法。
本申请实施例提供一种终端设备,包括处理器和存储设备,其中,所述处理器,用于实现各个指令;
所述存储设备用于储存多条指令,所述指令用于由处理器加载并执行如本申请实施例第一方面所述的数据编码方法。
可见,在本实施例的方法中,数据发送端每次对一个码率控制单元(比如第一码率控制单元)数据帧进行编码时,都会根据实际的需求确定当前的第一码率控制单元数据帧的长度,并确定第一码率控制单元的第一目标码率,然后根据前一码率控制单元(即第二码率控制单元)数据帧的实际码率与其第二目标码率的第一差值对第一目标码率进行调整后,根据调整后的第一目标码率对第一码率控制单元数据帧进行编码。这样,可以灵活地设置第一码率控制单元数据帧的长度,比如小于或等于一组图片GOP数据帧的长度,并通过对前一码率控制单元数据帧的实际编码情况对第一目标码率进行调整,使得最终根据调整后第一目标码率对第一码率控制单元进行编码后,可以满足对任何时长的码率特别是短时码率平稳性的要求。
附图简要说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种数据编码的方法流程图;
图2是本申请实施例提供的数据发送端确定第一码率控制单元数据帧的长度的方法流程图;
图3是本申请实施例提供的数据编码方法应用的场景示意图;
图4是本申请实施例提供的一种数据编码的方法流程图;
图5是本申请实施例提供的一种数据编码装置的结构示意图;
图6是本申请实施例提供的一种终端设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排它的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
本申请实施例提供的数据编码方法,主要应用于数据发送端发送待传输数据给数据接收端的过程中,在这个过程中,数据发送端需要先为 待传输数据中的每组GOP数据帧进行编码,然后再将编码后数据发送给数据接收端。
在本实施例中,数据发送端在对待传输数据中某一码率控制单元数据帧进行编码时:
先确定待传输数据中当前的第一码率控制单元数据帧的长度,第一码率控制单元数据帧的长度小于或等于一组图片GOP数据帧的长度,并根据第一码率控制单元数据帧的长度、待传输数据的目标码率及待传输数据的帧率,确定第一码率控制单元数据帧的第一目标码率;当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,根据第一差值对第一目标码率进行调整,第二码率控制单元数据帧是待传输数据中第一码率控制单元的前一码率控制单元数据帧;根据调整后的第一目标码率对第一码率控制单元数据帧进行编码。
这样,数据发送端可以灵活地设置第一码率控制单元数据帧的长度,比如小于或等于一组图片GOP数据帧的长度,并通过对前一码率控制单元数据帧的实际编码情况对第一目标码率进行调整,使得最终根据调整后第一目标码率对第一码率控制单元进行编码后,可以满足对任何时长的码率特别是短时码率平稳性的要求。
本申请实施例提供一种数据编码方法,主要是上述的数据发送端所执行的方法,其中数据发送端可以是视频数据发送端,比如微信客户端等,流程图如图1所示,包括:
步骤101,确定待传输数据中当前的第一码率控制单元数据帧的长度,第一码率控制单元数据帧的长度为小于或等于一组GOP数据帧的长度。
可以理解,数据发送端在将待传输数据发送给数据接收端之前,需要先对待传输数据进行编码,一般是以一个码率控制单元数据帧为基本 单位对待传输数据所包括的多个码率控制单元进行逐个编码,具体地,先为一个码率控制单元数据帧确定一个目标码率,使得该码率控制单元数据帧的实际码率接近为该码率控制单元数据帧的目标码率。其中,一个码率控制单元数据帧的码率是指该码率控制单元数据帧所包括的数据总量。
本实施例的步骤101到104是针对一个码率控制单元(即当前的第一码率控制单元)数据帧所执行的编码方法。
一般情况下,待传输数据是由多组GOP数据帧组成的,每一组GOP数据帧都包括I帧,P帧和B帧。其中,第一个数据帧为I帧,为关键帧,该组GOP数据帧的主要信息都集中在I帧;P帧为差别帧,表示该帧与之前的一个关键帧的差别;B帧为双向差别帧,表示该帧与前后帧之间的差别。则一组GOP数据帧的长度可以用I帧间隔来表示,具体可以为n个数据帧。
在本实施例中,数据发送端确定的第一码率控制单元数据帧的长度可能小于一组GOP数据帧的长度,具体可以为具有码率平稳需求的短时时长(比如1秒或2秒)所包括的数据帧个数,这样一组GOP数据帧就可以被划分为多个码率控制单元数据帧。
例如,对于实时视频通话,对短时码率的平稳性要求比较高,则当待传输数据为实时通话的视频数据时,可以将第一码率控制单元数据帧的长度确定为码率平稳性需求的时长所包括的数据帧个数。
步骤102,根据第一码率控制单元数据帧的长度、待传输数据的目标码率及待传输数据的帧率(即每秒包括的数据帧个数),确定第一码率控制单元数据帧的第一目标码率。
具体地,可以确定第一目标码率为待传输数据的目标码率与第一码率控制单元数据帧的长度的乘积,再与待传输数据的帧率的商值。
步骤103,当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,根据第一差值对第一目标码率进行调整,这里,第二码率控制单元数据帧是待传输数据中第一码率控制单元的前一码率控制单元数据帧。
可以理解,如果第二码率控制单元数据帧的实际码率超过第二目标码率,则数据发送端可以适当地减少该第一码率控制单元数据帧的第一目标码率,具体减少量可以根据第二码率控制单元的实际码率与其第二目标码率的第一差值来确定。其中,第二码率控制单元数据帧的实际码率是指数据发送端按照第二目标码率对第二码率控制单元数据帧进行编码后,第二码率控制单元数据帧所包括的实际数据总量。
具体地,如果该第一差值大于零,且小于或等于预置的差值,则将上述步骤102得到的第一目标码率减去第一差值得到调整后的第一目标码率。如果该第一差值大于预置的差值,计算第一差值与预置的差值的第二差值的加权值;然后将第一目标码率减去预置的差值,再减去加权值得到调整后的第一目标码率。
其中,预置的差值可以是设置在数据发送端的固定值,也可以是随着第一码率控制单元数据帧的长度的变化而改变的值。具体地,在执行本步骤103之前,数据发送端可以先确定预置的差值为平均每帧最低码率与第一码率控制单元数据帧的长度的乘积。
步骤104,根据上述步骤103调整后的第一目标码率对第一码率控制单元数据帧进行编码,使得第一码率控制单元数据帧的实际码率接近该第一目标码率。
进一步地,如果上述第一差值小于或等于零,即第二码率控制单元数据帧的实际码率小于或等于其第二目标码率,则数据发送端不会对上述步骤102确定的第一目标码率进行调整,直接按照该第一目标码率对 第一码率控制单元数据帧进行编码。
这样,通过上述步骤101到104,可以随时根据实际情况改变一个码率控制单元(比如第一码率控制单元)数据帧的长度,并根据调整后的第一目标码率,对该第一码率控制单元数据帧进行编码。
可见,在本实施例的方法中,数据发送端每次对一个码率控制单元(比如第一码率控制单元)数据帧进行编码时,都会根据实际的需求确定当前的第一码率控制单元数据帧的长度,并确定第一码率控制单元的第一目标码率,然后根据前一码率控制单元(即第二码率控制单元)数据帧的实际码率与其第二目标码率的第一差值对第一目标码率进行调整后,根据调整后的第一目标码率对第一码率控制单元数据帧进行编码。这样,可以灵活地设置第一码率控制单元数据帧的长度,比如小于或等于一组图片GOP数据帧的长度,并通过对前一码率控制单元数据帧的实际编码情况对第一目标码率进行调整,使得最终根据调整后第一目标码率对第一码率控制单元进行编码后,可以满足对任何时长的码率特别是短时码率平稳性的要求。
参考图2所示,在一个具体的实施例中,数据发送端在执行上述步骤101时,可以通过如下步骤来实现:
步骤201,设置待传输数据的码率平稳需求的时长,如果码率平稳需求的时长所包括的数据帧个数m大于或等于一组GOP数据帧的长度r,则执行步骤202。
如果码率平稳需求的时长所包括的数据帧个数m小于一组图片GOP数据帧的长度r,则在有些情况下,数据发送端执行步骤203,在另一种情况下,数据发送端执行步骤204,在另外一些情况下,数据发送端则执行步骤205或206。
这里的码率平稳需求的时长是指对码率的平稳性要求比较高的一 段时间,可以根据待传输数据的具体应用来设置,比如对于有些实时视频数据,码率平稳需求的时长可以是1秒或2秒,而对于有些非实时视频数据,对短时码率的平稳性要求不高,可以不用设置码率平稳需求的时长,直接将第一码率控制单元数据帧的长度确定为一组GOP数据帧的长度r。
其中,码率平稳需求的时长所包括的数据帧个数m可以根据码率平稳需求的时长与待传输数据的帧率得到,具体为码率平稳需求的时长与待传输数据的帧率的乘积。
步骤202,确定第一码率控制单元数据帧的长度为一组GOP数据帧的长度r。
步骤203,如果一组GOP数据帧的长度r是上述确定的数据帧个数m的整数倍;或者如果一组GOP数据帧的长度r不是上述数据帧个数m的整数倍,且第一码率控制单元数据帧非一组GOP数据帧包括的最后一个码率控制单元数据帧,则将码率平稳需求的时长所包括的数据帧个数m确定为第一码率控制单元数据帧的长度。
需要说明的是,由于待传输数据是由多组GOP数据帧组成的,则如果码率控制单元数据帧的长度为上述确定的数据帧个数m,该m小于一组GOP数据帧的长度r,则每组GOP数据帧都可以被划分为多个码率控制单元数据帧,这样可能会出现一组GOP数据帧所包括的最后一个码率控制单元数据帧的长度小于上述码率平稳需求的时长所包括的数据帧个数m。
具体地,如果一组GOP数据帧的长度r不是上述码率平稳需求的时长所包括的数据帧个数m的整数倍,且第一码率控制单元数据帧为一组GOP数据帧包括的最后一个码率控制单元数据帧,则数据发送端会执行步骤204。
步骤204,确定第一码率控制单元数据帧的长度为一组GOP数据帧的长度r与该组GOP数据帧中除第一码率控制单元数据帧之外的其它码率控制单元数据帧的长度的差值。其中,该组GOP数据帧中除第一码率控制单元数据帧之外的其它每个码率控制单元数据帧的长度都可以为上述确定的数据帧个数m。
在其它具体实施例中,如果一组GOP数据帧的长度r不是上述确定的数据帧个数m的整数倍,且一组GOP数据帧中最后两个码率控制单元数据帧按照顺序依次为第一码率控制单元数据帧和第三码率控制单元数据帧,即第一码率控制单元数据帧为第三码率控制单元数据帧的前一码率控制单元数据帧,数据发送端可以通过如下步骤205或206来确定第一码率控制单元数据帧的长度(图2中虚线箭头是指部分):
步骤205,如果一组GOP数据帧的长度r与第四码率控制单元数据帧的长度的第三差值为2的整数倍,确定第一码率控制单元数据帧的长度与第三码率控制单元数据帧的长度相同,都为该第三差值的一半。
其中,第四码率控制单元数据帧是一组GOP数据帧中除第一码率控制单元数据帧及第三码率控制单元数据帧之外的其它码率控制单元数据帧。
步骤206,如果一组GOP数据帧的长度r与第四码率控制单元数据帧的长度的第三差值不是2的整数倍,确定第一码率控制单元数据帧的长度为第三差值加1后对2的商,第三码率控制单元数据帧的长度为第三差值减1后对2的商。
以下以一个具体的实施例来说明本申请的数据编码方法,本实施例的方法主要应用于微信客户端的视频通话场景,则数据发送端为微信客户端,待传输数据为待传输的视频数据。在本实施例中:
参考图3所示,在具体应用中,用户通过本端微信客户端在发起与 对端微信客户端的视频通话后,本端微信客户端收集本端的视频数据,该视频数据包括多组GOP数据帧。本端微信客户端先对收集的视频数据进行编码,然后将编码后的视频数据发送给对端微信客户端。在本端微信客户端对视频数据进行编码的过程中,可以通过如下步骤来实现,流程图如图4所示,包括:
步骤301,微信客户端确定待传输的视频数据中当前的第一码率控制单元数据帧的长度,记为Frame_Unit。
具体地,微信客户端会先根据待传输的视频数据,设置一个码率平稳需求的时长,由于待传输的视频数据是实时视频数据,则可以设置对应的码率平稳需求的时长为1秒或2秒;然后再根据视频数据的帧率确定该码率平稳需求的时长所包括的数据帧个数m。
(1)如果确定的数据帧个数m大于或等于待传输的视频数据中一组GOP数据帧的长度,记为GOP_size,则将第一码率控制单元数据帧的长度确定为一组GOP数据帧的长度,即Frame_Unit=GOP_size。
(2)如果确定的数据帧个数m小于待传输的视频数据中一组GOP数据帧的长度,在有些情况下,如果一组GOP数据帧的长度是数据帧个数m的整数倍,或者一组GOP数据帧的长度不是数据帧个数m的整数倍,且第一码率控制单元数据帧非一组GOP数据帧包括的最后一个码率控制单元数据帧,则将第一码率控制单元数据帧的长度确定为确定的数据帧个数m,这时,Frame_Unit=m<GOP_size。
(3)如果确定的数据帧个数m小于待传输的视频数据中一组GOP数据帧的长度,在另一种情况下,如果一组GOP数据帧的长度不是上述确定的数据帧个数m的整数倍,且第一码率控制单元数据帧是一组GOP数据帧所包括的最后一个码率控制单元数据帧,则微信客户端确定第一 码率控制单元数据帧的长度为一组GOP数据帧的长度与一组GOP数据帧中除第一码率控制单元数据帧之外的其它码率控制单元数据帧的长度的差值。即Frame_Unit=GOP_size-tm,t为一组GOP数据帧所包括的其它码率控制单元数据帧的个数,其它码率控制单元数据帧的长度都为m。
(4)如果确定的数据帧个数m小于待传输的视频数据中一组GOP数据帧的长度,在其它情况下,如果一组GOP数据帧的长度不是上述确定的数据帧个数m的整数倍,且一组GOP数据帧中最后两个码率控制单元数据帧按照顺序依次为第一码率控制单元数据帧和第三码率控制单元数据帧,微信客户端在确定第一码率控制单元数据帧的长度时可以有如下几种情况:
具体地,假设一组GOP数据帧划分为的多个码率控制单元数据帧分别记为FU 1,FU 2,...,FU n-1,FU n,其中,第一码率控制单元数据帧和第三码率控制单元数据帧为别记为FU n-1,FU n,则:
(41)如果一组GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值为2的整数倍,其中,第四码率控制单元数据帧是一组GOP数据帧中除第一码率控制单元数据帧及第三码率控制单元数据帧之外的其它码率控制单元数据帧,即FU 1,FU 2,...,FU n-2,微信客户端确定第一码率控制单元数据帧FU n-1的长度与第三码率控制单元数据帧FU n的长度相同,都为第三差值的一半,即为:
Figure PCTCN2018086681-appb-000001
(42)如果一组GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值不是2的整数倍,确定第一码率控制单元数据帧的长度为 第三差值加1后对2的商,第三码率控制单元数据帧的长度为第三差值减1后对2的商,即:
Figure PCTCN2018086681-appb-000002
Figure PCTCN2018086681-appb-000003
(43)如果一组GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值再减去上述确定的数据帧个数m之后还大于上述确定的数据帧个数m的一半,即GOP_size-(lFU 1+lFU 2+......+lFU n-2)-m>m/2,但小于上述确定的数据帧个数m,微信客户端可以不用按照上述(41)或(42)中的方式确定第一码率控制单元数据帧的长度,而是确定第一码率控制单元数据帧的长度为m,第三码率控制单元数据帧的长度为GOP_size-tm。
需要说明的是,上述公式中lFU i表示一个码率控制单元数据帧FU i的长度,其中i为1到n之间的任一自然数。
(5)在其它情况下,如果根据实际应用,比如非实时视频数据,对短时码率的平稳性的要求不高,则不需要设置码率平稳需求的时长。在这种情况下,可以直接确定第一码率控制单元数据帧的长度为一组GOP数据帧的长度,即Frame_Unit=GOP_size。
步骤302,微信客户端确定第一码率控制单元数据帧的第一目标码率(记为Bit′ Target_i)具体为待传输的视频数据的目标码率(记为BitRate Target)与上述步骤301确定的第一码率控制单元数据帧的长度的乘积,再与视频数据的帧率(记为fps)的商值。即为:
Figure PCTCN2018086681-appb-000004
步骤303,判断第二码率控制单元数据帧的实际码率是否大于第二目标码率,如果大于,则执行步骤305到步骤306;如果小于或等于第二目标码率,则直接执行步骤304。这里第二码率控制单元数据帧为待传输的视频数据中第一码率控制单元的前一码率控制单元数据帧。
步骤304,将上述步骤302确定的第一目标码率作为对第一码率控制单元数据帧进行编码的码率。
步骤305,微信客户端根据第一码率控制单元的前一码率控制单元(即第二码率控制单元)数据帧的实际码率(记为Bit Real_i-1)与其第二目标码率(记为Bit Target_i-1)的第一差值,对第一目标码率进行调整。
(1)如果第二码率控制单元数据帧的实际码率大于第二目标码率,且第一差值未超过预置的差值(记为TH Bit),则将第一目标码率减去该第一差值得到调整后的第一目标码率,记为Bit Target_i
(2)如果第一差值超过预置的差值,则将第一目标码率减去预置的差值,再减去一个加权值得到调整后的第一目标码率,其中,加权值为第一差值与预置的差值的第二差值的加权值。即:
Figure PCTCN2018086681-appb-000005
其中,γ为上述第二差值的加权系数,可以大于或等于零且小于1,且预置的差值TH Bit是可以随着第一码率控制单元数据帧的长度的变化而改变的,具体地:
TH Bit=TH Bit_frame*Frame_Unit,
其中,TH Bit_frame为平均每帧最低码率。
步骤306,微信客户端根据调整后的第一目标码率对第一码率控制单元数据帧进行编码。
这样微信客户端重复执行上述步骤301到306,直到对待传输的视频数据包括的所有码率控制单元数据帧进行编码。
本申请实施例还提供一种数据编码装置,比如上述的数据发送端,其结构示意图如图5所示,具体可以包括:
长度确定单元10,用于确定待传输数据中当前的第一码率控制单元数据帧的长度,所述第一码率控制单元数据帧的长度小于或等于一组图片GOP数据帧的长度;
码率确定单元11,用于根据所述长度确定单元10确定的第一码率控制单元数据帧的长度,待传输数据的目标码率及所述待传输数据的帧率确定所述第一码率控制单元数据帧的第一目标码率;
调整单元12,用于当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,根据所述第一差值对所述码率确定单元11确定的第一目标码率进行调整,所述第二码率控制单元数据帧是所述待传输数据中第一码率控制单元的前一码率控制单元数据帧;
编码单元13,用于根据所述调整单元12调整后的第一目标码率对所述第一码率控制单元数据帧进行编码。
进一步地,编码单元13,还用于如果第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值小于或等于零,则根据所述码率确定单元11确定的第一目标码率对所述第一码率控制单元数据帧进行编码。
可见,在本实施例的装置中,编码单元13每次对一个码率控制单元(比如第一码率控制单元)数据帧进行编码时,长度确定单元10都会根 据实际的需求确定当前的第一码率控制单元数据帧的长度,并由码率确定单元11确定第一码率控制单元的第一目标码率,然后调整单元12根据前一码率控制单元(即第二码率控制单元)数据帧的实际码率与其第二目标码率的第一差值对第一目标码率进行调整后,编码单元13根据调整后的第一目标码率对第一码率控制单元数据帧进行编码。这样,可以灵活地设置第一码率控制单元数据帧的长度,比如小于或等于一组图片GOP数据帧的长度,并通过对前一码率控制单元数据帧的实际编码情况对第一目标码率进行调整,使得最终根据调整后第一目标码率对第一码率控制单元进行编码后,可以满足对任何时长的码率特别是短时码率平稳性的要求。
在具体的实施例中,上述长度确定单元10,具体用于设置所述待传输数据的码率平稳需求的时长,如果所述码率平稳需求的时长所包括的数据帧个数大于或等于所述一组图片GOP数据帧的长度,则确定所述第一码率控制单元数据帧的长度为一组图片GOP数据帧的长度;
且长度确定单元10,还用于如果所述码率平稳需求的时长所包括的数据帧个数小于所述一组图片GOP数据帧的长度,则如果所述一组图片GOP数据帧的长度是所述数据帧个数的整数倍;或者,如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述第一码率控制单元数据帧非所述一组图片GOP数据帧包括的最后一个码率控制单元数据帧,则将所述码率平稳需求的时长所包括的数据帧个数确定为所述第一码率控制单元数据帧的长度;否则,
如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述第一码率控制单元数据帧是所述一组图片GOP数据帧包括的最后一个码率控制单元数据帧,确定所述第一码率控制单元数据帧的长度为一组图片GOP数据帧的长度与所述一组图片GOP数据帧中除第一 码率控制单元数据帧之外的其它码率控制单元数据帧的长度的差值。
在其它情况下,所述长度确定单元10,还用于如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述一组图片GOP数据帧中最后两个码率控制单元数据帧按照顺序依次为所述第一码率控制单元数据帧和第三码率控制单元数据帧,则:
如果所述一组图片GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值为2的整数倍,确定所述第一码率控制单元数据帧的长度与第三码率控制单元数据帧的长度相同,都为所述第三差值的一半;所述第四码率控制单元数据帧是所述一组图片GOP数据帧中除所述第一码率控制单元数据帧及第三码率控制单元数据帧之外的其它码率控制单元数据帧;如果所述一组图片GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值不是2的整数倍,确定所述第一码率控制单元数据帧的长度为所述第三差值加1后对2的商,所述第三码率控制单元数据帧的长度为所述第三差值减1后对2的商。
在另一个具体的实施例中,所述码率确定单元11,具体用于确定所述第一目标码率为所述待传输数据的目标码率与所述第一码率控制单元数据帧的长度的乘积,再与所述待传输数据的帧率的商值。
在其它具体的实例中,所述调整单元12,具体用于如果所述第一差值大于零,且小于或等于预置的差值,则将第一目标码率减去所述第一差值得到调整后的第一目标码率;如果所述第一差值大于所述预置的差值,计算所述第一差值与所述预置的差值的第二差值的加权值;将所述第一目标码率减去所述预置的差值,再减去所述加权值得到调整后的第一目标码率。
该调整单元12,还用于在根据所述第一差值对所述第一目标码率进行调整之前,调整所述预置的差值为所述第一码率控制单元数据帧的长 度与平均每帧最低码率的乘积。
本申请实施例还提供一种数据编码装置,比如上述的数据发送端,该数据编码装置包括:至少一个存储器和至少一个处理器,其中:
所述至少一个存储器用于存储计算机指令;
所述至少一个处理器用于调用所述至少一个存储器中存储的计算机指令,包括:
确定待传输数据中当前的第一码率控制单元数据帧的长度,其中,第一码率控制单元数据帧的长度小于或等于一组图片数据帧的长度;
根据第一码率控制单元数据帧的长度,待传输数据的目标码率及待传输数据的帧率,确定第一码率控制单元数据帧的第一目标码率;
当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,根据第一差值对第一目标码率进行调整,其中,第二码率控制单元数据帧是待传输数据中第一码率控制单元的前一码率控制单元数据帧;以及
根据所述调整后的第一目标码率对第一码率控制单元数据帧进行编码。
其中,在本申请的实施例中,确定待传输数据中当前的第一码率控制单元数据帧的长度的计算机指令可以具体包括如下计算机指令:
设置待传输数据的码率平稳需求的时长,如果码率平稳需求的时长所包括的数据帧个数大于或等于所述一组图片数据帧的长度,则确定第一码率控制单元数据帧的长度为一组图片数据帧的长度;
如果码率平稳需求的时长所包括的数据帧个数小于所述一组图片数据帧的长度,则:如果一组图片数据帧的长度是所述数据帧个数的整数倍;或者如果一组图片数据帧的长度不是所述数据帧个数的整数倍,且第一码率控制单元数据帧非一组图片数据帧包括的最后一个码率控 制单元数据帧,则数据发送端将所述码率平稳需求的时长所包括的数据帧个数确定为第一码率控制单元数据帧的长度;否则,
如果一组图片数据帧的长度不是所述数据帧个数的整数倍,且第一码率控制单元数据帧是一组图片数据帧包括的最后一个码率控制单元数据帧,确定所述第一码率控制单元数据帧的长度为一组图片数据帧的长度与所述一组图片数据帧中除所述第一码率控制单元数据帧之外的其它码率控制单元数据帧的长度的差值。
进一步,如果一组图片数据帧的长度不是数据帧个数的整数倍,且一组图片数据帧中最后两个码率控制单元数据帧按照顺序依次为第一码率控制单元数据帧和第三码率控制单元数据帧,则上述计算机指令还包括:如果一组图片数据帧的长度与第四码率控制单元数据帧的长度的第三差值为2的整数倍,确定第一码率控制单元数据帧的长度与第三码率控制单元数据帧的长度相同,都为第三差值的一半;第四码率控制单元数据帧是一组图片数据帧中除第一码率控制单元数据帧及第三码率控制单元数据帧之外的其它码率控制单元数据帧;如果一组图片数据帧的长度与第四码率控制单元数据帧的长度的第三差值不是2的整数倍,确定第一码率控制单元数据帧的长度为第三差值加1后对2的商,第三码率控制单元数据帧的长度为第三差值减1后对2的商。
在本申请的实施例中,上述根据所述第一码率控制单元数据帧的长度、待传输数据的目标码率及所述待传输数据的帧率,确定第一码率控制单元数据帧的第一目标码率的计算机指令具体可以包括:确定第一目标码率为待传输数据的目标码率与第一帧码率控制单元数据帧的长度的乘积,再与待传输数据的帧率的商值。
在本申请的实施例中,上述根据第一差值对第一目标码率进行调整的计算机指令具体可以包括:如果第一差值大于零,且小于或等于预置 的差值,则数据发送端将第一目标码率减去所述第一差值得到调整后的第一目标码率;如果第一差值大于所述预置的差值,数据发送端计算第一差值与预置的差值的第二差值的加权值;将第一目标码率减去预置的差值,再减去加权值得到调整后的第一目标码率。
在执行根据第一差值对第一目标码率进行调整之前,上述计算机指令还包括:确定预置的差值为第一码率控制单元数据帧的长度与平均每帧最低码率的乘积。
在本申请的实施例中,上述计算机指令还可以进一步包括:当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值小于或等于零,将确定的第一目标码率作为对第一码率控制单元数据帧进行编码的码率,并对第一码率控制单元数据帧进行编码。
本申请实施例还提供一种终端设备,其结构示意图如图6所示,该终端设备可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)20(例如,一个或一个以上处理器)和存储器21,一个或一个以上存储应用程序221或数据222的存储介质22(例如一个或一个以上海量存储设备)。其中,存储器21和存储介质22可以是短暂存储或持久存储。存储在存储介质22的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对终端设备中的一系列指令操作。更进一步地,中央处理器20可以设置为与存储介质22通信,在终端设备上执行存储介质22中的一系列指令操作。
具体地,在存储介质22中储存的应用程序221包括数据编码的应用程序,且该程序可以包括上述数据编码装置中的长度确定单元10,码率确定单元11,调整单元12和编码单元13,在此不进行赘述。更进一步地,中央处理器20可以设置为与存储介质22通信,在终端设备上执行存储介质22中储存的数据编码的应用程序对应的一系列操作。
终端设备还可以包括一个或一个以上电源23,一个或一个以上有线或无线网络接口24,一个或一个以上输入输出接口25,和/或,一个或一个以上操作系统223,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。
上述方法实施例中所述的由数据发送端所执行的步骤可以基于该图6所示的终端设备的结构。
本申请实施例还提供一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质储存多条指令,所述指令适于由处理器加载并执行如上述实施例中数据发送端所执行的数据编码方法。
本申请实施例还提供一种终端设备,包括处理器和存储设备,所述处理器,用于实现各个指令;
所述存储设备用于储存多条指令,所述指令用于由处理器加载并执行如上述实施例中数据发送端所执行的数据编码方法。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:只读存储器(ROM)、随机存取存储器RAM)、磁盘或光盘等。
以上对本申请实施例所提供的数据编码方法、装置及存储设备和终端设备进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (15)

  1. 一种数据编码方法,其特征在于,包括:
    数据发送端确定待传输数据中当前的第一码率控制单元数据帧的长度,所述第一码率控制单元数据帧的长度小于或等于一组图片GOP数据帧的长度;
    所述数据发送端根据所述第一码率控制单元数据帧的长度,待传输数据的目标码率及所述待传输数据的帧率,确定所述第一码率控制单元数据帧的第一目标码率;
    当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,所述数据发送端根据所述第一差值对所述第一目标码率进行调整,所述第二码率控制单元数据帧是所述待传输数据中第一码率控制单元的前一码率控制单元数据帧;
    所述数据发送端根据所述调整后的第一目标码率对所述第一码率控制单元数据帧进行编码。
  2. 如权利要求1所述的方法,其特征在于,所述数据发送端确定待传输数据中当前的第一码率控制单元数据帧的长度,具体包括:
    所述数据发送端设置所述待传输数据的码率平稳需求的时长,如果所述码率平稳需求的时长所包括的数据帧个数大于或等于所述一组图片GOP数据帧的长度,则确定所述第一码率控制单元数据帧的长度为一组图片GOP数据帧的长度;
    如果所述码率平稳需求的时长所包括的数据帧个数小于所述一组图片GOP数据帧的长度,则:如果所述一组图片GOP数据帧的长度是所述数据帧个数的整数倍;或者如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述第一码率控制单元数据帧非所述一组图片GOP数据帧包括的最后一个码率控制单元数据帧,则所述数据发送 端将所述码率平稳需求的时长所包括的数据帧个数确定为所述第一码率控制单元数据帧的长度;否则,
    如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述第一码率控制单元数据帧是所述一组图片GOP数据帧包括的最后一个码率控制单元数据帧,所述数据发送端确定所述第一码率控制单元数据帧的长度为一组图片GOP数据帧的长度与所述一组图片GOP数据帧中除所述第一码率控制单元数据帧之外的其它码率控制单元数据帧的长度的差值。
  3. 如权利要求2所述的方法,其特征在于,如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述一组图片GOP数据帧中最后两个码率控制单元数据帧按照顺序依次为所述第一码率控制单元数据帧和第三码率控制单元数据帧,则所述方法还包括:
    如果所述一组图片GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值为2的整数倍,所述数据发送端确定所述第一码率控制单元数据帧的长度与第三码率控制单元数据帧的长度相同,都为所述第三差值的一半;所述第四码率控制单元数据帧是所述一组图片GOP数据帧中除所述第一码率控制单元数据帧及第三码率控制单元数据帧之外的其它码率控制单元数据帧;
    如果所述一组图片GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值不是2的整数倍,所述数据发送端确定所述第一码率控制单元数据帧的长度为所述第三差值加1后对2的商,所述第三码率控制单元数据帧的长度为所述第三差值减1后对2的商。
  4. 如权利要求1至3任一项所述的方法,其特征在于,所述数据发送端根据所述第一码率控制单元数据帧的长度、待传输数据的目标码率及所述待传输数据的帧率,确定所述第一码率控制单元数据帧的第一目 标码率,具体包括:
    所述数据发送端确定所述第一目标码率为所述待传输数据的目标码率与所述第一帧码率控制单元数据帧的长度的乘积,再与所述待传输数据的帧率的商值。
  5. 如权利要求1至3任一项所述的方法,其特征在于,所述数据发送端根据所述第一差值对所述第一目标码率进行调整,具体包括:
    如果所述第一差值大于零,且小于或等于预置的差值,则所述数据发送端将第一目标码率减去所述第一差值得到调整后的第一目标码率;
    如果所述第一差值大于所述预置的差值,所述数据发送端计算所述第一差值与所述预置的差值的第二差值的加权值;将所述第一目标码率减去所述预置的差值,再减去所述加权值得到调整后的第一目标码率。
  6. 如权利要求5所述的方法,其特征在于,所述数据发送端根据所述第一差值对所述第一目标码率进行调整之前,所述方法还包括:所述数据发送端确定所述预置的差值为所述第一码率控制单元数据帧的长度与平均每帧最低码率的乘积。
  7. 如权利要求1所述的方法,其特征在于,所述方法进一步包括:
    当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值小于或等于零,所述数据发送端将确定的第一目标码率作为对所述第一码率控制单元数据帧进行编码的码率,并对所述第一码率控制单元数据帧进行编码。
  8. 一种数据编码装置,其特征在于,包括:
    长度确定单元,用于确定待传输数据中当前的第一码率控制单元数据帧的长度,所述第一码率控制单元数据帧的长度小于或等于一组图片GOP数据帧的长度;
    码率确定单元,用于根据所述第一码率控制单元数据帧的长度,待 传输数据的目标码率及所述待传输数据的帧率确定所述第一码率控制单元数据帧的第一目标码率;
    调整单元,用于当第二码率控制单元数据帧的实际码率与其第二目标码率的第一差值大于零,根据所述第一差值对所述第一目标码率进行调整,所述第二码率控制单元数据帧是所述待传输数据中第一码率控制单元的前一码率控制单元数据帧;
    编码单元,用于根据所述调整后的第一目标码率对所述第一码率控制单元数据帧进行编码。
  9. 如权利要求8所述的装置,其特征在于,
    所述长度确定单元,具体用于设置所述待传输数据的码率平稳需求的时长,如果所述码率平稳需求的时长所包括的数据帧个数大于或等于所述一组图片GOP数据帧的长度,则确定所述第一码率控制单元数据帧的长度为一组图片GOP数据帧的长度;
    所述长度确定单元,还用于如果所述码率平稳需求的时长所包括的数据帧个数小于所述一组图片GOP数据帧的长度,则:如果所述一组图片GOP数据帧的长度是所述数据帧个数的整数倍;或者,如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述第一码率控制单元数据帧非所述一组图片GOP数据帧包括的最后一个码率控制单元数据帧,则将所述码率平稳需求的时长所包括的数据帧个数确定为所述第一码率控制单元数据帧的长度;否则,
    如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述第一码率控制单元数据帧是所述一组图片GOP数据帧包括的最后一个码率控制单元数据帧,确定所述第一码率控制单元数据帧的长度为一组图片GOP数据帧的长度与所述一组图片GOP数据帧中除所述第一码率控制单元数据帧之外的的其它码率控制单元数据帧的长度的 差值。
  10. 如权利要求9所述的装置,其特征在于,
    所述长度确定单元,还用于如果所述一组图片GOP数据帧的长度不是所述数据帧个数的整数倍,且所述一组图片GOP数据帧中最后两个码率控制单元数据帧按照顺序依次为所述第一码率控制单元数据帧和第三码率控制单元数据帧,则:
    如果所述一组图片GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值为2的整数倍,确定所述第一码率控制单元数据帧的长度与第三码率控制单元数据帧的长度相同,都为所述第三差值的一半;所述第四码率控制单元数据帧是所述一组图片GOP数据帧中除所述第一码率控制单元数据帧及第三码率控制单元数据帧之外的其它码率控制单元数据帧;
    如果所述一组图片GOP数据帧的长度与第四码率控制单元数据帧的长度的第三差值不是2的整数倍,确定所述第一码率控制单元数据帧的长度为所述第三差值加1后对2的商,所述第三码率控制单元数据帧的长度为所述第三差值减1后对2的商。
  11. 如权利要求8至10任一项所述的装置,其特征在于,
    所述码率确定单元,具体用于确定所述第一目标码率为所述待传输数据的目标码率与所述第一码率控制单元数据帧的长度的乘积,再与所述待传输数据的帧率的商值。
  12. 如权利要求8至11任一项所述的装置,其特征在于,
    所述调整单元,具体用于如果所述第一差值大于零,且小于或等于预置的差值,则将第一目标码率减去所述第一差值得到调整后的第一目标码率;如果所述第一差值大于所述预置的差值,计算所述第一差值与所述预置的差值的第二差值的加权值;将所述第一目标码率减去所述预 置的差值,再减去所述加权值得到调整后的第一目标码率。
  13. 如权利要求12所述的装置,其特征在于,所述调整单元,还用于在根据所述第一差值对所述第一目标码率进行调整之前,调整所述预置的差值为所述第一码率控制单元数据帧的长度与平均每帧最低码率的乘积。
  14. 一种非易失性计算机可读存储介质,其特征在于,所述非易失性计算机可读存储介质储存多条指令,所述指令适于由处理器加载并执行如权利要求1至7任一项所述的数据编码方法。
  15. 一种终端设备,其特征在于,包括处理器和存储设备,其中,所述处理器,用于实现各个指令;
    所述存储设备用于储存多条指令,所述指令用于由处理器加载并执行如权利要求1至7任一项所述的数据编码方法。
PCT/CN2018/086681 2017-07-06 2018-05-14 一种数据编码方法、装置、终端设备及计算机可读存储介质 WO2019007149A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
JP2019554773A JP6909308B2 (ja) 2017-07-06 2018-05-14 データ符号化方法、装置、端末機器及びコンピュータ可読記憶媒体
EP18827343.7A EP3651464B1 (en) 2017-07-06 2018-05-14 Data encoding method and apparatus, terminal device and computer readable storage medium
KR1020197029189A KR102306485B1 (ko) 2017-07-06 2018-05-14 데이터 부호화 방법, 장치, 단말기기 및 컴퓨터 판독 가능한 기억매체
US16/400,334 US11363263B2 (en) 2017-07-06 2019-05-01 Data coding method and apparatus, terminal device, and computer-readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710544962.7A CN109218724B (zh) 2017-07-06 2017-07-06 一种数据编码方法、装置及存储设备和终端设备
CN201710544962.7 2017-07-06

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/400,334 Continuation US11363263B2 (en) 2017-07-06 2019-05-01 Data coding method and apparatus, terminal device, and computer-readable storage medium

Publications (1)

Publication Number Publication Date
WO2019007149A1 true WO2019007149A1 (zh) 2019-01-10

Family

ID=64949660

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/086681 WO2019007149A1 (zh) 2017-07-06 2018-05-14 一种数据编码方法、装置、终端设备及计算机可读存储介质

Country Status (6)

Country Link
US (1) US11363263B2 (zh)
EP (1) EP3651464B1 (zh)
JP (1) JP6909308B2 (zh)
KR (1) KR102306485B1 (zh)
CN (1) CN109218724B (zh)
WO (1) WO2019007149A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111836081B (zh) * 2020-07-20 2021-07-27 南京百家云科技有限公司 一种视频传输的方法及装置
CN112565834B (zh) * 2021-02-24 2021-05-11 北京创世云科技股份有限公司 一种控制输出数据的方法、装置及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1997031481A1 (en) * 1996-02-26 1997-08-28 Sarnoff Corporation Dynamic coding rate control in a block-based video coding system
CN105872594A (zh) * 2016-03-30 2016-08-17 乐视控股(北京)有限公司 实时码率调节方法、装置及服务端设备
CN106060548A (zh) * 2016-05-26 2016-10-26 安凯(广州)微电子技术有限公司 一种码率控制的方法和装置
CN106331704A (zh) * 2015-07-07 2017-01-11 杭州海康威视数字技术股份有限公司 一种视频码率控制方法及视频编码装置
CN106488175A (zh) * 2015-08-26 2017-03-08 重庆西线科技有限公司 一种视频传输方法

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2000065842A1 (en) 1999-04-23 2000-11-02 Sony Corporation Image encoder and its method
JP2001086512A (ja) 1999-09-14 2001-03-30 Nec Corp 可変ビットレート符号化装置
DE60206738D1 (de) * 2002-06-11 2005-11-24 St Microelectronics Srl Videokodierungsverfahren und -Vorrichtung mit variabler Bitrate
KR100543453B1 (ko) * 2003-04-24 2006-01-23 삼성전자주식회사 디지털 비디오 스트림의 역재생시 비트율을 제어하기 위한 장치 및 그 방법
WO2006099226A1 (en) * 2005-03-10 2006-09-21 Qualcomm Incorporated Quasi-constant-quality rate control with look-ahead
CN100425077C (zh) * 2006-08-07 2008-10-08 浙江大学 采用帧目标比特数不平均分配的视频压缩码率控制方法
BRPI0912670A2 (pt) * 2008-05-16 2016-01-26 Sharp Kk aparelho de gravação
CN101651827B (zh) * 2009-07-16 2012-06-13 上海交通大学 屏幕编码的码率控制方法
US20110255594A1 (en) 2010-04-15 2011-10-20 Soyeb Nagori Rate Control in Video Coding
CN101977309B (zh) * 2010-06-30 2012-07-25 无锡中星微电子有限公司 码率控制方法及装置
CN104270649B (zh) * 2014-10-28 2019-01-22 中磊电子(苏州)有限公司 影像编码装置及影像编码方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1997031481A1 (en) * 1996-02-26 1997-08-28 Sarnoff Corporation Dynamic coding rate control in a block-based video coding system
CN106331704A (zh) * 2015-07-07 2017-01-11 杭州海康威视数字技术股份有限公司 一种视频码率控制方法及视频编码装置
CN106488175A (zh) * 2015-08-26 2017-03-08 重庆西线科技有限公司 一种视频传输方法
CN105872594A (zh) * 2016-03-30 2016-08-17 乐视控股(北京)有限公司 实时码率调节方法、装置及服务端设备
CN106060548A (zh) * 2016-05-26 2016-10-26 安凯(广州)微电子技术有限公司 一种码率控制的方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3651464A4 *

Also Published As

Publication number Publication date
JP6909308B2 (ja) 2021-07-28
JP2020516197A (ja) 2020-05-28
US20190260991A1 (en) 2019-08-22
CN109218724A (zh) 2019-01-15
EP3651464B1 (en) 2023-05-31
EP3651464A1 (en) 2020-05-13
CN109218724B (zh) 2020-08-04
EP3651464A4 (en) 2021-03-24
KR20190120374A (ko) 2019-10-23
KR102306485B1 (ko) 2021-09-28
US11363263B2 (en) 2022-06-14

Similar Documents

Publication Publication Date Title
US11089305B2 (en) Video frame coding method during scene change, terminal and storage medium
US20030165150A1 (en) Multi-threshold smoothing
US9826260B2 (en) Video encoding device and video encoding method
US11356635B2 (en) Imaging apparatus using MJPEG compression method
US8249070B2 (en) Methods and apparatuses for performing scene adaptive rate control
WO2018059175A1 (zh) 视频码率处理方法和装置、存储介质及电子设备
WO2019007149A1 (zh) 一种数据编码方法、装置、终端设备及计算机可读存储介质
EP1187460A2 (en) Image transmitting method and apparatus and image receiving method and apparatus
WO2022152137A1 (zh) 基于网络反馈的视频编码方法、装置、设备及存储介质
US20130003594A1 (en) Communication Apparatus, Method for Implementing Communication, and Non-Transitory Computer-Readable Medium
US20200412783A1 (en) Congestion response for timely media delivery
CN108476176A (zh) 在视频电话中的实时传输协议拥塞控制技术
CN117597920A (zh) 视频编码的方法、装置、设备和存储介质
WO2017161124A1 (en) System for video streaming using delay-aware fountain codes
US11197044B2 (en) Communication apparatus, media distribution system, media distribution method, and non-transitory computer readable medium
US10951924B2 (en) Video encoder
CN114389959A (zh) 网络拥塞控制方法、装置、电子设备及存储介质
CN112788335B (zh) 一种适用于实时视频传输的h.264帧级码率控制方法
KR101837637B1 (ko) 클라이언트 측 ack 조정 기반 적응 스트리밍 방법 및 장치
WO2016000191A1 (zh) 传输拥塞的确定方法及装置
Bhat et al. Distortion minimization in energy harvesting sensor nodes with compression power constraints
CN114039931B (zh) 一种控制数据传输的方法、装置、设备及介质
CN112737971A (zh) 数据处理方法、装置、存储介质及网络设备
KR102123839B1 (ko) 네트워크 환경에서의 적응적 텍스트 스트림 데이터 전송 시스템 및 그 방법
CN110611789A (zh) 视频流传输控制方法、装置、电子设备及存储介质

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: 18827343

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 20197029189

Country of ref document: KR

Kind code of ref document: A

Ref document number: 2019554773

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2018827343

Country of ref document: EP

Effective date: 20200206