WO2023246936A1 - Image processing method and apparatus, and device - Google Patents
Image processing method and apparatus, and device Download PDFInfo
- Publication number
- WO2023246936A1 WO2023246936A1 PCT/CN2023/102139 CN2023102139W WO2023246936A1 WO 2023246936 A1 WO2023246936 A1 WO 2023246936A1 CN 2023102139 W CN2023102139 W CN 2023102139W WO 2023246936 A1 WO2023246936 A1 WO 2023246936A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- frame
- type
- frames
- gop sequence
- sampling ratio
- Prior art date
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 14
- 238000000034 method Methods 0.000 claims abstract description 54
- 102100037812 Medium-wave-sensitive opsin 1 Human genes 0.000 claims abstract 105
- 238000005070 sampling Methods 0.000 claims description 454
- 238000000605 extraction Methods 0.000 claims description 92
- 239000000284 extract Substances 0.000 claims description 70
- 230000005540 biological transmission Effects 0.000 description 13
- 238000010586 diagram Methods 0.000 description 13
- 230000008569 process Effects 0.000 description 5
- 230000008859 change Effects 0.000 description 3
- 230000000717 retained effect Effects 0.000 description 3
- 230000006835 compression Effects 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000007774 longterm Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000013139 quantization Methods 0.000 description 1
- 238000010187 selection method Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods 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/103—Selection of coding mode or of prediction mode
- H04N19/109—Selection of coding mode or of prediction mode among a plurality of temporal predictive coding modes
Definitions
- the present application relates to the field of video coding and decoding, and in particular, to an image processing method, device and equipment.
- the complete video coding method can include prediction, transformation, quantization, entropy coding, filtering and other processes, and predictive coding can include intra-frame coding and inter-frame coding.
- Inter-frame coding uses the correlation in the video time domain to predict the pixels of the current image using the pixels of adjacent encoded images to achieve the purpose of removing video time domain redundancy.
- Intra-frame coding takes into account the strong spatial correlation between adjacent blocks, uses the surrounding reconstructed pixels as reference pixels to predict the current uncoded block, and only needs to perform subsequent coding processing on the residual value instead of Encoding the original value effectively removes redundancy in the spatial domain and greatly improves compression efficiency.
- I frames are images that use intra-frame coding, that is, they can be independently encoded without referring to other images.
- P frames are images that use inter-frame coding. , that is, you need to refer to other images to complete the encoding, such as relying on the previous image to complete the encoding.
- continuous video frames include frames 1 to 10 in sequence, frame 1 is an I frame, frame 2 to frame 5 are P frames, frame 6 is an I frame, and frame 7 to frame 10 are P frames.
- frame 1 adopts frame Intra-coding
- frame 2 refers to frame 1 to complete inter-frame coding
- frame 3 refers to frame 2 to complete inter-frame coding
- frame 4 refers to frame 3 to complete inter-frame coding
- frame 5 refers to frame 4 to complete inter-frame coding
- frame 6 uses intra-frame coding
- Frame 7 completes interframe coding with reference to frame 6, and so on.
- the present application provides an image processing method.
- the method includes: dividing all P frames in the picture group GOP sequence into at least two types of P frames, and any of the at least two types of P frames cannot be used as reference frames.
- the method includes: dividing all P frames in the GOP sequence into a first type of P frame and a second type of P frame; wherein the first type of P frame cannot be used as Reference frame, the second type P frame can be used as a reference frame of the first type P frame, and the second type P frame can be used as a reference frame of the second type P frame; if it is determined that it is necessary to When the P frame is extracted, the first type of P frame is extracted, or the first type of P frame and the second type of P frame are extracted.
- dividing all P frames in the GOP sequence into first type P frames and second type P frames includes: based on The position sorting relationship divides all P frames in the GOP sequence into first type P frames and second type P frames; wherein, there are M1 first type P frames between two adjacent second type P frames, There are M2 first-type P frames between the I frame of the GOP sequence and the first second-type P frame; where M1 is a positive integer and M2 is a positive integer.
- the most recent P frame of the second type before the P frame of the first type is used as the reference frame of the P frame of the first type.
- the I frame of the GOP sequence is used as the reference frame of the P frame of the first type;
- the nearest second type P frame before the second type P frame is used as the reference frame of the second type P frame.
- the I frame of the GOP sequence is used as the reference frame of the second type P frame.
- Extracting frames of P-type frames includes: if it is determined based on the service information that the first sampling ratio needs to be used to extract P frames in the GOP sequence, then extracting all P-frames of the first type or part of the P-frames of the first type. frames; if it is determined based on the service information that the second sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first type P frames, and extract frames from all second type P frames or part of the second type P-like frames are used to extract frames; or,
- the second sampling proportion is greater than the first sampling proportion
- the third sampling proportion is greater than the second sampling proportion
- the method further includes: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end, based on the resolution, the The frame rate and the decoding capability determine whether frame extraction needs to be performed on the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding of images with the resolution and the frame rate, it is determined that the P frames in the GOP sequence need to be decoded. The P frames in the GOP sequence are extracted; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability; or,
- the service information includes the network quality corresponding to the target network between the sending end and the receiving end, it is determined based on the network quality whether it is necessary to extract the P frames in the GOP sequence; wherein, if the network quality If the network quality is not the optimal level, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality;
- the sampling ratio is the first sampling ratio or the second sampling ratio; or,
- the sampling ratio is a first sampling ratio, a second sampling ratio, or a third sampling ratio.
- the method includes: dividing all P frames in the GOP sequence into a first type of P frame, a second type of P frame and a third type of P frame; wherein, the first type of P frame
- the P frame of the second type cannot be used as a reference frame
- the P frame of the second type can only be used as the reference frame of the P frame of the first type
- the P frame of the third type can be used as the reference frame of the P frame of the first type
- the reference frame of the second type of P frame and can be used as the reference frame of the third type of P frame; if it is determined that the P frame in the GOP sequence needs to be extracted, then the first type of P frame is extracted, or , perform frame extraction on the first type P frame and the second type P frame, or perform frame extraction on the first type P frame, the second type P frame and the third type P frame. .
- dividing all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames includes: based on The positional sorting relationship between each P frame divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame; wherein, two adjacent third type P frames There are two P frames of the first type and one P frame of the second type between frames, and the P frame of the second type is located between the two P frames of the first type; the I frame of the GOP sequence and the P frame of the second type There are two first-type P frames and one second-type P frame between a third-type P frame, and the second-type P frame is located between the two first-type P frames.
- the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is regarded as the first type P frame.
- reference frame if the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame will be used as the reference frame of the first type P frame;
- second type P frame P frame if there is a third type P frame before the second type P frame, then the latest third type P frame before the second type P frame is used as the reference frame of the second type P frame, if the second type P frame If there is no P frame of the third type before the P frame, then the I frame of the GOP sequence is used as the reference frame of the P frame of the second type; for each P frame of the third type, if there is a P frame of the third type before the P frame of the third type.
- the latest type three P frame before the third type P frame will be used as the reference frame of the third type P frame. If there is no third type P frame before the third type P frame, then the third type P frame will be used as the reference frame.
- the I frame of the GOP sequence serves as the reference frame of the third type of P frame.
- Performing frame extraction on type P frames, or performing frame extraction on the first type P frame, the second type P frame and the third type P frame including:
- the first sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first-type P frames or part of the first-type P frames;
- the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames will be extracted, and all the second type P frames or part of the second type P frames will be extracted.
- the frame is extracted; wherein the second sampling ratio is greater than the first sampling ratio;
- the third sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all P frames of the first type, extract frames from all P frames of the second type, and extract frames from all P frames of the second type.
- the third type P frame or part of the third type P frame is extracted; the third sampling ratio is greater than the second sampling ratio.
- the method further includes: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end, determining based on the resolution, the frame rate, and the decoding capability. Whether it is necessary to extract frames from P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and frame rate, it is determined to extract frames from the P frames in the GOP sequence.
- the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability, and the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio proportion; or, if the service information includes the network quality corresponding to the target network between the sending end and the receiving end, determine whether it is necessary to extract frames from the P frames in the GOP sequence based on the network quality; wherein, if If the network quality is not the optimal level, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, and the sampling ratio is The first sampling proportion, or the second sampling proportion, or the third sampling proportion.
- the method further includes: when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the first GOP sequence of the image sequence set, then replace the first GOP sequence with The I frame serves as the reference frame for the first frame of the GOP sequence.
- the present application provides an image processing device.
- the device includes: a dividing module, configured to divide all P frames in a GOP sequence into at least two types of P frames. There are inaccuracies in the at least two types of P frames.
- a P frame as a reference frame, and there is a P frame that can be used as a reference frame among the at least two types of P frames;
- a processing module configured to extract frames from the P frame in the GOP sequence if it is determined that the P frame needs to be extracted.
- the P frames that cannot be used as reference frames are extracted, or if it is determined that the P frames in the GOP sequence need to be extracted, the P frames that cannot be used as reference frames and the P frames that can be used as reference frames are extracted. frame.
- the dividing module is specifically configured to divide all P frames in the GOP sequence into first type P frames and second type P frames; wherein the first type P frame cannot As a reference frame, the second type P frame can be used as a reference frame of the first type P frame, and the second type P frame can be used as a reference frame of the second type P frame; the processing module is specifically used if If it is determined that the P frames in the GOP sequence need to be extracted, the first type of P frames may be extracted, or the first type of P frames and the second type of P frames may be extracted.
- the dividing module divides all P frames in the GOP sequence into first type P frames and second type P frames, it is specifically used to: based on the position ordering relationship between the P frames in the GOP sequence, All P frames within the GOP sequence are divided into first type P frames and second type P frames; where two adjacent There are M1 P frames of the first type between the P frames of the second type, and M2 P frames of the first type between the I frame of the GOP sequence and the first P frame of the second type; M1 and M2 are both positive integer.
- the nearest second type P frame before the first type P frame is used as the first type P frame.
- Reference frame if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type; for each P frame of the second type, if the P frame of the second type If there is a P frame of the second type before the P frame of the second type, the most recent P frame of the second type before the P frame of the second type is used as the reference frame of the P frame of the second type. If there is no P frame of the second type before the P frame of the second type. If the frame is a type P frame, the I frame of the GOP sequence is used as the reference frame of the second type P frame.
- the processing module determines that it is necessary to extract frames from P frames in the GOP sequence, then extract frames from the first type of P frames, or extract frames from the first type of P frames and the second type of P frames.
- P frames it is specifically used: if it is determined based on the service information that the first sampling ratio needs to be used to extract P frames in the GOP sequence, then extract all P frames of the first type or part of the P frames of the first type. Frame extraction; if it is determined based on the service information that the second sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first type P frames, and extract frames from all second type P frames or part of the first type P frames.
- the second type P frames are extracted; or, if it is determined based on the service information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then some first type P frames are extracted; if based on the service information, If it is determined that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames need to be extracted; if it is determined based on the service information that the third sampling ratio needs to be used to extract the P frames in the GOP sequence
- To extract frames from P frames extract frames from all P frames of the first type, and extract frames from all P frames of the second type or part of P frames of the second type; wherein, the second sampling ratio is greater than the first sampling ratio, and the second sampling ratio is larger than the first sampling ratio.
- the third sampling proportion is greater than the second sampling proportion.
- the processing module is also configured to: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence and the decoding capability corresponding to the decoding end, based on the resolution, the frame rate and the decoding capability
- the decoding capability determines whether it is necessary to extract frames from the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and frame rate, it is determined that the P frames in the GOP sequence need to be extracted.
- the P frame is extracted; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability; or, if the service information includes the communication between the sending end and the receiving end.
- the network quality corresponding to the target network it is determined based on the network quality whether it is necessary to extract frames from the P frames in the GOP sequence; wherein, if the network quality is not the optimal level of network quality, it is determined whether the P frames in the GOP sequence need to be extracted.
- the P frames in the sequence are extracted; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality; the sampling ratio is the first sampling ratio or the second sampling ratio; or, the sampling ratio is The first sampling proportion, or the second sampling proportion, or the third sampling proportion.
- the dividing module is specifically used to divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames;
- the first type P frame cannot be used as Reference frame
- the second type of P frame can only be used as a reference frame of the first type of P frame
- the third type of P frame can be used as a reference frame of the first type of P frame
- the processing module is specifically configured to extract frames for the first type of P frame if it is determined that the P frame in the GOP sequence needs to be extracted, Alternatively, perform frame extraction on the first type P frame and the second type P frame, or perform extraction on the first type P frame, the second type P frame and the third type P frame. frame.
- the dividing module divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame, it is specifically used: based on the position between each P frame in the GOP sequence.
- the sorting relationship divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame; wherein, for all P frames in the said GOP sequence, two adjacent There are two P frames of the first type and one P frame of the second type between the P frames of the third type, and the P frame of the second type is located between the two P frames of the first type; the GOP sequence There are two first-type P frames and one second-type P frame between the I frame and the first third-type P frame, and the second-type P frame is located between the two first-type P frames.
- the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is used as the reference of the first type P frame.
- frame if the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame is used as the reference frame of the first type P frame;
- second type P frame if there is a P frame of the third type before the P frame of the second type, then the most recent P frame of the third type before the P frame of the second type is used as the reference frame of the P frame of the second type, if the P frame of the second type If there is no P frame of the third type in front, the I frame of the GOP sequence is used as the reference frame of the P frame of the second type; for each P frame of the third type, if there is a P frame of the third type in front of the P frame of the third type, P frame, then the latest P frame of the third type preceding the P frame of the third type is
- the processing module determines that it is necessary to extract frames from P frames in the GOP sequence, then extract frames from the first type of P frames, or extract frames from the first type of P frames and the second type of P frames.
- Performing frame extraction on P frames, or performing frame extraction on the first type P frame, the second type P frame and the third type P frame is specifically used for: if it is determined based on the service information that it is necessary to use the first sampling If the proportion of P frames in the GOP sequence is used to extract frames, all first-type P frames or part of the first-type P frames are extracted; if it is determined based on the service information that a second sampling ratio needs to be used to extract P frames in the GOP sequence.
- the second sampling ratio is greater than the first sampling ratio; if it is determined based on the business information, Using the third sampling ratio to extract frames from P frames in the GOP sequence, all P frames of the first type are extracted, all P frames of the second type are extracted, and all P frames of the third type or part of the P frames are extracted. Three types of P frames are used for frame extraction; the third sampling ratio is greater than the second sampling ratio.
- the processing module is also configured to: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence and the decoding capability corresponding to the decoding end, based on the resolution, the frame rate and the decoding capability
- the decoding capability determines whether it is necessary to perform frame extraction on the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and frame rate, it is determined whether the P frames in the GOP sequence need to be decoded.
- the P frame is extracted; if so, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability, and the sampling ratio is the first sampling ratio, or the second sampling ratio, Or the third sampling ratio; or, if the service information includes the network quality corresponding to the target network between the encoding end and the decoding end, determine whether the P frame in the GOP sequence needs to be extracted based on the network quality. ; Wherein, if the network quality is not the optimal level of network quality, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, so The above-mentioned sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio.
- the dividing module is also used to divide the first GOP sequence into The I frame serves as the reference frame for the first frame of the GOP sequence.
- the present application provides an image processing device, including: a processor and a machine-readable storage medium.
- the machine-readable storage medium stores machine-executable instructions that can be executed by the processor; the processor is configured to execute machine-executable instructions. Execute instructions to implement the image processing method disclosed in the above embodiments of this application.
- all P frames in the GOP (Group of Pictures) sequence can be divided into P frames that cannot be used as reference frames and P frames that can be used as reference frames.
- the P frames that cannot be used as reference frames can be extracted, or the P frames that cannot be used as reference frames and the P frames that can be used as reference frames can be extracted.
- the above method provides a new type of video frame sequence.
- the video frame sequence includes different types of P frames.
- frames can be dropped according to certain rules, which can not only ensure that the video frame sequence is played in order, but also has the ability to interleave according to the rules.
- This video frame sequence has better prospects for use in decoding, network transmission, and storage, and realizes decoding Features include doubled channel number, low-bandwidth transmission, and low bit rate storage.
- FIG. 1A and Figure 1B are schematic diagrams of the GOP sequence
- FIG. 2 is a schematic flowchart of an image processing method in an embodiment of the present application.
- FIG. 3A and Figure 3B are schematic diagrams of the GOP sequence
- Figures 4A-4C are schematic diagrams of extracting frames from P frames in a GOP sequence
- Figures 5A-5E are schematic diagrams of images displayed through multiple channels
- Figure 6 is a schematic diagram of an image sequence collection
- FIG. 7 is a schematic flowchart of an image processing method in an embodiment of the present application.
- FIGS 8A and 8B are schematic diagrams of the GOP sequence
- Figures 9A-9C are schematic diagrams of extracting frames from P frames in a GOP sequence
- Figure 10 is a schematic diagram of an image sequence collection
- Figure 11 is a schematic structural diagram of an image processing device in an embodiment of the present application.
- Figure 12 is a hardware structure diagram of an image processing device in an embodiment of the present application.
- I frames are images that use intra-frame coding, that is, they can be encoded independently without referring to other images.
- P frames use inter-frame coding. The image needs to refer to other images to complete the encoding, such as relying on the previous image to complete the encoding.
- Video coding is a compression technology developed for image storage. It can compress images into smaller code streams and store the code streams on the hard disk. When the video needs to be played, the code stream is re-decoded into images and the images are displayed.
- the encoding methods include H.264, H.265, etc.
- Video decoding is a technology that re-decodes a code stream into an image. After the code stream (such as a code stream stored on a hard disk or transmitted from a network) is decoded into an image, the image can be displayed for video playback.
- code stream such as a code stream stored on a hard disk or transmitted from a network
- the I frame and all P frames between the I frame and the next I frame can be composed into a GOP sequence, that is, the first frame of the GOP sequence is an I frame, and the GOP sequence has only one I frame.
- the I frame of the GOP sequence may be followed by a P frame.
- continuous video frames include frames 1 to 10 in sequence, frame 1 is an I frame, frame 2 to frame 5 are P frames, frame 6 is an I frame, and frame 7 to frame 10 are P frames.
- GOP sequence 1 includes Frame 1 to frame 5
- GOP sequence 2 includes frame 6 to frame 10.
- FIG. 1A which shows GOP sequence 1 and GOP sequence 2
- each GOP sequence may include one I frame and multiple P frames.
- each P frame in the GOP sequence needs to refer to the previous frame.
- frame 2 refers to frame 1 to complete inter-frame coding
- frame 3 refers to frame 2 to complete inter-frame coding
- Frame 4 refers to frame 3 to complete interframe coding
- frame 5 refers to frame 4 to complete interframe coding.
- all P frames cannot be discarded.
- Once a P frame is discarded, subsequent P frames will not be processed correctly. For example, as shown in Figure 1B, if frame 3 is discarded, frame 4 will not be able to complete inter-frame coding with reference to frame 3, and frame 5 will not be able to complete inter-frame coding with reference to frame 4.
- the video frame sequence may include different types of P frames, such as P frames that cannot be used as reference frames and P frames that can be used as reference frames.
- the video frame sequence can be dropped according to certain rules, which not only ensures that the video frame sequence is played in order, but does not affect viewing even if P frames are discarded, it is also possible to save bandwidth by discarding some P frames.
- the new video frame sequence in the embodiment of the present application can divide all P frames in the GOP sequence into at least two types of P frames. There are inaccuracies in at least two types of P frames. P frames that serve as reference frames, and there are P frames that can serve as reference frames among at least two types of P frames.
- the P frame that cannot be used as a reference frame will be extracted, or if it is determined that the P frame within the GOP sequence needs to be extracted, , then the P frames that cannot be used as reference frames and the P frames that can be used as reference frames are extracted.
- the embodiment of the present application proposes an image processing method, which can be applied to any device. See Figure 2, which is a schematic flowchart of the image processing method.
- the method may include:
- Step 201 Divide all P frames in the GOP sequence into first type P frames and second type P frames; for example, the first type P frame cannot be used as a reference frame, and the second type P frame can be used as the second type P frame.
- a reference frame of a type of P frame, and the second type of P frame can also be used as a reference frame of a second type of P frame.
- the GOP sequence may include an I frame and multiple P frames.
- all P frames within the GOP sequence may be distinguished into two types of P frames. These two types of P frames can be called first type P frames and second type P frames respectively.
- the first type of P frame can also be called a normal P frame, and the first type of P frame cannot be used as a reference frame for other frames.
- the P frame of the first type can use other frames as reference frames of the P frame of the first type.
- the P frame of the first type can use the P frame of the second type as a reference frame.
- the P frame of the first type can also use the P frame of the GOP sequence as a reference frame. I frames serve as reference frames.
- a first-type P frame cannot use other first-type P frames as reference frames.
- the second type of P frame can also be called a referenced P frame (that is, the second type of P frame can be used as a reference frame).
- the second type of P frame can be used as a reference frame of the first type of P frame.
- the second type of P frame can also be called a reference frame.
- the second type of P frame can use other frames as reference frames of the second type of P frame.
- the second type of P frame can use other second type of P frames as reference frames.
- the second type of P frame can also use the GOP sequence.
- the I frame is used as the reference frame.
- the P frame of the second type cannot use the P frame of the first type as a reference frame.
- any division method can be used, and there is no limit to this division method, as long as both The first type of P frame and the second type of P frame are enough.
- all P frames in the GOP sequence can be divided into first type P frames and second type P frames based on the position ordering relationship between the P frames in the GOP sequence, that is, the division method is based on the position ordering relationship.
- the positional sorting relationship refers to which P frame within the GOP sequence the P frame is, such as the first P frame, the second P frame, etc., which is used to indicate which position in the GOP sequence it is in.
- the first P frame is a P frame of the first type
- the second P frame is a P frame of the second type
- the third P frame is a P frame of the first type
- the fourth P frame is a P frame of the second type.
- the first P frame and the second P frame are P frames of the first type
- the third P frame and the fourth P frame are P frames of the second type, and so on.
- the first P frame and the second P frame are the first type of P frames
- the third P frame is the second type of P frame, and so on.
- the first P frame, the second P frame and the third P frame are the first type of P frames
- the fourth P frame is the second type of P frame, and so on.
- the first P frame is a P frame of the first type
- the second P frame and the third P frame are P frames of the second type, and so on.
- the above division methods are just examples.
- the number of first type P frames and the number of second type P frames may be the same, and the number of first type P frames may be the same as the number of second type P frames.
- the number of P-frames of the second type can also be different.
- the number of P frames of the first type may be greater than the number of P frames of the second type, and the number of P frames of the first type may also be smaller than the number of P frames of the second type.
- the number of frames for example, in the following example, the number of P frames of the first type is greater than the number of P frames of the second type.
- first type P frames when all P frames are divided into first type P frames and second type P frames, at least two first type P frames may appear continuously, but two second type P frames will not appear continuously.
- first type of P frame can be the first type of P frame or the second type of P frame
- second type of P frame can be the first type of P frame, but what follows the second type of P frame will not It is the second type of P frame.
- the I frame of the GOP sequence may be followed by the P frame of the first type
- the I frame of the GOP sequence may be followed by the P frame of the second type
- the first P frame after the I frame in the GOP sequence is the first type of P frame.
- M1 when all P frames in the GOP sequence are divided into first type P frames and second type P frames, there are M1 first type P frames between two adjacent second type P frames.
- P frame there are M2 first type P frames between the I frame (i.e. the first frame) of the GOP sequence and the first second type P frame
- M1 is a positive integer
- M2 is a positive integer
- both M1 and M2 can be based on Experience configuration
- M1 and M2 can be the same or different.
- M1 when there are M1 first-category P frames between two adjacent second-category P frames, M1 can change.
- first second-category P frame and the second second-category P frame there are 3 P frames of the first type between, there are 4 P frames of the first type between the second P frame of the second type and the third P frame of the second type, and there are 4 P frames of the first type between the third P frame of the second type and the fourth P frame of the second type. There are three P frames of the first type between the P frames of the second type, and so on.
- two adjacent P frames of the second type need to include P frames of the first type.
- the number of P frames of the first type can be maintained at a fixed number.
- the number of P frames of the first type is more than 1, but , in order to prevent poor image quality, the number of first type P frames cannot be too many.
- three P frames of the first type are included between two adjacent P frames of the second type as an example, and the I frame of the GOP sequence and the first P frame of the second type are There are 3 type 1 P frames in between.
- two adjacent second-category P frames can include four first-category P frames, or two adjacent second-category P frames.
- two P frames of the first type may be included between P frames.
- the first frame after the I frame is a first type P frame, and there are 3 frames between the I frame and the first second type P frame.
- the frames in the GOP sequence are: I frame, first type P frame, first type P frame, first type P frame, second type P frame, first type P frame, first type Class P frames, first class P frames, second class P frames, and so on.
- the second type of P frame can be used as the reference frame of the first type of P frame, and the second type of P frame can be used as the second type of P frame.
- "reference frame” characteristics then: for each first-type P frame, if there is a second-type P frame before the first-type P frame frame, then the nearest P frame of the second type preceding the P frame of the first type is used as the reference frame of the P frame of the first type. If there is no P frame of the second type before the P frame of the first type, the P frame of the GOP sequence is The I frame serves as the reference frame of the first type P frame.
- the nearest second type P frame before the second type P frame is used as the reference frame of the second type P frame.
- the I frame of the GOP sequence is used as the reference frame of the second type P frame.
- the reference frame of the first type first P frame is the previous I frame
- the reference frame of the second type first P frame is the previous I frame
- the reference frame of the third type first P frame is the previous I frame.
- the reference frame of the frame is the previous I frame
- the reference frame of the 4th type 1 P frame is the previous type 2 P frame
- the reference frame of the 5th type 1 P frame is the previous type 2 P frame.
- the reference frame of the sixth type-1 P frame is the previous type-2 P frame, and so on.
- the reference frame of the first type II P frame is the previous I frame
- the reference frame of the second type II P frame is the previous type II P frame
- the reference frame of the third type II P frame is the previous type II P frame.
- the reference frame of a Type II P frame is the previous Type II P frame, and so on.
- Step 202 If it is determined that the P frames in the GOP sequence need to be extracted, then extract the first type of P frames, or extract the first type of P frames and the second type of P frames. For example, extracting a P frame means not processing the P frame. For example, when the encoding end extracts the P frame, it means that the P frame is not encoded. When the decoding end extracts the P frame, it means that the P frame is not processed. This P frame is not decoded.
- all the first type P frames or part of the first type P frames can be extracted; or, all the first type P frames can be extracted.
- the P-type frames are extracted, and all the P-frames of the second type or part of the P-frames of the second type are extracted.
- multiple sampling ratios can be divided, and the sampling ratio is used to indicate how many P frames to extract. For example, when the sampling ratio is x, Indicates that x in all P frames is sampled, and different sampling ratios represent different sampling methods.
- two sampling proportions can be divided. These two sampling proportions are recorded as the first sampling proportion and the second sampling proportion, and the first sampling proportion is smaller than the second sampling proportion.
- frame extraction can be performed on all P frames of the first type or part of the P frames of the first type; for the second sampling ratio, frames can be extracted on all P frames of the first type, and on all P frames of the second type The frame or part of the second type P frame is extracted.
- three sampling proportions can be divided. These three sampling proportions are recorded as the first sampling proportion, the second sampling proportion and the third sampling proportion. The first sampling proportion is smaller than the second sampling proportion, and the second sampling proportion is smaller than the third sampling proportion. Proportion. For the first sampling ratio, some P frames of the first type can be extracted; for the second sampling ratio, all P frames of the first type can be extracted; for the third sampling ratio, all P frames of the first type can be extracted Perform frame extraction, and perform frame extraction on all Type II P frames or part of Type II P frames.
- 4 sampling proportions can be divided, recorded as the first sampling proportion, the second sampling proportion, the third sampling proportion and the fourth sampling proportion.
- the first sampling proportion is smaller than the second sampling proportion
- the second sampling proportion is smaller than the third sampling proportion.
- Proportion, the third sampling proportion is smaller than the fourth sampling proportion.
- frame extraction is performed on some P frames of the first type
- for the second sampling ratio frames are extracted on all P frames of the first type
- for the third sampling ratio frames are extracted on all P frames of the first type , extract frames for some P-frames of the second type
- for the fourth sampling ratio extract frames for all P-frames of the first type, and extract frames for all P-frames of the second type.
- sampling proportions there is no limit to this. Any number of sampling proportions can be divided.
- the following explanation will be based on dividing 2 or 3 sampling proportions as an example.
- the second sampling ratio and the third sampling ratio if it is necessary to use the first sampling ratio to extract the P frames in the GOP sequence, then some of the first type P frames Perform frame extraction; if it is necessary to use the second sampling ratio to extract frames from P frames in the GOP sequence, then extract frames from all first-type P frames; if it is necessary to use the third sampling ratio to extract P frames within the GOP sequence frames, then extract frames for all P-frames of the first type, and extract frames for all P-frames of the second type or part of the P-frames of the second type.
- the first sampling ratio is less than x1
- the second sampling proportion is less than or equal to x1.
- the third sampling proportion is less than or equal to x1+x2.
- x1 is 0.75 and x2 is 0.25.
- the sampling proportion is less than or equal to 0.5, it can be determined that the sampling proportion is the first sampling proportion.
- sampling proportion is greater than 0.5, and less than or If equal to 0.75, it can be determined that the sampling proportion is the second sampling proportion. If the sampling proportion is greater than 0.75 and less than or equal to 1, it can be determined that the sampling proportion is the third sampling proportion.
- the second sampling ratio needs to be used to extract the P frames in the GOP sequence. In this case, the second sampling ratio is less than or equal to 0.75 , and greater than 0.5.
- the third sampling ratio is less than or equal to 1 and greater than 0.75.
- a GOP sequence can achieve 1/2 frame extraction.
- a The GOP sequence can achieve 3/4 frame extraction.
- a GOP sequence can achieve complete frame extraction.
- the first sampling ratio is less than or equal to x1
- the second sampling proportion is less than or equal to x1+x2.
- x1 is 0.75
- x2 is 0.25.
- the sampling proportion is determined to be the first sampling proportion. If the sampling proportion is greater than 0.75 and less than or equal to 1, then the sampling proportion is determined to be the second sampling proportion.
- the first sampling ratio needs to be used to extract the P frames in the GOP sequence
- all the first type P frames can be extracted. In this case, the first sampling ratio is less than or equal to 0.75.
- the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames can be extracted, and all the second type P frames can be extracted, In this case, the second sampling ratio is less than or equal to 1 and greater than 0.75.
- a GOP sequence can achieve 3/4 frame extraction.
- a GOP sequence can achieve complete frame extraction.
- the sampling proportion corresponding to the GOP sequence can be determined based on the business information.
- the sampling proportion corresponding to the GOP sequence can be determined based on the business information.
- a sampling ratio is used to extract frames from the P frames in the GOP sequence, or a second sampling ratio is determined based on the service information to extract frames from the P frames in the GOP sequence, or a third sampling ratio is determined based on the service information to extract the frames from the GOP sequence. The P frames within are extracted.
- the service requirements corresponding to the service information can be met. For example, if 50% of the P frames in the GOP sequence are extracted to meet the service requirements, then the first sampling ratio is determined based on the service information. Sampling proportion. If the first sampling ratio cannot meet the business requirements, but the second sampling ratio is used to extract P frames within the GOP sequence, the business requirements corresponding to the service information can be met. That is, extracting 75% of the P frames from the GOP sequence can meet the requirements. For business needs, the second sampling ratio is determined based on business information. If the first sampling ratio cannot meet the business needs, and the second sampling ratio cannot meet the business needs, the third sampling ratio will be determined based on the business information.
- the service information may include the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoder. Based on the resolution, the frame rate, and the decoding capability, it is determined whether it is necessary to modify the P in the GOP sequence. Frame is extracted. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability. For example, the sampling ratio corresponding to the GOP sequence may be the first sampling ratio, the second sampling ratio, or the third sampling ratio. Alternatively, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability, such as the first sampling ratio or the second sampling ratio.
- the NVR device has a decoding capability of 4*1080P30, that is, the NVR device can decode 4*30 frames of 1920*1080 images in one second. Images exceeding this decoding capability cannot be decoded.
- the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel to meet business needs.
- the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel of image is extracted according to the first sampling ratio (that is, 1/2 frame extraction method).
- the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel image is extracted according to the second sampling ratio (ie, 3/4 frame extraction method).
- the second sampling ratio ie, 3/4 frame extraction method.
- the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel of image is extracted according to the third sampling ratio (i.e. 4/4 frame extraction method).
- the third sampling ratio i.e. 4/4 frame extraction method.
- the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
- frames can be extracted according to the first sampling ratio, the second sampling ratio, or the third sampling ratio to meet business needs.
- the service information may include the network quality corresponding to the target network between the sending end and the receiving end. Based on the network quality, it is determined whether the P frames in the GOP sequence need to be extracted. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality. For example, the sampling ratio corresponding to the GOP sequence may be the first sampling ratio, the second sampling ratio, or the third sampling ratio. Alternatively, the sampling ratio corresponding to the GOP sequence is determined based on the network quality. The sampling ratio corresponding to the GOP sequence may be the first sampling ratio or the second sampling ratio.
- four levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (ie, the optimal level), it is determined not to extract the P frames in the GOP sequence. frame. If the network quality corresponding to the target network is level 2 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio, such as 1/2 frame extraction. If the network quality corresponding to the target network is level 3 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the second sampling ratio, such as 3/4 frame extraction. If the network quality corresponding to the target network is the network quality of level 4 (i.e., the worst level), it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the third sampling ratio, such as 4/4 frame extraction. Way.
- the network quality corresponding to the target network is the network quality of the first level (ie, the optimal level)
- the sampling ratio is the first sampling ratio, such as 1/2 frame extraction.
- two levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (i.e., the optimal level), it is determined that the P frames in the GOP sequence are not to be processed. Frame extraction. If the network quality corresponding to the target network is the second level network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio. During the transmission process of the GOP sequence, if the network quality is still If the network quality is Level 2, the sampling ratio will be adjusted to the second sampling ratio. During the transmission process of the GOP sequence, if the network quality is still Level 2, the sampling ratio will be adjusted to the third sampling ratio. In addition, during the transmission process of the GOP sequence, if the network quality returns to the first level of network quality, the P frames in the GOP sequence will not be extracted.
- the sampling ratio corresponding to the GOP sequence is determined based on the size of each frame. If the frame size is less than the first threshold, the P frames in the GOP sequence will not be sampled. The frame size is greater than the first threshold and less than the second threshold. limit, the sampling ratio is the first sampling ratio. When the frame size is greater than the second threshold and less than the third threshold, the sampling ratio is the second sampling ratio. When the frame size is greater than the third threshold, the sampling ratio is Third sampling ratio.
- At least two GOP sequences can also be composed into an image sequence set. Based on this, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the The first GOP sequence of the image sequence set, then the I frame of the first GOP sequence can be used as the reference frame of the first frame of the GOP sequence. In this embodiment, if the GOP sequence is not the first GOP sequence in the image sequence set, the first frame of the GOP sequence can be called a key P frame (that is, it is no longer called an I frame), and the reference frame of the key P frame is the most recent I frame.
- the image sequence set may include at least one key P frame, that is, at least one key P frame is allowed to exist.
- the key P frame is used to replace the position of the I frame.
- the key P frame can only refer to the I frame. Its frame structure is the closest preceding I frame, and the key P frame can effectively reduce the overall bandwidth.
- the image sequence set may include key P frames. Between the I frame and the key P frame, there may be a first type of P frame and a second type of P frame. For the structural relationship between the first type of P frame and the second type of P frame, please refer to the above embodiment. Between two adjacent key P frames, there may be a first type of P frame and a second type of P frame. For the structural relationship between the first type of P frame and the second type of P frame, please refer to the above embodiment. On this basis, when extracting P frames, frames of the first type of P frames can be extracted, and frames of the second type of P frames can be extracted, but frames of key P frames cannot be extracted.
- all P frames in the GOP sequence can be divided into first type P frames and second type P frames.
- the first type P frame cannot be used as a reference frame
- the second type P frame cannot be used as a reference frame.
- the frame can be used as the reference frame of the first type of P frame
- the second type of P frame can also be used as the reference frame of the second type of P frame.
- the first type of P frame can be extracted, or the first type of P frame can be extracted.
- Class P frames and second class P frames are extracted.
- the above method provides a new type of video frame sequence.
- the video frame sequence includes different types of P frames, namely the first type of P frame and the second type of P frame.
- frames can be dropped according to certain rules, which can It ensures that the video frame sequence is played in order, and has the characteristics of discarding P frames according to the rules without affecting viewing. It can also discard some P frames in some special scenarios to achieve the purpose of saving bandwidth.
- This video frame sequence is used in decoding and network It has better application prospects in transmission and storage, realizing features such as multiplied decoding channels, low-bandwidth transmission, and low bit rate storage. It can also solve problems such as long-term black screens and blurred screens after frame loss in weak network environments.
- the frame loss strategy can be dynamically implemented and arbitrarily adjusted according to on-site conditions, flexibly and effectively reducing consumption without affecting decoding integrity.
- This video frame sequence can ensure the flexibility of frame extraction and the stability of image quality, and can effectively improve customer experience.
- Certain rules of frame dropping can be performed during the decoding process to achieve decoding of 1/2 frame, 3/4 frame, etc. Or, realize low-bandwidth transmission of 1/2 frame and 3/4 frame in network transmission.
- This frame loss strategy can be dynamically implemented and the strategy can be adjusted arbitrarily according to the on-site situation. It is flexible and effective without affecting the decoding integrity. reduce consumption.
- the embodiment of the present application proposes an image processing method, which can be applied to any device. See Figure 7, which is a schematic flow chart of the image processing method.
- the method may include:
- Step 701 Divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; for example, the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame.
- the P frame of the first type can only be used as a reference frame of the P frame of the first type.
- the P frame of the third type can be used as the reference frame of the P frame of the first type, and can be used as the reference frame of the P frame of the second type, and can be used as the reference frame of the P frame of the third type.
- the reference frame of the P frame is dividing all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; for example, the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame.
- the P frame of the first type can only be used as a reference frame of the P frame of the first type.
- the P frame of the third type can be used as the reference
- the GOP sequence may include an I frame and multiple P frames.
- all P frames within the GOP sequence may be distinguished into three types of P frames. These three types of P frames are called first type P frames, second type P frames and third type P frames.
- the first type of P frame can also be called a normal P frame, and the first type of P frame cannot be used as a reference frame for other frames.
- the first type P frame can use other frames as reference frames of the first type P frame.
- the first type P frame can use the second type P frame as a reference frame, and the first type P frame can use the third type P frame as a reference frame.
- frame as a reference frame the first type of P frame can also use the I frame of the GOP sequence as a reference frame.
- the first type P frame cannot use the first type P frame (that is, other first type P frames except the first type P frame) as a reference frame.
- the second type of P frame can also be called 2X type P frame.
- the second type of P frame can only be used as a reference frame of the first type of P frame, but cannot be used as a reference frame of the second type of P frame, nor can it be used as a reference frame of the third type of P frame. Reference frame for P-like frames.
- the second type of P frame can use other frames as reference frames of the second type of P frame.
- the second type of P frame can use the third type of P frame as a reference frame.
- the second type of P frame can also use the reference frame of the GOP sequence. I frames serve as reference frames.
- the second type of P frame cannot use the second type of P frame (that is, other second type of P frame except the second type of P frame) as a reference frame, and the second type of P frame cannot use the first type of P frame as a reference frame. frame as a reference frame.
- the third type of P frame can also be called a 4X type P frame.
- the third type of P frame can be used as a reference frame of the first type of P frame, and can be used as a reference frame of the second type of P frame, and can be used as a reference frame of the third type of P frame.
- the third type P frame can use other frames as reference frames of the third type P frame.
- the third type P frame can use the third type P frame (that is, other third type P frames except the third type P frame).
- Class P frame) as a reference frame
- the third class P frame can also use the I frame of the GOP sequence as a reference frame.
- the third type P frame cannot use the second type P frame as a reference frame
- the third type P frame cannot use the first type P frame as a reference frame.
- any division method can be used.
- the division method there is no restriction on the division method, as long as the first type of P frame, the second type of P frame and the third type of P frame can exist at the same time.
- all P frames in the GOP sequence can be divided into first type P frames, second type P frames and third type P frames based on the position ordering relationship between each P frame in the GOP sequence, that is, divided The method is based on the position ordering relationship.
- the position ordering relationship refers to which P frame within the GOP sequence the P frame is, such as the first P frame, the second P frame, the third P frame, etc., which is used to indicate which position in the GOP sequence it is in.
- the first P frame is a P frame of the first type
- the second P frame is a P frame of the second type
- the third P frame is a P frame of the third type
- the fourth P frame is a P frame of the first type.
- the fifth P frame is the second type of P frame
- the sixth P frame is the third type of P frame, and so on.
- the first P frame and the second P frame are P frames of the first type
- the third P frame and the fourth P frame are P frames of the second type
- the fifth P frame and the sixth P frame are The third type of P frame, and so on.
- the first P frame is a P frame of the first type
- the second P frame is a P frame of the second type
- the third P frame is a P frame of the first type
- the fourth P frame is a P frame of the third type.
- the fifth P frame is the first type of P frame
- the sixth P frame is the second type of P frame, and so on.
- the first P frame and the second P frame are the first type P frames
- the third P frame is the second type P frame
- the fourth P frame is the third type P frame
- the fifth P frame and The sixth P frame is the first type of P frame, and so on.
- the above divisions are just a few examples.
- the number of the first type of P frames and the number of the second type of P frames may be the same.
- the number of P-type frames may be different from the number of P-frames of the second type.
- the number of P frames of the first type and the number of P frames of the third type may be the same, and the number of P frames of the first type and the number of P frames of the third type may be different.
- the number of P frames of the second type and the number of P frames of the third type may be the same, and the number of P frames of the second type and the number of P frames of the third type may be different.
- the number of P frames of the first type may be greater than the number of P frames of the second type, and the number of P frames of the first type may be less than the number of P frames of the second type.
- the number of P frames of the first type may be greater than the number of P frames of the third type, and the number of P frames of the first type may be less than the number of P frames of the third type.
- the number of P frames of the second type may be greater than the number of P frames of the third type, and the number of P frames of the second type may be less than the number of P frames of the third type.
- the number of P frames of the first type is greater than the number of P frames of the second type
- the number of P frames of the first type is greater than the number of P frames of the third type
- the number of P frames of the second type is equal to the number of P frames of the third type. quantity.
- the number of P frames of the second type is equal to the number of P frames of the third type
- the number of P frames of the first type is greater than or equal to the number of P frames of the second type and the number of P frames of the third type. The sum of the number of P frames of the three types.
- the first type of P frames, the second type of P frames and the third type of P frames may appear alternately.
- two P frames of the first type will not appear continuously
- two P frames of the second type will not appear continuously
- two P frames of the third type will not appear continuously.
- the P frame of the first type may be followed by the P frame of the second type or the P frame of the third type, but it will not be the P frame of the first type.
- the P frame after the second type P frame may be the P frame of the first type or the P frame of the third type.
- the third type of P frame can be followed by the first type of P frame or the second type of P frame, but it will not be the third type of P frame.
- a P frame of the first type may be followed by a P frame of the second type or a P frame of a third type
- a P frame of the second type may be followed by a P frame of the first type
- a P frame of the third type may be followed by a P frame of the first type.
- the I frame of the GOP sequence may be followed by the P frame of the first type
- the I frame of the GOP sequence may be followed by the P frame of the second type
- the I frame of the GOP sequence may be followed by the P frame of the third type. This is not done. limit.
- the first P frame after the I frame in the GOP sequence is the first type of P frame.
- first type P frames when all P frames in the GOP sequence are divided into first type P frames, second type P frames and third type P frames, between two adjacent third type P frames There may be two first-type P frames and one second-type P frame, and a second-type P frame may be located between two first-type P frames. In addition, there may be two first-type P frames and one second-type P frame between the I frame (i.e., the first frame) of the GOP sequence and the first third type P frame, and this second type P frame may be located between these two first-class P frames.
- the above division method is just an example, and there is no limit to this.
- the P frame of the second type is located between two P frames of the first type
- the P frame of the second type is located between the P frames of the second type.
- a P-frame of type 1 is located between two P-frames of type 2.
- the P frame of the second type is located between two P frames of the first type, and the P frame of the second type is located between two P frames of the first type.
- a P-frame of type 1 is located between two P-frames of type 2.
- the first frame after the I frame is a first type P frame, and there are two types of P frames between the I frame and the first third type P frame.
- a P frame of the first type and a P frame of a second type, and the P frame of the second type is located between two P frames of the first type.
- the frames in the GOP sequence are: I frame, first type P frame, second type P frame, first type P frame, third type P frame, first type P frame, second type P frame.
- the second type of P frame is used as the reference frame of the first type of P frame
- the third type of P frame is used as the reference frame of the first type of P frame.
- the nearest non-first type P frame (such as an I frame, a second type P frame, or a third type P frame) before the first type P frame is P frame) as the reference frame of the first type of P frame.
- the nearest P frame of the third type before the P frame of the second type is used as the reference frame of the P frame of the second type.
- the I frame of the GOP sequence is used as the reference frame of the P frame of the second type.
- the latest type 3 P frame before the type 3 P frame is used as the reference frame of the type 3 P frame.
- the I frame of the GOP sequence is used as the reference frame of the third type P frame.
- the reference frame of the first type of P frame is the previous I frame
- the reference frame of the second type of first P frame is the previous type of second P frame
- the reference frame of the third type of P frame is the previous type of P frame.
- the reference frame of a P frame of the first type is the previous P frame of the third type
- the reference frame of the fourth P frame of the first type is the previous P frame of the second type
- the reference frame of the fifth P frame of the first type is the previous P frame of the first type.
- the reference frame of the first type 2 P frame is the previous I frame
- the reference frame of the second type 2 P frame is the previous type 3 P frame
- the reference frame of the third type 2 P frame is the previous type 3 P frame.
- the reference frame of the second type P frame is the previous third type P frame, and so on.
- the reference frame of the first type III P frame is the previous I frame
- the reference frame of the second type III P frame is the previous type III P frame
- the reference frame of the third type III P frame is the previous type III P frame
- the reference frame of the third type P frame is the previous third type P frame, and so on.
- Step 702 If it is determined that the P frames in the GOP sequence need to be extracted, the first type of P frames are extracted, or the first type of P frames and the second type of P frames are extracted, or the first type of P frames are extracted, or the first type of P frames are extracted.
- P-frames of the first type, P-frames of the second type and P-frames of the third type are extracted.
- extracting the P frame may mean: not processing the P frame.
- the encoding end extracts the P frame, it means that the P frame is not encoded.
- the decoding end extracts the P frame, Just don't decode this P frame.
- all the first type P frames or part of the first type P frames can be extracted; or, all the first type P frames can be extracted.
- Frame extraction is performed on P-type frames, and all P-frames of the second type or part of the P-frames of the second type are extracted; alternatively, all P-frames of the first type can be extracted, and all P-frames of the second type can be extracted. , and perform frame extraction on all the third type P frames or part of the third type P frames.
- multiple sampling ratios can be divided, and the sampling ratio is used to indicate how many P frames to extract. For example, when the sampling ratio is x, Indicates that x in all P frames is sampled, and different sampling ratios represent different sampling methods.
- first sampling proportion For example, three sampling proportions are divided, recorded as the first sampling proportion, the second sampling proportion and the third sampling proportion.
- the first sampling proportion is smaller than the second sampling proportion, and the second sampling proportion is smaller than the third sampling proportion.
- frame extraction is performed on all P frames of the first type or part of the P frames of the first type; for the second sampling ratio, frames are extracted on all P frames of the first type, and on all P frames of the second type or Frame extraction is performed on some P-frames of the second type; for the third sampling ratio, all P-frames of the first type are extracted, all P-frames of the second type are extracted, and all P-frames of the third type or part of the third-category P-frame are extracted.
- P-like frames are used for frame extraction.
- sampling proportions are divided, recorded as the first sampling proportion, the second sampling proportion, the third sampling proportion, the fourth sampling proportion, the fifth sampling proportion and the sixth sampling proportion.
- the first sampling proportion is smaller than the second sampling proportion.
- the second sampling proportion is smaller than the third sampling proportion
- the third sampling proportion is smaller than the fourth sampling proportion
- the fourth sampling proportion is smaller than the fifth sampling proportion
- the fifth sampling proportion is smaller than the sixth sampling proportion.
- first sampling ratio frame extraction is performed on some P frames of the first type; for the second sampling ratio, frames are extracted on all P frames of the first type; for the third sampling ratio, frames are extracted on all P frames of the first type , extract frames for some P-frames of the second type; for the fourth sampling ratio, extract frames for all P-frames of the first type, and for all P-frames of the second type; for the fifth sampling ratio, extract frames for all P-frames of the first type P frames are extracted, and frames are extracted for all P frames of the second type, and some P frames of the third type are extracted; for the sixth sampling ratio, frames are extracted for all P frames of the first type, and all P frames of the second type are extracted. Frame extraction is performed on all P frames of the third type.
- sampling proportions are just an example of the division of sampling proportions, and there is no restriction on this. Any number of sampling proportions can be divided. For the convenience of description, the following description will be made by taking the division of three sampling proportions as an example.
- the first sampling ratio needs to be used to extract frames from P frames in the GOP sequence
- all first type P frames or part of the first type P frames can be extracted; if it is determined that the second sampling ratio needs to be used, If the sampling ratio is used to extract the P frames in the GOP sequence, all the first type P frames can be extracted, and all the second type P frames or part of the second type P frames can be extracted; if it is determined that the first type P frame needs to be used, The three-sampling ratio is used to extract frames from P frames in the GOP sequence. Then, all P frames of the first type can be extracted, all P frames of the second type can be extracted, and all P frames of the third type or part of the third type can be extracted. P-like frames are used for frame extraction.
- the total number of P frames of the first type accounts for x1 of the total number of P frames
- the total number of P frames of the second type accounts for x2 of the total number of P frames
- the total number of P frames of the third type accounts for x2 of the total number of P frames.
- x3 of Or equal to x1+x2+x3.
- x1 is 0.5
- x2 is 0.25
- x3 is 0.25.
- the sampling ratio is less than or equal to 0.5, it means that the sampling ratio is the first sampling ratio. If the sampling ratio is greater than 0.5, And less than or equal to 0.75, it means that the sampling ratio is the second sampling ratio. If the sampling ratio is greater than 0.75 and less than or equal to 1, it means that the sampling ratio is the third sampling ratio.
- the first sampling ratio if it is determined that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames can be extracted. In this case, the first sampling ratio The ratio is less than or equal to 0.5.
- the second sampling ratio if it is determined that the second sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then all first type P frames can be extracted, and all second type P frames can be extracted, In this case, the second sampling ratio is less than or equal to 0.75 and greater than 0.5.
- frames can be extracted from all P frames of the first type, and frames can be extracted from all P frames of the second type, and Frame sampling is performed on all P frames of the third type.
- the third sampling ratio is less than or equal to 1 and greater than 0.75.
- a GOP sequence can achieve 1/2 frame extraction.
- a GOP sequence can achieve 3/4 frame extraction.
- a GOP sequence can achieve complete frame extraction.
- the service requirements corresponding to the service information can be met, that is, the P frames extracted by x1 (such as 0.5) from the GOP sequence can meet the service requirements, and the selection is determined based on the service information.
- First sampling ratio If the first sampling ratio cannot meet the business requirements, but the second sampling ratio is used to extract frames from P frames in the GOP sequence, the business requirements corresponding to the business information can be met, that is, x1+x2 (such as 0.75) is extracted from the GOP sequence.
- the P frame can meet the business requirements, and the second sampling ratio is determined based on the business information. If the first sampling ratio cannot meet the business needs, and the second sampling ratio cannot meet the business needs, the third sampling ratio will be determined based on the business information.
- Application scenario 1 Business information includes the resolution corresponding to the GOP sequence (for example, 4*30 frames represents the frame rate), the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoder. Determine whether it is needed based on the resolution, frame rate, and decoding capability. Extract frames from P frames within the GOP sequence. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability, such as the first sampling ratio, the second sampling ratio, or the third sampling ratio.
- the NVR device has a decoding capability of 4*1080P30, that is, the NVR device can decode 4*30 frames of 1920*1080 images in one second. Images exceeding this decoding capability cannot be decoded.
- the NVR device does not extract frames from P frames in the GOP sequence, can decode 4*30 frames of images in one second, and display 1080P30 images through 4 channels, see Figure 5A.
- the GOP sequence corresponds to an 8*30 frame image (resolution is 1920*1080)
- the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel to meet business needs.
- the GOP sequence corresponds to an image of 4*60 frames (resolution 1920*1080), based on the resolution, frame rate and decoding capability, it is determined that the P frames in the GOP sequence need to be extracted, that is, the resolution, frame The rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, it is determined that the P frames in the GOP sequence need to be extracted, and each image must be sampled according to the first sampling ratio (i.e. 1 /2 frame extraction method) to extract frames, when 4*30 frames of images can be decoded in one second, 1080P30 images can be displayed through 4 channels, as shown in Figure 5C. Obviously, 4*60 frames are extracted by 1/2 4*30 frames remain after the frame.
- the first sampling ratio i.e. 1 /2 frame extraction method
- the GOP sequence corresponds to an image of 12*30 frames (resolution is 1920*1080)
- the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
- the GOP sequence corresponds to an image of 16*30 frames (resolution is 1920*1080)
- the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
- frames can be extracted according to the first sampling ratio, the second sampling ratio, or the third sampling ratio to meet business needs.
- Application scenario 2 If the service information includes the network quality corresponding to the target network between the sending end and the receiving end, it is determined based on the network quality whether the P frame in the GOP sequence needs to be extracted. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, such as the first sampling ratio, the second sampling ratio, or the third sampling ratio.
- the sender when the sender sends a GOP sequence to the receiver, it needs to detect the network quality (such as jitter, packet loss rate, etc.) corresponding to the target network used to carry the GOP sequence. There is no restriction on this detection method.
- the network quality such as jitter, packet loss rate, etc.
- four levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (ie, the optimal level), it is determined not to extract the P frames in the GOP sequence. frame. If the network quality corresponding to the target network is level 2 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio, such as 1/2 frame extraction. If the network quality corresponding to the target network is level 3 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the second sampling ratio, such as 3/4 frame extraction. If the network quality corresponding to the target network is the network quality of level 4 (i.e., the worst level), it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the third sampling ratio, such as 4/4 frame extraction. Way.
- the network quality corresponding to the target network is the network quality of the first level (ie, the optimal level)
- the sampling ratio is the first sampling ratio, such as 1/2 frame extraction.
- two levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (i.e., the optimal level), it is determined that the P frames in the GOP sequence are not to be processed. Frame extraction. If the network quality corresponding to the target network is the second level network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio. During the transmission process of the GOP sequence, if the network quality is still If the network quality is Level 2, the sampling ratio will be adjusted to the second sampling ratio. During the transmission process of the GOP sequence, if the network quality is still Level 2 network quality, the sampling ratio will be adjusted to the third sampling ratio. In addition, during the transmission process of the GOP sequence, if the network quality returns to the first level of network quality, the P frames in the GOP sequence will not be extracted.
- the sampling ratio corresponding to the GOP sequence is determined based on the size of each frame. If the frame size is less than the first threshold, the P frames in the GOP sequence will not be sampled. The frame size is greater than the first threshold and less than the second threshold. limit, the sampling ratio is the first sampling ratio. When the frame size is greater than the second threshold and less than the third threshold, the sampling ratio is the second sampling ratio. When the frame size is greater than the third threshold, the sampling ratio is Third sampling ratio.
- At least two GOP sequences can also be composed into an image sequence set. Based on this, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the The first GOP sequence of the image sequence set, then the I frame of the first GOP sequence can be used as the reference frame of the first frame of the GOP sequence. In this embodiment, if the GOP sequence is not the first GOP sequence in the image sequence set, the first frame of the GOP sequence can be called a key P frame (that is, it is no longer called an I frame), and the reference frame of the key P frame is the most recent I frame.
- the image sequence set may include at least one key P frame, that is, at least one key P frame is allowed to exist.
- the key P frame is used to replace the position of the I frame.
- the key P frame can only refer to the I frame. Its frame structure is the closest preceding I frame, and the key P frame can effectively reduce the overall bandwidth.
- the image sequence collection may include key P frames. Between the I frame and the key P frame, there may be the first type of P frame, the second type of P frame and the third type of P frame, and the structural relationship of the first type of P frame, the second type of P frame and the third type of P frame. See the above embodiments. Between two adjacent key P frames, there may be a first type of P frame, a second type of P frame and a third type of P frame, and the structure of the first type of P frame, the second type of P frame and the third type of P frame For the relationship, please refer to the above embodiment.
- the video frame sequence includes a first type of P frame, a second type of P frame, and a third type of P frame.
- Frames can be dropped according to certain rules, which can It ensures that the video frame sequence is played in order, and has the characteristics of discarding P frames according to the rules without affecting viewing. It can also discard some P frames in some special scenarios to achieve the purpose of saving bandwidth.
- the video frame sequence is decoded and transmitted over the network. , has better application prospects in storage, realizing the characteristics of multiplied decoding channels, low-bandwidth transmission, low bit rate storage, etc., and can also solve problems such as long-term black screen and blurred screen after frame loss in weak network environment.
- the frame loss strategy can be dynamically implemented and arbitrarily adjusted according to on-site conditions, flexibly and effectively reducing consumption without affecting decoding integrity. This video frame sequence can ensure the flexibility of frame extraction and the stability of image quality, and can effectively improve customer experience.
- an image processing device is proposed in the embodiment of the present application. See Figure 11, which is a schematic structural diagram of the image processing device.
- the device may include:
- the dividing module 111 is configured to divide all P frames in the picture group GOP sequence into at least two types of P frames. Among the at least two types of P frames, there are P frames that cannot be used as reference frames, and the at least Among the two types of P frames, there are P frames that can serve as reference frames;
- the processing module 112 is configured to extract frames that cannot be used as reference frames if it is determined that the P frames in the GOP sequence need to be extracted, or if it is determined that the P frames in the GOP sequence need to be extracted.
- frame extraction is performed on P frames that cannot be used as reference frames and P frames that can be used as reference frames.
- the dividing module 111 is specifically used to divide all P frames in the GOP sequence into first type P frames and second type P frames; wherein the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame.
- the frame can be used as a reference frame of the first type of P frame, and the second type of P frame can be used as a reference frame of the second type of P frame;
- the processing module 112 is specifically used to extract the P frame in the GOP sequence if it is determined that it is necessary to extract the frame. Then, frame extraction is performed on the P frame of the first type, or frame extraction is performed on the P frame of the first type and the P frame of the second type.
- the dividing module 111 divides all P frames in the GOP sequence into the first type of P frames and the second type of P frames, it is specifically used to: based on the position ordering relationship between the P frames in the GOP sequence, divide the GOP into All P frames in the sequence are divided into first type P frames and second type P frames; among them, there are M1 first type P frames between two adjacent second type P frames, and the I frame of the GOP sequence is the same as the first type P frame. There are M2 P frames of the first type between the P frames of the second type; M1 and M2 are both positive integers.
- the most recent P frame of the second type before the P frame of the first type is regarded as the P frame of the first type.
- the reference frame of the frame if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type; for each P frame of the second type, if the P frame of the second type If there is a P frame of the second type before the P frame of the second type, the most recent P frame of the second type before the P frame of the second type is used as the reference frame of the P frame of the second type. If there is no P frame of the second type before it, For the second type of P frame, the I frame of the GOP sequence is used as the reference frame of the second type of P frame.
- the processing module 112 determines that it is necessary to extract the P frames within the GOP sequence, then the first type of P frame is extracted, or specifically when the first type of P frame and the second type of P frame are extracted. Used for: If it is determined based on the business information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all first type P frames or part of the first type P frames are extracted; if it is determined based on the business information that it is necessary Using the second sampling ratio to extract frames from P frames in the GOP sequence, extract frames from all P frames of the first type, and extract frames from all P frames of the second type or part of the P frames of the second type; or, if If it is determined based on the business information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then some of the first type P frames will be extracted; if it is determined based on the business information that the second sampling ratio needs to be used to extract the P frames in the GOP sequence If the frame is extracted, all first-type P frames
- the processing module 112 is also configured to determine whether it is necessary to perform decoding based on the resolution, frame rate, and decoding capability if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end.
- the P frames in the GOP sequence are extracted; if the decoding capability does not support images with decoding resolution and frame rate, it is determined to extract the P frames in the GOP sequence; if so, based on the resolution, frame rate and decoding Ability determined
- the dividing module 111 is specifically used to divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; the first type P frame cannot be used as a reference. frame, the second type of P frame can only be used as a reference frame of the first type of P frame, the third type of P frame can be used as a reference frame of the first type of P frame, can be used as a reference frame of the second type of P frame, and can be used as a reference frame of the first type of P frame.
- the reference frame of the three types of P frames; the processing module 112 is specifically used to extract frames from the P frames in the GOP sequence if it is determined that the P frames in the GOP sequence need to be extracted, or extract the frames from the first type P frames and the first type P frames.
- the second type of P frame is extracted, or the first type of P frame, the second type of P frame and the third type of P frame are extracted.
- the dividing module 111 divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame, it is specifically used to: based on the difference between the P frames in the GOP sequence.
- the position sorting relationship divides all P frames in the GOP sequence into the first type of P frames, the second type of P frames and the third type of P frames; among them, for all P frames in the GOP sequence, two adjacent third type P frames
- There are two P frames of the first type and one P frame of the second type between the P frames, and the P frame of the second type is located between the two P frames of the first type.
- the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is regarded as the first type P frame.
- reference frame if the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame will be used as the reference frame of the first type P frame;
- second type P frame P frame if there is a third type P frame before the second type P frame, then the latest third type P frame before the second type P frame is used as the reference frame of the second type P frame, if the second type P frame If there is no P frame of the third type before the P frame, the I frame of the GOP sequence is used as the reference frame of the P frame of the second type;
- P frame of the third type if there is a P frame of the third type before the P frame of the third type, P frame, then the latest P frame of the third type before the P frame of the third type is used as the reference frame of the P frame of the third type
- the processing module 112 determines that the P frames in the GOP sequence need to be extracted, then the first type of P frames need to be extracted, or the first type of P frames and the second type of P frames need to be extracted, or , when extracting frames of the first type of P frame, the second type of P frame and the third type of P frame, it is specifically used: if it is determined based on the service information that the first sampling ratio needs to be used to extract the P frame in the GOP sequence, then Perform frame extraction on all first-type P frames or part of the first-type P frames; if it is determined based on the service information that the second sampling ratio needs to be used to extract frames within the GOP sequence, then all first-type P frames shall be extracted.
- the second sampling ratio is greater than the first sampling ratio; if it is determined based on the business information that a third sampling ratio needs to be used to perform frame extraction on the P frames within the GOP sequence
- the third sampling ratio is greater than Second sampling ratio.
- the processing module 112 is also configured to determine whether it is necessary to perform decoding based on the resolution, frame rate, and decoding capability if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end.
- the P frames in the GOP sequence are extracted; if the decoding capability does not support images with decoding resolution and frame rate, it is determined to extract the P frames in the GOP sequence; if so, based on the resolution, frame rate and decoding
- the ability to determine the sampling ratio corresponding to the GOP sequence the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio; or, if the service information includes the network quality corresponding to the target network between the encoding end and the decoding end, Then it is determined based on the network quality whether the P frame in the GOP sequence needs to be extracted; if the network quality is not the optimal level of network quality, it is determined to extract the P frame in the GOP sequence; if so, based on the network quality Determine the sampling ratio corresponding to the GOP sequence.
- the sampling ratio is the first sampling ratio, the second sampling ratio, or the third sampling ratio.
- the dividing module 111 is also used to divide the first GOP sequence into The I frame serves as the reference frame for the first frame of the GOP sequence.
- the image processing device includes a processor 1201 and a machine-readable storage medium 1202.
- the machine-readable storage medium 1202 stores Machine-executable instructions that can be executed by the processor 1201; the processor 1201 is used to execute the machine-executable instructions to implement the image processing method disclosed in the above examples of this application.
- embodiments of the present application also provide a machine-readable storage medium.
- Several computer instructions are stored on the machine-readable storage medium.
- the present invention can be realized. Apply the image processing method disclosed in the above example.
- machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device, which can contain or store information, such as executable instructions, data, etc.
- machine-readable storage media can be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard drive), solid state drive, any type of storage disk (such as CDs, DVDs, etc.), or similar storage media, or a combination thereof.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The present application provides an image processing method and apparatus, and a device. The method comprises: dividing all P frames in a GOP sequence into at least two types of P frames, the at least two types of P frames comprising P frames that cannot be used as reference frames and P frames that can be used as reference frames; and if it is determined that the P frames in the GOP sequence need to be subjected to step printing, performing step printing on the P frames that cannot be used as reference frames, or if it is determined that the P frames in the GOP sequence need to be subjected to step printing, performing step printing on the P frames that cannot be used as reference frames and the P frames that can be used as reference frames. By means of the technical solution of the present application, frame dropping can be performed according to a certain rule, such that a video frame sequence can be ensured to be played in order, and some P frames can also be dropped in some special scenarios to save bandwidth.
Description
本申请涉及视频编解码领域,尤其涉及一种图像处理方法、装置及设备。The present application relates to the field of video coding and decoding, and in particular, to an image processing method, device and equipment.
为了达到节约空间的目的,视频图像都是经过编码后才传输的,完整的视频编码方法可以包括预测、变换、量化、熵编码、滤波等过程,而预测编码可以包括帧内编码和帧间编码。帧间编码是利用视频时间域的相关性,使用邻近已编码图像的像素预测当前图像的像素,达到去除视频时域冗余的目的。帧内编码是考虑到相邻块之间存在很强的空域相关性,利用周围已经重建的像素作为参考像素,对当前未编码块进行预测,只需要对残差值进行后续编码处理,而不是对原始值进行编码,有效去除空域上的冗余,大大提高了压缩效率。In order to save space, video images are transmitted after encoding. The complete video coding method can include prediction, transformation, quantization, entropy coding, filtering and other processes, and predictive coding can include intra-frame coding and inter-frame coding. . Inter-frame coding uses the correlation in the video time domain to predict the pixels of the current image using the pixels of adjacent encoded images to achieve the purpose of removing video time domain redundancy. Intra-frame coding takes into account the strong spatial correlation between adjacent blocks, uses the surrounding reconstructed pixels as reference pixels to predict the current uncoded block, and only needs to perform subsequent coding processing on the residual value instead of Encoding the original value effectively removes redundancy in the spatial domain and greatly improves compression efficiency.
在视频编码过程中,可以将所有图像区分为I帧和P帧,I帧是采用帧内编码的图像,即可以进行独立编码,而不需要参考其它图像,P帧是采用帧间编码的图像,即需要参考其它图像完成编码,如依赖前面的图像完成编码。比如说,连续视频帧依次包括帧1-帧10,帧1是I帧,帧2-帧5是P帧,帧6是I帧,帧7-帧10是P帧,那么,帧1采用帧内编码,帧2参考帧1完成帧间编码,帧3参考帧2完成帧间编码,帧4参考帧3完成帧间编码,帧5参考帧4完成帧间编码,帧6采用帧内编码,帧7参考帧6完成帧间编码,以此类推。In the video encoding process, all images can be divided into I frames and P frames. I frames are images that use intra-frame coding, that is, they can be independently encoded without referring to other images. P frames are images that use inter-frame coding. , that is, you need to refer to other images to complete the encoding, such as relying on the previous image to complete the encoding. For example, continuous video frames include frames 1 to 10 in sequence, frame 1 is an I frame, frame 2 to frame 5 are P frames, frame 6 is an I frame, and frame 7 to frame 10 are P frames. Then, frame 1 adopts frame Intra-coding, frame 2 refers to frame 1 to complete inter-frame coding, frame 3 refers to frame 2 to complete inter-frame coding, frame 4 refers to frame 3 to complete inter-frame coding, frame 5 refers to frame 4 to complete inter-frame coding, frame 6 uses intra-frame coding, Frame 7 completes interframe coding with reference to frame 6, and so on.
显然,在上述方式中,所有P帧均不能被丢弃,一旦某个P帧被丢弃,那么,就会导致后续P帧无法被正确处理。比如说,若帧3被丢弃,则会导致帧4无法参考帧3完成帧间编码,帧5也无法参考帧4完成帧间编码。Obviously, in the above method, all P frames cannot be discarded. Once a certain P frame is discarded, subsequent P frames will not be processed correctly. For example, if frame 3 is discarded, frame 4 will not be able to complete inter-frame coding with reference to frame 3, and frame 5 will not be able to complete inter-frame coding with reference to frame 4.
发明内容Contents of the invention
本申请提供一种图像处理方法,所述方法包括:将画面组GOP序列内的所有P帧划分为至少两个类型的P帧,所述至少两个类型的P帧中存在不能够作为参考帧的P帧,且所述至少两个类型的P帧中存在能够作为参考帧的P帧;若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧进行抽帧,或者,若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽帧。The present application provides an image processing method. The method includes: dividing all P frames in the picture group GOP sequence into at least two types of P frames, and any of the at least two types of P frames cannot be used as reference frames. P frames, and there are P frames that can be used as reference frames among the at least two types of P frames; if it is determined that the P frames in the GOP sequence need to be framed, then the P frames that cannot be used as reference frames are Perform frame extraction, or if it is determined that P frames within the GOP sequence need to be extracted, then extract frames that cannot be used as reference frames and P frames that can be used as reference frames.
在一种可能的实施方式中,所述方法包括:将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,所述第一类P帧不能够作为参考帧,所述第二类P帧能够作为第一类P帧的参考帧、且所述第二类P帧能够作为第二类P帧的参考帧;若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧。In a possible implementation, the method includes: dividing all P frames in the GOP sequence into a first type of P frame and a second type of P frame; wherein the first type of P frame cannot be used as Reference frame, the second type P frame can be used as a reference frame of the first type P frame, and the second type P frame can be used as a reference frame of the second type P frame; if it is determined that it is necessary to When the P frame is extracted, the first type of P frame is extracted, or the first type of P frame and the second type of P frame are extracted.
在一种可能的实施方式中,所述将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧,包括:基于所述GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,相邻两个第二类P帧之间存在M1个第一类P帧,所述GOP序列的I帧与第一个第二类P帧之间存在M2个第一类P帧;其中,M1为正整数,M2为正整数。In a possible implementation, dividing all P frames in the GOP sequence into first type P frames and second type P frames includes: based on The position sorting relationship divides all P frames in the GOP sequence into first type P frames and second type P frames; wherein, there are M1 first type P frames between two adjacent second type P frames, There are M2 first-type P frames between the I frame of the GOP sequence and the first second-type P frame; where M1 is a positive integer and M2 is a positive integer.
针对每个第一类P帧,若该第一类P帧前面存在第二类P帧,则将该第一类P帧前面最近一个第二类P帧作为该第一类P帧的参考帧,若该第一类P帧前面不存在第二类P帧,则将所述GOP序列的I帧作为该第一类P帧的参考帧;For each P frame of the first type, if there is a P frame of the second type before the P frame of the first type, the most recent P frame of the second type before the P frame of the first type is used as the reference frame of the P frame of the first type. , if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type;
针对每个第二类P帧,若该第二类P帧前面存在第二类P帧,则将该第二类P帧前面最近一个第二类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第二类P帧,则将所述GOP序列的I帧作为该第二类P帧的参考帧。For each second type P frame, if there is a second type P frame before the second type P frame, the nearest second type P frame before the second type P frame is used as the reference frame of the second type P frame. , if there is no second type P frame before the second type P frame, then the I frame of the GOP sequence is used as the reference frame of the second type P frame.
示例性的,所述若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,包括:若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;或者,Exemplarily, if it is determined that the P frames in the GOP sequence need to be extracted, then extract the first type of P frames, or extract the first type of P frames and the second type of P frames. Extracting frames of P-type frames includes: if it is determined based on the service information that the first sampling ratio needs to be used to extract P frames in the GOP sequence, then extracting all P-frames of the first type or part of the P-frames of the first type. frames; if it is determined based on the service information that the second sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first type P frames, and extract frames from all second type P frames or part of the second type P-like frames are used to extract frames; or,
若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧;若基于业务信息确定需要采用第三抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;If it is determined based on the business information that the first sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then some of the first type P frames will be extracted; if it is determined based on the business information that the second sampling ratio needs to be used to extract the frames, To extract frames for P frames in the GOP sequence, all P frames of the first type are extracted. If it is determined based on the service information that it is necessary to use the third sampling ratio to extract frames for P frames in the GOP sequence, then all P frames of the first type are extracted. The P frames of the first type are extracted, and all the P frames of the second type or part of the P frames of the second type are extracted;
其中,第二抽样比例大于第一抽样比例,第三抽样比例大于第二抽样比例。Among them, the second sampling proportion is greater than the first sampling proportion, and the third sampling proportion is greater than the second sampling proportion.
在一种可能的实施方式中,所述方法还包括:若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例;或者,
In a possible implementation, the method further includes: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end, based on the resolution, the The frame rate and the decoding capability determine whether frame extraction needs to be performed on the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding of images with the resolution and the frame rate, it is determined that the P frames in the GOP sequence need to be decoded. The P frames in the GOP sequence are extracted; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability; or,
若所述业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例;If the service information includes the network quality corresponding to the target network between the sending end and the receiving end, it is determined based on the network quality whether it is necessary to extract the P frames in the GOP sequence; wherein, if the network quality If the network quality is not the optimal level, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality;
其中,所述抽样比例为第一抽样比例、或第二抽样比例;或者,Wherein, the sampling ratio is the first sampling ratio or the second sampling ratio; or,
所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。The sampling ratio is a first sampling ratio, a second sampling ratio, or a third sampling ratio.
在一种可能的实施方式中,所述方法包括:将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;其中,所述第一类P帧不能够作为参考帧,所述第二类P帧只能够作为第一类P帧的参考帧,所述第三类P帧能够作为第一类P帧的参考帧、且能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧;若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧。In a possible implementation, the method includes: dividing all P frames in the GOP sequence into a first type of P frame, a second type of P frame and a third type of P frame; wherein, the first type of P frame The P frame of the second type cannot be used as a reference frame, the P frame of the second type can only be used as the reference frame of the P frame of the first type, the P frame of the third type can be used as the reference frame of the P frame of the first type, and can be used as the reference frame of the P frame of the first type. The reference frame of the second type of P frame and can be used as the reference frame of the third type of P frame; if it is determined that the P frame in the GOP sequence needs to be extracted, then the first type of P frame is extracted, or , perform frame extraction on the first type P frame and the second type P frame, or perform frame extraction on the first type P frame, the second type P frame and the third type P frame. .
在一种可能的实施方式中,所述将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧,包括:基于所述GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;其中,相邻两个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且所述一个第二类P帧位于所述两个第一类P帧之间;所述GOP序列的I帧与第一个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且这个第二类P帧位于这两个第一类P帧之间。In a possible implementation, dividing all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames includes: based on The positional sorting relationship between each P frame divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame; wherein, two adjacent third type P frames There are two P frames of the first type and one P frame of the second type between frames, and the P frame of the second type is located between the two P frames of the first type; the I frame of the GOP sequence and the P frame of the second type There are two first-type P frames and one second-type P frame between a third-type P frame, and the second-type P frame is located between the two first-type P frames.
示例性的,针对每个第一类P帧,若该第一类P帧的前一帧不是第一类P帧,则将该第一类P帧的前一帧作为该第一类P帧的参考帧,若该第一类P帧的前一帧是第一类P帧,则将前面最近一个非第一类P帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第三类P帧,则将该第二类P帧前面最近一个第三类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第二类P帧的参考帧;针对每个第三类P帧,若该第三类P帧前面存在第三类P帧,则将该第三类P帧前面最近一个第三类P帧作为该第三类P帧的参考帧,若该第三类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第三类P帧的参考帧。For example, for each first type P frame, if the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is regarded as the first type P frame. reference frame, if the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame will be used as the reference frame of the first type P frame; for each second type P frame P frame, if there is a third type P frame before the second type P frame, then the latest third type P frame before the second type P frame is used as the reference frame of the second type P frame, if the second type P frame If there is no P frame of the third type before the P frame, then the I frame of the GOP sequence is used as the reference frame of the P frame of the second type; for each P frame of the third type, if there is a P frame of the third type before the P frame of the third type. If there are three types of P frames, then the latest type three P frame before the third type P frame will be used as the reference frame of the third type P frame. If there is no third type P frame before the third type P frame, then the third type P frame will be used as the reference frame. The I frame of the GOP sequence serves as the reference frame of the third type of P frame.
示例性的,所述若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧,包括:Exemplarily, if it is determined that the P frames in the GOP sequence need to be extracted, then extract the first type of P frames, or extract the first type of P frames and the second type of P frames. Performing frame extraction on type P frames, or performing frame extraction on the first type P frame, the second type P frame and the third type P frame, including:
若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;If it is determined based on the service information that the first sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first-type P frames or part of the first-type P frames;
若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;其中,所述第二抽样比例大于所述第一抽样比例;If it is determined based on the service information that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames will be extracted, and all the second type P frames or part of the second type P frames will be extracted. The frame is extracted; wherein the second sampling ratio is greater than the first sampling ratio;
若基于业务信息确定需要采用第三抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧;第三抽样比例大于第二抽样比例。If it is determined based on the service information that the third sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all P frames of the first type, extract frames from all P frames of the second type, and extract frames from all P frames of the second type. The third type P frame or part of the third type P frame is extracted; the third sampling ratio is greater than the second sampling ratio.
所述方法还包括:若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例;或者,若所述业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。The method further includes: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end, determining based on the resolution, the frame rate, and the decoding capability. Whether it is necessary to extract frames from P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and frame rate, it is determined to extract frames from the P frames in the GOP sequence. frame; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability, and the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio proportion; or, if the service information includes the network quality corresponding to the target network between the sending end and the receiving end, determine whether it is necessary to extract frames from the P frames in the GOP sequence based on the network quality; wherein, if If the network quality is not the optimal level, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, and the sampling ratio is The first sampling proportion, or the second sampling proportion, or the third sampling proportion.
示例性的,所述方法还包括:当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是所述图像序列集合的首个GOP序列,则将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。Exemplarily, the method further includes: when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the first GOP sequence of the image sequence set, then replace the first GOP sequence with The I frame serves as the reference frame for the first frame of the GOP sequence.
本申请提供一种图像处理装置,所述装置包括:划分模块,用于将GOP序列内的所有P帧划分为至少两个类型的P帧,所述至少两个类型的P帧中存在不能够作为参考帧的P帧,且所述至少两个类型的P帧中存在能够作为参考帧的P帧;处理模块,用于若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧进行抽帧,或者,若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽帧。The present application provides an image processing device. The device includes: a dividing module, configured to divide all P frames in a GOP sequence into at least two types of P frames. There are inaccuracies in the at least two types of P frames. A P frame as a reference frame, and there is a P frame that can be used as a reference frame among the at least two types of P frames; a processing module, configured to extract frames from the P frame in the GOP sequence if it is determined that the P frame needs to be extracted. The P frames that cannot be used as reference frames are extracted, or if it is determined that the P frames in the GOP sequence need to be extracted, the P frames that cannot be used as reference frames and the P frames that can be used as reference frames are extracted. frame.
在一种可能的实施方式中,所述划分模块,具体用于将GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,所述第一类P帧不能够作为参考帧,所述第二类P帧能够作为第一类P帧的参考帧、且所述第二类P帧能够作为第二类P帧的参考帧;所述处理模块,具体用于若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧。In a possible implementation, the dividing module is specifically configured to divide all P frames in the GOP sequence into first type P frames and second type P frames; wherein the first type P frame cannot As a reference frame, the second type P frame can be used as a reference frame of the first type P frame, and the second type P frame can be used as a reference frame of the second type P frame; the processing module is specifically used if If it is determined that the P frames in the GOP sequence need to be extracted, the first type of P frames may be extracted, or the first type of P frames and the second type of P frames may be extracted.
其中,所述划分模块将GOP序列内的所有P帧划分为第一类P帧和第二类P帧时具体用于:基于所述GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,相邻两
个第二类P帧之间存在M1个第一类P帧,所述GOP序列的I帧与第一个第二类P帧之间存在M2个第一类P帧;M1和M2均为正整数。Wherein, when the dividing module divides all P frames in the GOP sequence into first type P frames and second type P frames, it is specifically used to: based on the position ordering relationship between the P frames in the GOP sequence, All P frames within the GOP sequence are divided into first type P frames and second type P frames; where two adjacent There are M1 P frames of the first type between the P frames of the second type, and M2 P frames of the first type between the I frame of the GOP sequence and the first P frame of the second type; M1 and M2 are both positive integer.
其中,针对每个第一类P帧,若该第一类P帧前面存在第二类P帧,则将该第一类P帧前面最近一个第二类P帧作为该第一类P帧的参考帧,若该第一类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第二类P帧,则将该第二类P帧前面最近一个第二类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第二类P帧的参考帧。Wherein, for each first type P frame, if there is a second type P frame before the first type P frame, the nearest second type P frame before the first type P frame is used as the first type P frame. Reference frame, if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type; for each P frame of the second type, if the P frame of the second type If there is a P frame of the second type before the P frame of the second type, the most recent P frame of the second type before the P frame of the second type is used as the reference frame of the P frame of the second type. If there is no P frame of the second type before the P frame of the second type. If the frame is a type P frame, the I frame of the GOP sequence is used as the reference frame of the second type P frame.
其中,所述处理模块确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧时具体用于:若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;或者,若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧;若基于业务信息确定需要采用第三抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;其中,第二抽样比例大于第一抽样比例,第三抽样比例大于第二抽样比例。Wherein, if the processing module determines that it is necessary to extract frames from P frames in the GOP sequence, then extract frames from the first type of P frames, or extract frames from the first type of P frames and the second type of P frames. When extracting P frames, it is specifically used: if it is determined based on the service information that the first sampling ratio needs to be used to extract P frames in the GOP sequence, then extract all P frames of the first type or part of the P frames of the first type. Frame extraction; if it is determined based on the service information that the second sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first type P frames, and extract frames from all second type P frames or part of the first type P frames. The second type P frames are extracted; or, if it is determined based on the service information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then some first type P frames are extracted; if based on the service information, If it is determined that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames need to be extracted; if it is determined based on the service information that the third sampling ratio needs to be used to extract the P frames in the GOP sequence To extract frames from P frames, extract frames from all P frames of the first type, and extract frames from all P frames of the second type or part of P frames of the second type; wherein, the second sampling ratio is greater than the first sampling ratio, and the second sampling ratio is larger than the first sampling ratio. The third sampling proportion is greater than the second sampling proportion.
其中,所述处理模块,还用于若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例;或者,若所述业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例;所述抽样比例为第一抽样比例、或第二抽样比例;或者,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。Wherein, the processing module is also configured to: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence and the decoding capability corresponding to the decoding end, based on the resolution, the frame rate and the decoding capability The decoding capability determines whether it is necessary to extract frames from the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and frame rate, it is determined that the P frames in the GOP sequence need to be extracted. The P frame is extracted; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability; or, if the service information includes the communication between the sending end and the receiving end. According to the network quality corresponding to the target network, it is determined based on the network quality whether it is necessary to extract frames from the P frames in the GOP sequence; wherein, if the network quality is not the optimal level of network quality, it is determined whether the P frames in the GOP sequence need to be extracted. The P frames in the sequence are extracted; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality; the sampling ratio is the first sampling ratio or the second sampling ratio; or, the sampling ratio is The first sampling proportion, or the second sampling proportion, or the third sampling proportion.
其中,所述划分模块,具体用于用于将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;所述第一类P帧不能够作为参考帧,所述第二类P帧只能够作为第一类P帧的参考帧,所述第三类P帧能够作为第一类P帧的参考帧、能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧;所述处理模块,具体用于若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧。Among them, the dividing module is specifically used to divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; the first type P frame cannot be used as Reference frame, the second type of P frame can only be used as a reference frame of the first type of P frame, the third type of P frame can be used as a reference frame of the first type of P frame, can be used as a reference frame of the second type of P frame , and can be used as a reference frame for the third type of P frame; the processing module is specifically configured to extract frames for the first type of P frame if it is determined that the P frame in the GOP sequence needs to be extracted, Alternatively, perform frame extraction on the first type P frame and the second type P frame, or perform extraction on the first type P frame, the second type P frame and the third type P frame. frame.
其中,所述划分模块将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧时具体用于:基于GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;其中,针对所述GOP序列内的所有P帧,相邻两个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且所述一个第二类P帧位于所述两个第一类P帧之间;所述GOP序列的I帧与第一个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且这个第二类P帧位于这两个第一类P帧之间。Wherein, when the dividing module divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame, it is specifically used: based on the position between each P frame in the GOP sequence. The sorting relationship divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame; wherein, for all P frames in the said GOP sequence, two adjacent There are two P frames of the first type and one P frame of the second type between the P frames of the third type, and the P frame of the second type is located between the two P frames of the first type; the GOP sequence There are two first-type P frames and one second-type P frame between the I frame and the first third-type P frame, and the second-type P frame is located between the two first-type P frames.
其中,针对每个第一类P帧,若该第一类P帧的前一帧不是第一类P帧,则将该第一类P帧的前一帧作为该第一类P帧的参考帧,若该第一类P帧的前一帧是第一类P帧,则将前面最近一个非第一类P帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第三类P帧,则将该第二类P帧前面最近一个第三类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第二类P帧的参考帧;针对每个第三类P帧,若该第三类P帧前面存在第三类P帧,则将该第三类P帧前面最近一个第三类P帧作为该第三类P帧的参考帧,若该第三类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第三类P帧的参考帧。Wherein, for each first type P frame, if the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is used as the reference of the first type P frame. frame, if the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame is used as the reference frame of the first type P frame; for each second type P frame , if there is a P frame of the third type before the P frame of the second type, then the most recent P frame of the third type before the P frame of the second type is used as the reference frame of the P frame of the second type, if the P frame of the second type If there is no P frame of the third type in front, the I frame of the GOP sequence is used as the reference frame of the P frame of the second type; for each P frame of the third type, if there is a P frame of the third type in front of the P frame of the third type, P frame, then the latest P frame of the third type preceding the P frame of the third type is used as the reference frame of the P frame of the third type. If there is no P frame of the third type before the P frame of the third type, the P frame of the third type is used as the reference frame. The I frame of the GOP sequence serves as the reference frame of the third type of P frame.
其中,所述处理模块确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧时具体用于:若基于业务信息确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;第二抽样比例大于第一抽样比例;若基于业务信息确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧;第三抽样比例大于第二抽样比例。Wherein, if the processing module determines that it is necessary to extract frames from P frames in the GOP sequence, then extract frames from the first type of P frames, or extract frames from the first type of P frames and the second type of P frames. Performing frame extraction on P frames, or performing frame extraction on the first type P frame, the second type P frame and the third type P frame is specifically used for: if it is determined based on the service information that it is necessary to use the first sampling If the proportion of P frames in the GOP sequence is used to extract frames, all first-type P frames or part of the first-type P frames are extracted; if it is determined based on the service information that a second sampling ratio needs to be used to extract P frames in the GOP sequence. To extract frames, extract frames for all P frames of the first type, and extract frames for all P frames of the second type or part of P frames of the second type; the second sampling ratio is greater than the first sampling ratio; if it is determined based on the business information, Using the third sampling ratio to extract frames from P frames in the GOP sequence, all P frames of the first type are extracted, all P frames of the second type are extracted, and all P frames of the third type or part of the P frames are extracted. Three types of P frames are used for frame extraction; the third sampling ratio is greater than the second sampling ratio.
其中,所述处理模块,还用于若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例;或者,若所述业务信息包括编码端与解码端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。
Wherein, the processing module is also configured to: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence and the decoding capability corresponding to the decoding end, based on the resolution, the frame rate and the decoding capability The decoding capability determines whether it is necessary to perform frame extraction on the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and frame rate, it is determined whether the P frames in the GOP sequence need to be decoded. The P frame is extracted; if so, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability, and the sampling ratio is the first sampling ratio, or the second sampling ratio, Or the third sampling ratio; or, if the service information includes the network quality corresponding to the target network between the encoding end and the decoding end, determine whether the P frame in the GOP sequence needs to be extracted based on the network quality. ; Wherein, if the network quality is not the optimal level of network quality, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, so The above-mentioned sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio.
其中,当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是所述图像序列集合的首个GOP序列,则所述划分模块,还用于将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。Wherein, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the first GOP sequence of the image sequence set, the dividing module is also used to divide the first GOP sequence into The I frame serves as the reference frame for the first frame of the GOP sequence.
本申请提供一种图像处理设备,包括:处理器和机器可读存储介质,所述机器可读存储介质存储有能够被所述处理器执行的机器可执行指令;所述处理器用于执行机器可执行指令,以实现本申请上述实施例公开的图像处理方法。The present application provides an image processing device, including: a processor and a machine-readable storage medium. The machine-readable storage medium stores machine-executable instructions that can be executed by the processor; the processor is configured to execute machine-executable instructions. Execute instructions to implement the image processing method disclosed in the above embodiments of this application.
由以上技术方案可见,本申请实施例中,可以将GOP(Group of Pictures,画面组)序列内的所有P帧划分为不能够作为参考帧的P帧和能够作为参考帧的P帧,在此基础上,可以对不能够作为参考帧的P帧进行抽帧,或者,对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽。上述方式提供一种新型视频帧序列,该视频帧序列包括不同类型的P帧,在视频帧序列中,可以按照一定规律进行丢帧,既能保证视频帧序列按照顺序播放,具有按照规则间叉性丢弃P帧而不影响观看的特点,又可以在一些特殊场景下丢弃部分P帧以达到节省带宽的目的,该视频帧序列在解码、网络传输、存储中具有更好的使用前景,实现解码倍增路数、低带宽传输,低码率存储等特点。It can be seen from the above technical solution that in the embodiment of the present application, all P frames in the GOP (Group of Pictures) sequence can be divided into P frames that cannot be used as reference frames and P frames that can be used as reference frames. Here Basically, the P frames that cannot be used as reference frames can be extracted, or the P frames that cannot be used as reference frames and the P frames that can be used as reference frames can be extracted. The above method provides a new type of video frame sequence. The video frame sequence includes different types of P frames. In the video frame sequence, frames can be dropped according to certain rules, which can not only ensure that the video frame sequence is played in order, but also has the ability to interleave according to the rules. It has the characteristics of permanently discarding P frames without affecting viewing, and can also discard part of P frames in some special scenarios to achieve the purpose of saving bandwidth. This video frame sequence has better prospects for use in decoding, network transmission, and storage, and realizes decoding Features include doubled channel number, low-bandwidth transmission, and low bit rate storage.
图1A和图1B是GOP序列的示意图;Figure 1A and Figure 1B are schematic diagrams of the GOP sequence;
图2是本申请一种实施方式中的图像处理方法的流程示意图;Figure 2 is a schematic flowchart of an image processing method in an embodiment of the present application;
图3A和图3B是GOP序列的示意图;Figure 3A and Figure 3B are schematic diagrams of the GOP sequence;
图4A-图4C是对GOP序列内的P帧进行抽帧的示意图;Figures 4A-4C are schematic diagrams of extracting frames from P frames in a GOP sequence;
图5A-图5E是通过多路显示图像的示意图;Figures 5A-5E are schematic diagrams of images displayed through multiple channels;
图6是图像序列集合的示意图;Figure 6 is a schematic diagram of an image sequence collection;
图7是本申请一种实施方式中的图像处理方法的流程示意图;Figure 7 is a schematic flowchart of an image processing method in an embodiment of the present application;
图8A和图8B是GOP序列的示意图;Figures 8A and 8B are schematic diagrams of the GOP sequence;
图9A-图9C是对GOP序列内的P帧进行抽帧的示意图;Figures 9A-9C are schematic diagrams of extracting frames from P frames in a GOP sequence;
图10是图像序列集合的示意图;Figure 10 is a schematic diagram of an image sequence collection;
图11是本申请一种实施方式中的图像处理装置的结构示意图;Figure 11 is a schematic structural diagram of an image processing device in an embodiment of the present application;
图12是本申请一种实施方式中的图像处理设备的硬件结构图。Figure 12 is a hardware structure diagram of an image processing device in an embodiment of the present application.
在视频编码和视频解码过程中,可以将所有图像区分为I帧和P帧,I帧是采用帧内编码的图像,即可以独立编码,而不需要参考其它图像,P帧是采用帧间编码的图像,即需要参考其它图像完成编码,如依赖前面的图像完成编码。In the process of video encoding and video decoding, all images can be divided into I frames and P frames. I frames are images that use intra-frame coding, that is, they can be encoded independently without referring to other images. P frames use inter-frame coding. The image needs to refer to other images to complete the encoding, such as relying on the previous image to complete the encoding.
视频编码是为图像存储而产生的压缩技术,能够将图像压缩为体积较小的码流,并将码流存储于硬盘。当需要播放视频时,将码流重新解码为图像,并对图像进行显示。在对图像进行视频编码时,编码方式有H.264、H.265等。Video coding is a compression technology developed for image storage. It can compress images into smaller code streams and store the code streams on the hard disk. When the video needs to be played, the code stream is re-decoded into images and the images are displayed. When video encoding images, the encoding methods include H.264, H.265, etc.
视频解码是将码流重新解码为图像的技术,在将码流(如存储于硬盘或从网络传输的码流)解码为图像之后,就可以显示图像,实现视频播放。Video decoding is a technology that re-decodes a code stream into an image. After the code stream (such as a code stream stored on a hard disk or transmitted from a network) is decoded into an image, the image can be displayed for video playback.
在视频编码和视频解码过程中,可以将I帧、该I帧与下一个I帧之间的所有P帧组成GOP序列,即GOP序列的第一帧是I帧,且GOP序列只有一个I帧,GOP序列的I帧后面可以包括P帧。比如说,连续视频帧依次包括帧1-帧10,帧1是I帧,帧2-帧5是P帧,帧6是I帧,帧7-帧10是P帧,那么,GOP序列1包括帧1-帧5,GOP序列2包括帧6-帧10,参见图1A所示,示出了GOP序列1和GOP序列2,每个GOP序列可以包括一个I帧和多个P帧。In the process of video encoding and video decoding, the I frame and all P frames between the I frame and the next I frame can be composed into a GOP sequence, that is, the first frame of the GOP sequence is an I frame, and the GOP sequence has only one I frame. , the I frame of the GOP sequence may be followed by a P frame. For example, continuous video frames include frames 1 to 10 in sequence, frame 1 is an I frame, frame 2 to frame 5 are P frames, frame 6 is an I frame, and frame 7 to frame 10 are P frames. Then, GOP sequence 1 includes Frame 1 to frame 5, and GOP sequence 2 includes frame 6 to frame 10. Referring to FIG. 1A , which shows GOP sequence 1 and GOP sequence 2, each GOP sequence may include one I frame and multiple P frames.
针对每个GOP序列,该GOP序列内的每个P帧均需要参考前一帧,比如说,对于GOP序列1,帧2参考帧1完成帧间编码,帧3参考帧2完成帧间编码,帧4参考帧3完成帧间编码,帧5参考帧4完成帧间编码。但是,在上述结构中,所有P帧均不能丢弃,一旦某个P帧被丢弃,就会导致后续P帧无法被正确处理。比如说,参见图1B所示,若帧3被丢弃,则会导致帧4无法参考帧3完成帧间编码,帧5也无法参考帧4完成帧间编码,也就是说,帧3后面的所有P帧均不能被正确处理。正常情况下,两个I帧之间会有2秒到10秒之间的时间,若某个P帧被丢弃,就会导致数秒的图像无法正常显示。For each GOP sequence, each P frame in the GOP sequence needs to refer to the previous frame. For example, for GOP sequence 1, frame 2 refers to frame 1 to complete inter-frame coding, and frame 3 refers to frame 2 to complete inter-frame coding. Frame 4 refers to frame 3 to complete interframe coding, and frame 5 refers to frame 4 to complete interframe coding. However, in the above structure, all P frames cannot be discarded. Once a P frame is discarded, subsequent P frames will not be processed correctly. For example, as shown in Figure 1B, if frame 3 is discarded, frame 4 will not be able to complete inter-frame coding with reference to frame 3, and frame 5 will not be able to complete inter-frame coding with reference to frame 4. That is to say, all the frames after frame 3 will not be able to complete inter-frame coding with reference to frame 3. None of the P frames can be processed correctly. Under normal circumstances, there will be between 2 seconds and 10 seconds between two I frames. If a P frame is discarded, the image will not be displayed normally for several seconds.
针对上述问题,本申请实施例中提供一种新型视频帧序列,该视频帧序列可以包括不同类型的P帧,如不能够作为参考帧的P帧和能够作为参考帧的P帧等,该视频帧序列可以按照一定规律进行丢帧,既能保证视频帧序列按照顺序播放,在丢弃P帧的情况下也不影响观看,也可以通过丢弃部分P帧达到节省带宽的目的。本申请实施例中的新型视频帧序列,可以将GOP序列内的所有P帧划分为至少两个类型的P帧,至少两个类型的P帧中存在不能够
作为参考帧的P帧,且至少两个类型的P帧中存在能够作为参考帧的P帧。在此基础上,若确定需要对GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧进行抽帧,或者,若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽帧。To address the above problems, embodiments of the present application provide a new type of video frame sequence. The video frame sequence may include different types of P frames, such as P frames that cannot be used as reference frames and P frames that can be used as reference frames. The video frame sequence The frame sequence can be dropped according to certain rules, which not only ensures that the video frame sequence is played in order, but does not affect viewing even if P frames are discarded, it is also possible to save bandwidth by discarding some P frames. The new video frame sequence in the embodiment of the present application can divide all P frames in the GOP sequence into at least two types of P frames. There are inaccuracies in at least two types of P frames. P frames that serve as reference frames, and there are P frames that can serve as reference frames among at least two types of P frames. On this basis, if it is determined that the P frame within the GOP sequence needs to be extracted, then the P frame that cannot be used as a reference frame will be extracted, or if it is determined that the P frame within the GOP sequence needs to be extracted, , then the P frames that cannot be used as reference frames and the P frames that can be used as reference frames are extracted.
以下结合具体实施例,对本申请实施例的技术方案进行说明。The technical solutions of the embodiments of the present application will be described below with reference to specific examples.
本申请实施例中提出一种图像处理方法,该方法可以应用于任意设备,参见图2所示,为该图像处理方法的流程示意图,该方法可以包括:The embodiment of the present application proposes an image processing method, which can be applied to any device. See Figure 2, which is a schematic flowchart of the image processing method. The method may include:
步骤201、将GOP序列内的所有P帧划分为第一类P帧和第二类P帧;示例性的,该第一类P帧不能够作为参考帧,该第二类P帧能够作为第一类P帧的参考帧、且该第二类P帧也能够作为第二类P帧的参考帧。Step 201: Divide all P frames in the GOP sequence into first type P frames and second type P frames; for example, the first type P frame cannot be used as a reference frame, and the second type P frame can be used as the second type P frame. A reference frame of a type of P frame, and the second type of P frame can also be used as a reference frame of a second type of P frame.
示例性的,针对每个GOP序列来说,该GOP序列可以包括I帧和多个P帧,本申请实施例中,可以将该GOP序列内的所有P帧区分为2种类型的P帧,可以将这2种类型的P帧分别称为第一类P帧和第二类P帧。For example, for each GOP sequence, the GOP sequence may include an I frame and multiple P frames. In this embodiment of the present application, all P frames within the GOP sequence may be distinguished into two types of P frames. These two types of P frames can be called first type P frames and second type P frames respectively.
其中,第一类P帧也可以称为普通P帧,第一类P帧不能作为其它帧的参考帧。第一类P帧可以将其它帧作为本第一类P帧的参考帧,比如说,第一类P帧可以将第二类P帧作为参考帧,第一类P帧也可以将GOP序列的I帧作为参考帧。但是,第一类P帧不可以将其它第一类P帧作为参考帧。Among them, the first type of P frame can also be called a normal P frame, and the first type of P frame cannot be used as a reference frame for other frames. The P frame of the first type can use other frames as reference frames of the P frame of the first type. For example, the P frame of the first type can use the P frame of the second type as a reference frame. The P frame of the first type can also use the P frame of the GOP sequence as a reference frame. I frames serve as reference frames. However, a first-type P frame cannot use other first-type P frames as reference frames.
其中,第二类P帧也可以称为被参考P帧(即第二类P帧可以作为参考帧),第二类P帧能够作为第一类P帧的参考帧、第二类P帧也能够作为第二类P帧的参考帧。第二类P帧可以将其它帧作为本第二类P帧的参考帧,比如说,第二类P帧可以将其它第二类P帧作为参考帧,第二类P帧也可以将GOP序列的I帧作为参考帧。但是,第二类P帧不可以将第一类P帧作为参考帧。Among them, the second type of P frame can also be called a referenced P frame (that is, the second type of P frame can be used as a reference frame). The second type of P frame can be used as a reference frame of the first type of P frame. The second type of P frame can also be called a reference frame. Can be used as a reference frame for the second type of P frame. The second type of P frame can use other frames as reference frames of the second type of P frame. For example, the second type of P frame can use other second type of P frames as reference frames. The second type of P frame can also use the GOP sequence. The I frame is used as the reference frame. However, the P frame of the second type cannot use the P frame of the first type as a reference frame.
在一种可能的实施方式中,在将GOP序列内的所有P帧划分为第一类P帧和第二类P帧时,可以采用任意划分方式,对此划分方式不做限制,只要同时存在第一类P帧和第二类P帧即可。示例性的,可以基于GOP序列内的各P帧之间的位置排序关系,将GOP序列内的所有P帧划分为第一类P帧和第二类P帧,即划分方式依据是位置排序关系。位置排序关系是指P帧是GOP序列内的哪一P帧,如第一个P帧、第二个P帧等,用于表示处于GOP序列的哪个位置。In a possible implementation, when dividing all P frames in the GOP sequence into first type P frames and second type P frames, any division method can be used, and there is no limit to this division method, as long as both The first type of P frame and the second type of P frame are enough. For example, all P frames in the GOP sequence can be divided into first type P frames and second type P frames based on the position ordering relationship between the P frames in the GOP sequence, that is, the division method is based on the position ordering relationship. . The positional sorting relationship refers to which P frame within the GOP sequence the P frame is, such as the first P frame, the second P frame, etc., which is used to indicate which position in the GOP sequence it is in.
例如,第一个P帧是第一类P帧,第二个P帧是第二类P帧,第三个P帧是第一类P帧,第四个P帧是第二类P帧,以此类推。又例如,第一个P帧和第二个P帧是第一类P帧,第三个P帧和第四个P帧是第二类P帧,以此类推。又例如,第一个P帧和第二个P帧是第一类P帧,第三个P帧是第二类P帧,以此类推。又例如,第一个P帧、第二个P帧和第三个P帧是第一类P帧,第四个P帧是第二类P帧,以此类推。又例如,第一个P帧是第一类P帧,第二个P帧和第三个P帧是第二类P帧,以此类推。当然,上述划分方式只是示例。For example, the first P frame is a P frame of the first type, the second P frame is a P frame of the second type, the third P frame is a P frame of the first type, and the fourth P frame is a P frame of the second type. And so on. For another example, the first P frame and the second P frame are P frames of the first type, the third P frame and the fourth P frame are P frames of the second type, and so on. For another example, the first P frame and the second P frame are the first type of P frames, the third P frame is the second type of P frame, and so on. For another example, the first P frame, the second P frame and the third P frame are the first type of P frames, the fourth P frame is the second type of P frame, and so on. For another example, the first P frame is a P frame of the first type, the second P frame and the third P frame are P frames of the second type, and so on. Of course, the above division methods are just examples.
示例性的,在将所有P帧划分为第一类P帧和第二类P帧时,第一类P帧的数量与第二类P帧的数量可以相同,第一类P帧的数量与第二类P帧的数量也可以不同。在第一类P帧的数量与第二类P帧的数量不同时,第一类P帧的数量可以大于第二类P帧的数量,第一类P帧的数量也可以小于第二类P帧的数量,比如说,后续以第一类P帧的数量大于第二类P帧的数量为例。For example, when all P frames are divided into first type P frames and second type P frames, the number of first type P frames and the number of second type P frames may be the same, and the number of first type P frames may be the same as the number of second type P frames. The number of P-frames of the second type can also be different. When the number of P frames of the first type is different from the number of P frames of the second type, the number of P frames of the first type may be greater than the number of P frames of the second type, and the number of P frames of the first type may also be smaller than the number of P frames of the second type. The number of frames, for example, in the following example, the number of P frames of the first type is greater than the number of P frames of the second type.
示例性的,在将所有P帧划分为第一类P帧和第二类P帧时,至少两个第一类P帧可以连续出现,但是,两个第二类P帧不会连续出现。比如说,第一类P帧后面的可以是第一类P帧或者第二类P帧,第二类P帧后面的可以是第一类P帧,但是,第二类P帧后面的不会是第二类P帧。For example, when all P frames are divided into first type P frames and second type P frames, at least two first type P frames may appear continuously, but two second type P frames will not appear continuously. For example, what follows the first type of P frame can be the first type of P frame or the second type of P frame, and what follows the second type of P frame can be the first type of P frame, but what follows the second type of P frame will not It is the second type of P frame.
示例性的,GOP序列的I帧后面可以是第一类P帧,GOP序列的I帧后面可以是第二类P帧。比如说,GOP序列的I帧后面的第一个P帧是第一类P帧。For example, the I frame of the GOP sequence may be followed by the P frame of the first type, and the I frame of the GOP sequence may be followed by the P frame of the second type. For example, the first P frame after the I frame in the GOP sequence is the first type of P frame.
在一种可能的实施方式中,在将GOP序列内的所有P帧划分为第一类P帧和第二类P帧时,相邻两个第二类P帧之间存在M1个第一类P帧,GOP序列的I帧(即第一帧)与第一个第二类P帧之间存在M2个第一类P帧,M1为正整数,M2为正整数,M1和M2均可以根据经验配置,M1和M2可以相同,也可以不同。其中,相邻两个第二类P帧之间存在M1个第一类P帧时,M1是可以变化的,比如说,第一个第二类P帧与第二个第二类P帧之间存在3个第一类P帧,第二个第二类P帧与第三个第二类P帧之间存在4个第一类P帧,第三个第二类P帧与第四个第二类P帧之间存在3个第一类P帧,以此类推。In a possible implementation, when all P frames in the GOP sequence are divided into first type P frames and second type P frames, there are M1 first type P frames between two adjacent second type P frames. P frame, there are M2 first type P frames between the I frame (i.e. the first frame) of the GOP sequence and the first second type P frame, M1 is a positive integer, M2 is a positive integer, both M1 and M2 can be based on Experience configuration, M1 and M2 can be the same or different. Among them, when there are M1 first-category P frames between two adjacent second-category P frames, M1 can change. For example, between the first second-category P frame and the second second-category P frame There are 3 P frames of the first type between, there are 4 P frames of the first type between the second P frame of the second type and the third P frame of the second type, and there are 4 P frames of the first type between the third P frame of the second type and the fourth P frame of the second type. There are three P frames of the first type between the P frames of the second type, and so on.
示例性的,相邻两个第二类P帧之间需要包括第一类P帧,第一类P帧的个数可以保持固定数目,如第一类P帧的数量为1个以上,但是,为了防止图像质量较差,第一类P帧的数量也不能太多。为了方便描述,在本申请实施例中,以相邻两个第二类P帧之间包括3个第一类P帧为例,且GOP序列的I帧与第一个第二类P帧之间存在3个第一类P帧。当然,上述划分方式只是一个示例,对此不做限制,比如说,相邻两个第二类P帧之间可以包括4个第一类P帧为例,或,相邻两个第二类P帧之间可以包括2个第一类P帧为例。For example, two adjacent P frames of the second type need to include P frames of the first type. The number of P frames of the first type can be maintained at a fixed number. For example, the number of P frames of the first type is more than 1, but , in order to prevent poor image quality, the number of first type P frames cannot be too many. For the convenience of description, in the embodiment of the present application, three P frames of the first type are included between two adjacent P frames of the second type as an example, and the I frame of the GOP sequence and the first P frame of the second type are There are 3 type 1 P frames in between. Of course, the above division method is just an example, and there is no limit to this. For example, two adjacent second-category P frames can include four first-category P frames, or two adjacent second-category P frames. For example, two P frames of the first type may be included between P frames.
为了方便描述,本申请实施例中,以图3A所示的GOP序列为例,I帧后面的第一帧是第一类P帧,I帧与第一个第二类P帧之间存在3个第一类P帧。相邻两个第二类P帧之间存在3个第一类P帧。参见图3A所示,GOP序列内的各帧依次是:I帧、第一类P帧、第一类P帧、第一类P帧、第二类P帧、第一类P帧、第一类P帧、第一类P帧、第二类P帧,以此类推。For the convenience of description, in the embodiment of the present application, taking the GOP sequence shown in Figure 3A as an example, the first frame after the I frame is a first type P frame, and there are 3 frames between the I frame and the first second type P frame. A type 1 P frame. There are three first-type P frames between two adjacent second-type P frames. Referring to Figure 3A, the frames in the GOP sequence are: I frame, first type P frame, first type P frame, first type P frame, second type P frame, first type P frame, first type Class P frames, first class P frames, second class P frames, and so on.
在一种可能的实施方式中,基于“第一类P帧不作为参考帧,第二类P帧能够作为第一类P帧的参考帧、且第二类P帧能够作为第二类P帧的参考帧”的特点,那么:针对每个第一类P帧,若该第一类P帧前面存在第二类P
帧,则将该第一类P帧前面最近一个第二类P帧作为该第一类P帧的参考帧,若该第一类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第一类P帧的参考帧。针对每个第二类P帧,若该第二类P帧前面存在第二类P帧,则将该第二类P帧前面最近一个第二类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第二类P帧的参考帧。In a possible implementation, based on "the first type of P frame is not used as a reference frame, the second type of P frame can be used as the reference frame of the first type of P frame, and the second type of P frame can be used as the second type of P frame. "reference frame" characteristics, then: for each first-type P frame, if there is a second-type P frame before the first-type P frame frame, then the nearest P frame of the second type preceding the P frame of the first type is used as the reference frame of the P frame of the first type. If there is no P frame of the second type before the P frame of the first type, the P frame of the GOP sequence is The I frame serves as the reference frame of the first type P frame. For each second type P frame, if there is a second type P frame before the second type P frame, the nearest second type P frame before the second type P frame is used as the reference frame of the second type P frame. , if there is no second type P frame before the second type P frame, then the I frame of the GOP sequence is used as the reference frame of the second type P frame.
参见图3B所示,示出了各P帧与参考帧之间的关系。针对第一类P帧来说,第1个第一类P帧的参考帧是前面的I帧,第2个第一类P帧的参考帧是前面的I帧,第3个第一类P帧的参考帧是前面的I帧,第4个第一类P帧的参考帧是前面的第二类P帧,第5个第一类P帧的参考帧是前面的第二类P帧,第6个第一类P帧的参考帧是前面的第二类P帧,以此类推。针对第二类P帧来说,第1个第二类P帧的参考帧是前面的I帧,第2个第二类P帧的参考帧是前面的第二类P帧,第3个第二类P帧的参考帧是前面的第二类P帧,以此类推。Referring to FIG. 3B , the relationship between each P frame and the reference frame is shown. For the first type P frame, the reference frame of the first type first P frame is the previous I frame, the reference frame of the second type first P frame is the previous I frame, and the reference frame of the third type first P frame is the previous I frame. The reference frame of the frame is the previous I frame, the reference frame of the 4th type 1 P frame is the previous type 2 P frame, and the reference frame of the 5th type 1 P frame is the previous type 2 P frame. The reference frame of the sixth type-1 P frame is the previous type-2 P frame, and so on. For the second type P frame, the reference frame of the first type II P frame is the previous I frame, the reference frame of the second type II P frame is the previous type II P frame, and the reference frame of the third type II P frame is the previous type II P frame. The reference frame of a Type II P frame is the previous Type II P frame, and so on.
步骤202、若确定需要对GOP序列内的P帧进行抽帧,则对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧。示例性的,对P帧进行抽帧是指:不对这个P帧进行处理,如编码端对P帧进行抽帧时,就是不对这个P帧进行编码,解码端对P帧进行抽帧时,就是不对这个P帧进行解码。Step 202: If it is determined that the P frames in the GOP sequence need to be extracted, then extract the first type of P frames, or extract the first type of P frames and the second type of P frames. For example, extracting a P frame means not processing the P frame. For example, when the encoding end extracts the P frame, it means that the P frame is not encoded. When the decoding end extracts the P frame, it means that the P frame is not processed. This P frame is not decoded.
在一种可能的实施方式中,若确定需要对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧或部分第一类P帧进行抽帧;或者,可以对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧。综上可以看出,在对第一类P帧进行抽帧时,不需要考虑第二类P帧是否被抽帧,可以直接对第一类P帧进行抽帧。在对第二类P帧进行抽帧时,需要考虑第一类P帧是否被抽帧,只有在所有第一类P帧均被抽帧之后,才可以对第二类P帧进行抽帧。In a possible implementation, if it is determined that the P frames in the GOP sequence need to be extracted, all the first type P frames or part of the first type P frames can be extracted; or, all the first type P frames can be extracted. The P-type frames are extracted, and all the P-frames of the second type or part of the P-frames of the second type are extracted. In summary, it can be seen that when extracting frames of the first type of P frames, it is not necessary to consider whether the frames of the second type of P frames are extracted, and the frames of the first type of P frames can be extracted directly. When extracting frames of the second type of P frames, it is necessary to consider whether the first type of P frames have been extracted. Only after all first type of P frames have been extracted, can the second type of P frames be extracted.
在一种可能的实施方式中,为了对GOP序列内的P帧进行抽帧,可以划分多个抽样比例,该抽样比例用于表示对多少P帧进行抽帧,例如,抽样比例为x时,表示对所有P帧中的x进行抽帧,不同抽样比例表示不同抽样方式。In a possible implementation, in order to extract frames from P frames in a GOP sequence, multiple sampling ratios can be divided, and the sampling ratio is used to indicate how many P frames to extract. For example, when the sampling ratio is x, Indicates that x in all P frames is sampled, and different sampling ratios represent different sampling methods.
比如说,可以划分2个抽样比例,这2个抽样比例记为第一抽样比例和第二抽样比例,且第一抽样比例小于第二抽样比例。针对第一抽样比例,可以对所有第一类P帧或部分第一类P帧进行抽帧;针对第二抽样比例,可以对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧。For example, two sampling proportions can be divided. These two sampling proportions are recorded as the first sampling proportion and the second sampling proportion, and the first sampling proportion is smaller than the second sampling proportion. For the first sampling ratio, frame extraction can be performed on all P frames of the first type or part of the P frames of the first type; for the second sampling ratio, frames can be extracted on all P frames of the first type, and on all P frames of the second type The frame or part of the second type P frame is extracted.
又例如,可以划分3个抽样比例,这3个抽样比例记为第一抽样比例、第二抽样比例和第三抽样比例,第一抽样比例小于第二抽样比例,第二抽样比例小于第三抽样比例。针对第一抽样比例,可以对部分第一类P帧进行抽帧;针对第二抽样比例,可以对所有第一类P帧进行抽帧;针对第三抽样比例,可以对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧。For another example, three sampling proportions can be divided. These three sampling proportions are recorded as the first sampling proportion, the second sampling proportion and the third sampling proportion. The first sampling proportion is smaller than the second sampling proportion, and the second sampling proportion is smaller than the third sampling proportion. Proportion. For the first sampling ratio, some P frames of the first type can be extracted; for the second sampling ratio, all P frames of the first type can be extracted; for the third sampling ratio, all P frames of the first type can be extracted Perform frame extraction, and perform frame extraction on all Type II P frames or part of Type II P frames.
又例如,可以划分4个抽样比例,记为第一抽样比例、第二抽样比例、第三抽样比例和第四抽样比例,第一抽样比例小于第二抽样比例,第二抽样比例小于第三抽样比例,第三抽样比例小于第四抽样比例。针对第一抽样比例,对部分第一类P帧进行抽帧;针对第二抽样比例,对所有第一类P帧进行抽帧;针对第三抽样比例,对所有第一类P帧进行抽帧,对部分第二类P帧进行抽帧;针对第四抽样比例,对所有第一类P帧进行抽帧,对所有第二类P帧抽帧。For another example, 4 sampling proportions can be divided, recorded as the first sampling proportion, the second sampling proportion, the third sampling proportion and the fourth sampling proportion. The first sampling proportion is smaller than the second sampling proportion, and the second sampling proportion is smaller than the third sampling proportion. Proportion, the third sampling proportion is smaller than the fourth sampling proportion. For the first sampling ratio, frame extraction is performed on some P frames of the first type; for the second sampling ratio, frames are extracted on all P frames of the first type; for the third sampling ratio, frames are extracted on all P frames of the first type , extract frames for some P-frames of the second type; for the fourth sampling ratio, extract frames for all P-frames of the first type, and extract frames for all P-frames of the second type.
当然,上述只是抽样比例的划分示例,对此不做限制,可以划分任意数量的抽样比例,为了方便描述,后续以划分2个或3个抽样比例为例进行说明。Of course, the above is just an example of the division of sampling proportions, and there is no limit to this. Any number of sampling proportions can be divided. For convenience of description, the following explanation will be based on dividing 2 or 3 sampling proportions as an example.
示例性的,在划分第一抽样比例、第二抽样比例和第三抽样比例的基础上,若需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧;若需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧;若需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,对所有第二类P帧或部分第二类P帧进行抽帧。For example, on the basis of dividing the first sampling ratio, the second sampling ratio and the third sampling ratio, if it is necessary to use the first sampling ratio to extract the P frames in the GOP sequence, then some of the first type P frames Perform frame extraction; if it is necessary to use the second sampling ratio to extract frames from P frames in the GOP sequence, then extract frames from all first-type P frames; if it is necessary to use the third sampling ratio to extract P frames within the GOP sequence frames, then extract frames for all P-frames of the first type, and extract frames for all P-frames of the second type or part of the P-frames of the second type.
假设第一类P帧的总数量占P帧总数量的x1,第二类P帧的总数量占P帧总数量的x2,x1与x2之和为1,那么,第一抽样比例小于x1,第二抽样比例小于或者等于x1,以第二抽样比例是x1为例,第三抽样比例小于或者等于x1+x2。参见图3A和图3B所示,x1为0.75,x2为0.25,在此基础上,若抽样比例小于或者等于0.5,则可以确定抽样比例是第一抽样比例,若抽样比例大于0.5,且小于或者等于0.75,则可以确定抽样比例是第二抽样比例,若抽样比例大于0.75,且小于或者等于1,则可以确定抽样比例是第三抽样比例。Assume that the total number of P frames of the first type accounts for x1 of the total number of P frames, and the total number of P frames of the second type accounts for x2 of the total number of P frames. The sum of x1 and x2 is 1, then the first sampling ratio is less than x1, The second sampling proportion is less than or equal to x1. Taking the second sampling proportion as x1 as an example, the third sampling proportion is less than or equal to x1+x2. Referring to Figure 3A and Figure 3B, x1 is 0.75 and x2 is 0.25. On this basis, if the sampling proportion is less than or equal to 0.5, it can be determined that the sampling proportion is the first sampling proportion. If the sampling proportion is greater than 0.5, and less than or If equal to 0.75, it can be determined that the sampling proportion is the second sampling proportion. If the sampling proportion is greater than 0.75 and less than or equal to 1, it can be determined that the sampling proportion is the third sampling proportion.
综上可以看出,在对P帧进行抽帧时,优先对第一类P帧的全部或局部进行抽帧,第一类P帧全部被抽帧后,对第二类P帧的全部或局部进行抽帧。在对第二类P帧的局部进行抽帧时,保留前面的第二类P帧,对后面的第二类P帧进行抽帧,如对第k(大于1)个第二类P帧之后的所有第二类P帧进行抽帧。In summary, it can be seen that when extracting P frames, priority is given to extracting all or part of the P frames of the first type. After all P frames of the first type are extracted, all or part of the P frames of the second type are extracted. Frame extraction is performed locally. When extracting a part of the second type P frame, the previous second type P frame is retained, and the following second type P frame is extracted, such as after the kth (greater than 1) second type P frame. All second type P frames are extracted.
参见图4A所示,若确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧,在该情况下,第一抽样比例小于或等于0.5,以第一抽样比例是0.5为例,需要对两个第二类P帧之间的2个第一类P帧进行抽帧,即两个第二类P帧之间保留1个第一类P帧。比如说,将两个第二类P帧之间的3个第一类P帧,按照一个丢弃,一个保留,一个丢弃的策略进行抽帧。参见图4B所示,若确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,在该情况下,第二抽样比例小于或者等于0.75,且大于0.5。参见图4C所示,若确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,并对所有第二类P帧进行抽帧,在该情况下,第三抽样比例小于或者等于1,且大于0.75。Referring to Figure 4A, if it is determined that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then some of the first type P frames will be extracted. In this case, the first sampling ratio is less than or equal to 0.5 , taking the first sampling ratio as 0.5 as an example, two first-category P frames need to be extracted between two second-category P frames, that is, one first-category P frame is retained between two second-category P frames. P frame. For example, three first-category P frames between two second-category P frames are extracted according to the strategy of discarding one, retaining one, and discarding one. Referring to Figure 4B, if it is determined that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all first type P frames will be extracted. In this case, the second sampling ratio is less than or equal to 0.75 , and greater than 0.5. Referring to Figure 4C, if it is determined that the third sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then all first type P frames can be extracted, and all second type P frames can be extracted, In this case, the third sampling ratio is less than or equal to 1 and greater than 0.75.
参见图4A所示,一个GOP序列可以实现1/2抽帧,当1/2抽帧无法满足业务需求时,参见图4B所示,一个
GOP序列可以实现3/4抽帧,当3/4抽帧也无法满足业务需求时,参见图4C所示,一个GOP序列可以实现完全抽帧。As shown in Figure 4A, a GOP sequence can achieve 1/2 frame extraction. When 1/2 frame extraction cannot meet business requirements, as shown in Figure 4B, a The GOP sequence can achieve 3/4 frame extraction. When 3/4 frame extraction cannot meet the business requirements, as shown in Figure 4C, a GOP sequence can achieve complete frame extraction.
示例性的,在划分第一抽样比例和第二抽样比例的基础上,若确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧;若确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧。For example, on the basis of dividing the first sampling ratio and the second sampling ratio, if it is determined that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames can be extracted. ; If it is determined that the second sampling ratio needs to be used to extract frames from P frames in the GOP sequence, then extract frames from all first-type P frames, and extract frames from all second-type P frames or part of second-type P frames. .
假设第一类P帧的总数量占P帧总数量的x1,第二类P帧的总数量占P帧总数量的x2,x1与x2之和为1,那么,第一抽样比例小于或等于x1,第二抽样比例小于或等于x1+x2。参见图3A和图3B所示,x1为0.75,x2为0.25,在此基础上,若抽样比例小于或等于0.75,则确定抽样比例是第一抽样比例,若抽样比例大于0.75,且小于或等于1,则确定抽样比例是第二抽样比例。Assume that the total number of P frames of the first type accounts for x1 of the total number of P frames, the total number of P frames of the second type accounts for x2 of the total number of P frames, and the sum of x1 and x2 is 1, then the first sampling ratio is less than or equal to x1, the second sampling proportion is less than or equal to x1+x2. Referring to Figure 3A and Figure 3B, x1 is 0.75 and x2 is 0.25. On this basis, if the sampling proportion is less than or equal to 0.75, then the sampling proportion is determined to be the first sampling proportion. If the sampling proportion is greater than 0.75 and less than or equal to 1, then the sampling proportion is determined to be the second sampling proportion.
参见图4B所示,若确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,在该情况下,第一抽样比例小于或者等于0.75。参见图4C所示,若确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,并对所有第二类P帧进行抽帧,在该情况下,第二抽样比例小于或者等于1,且大于0.75。Referring to Figure 4B, if it is determined that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames can be extracted. In this case, the first sampling ratio is less than or equal to 0.75. Referring to Figure 4C, if it is determined that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames can be extracted, and all the second type P frames can be extracted, In this case, the second sampling ratio is less than or equal to 1 and greater than 0.75.
参见图4B所示,一个GOP序列可以实现3/4抽帧,当3/4抽帧也无法满足业务需求时,参见图4C所示,一个GOP序列可以实现完全抽帧。As shown in Figure 4B, a GOP sequence can achieve 3/4 frame extraction. When 3/4 frame extraction cannot meet business requirements, as shown in Figure 4C, a GOP sequence can achieve complete frame extraction.
在一种可能的实施方式中,在划分第一抽样比例、第二抽样比例和第三抽样比例的基础上,可以基于业务信息确定GOP序列对应的抽样比例,比如说,基于业务信息确定采用第一抽样比例对GOP序列内的P帧进行抽帧,或者,基于业务信息确定采用第二抽样比例对GOP序列内的P帧进行抽帧,或者,基于业务信息确定采用第三抽样比例对GOP序列内的P帧进行抽帧。In a possible implementation, on the basis of dividing the first sampling proportion, the second sampling proportion and the third sampling proportion, the sampling proportion corresponding to the GOP sequence can be determined based on the business information. For example, the sampling proportion corresponding to the GOP sequence can be determined based on the business information. A sampling ratio is used to extract frames from the P frames in the GOP sequence, or a second sampling ratio is determined based on the service information to extract frames from the P frames in the GOP sequence, or a third sampling ratio is determined based on the service information to extract the frames from the GOP sequence. The P frames within are extracted.
若采用第一抽样比例对GOP序列内的P帧进行抽帧时,能够满足业务信息对应的业务需求,如对GOP序列抽取50%的P帧能够满足业务需求,则基于业务信息确定采用第一抽样比例。若采用第一抽样比例无法满足业务需求,但采用第二抽样比例对GOP序列内的P帧进行抽帧时,能够满足业务信息对应的业务需求,即对GOP序列抽取75%的P帧能够满足业务需求,则基于业务信息确定采用第二抽样比例。若采用第一抽样比例无法满足业务需求,采用第二抽样比例也无法满足业务需求,则基于业务信息确定采用第三抽样比例。If the first sampling ratio is used to extract P frames in the GOP sequence, the service requirements corresponding to the service information can be met. For example, if 50% of the P frames in the GOP sequence are extracted to meet the service requirements, then the first sampling ratio is determined based on the service information. Sampling proportion. If the first sampling ratio cannot meet the business requirements, but the second sampling ratio is used to extract P frames within the GOP sequence, the business requirements corresponding to the service information can be met. That is, extracting 75% of the P frames from the GOP sequence can meet the requirements. For business needs, the second sampling ratio is determined based on business information. If the first sampling ratio cannot meet the business needs, and the second sampling ratio cannot meet the business needs, the third sampling ratio will be determined based on the business information.
在另一种可能的实施方式中,在划分第一抽样比例和第二抽样比例的基础上,可以基于业务信息确定GOP序列对应的抽样比例,如基于业务信息确定采用第一抽样比例对GOP序列内的P帧进行抽帧,或者,基于业务信息确定采用第二抽样比例对GOP序列内的P帧进行抽帧。例如,若采用第一抽样比例对GOP序列内的P帧进行抽帧时,能够满足业务信息对应的业务需求,即对GOP序列抽取75%的P帧能满足业务需求,则基于业务信息确定采用第一抽样比例。若采用第一抽样比例无法满足业务需求,基于业务信息确定采用第二抽样比例。In another possible implementation, on the basis of dividing the first sampling ratio and the second sampling ratio, the sampling ratio corresponding to the GOP sequence can be determined based on the business information. For example, the first sampling ratio is used to determine the GOP sequence based on the business information. The P frames within the GOP sequence are extracted, or the second sampling ratio is determined based on the service information to extract the P frames within the GOP sequence. For example, if the first sampling ratio is used to extract P frames within the GOP sequence, the service requirements corresponding to the service information can be met, that is, extracting 75% of the P frames from the GOP sequence can meet the service requirements, then the selection method is determined based on the service information. First sampling ratio. If the first sampling ratio cannot meet business needs, the second sampling ratio will be determined based on business information.
在划分第一抽样比例、第二抽样比例和第三抽样比例的基础上,以下结合业务信息的两个具体应用场景,对上述抽帧过程进行说明。当然,在划分第一抽样比例和第二抽样比例的基础上,其实现方式可以类似,本文不再赘述。On the basis of dividing the first sampling ratio, the second sampling ratio, and the third sampling ratio, the above frame extraction process will be explained below in combination with two specific application scenarios of business information. Of course, on the basis of dividing the first sampling ratio and the second sampling ratio, the implementation method can be similar, and this article will not go into details.
应用场景1:业务信息可以包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,基于该分辨率、该帧率和该解码能力确定是否需要对GOP序列内的P帧进行抽帧。若否,则不对GOP序列内的P帧进行抽帧。若是,则基于该分辨率、该帧率和该解码能力确定GOP序列对应的抽样比例。例如,GOP序列对应的抽样比例可以为第一抽样比例、或第二抽样比例、或第三抽样比例。或者,基于该分辨率、该帧率和该解码能力确定GOP序列对应的抽样比例,如第一抽样比例、或第二抽样比例。Application scenario 1: The service information may include the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoder. Based on the resolution, the frame rate, and the decoding capability, it is determined whether it is necessary to modify the P in the GOP sequence. Frame is extracted. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability. For example, the sampling ratio corresponding to the GOP sequence may be the first sampling ratio, the second sampling ratio, or the third sampling ratio. Alternatively, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability, such as the first sampling ratio or the second sampling ratio.
比如说,假设NVR设备具有4*1080P30的解码能力,即NVR设备一秒钟可以解码4*30帧的1920*1080的图像,超过该解码能力的图像就无法完成解码。For example, assuming that the NVR device has a decoding capability of 4*1080P30, that is, the NVR device can decode 4*30 frames of 1920*1080 images in one second. Images exceeding this decoding capability cannot be decoded.
a、若GOP序列对应的是4*30帧的图像(分辨率为1920*1080,帧率为4*30帧),则基于分辨率、帧率和解码能力确定不需要对GOP序列内的P帧进行抽帧,即分辨率、帧率和解码能力匹配,因此,NVR设备不对GOP序列内的P帧进行抽帧,一秒钟可以解码4*30帧的图像,并通过4路显示1080P30的图像,参见图5A所示。a. If the GOP sequence corresponds to an image of 4*30 frames (the resolution is 1920*1080, the frame rate is 4*30 frames), then based on the resolution, frame rate and decoding capability, it is determined that there is no need to modify the P in the GOP sequence Frames are extracted, that is, the resolution, frame rate and decoding capabilities match. Therefore, the NVR device does not extract frames within the GOP sequence. It can decode 4*30 frames of images in one second and display 1080P30 through 4 channels. For an image, see Figure 5A.
b、若GOP序列对应的是8*30帧的图像(分辨率为1920*1080,帧率为8*30帧),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即,分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,NVR设备确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第一抽样比例(即1/2抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过8路显示1080P15的图像,参见图5B所示,显然,8路的15帧对应的是4*30帧。b. If the GOP sequence corresponds to an image of 8*30 frames (the resolution is 1920*1080, the frame rate is 8*30 frames), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be To perform frame extraction, that is, the resolution, frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel of image is extracted according to the first sampling ratio (i.e. 1/2 frame extraction method). When 4*30 frames of images can be decoded in one second, 1080P15 images can be displayed through 8 channels, as shown in Figure 5B , obviously, the 15 frames of 8 channels correspond to 4*30 frames.
显然,当解码路数增加时,如从4路变为8路,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求。Obviously, when the number of decoding channels increases, such as from 4 channels to 8 channels, the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel to meet business needs.
c、若GOP序列对应的是4*60帧的图像(分辨率为1920*1080,帧率为4*60帧),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即,分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,NVR设备确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第一抽样比例(即1/2抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过4路显示1080P30的图像,参见图5C所示,显然,4*60帧被1/2抽帧之后剩余4*30帧。
c. If the GOP sequence corresponds to an image of 4*60 frames (the resolution is 1920*1080, the frame rate is 4*60 frames), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be To perform frame extraction, that is, the resolution, frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel of image is extracted according to the first sampling ratio (that is, 1/2 frame extraction method). When 4*30 frames of images can be decoded in one second, 1080P30 images can be displayed through 4 channels, as shown in Figure 5C , obviously, after 4*60 frames are extracted by 1/2, 4*30 frames remain.
显然,当倍速回放时,如从30帧图像变为60帧图像,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求,显然,30帧2倍速相当于每秒60帧,按照1/2抽帧则等于每秒30帧。Obviously, when playing back at double speed, such as changing from a 30-frame image to a 60-frame image, you can extract frames for each image so that the decoding capability can support decoding images of this resolution and frame rate to meet business needs. Obviously, 30 frames at 2x speed is equivalent to 60 frames per second, and 1/2 frame sampling is equal to 30 frames per second.
d、若GOP序列对应的是12*30帧的图像(分辨率为1920*1080,帧率为12*30帧),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即,分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,NVR设备确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第二抽样比例(即3/4抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过12路显示1080P10的图像,参见图5D所示,显然,12路的10帧对应的是4*30帧。d. If the GOP sequence corresponds to an image of 12*30 frames (the resolution is 1920*1080 and the frame rate is 12*30 frames), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be To perform frame extraction, that is, the resolution, frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel image is extracted according to the second sampling ratio (ie, 3/4 frame extraction method). When 4*30 frames of images can be decoded in one second, 1080P10 images can be displayed through 12 channels, as shown in Figure 5D , obviously, 10 frames of 12 channels correspond to 4*30 frames.
显然,当解码路数增加时,如从4路变为12路,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求。Obviously, when the number of decoding channels increases, such as from 4 channels to 12 channels, the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
e、若GOP序列对应的是16*30帧的图像(分辨率为1920*1080,帧率为16*30帧),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即,分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,NVR设备确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第三抽样比例(即4/4抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过16路显示1080P7.5的图像,参见图5E所示,显然,16路的7.5帧对应的是4*30帧。e. If the GOP sequence corresponds to an image of 16*30 frames (the resolution is 1920*1080 and the frame rate is 16*30 frames), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be To perform frame extraction, that is, the resolution, frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, the NVR device determines that it is necessary to extract frames from the P frames in the GOP sequence. And each channel of image is extracted according to the third sampling ratio (i.e. 4/4 frame extraction method). When 4*30 frames of images can be decoded in one second, 1080P7.5 images can be displayed through 16 channels, see Figure 5E As shown in the figure, obviously, the 7.5 frames of 16 channels correspond to 4*30 frames.
显然,当解码路数增加时,如从4路变为16路,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求。Obviously, when the number of decoding channels increases, such as from 4 channels to 16 channels, the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
综上可以看出,当多倍速和/或多路数的条件任意变化时,可以按照第一抽样比例、或第二抽样比例、或第三抽样比例来抽帧,从而满足业务需求。In summary, it can be seen that when the conditions of multiple speeds and/or the number of multiple channels change arbitrarily, frames can be extracted according to the first sampling ratio, the second sampling ratio, or the third sampling ratio to meet business needs.
应用场景2:业务信息可以包括发送端与接收端之间的目标网络对应的网络质量,基于该网络质量确定是否需要对GOP序列内的P帧进行抽帧。若否,则不对GOP序列内的P帧进行抽帧。若是,则基于该网络质量确定GOP序列对应的抽样比例,例如,GOP序列对应的抽样比例可以为第一抽样比例、或第二抽样比例、或第三抽样比例。或者,基于该网络质量确定GOP序列对应的抽样比例,GOP序列对应的抽样比例可以为第一抽样比例、或第二抽样比例。Application scenario 2: The service information may include the network quality corresponding to the target network between the sending end and the receiving end. Based on the network quality, it is determined whether the P frames in the GOP sequence need to be extracted. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality. For example, the sampling ratio corresponding to the GOP sequence may be the first sampling ratio, the second sampling ratio, or the third sampling ratio. Alternatively, the sampling ratio corresponding to the GOP sequence is determined based on the network quality. The sampling ratio corresponding to the GOP sequence may be the first sampling ratio or the second sampling ratio.
比如说,发送端向接收端发送GOP序列时,需要检测用于承载GOP序列的目标网络对应的网络质量(如抖动、丢包率等),对此检测方式不做限制。For example, when the sender sends a GOP sequence to the receiver, it needs to detect the network quality (such as jitter, packet loss rate, etc.) corresponding to the target network used to carry the GOP sequence. There is no restriction on this detection method.
在一种可能的实施方式中,可以设计4个级别的网络质量,若目标网络对应的网络质量是第1级别(即最优级别)的网络质量,则确定不对GOP序列内的P帧进行抽帧。若目标网络对应的网络质量是第2级别的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第一抽样比例,如1/2抽帧的方式。若目标网络对应的网络质量是第3级别的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第二抽样比例,如3/4抽帧的方式。若目标网络对应的网络质量是第4级别(即最差级别)的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第三抽样比例,如4/4抽帧的方式。In a possible implementation, four levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (ie, the optimal level), it is determined not to extract the P frames in the GOP sequence. frame. If the network quality corresponding to the target network is level 2 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio, such as 1/2 frame extraction. If the network quality corresponding to the target network is level 3 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the second sampling ratio, such as 3/4 frame extraction. If the network quality corresponding to the target network is the network quality of level 4 (i.e., the worst level), it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the third sampling ratio, such as 4/4 frame extraction. Way.
在另一种可能的实施方式中,可以设计2个级别的网络质量,若目标网络对应的网络质量是第1级别(即最优级别)的网络质量,则确定不对GOP序列内的P帧进行抽帧。若目标网络对应的网络质量是第2级别的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第一抽样比例,在GOP序列的传输过程中,若网络质量仍然是第2级别的网络质量,则将抽样比例调整为第二抽样比例,在GOP序列的传输过程中,若网络质量仍然是第2级别的网络质量,则将抽样比例调整为第三抽样比例。此外,在GOP序列的传输过程中,若网络质量恢复为第1级别的网络质量,则不对GOP序列内的P帧进行抽帧。In another possible implementation, two levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (i.e., the optimal level), it is determined that the P frames in the GOP sequence are not to be processed. Frame extraction. If the network quality corresponding to the target network is the second level network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio. During the transmission process of the GOP sequence, if the network quality is still If the network quality is Level 2, the sampling ratio will be adjusted to the second sampling ratio. During the transmission process of the GOP sequence, if the network quality is still Level 2, the sampling ratio will be adjusted to the third sampling ratio. In addition, during the transmission process of the GOP sequence, if the network quality returns to the first level of network quality, the P frames in the GOP sequence will not be extracted.
当然,上述两个应用场景只是确定抽样比例的两个示例,还可以采用其它方式确定GOP序列对应的抽样比例,对此不做限制。例如,依据每帧大小来确定GOP序列对应的抽样比例,如帧大小小于第一门限值时,不对GOP序列内的P帧进行抽帧,帧大小大于第一门限值且小于第二门限值时,抽样比例是第一抽样比例,帧大小大于第二门限值且小于第三门限值时,抽样比例是第二抽样比例,帧大小大于第三门限值时,抽样比例是第三抽样比例。Of course, the above two application scenarios are just two examples of determining the sampling ratio. Other methods can also be used to determine the sampling ratio corresponding to the GOP sequence, and there are no restrictions on this. For example, the sampling ratio corresponding to the GOP sequence is determined based on the size of each frame. If the frame size is less than the first threshold, the P frames in the GOP sequence will not be sampled. The frame size is greater than the first threshold and less than the second threshold. limit, the sampling ratio is the first sampling ratio. When the frame size is greater than the second threshold and less than the third threshold, the sampling ratio is the second sampling ratio. When the frame size is greater than the third threshold, the sampling ratio is Third sampling ratio.
在一种可能的实施方式中,还可以将至少两个GOP序列组成一个图像序列集合,基于此,当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是该图像序列集合的首个GOP序列,则可以将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。在该实施方式中,若GOP序列不是图像序列集合的首个GOP序列,则可以将该GOP序列的第一帧称为关键P帧(即不再称为I帧),关键P帧的参考帧是前面最近的I帧。In a possible implementation, at least two GOP sequences can also be composed into an image sequence set. Based on this, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the The first GOP sequence of the image sequence set, then the I frame of the first GOP sequence can be used as the reference frame of the first frame of the GOP sequence. In this embodiment, if the GOP sequence is not the first GOP sequence in the image sequence set, the first frame of the GOP sequence can be called a key P frame (that is, it is no longer called an I frame), and the reference frame of the key P frame is the most recent I frame.
示例性的,对于图像序列集合来说,该图像序列集合可以包括至少一个关键P帧,即允许存在至少一个关键P帧,关键P帧用于取代I帧的位置,关键P帧只能参考离它最近的前面的I帧,且关键P帧的帧结构可以有效降低整体带宽。For example, for an image sequence set, the image sequence set may include at least one key P frame, that is, at least one key P frame is allowed to exist. The key P frame is used to replace the position of the I frame. The key P frame can only refer to the I frame. Its frame structure is the closest preceding I frame, and the key P frame can effectively reduce the overall bandwidth.
参见图6所示,是图像序列集合的示意图,该图像序列集合可以包括关键P帧。在I帧与关键P帧之间,可以存在第一类P帧和第二类P帧,第一类P帧和第二类P帧的结构关系可以参见上述实施例。在相邻两个关键P帧之间,可以存在第一类P帧和第二类P帧,第一类P帧和第二类P帧的结构关系可以参见上述实施例。在此基础上,在对P帧进行抽帧时,可以对第一类P帧进行抽帧,可以对第二类P帧进行抽帧,但是不能对关键P帧进行抽帧。
Referring to FIG. 6 , which is a schematic diagram of an image sequence set, the image sequence set may include key P frames. Between the I frame and the key P frame, there may be a first type of P frame and a second type of P frame. For the structural relationship between the first type of P frame and the second type of P frame, please refer to the above embodiment. Between two adjacent key P frames, there may be a first type of P frame and a second type of P frame. For the structural relationship between the first type of P frame and the second type of P frame, please refer to the above embodiment. On this basis, when extracting P frames, frames of the first type of P frames can be extracted, and frames of the second type of P frames can be extracted, but frames of key P frames cannot be extracted.
由以上技术方案可见,本申请实施例中,可以将GOP序列内的所有P帧划分为第一类P帧和第二类P帧,第一类P帧不能够作为参考帧,第二类P帧能够作为第一类P帧的参考帧、第二类P帧也能够作为第二类P帧的参考帧,在此基础上,可以对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧。上述方式提供一种新型视频帧序列,该视频帧序列包括不同类型的P帧,即第一类P帧和第二类P帧,在视频帧序列中,可以按照一定规律进行丢帧,既能保证视频帧序列按照顺序播放,具有按照规则间叉性丢弃P帧而不影响观看的特点,又可以在一些特殊场景下丢弃部分P帧以达到节省带宽的目的,该视频帧序列在解码、网络传输、存储中具有更好的使用前景,实现解码倍增路数、低带宽传输,低码率存储等特点,在弱网环境下也能够解决帧丢失后长期黑屏花屏等问题。丢帧策略可以动态实施,根据现场情况任意调整丢帧策略,在不影响解码完整性的情况下,灵活而有效的降低消耗。该视频帧序列可以保证抽帧的灵活性和图像质量的稳定性,可以有效改善客户体验。可以在解码过程中进行一定规则的丢帧以实现1/2帧、3/4帧等方式的解码。或者,在网络传输中实现1/2帧、3/4帧的低带宽传输,这种丢帧策略可以动态实施,根据现场情况任意调整策略,在不影响解码完整性的情况下,灵活而有效的降低消耗。It can be seen from the above technical solution that in the embodiment of the present application, all P frames in the GOP sequence can be divided into first type P frames and second type P frames. The first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame. The frame can be used as the reference frame of the first type of P frame, and the second type of P frame can also be used as the reference frame of the second type of P frame. On this basis, the first type of P frame can be extracted, or the first type of P frame can be extracted. Class P frames and second class P frames are extracted. The above method provides a new type of video frame sequence. The video frame sequence includes different types of P frames, namely the first type of P frame and the second type of P frame. In the video frame sequence, frames can be dropped according to certain rules, which can It ensures that the video frame sequence is played in order, and has the characteristics of discarding P frames according to the rules without affecting viewing. It can also discard some P frames in some special scenarios to achieve the purpose of saving bandwidth. This video frame sequence is used in decoding and network It has better application prospects in transmission and storage, realizing features such as multiplied decoding channels, low-bandwidth transmission, and low bit rate storage. It can also solve problems such as long-term black screens and blurred screens after frame loss in weak network environments. The frame loss strategy can be dynamically implemented and arbitrarily adjusted according to on-site conditions, flexibly and effectively reducing consumption without affecting decoding integrity. This video frame sequence can ensure the flexibility of frame extraction and the stability of image quality, and can effectively improve customer experience. Certain rules of frame dropping can be performed during the decoding process to achieve decoding of 1/2 frame, 3/4 frame, etc. Or, realize low-bandwidth transmission of 1/2 frame and 3/4 frame in network transmission. This frame loss strategy can be dynamically implemented and the strategy can be adjusted arbitrarily according to the on-site situation. It is flexible and effective without affecting the decoding integrity. reduce consumption.
本申请实施例中提出一种图像处理方法,该方法可以应用于任意设备,参见图7所示,为该图像处理方法的流程示意图,该方法可以包括:The embodiment of the present application proposes an image processing method, which can be applied to any device. See Figure 7, which is a schematic flow chart of the image processing method. The method may include:
步骤701、将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;示例性的,该第一类P帧不能够作为参考帧,该第二类P帧只能够作为第一类P帧的参考帧,该第三类P帧能够作为第一类P帧的参考帧、且能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧。Step 701: Divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; for example, the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame. The P frame of the first type can only be used as a reference frame of the P frame of the first type. The P frame of the third type can be used as the reference frame of the P frame of the first type, and can be used as the reference frame of the P frame of the second type, and can be used as the reference frame of the P frame of the third type. The reference frame of the P frame.
示例性的,针对每个GOP序列来说,该GOP序列可以包括I帧和多个P帧,本申请实施例中,可以将该GOP序列内的所有P帧区分为3种类型的P帧,将这3种类型的P帧称为第一类P帧、第二类P帧和第三类P帧。For example, for each GOP sequence, the GOP sequence may include an I frame and multiple P frames. In this embodiment of the present application, all P frames within the GOP sequence may be distinguished into three types of P frames. These three types of P frames are called first type P frames, second type P frames and third type P frames.
其中,第一类P帧也可以称为普通P帧,第一类P帧不能作为其它帧的参考帧。第一类P帧可以将其它帧作为本第一类P帧的参考帧,比如说,第一类P帧可以将第二类P帧作为参考帧,第一类P帧可以将第三类P帧作为参考帧,第一类P帧也可以将GOP序列的I帧作为参考帧。但是,第一类P帧不可以将第一类P帧(即除本第一类P帧之外的其它第一类P帧)作为参考帧。Among them, the first type of P frame can also be called a normal P frame, and the first type of P frame cannot be used as a reference frame for other frames. The first type P frame can use other frames as reference frames of the first type P frame. For example, the first type P frame can use the second type P frame as a reference frame, and the first type P frame can use the third type P frame as a reference frame. frame as a reference frame, the first type of P frame can also use the I frame of the GOP sequence as a reference frame. However, the first type P frame cannot use the first type P frame (that is, other first type P frames except the first type P frame) as a reference frame.
其中,第二类P帧也可以称为2X类型P帧,第二类P帧只能够作为第一类P帧的参考帧,但是不能作为第二类P帧的参考帧,也不能作为第三类P帧的参考帧。第二类P帧可以将其它帧作为本第二类P帧的参考帧,比如说,第二类P帧可以将第三类P帧作为参考帧,第二类P帧也可以将GOP序列的I帧作为参考帧。但是,第二类P帧不可以将第二类P帧(即除本第二类P帧之外的其它第二类P帧)作为参考帧,第二类P帧也不能将第一类P帧作为参考帧。Among them, the second type of P frame can also be called 2X type P frame. The second type of P frame can only be used as a reference frame of the first type of P frame, but cannot be used as a reference frame of the second type of P frame, nor can it be used as a reference frame of the third type of P frame. Reference frame for P-like frames. The second type of P frame can use other frames as reference frames of the second type of P frame. For example, the second type of P frame can use the third type of P frame as a reference frame. The second type of P frame can also use the reference frame of the GOP sequence. I frames serve as reference frames. However, the second type of P frame cannot use the second type of P frame (that is, other second type of P frame except the second type of P frame) as a reference frame, and the second type of P frame cannot use the first type of P frame as a reference frame. frame as a reference frame.
其中,第三类P帧也可以称为4X类型P帧,第三类P帧能够作为第一类P帧的参考帧、且能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧。第三类P帧可以将其它帧作为本第三类P帧的参考帧,比如说,第三类P帧可以将第三类P帧(即除本第三类P帧之外的其它第三类P帧)作为参考帧,第三类P帧也可以将GOP序列的I帧作为参考帧。但是,第三类P帧不可以将第二类P帧作为参考帧,第三类P帧也不能将第一类P帧作为参考帧。Among them, the third type of P frame can also be called a 4X type P frame. The third type of P frame can be used as a reference frame of the first type of P frame, and can be used as a reference frame of the second type of P frame, and can be used as a reference frame of the third type of P frame. The reference frame of the P frame. The third type P frame can use other frames as reference frames of the third type P frame. For example, the third type P frame can use the third type P frame (that is, other third type P frames except the third type P frame). Class P frame) as a reference frame, the third class P frame can also use the I frame of the GOP sequence as a reference frame. However, the third type P frame cannot use the second type P frame as a reference frame, and the third type P frame cannot use the first type P frame as a reference frame.
在一种可能的实施方式中,在将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧时,可以采用任意划分方式,本实施例对此划分方式不做限制,只要能够同时存在第一类P帧、第二类P帧和第三类P帧即可。示例性的,可以基于GOP序列内的各P帧之间的位置排序关系,将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧,即划分方式依据是位置排序关系。位置排序关系是指P帧是GOP序列内的哪一P帧,如第一个P帧、第二个P帧、第三个P帧等,用于表示处于GOP序列的哪个位置。In a possible implementation, when dividing all P frames in the GOP sequence into the first type of P frames, the second type of P frames and the third type of P frames, any division method can be used. In this embodiment, There is no restriction on the division method, as long as the first type of P frame, the second type of P frame and the third type of P frame can exist at the same time. For example, all P frames in the GOP sequence can be divided into first type P frames, second type P frames and third type P frames based on the position ordering relationship between each P frame in the GOP sequence, that is, divided The method is based on the position ordering relationship. The position ordering relationship refers to which P frame within the GOP sequence the P frame is, such as the first P frame, the second P frame, the third P frame, etc., which is used to indicate which position in the GOP sequence it is in.
例如,第一个P帧是第一类P帧,第二个P帧是第二类P帧,第三个P帧是第三类P帧,第四个P帧是第一类P帧,第五个P帧是第二类P帧,第六个P帧是第三类P帧,以此类推。例如,第一个P帧和第二个P帧是第一类P帧,第三个P帧和第四个P帧是第二类P帧,第五个P帧和第六个P帧是第三类P帧,以此类推。又例如,第一个P帧是第一类P帧,第二个P帧是第二类P帧,第三个P帧是第一类P帧,第四个P帧是第三类P帧,第五个P帧是第一类P帧,第六个P帧是第二类P帧,以此类推。例如,第一个P帧和第二个P帧是第一类P帧,第三个P帧是第二类P帧,第四个P帧是第三类P帧,第五个P帧和第六个P帧是第一类P帧,以此类推。当然,上述划分方式只是几个示例。For example, the first P frame is a P frame of the first type, the second P frame is a P frame of the second type, the third P frame is a P frame of the third type, and the fourth P frame is a P frame of the first type. The fifth P frame is the second type of P frame, the sixth P frame is the third type of P frame, and so on. For example, the first P frame and the second P frame are P frames of the first type, the third P frame and the fourth P frame are P frames of the second type, and the fifth P frame and the sixth P frame are The third type of P frame, and so on. For another example, the first P frame is a P frame of the first type, the second P frame is a P frame of the second type, the third P frame is a P frame of the first type, and the fourth P frame is a P frame of the third type. , the fifth P frame is the first type of P frame, the sixth P frame is the second type of P frame, and so on. For example, the first P frame and the second P frame are the first type P frames, the third P frame is the second type P frame, the fourth P frame is the third type P frame, the fifth P frame and The sixth P frame is the first type of P frame, and so on. Of course, the above divisions are just a few examples.
示例性的,在将所有P帧划分为第一类P帧、第二类P帧和第三类P帧时,第一类P帧的数量与第二类P帧的数量可以相同,第一类P帧的数量与第二类P帧的数量可以不同。第一类P帧的数量与第三类P帧的数量可以相同,第一类P帧的数量与第三类P帧的数量可以不同。第二类P帧的数量与第三类P帧的数量可以相同,第二类P帧的数量与第三类P帧的数量可以不同。For example, when all P frames are divided into the first type of P frames, the second type of P frames and the third type of P frames, the number of the first type of P frames and the number of the second type of P frames may be the same. The number of P-type frames may be different from the number of P-frames of the second type. The number of P frames of the first type and the number of P frames of the third type may be the same, and the number of P frames of the first type and the number of P frames of the third type may be different. The number of P frames of the second type and the number of P frames of the third type may be the same, and the number of P frames of the second type and the number of P frames of the third type may be different.
示例性的,第一类P帧的数量可以大于第二类P帧的数量,第一类P帧的数量可以小于第二类P帧的数量。第一类P帧的数量可以大于第三类P帧的数量,第一类P帧的数量可以小于第三类P帧的数量。第二类P帧的数量可以大于第三类P帧的数量,第二类P帧的数量可以小于第三类P帧的数量。For example, the number of P frames of the first type may be greater than the number of P frames of the second type, and the number of P frames of the first type may be less than the number of P frames of the second type. The number of P frames of the first type may be greater than the number of P frames of the third type, and the number of P frames of the first type may be less than the number of P frames of the third type. The number of P frames of the second type may be greater than the number of P frames of the third type, and the number of P frames of the second type may be less than the number of P frames of the third type.
比如说,第一类P帧的数量大于第二类P帧的数量,第一类P帧的数量大于第三类P帧的数量,且第二类P帧的数量等于第三类P帧的数量。For example, the number of P frames of the first type is greater than the number of P frames of the second type, the number of P frames of the first type is greater than the number of P frames of the third type, and the number of P frames of the second type is equal to the number of P frames of the third type. quantity.
又例如,第二类P帧的数量等于第三类P帧的数量,且第一类P帧的数量大于或者等于第二类P帧的数量与第
三类P帧的数量之和。For another example, the number of P frames of the second type is equal to the number of P frames of the third type, and the number of P frames of the first type is greater than or equal to the number of P frames of the second type and the number of P frames of the third type. The sum of the number of P frames of the three types.
示例性的,在将所有P帧划分为第一类P帧、第二类P帧和第三类P帧时,第一类P帧、第二类P帧和第三类P帧可以交替出现,即两个第一类P帧不会连续出现,两个第二类P帧不会连续出现,两个第三类P帧不会连续出现。比如说,第一类P帧后面的可以是第二类P帧或第三类P帧,但不会是第一类P帧,第二类P帧后面的可以是第一类P帧或第三类P帧,但不会是第二类P帧,第三类P帧后面的可以是第一类P帧或第二类P帧,但不会是第三类P帧。For example, when all P frames are divided into the first type of P frames, the second type of P frames and the third type of P frames, the first type of P frames, the second type of P frames and the third type of P frames may appear alternately. , that is, two P frames of the first type will not appear continuously, two P frames of the second type will not appear continuously, and two P frames of the third type will not appear continuously. For example, the P frame of the first type may be followed by the P frame of the second type or the P frame of the third type, but it will not be the P frame of the first type. The P frame after the second type P frame may be the P frame of the first type or the P frame of the third type. The third type of P frame, but not the second type of P frame. The third type of P frame can be followed by the first type of P frame or the second type of P frame, but it will not be the third type of P frame.
比如说,第一类P帧后面的可以是第二类P帧或第三类P帧,第二类P帧后面的可以是第一类P帧,第三类P帧后面的可以是第一类P帧。For example, a P frame of the first type may be followed by a P frame of the second type or a P frame of a third type, a P frame of the second type may be followed by a P frame of the first type, and a P frame of the third type may be followed by a P frame of the first type. Class P frame.
示例性的,GOP序列的I帧后面可以是第一类P帧,GOP序列的I帧后面可以是第二类P帧,GOP序列的I帧后面可以是第三类P帧,对此不做限制。For example, the I frame of the GOP sequence may be followed by the P frame of the first type, the I frame of the GOP sequence may be followed by the P frame of the second type, and the I frame of the GOP sequence may be followed by the P frame of the third type. This is not done. limit.
比如说,GOP序列的I帧后面的第一个P帧是第一类P帧。For example, the first P frame after the I frame in the GOP sequence is the first type of P frame.
在一种可能的实施方式中,在将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧时,相邻两个第三类P帧之间可以存在两个第一类P帧和一个第二类P帧,且一个第二类P帧可以位于两个第一类P帧之间。此外,GOP序列的I帧(即第一帧)与第一个第三类P帧之间可以存在两个第一类P帧和一个第二类P帧,且这个第二类P帧可以位于这两个第一类P帧之间。In a possible implementation, when all P frames in the GOP sequence are divided into first type P frames, second type P frames and third type P frames, between two adjacent third type P frames There may be two first-type P frames and one second-type P frame, and a second-type P frame may be located between two first-type P frames. In addition, there may be two first-type P frames and one second-type P frame between the I frame (i.e., the first frame) of the GOP sequence and the first third type P frame, and this second type P frame may be located between these two first-class P frames.
当然,上述划分方式只是一个示例,对此不做限制,比如说,相邻两个第三类P帧之间可以存在三个第一类P帧和两个第二类P帧,且第二类P帧位于两个第一类P帧之间。又例如,相邻两个第三类P帧之间可以存在两个第一类P帧和三个第二类P帧,且第一类P帧位于两个第二类P帧之间。又例如,相邻两个第三类P帧之间可以存在两个第一类P帧和两个第二类P帧,第二类P帧位于两个第一类P帧之间,且第一类P帧位于两个第二类P帧之间。又例如,相邻两个第三类P帧之间可以存在三个第一类P帧和三个第二类P帧,第二类P帧位于两个第一类P帧之间,且第一类P帧位于两个第二类P帧之间。Of course, the above division method is just an example, and there is no limit to this. For example, there can be three first-type P frames and two second-type P frames between two adjacent third-type P frames, and the second type A class P frame is located between two first class P frames. For another example, there may be two first-type P frames and three second-type P frames between two adjacent third-type P frames, and the first-type P frame is located between two second-type P frames. For another example, there may be two P frames of the first type and two P frames of the second type between two adjacent P frames of the third type. The P frame of the second type is located between two P frames of the first type, and the P frame of the second type is located between the P frames of the second type. A P-frame of type 1 is located between two P-frames of type 2. For another example, there may be three P frames of the first type and three P frames of the second type between two adjacent P frames of the third type. The P frame of the second type is located between two P frames of the first type, and the P frame of the second type is located between two P frames of the first type. A P-frame of type 1 is located between two P-frames of type 2.
为了方便描述,本实施例中,以图8A所示的GOP序列为例,I帧后面的第一帧是第一类P帧,I帧与第一个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且第二类P帧位于两个第一类P帧之间。相邻两个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且第二类P帧位于两个第一类P帧之间。参见图8A所示,GOP序列内的各帧依次是:I帧、第一类P帧、第二类P帧、第一类P帧、第三类P帧、第一类P帧、第二类P帧、第一类P帧、第三类P帧、第一类P帧、第二类P帧、第一类P帧、第三类P帧,以此类推。For the convenience of description, in this embodiment, taking the GOP sequence shown in Figure 8A as an example, the first frame after the I frame is a first type P frame, and there are two types of P frames between the I frame and the first third type P frame. A P frame of the first type and a P frame of a second type, and the P frame of the second type is located between two P frames of the first type. There are two first-type P frames and one second-type P frame between two adjacent third-type P frames, and the second-type P frame is located between two first-type P frames. Referring to Figure 8A, the frames in the GOP sequence are: I frame, first type P frame, second type P frame, first type P frame, third type P frame, first type P frame, second type P frame. P frames of the first type, P frames of the third type, P frames of the first type, P frames of the second type, P frames of the first type, P frames of the third type, and so on.
在一种可能的实施方式中,基于“第一类P帧不作为参考帧,第二类P帧作为第一类P帧的参考帧,第三类P帧作为第一类P帧的参考帧、且作为第二类P帧的参考帧、且作为第三类P帧的参考帧”的特点,那么:针对每个第一类P帧,若该第一类P帧的前一帧不是第一类P帧,则将该第一类P帧的前一帧(可能是I帧、第二类P帧、或第三类P帧)作为该第一类P帧的参考帧。若该第一类P帧的前一帧是第一类P帧,则将该第一类P帧前面最近一个非第一类P帧(如I帧、第二类P帧、或第三类P帧)作为该第一类P帧的参考帧。In a possible implementation, based on "the first type of P frame is not used as a reference frame, the second type of P frame is used as the reference frame of the first type of P frame, and the third type of P frame is used as the reference frame of the first type of P frame. , and as the reference frame of the second type of P frame, and as the reference frame of the third type of P frame", then: for each first type of P frame, if the previous frame of the first type of P frame is not the first type of P frame, For a P frame of the first type, the frame preceding the P frame of the first type (which may be an I frame, a P frame of the second type, or a P frame of the third type) is used as the reference frame of the P frame of the first type. If the previous frame of the first type P frame is a first type P frame, then the nearest non-first type P frame (such as an I frame, a second type P frame, or a third type P frame) before the first type P frame is P frame) as the reference frame of the first type of P frame.
针对每个第二类P帧,若该第二类P帧前面存在第三类P帧,则将该第二类P帧前面最近一个第三类P帧作为该第二类P帧的参考帧。若该第二类P帧前面不存在第三类P帧,则将GOP序列的I帧作为该第二类P帧的参考帧。For each P frame of the second type, if there is a P frame of the third type before the P frame of the second type, the nearest P frame of the third type before the P frame of the second type is used as the reference frame of the P frame of the second type. . If there is no P frame of the third type before the P frame of the second type, the I frame of the GOP sequence is used as the reference frame of the P frame of the second type.
针对每个第三类P帧,若该第三类P帧前面存在第三类P帧,则将该第三类P帧前面最近一个第三类P帧作为该第三类P帧的参考帧。若该第三类P帧前面不存在第三类P帧,则将GOP序列的I帧作为该第三类P帧的参考帧。For each type 3 P frame, if there is a type 3 P frame before the type 3 P frame, then the latest type 3 P frame before the type 3 P frame is used as the reference frame of the type 3 P frame. . If there is no third type P frame before the third type P frame, the I frame of the GOP sequence is used as the reference frame of the third type P frame.
参见图8B所示,示出了各P帧与参考帧之间的关系。针对第一类P帧来说,第1个第一类P帧的参考帧是前面的I帧,第2个第一类P帧的参考帧是前面的第二类P帧,第3个第一类P帧的参考帧是前面的第三类P帧,第4个第一类P帧的参考帧是前面的第二类P帧,第5个第一类P帧的参考帧是前面的第三类P帧,以此类推。针对第二类P帧来说,第1个第二类P帧的参考帧是前面的I帧,第2个第二类P帧的参考帧是前面的第三类P帧,第3个第二类P帧的参考帧是前面的第三类P帧,以此类推。针对第三类P帧来说,第1个第三类P帧的参考帧是前面的I帧,第2个第三类P帧的参考帧是前面的第三类P帧,第3个第三类P帧的参考帧是前面的第三类P帧,以此类推。Referring to FIG. 8B , the relationship between each P frame and the reference frame is shown. For the first type of P frame, the reference frame of the first type of P frame is the previous I frame, the reference frame of the second type of first P frame is the previous type of second P frame, and the reference frame of the third type of P frame is the previous type of P frame. The reference frame of a P frame of the first type is the previous P frame of the third type, the reference frame of the fourth P frame of the first type is the previous P frame of the second type, and the reference frame of the fifth P frame of the first type is the previous P frame of the first type. The third type of P frame, and so on. For type 2 P frames, the reference frame of the first type 2 P frame is the previous I frame, the reference frame of the second type 2 P frame is the previous type 3 P frame, and the reference frame of the third type 2 P frame is the previous type 3 P frame. The reference frame of the second type P frame is the previous third type P frame, and so on. For the third type of P frame, the reference frame of the first type III P frame is the previous I frame, the reference frame of the second type III P frame is the previous type III P frame, and the reference frame of the third type III P frame is the previous type III P frame. The reference frame of the third type P frame is the previous third type P frame, and so on.
步骤702、若确定需要对GOP序列内的P帧进行抽帧,则对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧,或者,对第一类P帧、第二类P帧和第三类P帧进行抽帧。示例性的,对P帧进行抽帧可以是指:不对这个P帧进行处理,如编码端对P帧进行抽帧时,就是不对这个P帧进行编码,解码端对P帧进行抽帧时,就是不对这个P帧进行解码。Step 702: If it is determined that the P frames in the GOP sequence need to be extracted, the first type of P frames are extracted, or the first type of P frames and the second type of P frames are extracted, or the first type of P frames are extracted, or the first type of P frames are extracted. P-frames of the first type, P-frames of the second type and P-frames of the third type are extracted. For example, extracting the P frame may mean: not processing the P frame. For example, when the encoding end extracts the P frame, it means that the P frame is not encoded. When the decoding end extracts the P frame, Just don't decode this P frame.
在一种可能的实施方式中,若确定需要对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧或部分第一类P帧进行抽帧;或者,可以对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;或者,可以对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧。综上可以看出,在对第一类P帧进行抽帧时,不需要考虑第二类P帧和第三类P帧是否被抽帧,可以直接对第一类P帧进行抽帧。在对第二类P帧进行抽帧时,需要考虑第一类P帧是否被抽帧,不需要考虑第三类P帧是否被抽帧,只有在所有第一类P帧均被抽帧之后,才可以对第二类P帧进行抽帧。在对第三类P帧进行抽帧时,需要考虑第一类P帧是否被抽帧,且需要考虑第二类P帧是否被抽帧,只有在所有第一类P帧均被抽帧,且所有第二类P帧均被抽帧之后,才可以对第三类P帧进行抽帧。
In a possible implementation, if it is determined that the P frames in the GOP sequence need to be extracted, all the first type P frames or part of the first type P frames can be extracted; or, all the first type P frames can be extracted. Frame extraction is performed on P-type frames, and all P-frames of the second type or part of the P-frames of the second type are extracted; alternatively, all P-frames of the first type can be extracted, and all P-frames of the second type can be extracted. , and perform frame extraction on all the third type P frames or part of the third type P frames. In summary, it can be seen that when extracting frames of the first type of P frames, there is no need to consider whether the second type of P frames and third type of P frames are extracted, and the first type of P frames can be extracted directly. When extracting frames of the second type of P frames, it is necessary to consider whether the first type of P frames have been extracted. It is not necessary to consider whether the third type of P frames have been extracted. Only after all first type of P frames have been extracted. , only then can the second type of P frame be extracted. When extracting frames of the third type of P frames, it is necessary to consider whether the first type of P frames are extracted, and whether the second type of P frames are extracted. Only when all the first type of P frames are extracted, And only after all the P frames of the second type have been extracted, the P frames of the third type can be extracted.
在一种可能的实施方式中,为了对GOP序列内的P帧进行抽帧,可以划分多个抽样比例,该抽样比例用于表示对多少P帧进行抽帧,例如,抽样比例为x时,表示对所有P帧中的x进行抽帧,不同抽样比例表示不同抽样方式。In a possible implementation, in order to extract frames from P frames in a GOP sequence, multiple sampling ratios can be divided, and the sampling ratio is used to indicate how many P frames to extract. For example, when the sampling ratio is x, Indicates that x in all P frames is sampled, and different sampling ratios represent different sampling methods.
比如说,划分3个抽样比例,记为第一抽样比例、第二抽样比例和第三抽样比例,第一抽样比例小于第二抽样比例,且第二抽样比例小于第三抽样比例。针对第一抽样比例,对所有第一类P帧或部分第一类P帧进行抽帧;针对第二抽样比例,对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;针对第三抽样比例,对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧。For example, three sampling proportions are divided, recorded as the first sampling proportion, the second sampling proportion and the third sampling proportion. The first sampling proportion is smaller than the second sampling proportion, and the second sampling proportion is smaller than the third sampling proportion. For the first sampling ratio, frame extraction is performed on all P frames of the first type or part of the P frames of the first type; for the second sampling ratio, frames are extracted on all P frames of the first type, and on all P frames of the second type or Frame extraction is performed on some P-frames of the second type; for the third sampling ratio, all P-frames of the first type are extracted, all P-frames of the second type are extracted, and all P-frames of the third type or part of the third-category P-frame are extracted. P-like frames are used for frame extraction.
又例如,划分6个抽样比例,记为第一抽样比例、第二抽样比例、第三抽样比例、第四抽样比例、第五抽样比例和第六抽样比例,第一抽样比例小于第二抽样比例,第二抽样比例小于第三抽样比例,第三抽样比例小于第四抽样比例,第四抽样比例小于第五抽样比例,第五抽样比例小于第六抽样比例。针对第一抽样比例,对部分第一类P帧进行抽帧;针对第二抽样比例,对所有第一类P帧进行抽帧;针对第三抽样比例,对所有第一类P帧进行抽帧,对部分第二类P帧进行抽帧;针对第四抽样比例,对所有第一类P帧进行抽帧,对所有第二类P帧抽帧;针对第五抽样比例,对所有第一类P帧进行抽帧,对所有第二类P帧抽帧,对部分第三类P帧进行抽帧;针对第六抽样比例,对所有第一类P帧进行抽帧,对所有第二类P帧抽帧,对所有第三类P帧进行抽帧。For another example, six sampling proportions are divided, recorded as the first sampling proportion, the second sampling proportion, the third sampling proportion, the fourth sampling proportion, the fifth sampling proportion and the sixth sampling proportion. The first sampling proportion is smaller than the second sampling proportion. , the second sampling proportion is smaller than the third sampling proportion, the third sampling proportion is smaller than the fourth sampling proportion, the fourth sampling proportion is smaller than the fifth sampling proportion, and the fifth sampling proportion is smaller than the sixth sampling proportion. For the first sampling ratio, frame extraction is performed on some P frames of the first type; for the second sampling ratio, frames are extracted on all P frames of the first type; for the third sampling ratio, frames are extracted on all P frames of the first type , extract frames for some P-frames of the second type; for the fourth sampling ratio, extract frames for all P-frames of the first type, and for all P-frames of the second type; for the fifth sampling ratio, extract frames for all P-frames of the first type P frames are extracted, and frames are extracted for all P frames of the second type, and some P frames of the third type are extracted; for the sixth sampling ratio, frames are extracted for all P frames of the first type, and all P frames of the second type are extracted. Frame extraction is performed on all P frames of the third type.
当然,上述只是抽样比例的划分示例,对此不做限制,可以划分任意数量的抽样比例,为了方便描述,后续以划分3个抽样比例为例进行说明。Of course, the above is just an example of the division of sampling proportions, and there is no restriction on this. Any number of sampling proportions can be divided. For the convenience of description, the following description will be made by taking the division of three sampling proportions as an example.
在此基础上,若确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧或部分第一类P帧进行抽帧;若确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;若确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧。On this basis, if it is determined that the first sampling ratio needs to be used to extract frames from P frames in the GOP sequence, all first type P frames or part of the first type P frames can be extracted; if it is determined that the second sampling ratio needs to be used, If the sampling ratio is used to extract the P frames in the GOP sequence, all the first type P frames can be extracted, and all the second type P frames or part of the second type P frames can be extracted; if it is determined that the first type P frame needs to be used, The three-sampling ratio is used to extract frames from P frames in the GOP sequence. Then, all P frames of the first type can be extracted, all P frames of the second type can be extracted, and all P frames of the third type or part of the third type can be extracted. P-like frames are used for frame extraction.
示例性的,假设第一类P帧的总数量占P帧总数量的x1,第二类P帧的总数量占P帧总数量的x2,第三类P帧的总数量占P帧总数量的x3,x1、x2与x3之和为1,那么,第一抽样比例小于或者等于x1,第二抽样比例大于x1,且小于或者等于x1+x2,第三抽样比例大于x1+x2,且小于或者等于x1+x2+x3。For example, assume that the total number of P frames of the first type accounts for x1 of the total number of P frames, the total number of P frames of the second type accounts for x2 of the total number of P frames, and the total number of P frames of the third type accounts for x2 of the total number of P frames. x3 of Or equal to x1+x2+x3.
参见图8A和图8B所示,x1为0.5,x2为0.25,x3为0.25,在此基础上,若抽样比例小于或者等于0.5,则说明抽样比例是第一抽样比例,若抽样比例大于0.5,且小于或者等于0.75,则说明抽样比例是第二抽样比例,若抽样比例大于0.75,且小于或者等于1,则说明抽样比例是第三抽样比例。Referring to Figure 8A and Figure 8B, x1 is 0.5, x2 is 0.25, and x3 is 0.25. On this basis, if the sampling ratio is less than or equal to 0.5, it means that the sampling ratio is the first sampling ratio. If the sampling ratio is greater than 0.5, And less than or equal to 0.75, it means that the sampling ratio is the second sampling ratio. If the sampling ratio is greater than 0.75 and less than or equal to 1, it means that the sampling ratio is the third sampling ratio.
综上可以看出,在对P帧进行抽帧时,优先对第一类P帧的全部或局部进行抽帧,第一类P帧全部被抽帧后,可以对第二类P帧的全部或局部进行抽帧,第二类P帧全部被抽帧后,可以对第三类P帧的全部或局部进行抽帧。对第三类P帧的局部进行抽帧时,保留前面的第三类P帧,对后面的第三类P帧进行抽帧,如对第k(k大于1)个第三类P帧之后的所有第三类P帧进行抽帧。In summary, it can be seen that when extracting P frames, priority is given to extracting all or part of the P frames of the first type. After all P frames of the first type are extracted, all P frames of the second type can be extracted. Or partial frame extraction is performed. After all second type P frames are extracted, frame extraction can be performed on all or part of the third type P frame. When extracting a part of the third type P frame, the previous third type P frame is retained, and the following third type P frame is extracted, such as after the kth (k is greater than 1) third type P frame. All third-category P frames are extracted.
示例性的,参见图9A所示,若确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,在该情况下,第一抽样比例小于或者等于0.5。参见图9B所示,若确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,并对所有第二类P帧进行抽帧,在该情况下,第二抽样比例小于或者等于0.75,且大于0.5。参见图9C所示,若确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则可以对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧进行抽帧,在该情况下,第三抽样比例小于或者等于1,且大于0.75。For example, as shown in Figure 9A, if it is determined that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames can be extracted. In this case, the first sampling ratio The ratio is less than or equal to 0.5. Referring to Figure 9B, if it is determined that the second sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then all first type P frames can be extracted, and all second type P frames can be extracted, In this case, the second sampling ratio is less than or equal to 0.75 and greater than 0.5. Referring to Figure 9C, if it is determined that the third sampling ratio needs to be used to extract frames from P frames in the GOP sequence, frames can be extracted from all P frames of the first type, and frames can be extracted from all P frames of the second type, and Frame sampling is performed on all P frames of the third type. In this case, the third sampling ratio is less than or equal to 1 and greater than 0.75.
参见图9A所示,一个GOP序列可以实现1/2抽帧,当1/2抽帧无法满足业务需求时,参见图9B所示,一个GOP序列可以实现3/4抽帧,当3/4抽帧也无法满足业务需求时,参见图9C所示,一个GOP序列可以实现完全抽帧。As shown in Figure 9A, a GOP sequence can achieve 1/2 frame extraction. When 1/2 frame extraction cannot meet business requirements, as shown in Figure 9B, a GOP sequence can achieve 3/4 frame extraction. When 3/4 frame extraction When frame extraction cannot meet business requirements, as shown in Figure 9C, a GOP sequence can achieve complete frame extraction.
在一种可能的实施方式中,可以基于业务信息确定GOP序列对应的抽样比例,比如说,基于业务信息确定采用第一抽样比例对GOP序列内的P帧进行抽帧,或者,基于业务信息确定采用第二抽样比例对GOP序列内的P帧进行抽帧,或者,基于业务信息确定采用第三抽样比例对GOP序列内的P帧进行抽帧。In a possible implementation, the sampling ratio corresponding to the GOP sequence can be determined based on the service information. For example, it is determined based on the service information that the first sampling ratio is used to extract the P frames in the GOP sequence, or the sampling ratio is determined based on the service information. The second sampling ratio is used to extract frames from the P frames in the GOP sequence, or the third sampling ratio is used to extract frames from the P frames in the GOP sequence based on the service information.
若采用第一抽样比例对GOP序列内的P帧进行抽帧时,能够满足业务信息对应的业务需求,即对GOP序列抽取x1(如0.5)的P帧能够满足业务需求,基于业务信息确定采用第一抽样比例。若采用第一抽样比例无法满足业务需求,但采用第二抽样比例对GOP序列内的P帧进行抽帧时,能够满足业务信息对应的业务需求,即对GOP序列抽取x1+x2(如0.75)的P帧能够满足业务需求,基于业务信息确定采用第二抽样比例。若采用第一抽样比例无法满足业务需求,采用第二抽样比例也无法满足业务需求,基于业务信息确定采用第三抽样比例。If the first sampling ratio is used to extract P frames in the GOP sequence, the service requirements corresponding to the service information can be met, that is, the P frames extracted by x1 (such as 0.5) from the GOP sequence can meet the service requirements, and the selection is determined based on the service information. First sampling ratio. If the first sampling ratio cannot meet the business requirements, but the second sampling ratio is used to extract frames from P frames in the GOP sequence, the business requirements corresponding to the business information can be met, that is, x1+x2 (such as 0.75) is extracted from the GOP sequence. The P frame can meet the business requirements, and the second sampling ratio is determined based on the business information. If the first sampling ratio cannot meet the business needs, and the second sampling ratio cannot meet the business needs, the third sampling ratio will be determined based on the business information.
以下结合业务信息的两个具体应用场景,对上述抽帧过程进行说明。The above frame extraction process is explained below based on two specific application scenarios of business information.
应用场景1:业务信息包括GOP序列对应的分辨率(如4*30帧表示帧率)、GOP序列对应的帧率和解码端对应的解码能力,基于分辨率、帧率和解码能力确定是否需要对GOP序列内的P帧进行抽帧。若否,则不对GOP序列内的P帧进行抽帧。若是,则基于该分辨率、帧率和该解码能力确定GOP序列对应的抽样比例,如第一抽样比例、或第二抽样比例、或第三抽样比例。
Application scenario 1: Business information includes the resolution corresponding to the GOP sequence (for example, 4*30 frames represents the frame rate), the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoder. Determine whether it is needed based on the resolution, frame rate, and decoding capability. Extract frames from P frames within the GOP sequence. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the resolution, the frame rate and the decoding capability, such as the first sampling ratio, the second sampling ratio, or the third sampling ratio.
比如说,假设NVR设备具有4*1080P30的解码能力,即NVR设备一秒钟可以解码4*30帧的1920*1080的图像,超过该解码能力的图像就无法完成解码。For example, assuming that the NVR device has a decoding capability of 4*1080P30, that is, the NVR device can decode 4*30 frames of 1920*1080 images in one second. Images exceeding this decoding capability cannot be decoded.
a、若GOP序列对应的是4*30帧的图像(分辨率为1920*1080),则基于分辨率、帧率和解码能力确定不需要对GOP序列内的P帧进行抽帧,即分辨率、帧率和解码能力匹配,因此,NVR设备不对GOP序列内的P帧进行抽帧,一秒钟可以解码4*30帧的图像,并通过4路显示1080P30的图像,参见图5A所示。a. If the GOP sequence corresponds to an image of 4*30 frames (resolution is 1920*1080), it is determined based on the resolution, frame rate and decoding capability that there is no need to extract the P frames in the GOP sequence, that is, the resolution , frame rate and decoding capability match, therefore, the NVR device does not extract frames from P frames in the GOP sequence, can decode 4*30 frames of images in one second, and display 1080P30 images through 4 channels, see Figure 5A.
b、若GOP序列对应的是8*30帧的图像(分辨率为1920*1080),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第一抽样比例(即1/2抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过8路显示1080P15的图像,参见图5B所示,显然,8路的15帧对应的是4*30帧。b. If the GOP sequence corresponds to an 8*30 frame image (resolution is 1920*1080), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be extracted, that is, the resolution, The frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, it is determined that the P frames in the GOP sequence need to be extracted, and each image must be sampled according to the first sampling ratio (i.e. 1/2 frame extraction method), when 4*30 frames of images can be decoded in one second, 1080P15 images can be displayed through 8 channels, as shown in Figure 5B. Obviously, 15 frames of 8 channels correspond to 4*30 frames.
显然,当解码路数增加时,如从4路变为8路,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求。Obviously, when the number of decoding channels increases, such as from 4 channels to 8 channels, the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel to meet business needs.
c、若GOP序列对应的是4*60帧的图像(分辨率1920*1080),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第一抽样比例(即1/2抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过4路显示1080P30的图像,参见图5C所示,显然,4*60帧被1/2抽帧之后剩余4*30帧。c. If the GOP sequence corresponds to an image of 4*60 frames (resolution 1920*1080), based on the resolution, frame rate and decoding capability, it is determined that the P frames in the GOP sequence need to be extracted, that is, the resolution, frame The rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, it is determined that the P frames in the GOP sequence need to be extracted, and each image must be sampled according to the first sampling ratio (i.e. 1 /2 frame extraction method) to extract frames, when 4*30 frames of images can be decoded in one second, 1080P30 images can be displayed through 4 channels, as shown in Figure 5C. Obviously, 4*60 frames are extracted by 1/2 4*30 frames remain after the frame.
显然,当倍速回放时,如从30帧图像变为60帧图像,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求,也就是说,30帧2倍速相当于每秒60帧,按照1/2抽帧等于每秒30帧。Obviously, when playing back at double speed, such as changing from a 30-frame image to a 60-frame image, you can extract frames for each image so that the decoding capability can support decoding images of this resolution and frame rate to meet business needs, that is, Say, 30 frames at 2x speed is equivalent to 60 frames per second, and 1/2 frame extraction is equal to 30 frames per second.
d、若GOP序列对应的是12*30帧的图像(分辨率为1920*1080),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第二抽样比例(即3/4抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过12路显示1080P10的图像,参见图5D所示,显然,12路的10帧对应的是4*30帧。d. If the GOP sequence corresponds to an image of 12*30 frames (resolution is 1920*1080), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be extracted, that is, the resolution, The frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, it is determined that the P frames in the GOP sequence need to be extracted, and each image must be sampled according to the second sampling ratio (i.e. 3/4 frame extraction method), when 4*30 frames of images can be decoded in one second, 1080P10 images can be displayed through 12 channels, as shown in Figure 5D. Obviously, 10 frames of 12 channels correspond to 4*30 frames.
显然,当解码路数增加时,如从4路变为12路,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求。Obviously, when the number of decoding channels increases, such as from 4 channels to 12 channels, the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
e、若GOP序列对应的是16*30帧的图像(分辨率为1920*1080),则基于分辨率、帧率和解码能力确定需要对GOP序列内的P帧进行抽帧,即分辨率、帧率和解码能力不匹配(即解码能力不支持解码该分辨率、帧率的图像),因此,确定需要对GOP序列内的P帧进行抽帧,且每路图像按照第三抽样比例(即4/4抽帧的方式)进行抽帧,一秒钟可以解码4*30帧的图像时,可以通过16路显示1080P7.5的图像,参见图5E所示,显然,16路的7.5帧对应的是4*30帧。e. If the GOP sequence corresponds to an image of 16*30 frames (resolution is 1920*1080), it is determined based on the resolution, frame rate and decoding capability that the P frames in the GOP sequence need to be extracted, that is, the resolution, The frame rate and decoding capability do not match (that is, the decoding capability does not support decoding images of this resolution and frame rate). Therefore, it is determined that the P frames in the GOP sequence need to be extracted, and each image must be sampled according to the third sampling ratio (i.e. 4/4 frame extraction method), when 4*30 frames of images can be decoded in one second, 1080P7.5 images can be displayed through 16 channels, as shown in Figure 5E. Obviously, 7.5 frames of 16 channels correspond to It's 4*30 frames.
显然,当解码路数增加时,如从4路变为16路,可以通过对每路图像进行抽帧的方式,使得解码能力支持解码该分辨率、帧率的图像,满足业务需求。Obviously, when the number of decoding channels increases, such as from 4 channels to 16 channels, the decoding capability can be supported by decoding images of the resolution and frame rate by extracting frames for each channel of images to meet business needs.
综上可以看出,当多倍速和/或多路数的条件任意变化时,可以按照第一抽样比例、或第二抽样比例、或第三抽样比例来抽帧,从而满足业务需求。In summary, it can be seen that when the conditions of multiple speeds and/or the number of multiple channels change arbitrarily, frames can be extracted according to the first sampling ratio, the second sampling ratio, or the third sampling ratio to meet business needs.
应用场景2:若业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于该网络质量确定是否需要对GOP序列内的P帧进行抽帧。若否,则不对GOP序列内的P帧进行抽帧。若是,则基于该网络质量确定GOP序列对应的抽样比例,如第一抽样比例、或第二抽样比例、或第三抽样比例。Application scenario 2: If the service information includes the network quality corresponding to the target network between the sending end and the receiving end, it is determined based on the network quality whether the P frame in the GOP sequence needs to be extracted. If not, frame extraction will not be performed on the P frames in the GOP sequence. If so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, such as the first sampling ratio, the second sampling ratio, or the third sampling ratio.
比如说,发送端向接收端发送GOP序列时,需要检测用于承载GOP序列的目标网络对应的网络质量(如抖动、丢包率等),对此检测方式不做限制。For example, when the sender sends a GOP sequence to the receiver, it needs to detect the network quality (such as jitter, packet loss rate, etc.) corresponding to the target network used to carry the GOP sequence. There is no restriction on this detection method.
在一种可能的实施方式中,可以设计4个级别的网络质量,若目标网络对应的网络质量是第1级别(即最优级别)的网络质量,则确定不对GOP序列内的P帧进行抽帧。若目标网络对应的网络质量是第2级别的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第一抽样比例,如1/2抽帧的方式。若目标网络对应的网络质量是第3级别的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第二抽样比例,如3/4抽帧的方式。若目标网络对应的网络质量是第4级别(即最差级别)的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第三抽样比例,如4/4抽帧的方式。In a possible implementation, four levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (ie, the optimal level), it is determined not to extract the P frames in the GOP sequence. frame. If the network quality corresponding to the target network is level 2 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio, such as 1/2 frame extraction. If the network quality corresponding to the target network is level 3 network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the second sampling ratio, such as 3/4 frame extraction. If the network quality corresponding to the target network is the network quality of level 4 (i.e., the worst level), it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the third sampling ratio, such as 4/4 frame extraction. Way.
在另一种可能的实施方式中,可以设计2个级别的网络质量,若目标网络对应的网络质量是第1级别(即最优级别)的网络质量,则确定不对GOP序列内的P帧进行抽帧。若目标网络对应的网络质量是第2级别的网络质量,则确定对GOP序列内的P帧进行抽帧,且抽样比例是第一抽样比例,在GOP序列的传输过程中,若网络质量仍然是第2级别的网络质量,则将抽样比例调整为第二抽样比例,在GOP序列的传输过程中,若网络质量仍然是第2级别的网络质量,则将抽样比例调整为第三抽样比例。此外,在GOP序列的传输过程中,若网络质量恢复为第1级别的网络质量,则不对GOP序列内的P帧进行抽帧。
In another possible implementation, two levels of network quality can be designed. If the network quality corresponding to the target network is the network quality of the first level (i.e., the optimal level), it is determined that the P frames in the GOP sequence are not to be processed. Frame extraction. If the network quality corresponding to the target network is the second level network quality, it is determined to extract frames from the P frames in the GOP sequence, and the sampling ratio is the first sampling ratio. During the transmission process of the GOP sequence, if the network quality is still If the network quality is Level 2, the sampling ratio will be adjusted to the second sampling ratio. During the transmission process of the GOP sequence, if the network quality is still Level 2 network quality, the sampling ratio will be adjusted to the third sampling ratio. In addition, during the transmission process of the GOP sequence, if the network quality returns to the first level of network quality, the P frames in the GOP sequence will not be extracted.
当然,上述两个应用场景只是确定抽样比例的两个示例,还可以采用其它方式确定GOP序列对应的抽样比例,对此不做限制。例如,依据每帧大小来确定GOP序列对应的抽样比例,如帧大小小于第一门限值时,不对GOP序列内的P帧进行抽帧,帧大小大于第一门限值且小于第二门限值时,抽样比例是第一抽样比例,帧大小大于第二门限值且小于第三门限值时,抽样比例是第二抽样比例,帧大小大于第三门限值时,抽样比例是第三抽样比例。Of course, the above two application scenarios are just two examples of determining the sampling ratio. Other methods can also be used to determine the sampling ratio corresponding to the GOP sequence, and there are no restrictions on this. For example, the sampling ratio corresponding to the GOP sequence is determined based on the size of each frame. If the frame size is less than the first threshold, the P frames in the GOP sequence will not be sampled. The frame size is greater than the first threshold and less than the second threshold. limit, the sampling ratio is the first sampling ratio. When the frame size is greater than the second threshold and less than the third threshold, the sampling ratio is the second sampling ratio. When the frame size is greater than the third threshold, the sampling ratio is Third sampling ratio.
在一种可能的实施方式中,还可以将至少两个GOP序列组成一个图像序列集合,基于此,当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是该图像序列集合的首个GOP序列,则可以将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。在该实施方式中,若GOP序列不是图像序列集合的首个GOP序列,则可以将该GOP序列的第一帧称为关键P帧(即不再称为I帧),关键P帧的参考帧是前面最近的I帧。In a possible implementation, at least two GOP sequences can also be composed into an image sequence set. Based on this, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the The first GOP sequence of the image sequence set, then the I frame of the first GOP sequence can be used as the reference frame of the first frame of the GOP sequence. In this embodiment, if the GOP sequence is not the first GOP sequence in the image sequence set, the first frame of the GOP sequence can be called a key P frame (that is, it is no longer called an I frame), and the reference frame of the key P frame is the most recent I frame.
示例性的,对于图像序列集合来说,该图像序列集合可以包括至少一个关键P帧,即允许存在至少一个关键P帧,关键P帧用于取代I帧的位置,关键P帧只能参考离它最近的前面的I帧,且关键P帧的帧结构可以有效降低整体带宽。For example, for an image sequence set, the image sequence set may include at least one key P frame, that is, at least one key P frame is allowed to exist. The key P frame is used to replace the position of the I frame. The key P frame can only refer to the I frame. Its frame structure is the closest preceding I frame, and the key P frame can effectively reduce the overall bandwidth.
参见图10所示,是图像序列集合的示意图,该图像序列集合可以包括关键P帧。在I帧与关键P帧之间,可以存在第一类P帧、第二类P帧和第三类P帧,第一类P帧、第二类P帧和第三类P帧的结构关系可以参见上述实施例。在相邻两个关键P帧之间,可以存在第一类P帧、第二类P帧和第三类P帧,第一类P帧、第二类P帧和第三类P帧的结构关系可以参见上述实施例。Referring to FIG. 10 , which is a schematic diagram of an image sequence collection, the image sequence collection may include key P frames. Between the I frame and the key P frame, there may be the first type of P frame, the second type of P frame and the third type of P frame, and the structural relationship of the first type of P frame, the second type of P frame and the third type of P frame. See the above embodiments. Between two adjacent key P frames, there may be a first type of P frame, a second type of P frame and a third type of P frame, and the structure of the first type of P frame, the second type of P frame and the third type of P frame For the relationship, please refer to the above embodiment.
在对P帧进行抽帧时,可以对第一类P帧进行抽帧,可以对第二类P帧进行抽帧,可以对第三类P帧进行抽帧,但是不能对关键P帧进行抽帧。When extracting P frames, you can extract frames of the first type of P frames, you can extract frames of the second type of P frames, you can extract frames of the third type of P frames, but you cannot extract frames of key P frames. frame.
由以上技术方案可见,本实施例提供一种新型视频帧序列,该视频帧序列包括第一类P帧、第二类P帧和第三类P帧,可以按照一定规律进行丢帧,既能保证视频帧序列按照顺序播放,具有按照规则间叉性丢弃P帧而不影响观看的特点,又可以在一些特殊场景下丢弃部分P帧以达到节省带宽的目的,视频帧序列在解码、网络传输、存储中具有更好的使用前景,实现解码倍增路数、低带宽传输,低码率存储等特点,在弱网环境下也能够解决帧丢失后长期黑屏花屏等问题。丢帧策略可以动态实施,根据现场情况任意调整丢帧策略,在不影响解码完整性的情况下,灵活而有效的降低消耗。该视频帧序列可以保证抽帧的灵活性和图像质量的稳定性,可以有效改善客户体验。It can be seen from the above technical solution that this embodiment provides a new type of video frame sequence. The video frame sequence includes a first type of P frame, a second type of P frame, and a third type of P frame. Frames can be dropped according to certain rules, which can It ensures that the video frame sequence is played in order, and has the characteristics of discarding P frames according to the rules without affecting viewing. It can also discard some P frames in some special scenarios to achieve the purpose of saving bandwidth. The video frame sequence is decoded and transmitted over the network. , has better application prospects in storage, realizing the characteristics of multiplied decoding channels, low-bandwidth transmission, low bit rate storage, etc., and can also solve problems such as long-term black screen and blurred screen after frame loss in weak network environment. The frame loss strategy can be dynamically implemented and arbitrarily adjusted according to on-site conditions, flexibly and effectively reducing consumption without affecting decoding integrity. This video frame sequence can ensure the flexibility of frame extraction and the stability of image quality, and can effectively improve customer experience.
基于与上述方法同样的申请构思,本申请实施例中提出一种图像处理装置,参见图11所示,为所述图像处理装置的结构示意图,所述装置可以包括:Based on the same application concept as the above method, an image processing device is proposed in the embodiment of the present application. See Figure 11, which is a schematic structural diagram of the image processing device. The device may include:
划分模块111,用于将画面组GOP序列内的所有P帧划分为至少两个类型的P帧,所述至少两个类型的P帧中存在不能够作为参考帧的P帧,且所述至少两个类型的P帧中存在能够作为参考帧的P帧;The dividing module 111 is configured to divide all P frames in the picture group GOP sequence into at least two types of P frames. Among the at least two types of P frames, there are P frames that cannot be used as reference frames, and the at least Among the two types of P frames, there are P frames that can serve as reference frames;
处理模块112,用于若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧进行抽帧,或者,若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽帧。The processing module 112 is configured to extract frames that cannot be used as reference frames if it is determined that the P frames in the GOP sequence need to be extracted, or if it is determined that the P frames in the GOP sequence need to be extracted. When performing frame extraction, frame extraction is performed on P frames that cannot be used as reference frames and P frames that can be used as reference frames.
示例性的,划分模块111,具体用于将GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,第一类P帧不能够作为参考帧,第二类P帧能够作为第一类P帧的参考帧、且第二类P帧能够作为第二类P帧的参考帧;处理模块112,具体用于若确定需要对GOP序列内的P帧进行抽帧,则对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧。Exemplarily, the dividing module 111 is specifically used to divide all P frames in the GOP sequence into first type P frames and second type P frames; wherein the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame. The frame can be used as a reference frame of the first type of P frame, and the second type of P frame can be used as a reference frame of the second type of P frame; the processing module 112 is specifically used to extract the P frame in the GOP sequence if it is determined that it is necessary to extract the frame. Then, frame extraction is performed on the P frame of the first type, or frame extraction is performed on the P frame of the first type and the P frame of the second type.
示例性的,划分模块111将GOP序列内的所有P帧划分为第一类P帧和第二类P帧时具体用于:基于GOP序列内的各P帧之间的位置排序关系,将GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,相邻两个第二类P帧之间存在M1个第一类P帧,GOP序列的I帧与第一个第二类P帧之间存在M2个第一类P帧;M1和M2均为正整数。Exemplarily, when the dividing module 111 divides all P frames in the GOP sequence into the first type of P frames and the second type of P frames, it is specifically used to: based on the position ordering relationship between the P frames in the GOP sequence, divide the GOP into All P frames in the sequence are divided into first type P frames and second type P frames; among them, there are M1 first type P frames between two adjacent second type P frames, and the I frame of the GOP sequence is the same as the first type P frame. There are M2 P frames of the first type between the P frames of the second type; M1 and M2 are both positive integers.
示例性的,针对每个第一类P帧,若该第一类P帧前面存在第二类P帧,则将该第一类P帧前面最近一个第二类P帧作为该第一类P帧的参考帧,若该第一类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第二类P帧,则将该第二类P帧前面最近一个第二类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第二类P帧的参考帧。For example, for each P frame of the first type, if there is a P frame of the second type before the P frame of the first type, the most recent P frame of the second type before the P frame of the first type is regarded as the P frame of the first type. The reference frame of the frame, if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type; for each P frame of the second type, if the P frame of the second type If there is a P frame of the second type before the P frame of the second type, the most recent P frame of the second type before the P frame of the second type is used as the reference frame of the P frame of the second type. If there is no P frame of the second type before it, For the second type of P frame, the I frame of the GOP sequence is used as the reference frame of the second type of P frame.
示例性的,处理模块112确定需要对GOP序列内的P帧进行抽帧,则对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧时具体用于:若基于业务信息确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;或者,若基于业务信息确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧;若基于业务信息确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;其中,第二抽样比例大于第一抽样比例,第三抽样比例大于第二抽样比例。For example, if the processing module 112 determines that it is necessary to extract the P frames within the GOP sequence, then the first type of P frame is extracted, or specifically when the first type of P frame and the second type of P frame are extracted. Used for: If it is determined based on the business information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all first type P frames or part of the first type P frames are extracted; if it is determined based on the business information that it is necessary Using the second sampling ratio to extract frames from P frames in the GOP sequence, extract frames from all P frames of the first type, and extract frames from all P frames of the second type or part of the P frames of the second type; or, if If it is determined based on the business information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then some of the first type P frames will be extracted; if it is determined based on the business information that the second sampling ratio needs to be used to extract the P frames in the GOP sequence If the frame is extracted, all first-type P frames will be extracted; if it is determined based on the service information that the third sampling ratio needs to be used to extract P frames in the GOP sequence, then all first-category P frames will be extracted. , and perform frame sampling on all second type P frames or part of the second type P frames; wherein the second sampling ratio is greater than the first sampling ratio, and the third sampling ratio is greater than the second sampling ratio.
示例性的,处理模块112,还用于若业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于分辨率、帧率和解码能力确定是否需要对GOP序列内的P帧进行抽帧;其中,若解码能力不支持解码分辨率和帧率的图像,则确定对GOP序列内的P帧进行抽帧;若是,则基于分辨率、帧率和解码能力确定
GOP序列对应的抽样比例;或者,若业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于网络质量确定是否需要对GOP序列内的P帧进行抽帧;其中,若网络质量不是最优级别的网络质量,则确定对GOP序列内的P帧进行抽帧;若是,则基于网络质量确定GOP序列对应的抽样比例;抽样比例为第一抽样比例、或第二抽样比例;或者,抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。Exemplarily, the processing module 112 is also configured to determine whether it is necessary to perform decoding based on the resolution, frame rate, and decoding capability if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end. The P frames in the GOP sequence are extracted; if the decoding capability does not support images with decoding resolution and frame rate, it is determined to extract the P frames in the GOP sequence; if so, based on the resolution, frame rate and decoding Ability determined The sampling ratio corresponding to the GOP sequence; or, if the service information includes the network quality corresponding to the target network between the sending end and the receiving end, determine whether the P frame in the GOP sequence needs to be extracted based on the network quality; where, if the network If the quality is not the optimal level of network quality, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality; the sampling ratio is the first sampling ratio or the second sampling ratio; Alternatively, the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio.
示例性的,划分模块111,具体用于用于将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;第一类P帧不能够作为参考帧,第二类P帧只能够作为第一类P帧的参考帧,第三类P帧能够作为第一类P帧的参考帧、能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧;处理模块112,具体用于若确定需要对GOP序列内的P帧进行抽帧,则对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧,或者,对第一类P帧、第二类P帧和第三类P帧进行抽帧。Exemplarily, the dividing module 111 is specifically used to divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; the first type P frame cannot be used as a reference. frame, the second type of P frame can only be used as a reference frame of the first type of P frame, the third type of P frame can be used as a reference frame of the first type of P frame, can be used as a reference frame of the second type of P frame, and can be used as a reference frame of the first type of P frame. The reference frame of the three types of P frames; the processing module 112 is specifically used to extract frames from the P frames in the GOP sequence if it is determined that the P frames in the GOP sequence need to be extracted, or extract the frames from the first type P frames and the first type P frames. The second type of P frame is extracted, or the first type of P frame, the second type of P frame and the third type of P frame are extracted.
示例性的,划分模块111将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧时具体用于:基于GOP序列内的各P帧之间的位置排序关系,将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;其中,针对GOP序列内的所有P帧,相邻两个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且一个第二类P帧位于两个第一类P帧之间;GOP序列的I帧与第一个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且这个第二类P帧位于这两个第一类P帧之间。Exemplarily, when the dividing module 111 divides all P frames in the GOP sequence into the first type of P frame, the second type of P frame and the third type of P frame, it is specifically used to: based on the difference between the P frames in the GOP sequence. The position sorting relationship divides all P frames in the GOP sequence into the first type of P frames, the second type of P frames and the third type of P frames; among them, for all P frames in the GOP sequence, two adjacent third type P frames There are two P frames of the first type and one P frame of the second type between P frames, and a P frame of the second type is located between two P frames of the first type; the I frame of the GOP sequence is the same as the first P frame of the third type. There are two P frames of the first type and one P frame of the second type between the P frames, and the P frame of the second type is located between the two P frames of the first type.
示例性的,针对每个第一类P帧,若该第一类P帧的前一帧不是第一类P帧,则将该第一类P帧的前一帧作为该第一类P帧的参考帧,若该第一类P帧的前一帧是第一类P帧,则将前面最近一个非第一类P帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第三类P帧,则将该第二类P帧前面最近一个第三类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第三类P帧,则将GOP序列的I帧作为该第二类P帧的参考帧;针对每个第三类P帧,若该第三类P帧前面存在第三类P帧,则将该第三类P帧前面最近一个第三类P帧作为该第三类P帧的参考帧,若该第三类P帧前面不存在第三类P帧,则将GOP序列的I帧作为该第三类P帧的参考帧;For example, for each first type P frame, if the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is regarded as the first type P frame. reference frame, if the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame will be used as the reference frame of the first type P frame; for each second type P frame P frame, if there is a third type P frame before the second type P frame, then the latest third type P frame before the second type P frame is used as the reference frame of the second type P frame, if the second type P frame If there is no P frame of the third type before the P frame, the I frame of the GOP sequence is used as the reference frame of the P frame of the second type; for each P frame of the third type, if there is a P frame of the third type before the P frame of the third type, P frame, then the latest P frame of the third type before the P frame of the third type is used as the reference frame of the P frame of the third type. If there is no P frame of the third type before the P frame of the third type, the GOP sequence The I frame serves as the reference frame of the third type of P frame;
示例性的,处理模块112确定需要对GOP序列内的P帧进行抽帧,则对第一类P帧进行抽帧,或者,对第一类P帧和第二类P帧进行抽帧,或者,对第一类P帧、第二类P帧和第三类P帧进行抽帧时具体用于:若基于业务信息确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;第二抽样比例大于第一抽样比例;若基于业务信息确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧;第三抽样比例大于第二抽样比例。For example, if the processing module 112 determines that the P frames in the GOP sequence need to be extracted, then the first type of P frames need to be extracted, or the first type of P frames and the second type of P frames need to be extracted, or , when extracting frames of the first type of P frame, the second type of P frame and the third type of P frame, it is specifically used: if it is determined based on the service information that the first sampling ratio needs to be used to extract the P frame in the GOP sequence, then Perform frame extraction on all first-type P frames or part of the first-type P frames; if it is determined based on the service information that the second sampling ratio needs to be used to extract frames within the GOP sequence, then all first-type P frames shall be extracted. frame, and perform frame sampling on all second type P frames or part of the second type P frames; the second sampling ratio is greater than the first sampling ratio; if it is determined based on the business information that a third sampling ratio needs to be used to perform frame extraction on the P frames within the GOP sequence To extract frames, all P frames of the first type are extracted, all P frames of the second type are extracted, and all P frames of the third type or part of the P frames of the third type are extracted; the third sampling ratio is greater than Second sampling ratio.
示例性的,处理模块112,还用于若业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于分辨率、帧率和解码能力确定是否需要对GOP序列内的P帧进行抽帧;其中,若解码能力不支持解码分辨率和帧率的图像,则确定对GOP序列内的P帧进行抽帧;若是,则基于分辨率、帧率和解码能力确定GOP序列对应的抽样比例,抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例;或者,若业务信息包括编码端与解码端之间的目标网络对应的网络质量,则基于网络质量确定是否需要对GOP序列内的P帧进行抽帧;其中,若网络质量不是最优级别的网络质量,则确定对GOP序列内的P帧进行抽帧;若是,则基于网络质量确定GOP序列对应的抽样比例,抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。Exemplarily, the processing module 112 is also configured to determine whether it is necessary to perform decoding based on the resolution, frame rate, and decoding capability if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end. The P frames in the GOP sequence are extracted; if the decoding capability does not support images with decoding resolution and frame rate, it is determined to extract the P frames in the GOP sequence; if so, based on the resolution, frame rate and decoding The ability to determine the sampling ratio corresponding to the GOP sequence, the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio; or, if the service information includes the network quality corresponding to the target network between the encoding end and the decoding end, Then it is determined based on the network quality whether the P frame in the GOP sequence needs to be extracted; if the network quality is not the optimal level of network quality, it is determined to extract the P frame in the GOP sequence; if so, based on the network quality Determine the sampling ratio corresponding to the GOP sequence. The sampling ratio is the first sampling ratio, the second sampling ratio, or the third sampling ratio.
示例性的,当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是图像序列集合的首个GOP序列,则划分模块111,还用于将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。For example, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the first GOP sequence of the image sequence set, the dividing module 111 is also used to divide the first GOP sequence into The I frame serves as the reference frame for the first frame of the GOP sequence.
基于与上述方法同样的申请构思,本申请实施例中提出一种图像处理设备,参见图12所示,图像处理设备包括处理器1201和机器可读存储介质1202,机器可读存储介质1202存储有能够被处理器1201执行的机器可执行指令;处理器1201用于执行机器可执行指令,以实现本申请上述示例公开的图像处理方法。Based on the same application concept as the above method, an image processing device is proposed in the embodiment of the present application. As shown in Figure 12, the image processing device includes a processor 1201 and a machine-readable storage medium 1202. The machine-readable storage medium 1202 stores Machine-executable instructions that can be executed by the processor 1201; the processor 1201 is used to execute the machine-executable instructions to implement the image processing method disclosed in the above examples of this application.
基于与上述方法同样的申请构思,本申请实施例还提供一种机器可读存储介质,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被处理器执行时,能够实现本申请上述示例公开的图像处理方法。Based on the same application concept as the above method, embodiments of the present application also provide a machine-readable storage medium. Several computer instructions are stored on the machine-readable storage medium. When the computer instructions are executed by the processor, the present invention can be realized. Apply the image processing method disclosed in the above example.
其中,上述机器可读存储介质可以是任何电子、磁性、光学或其它物理存储装置,可以包含或存储信息,如可执行指令、数据,等等。例如,机器可读存储介质可以是:RAM(Radom Access Memory,随机存取存储器)、易失存储器、非易失性存储器、闪存、存储驱动器(如硬盘驱动器)、固态硬盘、任何类型的存储盘(如光盘、dvd等),或者类似的存储介质,或者它们的组合。Wherein, the above-mentioned machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device, which can contain or store information, such as executable instructions, data, etc. For example, machine-readable storage media can be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard drive), solid state drive, any type of storage disk (such as CDs, DVDs, etc.), or similar storage media, or a combination thereof.
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。
The above descriptions are only examples of the present application and are not intended to limit the present application. To those skilled in the art, various modifications and variations may be made to this application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this application shall be included in the scope of the claims of this application.
Claims (25)
- 一种图像处理方法,其特征在于,所述方法包括:An image processing method, characterized in that the method includes:将画面组GOP序列内的所有P帧划分为至少两个类型的P帧,所述至少两个类型的P帧中存在不能够作为参考帧的P帧,且所述至少两个类型的P帧中存在能够作为参考帧的P帧;Divide all P frames in the picture group GOP sequence into at least two types of P frames, there are P frames among the at least two types of P frames that cannot be used as reference frames, and the at least two types of P frames There is a P frame that can be used as a reference frame;若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧进行抽帧,或者,若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽帧。If it is determined that the P frame within the GOP sequence needs to be extracted, then the P frame that cannot be used as a reference frame will be extracted, or if it is determined that the P frame within the GOP sequence needs to be extracted, then the P frame will be extracted. P frames that cannot be used as reference frames and P frames that can be used as reference frames are extracted.
- 根据权利要求1所述的方法,其特征在于,所述方法包括:The method according to claim 1, characterized in that the method includes:将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,所述第一类P帧不能够作为参考帧,所述第二类P帧能够作为第一类P帧的参考帧、且所述第二类P帧能够作为第二类P帧的参考帧;All P frames in the GOP sequence are divided into first type P frames and second type P frames; wherein, the first type P frame cannot be used as a reference frame, and the second type P frame can be used as the first type P frame. A reference frame of the P frame type, and the P frame of the second type can be used as a reference frame of the P frame of the second type;若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧。If it is determined that the P frames in the GOP sequence need to be extracted, the first type of P frames are extracted, or the first type of P frames and the second type of P frames are extracted. .
- 根据权利要求2所述的方法,其特征在于,The method according to claim 2, characterized in that:所述将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧,包括:The method of dividing all P frames in the GOP sequence into first type P frames and second type P frames includes:基于所述GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,相邻两个第二类P帧之间存在M1个第一类P帧,所述GOP序列的I帧与第一个第二类P帧之间存在M2个第一类P帧;其中,所述M1为正整数,所述M2为正整数。Based on the positional sorting relationship between the P frames in the GOP sequence, all P frames in the GOP sequence are divided into first type P frames and second type P frames; wherein, two adjacent second type P frames There are M1 P frames of the first type between P frames, and there are M2 P frames of the first type between the I frame of the GOP sequence and the first P frame of the second type; wherein, the M1 is a positive integer, so M2 is a positive integer.
- 根据权利要求2或3所述的方法,其特征在于,The method according to claim 2 or 3, characterized in that,针对每个第一类P帧,若该第一类P帧前面存在第二类P帧,则将该第一类P帧前面最近一个第二类P帧作为该第一类P帧的参考帧,若该第一类P帧前面不存在第二类P帧,则将所述GOP序列的I帧作为该第一类P帧的参考帧;For each P frame of the first type, if there is a P frame of the second type before the P frame of the first type, the most recent P frame of the second type before the P frame of the first type is used as the reference frame of the P frame of the first type. , if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type;针对每个第二类P帧,若该第二类P帧前面存在第二类P帧,则将该第二类P帧前面最近一个第二类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第二类P帧,则将所述GOP序列的I帧作为该第二类P帧的参考帧。For each second type P frame, if there is a second type P frame before the second type P frame, the nearest second type P frame before the second type P frame is used as the reference frame of the second type P frame. , if there is no second type P frame before the second type P frame, then the I frame of the GOP sequence is used as the reference frame of the second type P frame.
- 根据权利要求2所述的方法,其特征在于,The method according to claim 2, characterized in that:所述若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,包括:If it is determined that the P frames in the GOP sequence need to be extracted, then extract the P frames of the first type, or extract the P frames of the first type and the P frames of the second type. Frame extraction, including:若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;或者,If it is determined based on the business information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames or part of the first type P frames need to be extracted; if it is determined based on the business information that it is necessary to use The second sampling ratio is to extract frames from P frames in the GOP sequence, then extract frames from all P frames of the first type, and extract frames from all P frames of the second type or part of the P frames of the second type; or,若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧;若基于业务信息确定需要采用第三抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;If it is determined based on the business information that the first sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then some of the first type P frames will be extracted; if it is determined based on the business information that the second sampling ratio needs to be used to extract the frames, To extract frames for P frames in the GOP sequence, all P frames of the first type are extracted. If it is determined based on the service information that it is necessary to use the third sampling ratio to extract frames for P frames in the GOP sequence, then all P frames of the first type are extracted. The P frames of the first type are extracted, and all the P frames of the second type or part of the P frames of the second type are extracted;其中,第二抽样比例大于第一抽样比例,第三抽样比例大于第二抽样比例。Among them, the second sampling proportion is greater than the first sampling proportion, and the third sampling proportion is greater than the second sampling proportion.
- 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method of claim 5, further comprising:若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例;或者,If the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end, then it is determined based on the resolution, the frame rate, and the decoding capability whether it is necessary to modify the GOP sequence. The P frames in the sequence are extracted; if the decoding capability does not support decoding the image with the resolution and the frame rate, it is determined to extract the P frames in the GOP sequence; if so, based on The resolution, the frame rate and the decoding capability determine the sampling ratio corresponding to the GOP sequence; or,若所述业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例;If the service information includes the network quality corresponding to the target network between the sending end and the receiving end, it is determined based on the network quality whether it is necessary to extract the P frames in the GOP sequence; wherein, if the network quality If the network quality is not the optimal level, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality;其中,所述抽样比例为第一抽样比例、或第二抽样比例;或者,Wherein, the sampling ratio is the first sampling ratio or the second sampling ratio; or,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。The sampling ratio is a first sampling ratio, a second sampling ratio, or a third sampling ratio.
- 根据权利要求1所述的方法,其特征在于,所述方法包括:The method according to claim 1, characterized in that the method includes:将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;其中,所述第一类P帧不能够作为参考帧,所述第二类P帧只能够作为第一类P帧的参考帧,所述第三类P帧能够作为第一类P帧的参考帧、且能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧;All P frames in the GOP sequence are divided into first type P frames, second type P frames and third type P frames; wherein the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame. A P frame can only be used as a reference frame of the first type of P frame, and the third type of P frame can be used as a reference frame of the first type of P frame, and can be used as a reference frame of the second type of P frame, and can be used as a reference frame of the third type of P frame. Reference frame of P frame;若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧。If it is determined that the P frames in the GOP sequence need to be extracted, the first type of P frames are extracted, or the first type of P frames and the second type of P frames are extracted. , or perform frame extraction on the first type P frame, the second type P frame and the third type P frame.
- 根据权利要求7所述的方法,其特征在于,所述将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧,包括:The method according to claim 7, characterized in that dividing all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames includes:基于所述GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;Based on the positional ordering relationship between the P frames in the GOP sequence, divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames;其中,相邻两个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且所述一个第二类P帧位于所述两个第一类P帧之间;Wherein, there are two P frames of the first type and one P frame of the second type between two adjacent P frames of the third type, and the P frame of the second type is located between the two P frames of the first type. ;所述GOP序列的I帧与第一个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且这个第二类P帧位于这两个第一类P帧之间。There are two first-type P frames and one second-type P frame between the I-frame of the GOP sequence and the first third-type P frame, and this second-type P frame is located between the two first-type P frames. between.
- 根据权利要求7或8所述的方法,其特征在于,The method according to claim 7 or 8, characterized in that,针对每个第一类P帧,若该第一类P帧的前一帧不是第一类P帧,则将该第一类P帧的前一帧作为该第一类P 帧的参考帧,若该第一类P帧的前一帧是第一类P帧,则将前面最近一个非第一类P帧作为该第一类P帧的参考帧;For each first type P frame, if the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is regarded as the first type P frame. The reference frame of the frame, if the previous frame of the first type P frame is the first type P frame, then the most recent non-first type P frame is used as the reference frame of the first type P frame;针对每个第二类P帧,若该第二类P帧前面存在第三类P帧,则将该第二类P帧前面最近一个第三类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第二类P帧的参考帧;For each P frame of the second type, if there is a P frame of the third type before the P frame of the second type, the nearest P frame of the third type before the P frame of the second type is used as the reference frame of the P frame of the second type. , if there is no third type P frame before the second type P frame, then the I frame of the GOP sequence is used as the reference frame of the second type P frame;针对每个第三类P帧,若该第三类P帧前面存在第三类P帧,则将该第三类P帧前面最近一个第三类P帧作为该第三类P帧的参考帧,若该第三类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第三类P帧的参考帧。For each type 3 P frame, if there is a type 3 P frame before the type 3 P frame, then the latest type 3 P frame before the type 3 P frame is used as the reference frame of the type 3 P frame. , if there is no third type P frame before the third type P frame, then the I frame of the GOP sequence is used as the reference frame of the third type P frame.
- 根据权利要求7所述的方法,其特征在于,The method according to claim 7, characterized in that:所述若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧,包括:If it is determined that the P frames in the GOP sequence need to be extracted, then extract the P frames of the first type, or extract the P frames of the first type and the P frames of the second type. Frame extraction, or frame extraction for the first type of P frame, the second type of P frame and the third type of P frame, including:若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;If it is determined based on the service information that the first sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all first-type P frames or part of the first-type P frames;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;其中,所述第二抽样比例大于所述第一抽样比例;If it is determined based on the service information that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then all the first type P frames will be extracted, and all the second type P frames or part of the second type P frames will be extracted. The frame is extracted; wherein the second sampling ratio is greater than the first sampling ratio;若基于业务信息确定需要采用第三抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧;第三抽样比例大于第二抽样比例。If it is determined based on the service information that the third sampling ratio needs to be used to extract frames from the P frames in the GOP sequence, then extract frames from all P frames of the first type, extract frames from all P frames of the second type, and extract frames from all P frames of the second type. The third type P frame or part of the third type P frame is extracted; the third sampling ratio is greater than the second sampling ratio.
- 根据权利要求10所述的方法,其特征在于,所述方法还包括:The method of claim 10, further comprising:若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例;或者,If the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence, and the decoding capability corresponding to the decoding end, then it is determined based on the resolution, the frame rate, and the decoding capability whether it is necessary to modify the GOP sequence. The P frames in the sequence are extracted; if the decoding capability does not support decoding the image with the resolution and the frame rate, it is determined to extract the P frames in the GOP sequence; if so, based on The resolution, the frame rate and the decoding capability determine the sampling ratio corresponding to the GOP sequence, and the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio; or,若所述业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。If the service information includes the network quality corresponding to the target network between the sending end and the receiving end, it is determined based on the network quality whether it is necessary to extract the P frames in the GOP sequence; wherein, if the network quality If the network quality is not the optimal level, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, and the sampling ratio is the first sampling ratio. , or the second sampling ratio, or the third sampling ratio.
- 根据权利要求2或7所述的方法,其特征在于,所述方法还包括:The method according to claim 2 or 7, characterized in that, the method further includes:当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是所述图像序列集合的首个GOP序列,则将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。When the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the first GOP sequence of the image sequence set, the I frame of the first GOP sequence is regarded as the first of the GOP sequence. The reference frame of the frame.
- 一种图像处理装置,其特征在于,所述装置包括:An image processing device, characterized in that the device includes:划分模块,用于将画面组GOP序列内的所有P帧划分为至少两个类型的P帧,所述至少两个类型的P帧中存在不能够作为参考帧的P帧,且所述至少两个类型的P帧中存在能够作为参考帧的P帧;A dividing module, configured to divide all P frames in the picture group GOP sequence into at least two types of P frames. Among the at least two types of P frames, there are P frames that cannot be used as reference frames, and the at least two types of P frames Among the types of P frames, there is a P frame that can be used as a reference frame;处理模块,用于若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧进行抽帧,或者,若确定需要对所述GOP序列内的P帧进行抽帧,则对不能够作为参考帧的P帧和能够作为参考帧的P帧进行抽帧。A processing module, configured to extract frames from P frames that cannot be used as reference frames if it is determined that the P frames in the GOP sequence need to be extracted, or if it is determined that the P frames in the GOP sequence need to be extracted. For frame extraction, frame extraction is performed on P frames that cannot be used as reference frames and P frames that can be used as reference frames.
- 根据权利要求13所述的装置,其特征在于,The device according to claim 13, characterized in that:所述划分模块,具体用于将GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,所述第一类P帧不能够作为参考帧,所述第二类P帧能够作为第一类P帧的参考帧、且所述第二类P帧能够作为第二类P帧的参考帧;所述处理模块,具体用于若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧。The dividing module is specifically used to divide all P frames in the GOP sequence into first type P frames and second type P frames; wherein, the first type P frame cannot be used as a reference frame, and the second type P frame cannot be used as a reference frame. The P frame can be used as the reference frame of the first type of P frame, and the second type of P frame can be used as the reference frame of the second type of P frame; the processing module is specifically used to determine that it is necessary to When the P frame is extracted, the first type of P frame is extracted, or the first type of P frame and the second type of P frame are extracted.
- 根据权利要求14所述的装置,其特征在于,The device according to claim 14, characterized in that:所述划分模块将GOP序列内的所有P帧划分为第一类P帧和第二类P帧时具体用于:基于所述GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧和第二类P帧;其中,相邻两个第二类P帧之间存在M1个第一类P帧,所述GOP序列的I帧与第一个第二类P帧之间存在M2个第一类P帧;M1和M2均为正整数。When the dividing module divides all P frames in the GOP sequence into first type P frames and second type P frames, it is specifically used to: based on the position ordering relationship between the P frames in the GOP sequence, divide the All P frames in the GOP sequence are divided into first type P frames and second type P frames; wherein, there are M1 first type P frames between two adjacent second type P frames, and the I frame of the GOP sequence There are M2 type-1 P frames between it and the first type-2 P frame; M1 and M2 are both positive integers.
- 根据权利要求14或15所述的装置,其特征在于,The device according to claim 14 or 15, characterized in that,针对每个第一类P帧,若该第一类P帧前面存在第二类P帧,则将该第一类P帧前面最近一个第二类P帧作为该第一类P帧的参考帧,若该第一类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第二类P帧,则将该第二类P帧前面最近一个第二类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第二类P帧,则将GOP序列的I帧作为该第二类P帧的参考帧。For each P frame of the first type, if there is a P frame of the second type before the P frame of the first type, the most recent P frame of the second type before the P frame of the first type is used as the reference frame of the P frame of the first type. , if there is no P frame of the second type before the P frame of the first type, then the I frame of the GOP sequence is used as the reference frame of the P frame of the first type; for each P frame of the second type, if the P frame of the second type If there is a P frame of the second type before the frame, the most recent P frame of the second type before the P frame of the second type is used as the reference frame of the P frame of the second type. If there is no P frame of the second type before the P frame of the second type. frame, the I frame of the GOP sequence is used as the reference frame of the second type of P frame.
- 根据权利要求14所述的装置,其特征在于,The device according to claim 14, characterized in that:所述处理模块确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧时具体用于:若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;或者,若基于业务信息确定需要采用第一抽样比例对所述GOP序列内的P帧进行抽帧,则对部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧;若基于业务信息确定需要采用第三抽样比例对所述GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;其中,第二抽样比例大于第一抽样比例,第三抽样比例大于第二抽样比例。When the processing module determines that it is necessary to extract frames from P frames in the GOP sequence, extract frames from the first type of P frames, or extract frames from the first type of P frames and the second type of P frames. When performing frame extraction, it is specifically used: if it is determined based on the service information that the first sampling ratio needs to be used to extract the P frames in the GOP sequence, then extract the frames for all the first type P frames or part of the first type P frames. ; If it is determined based on the service information that the second sampling ratio needs to be used to extract the P frames in the GOP sequence, then extract the frames for all the first type P frames, and extract all the second type P frames or part of the second type. P frames are extracted; or, if it is determined based on the service information that it is necessary to use the first sampling ratio to extract the P frames in the GOP sequence, then some of the first type P frames are extracted; if it is determined based on the service information that it is necessary Using the second sampling ratio to extract frames from the P frames in the GOP sequence, all P frames of the first type are extracted; if it is determined based on the service information that it is necessary to use the third sampling ratio to extract the P frames in the GOP sequence To perform frame extraction, all P-frames of the first type are extracted, and all P-frames of the second type or part of the P-frames of the second type are extracted; among them, the second sampling ratio is greater than the first sampling ratio, and the third sampling ratio The proportion is greater than the second sampling proportion.
- 根据权利要求17所述的装置,其特征在于, The device according to claim 17, characterized in that:所述处理模块,还用于若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例;或者,若所述业务信息包括发送端与接收端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例;所述抽样比例为第一抽样比例、或第二抽样比例;或者,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。The processing module is also configured to: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence and the decoding capability corresponding to the decoding end, based on the resolution, the frame rate and the decoding The ability determines whether it is necessary to perform frame extraction on the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and the frame rate, determine whether the P frames in the GOP sequence need to be decoded. Perform frame extraction; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability; or, if the service information includes the target network between the sending end and the receiving end According to the corresponding network quality, it is determined based on the network quality whether it is necessary to extract frames from the P frames in the GOP sequence; wherein, if the network quality is not the optimal level of network quality, it is determined that the P frames in the GOP sequence need to be extracted. P frames are extracted; if so, determine the sampling ratio corresponding to the GOP sequence based on the network quality; the sampling ratio is the first sampling ratio, or the second sampling ratio; or, the sampling ratio is the first sampling ratio Sampling proportion, or second sampling proportion, or third sampling proportion.
- 根据权利要求12所述的装置,其特征在于,The device according to claim 12, characterized in that:所述划分模块,具体用于用于将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;所述第一类P帧不能够作为参考帧,所述第二类P帧只能够作为第一类P帧的参考帧,所述第三类P帧能够作为第一类P帧的参考帧、能够作为第二类P帧的参考帧、且能够作为第三类P帧的参考帧;所述处理模块,具体用于若确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧。The division module is specifically used to divide all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames; the first type P frame cannot be used as a reference frame. , the second type of P frame can only be used as a reference frame of the first type of P frame, the third type of P frame can be used as a reference frame of the first type of P frame, can be used as a reference frame of the second type of P frame, and Can be used as a reference frame of the third type of P frame; the processing module is specifically configured to extract frames of the first type of P frame if it is determined that the P frame in the GOP sequence needs to be extracted, or, The P frames of the first type and the P frames of the second type are extracted, or the P frames of the first type, the P frames of the second type and the P frames of the third type are extracted.
- 根据权利要求19所述的装置,其特征在于,The device according to claim 19, characterized in that:所述划分模块将GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧时具体用于:基于GOP序列内的各P帧之间的位置排序关系,将所述GOP序列内的所有P帧划分为第一类P帧、第二类P帧和第三类P帧;其中,针对所述GOP序列内的所有P帧,相邻两个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且所述一个第二类P帧位于所述两个第一类P帧之间;所述GOP序列的I帧与第一个第三类P帧之间存在两个第一类P帧和一个第二类P帧,且这个第二类P帧位于这两个第一类P帧之间。When the division module divides all P frames in the GOP sequence into first type P frames, second type P frames and third type P frames, it is specifically used to: based on the positional sorting relationship between each P frame in the GOP sequence. , all P frames in the GOP sequence are divided into first type P frames, second type P frames and third type P frames; wherein, for all P frames in the GOP sequence, two adjacent third type P frames There are two first type P frames and one second type P frame between the type P frames, and the one second type P frame is located between the two first type P frames; the I frame of the GOP sequence There are two P frames of the first type and one P frame of the second type between the first P frame of the third type, and the P frame of the second type is located between the two P frames of the first type.
- 根据权利要求19或20所述的装置,其特征在于,The device according to claim 19 or 20, characterized in that,针对每个第一类P帧,若该第一类P帧的前一帧不是第一类P帧,则将该第一类P帧的前一帧作为该第一类P帧的参考帧,若该第一类P帧的前一帧是第一类P帧,则将前面最近一个非第一类P帧作为该第一类P帧的参考帧;针对每个第二类P帧,若该第二类P帧前面存在第三类P帧,则将该第二类P帧前面最近一个第三类P帧作为该第二类P帧的参考帧,若该第二类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第二类P帧的参考帧;针对每个第三类P帧,若该第三类P帧前面存在第三类P帧,则将该第三类P帧前面最近一个第三类P帧作为该第三类P帧的参考帧,若该第三类P帧前面不存在第三类P帧,则将所述GOP序列的I帧作为该第三类P帧的参考帧。For each first type P frame, if the previous frame of the first type P frame is not the first type P frame, then the previous frame of the first type P frame is used as the reference frame of the first type P frame, If the previous frame of the first type P frame is a first type P frame, then the most recent non-first type P frame is used as the reference frame of the first type P frame; for each second type P frame, if There is a P frame of the third type before the P frame of the second type, then the P frame of the third type most recent before the P frame of the second type is used as the reference frame of the P frame of the second type. If there is no P frame of the second type before it, If there is a P frame of the third type, the I frame of the GOP sequence is used as the reference frame of the P frame of the second type; for each P frame of the third type, if there is a P frame of the third type before the P frame of the third type , then the latest P frame of the third type before the P frame of the third type is used as the reference frame of the P frame of the third type. If there is no P frame of the third type before the P frame of the third type, then the GOP sequence The I frame serves as the reference frame of the third type of P frame.
- 根据权利要求19所述的装置,其特征在于,The device according to claim 19, characterized in that:所述处理模块确定需要对所述GOP序列内的P帧进行抽帧,则对所述第一类P帧进行抽帧,或者,对所述第一类P帧和所述第二类P帧进行抽帧,或者,对所述第一类P帧、所述第二类P帧和所述第三类P帧进行抽帧时具体用于:若基于业务信息确定需要采用第一抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧或部分第一类P帧进行抽帧;若基于业务信息确定需要采用第二抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,并对所有第二类P帧或部分第二类P帧进行抽帧;第二抽样比例大于第一抽样比例;若基于业务信息确定需要采用第三抽样比例对GOP序列内的P帧进行抽帧,则对所有第一类P帧进行抽帧,对所有第二类P帧进行抽帧,并对所有第三类P帧或部分第三类P帧进行抽帧;第三抽样比例大于第二抽样比例。When the processing module determines that it is necessary to extract frames from P frames in the GOP sequence, extract frames from the first type of P frames, or extract frames from the first type of P frames and the second type of P frames. Performing frame extraction, or performing frame extraction on the first type P frame, the second type P frame and the third type P frame is specifically used for: if it is determined based on the service information that the first sampling ratio needs to be used To extract frames for P frames in the GOP sequence, all first-type P frames or part of the first-type P frames are extracted; if it is determined based on the service information that a second sampling ratio needs to be used to extract frames for P frames in the GOP sequence , then extract frames from all first-type P frames, and extract frames from all second-type P frames or part of second-type P frames; the second sampling ratio is greater than the first sampling ratio; if it is determined based on the service information that it is necessary to use the second The three-sampling ratio is used to extract frames from P frames in the GOP sequence. Then all P frames of the first type are extracted, all P frames of the second type are extracted, and all P frames of the third type or part of the third type are extracted. The P frame is extracted; the third sampling ratio is greater than the second sampling ratio.
- 根据权利要求22所述的装置,其特征在于,The device according to claim 22, characterized in that:所述处理模块,还用于若所述业务信息包括GOP序列对应的分辨率、GOP序列对应的帧率和解码端对应的解码能力,则基于所述分辨率、所述帧率和所述解码能力确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述解码能力不支持解码所述分辨率和所述帧率的图像,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述分辨率、所述帧率和所述解码能力确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例;或者,若所述业务信息包括编码端与解码端之间的目标网络对应的网络质量,则基于所述网络质量确定是否需要对所述GOP序列内的P帧进行抽帧;其中,若所述网络质量不是最优级别的网络质量,则确定对所述GOP序列内的P帧进行抽帧;若是,则基于所述网络质量确定所述GOP序列对应的抽样比例,所述抽样比例为第一抽样比例、或第二抽样比例、或第三抽样比例。The processing module is also configured to: if the service information includes the resolution corresponding to the GOP sequence, the frame rate corresponding to the GOP sequence and the decoding capability corresponding to the decoding end, based on the resolution, the frame rate and the decoding The ability determines whether it is necessary to perform frame extraction on the P frames in the GOP sequence; wherein, if the decoding capability does not support decoding images of the resolution and the frame rate, determine whether the P frames in the GOP sequence need to be decoded. Perform frame extraction; if so, determine the sampling ratio corresponding to the GOP sequence based on the resolution, the frame rate and the decoding capability, and the sampling ratio is the first sampling ratio, or the second sampling ratio, or the third sampling ratio. Three sampling ratios; or, if the service information includes the network quality corresponding to the target network between the encoding end and the decoding end, determine whether the P frames in the GOP sequence need to be extracted based on the network quality; where , if the network quality is not the optimal level of network quality, it is determined to extract frames from the P frames in the GOP sequence; if so, the sampling ratio corresponding to the GOP sequence is determined based on the network quality, and the sampling The proportion is the first sampling proportion, or the second sampling proportion, or the third sampling proportion.
- 根据权利要求14或19所述的装置,其特征在于,The device according to claim 14 or 19, characterized in that,其中,当图像序列集合包括至少两个GOP序列时,针对每个GOP序列,若该GOP序列不是所述图像序列集合的首个GOP序列,则所述划分模块,还用于将首个GOP序列的I帧作为该GOP序列的第一帧的参考帧。Wherein, when the image sequence set includes at least two GOP sequences, for each GOP sequence, if the GOP sequence is not the first GOP sequence of the image sequence set, the dividing module is also used to divide the first GOP sequence into The I frame serves as the reference frame for the first frame of the GOP sequence.
- 一种图像处理设备,其特征在于,包括:处理器和机器可读存储介质,所述机器可读存储介质存储有能够被所述处理器执行的机器可执行指令;所述处理器用于执行机器可执行指令,以实现权利要求1-12任一所述的方法步骤。 An image processing device, characterized in that it includes: a processor and a machine-readable storage medium, the machine-readable storage medium stores machine-executable instructions that can be executed by the processor; the processor is used to execute the machine The instructions are executable to implement the method steps described in any one of claims 1-12.
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210731347.8A CN115150610A (en) | 2022-06-24 | 2022-06-24 | Image processing method, device and equipment |
CN202210731349.7 | 2022-06-24 | ||
CN202210731347.8 | 2022-06-24 | ||
CN202210731349.7A CN115150611A (en) | 2022-06-24 | 2022-06-24 | Image processing method, device and equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023246936A1 true WO2023246936A1 (en) | 2023-12-28 |
Family
ID=89379207
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/102139 WO2023246936A1 (en) | 2022-06-24 | 2023-06-25 | Image processing method and apparatus, and device |
Country Status (1)
Country | Link |
---|---|
WO (1) | WO2023246936A1 (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101257628A (en) * | 2008-03-20 | 2008-09-03 | 武汉大学 | Adjustable compressing method for realizing video code stream frame rate |
CN101621688A (en) * | 2009-04-30 | 2010-01-06 | 武汉大学 | Codec method for realizing AVS video standard time domain classification |
US20130156105A1 (en) * | 2011-12-16 | 2013-06-20 | Apple Inc. | High quality seamless playback for video decoder clients |
US20170118474A1 (en) * | 2013-06-24 | 2017-04-27 | Kyeong Ho Yang | Rate control algorithm for scalable video encoding with disposable p-frames |
CN111405288A (en) * | 2020-03-19 | 2020-07-10 | 北京字节跳动网络技术有限公司 | Video frame extraction method and device, electronic equipment and computer readable storage medium |
CN112291566A (en) * | 2020-06-19 | 2021-01-29 | 珠海市杰理科技股份有限公司 | H.264 video coding method, device, chip, storage equipment and electronic equipment |
CN112866746A (en) * | 2020-12-31 | 2021-05-28 | 杭州雾联科技有限公司 | Multi-path streaming cloud game control method, device, equipment and storage medium |
CN115150611A (en) * | 2022-06-24 | 2022-10-04 | 杭州海康威视数字技术股份有限公司 | Image processing method, device and equipment |
CN115150610A (en) * | 2022-06-24 | 2022-10-04 | 杭州海康威视数字技术股份有限公司 | Image processing method, device and equipment |
-
2023
- 2023-06-25 WO PCT/CN2023/102139 patent/WO2023246936A1/en unknown
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101257628A (en) * | 2008-03-20 | 2008-09-03 | 武汉大学 | Adjustable compressing method for realizing video code stream frame rate |
CN101621688A (en) * | 2009-04-30 | 2010-01-06 | 武汉大学 | Codec method for realizing AVS video standard time domain classification |
US20130156105A1 (en) * | 2011-12-16 | 2013-06-20 | Apple Inc. | High quality seamless playback for video decoder clients |
US20170118474A1 (en) * | 2013-06-24 | 2017-04-27 | Kyeong Ho Yang | Rate control algorithm for scalable video encoding with disposable p-frames |
CN111405288A (en) * | 2020-03-19 | 2020-07-10 | 北京字节跳动网络技术有限公司 | Video frame extraction method and device, electronic equipment and computer readable storage medium |
CN112291566A (en) * | 2020-06-19 | 2021-01-29 | 珠海市杰理科技股份有限公司 | H.264 video coding method, device, chip, storage equipment and electronic equipment |
CN112866746A (en) * | 2020-12-31 | 2021-05-28 | 杭州雾联科技有限公司 | Multi-path streaming cloud game control method, device, equipment and storage medium |
CN115150611A (en) * | 2022-06-24 | 2022-10-04 | 杭州海康威视数字技术股份有限公司 | Image processing method, device and equipment |
CN115150610A (en) * | 2022-06-24 | 2022-10-04 | 杭州海康威视数字技术股份有限公司 | Image processing method, device and equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100667806B1 (en) | Method and apparatus for video encoding and decoding | |
CN1193601C (en) | Method and apparatus for storing compressed audio and video data of MPEG | |
EP2096870A2 (en) | Systems and methods for processing multiple projections of video data in a single video file | |
US6025888A (en) | Method and apparatus for improved error recovery in video transmission over wireless channels | |
WO2011004598A1 (en) | Video encoding method, device, program, and integrated circuit | |
WO2021114846A1 (en) | Video noise cancellation processing method and apparatus, and storage medium | |
JP3302939B2 (en) | Video signal decompressor for independently compressed even and odd field data | |
TW201127048A (en) | Inverse telecine techniques | |
CN1220065A (en) | System and method for creating trick play video streams from compressed normal play video bitstream | |
JP5232114B2 (en) | Image coding apparatus and image coding method | |
US20180007375A1 (en) | Image encoding and decoding methods and devices thereof | |
CN107770600A (en) | Transmission method, device, equipment and the storage medium of stream medium data | |
JP2022141586A (en) | Cloud Gaming GPU with Integrated NIC and Shared Frame Buffer Access for Low Latency | |
US20060165172A1 (en) | Method for transmitting data without jitter in synchronous Ethernet | |
CN115150610A (en) | Image processing method, device and equipment | |
CN101138246A (en) | Buffering of video stream data | |
US7403566B2 (en) | System, computer program product, and method for transmitting compressed screen images from one computer to another or many computers | |
WO2023246936A1 (en) | Image processing method and apparatus, and device | |
KR100860661B1 (en) | Image reproducing method and image processing method, and image reproducing device, image processing device, and television receiver capable of using the methods | |
CN115150611A (en) | Image processing method, device and equipment | |
WO2024113869A1 (en) | Video coding method and related apparatus | |
CN103379320A (en) | Method and device for processing video image code stream | |
CN115278313A (en) | Video concurrent speed doubling method with high multiplying power and multiple paths | |
US9591319B2 (en) | Video encoder | |
CN111212288B (en) | Video data encoding and decoding method and device, computer equipment and storage medium |
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: 23826581 Country of ref document: EP Kind code of ref document: A1 |