A method, device and equipment for encoding and decoding
By dividing the strips of the video image into multiple code stream segments and performing interleaving, encoding and deinterleaving, the storage and delay problems in parallel processing of multiple strips in video encoding are solved, and efficient resource utilization and low-latency transmission are achieved. .
Patent Information
- Application Number
- CN202210273469.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2042-03-18
AI Technical Summary
In the video encoding process, in order to achieve efficient compression and fast transmission, large-resolution images need to be encoded and decoded in parallel with multiple strips. However, this requires caching the code streams of all strips of the entire image, resulting in large storage resource usage and inability to Meet the latency requirements of low-latency scenarios.
Divide each strip into multiple code stream segments, interleave and encode these segments at the encoding end to generate the target code stream, and deinterleave the target code stream at the decoding end to obtain the code stream segments of each strip, thus Avoid caching the code streams of all stripes, save storage resources and achieve parallel decoding of multiple strips.
Through this method, the occupation of storage resources is reduced, the delay requirements of low-latency scenarios are met, and the efficiency of encoding and decoding is improved.
Smart Images

Figure CN116095340B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of coding and decoding technology, and in particular to a coding and decoding method, device and equipment thereof. Background Art
[0002] In order to save space, video images are transmitted after being encoded. The complete video encoding method may include prediction, transformation, quantization, entropy coding, filtering and other processes. Predictive coding may 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 the adjacent encoded images to remove the redundancy in the video time domain. Intra-frame coding takes into account the strong spatial correlation between adjacent blocks, and uses the surrounding reconstructed pixels as reference pixels to predict the current uncoded block. It only needs to perform subsequent encoding processing on the residual value instead of encoding the original value, which effectively removes the redundancy in the spatial domain and greatly improves the compression efficiency.
[0003] In the video encoding process, for each coding block, the original input signal is predicted to generate a residual signal, removing the time and space redundancy, and then the residual signal is transformed to make the energy of the residual signal more concentrated. Next, quantization is performed by adjusting the quantization step size, using a larger quantization step size for high-frequency signals and a smaller quantization step size for low-frequency signals to ensure that the basic information of the image is not lost. The last step is the entropy coding process, which encodes non-binary coded information into binary information, removes coding redundancy, and finally outputs a binary code stream, that is, the binary code stream after entropy coding is transmitted.
[0004] In the video encoding process, an image needs to be divided into several non-overlapping strips, each strip needs to be encoded, and the code stream of each strip (i.e., the binary code stream after entropy coding) is sent to the decoding end in turn. In the video decoding process, the decoding end receives the code stream and decodes each strip in turn based on the code stream to obtain a reconstructed image.
[0005] For large-resolution images, the encoder needs to encode multiple strips in parallel to improve the encoder throughput, and the decoder needs to decode multiple strips in parallel to improve the decoder throughput. To achieve this goal, it is necessary to cache the bitstreams of all strips of the entire image, which requires a large amount of storage resources. Moreover, the decoder needs to cache the bitstreams of all strips before it can decode multiple strips in parallel, which means that it takes a long time to complete the caching, which cannot meet the latency requirements of low-latency scenarios. Summary of the invention
[0006] The present application provides a coding method, the method comprising: dividing a to-be-processed image into X*Y stripes, where X is the number of stripes in the horizontal direction, Y is the number of stripes in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; determining the number of code stream segments in each stripe; encoding the X stripes in the horizontal direction of the same stripe row to obtain X bit stream buffers corresponding to the X stripes; for each bit stream buffer, dividing the bit stream buffer into code stream segments of the number of code stream segments; wherein, in the code stream segments of the number of code stream segments, there are at least two sizes of code stream segments; interleaving the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain a target code stream; and sending the target code stream to a decoding end.
[0007] The present application provides a decoding method, the method comprising: dividing a to-be-processed image into X*Y stripes, where X is the number of stripes in the horizontal direction, Y is the number of stripes in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; determining the number of code stream segments in each stripe; deinterleaving the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target code stream to obtain the number of code stream segments corresponding to each stripe; wherein, among the number of code stream segments, there are at least two sizes of code stream segments; decoding the X stripes based on the bit stream buffer corresponding to the X stripes in the horizontal direction of the same stripe row; wherein the bit stream buffer corresponding to each stripe includes the code stream segment corresponding to the stripe.
[0008] The present application provides an encoding device, the encoding device comprising: a memory configured to store video data; an encoder configured to implement:
[0009] The image to be processed is divided into X*Y stripes, where X is the number of stripes in the horizontal direction, Y is the number of stripes in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; the number of code stream segments in each stripe is determined; the X stripes in the horizontal direction of the same stripe row are encoded to obtain X bit stream buffers corresponding to the X stripes; for each bit stream buffer, the bit stream buffer is divided into code stream segments of the number of code stream segments; wherein, in the code stream segments of the number of code stream segments, there are at least two sizes of code stream segments; the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row are interleaved to obtain a target code stream; and the target code stream is sent to a decoding end.
[0010] The present application provides a decoding device, the decoding device comprising: a memory configured to store video data; a decoder configured to implement:
[0011] The image to be processed is divided into X*Y stripes, where X is the number of stripes in the horizontal direction, Y is the number of stripes in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; the number of code stream segments in each stripe is determined; the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target code stream are deinterleaved to obtain the number of code stream segments corresponding to each stripe; wherein, among the number of code stream segments, there are at least two sizes of code stream segments; based on the bit stream buffer corresponding to the X stripes in the horizontal direction of the same stripe row, the X stripes are decoded; wherein the bit stream buffer corresponding to each stripe includes the code stream segment corresponding to the stripe.
[0012] The present application provides an encoding end device, comprising: a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor;
[0013] The processor is used to execute machine executable instructions to implement the encoding method of the above example.
[0014] The present application provides a decoding end device, comprising: a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor;
[0015] The processor is used to execute machine executable instructions to implement the decoding method of the above example.
[0016] It can be seen from the above technical solution that in the embodiment of the present application, for each stripe, the stripe can be divided into multiple code stream segments, the encoding end interweaves all the code stream segments into the target code stream, and sends the target code stream to the decoding end, the decoding end deinterleaves the code stream segments in the target code stream, obtains the code stream segments corresponding to each stripe, and decodes the code stream segments, thereby avoiding caching the code streams of all stripes of the entire image, saving storage resources, and the decoding end does not need to cache all the code streams to be able to decode multiple strips in parallel, which can meet the latency requirements of low-latency scenarios. For example, the code stream segment interleaving process at the encoding end: the encoding end first adds the code stream segment a1 of stripe a to the target code stream, then adds the code stream segment b1 of stripe b to the target code stream, then adds the code stream segment a2 of stripe a to the target code stream, then adds the code stream segment b2 of stripe b to the target code stream, and so on. The decoding end deinterleaving process of the bitstream segments: the decoding end deinterleaves the bitstream segments a1 and b1 from the target bitstream, caches the bitstream segment a1 to the bitstream buffer of slice a, caches the bitstream segment b1 to the bitstream buffer of slice b, deinterleaves the bitstream segments a2 and b2 from the target bitstream, caches the bitstream segment a2 to the bitstream buffer of slice a, caches the bitstream segment b2 to the bitstream buffer of slice b, and so on. After the codestream segments a1 and the codestream segments b1 are cached in their respective corresponding bitstream buffers, the codestream segments a1 and the codestream segments b1 can be decoded in parallel without waiting for subsequent codestream segments (such as the codestream segments a2 and the codestream segments b2) to be cached in their respective corresponding bitstream buffers, thereby reducing the waiting time and meeting the latency requirement of the low-latency scenario. After the codestream segments a1 and the codestream segments b1 are decoded in parallel, the codestream segments a1 and the codestream segments b1 can be deleted from their respective corresponding bitstream buffers to save storage resources, that is, there is no need to cache all the codestream segments of all stripes at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1A-1F is a schematic diagram of encoding and decoding in one embodiment of the present application;
[0018] Figure 2A and Figure 2B is a flowchart of an encoding method and a decoding method in one embodiment of the present application;
[0019] Figure 3A and Figure 3B is a schematic diagram of a strip in one embodiment of the present application;
[0020] Figure 4A-4D is a schematic diagram of the fragment size in one embodiment of the present application;
[0021] Figure 5A-Figure 5C is a schematic diagram of the fragment size in one embodiment of the present application;
[0022] Figure 6A-6C is a schematic diagram of the fragment size in one embodiment of the present application;
[0023] Fig. 7A and Figure 7B is a schematic diagram of the fragment size in one embodiment of the present application;
[0024] Fig. 8A and Figure 8B is a schematic diagram of the fragment size in one embodiment of the present application;
[0025] Fig. 9A is a hardware structure diagram of a decoding end device in one embodiment of the present application;
[0026] Fig. 9B It is a hardware structure diagram of an encoding end device in one implementation of the present application. DETAILED DESCRIPTION
[0027] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, rather than for limiting the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to any or all possible combinations of one or more associated listed items. It should be understood that, although the terms first, second, third, etc. may be used to describe various information in the embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information, which may depend on the context, and in addition, the term "if" used may be interpreted as "at ... ", or "when ... ", or "in response to determination".
[0028] In order to enable those skilled in the art to better understand the technical solution of the present application, the technical terms are briefly explained below.
[0029] Image width (image_width): A 16-bit unsigned integer, which is the width of the image brightness component, that is, the number of samples in the horizontal direction. The unit of image_width is the number of samples per row of the image. The upper left corner sample of the displayable area is aligned with the upper left corner sample of the image. The value of ImageWidth is equal to the value of image_width. The value of ImageWidth is not 0 and is an integer multiple of 16.
[0030] Image height (image_height): a 16-bit unsigned integer, which is the height of the image brightness component, that is, the number of vertical scanning lines. The unit of image_height is the number of rows of image samples. The value of ImageHeight can be equal to the value of image_height, the value of ImageHeight is not 0, and the value of ImageHeight can be an integer multiple of 2.
[0031] real_width and real_height are the real width and real height. For the relationship between real_width and real_height and the image boundary, see Figure 1A As shown. Figure 1A In the figure, the solid line represents the boundary of the image displayable area, and the width and height of the boundary of the displayable area are determined by real_width and real_height respectively. The dotted line represents the image boundary, and the width and height of the image boundary are determined by image_width and image_height respectively. In the subsequent embodiments, image_width and image_height are taken as examples.
[0032] Slice: A slice is a fixed rectangular area in an image, containing several coding units (i.e. coding blocks), and there is no overlap between slices. Figure 1B As shown, the structural relationship of several stripes is shown, and each stripe may include multiple coding units. Figure 1B Take stripe A, stripe B, stripe C, stripe D, stripe E, stripe F, stripe G, stripe H and stripe I as an example. Figure 1C As shown, three stripe structural relationships are shown. The upper left figure shows the structural relationship of 4 stripes, the upper right figure shows the structural relationship of 2 stripes, and the lower figure shows the structural relationship of 8 stripes.
[0033] Slice width (slice_width) and slice height (slice_height): The slice width and slice height are parameters set by the encoder, which are the width and height of the slice, with the coding unit CU as the unit. Let SliceNumX represent the number of slices in the horizontal direction of an image, and SliceNumY represent the number of slices in the vertical direction of an image. See Figure 1D As shown, the distribution relationship between stripes is shown. The strip width and strip height can be seen in Figure 1D shown.
[0034] Exemplarily, SlicenumX and SlicenumY are calculated as follows: SliceNumX=(ImageWidth+SliceWidth−1) / SliceWidth; SliceNumY=(ImageHeight+SliceHeight−1) / SliceHeight.
[0035] bpp (bit per pixel): indicates the average number of bits required to express each pixel. For example, for a 10-bit original image in YUV444 format, the bpp per pixel is 30.
[0036] Target bpp (target bit per pixel): a parameter specified by the encoder, indicating the average number of bits required to express each pixel after compression. For example, for a 10-bit YUV444 original image, the target bpp per pixel is 5. Obviously, when the bpp per pixel is 30, it means a 6-fold compression.
[0037] The video coding framework applicable to this application: see Figure 1E As shown, the video encoding framework can be used to implement the encoding end processing flow of the embodiment of the present application, and the schematic diagram of the video decoding framework is similar to Figure 1E Similarly, no further description will be given here, and the decoding end processing flow of the embodiment of the present application can be implemented using a video decoding framework. In the video encoding framework and the video decoding framework, it may include but is not limited to: intra-frame prediction, motion estimation / motion compensation, reference image buffer, in-loop filtering, reconstruction, transformation, quantization, inverse transformation, inverse quantization, entropy encoder and other modules. At the encoding end, through the cooperation between these modules, the processing flow of the encoding end can be implemented, and at the decoding end, through the cooperation between these modules, the processing flow of the decoding end can be implemented.
[0038] For example, prediction is divided into intra-frame prediction and inter-frame prediction. Intra-frame prediction takes into account the strong spatial correlation between adjacent blocks in the image, and can use the surrounding reconstructed pixels as reference pixels to predict the current uncoded block. It only needs to perform subsequent coding processing on the residual signal (original signal-prediction signal) instead of encoding the original signal, effectively removing the redundancy in the spatial domain and greatly improving the compression efficiency of the video signal. Inter-frame prediction refers to the use of the correlation in the time domain of the video signal, using the adjacent coded image pixels to predict the pixels of the current image, so as to achieve the purpose of removing the temporal redundancy of the video.
[0039] For example, in the video encoding process, transformation refers to converting an image described in the form of pixels in the spatial domain to an image in the transform domain, and expressing it in the form of transform coefficients. Since most images contain more flat areas and slowly changing areas, an appropriate transformation process can convert the dispersed distribution of image energy in the spatial domain into a relatively concentrated distribution in the transform domain, thereby removing the frequency domain correlation between signals, and in conjunction with the quantization process, effectively compressing the bitstream.
[0040] Exemplarily, entropy coding refers to a method of lossless coding based on the principle of information entropy. It is the last processing module of video compression, which converts a series of element symbols used to represent the video sequence into a binary code stream for transmission or storage. The input symbols may include quantized transform coefficients, motion vector information, prediction mode information, transform quantization related syntax, etc. The output data of the entropy coding module is the final code stream after the original video is compressed. Entropy coding can effectively remove the statistical redundancy of these video element symbols and is one of the important tools to ensure the efficiency of video coding compression.
[0041] See also Figure 1F As shown in the figure, in the video encoding process, the encoding process of each image block (i.e., encoding block) generally includes prediction, transformation, quantization, entropy coding and other modules. For each encoding block, the original input signal is predicted to generate a residual signal, removing the time and space redundancy. Then the residual signal is transformed to make the energy of the residual signal more concentrated. Next, quantization is performed by adjusting the quantization step size. A larger quantization step size is used for high-frequency signals, while a smaller quantization step size is used for low-frequency signals to ensure that the basic information of the image is not lost. Finally, the entropy coding process encodes non-binary coded information into binary information, removes coding redundancy, and finally outputs a binary code stream, that is, the binary code stream after entropy coding is transmitted.
[0042] In the video encoding process, an image needs to be divided into several non-overlapping rectangular strips. Each strip contains an integer number of non-overlapping coding blocks. Each strip is encoded independently in turn. The encoding process is shown in Figure 1F As shown, after going through the prediction, transformation, quantization, entropy coding and other modules in sequence, a binary code stream is generated, and then the code stream of each strip (i.e., the binary code stream after entropy coding) is spliced together in sequence to form a final code stream and sent to the decoding end. Corresponding to the encoding end, in the video decoding process, the image is first divided into multiple rectangular strips consistent with the encoding end, and the decoding end receives the code stream and decodes each strip in sequence. The decoding of each coding block in each strip includes: entropy decoding, inverse quantization, inverse transformation, prediction and other processes to obtain the reconstructed pixels of each rectangular strip, and the reconstructed pixels of each strip are spliced together to obtain the reconstructed image.
[0043] For large-resolution images, the encoder needs to encode multiple strips in parallel to improve the encoder throughput, and the decoder needs to decode multiple strips in parallel to improve the decoder throughput. To achieve this goal, it is necessary to cache the bitstreams of all strips of the entire image, which requires a large amount of storage resources. Moreover, the decoder needs to cache the bitstreams of all strips before it can decode multiple strips in parallel, which means that it takes a long time to complete the caching, which cannot meet the latency requirements of low-latency scenarios.
[0044] In view of the above findings, in the embodiment of the present application, in order to reduce the cache of the decoding end as much as possible, a code stream grouping method is designed, the encoding end divides each stripe into multiple code stream fragments (chunks), each code stream fragment is composed of a code stream of multiple bytes, and then the code stream fragments of each stripe in a stripe row are interleaved and encoded, which is equivalent to caching a number of code stream fragments to achieve parallel decoding, greatly reducing the decoding delay, meeting the low latency requirement, and reducing the cache size of the code stream at the decoding end, saving hardware costs. For example, for each stripe, the stripe can be divided into multiple code stream fragments, the encoding end interleaves all the code stream fragments into the target code stream, and sends the target code stream to the decoding end, the decoding end deinterleaves the code stream fragments in the target code stream, obtains the code stream fragments corresponding to each stripe, and decodes the code stream fragments, thereby avoiding caching the code streams of all stripes of the entire image, saving storage resources, and the decoding end does not need to cache all the code streams to be able to decode multiple stripes in parallel, which can meet the latency requirements of low latency scenarios, and can also be decoded in parallel in low latency scenarios.
[0045] The following is a detailed description of the encoding method and decoding method of the embodiments of the present application in combination with several specific embodiments.
[0046] Example 1: In one possible implementation, see Figure 2A As shown, it is a schematic diagram of the process of the encoding method proposed in the embodiment of the present application. The method can be applied to the encoding end (such as a video encoder). The method may include:
[0047] Step 211: Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, and Y is the number of strips in the vertical direction. X may be a positive integer greater than 1, and Y may be a positive integer greater than or equal to 1.
[0048] For example, X may be SliceNumX, which indicates the number of slices in the horizontal direction of an image, and Y may be SliceNumY, which indicates the number of slices in the vertical direction of an image. Figure 1B As shown, X can be 3, Y can be 3, see Figure 1C As shown in the upper left figure, X can be 2, Y can be 2, see Figure 1CAs shown in the upper right figure, X can be 2 and Y can be 1, see Figure 1C As shown in the figure below, X can be 4 and Y can be 2.
[0049] Step 212: Determine the number of code stream segments in each slice.
[0050] In a possible implementation, the number of code stream segments in each stripe may be determined according to a target number of transmission bits (also referred to as total resources). For example, the target number of transmission bits may be determined according to the stripe width, the stripe height, and the target number of bits per pixel, and the number of code stream segments may be determined according to the target number of transmission bits and a configured segment size value.
[0051] The target number of transmission bits is the sum of the number of bits occupied by all pixels in a stripe. Therefore, the total number of pixels in a stripe can be determined based on the stripe width and stripe height, and the target number of transmission bits can be determined based on the total number of pixels and the target number of bits per pixel (i.e., target bpp, which indicates the average number of bits required to express each pixel after compression).
[0052] The configured segment size value may be a preset value configured based on experience, or a value indicated by a syntax parameter (such as a picture-level syntax parameter, a sequence-level syntax parameter, etc.). There is no restriction on the segment size value, and the segment size value is used to indicate the length of the bitstream segment. Obviously, the target number of transmission bits indicates the length of all bitstream segments, and the segment size value indicates the length of a bitstream segment. Therefore, the number of bitstream segments can be determined based on the target number of transmission bits and the segment size value.
[0053] In another possible implementation, the number of code stream segments can be determined based on the strip height. For example, the size of the strip is slice_width*slice_height, that is, there are slice_width*slice_height pixels in total, each row has slice_width pixels, and there are slice_height strip rows in total. If the length of the code stream segment is determined based on slice_width, then the number of code stream segments can be determined based on the strip height (i.e., slice_height). For example, if the length of the code stream segment is slice_width, then the number of code stream segments can be slice_height, or, if the length of the code stream segment is slice_width / 2, then the number of code stream segments can be 2*slice_height, or, if the length of the code stream segment is 2*slice_width, then the number of code stream segments can be slice_height / 2. Of course, the above method is only an example and is not limited to this.
[0054] Step 213: Encode X stripes in the horizontal direction of the same stripe row to obtain X bitstream buffers corresponding to the X stripes. Since the processing process of each stripe row is the same, the processing process of one stripe row is taken as an example.
[0055] For example, for each slice row, X slices of the slice row may be encoded to obtain X bitstream buffers corresponding to the X slices. Figure 1B As shown, the first stripe row is encoded first, that is, stripe A, stripe B, and stripe C are encoded. For example, stripe A, stripe B, and stripe C are encoded in parallel to obtain a bit stream buffer A1 corresponding to stripe A, a bit stream buffer B1 corresponding to stripe B, and a bit stream buffer C1 corresponding to stripe C.
[0056] After the encoding of the first stripe row is completed, the second stripe row is encoded, that is, stripe D, stripe E, and stripe F are encoded. For example, stripe D, stripe E, and stripe F are encoded in parallel to obtain a bit stream buffer D1 corresponding to stripe D, a bit stream buffer E1 corresponding to stripe E, and a bit stream buffer F1 corresponding to stripe F.
[0057] After the encoding of the second stripe row is completed, the third stripe row is encoded, that is, stripe G, stripe H, and stripe I are encoded, such as encoding stripe G, stripe H, and stripe I in parallel to obtain a bit stream buffer G1 corresponding to stripe G, a bit stream buffer H1 corresponding to stripe H, and a bit stream buffer I1 corresponding to stripe I.
[0058] Step 214: For each bitstream buffer corresponding to the X slices, divide the bitstream buffer into bitstream segments equal to the number of bitstream segments; wherein, among the bitstream segments equal to the number of bitstream segments, there are at least two sizes of bitstream segments.
[0059] Exemplarily, for code stream segments having two sizes, the size may be the code length.
[0060] For example, after the encoding of the first stripe row is completed, the bitstream buffer A1 corresponding to stripe A, the bitstream buffer B1 corresponding to stripe B, and the bitstream buffer C1 corresponding to stripe C can be obtained. On this basis, the bitstream buffer A1 can be divided into the number of stream segments, recorded as stream segments A11, stream segments A12, …, the bitstream buffer B1 can be divided into the number of stream segments, recorded as stream segments B11, stream segments B12, …, and the bitstream buffer C1 can be divided into the number of stream segments, recorded as stream segments C11, stream segments C12, ….
[0061] Among the number of stream segments corresponding to the bitstream buffer A1, there are at least two sizes of stream segments, among the number of stream segments corresponding to the bitstream buffer B1, there are at least two sizes of stream segments, and among the number of stream segments corresponding to the bitstream buffer C1, there are at least two sizes of stream segments.
[0062] Step 215: interleave the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target code stream.
[0063] Exemplarily, interleaving the bitstream segments corresponding to X stripes in the horizontal direction of the same stripe row means: first adding the bitstream segment A11 corresponding to stripe A to the current bitstream, then adding the bitstream segment B11 corresponding to stripe B to the current bitstream, then adding the bitstream segment C11 corresponding to stripe C to the current bitstream, then adding the bitstream segment A12 corresponding to stripe A to the current bitstream, then adding the bitstream segment B12 corresponding to stripe B to the current bitstream, then adding the bitstream segment C12 corresponding to stripe C to the current bitstream, and so on, to finally obtain the target bitstream. Obviously, in the target bitstream, the bitstream segment corresponding to one stripe is connected with the bitstream segment corresponding to another stripe, and the bitstream segment corresponding to one stripe is not connected with another bitstream segment corresponding to the stripe, that is, the bitstream segments corresponding to different stripes are interleaved to form the target bitstream.
[0064] Obviously, in the target bitstream, before the last bitstream segment of a stripe is added to the target bitstream, the bitstream segment of another stripe needs to be added to the target bitstream. For example, before the last bitstream segment of stripe A is added to the target bitstream, the bitstream segment of stripe B needs to be added to the target bitstream. Before the last bitstream segment of stripe B is added to the target bitstream, the bitstream segment of stripe A also needs to be added to the target bitstream.
[0065] In a possible implementation manner, based on the order of the X stripes in the horizontal direction of the same stripe row, one stream segment corresponding to each stripe (in practical applications, there may also be at least two stream segments, which is not limited, and one stream segment is taken as an example in this embodiment) is added to the current stream in sequence, and it is determined whether all the stream segments have been added to the current stream; if so, the stream segment addition is stopped, and the current stream is used as the target stream; if not, one stream segment corresponding to each stripe continues to be added to the current stream, and the operation of determining whether all the stream segments have been added to the current stream is returned.
[0066] For example, for the horizontal strips A, B, and C, the order of these strips is strip A, strip B, and strip C. Therefore, a stream segment A11 corresponding to strip A, a stream segment B11 corresponding to strip B, and a stream segment C11 corresponding to strip C are added to the current stream in sequence, and it is determined whether all stream segments (i.e., all stream segments of strips A, strips B, and strips C) have been added to the current stream. If so, the stream segment addition stops, i.e., the processing of the current strip line is completed, and the target stream of the current strip line is obtained, i.e., the current stream is used as the target stream.
[0067] If not, continue to add a stream segment corresponding to stripe A, a stream segment corresponding to stripe B, and a stream segment corresponding to stripe C to the current stream, and determine whether all stream segments have been added to the current stream, and so on, until all stream segments are added to the current stream, the processing of the current stripe row is completed, and the target stream is obtained.
[0068] In a possible implementation manner, interleaving bitstream segments corresponding to X stripes in the horizontal direction of the same stripe row to obtain a target bitstream may include, but is not limited to: when the bitstream segments corresponding to the X stripes have been obtained, starting to interleave the bitstream segments corresponding to the X stripes to obtain the target bitstream; wherein the bitstream segments corresponding to the X stripes have been obtained includes: for each stripe, S bitstream segments corresponding to the stripe have been obtained, S is greater than or equal to 1, and S is less than the number of bitstream segments.
[0069] For example, after the encoding of the first stripe row is completed, the bitstream buffer A1 corresponding to the stripe A, the bitstream buffer B1 corresponding to the stripe B, and the bitstream buffer C1 corresponding to the stripe C are obtained, and the code stream segment A11 is divided from the bitstream buffer A1, the code stream segment B11 is divided from the bitstream buffer B1, and the code stream segment C11 is divided from the bitstream buffer C1. Then, the code stream segment A12 is divided from the bitstream buffer A1, the code stream segment B12 is divided from the bitstream buffer B1, and the code stream segment C12 is divided from the bitstream buffer C1. Then, the code stream segment A13 is divided from the bitstream buffer A1, the code stream segment B13 is divided from the bitstream buffer B1, and the code stream segment C13 is divided from the bitstream buffer C1, and so on.
[0070] On this basis, when the code stream segments A11, B11, and C11 are obtained, the code stream segments can be interleaved to obtain the target code stream; or, when the code stream segments A11, B11, C11, A12, B12, and C12 are obtained, the code stream segments can be interleaved to obtain the target code stream; or, when the code stream segments A11, B11, C11, A12, B12, and C13 are obtained, the code stream segments can be interleaved to obtain the target code stream, and so on. Obviously, when S code stream segments corresponding to each stripe have been obtained, the code stream segments corresponding to X stripes can be interleaved to obtain the target code stream, where S is greater than or equal to 1 and S is less than the number of code stream segments.
[0071] Step 216: Send the target code stream to the decoding end, where the target code stream includes code stream segments of X stripes in the horizontal direction.
[0072] In one possible implementation, see Figure 2B As shown, it is a flowchart of a decoding method proposed in an embodiment of the present application. The method can be applied to a decoding end (such as a video decoder). The method may include the following steps:
[0073] Step 221: Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, and Y is the number of strips in the vertical direction. X may be a positive integer greater than 1, and Y may be a positive integer greater than or equal to 1.
[0074] Exemplarily, X may be SliceNumX, indicating the number of slices in the horizontal direction of an image, and Y may be SliceNumY, indicating the number of slices in the vertical direction of an image, which is consistent with the parameters of the encoding end.
[0075] Step 222: Determine the number of code stream segments in each slice.
[0076] In a possible implementation, the number of code stream segments in each stripe may be determined according to a target number of transmission bits (also referred to as total resources). For example, the target number of transmission bits may be determined according to the stripe width, the stripe height, and the target number of bits per pixel, and the number of code stream segments may be determined according to the target number of transmission bits and a configured segment size value.
[0077] In another possible implementation, the number of code stream segments may be determined according to the slice height.
[0078] Exemplarily, step 221 - step 222 may refer to step 211 - step 212 , which will not be described in detail here.
[0079] Step 223, deinterleave the code stream segments corresponding to the X stripes in the same stripe row in the horizontal direction in the target code stream, and obtain the number of code stream segments corresponding to each stripe, wherein there are at least two sizes of code stream segments in the number of code stream segments. For example, the decoder can receive the target code stream from the encoder, and the target code stream can include the code stream segments of the X stripes in the horizontal direction of the same stripe row. Therefore, the decoder can deinterleave the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target code stream, and obtain the number of code stream segments corresponding to each stripe. Since the processing process of each stripe row is the same, the processing process of one stripe row is taken as an example.
[0080] Exemplarily, deinterleaving the code stream segments corresponding to X stripes in the same stripe row in the target code stream means: assuming that the X stripes in a stripe row are stripe A, stripe B, and stripe C, firstly parse the target code stream to obtain a code stream segment A11 corresponding to stripe A, then parse the target code stream to obtain a code stream segment B11 corresponding to stripe B, then parse the target code stream to obtain a code stream segment C11 corresponding to stripe C, then parse the target code stream to obtain a code stream segment A12 corresponding to stripe A, then parse the target code stream to obtain a code stream segment B12 corresponding to stripe B, then parse the target code stream to obtain a code stream segment C12 corresponding to stripe C, and so on, and finally obtain the number of code stream segments corresponding to each stripe.
[0081] Obviously, before parsing the last stream segment of a stripe from the target stream, it is necessary to parse the stream segment of another stripe from the target stream. For example, before parsing the last stream segment of stripe A, it is necessary to parse the stream segment of stripe B. Before parsing the last stream segment of stripe B, it is also necessary to parse the stream segment of stripe A.
[0082] In a possible implementation manner, based on the order of the X stripes in the horizontal direction of the same stripe row, one stream segment corresponding to each stripe (in practical applications, there may also be at least two stream segments, which is not limited, and one stream segment is taken as an example) is parsed in sequence to a bit stream buffer corresponding to the stripe, and it is determined whether all the stream segments have been parsed; if so, deinterleaving of the X stripes is completed to obtain all the stream segments corresponding to each stripe; if not, the operation of returning to the order of the X stripes in the horizontal direction of the same stripe row and parsing one stream segment corresponding to each stripe to a bit stream buffer corresponding to the stripe in sequence is performed.
[0083] For example, for the horizontal strips A, B, and C, the order of these strips is strip A, strip B, and strip C. Therefore, a code stream segment A11 corresponding to strip A is parsed to the bit stream buffer A1 corresponding to strip A, a code stream segment B11 corresponding to strip B is parsed to the bit stream buffer B1 corresponding to strip B, and a code stream segment C11 corresponding to strip C is parsed to the bit stream buffer C1 corresponding to strip C, and it is determined whether all code stream segments (i.e., all code stream segments of strip A, strip B, and strip C) have been parsed. If so, the deinterleaving of X strips is completed to obtain all code stream segments corresponding to each strip. If not, continue to parse a bitstream segment corresponding to slice A to the bitstream buffer A1 corresponding to slice A, parse a bitstream segment corresponding to slice B to the bitstream buffer B1 corresponding to slice B, parse a bitstream segment corresponding to slice C to the bitstream buffer C1 corresponding to slice C, and so on, until all bitstream segments have been parsed, the deinterleaving of X slices is completed, and all bitstream segments corresponding to each slice are obtained.
[0084] In summary, the number of stream segments corresponding to stripe A can be obtained, and among the number of stream segments, there are at least two sizes of stream segments; the number of stream segments corresponding to stripe B can be obtained, and among the number of stream segments, there are at least two sizes of stream segments; the number of stream segments corresponding to stripe C can be obtained, and among the number of stream segments, there are at least two sizes of stream segments.
[0085] Step 224: Decode the X stripes based on the bitstream buffers corresponding to the X stripes in the horizontal direction of the same stripe row; the bitstream buffer corresponding to each stripe includes a codestream segment corresponding to the stripe, such as at least one codestream segment.
[0086] For example, the bitstream buffer A1 corresponding to the slice A may include the codestream segments A11, A12, A13, ... corresponding to the slice A, the bitstream buffer B1 corresponding to the slice B may include the codestream segments B11, B12, B13, ... corresponding to the slice B, the bitstream buffer C1 corresponding to the slice C may include the codestream segments C11, C12, C13, ... corresponding to the slice C, on this basis, the codestream segments A11, B11 and C11 may be decoded, such as in parallel, and there is no restriction on this decoding process. Then, the codestream segments A12, B12 and C12 may be decoded, such as in parallel, and then, the codestream segments A13, B13 and C13 may be decoded, such as in parallel, and so on, until the decoding process of all the codestream segments of the X slices in the horizontal direction is completed.
[0087] In a possible implementation manner, when there are code stream segments corresponding to X slices in the bit stream buffer corresponding to the X slices, decoding of the code stream segments corresponding to the X slices is started. The code stream segments corresponding to the X slices in the bit stream buffer corresponding to the X slices may include but is not limited to: for each slice, there are T code stream segments corresponding to the slice in the bit stream buffer corresponding to the slice, where T is greater than or equal to 1, and T is less than the number of code stream segments.
[0088] Obviously, when there are T code stream segments in the bit stream buffer, the code stream segments corresponding to X stripes are decoded, and T is less than the number of code stream segments. Therefore, before deinterleaving the last group of code stream segments, the X stripes can be decoded based on the bit stream buffer corresponding to the X stripes in the horizontal direction. In practical applications, the X stripes can also be decoded based on the bit stream buffer corresponding to the X stripes in the horizontal direction after deinterleaving the last group of code stream segments.
[0089] For example, the decoding end first parses the target bitstream to obtain bitstream segments A11, B11, and C11, and caches the bitstream segment A11 in the bitstream buffer A1, caches the bitstream segment B11 in the bitstream buffer B1, and caches the bitstream segment C11 in the bitstream buffer C1; then, the decoding end parses the target bitstream to obtain bitstream segments A12, B12, and C12, and caches the bitstream segment A12 in the bitstream buffer A1, caches the bitstream segment B12 in the bitstream buffer B1, and caches the bitstream segment C12 in the bitstream buffer C1; then, the decoding end parses the target bitstream to obtain bitstream segments A13, B13, and C13, and caches the bitstream segment A13 in the bitstream buffer A1, caches the bitstream segment B13 in the bitstream buffer B1, and caches the bitstream segment C13 in the bitstream buffer C1, and so on.
[0090] Exemplarily, the sizes of multiple code stream segments interleaved each time by the encoding end are the same, and the sizes of multiple code stream segments deinterleaved each time by the decoding end are the same. For example, the sizes of code stream segments A11, code stream segments B11, and code stream segments C11 are the same, and the sizes of code stream segments A12, code stream segments B12, and code stream segments C12 are also the same. However, the size of code stream segment A11 may be the same as or different from the size of code stream segment A12. For the size relationship of different code stream segments, refer to the subsequent embodiments.
[0091] On this basis, when there are stream segments A11, B11, and C11 in these bitstream buffers, these stream segments can be decoded; or, when there are stream segments A11, B11, C11, A12, B12, and C12 in these bitstream buffers, these stream segments can be decoded; or, when there are stream segments A11, B11, C11, A12, B12, and C13 in these bitstream buffers, these stream segments can be decoded, and so on. Obviously, when there are T stream segments corresponding to each stripe in the bitstream buffer, the X stripes can be decoded based on the bitstream buffers corresponding to the X stripes in the horizontal direction, and T is greater than or equal to 1, and T is less than the number of stream segments.
[0092] In a possible implementation manner, regarding the bitstream segments of at least two sizes, the at least two sizes have the following situations:
[0093] Case 1: when the length of the actual number of coded bits is fixed, for the number of bitstream segments, the lengths of the remaining bitstream segments except the k-th bitstream segment are all of the first size, and the length of the k-th bitstream segment is of the second size.
[0094] For the encoder, the first size is determined based on the configured segment size value, and the second size is determined based on the target number of transmission bits, the segment size value, and the number of codestream segments. For the decoder, the first size is determined based on the configured segment size value, and the second size is determined based on the target number of transmission bits, the segment size value, and the number of codestream segments.
[0095] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0096] Case 2: when the length of the actual number of coded bits is fixed, for the number of bitstream segments, the lengths of the remaining bitstream segments except the k-th bitstream segment are all of the first size, and the length of the k-th bitstream segment is of the second size.
[0097] For the encoding end, the first size is determined based on the stripe width and the number of bits per pixel, and the second size is determined based on the target number of transmission bits, the first size, and the number of code stream segments. For the decoding end, the first size is determined based on the stripe width and the number of bits per pixel, and the second size is determined based on the target number of transmission bits, the first size, and the number of code stream segments.
[0098] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0099] Case 3: When the length of the actual number of coded bits is fixed, for the number of codestream segments, the codestream segment set includes the remaining codestream segments except the k-th codestream segment, the lengths of the odd-numbered codestream segments in the codestream segment set are all the first size, the lengths of the even-numbered codestream segments are all the second size, and the length of the k-th codestream segment is the third size.
[0100] For the encoding end, the first size is determined based on the sum of the segment size value and the preset value, the second size is determined based on the difference between the segment size value and the preset value, and the third size is determined based on the target number of transmission bits, the segment size value, and the number of code stream segments. For the decoding end, the first size is determined based on the sum of the segment size value and the preset value, the second size is determined based on the difference between the segment size value and the preset value, and the third size is determined based on the target number of transmission bits, the segment size value, and the number of code stream segments.
[0101] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0102] Case 4: When the length of the actual number of coded bits is fixed, for the number of codestream segments, the codestream segment set includes the remaining codestream segments except the k-th codestream segment, the lengths of the odd-numbered codestream segments in the codestream segment set are all the first size, the lengths of the even-numbered codestream segments are all the second size, and the length of the k-th codestream segment is the third size.
[0103] For the encoding end, the first size is determined based on the sum of the number of pixels in a stripe row and a preset value, the second size is determined based on the difference between the number of pixels in a stripe row and a preset value, and the third size is determined based on the target number of transmission bits, the number of pixels in a stripe row and the number of code stream segments; wherein the number of pixels in a stripe row can be determined based on the stripe width and the number of bits occupied by each pixel.
[0104] For the decoding end, the first size is determined based on the sum of the number of pixels in the stripe row and a preset value, the second size is determined based on the difference between the number of pixels in the stripe row and the preset value, and the third size is determined based on the target number of transmission bits, the number of pixels in the stripe row and the number of code stream segments; wherein the number of pixels in the stripe row can be determined based on the stripe width and the number of bits occupied by each pixel.
[0105] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0106] Case 5: when the length of the actual number of coded bits is fixed, for the number of bitstream segments, the lengths of the odd-numbered bitstream segments are all the first size, and the lengths of the even-numbered bitstream segments are all the second size.
[0107] For the encoding end, the first size is determined based on the sum of the configured segment size value and the preset value; the second size is determined based on the difference between the segment size value and the preset value. For the decoding end, the first size is determined based on the sum of the configured segment size value and the preset value; the second size is determined based on the difference between the segment size value and the preset value.
[0108] Case 6: when the length of the actual number of coded bits is fixed, for the number of bitstream segments, the lengths of the odd-numbered bitstream segments are all the first size, and the lengths of the even-numbered bitstream segments are all the second size.
[0109] For the encoding end, the first size is determined based on the sum of the number of pixels in a stripe row and a preset value; the second size is determined based on the difference between the number of pixels in a stripe row and the preset value; the number of pixels in a stripe row is determined based on the stripe width and the number of bits occupied by each pixel.
[0110] For the decoding end, the first size is determined based on the sum of the number of pixels in a stripe row and a preset value; the second size is determined based on the difference between the number of pixels in a stripe row and the preset value; the number of pixels in a stripe row is determined based on the stripe width and the number of bits occupied by each pixel.
[0111] Case 7: when the length of the actual number of coded bits is not fixed, for the number of bitstream segments, the lengths of the remaining bitstream segments except the k-th bitstream segment are all of the first size, and the length of the k-th bitstream segment is of the second size.
[0112] For the encoder, the first size is determined based on the configured segment size value, and the second size is determined based on the actual number of coded bits in the bitstream buffer, the segment size value, and the number of bitstream segments. When the encoder sends the target bitstream to the decoder, the target bitstream may also include segment length indication information for the second size, i.e., for indicating the length of the second size.
[0113] For the decoding end, the first size is determined based on the configured segment size value, and the second size is determined based on the segment length indication information, and the segment length indication information is used to indicate the length value of the second size. For example, the target bitstream includes segment length indication information for the second size, and the decoding end can parse the segment length indication information for the second size from the target bitstream, and determine the length value of the second size according to the segment length indication information, that is, obtain the second size.
[0114] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0115] Case 8: when the length of the actual number of coded bits is not fixed, for the number of bitstream segments, the lengths of the remaining bitstream segments except the k-th bitstream segment are all of the first size, and the length of the k-th bitstream segment is of the second size.
[0116] For the encoder, the first size is determined based on the stripe width and the number of bits per pixel; the second size is determined based on the actual number of coded bits in the bitstream buffer, the first size, and the number of codestream segments. When the encoder sends the target codestream to the decoder, the target codestream may also include segment length indication information for the second size, i.e., for indicating the length of the second size.
[0117] For the decoding end, the first size is determined based on the stripe width and the number of bits per pixel, and the second size is determined based on the segment length indication information, and the segment length indication information is used to indicate the length value of the second size. For example, the target bitstream includes the segment length indication information for the second size, and the decoding end can parse the segment length indication information for the second size from the target bitstream, and determine the length value of the second size according to the segment length indication information, that is, obtain the second size.
[0118] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0119] Case 9: when the length of the actual number of coded bits is fixed, for the number of bitstream segments, the lengths of the remaining bitstream segments except the k-th bitstream segment are all of the first size, and the length of the k-th bitstream segment is of the second size.
[0120] For the encoder, the first size is determined based on the configured segment size value, and the second size is determined based on the target number of transmission bits, the segment size value, and the number of bitstream segments. When the encoder sends the target bitstream to the decoder, the target bitstream may also include segment length indication information for the second size, i.e., for indicating the length of the second size.
[0121] For the decoding end, the first size is determined based on the configured segment size value, and the second size is determined based on the segment length indication information, and the segment length indication information is used to indicate the length value of the second size. For example, the target bitstream includes segment length indication information for the second size, and the decoding end can parse the segment length indication information for the second size from the target bitstream, and determine the length value of the second size according to the segment length indication information, that is, obtain the second size.
[0122] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0123] Case 10: when the length of the actual number of coded bits is fixed, for the number of bitstream segments, the lengths of the remaining bitstream segments except the k-th bitstream segment are all of the first size, and the length of the k-th bitstream segment is of the second size.
[0124] For the encoder, the first size is determined based on the stripe width and the number of bits per pixel, and the second size is determined based on the target number of transmission bits, the first size, and the number of code stream segments. When the encoder sends the target code stream to the decoder, the target code stream may also include segment length indication information for the second size, i.e., for indicating the length of the second size.
[0125] For the decoding end, the first size is determined based on the stripe width and the number of bits per pixel, and the second size is determined based on the segment length indication information, and the segment length indication information is used to indicate the length value of the second size. For example, the target bitstream includes the segment length indication information for the second size, and the decoding end can parse the segment length indication information for the second size from the target bitstream, and determine the length value of the second size according to the segment length indication information, that is, obtain the second size.
[0126] In the above embodiment, the kth code stream segment may be the last code stream segment among all code stream segments; or, the kth code stream segment is the first code stream segment among all code stream segments; or, the kth code stream segment is located between the first code stream segment and the last code stream segment, that is, the kth code stream segment is any code stream segment.
[0127] In the above cases 1 to 10, the first sizes in different cases are irrelevant. Here, the first size is used to indicate the length of the code stream segment, but it does not mean that the first sizes in case 1 and case 2 are the same, that is, the first sizes in case 1 and case 2 can be the same or different. Similarly, the second sizes in different cases are irrelevant. Here, the second size is used to indicate the length of the code stream segment, but it does not mean that the second sizes in case 1 and case 2 are the same.
[0128] In a possible implementation manner, for the encoding end and the decoding end, the chunkNum in each slice is fixed, that is, the number of code stream segments in all slices is the same, thereby ensuring parallel decoding.
[0129] It can be seen from the above technical solution that in the embodiment of the present application, for each stripe, the stripe can be divided into multiple code stream segments, the encoding end interweaves all the code stream segments into the target code stream, and sends the target code stream to the decoding end, the decoding end deinterleaves the code stream segments in the target code stream, obtains the code stream segments corresponding to each stripe, and decodes the code stream segments, thereby avoiding caching the code streams of all stripes of the entire image, saving storage resources, and the decoding end does not need to cache all the code streams to be able to decode multiple strips in parallel, which can meet the latency requirements of low-latency scenarios. For example, the code stream segment interleaving process at the encoding end: the encoding end first adds the code stream segment a1 of stripe a to the target code stream, then adds the code stream segment b1 of stripe b to the target code stream, then adds the code stream segment a2 of stripe a to the target code stream, then adds the code stream segment b2 of stripe b to the target code stream, and so on. The decoding end deinterleaving process of the bitstream segments: the decoding end deinterleaves the bitstream segments a1 and b1 from the target bitstream, caches the bitstream segment a1 to the bitstream buffer of slice a, caches the bitstream segment b1 to the bitstream buffer of slice b, deinterleaves the bitstream segments a2 and b2 from the target bitstream, caches the bitstream segment a2 to the bitstream buffer of slice a, caches the bitstream segment b2 to the bitstream buffer of slice b, and so on. After the codestream segments a1 and the codestream segments b1 are cached in their respective corresponding bitstream buffers, the codestream segments a1 and the codestream segments b1 can be decoded in parallel without waiting for subsequent codestream segments (such as the codestream segments a2 and the codestream segments b2) to be cached in their respective corresponding bitstream buffers, thereby reducing the waiting time and meeting the latency requirement of the low-latency scenario. After the codestream segments a1 and the codestream segments b1 are decoded in parallel, the codestream segments a1 and the codestream segments b1 can be deleted from their respective corresponding bitstream buffers to save storage resources, that is, there is no need to cache all the codestream segments of all stripes at the same time.
[0130] Embodiment 2: In the embodiment of the present application, a coding method is proposed, which can be applied to a coding end. The method may include:
[0131] The first step is to split the image into multiple rectangular strips horizontally and vertically.
[0132] The second step is to calculate the total resources (ie, the target number of transmission bits), and determine the number of code stream segments chunkNum according to the total resources.
[0133] Step 3: Encode multiple stripes in each stripe row in sequence to obtain multiple bit stream buffers.
[0134] Step 4: Divide each bitstream buffer into chunkNum stream segments (chunk segments).
[0135] Exemplarily, among chunkNum codestream segments, there are at least two sizes of codestream segments.
[0136] Step 5: For all slices in a stripe row, encode chunkNum times in sequence, and interleave a stream segment of each slice to form a final stream each time. Since each stripe has chunkNum stream segments, all stream segments of each stripe can be interleaved to form a final stream by encoding chunkNum times.
[0137] In a possible implementation manner, for all slices in a slice row, chunkNum times are encoded in sequence, and each time a code stream segment of each slice is interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all slices in a slice row have been obtained, the code stream segments corresponding to X slices are interleaved to obtain the final code stream; wherein the code stream segments corresponding to X slices have been obtained, includes: for each stripe, S code stream segments corresponding to the stripe have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0138] Step 6: Determine whether the encoding of all stripe rows has been completed. If not, return to step 3 to encode the next stripe row. If it has been completed, the encoding process of the current image is completed and the next image can be encoded.
[0139] In an embodiment of the present application, a decoding method is proposed, which can be applied to a decoding end. The method may include:
[0140] The first step is to split the image into multiple rectangular strips horizontally and vertically.
[0141] The second step is to calculate the total resources (ie, the target number of transmission bits), and determine the number of code stream segments chunkNum according to the total resources.
[0142] Step 3: Receive the code stream. For each SliceNumX stripes in each stripe row, parse chunkNum times in sequence. Each time, parse SliceNumX code stream segments (chunk segments) and deinterleave them into the bit stream buffer of each stripe.
[0143] Exemplarily, SliceNumX represents the number of strips in the horizontal direction of an image, that is, the number of strips in the horizontal direction.
[0144] Exemplarily, since each stripe has chunkNum stream segments, when parsing chunkNum times, each time parsing a stream segment of the stripe (SliceNumX stripes mean parsing SliceNumX stream segments at a time), chunkNum stream segments of the stripe can be parsed, that is, all stream segments of the stripe are obtained.
[0145] Exemplarily, among chunkNum code stream segments of the slice, there are code stream segments of at least two sizes.
[0146] Step 4: decode each slice based on the bitstream buffer of each slice.
[0147] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but are not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0148] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0149] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0150] In a possible implementation, for the encoding end, the bitstream buffer of each stripe can be divided into multiple stream segments, and the stream segments of each stripe in a stripe row are interwoven together. For the encoding end and the decoding end, the chunkNum in each stripe is fixed, that is, the number of stream segments in all stripes is the same, thereby ensuring parallel decoding. The size of the stream segment (that is, the size of the stream segment) is not fixed. For example, the size (chunksize) of the previous chunkNum-1 stream segments is the configured segment size value, such as 8192, etc., and the size of the last stream segment is the number of remaining bits. For the encoding end, each stripe can be padded with zeros and bit aligned to ensure that the stream size of each stripe is consistent.
[0151] For example, if the number of SliceNumX stripes in a stripe row is 2, that is, sliceNumX is equal to 2, see Figure 3AAs shown, it is an example of a code stream buffer (ie, the above-mentioned bit stream buffer) when SliceNumX=2. The code stream buffer of slice 1 can be divided into chunkNum code stream segments, and the code stream buffer of slice 2 can be divided into chunkNum code stream segments.
[0152] For another example, if the number of SliceNumX stripes in a stripe row is 3, that is, sliceNumX is equal to 3, see Figure 3B As shown, it is an example of a bitstream buffer (i.e., the above-mentioned bitstream buffer) when SliceNumX=3. The bitstream buffer of slice 1 can be divided into chunkNum bitstream segments, the bitstream buffer of slice 2 can be divided into chunkNum bitstream segments, and the bitstream buffer of slice 3 can be divided into chunkNum bitstream segments.
[0153] Embodiment 3: The length of the actual number of coded bits of each stripe is fixed. For example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits. The length of the first chunkNum-1 code stream segments is fixed and recorded as the first size. The length of the last code stream segment is not fixed and recorded as the second size.
[0154] In Embodiment 3, for the encoding end, the encoding method can be implemented by using the following steps:
[0155] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0156] The second step is to calculate the total resource (ie, the target number of transmission bits, the total resource can be recorded as total_resource), and determine the number of code stream segments chunkNum of the code stream segments (the code stream segments can be recorded as chunk) according to the total resource.
[0157] In a possible implementation, the total resources may be calculated using the following formula:
[0158] total_resourec=((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec=((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3.
[0159] In the above formula, total_resourec is the total resource, that is, the above-mentioned target transmission bits. slice_width is used to represent the strip width, slice_height is used to represent the strip height, target_bpp is used to represent the target bits per pixel, and RC_BUFFER_LENGTH represents the length of the bitstream cached additionally in the bitstream buffer. Obviously, slice_width, slice_height, target_bpp, and RC_BUFFER_LENGTH are all known values, so the total resource can be calculated.
[0160] In a possible implementation manner, according to the total resource total_resource, the following formula can be used to calculate the number of bitstream segments chunkNum: chunknum = total_resoure >> s + n. In the above formula, s is a preset value, which can be a preset value configured according to experience or a value indicated by syntax parameters (such as picture-level syntax parameters, sequence-level syntax parameters, etc.). There is no limitation on this. Optionally, 2 to the power of s can be the length of the bitstream segment. In the above formula, for the value of n, the following method can be adopted: n = total_resoure % (1 << s) == 0? 0 : 1, that is to say, if total_resoure % (1 << s) is 0, the value of n can be 0; if total_resoure % (1 << s) is not 0, the value of n can be 1.
[0161] Step 3: Encode sliceNumX strips in each strip row in sequence to generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and pad zeros and perform byte alignment on the bitstream buffers.
[0162] Exemplarily, since there are sliceNumX strips in each strip row, therefore, sliceNumX strips can be encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX strips. For each bitstream buffer, padding zeros and byte alignment can be performed on this bitstream buffer so that the length of this bitstream buffer is the target transmission bits (i.e., the total resource), that is, padding zeros and byte alignment are performed on this bitstream buffer according to the target transmission bits.
[0163] Step 4: Divide each bitstream buffer into chunkNum bitstream segments, and the lengths of the bitstream segments are not fixed.
[0164] Exemplarily, the calculation method of the length (chunksize) of chunkNum bitstream segments can be as follows: the length of the first chunkNum - 1 bitstream segments is size1, and the length of the last bitstream segment is size2. For example, size1 = 1 << s, size2 = total_resouce – ((chunknum - 1) << s)). In the above formula, s is a preset value, that is, the configured segment size value, which can be a preset value configured according to experience or a value indicated by syntax parameters (such as picture-level syntax parameters, sequence-level syntax parameters, etc.). There is no limitation on this. The segment size value is used to represent the length of the bitstream segment, and total_resouce is used to represent the target transmission bit count.
[0165] Step 5: For sliceNumX stripes in a stripe row, encode chunkNum times in sequence. Each time, interleave the bitstream segments of each stripe (i.e., the bitstream segments of sliceNumX stripes) to form the final bitstream.
[0166] In a possible implementation manner, for sliceNumX stripes in a stripe row, encoding chunkNum times in sequence and interleaving the bitstream segments of each stripe each time to form the final bitstream may include, but is not limited to: when all the bitstream segments corresponding to the stripes in a stripe row have been obtained, start interleaving the bitstream segments corresponding to X stripes to obtain the final bitstream; where obtaining all the bitstream segments corresponding to the stripes in a stripe row includes: for each stripe, S bitstream segments corresponding to the stripe have been obtained, S is greater than or equal to 1 and less than the number of bitstream segments.
[0167] Step 6: Check whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0168] Exemplarily, for the interleaving schematic diagram of the bitstream segments when sliceNumX is equal to 2, reference can be made to Figure 4A as shown. First, encode segment 1 of the first stripe, then encode segment 1 of the second stripe, then encode segment 2 of the first stripe, then encode segment 2 of the second stripe, and so on, until encoding segment N of the first stripe, and then encode segment N of the second stripe. Figure 4A Here, it is taken that the chunkNum bitstream segments are N segments as an example. See Figure 4B as shown, which is the schematic diagram of the length of the bitstream segments. The lengths of segments 1 - (N - 1) are all size1, and the length of segment N is size2.
[0169] For the interleaving schematic diagram of the bitstream segments when sliceNumX is equal to 3, reference can be made to Figure 4CAs shown, the fragment 1 of the first stripe may be encoded first, then the fragment 1 of the second stripe may be encoded, then the fragment 1 of the third stripe may be encoded, then the fragment 2 of the first stripe may be encoded, then the fragment 2 of the second stripe may be encoded, then the fragment 2 of the third stripe may be encoded, and so on, until the fragment N of the first stripe is encoded, then the fragment N of the second stripe may be encoded, and then the fragment N of the third stripe may be encoded. Figure 4A In the example, chunkNum code stream segments are N segments. Figure 4D As shown, it is a schematic diagram of the length of the code stream segment. The length of each segment in segment 1-segment (N-1) is size 1, and the length of segment N is size 2.
[0170] In Embodiment 3, for the decoding end, the decoding method can be implemented by using the following steps:
[0171] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0172] The second step is to calculate the total resources (i.e. the target number of transmission bits, denoted as total_resource), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. The total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, based on the total resources total_resource, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = total_resoure>>s+n. s is a preset value, n = total_resoure% (1< <s)==0?0:1。
[0173] Step 3: Receive the code stream. For each sliceNumX stripe of each stripe row, parse chunknum times in sequence. Each time, sliceenumX code stream segments are deinterleaved into the code stream buffer (i.e., bit stream buffer) of each stripe. For example, for each stripe, chunknum code stream segments can be obtained by parsing chunknum times. The length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the first chunkNum-1 code stream segments is size1, and the length of the last code stream segment is size2. For example, size1=1< <s,size2=total_resouce–((chunknum-1)<<s))。
[0174] Step 4: decode each slice based on the bitstream buffer of each slice.
[0175] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but are not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0176] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0177] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0178] Embodiment 4: The length of the actual number of coded bits of each stripe is fixed. For example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits. The length of the following chunkNum-1 code stream segments is fixed and recorded as the first size. The length of the first code stream segment is not fixed and recorded as the second size.
[0179] In Embodiment 4, for the encoding end, the encoding method can be implemented by using the following steps:
[0180] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0181] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, the total resource can be calculated using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, calculate the number of chunks chunkNum using the following formula: chunknum = total_resoure >> s + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0182] Step 3: Encode sliceNumX stripes within each stripe row in sequence to generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and pad zeros and perform byte alignment on the bitstream buffers.
[0183] Exemplarily, since there are sliceNumX stripes in each stripe row, thus, sliceNumX stripes can be encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, zeros can be padded and byte alignment can be performed on this bitstream buffer to make the length of this bitstream buffer be the target transmission bit count (i.e., the total resource), that is, pad zeros and perform byte alignment on this bitstream buffer according to the target transmission bit count.
[0184] Step 4: Divide each bitstream buffer into chunkNum bitstream segments, and the lengths of the bitstream segments are not fixed.
[0185] Exemplarily, the calculation method for the lengths (chunksize) of the chunkNum bitstream segments can be: the length of the first bitstream segment is size1, and the lengths of the subsequent chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, size1 = total_resouce – ((chunknum - 1) << s)). In the above formula, s is a preset value, that is, the configured segment size value.
[0186] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0187] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0188] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0189] For example, the interleaving diagram of the code stream segments when sliceNumX is equal to 2 can be seen in Figure 5A As shown, the fragment 1 of the first stripe may be encoded first, then the fragment 1 of the second stripe may be encoded, then the fragment 2 of the first stripe may be encoded, then the fragment 2 of the second stripe may be encoded, and so on, until the fragment N of the first stripe is encoded, and then the fragment N of the second stripe is encoded. Figure 5A In the example, chunkNum code stream segments are N segments. Figure 5B As shown, it is a schematic diagram of the length of the code stream segment, the length of segment 1 is size 1, and the length of each segment in segment 2-segment N is size 2.
[0190] Exemplarily, for the interleaving process of the code stream segments when sliceNumX is equal to 3, first encode the segment 1 of the first slice, then encode the segment 1 of the second slice, then encode the segment 1 of the third slice, then encode the segment 2 of the first slice, encode the segment 2 of the second slice, encode the segment 2 of the third slice, and so on, until encoding the segment N of the first slice, encoding the segment N of the second slice, and encoding the segment N of the third slice. See Figure 5C As shown, it is a schematic diagram of the length of the code stream segments, the length of segment 1 is size 1, and the lengths of segments 2 to N are all size 2.
[0191] In Embodiment 4, for the decoding end, the decoding method can be implemented by using the following steps:
[0192] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0193] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. The total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, based on the total resource total_resource, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = total_resoure>>s+n. s is a preset value, n = total_resoure% (1< <s)==0?0:1。
[0194] Step 3: Receive the code stream. For each sliceNumX stripe of each stripe row, parse chunknum times in sequence. Each time, sliceenumX code stream segments are deinterleaved into the code stream buffer (i.e., bit stream buffer) of each stripe. For example, for each stripe, chunknum code stream segments can be obtained by parsing chunknum times. The length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the first code stream segment is size1, and the length of the following chunkNum-1 code stream segments is size2. For example, size2=1< <s,size1=total_resouce–((chunknum-1)<<s))。
[0195] Step 4: decode each slice based on the bitstream buffer of each slice.
[0196] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0197] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0198] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0199] Embodiment 5: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, the length of the remaining code stream segments (i.e., chunkNum-1 code stream segments) except the k-th code stream segment is fixed, recorded as the first size, and the length of the k-th code stream segment is not fixed, recorded as the second size. The k-th code stream segment may be the last code stream segment among all code stream segments; or, the k-th code stream segment is the first code stream segment among all code stream segments; or, the k-th code stream segment is located between the first code stream segment and the last code stream segment, that is, the k-th code stream segment is any code stream segment.
[0200] In Embodiment 5, for the encoding end, the encoding method can be implemented by using the following steps:
[0201] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0202] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. For example, the total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = total_resoure>>s+n. s is a preset value. Regarding the value of n, n=total_resoure%(1< <s)==0?0:1。
[0203] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0204] Exemplarily, since there are sliceNumX stripes in each stripe row, sliceNumX stripes can be encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, zero-padding and byte alignment can be performed on the bitstream buffer so that the length of the bitstream buffer is the target transmission bits (i.e., the total resources), that is, zero-padding and byte alignment are performed on the bitstream buffer according to the target transmission bits.
[0205] Step 4: Divide each bitstream buffer into chunkNum code stream segments, and the lengths of the code stream segments are not fixed.
[0206] Exemplarily, the calculation method of the lengths (chunksize) of the chunkNum code stream segments can be: the length of the kth code stream segment is size1, and the lengths of the remaining chunkNum - 1 code stream segments are size2. For example, size2 = 1 << s, size1 = total_resouce – ((chunknum - 1) << s)). In the above formula, s is a preset value, and the value range of k is 1 to chunknum.
[0207] Step 5: For the sliceNumX stripes in a stripe row, encode chunkNum times in sequence. Each time, the code stream segments of each stripe (i.e., the code stream segments of the sliceNumX stripes) are interleaved to form the final code stream.
[0208] In a possible implementation manner, for the sliceNumX stripes in a stripe row, encoding chunkNum times in sequence, and each time interleaving the code stream segments of each stripe to form the final code stream may include, but is not limited to: when all the code stream segments corresponding to the stripes in a stripe row have been obtained, start interleaving the code stream segments corresponding to the X stripes to obtain the final code stream; where obtaining all the code stream segments corresponding to the stripes in a stripe row includes: for each stripe, obtaining S code stream segments corresponding to the stripe, S is greater than or equal to 1 and less than the number of code stream segments.
[0209] Step 6: Determine whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0210] In Embodiment 5, for the decoding end, the decoding method can be implemented by the following steps:
[0211] Step 1: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular stripes.
[0212] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. The total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, based on the total resource total_resource, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = total_resoure>>s+n. s is a preset value, n = total_resoure% (1< <s)==0?0:1。
[0213] Step 3: Receive the code stream. For each sliceNumX stripe of each stripe row, parse chunknum times in sequence. Each time, sliceenumX code stream segments are deinterleaved into the code stream buffer (i.e., bit stream buffer) of each stripe. For example, for each stripe, chunknum code stream segments can be obtained by parsing chunknum times. The length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunkNum-1 code stream segments is size2. For example, size2=1< <s,size1=total_resouce–((chunknum-1)<<s))。
[0214] Step 4: decode each slice based on the bitstream buffer of each slice.
[0215] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0216] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0217] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0218] Embodiment 6: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, the length of the remaining code stream segments (i.e., chunkNum-1 code stream segments) except the k-th code stream segment is fixed, recorded as the first size, and the length of the k-th code stream segment is not fixed, recorded as the second size. The k-th code stream segment may be the last code stream segment among all code stream segments; or, the k-th code stream segment is the first code stream segment among all code stream segments; or, the k-th code stream segment is located between the first code stream segment and the last code stream segment, that is, the k-th code stream segment is any code stream segment.
[0219] In Embodiment 6, for the encoding end, the encoding method may be implemented by using the following steps:
[0220] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0221] Step 2: Calculate the total resource total_resource (i.e., the target number of bits to be transmitted), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum is calculated using the following formula: chunknum = slice_height.
[0222] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0223] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0224] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0225] Exemplarily, the length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunkNum-1 code stream segments is size2. For example, size2 = ((slice_width*bpp+7)<<3)>>3, size1 = total_resouce–((chunknum-1)*size2), and the value range of k is 1 to chunknum. In the above formula, slice_width is used to indicate the stripe width, bpp is used to indicate the number of bits per pixel, total_resouce indicates the target number of transmission bits, and chunknum indicates the number of code stream segments. In summary, size2 is determined based on the stripe width and the number of bits per pixel, and size1 is determined based on the target number of transmission bits, size2, and the number of code stream segments.
[0226] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0227] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0228] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0229] In Embodiment 6, for the decoding end, the decoding method can be implemented by using the following steps:
[0230] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0231] Step 2: Calculate the total resource total_resource (i.e., the target number of bits to be transmitted), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum is calculated using the following formula: chunknum = slice_height.
[0232] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0233] For example, for each slice, chunknum can be parsed for chunknum times to obtain chunknum code stream segments, and the length (chunksize) of chunknum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunknum-1 code stream segments is size2. For example, size2 = ((slice_width*bpp+7)<<3)>>3, size1 = total_resouce-((chunknum-1)*size2), and the value range of k is 1 to chunknum.
[0234] Step 4: decode each slice based on the bitstream buffer of each slice.
[0235] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0236] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0237] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0238] Embodiment 7: The length of the actual number of coded bits of each stripe is fixed. For example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits. The lengths of the first chunkNum-1 code stream segments are switched between two fixed values of odd and even. The lengths of the odd-numbered code stream segments are all of the first size, the lengths of the even-numbered code stream segments are all of the second size, and the length of the last code stream segment is not fixed and is recorded as the third size.
[0239] In Embodiment 7, for the encoding end, the encoding method may be implemented by using the following steps:
[0240] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0241] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. For example, the total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure>>s)<<1+n. s is a preset value. Regarding the value of n, n=n=total_resoure%(1< <s)==0?0:1。
[0242] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0243] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0244] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0245] Exemplarily, the length (chunksize) of chunkNum code stream segments may be calculated as follows: the lengths of the first chunkNum-1 code stream segments are switched with two fixed values of odd and even, that is, they are switched between size1 and size2 in sequence, that is, the length of the odd-numbered code stream segments is size1, and the length of the even-numbered code stream segments is size2, or the length of the odd-numbered code stream segments is size2, and the length of the even-numbered code stream segments is size1, and in addition, the length of the last code stream segment is size3.
[0246] For example, size1 = (1 << s) + x, size2 = (1 << s) - x, size3 = total_resouce – ((chunknum - 1) << s). In the above formulas, s is a preset value, i.e., the configured segment size value, which can be indicated by image-level syntax parameters. x is a preset value, which can be configured according to experience, such as 1, 2, 3 or -1, -2, -3, etc., and can be indicated by image-level syntax parameters. It can be seen from the above formulas that size1 is determined based on the sum of the segment size value s and the preset value x, size2 is determined based on the difference between the segment size value s and the preset value x, and size3 is determined based on the target transmission bit number total_resouce, the segment size value s, and the number of bitstream segments chunknum.
[0247] Step 5: For sliceNumX slices within a stripe row, encode them chunkNum times in sequence. Each time, interleave the bitstream segments of each slice (i.e., the bitstream segments of sliceNumX slices) to form the final bitstream.
[0248] In a possible implementation, for sliceNumX slices within a stripe row, encoding them chunkNum times in sequence and interleaving the bitstream segments of each slice each time to form the final bitstream may include, but is not limited to: when the bitstream segments corresponding to all slices within a stripe row have been obtained, start interleaving the bitstream segments corresponding to X slices to obtain the final bitstream; where obtaining the bitstream segments corresponding to all slices within a stripe row includes: for each slice, having obtained S bitstream segments corresponding to the slice, where S is greater than or equal to 1 and less than the number of bitstream segments.
[0249] Step 6: Determine whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0250] Exemplarily, for the interleaving process of the bitstream segments when sliceNumX is equal to 2, the segment 1 of the first stripe can be encoded first, then the segment 1 of the second stripe, then the segment 2 of the first stripe, then the segment 2 of the second stripe, and so on, until the segment N of the first stripe is encoded, and then the segment N of the second stripe is encoded. Refer to Fig. 6A As shown, it is a schematic diagram of the lengths of the bitstream segments. The odd-numbered bitstream segments such as segment 1, segment 3, segment 5, etc. of each stripe have a length of size1, and the even-numbered bitstream segments such as segment 2, segment 4, segment 6, etc. of each stripe have a length of size2. In addition, the length of the last bitstream segment (i.e., segment N) is size3.
[0251] In Embodiment 7, for the decoding end, the decoding method can be implemented by the following steps:
[0252] Step 1: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular strips.
[0253] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit number), and determine the number of chunks chunkNum of the bitstream segments according to the total resource. For example, calculate the total resource using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. According to the total resource total_resource, calculate the number of chunks chunkNum using the following formula: chunknum = (total_resoure >> s) << 1 + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0254] Step 3: Receive the bitstream. For the sliceNumX strips in each strip row, parse chunknum times in sequence, and each time parse slicenumX bitstream segments and deinterleave them into the bitstream buffer (i.e., the bitstream buffer) of each strip.
[0255] Exemplarily, for each strip, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the length (chunksize) of the chunkNum bitstream segments can be: the lengths of the previous chunkNum - 1 bitstream segments switch between two fixed values in an odd - even manner, that is, switch between size1 and size2 in sequence, that is, the length of the odd - numbered bitstream segments is size1, and the length of the even - numbered bitstream segments is size2, or the length of the odd - numbered bitstream segments is size2, and the length of the even - numbered bitstream segments is size1. In addition, the length of the last bitstream segment is size3. For example, size1 = (1 << s) + x, size2 = (1 << s) - x, size3 = total_resouce – ((chunknum - 1) << s), where x is a preset value.
[0256] Step 4: Decode each strip based on the bitstream buffer of each strip.
[0257] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0258] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0259] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0260] Embodiment 8: The length of the actual number of coded bits of each stripe is fixed. For example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits. The lengths of the following chunkNum-1 code stream segments are switched between two fixed values of odd and even. The lengths of the odd-numbered code stream segments are all the first size, and the lengths of the even-numbered code stream segments are all the second size. The length of the first code stream segment is not fixed and is recorded as the third size.
[0261] In Embodiment 8, for the encoding end, the encoding method may be implemented by using the following steps:
[0262] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0263] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. For example, the total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure>>s)<<1+n. s is a preset value. Regarding the value of n, n=total_resoure%(1< <s)==0?0:1。
[0264] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0265] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0266] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0267] Exemplarily, the calculation method of the length (chunksize) of chunkNum bitstream segments can be as follows: the length of the first bitstream segment is size1, and the lengths of the subsequent chunkNum - 1 bitstream segments switch alternately between two fixed values, that is, they switch between size2 and size3 in turn. That is, the length of the odd-numbered bitstream segments is size2, and the length of the even-numbered bitstream segments is size3, or the length of the odd-numbered bitstream segments is size3, and the length of the even-numbered bitstream segments is size2. For example, size2 = (1 << s) + x, size3 = (1 << s) - x, size1 = total_resouce - ((chunknum - 1) << s), where x is a preset value.
[0268] Step 5: For sliceNumX stripes in a stripe row, encode chunkNum times in sequence. Each time, the bitstream segments of each stripe (i.e., the bitstream segments of sliceNumX stripes) are interleaved to form the final bitstream.
[0269] In a possible implementation manner, for sliceNumX stripes in a stripe row, encoding chunkNum times in sequence and interleaving the bitstream segments of each stripe to form the final bitstream may include, but is not limited to: when the bitstream segments corresponding to all stripes in a stripe row have been obtained, start interleaving the bitstream segments corresponding to X stripes to obtain the final bitstream; where obtaining the bitstream segments corresponding to all stripes in a stripe row includes: for each stripe, the S bitstream segments corresponding to the stripe have been obtained, S is greater than or equal to 1 and less than the number of bitstream segments.
[0270] Step 6: Determine whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0271] Exemplarily, for the interleaving process of the bitstream segments when sliceNumX is equal to 2, the segment 1 of the first stripe can be encoded first, then the segment 1 of the second stripe, then the segment 2 of the first stripe, then the segment 2 of the second stripe, and so on, until the segment N of the first stripe is encoded, and then the segment N of the second stripe is encoded. See Figure 6B As shown, it is a schematic diagram of the length of the bitstream segments. The length of the first bitstream segment (i.e., segment 1) is size1. Among the remaining bitstream segments, the even-numbered bitstream segments such as segment 2, segment 4, segment 6, etc. of each stripe have a length of size2, and the odd-numbered bitstream segments such as segment 3, segment 5, segment 7, etc. of each stripe have a length of size3.
[0272] In Embodiment 8, for the decoding end, the decoding method can be implemented by the following steps:
[0273] Step 1: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular strips.
[0274] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, calculate the total resource using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, calculate the number of chunks chunkNum using the following formula: chunknum = (total_resoure >> s) << 1 + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0275] Step 3: Receive the bitstream. For the sliceNumX strips in each strip row, parse chunknum times in sequence. Each time, parse slicenumX bitstream segments and deinterleave them into the bitstream buffer (i.e., the bitstream buffer) of each strip.
[0276] Exemplarily, for each strip, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method for the length (chunksize) of the chunkNum bitstream segments can be as follows: The length of the first bitstream segment is size1, and the lengths of the subsequent chunkNum - 1 bitstream segments switch alternately between two fixed values, that is, switch between size2 and size3 in sequence. For example, the length of the odd-numbered bitstream segments is size2, and the length of the even-numbered bitstream segments is size3, or the length of the odd-numbered bitstream segments is size3, and the length of the even-numbered bitstream segments is size2. For example, size2 = (1 << s) + x, size3 = (1 << s) - x, size1 = total_resouce – ((chunknum - 1) << s), where x is a preset value.
[0277] Step 4: Decode each strip based on the bitstream buffer of each strip.
[0278] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0279] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0280] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0281] Embodiment 9: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, the lengths of the remaining code stream segments (i.e., chunkNum-1 code stream segments) except the k-th code stream segment are switched between two fixed values of odd and even, the lengths of the odd-numbered code stream segments are all the first size, the lengths of the even-numbered code stream segments are all the second size, and the length of the k-th code stream segment is not fixed and is recorded as the third size. The k-th code stream segment may be the last code stream segment among all code stream segments; or, the k-th code stream segment is the first code stream segment among all code stream segments; or, the k-th code stream segment is located between the first code stream segment and the last code stream segment, that is, the k-th code stream segment is any code stream segment.
[0282] In Embodiment 9, for the encoding end, the encoding method may be implemented by using the following steps:
[0283] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0284] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. For example, the total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure>>s)<<1+n. s is a preset value. Regarding the value of n, n=total_resoure%(1< <s)==0?0:1。
[0285] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0286] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0287] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0288] Exemplarily, the calculation method of the lengths (chunksize) of chunkNum bitstream segments can be as follows: the length of the k-th bitstream segment is size1, and the lengths of the remaining bitstream segments except the k-th bitstream segment (i.e., chunkNum - 1 bitstream segments) switch between two fixed values in an odd-even manner, that is, they switch between size2 and size3 in sequence. That is, the lengths of the odd-numbered bitstream segments are size2, and the lengths of the even-numbered bitstream segments are size3, or the lengths of the odd-numbered bitstream segments are size3, and the lengths of the even-numbered bitstream segments are size2. For example, size2 = (1 << s) + x, size3 = (1 << s) - x, size1 = total_resouce – ((chunknum - 1) << s), where x is a preset value. The odd-numbered bitstream segments are the odd-numbered bitstream segments among the remaining chunkNum - 1 bitstream segments, and the even-numbered bitstream segments are the even-numbered bitstream segments among the remaining chunkNum - 1 bitstream segments.
[0289] Step 5: For sliceNumX stripes within a stripe row, encode chunkNum times in sequence. Each time, the bitstream segments of each stripe (i.e., the bitstream segments of sliceNumX stripes) are interleaved to form the final bitstream.
[0290] In a possible implementation manner, for sliceNumX stripes within a stripe row, encoding chunkNum times in sequence and interleaving the bitstream segments of each stripe each time to form the final bitstream may include, but is not limited to: when the bitstream segments corresponding to all stripes within a stripe row have been obtained, start interleaving the bitstream segments corresponding to X stripes to obtain the final bitstream; where obtaining the bitstream segments corresponding to all stripes within a stripe row includes: for each stripe, the S bitstream segments corresponding to the stripe have been obtained, where S is greater than or equal to 1 and less than the number of bitstream segments.
[0291] Step 6: Determine whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0292] In Embodiment 9, for the decoding end, the decoding method can be implemented by the following steps:
[0293] Step 1: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular stripes.
[0294] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, the number of chunks chunkNum is calculated using the following formula: chunknum = (total_resoure >> s) << 1 + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0295] Step 3: Receive the bitstream. For the sliceNumX slices of each strip row, parse chunknum times in sequence. Each time, parse slicenumX bitstream segments and deinterleave them into the bitstream buffer (i.e., the bitstream buffer) of each strip.
[0296] Exemplarily, for each strip, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method for the length (chunksize) of the chunkNum bitstream segments can be as follows: The length of the k-th bitstream segment is size1, and the lengths of the remaining chunkNum - 1 bitstream segments switch alternately between two fixed values, that is, switch between size2 and size3 in sequence. For example, the lengths of the odd-numbered bitstream segments are size2, and the lengths of the even-numbered bitstream segments are size3, or the lengths of the odd-numbered bitstream segments are size3, and the lengths of the even-numbered bitstream segments are size2. For example, size2 = (1 << s) + x, size3 = (1 << s) - x, size1 = total_resouce – ((chunknum - 1) << s), where x is a preset value.
[0297] Step 4: Decode each strip based on the bitstream buffer of each strip.
[0298] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0299] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0300] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0301] Embodiment 10: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, and the lengths of the remaining code stream segments (i.e., chunkNum-1 code stream segments) except the k-th code stream segment are switched between two fixed values of odd and even, the lengths of the odd-numbered code stream segments are all the first size, the lengths of the even-numbered code stream segments are all the second size, and the length of the k-th code stream segment is not fixed and is recorded as the third size. The k-th code stream segment may be the last code stream segment among all code stream segments; or, the k-th code stream segment is the first code stream segment among all code stream segments; or, the k-th code stream segment is located between the first code stream segment and the last code stream segment, that is, the k-th code stream segment is any code stream segment.
[0302] In Embodiment 10, for the encoding end, the encoding method may be implemented by using the following steps:
[0303] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0304] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height+1.
[0305] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0306] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0307] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0308] Exemplarily, the length (chunksize) of chunkNum stream segments may be calculated as follows: the length of the kth stream segment is size1, and the lengths of the remaining stream segments (i.e., chunkNum-1 stream segments) other than the kth stream segment are switched between two fixed values of odd and even, i.e., they are switched between size2 and size3 in sequence, i.e., the length of the odd-numbered stream segments is size2, and the length of the even-numbered stream segments is size3, or, the length of the odd-numbered stream segments is size3, and the length of the even-numbered stream segments is size2. For example, size2=(((slice_width*bpp)<<3)>>3)+x, size3=(((slice_width*bpp)<<3)>>3)-x, size1=total_resouce-((chunknum-1)*(size2-x)), x is a preset value, and k is in the range of 1 to chunknum. The odd-numbered code stream segments are the odd-numbered code stream segments among the remaining chunkNum-1 code stream segments, and the even-numbered code stream segments are the even-numbered code stream segments among the remaining chunkNum-1 code stream segments.
[0309] In the above formula, slice_width can be used to indicate the strip width, bpp can be used to indicate the number of bits occupied per pixel, total_resouce can indicate the target number of transmission bits, and chunknum can indicate the number of code stream segments.
[0310] In the above formula, (((slice_width*bpp)<<3)>>3) can be recorded as the number of pixels in the stripe row.
[0311] To summarize, size2 is determined based on the sum of the number of pixels in a stripe row and a preset value x, size3 is determined based on the difference between the number of pixels in a stripe row and the preset value x, size1 is determined based on the target number of transmission bits, size2 and the number of code stream fragments chunknum, and since size2 is determined based on the number of pixels in a stripe row, size1 is determined based on the target number of transmission bits, the number of pixels in a stripe row and the number of code stream fragments chunknum, and the number of pixels in a stripe row is determined based on the stripe width and the number of bits occupied by each pixel.
[0312] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0313] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0314] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0315] In Embodiment 10, for the decoding end, the decoding method can be implemented by using the following steps:
[0316] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0317] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height+1.
[0318] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0319] Exemplarily, for each slice, chunknum is parsed for times to obtain chunknum stream segments, and the lengths (chunksize) of chunknum stream segments may be calculated as follows: the length of the kth stream segment is size1, and the lengths of the remaining stream segments are switched between size2 and size3 in two fixed values of odd and even, that is, the lengths of odd-numbered stream segments are size2, and the lengths of even-numbered stream segments are size3, or the lengths of odd-numbered stream segments are size3, and the lengths of even-numbered stream segments are size2. For example, size2 = (((slice_width*bpp)<<3)>>3)+x, size3 = (((slice_width*bpp)<<3)>>3)-x, and size1 = total_resouce-((chunknum-1)*(size2-x)).
[0320] Step 4: decode each slice based on the bitstream buffer of each slice.
[0321] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0322] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0323] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0324] Embodiment 11: The length of the actual number of coded bits of each stripe is fixed. The length of the actual number of coded bits of each stripe is not the target number of transmitted bits, but is determined based on the length of all code stream segments, that is, the sum of the lengths of all code stream segments. By filling the bit stream buffer with zeros and byte alignment, the lengths of all code stream segments are switched between two fixed values of odd and even. The lengths of odd-numbered code stream segments are all of the first size, and the lengths of even-numbered code stream segments are all of the second size. The length of the bit stream buffer is the sum of the lengths of the code stream segments of the first size plus the sum of the lengths of the code stream segments of the second size.
[0325] In Embodiment 11, for the encoding end, the following steps can be adopted to implement the encoding method:
[0326] First step: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular stripes.
[0327] Second step: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of bitstream segments chunkNum according to the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. According to the total resource total_resource, the number of bitstream segments chunkNum can be calculated using the following formula: chunknum = (total_resoure >> s) << 1 + n. In the above formula, s is a preset value, that is, the configured segment size value, which can be indicated by the picture-level syntax parameter. Regarding the value of n, n = left == 0? 0 : (left <= (1 << s + x)? 1 : 2), and left = (total_resoure – (chunknum - 1) << s).
[0328] Third step: Encode the sliceNumX stripes within each stripe row in sequence to generate slicenumX bitstream buffers slicebuffer[sliceNumX], and pad zeros and perform byte alignment on the bitstream buffers.
[0329] Exemplarily, since there are sliceNumX stripes in each stripe row, therefore, the sliceNumX stripes can be encoded to obtain slicenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, zeros can be padded and byte alignment can be performed on this bitstream buffer so that the length of the actual encoded bit count is the sum of the lengths of all bitstream segments, and the sum of the lengths of all bitstream segments can be greater than the target transmission bit count (i.e., the total resource), that is to say, zeros can be padded and byte alignment can be performed on this bitstream buffer according to the lengths of all bitstream segments.
[0330] Fourth step: Divide each bitstream buffer into chunkNum bitstream segments, and the lengths of the bitstream segments are not fixed.
[0331] Exemplarily, the calculation method of the length (chunksize) of chunkNum bitstream segments can be as follows: the lengths of all bitstream segments (i.e., chunkNum bitstream segments) switch between two fixed values in an odd-even pattern, that is, they switch between size1 and size2 in turn. That is, the length of odd-numbered bitstream segments is size1, and the length of even-numbered bitstream segments is size2, or the length of odd-numbered bitstream segments is size2, and the length of even-numbered bitstream segments is size1. For example, size1 = (1 << s) + x, size2 = (1 << s) - x, where x is a preset value. Obviously, since the bitstream buffer is filled with zeros and byte-aligned according to the lengths of all bitstream segments, it is possible to make the lengths of all bitstream segments switch between size1 and size2 in turn.
[0332] For example, assume that there are sliceNumX stripes in a coded stripe row. After generating slicenumX bitstream buffers, the length of the bitstream buffer is 340, and the target transmission bit number is 360. Then, in Embodiments 3 - 10, the bitstream buffer is filled with zeros and byte-aligned so that the length of the bitstream buffer changes from 340 to 360, that is, the length that needs to be filled with zeros is 20. In Embodiment 11, assume that size1 is 99, size2 is 101, and the number of bitstream segments chunkNum is 4. Then, the length of the bitstream buffer needs to be 400, that is, the sum of the lengths of two size1 and two size2. Therefore, when filling the bitstream buffer with zeros and byte-aligning it, it is necessary to make the length of the bitstream buffer change from 340 to 400, that is, the length that needs to be filled with zeros is 60. In this way, it exactly makes the lengths of all bitstream segments switch between size1 and size2.
[0333] Step 5: For sliceNumX stripes in a stripe row, encode chunkNum times in sequence. Each time, the bitstream segments of each stripe (i.e., the bitstream segments of sliceNumX stripes) are interleaved to form the final bitstream.
[0334] In a possible implementation manner, for sliceNumX stripes in a stripe row, encoding chunkNum times in sequence and interleaving the bitstream segments of each stripe each time to form the final bitstream may include, but is not limited to: when all the bitstream segments corresponding to the stripes in a stripe row have been obtained, start interleaving the bitstream segments corresponding to X stripes to obtain the final bitstream; where obtaining all the bitstream segments corresponding to the stripes in a stripe row includes: for each stripe, having obtained S bitstream segments corresponding to the stripe, where S is greater than or equal to 1 and less than the number of bitstream segments.
[0335] Step 6: Determine whether the strip encoding is completed. If not, return to Step 3 to encode the next strip row.
[0336] Exemplarily, for the interleaving process of the bitstream segments when sliceNumX is equal to 2, the segment 1 of the first strip can be encoded first, then the segment 1 of the second strip, then the segment 2 of the first strip, then the segment 2 of the second strip, and so on, until the segment N of the first strip is encoded, and then the segment N of the second strip is encoded. See Figure 6C As shown, it is a schematic diagram of the length of the bitstream segments. The odd-numbered bitstream segments such as segment 1, segment 3, and segment 5 of each strip have a length of size 1, while the even-numbered bitstream segments such as segment 2, segment 4, and segment 6 have a length of size 2.
[0337] In Embodiment 11, for the decoding end, the following steps can be adopted to implement the decoding method:
[0338] Step 1: Horizontally and vertically divide the image into sliceNumX*sliceNumY rectangular strips.
[0339] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit number), and determine the number of bitstream segments chunkNum of the bitstream segments according to the total resource. For example, the total resource can be calculated using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. According to the total resource total_resource, the number of bitstream segments chunkNum can be calculated using the following formula: chunknum = (total_resoure >> s) << 1 + n. In the above formula, s is a preset value, that is, the configured segment size value, which can be indicated by the image-level syntax parameter. Regarding the value of n, let left = (total_resoure – (chunknum - 1) << s), and n = left == 0? 0 : (left <= (1 << s + x)? 1 : 2).
[0340] Step 3: Receive the bitstream. For the sliceNumX strips of each strip row, parse chunknum times in sequence, and each time parse slicenumX bitstream segments and de-interleave them into the bitstream buffer (i.e., the bitstream buffer) of each strip.
[0341] Exemplarily, for each stripe, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the length (chunksize) of the chunkNum bitstream segments can be as follows: The lengths of all bitstream segments (i.e., chunkNum bitstream segments) switch between two fixed values in an odd-even pattern, that is, they switch between size1 and size2 in turn. That is, the length of odd-numbered bitstream segments is size1, and the length of even-numbered bitstream segments is size2, or the length of odd-numbered bitstream segments is size2, and the length of even-numbered bitstream segments is size1. For example, size1 = (1 << s) + x, size2 = (1 << s) - x, where x is a preset value.
[0342] Step 4: Decode each stripe based on the bitstream buffer of each stripe.
[0343] In a possible implementation, when there are bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to SliceNumX stripes, start decoding the bitstream segments corresponding to SliceNumX stripes. Among them, the existence of bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to SliceNumX stripes may include, but is not limited to: For each stripe, there are T bitstream segments corresponding to this stripe in the bitstream buffer corresponding to this stripe, where T is greater than or equal to 1 and less than the number of bitstream segments.
[0344] Step 5: After decoding each stripe is completed, obtain the reconstructed image of each stripe.
[0345] Step 6: Determine whether the parsing of the bitstreams of all stripe rows is completed. If not, return to Step 3 to parse the next stripe row. If it is completed, the decoding process of the current image is completed, and the next image can be parsed.
[0346] Embodiment 12: The length of the actual encoded bits of each stripe is fixed. The length of the actual encoded bits of each stripe is not the target transmission bit number, but is determined based on the lengths of all bitstream segments, that is, the sum of the lengths of all bitstream segments. By padding zeros and byte-aligning the bitstream buffer, the lengths of all bitstream segments switch between two fixed values in an odd-even pattern. The lengths of odd-numbered bitstream segments are all the first size, and the lengths of even-numbered bitstream segments are all the second size. The length of the bitstream buffer is the sum of the lengths of the bitstream segments of the first size plus the sum of the lengths of the bitstream segments of the second size.
[0347] In Embodiment 12, for the encoding end, the following steps can be adopted to implement the encoding method:
[0348] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0349] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, according to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height.
[0350] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0351] Exemplarily, since there are sliceNumX slices in each slice row, the sliceNumX slices can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX slices. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte aligned so that the length of the bitstream buffer is the sum of the lengths of all codestream segments, and the sum of the lengths of all codestream segments can be greater than the target number of transmission bits (i.e., total resources), that is, the bitstream buffer can be filled with zeros and byte aligned according to the lengths of all codestream segments.
[0352] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0353] Exemplarily, the length (chunksize) of chunkNum code stream segments may be calculated as follows: the lengths of all code stream segments (i.e., chunkNum code stream segments) are switched between two fixed values of odd and even, i.e., they are switched between size1 and size2 in sequence, i.e., the length of the odd-numbered code stream segments is size1, and the length of the even-numbered code stream segments is size2, or, the length of the odd-numbered code stream segments is size2, and the length of the even-numbered code stream segments is size1.
[0354] For example, size1 = (((slice_width*bpp+7)<<3)>>3)+x, size2 = (((slice_width*bpp+7)<<3)>>3)-x, where x is a preset value. As can be seen from the above formula, the number of pixels in a stripe row is determined based on the stripe width and the number of bits occupied by each pixel. For example, if the number of pixels in a stripe row is (((slice_width*bpp+7)<<3)>>3), size1 is determined based on the sum of the number of pixels in a stripe row and the preset value x, and size2 is determined based on the difference between the number of pixels in a stripe row and the preset value x.
[0355] Exemplarily, since the bitstream buffer is padded with zeros and byte-aligned according to the lengths of all bitstream segments, the lengths of all bitstream segments can be switched between size1 and size2 in sequence.
[0356] For example, assuming that there are sliceNumX strips in the coding strip row, after generating sliceenumX bitstream buffers, the length of the bitstream buffer is 340. Assuming that size1 is 99, size2 is 101, and the number of code stream fragments chunkNum is 4, then the length of the bitstream buffer needs to be 400, that is, the sum of the lengths of two size1s and two size2s. Therefore, when filling the bitstream buffer with zeros and aligning bytes, the length of the bitstream buffer needs to be increased from 340 to 400, that is, the length that needs to be filled with zeros is 60, so that the length of all code stream fragments is switched between size1 and size2.
[0357] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0358] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0359] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0360] In Embodiment 12, for the decoding end, the decoding method can be implemented by using the following steps:
[0361] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0362] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, according to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height.
[0363] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0364] Exemplarily, for each slice, chunknum is parsed for times to obtain chunkNum stream segments, and the length (chunksize) of chunkNum stream segments may be calculated as follows: the lengths of all stream segments (i.e., chunkNum stream segments) are switched between two fixed values of odd and even, i.e., switching between size1 and size2 in sequence, for example, the length of odd stream segments is size1, and the length of even stream segments is size2, or the length of odd stream segments is size2, and the length of even stream segments is size1. For example, size1 = (((slice_width*bpp+7)<<3)>>3)+x, size2 = (((slice_width*bpp+7)<<3)>>3)-x, and x may be a preset value.
[0365] Step 4: decode each slice based on the bitstream buffer of each slice.
[0366] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0367] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0368] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0369] Embodiment 13: The length of the actual number of coded bits of each stripe is not fixed (the lengths of the actual number of coded bits of different stripes may be the same or different), that is, the bitstream buffer is not filled with zeros and byte-aligned, and the length of the bitstream buffer is not the target number of transmission bits, but the actual number of coded bits. For example, after the bitstream buffer is generated for the coded stripe, the length of the bitstream buffer is 340, then the actual number of coded bits in the bitstream buffer is 340, and no additional zero-filling operation is required.
[0370] The lengths of the first chunkNum-1 code stream segments are fixed and recorded as the first size. The length of the last code stream segment is not fixed and recorded as the second size. The code stream needs to include segment length indication information corresponding to the last code stream segment. The segment length indication information is used to indicate the length of the last code stream segment, that is, to indicate the length of the second size.
[0371] In Embodiment 13, for the encoding end, the encoding method may be implemented by using the following steps:
[0372] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0373] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure-RC_BUFFER_LENGTH)>>s+1, where s is a preset value, i.e., a configured segment size value, which can be indicated by a picture-level syntax parameter.
[0374] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and calculate the actual number of bits real_bit corresponding to each bitstream buffer.
[0375] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. After obtaining the sliceenumX bitstream buffers, the bitstream buffers are no longer filled with zeros and byte aligned, that is, the length of the bitstream buffer is the actual number of encoded bits, rather than the target number of transmitted bits after zero filling. In addition, the actual number of bits real_bit corresponding to each bitstream buffer can be calculated, and the actual number of bits real_bit is the actual number of encoded bits of the bitstream buffer.
[0376] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0377] Exemplarily, the calculation method of the lengths (chunksize) of chunkNum bitstream segments can be as follows: the lengths of the previous chunkNum - 1 bitstream segments are size1, and the length of the last bitstream segment is size2. For example, size1 = 1 << s, and size2 = real_bit – ((chunknum - 1) << s). In the above formula, s is a preset value, real_bit represents the actual encoded bits in the bitstream buffer, and chunknum represents the number of bitstream segments. In summary, size1 is determined based on the segment size value s, and size2 is determined based on the actual encoded bits real_bit in the bitstream buffer, the segment size value s, and the number of bitstream segments.
[0378] Step 5: For sliceNumX slices within a stripe row, encode chunkNum times. Each time, interleave the bitstream segments of each slice (i.e., the bitstream segments of sliceNumX slices) to form the final bitstream.
[0379] In a possible implementation, for sliceNumX slices within a stripe row, encoding chunkNum times and interleaving the bitstream segments of each slice each time to form the final bitstream may include, but is not limited to: when all the bitstream segments corresponding to all the slices within a stripe row have been obtained, start interleaving the bitstream segments corresponding to X slices to obtain the final bitstream; where obtaining all the bitstream segments corresponding to all the slices within a stripe row includes: for each slice, having obtained S bitstream segments corresponding to the slice, where S is greater than or equal to 1 and less than the number of bitstream segments.
[0380] Exemplarily, before encoding the last bitstream segment, segment header information can also be encoded in the bitstream. This segment header information is the segment length indication information corresponding to the last bitstream segment, and this segment header information is used to indicate the length of the last bitstream segment. That is to say, the value of this segment header information represents the length of the last bitstream segment, i.e., the value of size2. For example, this segment header information can be encoded using a fixed number of bits, such as encoded using 16 fixed bits.
[0381] Step 6: Determine whether the encoding of the stripe has ended. If not, return to Step 3 to encode the next stripe row.
[0382] Exemplarily, when sliceNumX is equal to 2, the interleaving process of the code stream segments may first encode the segment 1 of the first slice, then encode the segment 1 of the second slice, then encode the segment 2 of the first slice, then encode the segment 2 of the second slice, and so on, until the segment N-1 of the first slice is encoded, then the segment N-1 of the second slice is encoded, then the segment header information 1 of the segment N of the first slice is encoded, the segment header information 1 is used to indicate the length of the segment N of the first slice, then the segment N of the first slice is encoded, then the segment header information 2 of the segment N of the second slice is encoded, the segment header information 2 is used to indicate the length of the segment N of the second slice, and then the segment N of the second slice is encoded. See Fig. 7A As shown, it is a schematic diagram of the length of the code stream segment. The lengths of segment 1 to segment (N-1) are all size 1. The length of segment N of the first stripe is not fixed, and the length is indicated by the segment N header of the first stripe. The length of segment N of the second stripe is not fixed (and may also be different from the length of segment N of the first stripe), and the length is indicated by the segment N header of the second stripe.
[0383] In Embodiment 13, for the decoding end, the decoding method can be implemented by using the following steps:
[0384] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0385] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure-RC_BUFFER_LENGTH)>>s+1, where s is a preset value, i.e., a configured segment size value, which can be indicated by a picture-level syntax parameter.
[0386] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0387] Exemplarily, before parsing the last bitstream segment from the bitstream, the segment header information of this bitstream segment can be parsed first. The segment header information is the segment length indication information corresponding to the last bitstream segment, and it is used to indicate the length of the last bitstream segment. The segment header information can be parsed with a fixed number of bits, such as 16 bits. Based on the value of the segment header information (i.e., the length of the last bitstream segment), the last bitstream segment is parsed from the bitstream. For example, first parse the segment header information of the last bitstream segment of the first stripe from the bitstream, and parse the last bitstream segment of the first stripe based on this segment header information. Then parse the segment header information of the last bitstream segment of the second stripe from the bitstream, and parse the last bitstream segment of the second stripe based on this segment header information, and so on.
[0388] Exemplarily, for each stripe, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the lengths (chunksize) of the chunkNum bitstream segments can be: the lengths of the previous chunkNum - 1 bitstream segments are size1, and the length of the last bitstream segment is size2. For example, size1 = 1 << s, and size2 is the value of the segment header information of the last bitstream segment, that is, this segment header information is used to indicate the length of size2, and its value is used as size2.
[0389] Step 4: Decode each stripe based on the bitstream buffer of each stripe.
[0390] In a possible implementation manner, when there are bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to SliceNumX stripes, start decoding the bitstream segments corresponding to the SliceNumX stripes. Among them, that there are bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to SliceNumX stripes may include, but is not limited to: for each stripe, there are T bitstream segments corresponding to this stripe in the bitstream buffer corresponding to this stripe, where T is greater than or equal to 1 and less than the number of bitstream segments.
[0391] Step 5: After the decoding of each stripe is completed, obtain the reconstructed image of each stripe.
[0392] Step 6: Determine whether the parsing of the bitstreams of all stripe rows is ended. If not, return to Step 3 to parse the next stripe row. If it is ended, complete the decoding process of the current image and can parse the next image.
[0393] Embodiment 14: The length of the actual number of coded bits of each stripe is not fixed (the lengths of the actual number of coded bits of different stripes can be the same or different), that is, the bitstream buffer is not filled with zeros and byte aligned, and the length of the bitstream buffer is not the target number of transmitted bits, but the actual number of coded bits. The length of the following chunkNum-1 code stream segments is fixed, recorded as the first size, the length of the first code stream segment is not fixed, recorded as the second size, and the code stream needs to include the segment length indication information corresponding to the first code stream segment, and the segment length indication information is used to indicate the length of the first code stream segment.
[0394] In Embodiment 14, for the encoding end, the encoding method may be implemented by using the following steps:
[0395] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0396] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure-RC_BUFFER_LENGTH)>>s+1, where s is a preset value, i.e., a configured segment size value, which can be indicated by a picture-level syntax parameter.
[0397] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and calculate the actual number of bits real_bit corresponding to each bitstream buffer.
[0398] Exemplarily, since there are sliceNumX slices in each slice row, sliceNumX slices are encoded to obtain sliceenumX bitstream buffers corresponding to sliceNumX slices. After obtaining sliceenumX bitstream buffers, the bitstream buffers are no longer filled with zeros and byte aligned, that is, the length of the bitstream buffer is the actual number of encoded bits.
[0399] Step 4: Divide each bitstream buffer into chunkNum code stream segments, and the lengths of the code stream segments are not fixed.
[0400] Exemplarily, the calculation method for the lengths (chunksize) of the chunkNum code stream segments can be as follows: the length of the first code stream segment is size1, and the lengths of the subsequent chunkNum - 1 code stream segments are size2. For example, size2 = 1 << s, and size1 = real_bit - ((chunknum - 1) << s). In the above formula, s is a preset value, real_bit represents the actual encoded number of bits in the bitstream buffer, and chunknum represents the number of code stream segments.
[0401] Step 5: For the sliceNumX stripes within a stripe row, encode chunkNum times in sequence. Each time, interleave the code stream segments of each stripe (i.e., the code stream segments of sliceNumX stripes) to form the final code stream.
[0402] In a possible implementation manner, for the sliceNumX stripes within a stripe row, encoding chunkNum times in sequence and interleaving the code stream segments of each stripe each time to form the final code stream may include, but is not limited to: when all the code stream segments corresponding to the stripes within a stripe row have been obtained, start interleaving the code stream segments corresponding to the X stripes to obtain the final code stream; where obtaining all the code stream segments corresponding to the stripes within a stripe row includes: for each stripe, having obtained S code stream segments corresponding to the stripe, where S is greater than or equal to 1 and less than the number of code stream segments.
[0403] Exemplarily, before encoding the first code stream segment, fragment header information can also be encoded in the code stream. This fragment header information is the fragment length indication information corresponding to the first code stream segment, and it is used to indicate the length of the first code stream segment. That is to say, the value of this fragment header information represents the length of the first code stream segment, i.e., the value of size1. For example, this fragment header information can be encoded using a fixed number of bits, such as encoded using 16 fixed bits.
[0404] Step 6: Determine whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0405] Exemplarily, in the interleaving process of the code stream segments when sliceNumX is equal to 2, the segment header information 1 of the segment 1 of the first slice may be first encoded, where the segment header information 1 is used to indicate the length of the segment 1 of the first slice, and then the segment 1 of the first slice is encoded, and then the segment header information 2 of the segment 1 of the second slice is encoded, where the segment header information 2 is used to indicate the length of the segment 1 of the second slice, and then the segment 1 of the second slice is encoded. Then, the segment 2 of the first slice is encoded, the segment 2 of the second slice is encoded, the segment 3 of the first slice is encoded, the segment 3 of the second slice is encoded, and so on, until the segment N of the first slice is encoded, and then the segment N of the second slice is encoded. See. Figure 7B As shown, it is a schematic diagram of the length of the code stream segment. The lengths of segments 2 to N are all size 1. The length of segment 1 of the first stripe is not fixed, and the length is indicated by the segment 1 header of the first stripe. The length of segment 1 of the second stripe is not fixed (and may also be different from the length of segment 1 of the first stripe), and the length is indicated by the segment 1 header of the second stripe.
[0406] In Embodiment 14, for the decoding end, the decoding method can be implemented by using the following steps:
[0407] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0408] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure-RC_BUFFER_LENGTH)>>s+1, where s is a preset value, i.e., a configured segment size value, which can be indicated by a picture-level syntax parameter.
[0409] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0410] Exemplarily, before parsing the first bitstream segment from the bitstream, the segment header information of the bitstream segment can be parsed first. The segment header information is the segment length indication information corresponding to the first bitstream segment, and is used to indicate the length of the first bitstream segment. The segment header information can be parsed with a fixed number of bits, such as 16 bits.
[0411] Based on the value of the segment header information (i.e., the length of the first bitstream segment), the first bitstream segment is parsed from the bitstream. For example, first parse the segment header information of the first bitstream segment of the first strip from the bitstream, parse the first bitstream segment of the first strip based on the segment header information, then parse the segment header information of the first bitstream segment of the second strip from the bitstream, and parse the first bitstream segment of the second strip based on the segment header information, and so on.
[0412] Exemplarily, for each strip, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the lengths (chunksize) of the chunkNum bitstream segments can be: the length of the first bitstream segment is size1, and the lengths of the subsequent chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, and size1 is the value of the segment header information of the first bitstream segment, that is, the segment header information is used to indicate the length of size1, and its value is used as size1.
[0413] Step 4: Decode each strip based on the bitstream buffer of each strip.
[0414] In a possible implementation manner, when there are bitstream segments corresponding to SliceNumX strips in the bitstream buffers corresponding to the SliceNumX strips, start decoding the bitstream segments corresponding to the SliceNumX strips. Among them, the existence of bitstream segments corresponding to SliceNumX strips in the bitstream buffers corresponding to the SliceNumX strips may include, but is not limited to: for each strip, there are T bitstream segments corresponding to the strip in the bitstream buffer corresponding to the strip, where T is greater than or equal to 1 and less than the number of bitstream segments.
[0415] Step 5: After decoding each strip is completed, the reconstructed image of each strip is obtained.
[0416] Step 6: Determine whether the parsing of the bitstreams of all strip rows is completed. If not, return to Step 3 to parse the next strip row. If it is completed, the decoding process of the current image is completed, and the next image can be parsed.
[0417] Embodiment 15: The length of the actual number of coded bits of each stripe is not fixed (the lengths of the actual number of coded bits of different stripes may be the same or different), that is, the bitstream buffer is not padded with zeros and byte aligned, and the length of the bitstream buffer is not the target number of transmitted bits, but the actual number of coded bits. The length of the remaining codestream segments (i.e., chunkNum-1 codestream segments) except the k-th codestream segment is fixed, recorded as the first size, the length of the k-th codestream segment is not fixed, recorded as the second size, and the codestream needs to include segment length indication information corresponding to the k-th codestream segment, and the segment length indication information is used to indicate the length of the k-th codestream segment. The k-th codestream segment may be the last codestream segment among all codestream segments; or, the k-th codestream segment is the first codestream segment among all codestream segments; or, the k-th codestream segment is located between the first codestream segment and the last codestream segment, that is, the k-th codestream segment is any codestream segment.
[0418] In Embodiment 15, for the encoding end, the encoding method may be implemented by using the following steps:
[0419] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0420] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure-RC_BUFFER_LENGTH)>>s+1, where s is a preset value, i.e., a configured segment size value, which can be indicated by a picture-level syntax parameter.
[0421] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and calculate the actual number of bits real_bit corresponding to each bitstream buffer.
[0422] Exemplarily, since there are sliceNumX stripes in each stripe row, sliceNumX stripes are encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX stripes. After obtaining the sliceNumX bitstream buffers, zero-padding and byte alignment are no longer performed on the bitstream buffers, that is, the length of the bitstream buffer is the actual number of encoded bits.
[0423] Step 4: Divide each bitstream buffer into chunkNum code stream segments, and the lengths of the code stream segments are not fixed.
[0424] Exemplarily, the calculation method for the lengths (chunksize) of the chunkNum code stream segments can be: the length of the kth code stream segment is size1, and the lengths of the remaining chunkNum - 1 code stream segments are size2. For example, size2 = 1 << s, size1 = real_bit – ((chunknum - 1) << s). In the above formula, s is a preset value, and the value range of k is 1 to chunknum.
[0425] Step 5: For the sliceNumX stripes in a stripe row, encode chunkNum times in sequence. Each time, the code stream segments of each stripe (i.e., the code stream segments of the sliceNumX stripes) are interleaved to form the final code stream.
[0426] In a possible implementation, for the sliceNumX stripes in a stripe row, encoding chunkNum times in sequence and interleaving the code stream segments of each stripe each time to form the final code stream may include, but is not limited to: when all the code stream segments corresponding to the stripes in a stripe row have been obtained, start interleaving the code stream segments corresponding to X stripes to obtain the final code stream; where obtaining all the code stream segments corresponding to the stripes in a stripe row includes: for each stripe, having obtained S code stream segments corresponding to the stripe, S is greater than or equal to 1 and less than the number of code stream segments.
[0427] Exemplarily, before encoding the kth code stream segment, segment header information can also be encoded in the code stream. The segment header information is the segment length indication information corresponding to the kth code stream segment, and the segment header information is used to indicate the length of the kth code stream segment. That is to say, the value of the segment header information represents the length of the kth code stream segment, that is, the value of size1. For example, the segment header information can be encoded with a fixed number of bits, such as encoded with a fixed 16 bits.
[0428] Step 6: Determine whether the encoding of the stripe is completed. If not, return to Step 3 to encode the next stripe row.
[0429] In Embodiment 15, for the decoding end, the decoding method can be implemented by using the following steps:
[0430] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0431] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure-RC_BUFFER_LENGTH)>>s+1, where s is a preset value, i.e., a configured segment size value, which can be indicated by a picture-level syntax parameter.
[0432] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0433] Exemplarily, before parsing the kth code stream segment from the code stream, the segment header information of the code stream segment can be parsed first. The segment header information is the segment length indication information corresponding to the kth code stream segment. The segment header information is used to indicate the length of the kth code stream segment. The segment header information can be parsed using a fixed number of bits, such as 16 bits.
[0434] Based on the value of the segment header information (i.e., the length of the k-th bitstream segment), the k-th bitstream segment is parsed from the bitstream. For example, the segment header information of the k-th bitstream segment of the first stripe is first parsed from the bitstream, and the k-th bitstream segment of the first stripe is parsed based on the segment header information. Then, the segment header information of the k-th bitstream segment of the second stripe is parsed from the bitstream, and the k-th bitstream segment of the second stripe is parsed based on the segment header information, and so on.
[0435] Exemplarily, for each stripe, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the length (chunksize) of the chunkNum bitstream segments can be as follows: the length of the k-th bitstream segment is size1, and the lengths of the remaining chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, and size1 is the value of the segment header information of the k-th bitstream segment, that is, this segment header information is used to indicate the length of size1, and its value is used as size1.
[0436] Step 4: Decode each stripe based on the bitstream buffer of each stripe.
[0437] In a possible implementation manner, when there are bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to SliceNumX stripes, start decoding the bitstream segments corresponding to SliceNumX stripes. Among them, the existence of bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to SliceNumX stripes may include, but is not limited to: for each stripe, there are T bitstream segments corresponding to this stripe in the bitstream buffer corresponding to this stripe, where T is greater than or equal to 1 and less than the number of bitstream segments.
[0438] Step 5: After decoding each stripe is completed, obtain the reconstructed image of each stripe.
[0439] Step 6: Determine whether the parsing of the bitstreams of all stripe rows is ended. If not, return to Step 3 to parse the next stripe row. If it is ended, complete the decoding process of the current image and can parse the next image.
[0440] Embodiment 16: The length of the actual encoded bits of each stripe is not fixed (the lengths of the actual encoded bits of different stripes can be the same or different), that is, zero-padding and byte alignment are not performed on the bitstream buffer. The length of the bitstream buffer is not the target transmission bit number, but the actual encoded bit number. The lengths of the remaining bitstream segments (that is, chunkNum - 1 bitstream segments) except the k-th bitstream segment are fixed, denoted as the first size, the length of the k-th bitstream segment is not fixed, denoted as the second size, and the bitstream needs to include the segment length indication information corresponding to the k-th bitstream segment, and this segment length indication information is used to indicate the length of the k-th bitstream segment. The k-th bitstream segment can be the last bitstream segment among all bitstream segments; or, the k-th bitstream segment is the first bitstream segment among all bitstream segments; or, the k-th bitstream segment is located between the first bitstream segment and the last bitstream segment, that is, the k-th bitstream segment is any one of the bitstream segments.
[0441] In Embodiment 16, for the encoding end, the encoding method may be implemented by using the following steps:
[0442] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0443] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, according to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height.
[0444] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and calculate the actual number of bits real_bit corresponding to each bitstream buffer.
[0445] Exemplarily, since there are sliceNumX slices in each slice row, sliceNumX slices are encoded to obtain sliceenumX bitstream buffers corresponding to sliceNumX slices. After obtaining sliceenumX bitstream buffers, the bitstream buffers are no longer filled with zeros and byte aligned, that is, the length of the bitstream buffer is the actual number of encoded bits.
[0446] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0447] Exemplarily, the length (chunksize) of chunkNum codestream segments can be calculated as follows: the length of the kth codestream segment is size1, and the length of the remaining chunkNum-1 codestream segments is size2. For example, size2 = (((slice_width*bpp)<<3)>>3), size1 = real_bit–((chunknum-1)*size2), and the value range of k is 1 to chunknum. slice_width is used to indicate the stripe width, bpp is used to indicate the number of bits per pixel, real_bit indicates the actual number of coded bits corresponding to the bitstream buffer, and chunknum indicates the number of codestream segments. In summary, size2 is determined based on the stripe width and the number of bits per pixel, and size1 is determined based on the actual number of coded bits corresponding to the bitstream buffer, size2, and the number of codestream segments.
[0448] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0449] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0450] Exemplarily, before encoding the kth code stream segment, segment header information may be encoded in the code stream, the segment header information is segment length indication information corresponding to the kth code stream segment, and the segment header information is used to indicate the length of the kth code stream segment, that is, the value of the segment header information indicates the length of the kth code stream segment, that is, the value of size1. For example, the segment header information may be encoded using a fixed number of bits, such as a fixed 16 bits.
[0451] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0452] In Embodiment 16, for the decoding end, the decoding method can be implemented by using the following steps:
[0453] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0454] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. And, according to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height.
[0455] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0456] Exemplarily, before parsing the kth code stream segment from the code stream, the segment header information of the code stream segment can be parsed first. The segment header information is the segment length indication information corresponding to the kth code stream segment. The segment header information is used to indicate the length of the kth code stream segment. The segment header information can be parsed using a fixed number of bits, such as 16 bits.
[0457] Based on the value of the segment header information (i.e., the length of the k-th bitstream segment), the k-th bitstream segment is parsed from the bitstream. For example, the segment header information of the k-th bitstream segment of the first stripe is first parsed from the bitstream, and the k-th bitstream segment of the first stripe is parsed based on the segment header information. Then, the segment header information of the k-th bitstream segment of the second stripe is parsed from the bitstream, and the k-th bitstream segment of the second stripe is parsed based on the segment header information, and so on.
[0458] Exemplarily, for each slice, chunknum can be parsed for times to obtain chunkNum code stream segments, and the length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunkNum-1 code stream segments is size2. size2=(((slice_width*bpp)<<3)>>3), size1 is the value of the segment header information of the kth code stream segment, that is, the segment header information is used to indicate the length of size1, and its value is used as size1.
[0459] Step 4: decode each slice based on the bitstream buffer of each slice.
[0460] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0461] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0462] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0463] Embodiment 17: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, the length of the first chunkNum-1 code stream segments is fixed, recorded as the first size, the length of the last code stream segment is not fixed, recorded as the second size, and the code stream needs to include segment length indication information corresponding to the last code stream segment, and the segment length indication information is used to indicate the length of the last code stream segment.
[0464] In Embodiment 17, for the encoding end, the encoding method may be implemented by using the following steps:
[0465] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0466] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, the number of chunks chunkNum is calculated using the following formula: chunknum = (total_resoure) >> s + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0467] Step 3: Encode sliceNumX stripes within each stripe row in sequence to generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and pad zeros and perform byte alignment on the bitstream buffers.
[0468] Exemplarily, since there are sliceNumX stripes in each stripe row, thus, sliceNumX stripes can be encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, zeros can be padded and byte alignment can be performed on this bitstream buffer so that the length of this bitstream buffer is the target transmission bit count (i.e., the total resource), that is, zeros are padded and byte alignment is performed on this bitstream buffer according to the target transmission bit count.
[0469] Step 4: Divide each bitstream buffer into chunkNum bitstream segments, and the lengths of the bitstream segments are not fixed.
[0470] Exemplarily, the calculation method for the lengths (chunksize) of the chunkNum bitstream segments can be: the lengths of the first chunkNum - 1 bitstream segments are size1, and the length of the last bitstream segment is size2. For example, size1 = 1 << s, size2 = total_resouce – ((chunknum - 1) << s)). In the above formula, s is a preset value, that is, the configured segment size value.
[0471] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0472] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0473] Exemplarily, before encoding the last code stream segment, segment header information may also be encoded in the code stream, the segment header information is segment length indication information corresponding to the last code stream segment, and the segment header information is used to indicate the length of the last code stream segment, that is, the value of the segment header information indicates the length of the last code stream segment, that is, the value of size2. For example, the segment header information may be encoded using a fixed number of bits, such as a fixed 16 bits.
[0474] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0475] Exemplarily, when sliceNumX is equal to 2, the interleaving process of the code stream segments is to encode the segment 1 of the first slice, encode the segment 1 of the second slice, encode the segment 2 of the first slice, encode the segment 2 of the second slice, and so on, until the segment N-1 of the first slice is encoded, the segment N-1 of the second slice is encoded, and then the segment header information 1 of the segment N of the first slice is encoded, the segment header information 1 is used to indicate the length of the segment N of the first slice, the segment N of the first slice is encoded, the segment header information 2 of the segment N of the second slice is encoded, the segment header information 2 is used to indicate the length of the segment N of the second slice, and the segment N of the second slice is encoded. See Fig. 8A As shown, it is a schematic diagram of the length of the code stream segment. The lengths of segment 1 to segment (N-1) are all size 1. The length of segment N of the first stripe is not fixed, and the length is indicated by the segment N header of the first stripe. The length of segment N of the second stripe is not fixed, and the length is indicated by the segment N header of the second stripe.
[0476] In Embodiment 17, for the decoding end, the decoding method can be implemented by using the following steps:
[0477] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0478] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. For example, the total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure)>>s+n. s is a preset value. Regarding the value of n, n=total_resoure%(1< <s)==0?0:1。
[0479] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0480] Exemplarily, before parsing the last code stream segment from the code stream, the segment header information of the code stream segment may be parsed first. The segment header information is the segment length indication information corresponding to the last code stream segment. The segment header information is used to indicate the length of the last code stream segment. The segment header information may be parsed using a fixed number of bits, such as 16 bits. Based on the value of the segment header information (i.e., the length of the last code stream segment), the last code stream segment is parsed from the code stream. For example, the segment header information of the last code stream segment of the first stripe is first parsed from the code stream, and the last code stream segment of the first stripe is parsed based on the segment header information. Then, the segment header information of the last code stream segment of the second stripe is parsed from the code stream, and the last code stream segment of the second stripe is parsed based on the segment header information, and so on.
[0481] Exemplarily, for each stripe, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the length (chunksize) of the chunkNum bitstream segments can be as follows: the lengths of the previous chunkNum - 1 bitstream segments are size1, and the length of the last bitstream segment is size2. For example, size1 = 1 << s, and size2 is the value of the segment header information of the last bitstream segment, that is, the segment header information is used to indicate the length of size2, and its value is used as size2.
[0482] Step 4: Decode each stripe based on the bitstream buffer of each stripe.
[0483] In a possible implementation manner, when there are bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to the SliceNumX stripes, start decoding the bitstream segments corresponding to the SliceNumX stripes. Among them, the existence of bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to the SliceNumX stripes may include, but is not limited to: for each stripe, there are T bitstream segments corresponding to this stripe in the bitstream buffer corresponding to this stripe, where T is greater than or equal to 1 and less than the number of bitstream segments.
[0484] Step 5: After the decoding of each stripe is completed, obtain the reconstructed image of each stripe.
[0485] Step 6: Determine whether the parsing of the bitstreams of all stripe rows is completed. If not, return to Step 3 to parse the next stripe row. If it is completed, the decoding process of the current image is completed, and the next image can be parsed.
[0486] Embodiment 18: The length of the actual encoded bits of each stripe is fixed. For example, the length of the actual encoded bits of each stripe is equal to the target transmission bits. The lengths of the subsequent chunkNum - 1 bitstream segments are fixed, denoted as the first size, and the length of the first bitstream segment is not fixed, denoted as the second size. And the bitstream needs to include the segment length indication information corresponding to the first bitstream segment, and this segment length indication information is used to indicate the length of the first bitstream segment.
[0487] In Embodiment 18, for the encoding end, the following steps can be adopted to implement the encoding method:
[0488] Step 1: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular stripes.
[0489] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, the number of chunks chunkNum is calculated using the following formula: chunknum = (total_resoure) >> s + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0490] Step 3: Encode sliceNumX stripes within each stripe row in sequence to generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and pad zeros and perform byte alignment on the bitstream buffers.
[0491] Exemplarily, since there are sliceNumX stripes in each stripe row, therefore, sliceNumX stripes can be encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, zeros can be padded and byte alignment can be performed on the bitstream buffer so that the length of the bitstream buffer is the target transmission bit count (i.e., the total resource), that is, padding zeros and performing byte alignment on the bitstream buffer according to the target transmission bit count.
[0492] Step 4: Divide each bitstream buffer into chunkNum bitstream segments, and the lengths of the bitstream segments are not fixed.
[0493] Exemplarily, the calculation method for the lengths (chunksize) of the chunkNum bitstream segments can be: the length of the first bitstream segment is size1, and the lengths of the subsequent chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, size1 = total_resouce – ((chunknum - 1) << s)). In the above formula, s is a preset value, that is, the configured segment size value.
[0494] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0495] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0496] Exemplarily, before encoding the first code stream segment, segment header information may be encoded in the code stream, the segment header information is segment length indication information corresponding to the first code stream segment, and the segment header information is used to indicate the length of the first code stream segment, that is, the value of the segment header information indicates the length of the first code stream segment, that is, the value of size1. For example, the segment header information may be encoded using a fixed number of bits, such as a fixed 16 bits.
[0497] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0498] Exemplarily, in the interleaving process of the code stream segments when sliceNumX is equal to 2, the segment header information 1 of the segment 1 of the first slice is encoded, the segment header information 1 is used to indicate the length of the segment 1 of the first slice, the segment 1 of the first slice is encoded, the segment header information 2 of the segment 1 of the second slice is encoded, the segment header information 2 is used to indicate the length of the segment 1 of the second slice, and the segment 1 of the second slice is encoded. Then, the segment 2 of the first slice is encoded, the segment 2 of the second slice is encoded, the segment 3 of the first slice is encoded, the segment 3 of the second slice is encoded, and so on, until the segment N of the first slice is encoded, and then the segment N of the second slice is encoded. See Figure 8B As shown, it is a schematic diagram of the length of the code stream segment. The lengths of segment 2 to segment N are all size 1. The length of segment 1 of the first stripe is not fixed, and the length is indicated by the segment 1 header of the first stripe. The length of segment 1 of the second stripe is not fixed, and the length is indicated by the segment 1 header of the second stripe.
[0499] In Embodiment 18, for the decoding end, the decoding method can be implemented by using the following steps:
[0500] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0501] The second step is to calculate the total resource total_resource (i.e. the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment based on the total resources. For example, the total resources are calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. Based on the total resource total_resource, the number of code stream segments chunkNum is calculated using the following formula: chunknum = (total_resoure)>>s+n. s is a preset value. Regarding the value of n, n=total_resoure%(1< <s)==0?0:1。
[0502] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0503] Exemplarily, before parsing the first code stream segment from the code stream, the segment header information of the code stream segment can be parsed first. The segment header information is the segment length indication information corresponding to the first code stream segment. The segment header information is used to indicate the length of the first code stream segment. The segment header information can be parsed using a fixed number of bits, such as 16 bits. Based on the value of the segment header information (i.e., the length of the first code stream segment), the first code stream segment is parsed from the code stream. For example, the segment header information of the first code stream segment of the first stripe is parsed from the code stream first, and the first code stream segment of the first stripe is parsed based on the segment header information. Then, the segment header information of the first code stream segment of the second stripe is parsed from the code stream, and the first code stream segment of the second stripe is parsed based on the segment header information, and so on.
[0504] Exemplarily, for each stripe, parsing chunknum times can obtain chunkNum bitstream segments. The calculation method of the length (chunksize) of the chunkNum bitstream segments can be as follows: the length of the first bitstream segment is size1, and the lengths of the subsequent chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, and size1 is the value of the segment header information of the first bitstream segment, that is, the segment header information is used to indicate the length of size1, and its value is used as size1.
[0505] Step 4: Decode each stripe based on the bitstream buffer of each stripe.
[0506] In a possible implementation manner, when there are bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to the SliceNumX stripes, start decoding the bitstream segments corresponding to the SliceNumX stripes. Among them, the existence of bitstream segments corresponding to SliceNumX stripes in the bitstream buffers corresponding to the SliceNumX stripes may include, but is not limited to: for each stripe, there are T bitstream segments corresponding to this stripe in the bitstream buffer corresponding to this stripe, where T is greater than or equal to 1 and less than the number of bitstream segments.
[0507] Step 5: After decoding each stripe is completed, obtain the reconstructed image of each stripe.
[0508] Step 6: Determine whether the parsing of the bitstreams of all stripe rows is completed. If not, return to Step 3 to parse the next stripe row. If it is completed, the decoding process of the current image is completed, and the next image can be parsed.
[0509] Embodiment 19: The length of the actual encoded bits of each stripe is fixed. For example, the length of the actual encoded bits of each stripe is equal to the target transmission bits. The lengths of the remaining bitstream segments (i.e., chunkNum - 1 bitstream segments) except for the kth bitstream segment are fixed, denoted as the first size, and the length of the kth bitstream segment is not fixed, denoted as the second size. And the bitstream needs to include the segment length indication information corresponding to the kth bitstream segment, and this segment length indication information is used to indicate the length of the kth bitstream segment. The kth bitstream segment can be the last bitstream segment among all bitstream segments; or, the kth bitstream segment is the first bitstream segment among all bitstream segments; or, the kth bitstream segment is located between the first bitstream segment and the last bitstream segment, that is, the kth bitstream segment is any one of the bitstream segments.
[0510] In Embodiment 19, for the encoding end, the following steps can be adopted to implement the encoding method:
[0511] Step 1: Horizontally and vertically divide the image into sliceNumX * sliceNumY rectangular strips.
[0512] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, calculate the total resource using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, calculate the number of chunks chunkNum using the following formula: chunknum = (total_resoure) >> s + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0513] Step 3: Encode the sliceNumX strips within each strip row in sequence to generate sliceNumX bitstream buffers slicebuffer[sliceNumX], and pad zeros and perform byte alignment on the bitstream buffers.
[0514] Exemplarily, since there are sliceNumX strips in each strip row, thus, the sliceNumX strips can be encoded to obtain sliceNumX bitstream buffers corresponding to the sliceNumX strips. For each bitstream buffer, zeros can be padded and byte alignment can be performed on this bitstream buffer so that the length of this bitstream buffer is the target transmission bit count (i.e., the total resource), that is, pad zeros and perform byte alignment on this bitstream buffer according to the target transmission bit count.
[0515] Step 4: Divide each bitstream buffer into chunkNum bitstream segments, and the lengths of the bitstream segments are not fixed.
[0516] Exemplarily, the calculation method for the lengths (chunksize) of the chunkNum bitstream segments can be: the length of the k-th bitstream segment is size1, and the lengths of the remaining chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, size1 = total_resouce - ((chunknum - 1) << s)). In the above formula, s is a preset value, that is, the configured segment size value.
[0517] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0518] Exemplarily, before encoding the kth code stream segment, segment header information may be encoded in the code stream, the segment header information is segment length indication information corresponding to the kth code stream segment, and the segment header information is used to indicate the length of the kth code stream segment, that is, the value of the segment header information indicates the length of the kth code stream segment, that is, the value of size1. For example, the segment header information may be encoded using a fixed number of bits, such as a fixed 16 bits.
[0519] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0520] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0521] In Embodiment 19, for the decoding end, the decoding method can be implemented by using the following steps:
[0522] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0523] Step 2: Calculate the total resource total_resource (i.e., the target transmission bit count), and determine the number of chunks chunkNum of the bitstream segments based on the total resource. For example, calculate the total resource using the following formula: total_resourec = ((slice_width * slice_height * target_bpp + 7) >> 3) << 3; or, total_resourec = ((slice_width * slice_height * target_bpp + 7 + RC_BUFFER_LENGTH) >> 3) << 3. Based on the total resource total_resource, calculate the number of chunks chunkNum using the following formula: chunknum = (total_resoure) >> s + n. s is a preset value. Regarding the value of n, n = total_resoure % (1 << s) == 0? 0 : 1.
[0524] Step 3: Receive the bitstream. For sliceNumX slices of each strip row, parse it chunknum times in sequence. Each time, parse slicenumX bitstream segments and deinterleave them into the bitstream buffer (i.e., the bitstream buffer) of each strip.
[0525] Exemplarily, before parsing the k-th bitstream segment from the bitstream, the segment header information of this bitstream segment can be parsed first. The segment header information is the segment length indication information corresponding to the k-th bitstream segment. The segment header information is used to indicate the length of the k-th bitstream segment. The segment header information can be parsed using a fixed number of bits, such as 16 bits. Based on the value of the segment header information (i.e., the length of the k-th bitstream segment), parse the k-th bitstream segment from the bitstream.
[0526] Exemplarily, for each strip, parsing it chunknum times can obtain chunkNum bitstream segments. The calculation method for the lengths (chunksize) of the chunkNum bitstream segments can be as follows: The length of the k-th bitstream segment is size1, and the lengths of the remaining chunkNum - 1 bitstream segments are size2. For example, size2 = 1 << s, and size1 is the value of the segment header information of the k-th bitstream segment, that is, the segment header information is used to indicate the length of size1, and its value is taken as size1.
[0527] Step 4: Decode each strip based on the bitstream buffer of each strip.
[0528] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0529] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0530] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0531] Embodiment 20: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, the length of the remaining code stream segments (i.e., chunkNum-1 code stream segments) except the k-th code stream segment is fixed, recorded as the first size, the length of the k-th code stream segment is not fixed, recorded as the second size, and the code stream needs to include segment length indication information corresponding to the k-th code stream segment, and the segment length indication information is used to indicate the length of the k-th code stream segment. The k-th code stream segment may be the last code stream segment among all code stream segments; or, the k-th code stream segment is the first code stream segment among all code stream segments; or, the k-th code stream segment is located between the first code stream segment and the last code stream segment, that is, the k-th code stream segment is any code stream segment.
[0532] In Embodiment 20, for the encoding end, the encoding method may be implemented by using the following steps:
[0533] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0534] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height.
[0535] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0536] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0537] Step 4: Divide each bitstream buffer into chunkNum stream segments, where the length of the stream segments is not fixed.
[0538] Exemplarily, the length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunkNum-1 code stream segments is size2. For example, size2 = (((slice_width*bpp+7)<<3)>>3), size1 = total_resouce–((chunknum-1)*size2), and the value range of k is 1 to chunknum. In the above formula, slice_width is used to indicate the stripe width, bpp is used to indicate the number of bits per pixel, total_resouce indicates the target number of transmission bits, and chunknum indicates the number of code stream segments. In summary, size2 is determined based on the stripe width and the number of bits per pixel, and size1 is determined based on the target number of transmission bits, size2, and the number of code stream segments.
[0539] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0540] Exemplarily, before encoding the kth code stream segment, segment header information may be encoded in the code stream, the segment header information is segment length indication information corresponding to the kth code stream segment, and the segment header information is used to indicate the length of the kth code stream segment, that is, the value of the segment header information indicates the length of the kth code stream segment, that is, the value of size1. For example, the segment header information may be encoded using a fixed number of bits, such as a fixed 16 bits.
[0541] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0542] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0543] In Embodiment 20, for the decoding end, the decoding method can be implemented by using the following steps:
[0544] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0545] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height.
[0546] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0547] Exemplarily, before parsing the kth code stream segment from the code stream, the segment header information of the code stream segment may be parsed first. The segment header information is the segment length indication information corresponding to the kth code stream segment. The segment header information is used to indicate the length of the kth code stream segment. The segment header information may be parsed using a fixed number of bits, such as 16 bits. Based on the value of the segment header information (i.e., the length of the kth code stream segment), the kth code stream segment is parsed from the code stream.
[0548] Exemplarily, for each slice, chunknum can be parsed for times to obtain chunkNum code stream segments, and the length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunkNum-1 code stream segments is size2. size2=(((slice_width*bpp+7)<<3)>>3), size1 is the value of the segment header information of the kth code stream segment, that is, the segment header information is used to indicate the length of size1, and the value is used as size1.
[0549] Step 4: decode each slice based on the bitstream buffer of each slice.
[0550] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0551] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0552] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0553] Embodiment 21: The length of the actual number of coded bits of each stripe is fixed, for example, the length of the actual number of coded bits of each stripe is equal to the target number of transmitted bits, the length of the remaining code stream segments (i.e., chunkNum-1 code stream segments) except the k-th code stream segment is fixed, recorded as the first size, the length of the k-th code stream segment is not fixed, recorded as the second size, and the code stream needs to include segment length indication information corresponding to the k-th code stream segment, and the segment length indication information is used to indicate the length of the k-th code stream segment. The k-th code stream segment may be the last code stream segment among all code stream segments; or, the k-th code stream segment is the first code stream segment among all code stream segments; or, the k-th code stream segment is located between the first code stream segment and the last code stream segment, that is, the k-th code stream segment is any code stream segment.
[0554] In Embodiment 21, for the encoding end, the encoding method may be implemented by using the following steps:
[0555] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0556] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height+1.
[0557] Step 3: Encode sliceNumX slices in each slice row in sequence, generate sliceenumX bitstream buffers slicebuffer[sliceNumX], and fill the bitstream buffers with zeros and align the bytes.
[0558] Exemplarily, since there are sliceNumX stripes in each stripe row, the sliceNumX stripes can be encoded to obtain sliceenumX bitstream buffers corresponding to the sliceNumX stripes. For each bitstream buffer, the bitstream buffer can be filled with zeros and byte-aligned so that the length of the bitstream buffer is the target number of transmission bits (i.e., total resources), that is, the bitstream buffer is filled with zeros and byte-aligned according to the target number of transmission bits.
[0559] Step 4: Divide each bitstream buffer into chunkNum stream segments, and the length of the stream segments is not fixed. For example, the length (chunksize) of chunkNum stream segments can be calculated as follows: the length of the kth stream segment can be size1, and the length of the remaining chunkNum-1 stream segments can be size2. For example, size2 = (((slice_width*bpp)<<3)>>3), size1 = total_resouce–((chunknum-1)*size2).
[0560] Compared with Example 20, the calculation formula for size2 in Example 21 is different. In Example 20, size2 = (((slice_width*bpp+7)<<3)>>3), and in Example 21, size2 = (((slice_width*bpp)<<3)>>3). The difference is that: since each byte is 8 bits, in Example 20, there is a "+7" operation, through which the length of the code stream segment is increased by one byte, while in Example 21, there is no "+7" operation, that is, the length of the code stream segment is increased by one byte.
[0561] Step 5: For sliceNumX slices in a slice row, encode chunkNum times in sequence, and each time interleave the code stream segments of each slice (that is, the code stream segments of sliceNumX slices) together to form the final code stream.
[0562] Exemplarily, before encoding the kth code stream segment, segment header information may be encoded in the code stream, the segment header information is segment length indication information corresponding to the kth code stream segment, and the segment header information is used to indicate the length of the kth code stream segment, that is, the value of the segment header information indicates the length of the kth code stream segment, that is, the value of size1. For example, the segment header information may be encoded using a fixed number of bits, such as a fixed 16 bits.
[0563] In a possible implementation manner, for sliceNumX slices in a slice row, chunkNum times are encoded in sequence, and each time, the code stream segments of each slice are interleaved together to form a final code stream, which may include but is not limited to: when the code stream segments corresponding to all the strips in a strip row have been obtained, the code stream segments corresponding to the X strips are started to be interleaved to obtain the final code stream; wherein the code stream segments corresponding to all the strips in a strip row have been obtained, including: for each strip, S code stream segments corresponding to the strip have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0564] Step 6: Determine whether the stripe encoding is complete. If not, return to step 3 and encode the next stripe row.
[0565] In Embodiment 21, for the decoding end, the decoding method can be implemented by using the following steps:
[0566] The first step is to split the image horizontally and vertically into sliceNumX*sliceNumY rectangular strips.
[0567] The second step is to calculate the total resource total_resource (i.e., the target number of transmission bits), and determine the number of code stream segments chunkNum of the code stream segment according to the slice height slice_height. For example, the total resource is calculated using the following formula: total_resourec = ((slice_width*slice_height*target_bpp+7)>>3)<<3; or, total_resourec = ((slice_width*slice_height*target_bpp+7+RC_BUFFER_LENGTH)>>3)<<3. According to the slice height slice_height, the number of code stream segments chunkNum can be calculated using the following formula: chunknum = slice_height+1.
[0568] Step 3: Receive the code stream. For each sliceNumX stripes of each stripe row, parse chunknum times in sequence. Each time, sliceNumX code stream segments are parsed and deinterleaved into the code stream buffer (ie, bit stream buffer) of each stripe.
[0569] Exemplarily, before parsing the kth code stream segment from the code stream, the segment header information of the code stream segment may be parsed first. The segment header information is the segment length indication information corresponding to the kth code stream segment. The segment header information is used to indicate the length of the kth code stream segment. The segment header information may be parsed using a fixed number of bits, such as 16 bits. Based on the value of the segment header information (i.e., the length of the kth code stream segment), the kth code stream segment is parsed from the code stream.
[0570] Exemplarily, for each slice, chunknum can be parsed for times to obtain chunkNum code stream segments, and the length (chunksize) of chunkNum code stream segments can be calculated as follows: the length of the kth code stream segment is size1, and the length of the remaining chunkNum-1 code stream segments is size2. size2=(((slice_width*bpp)<<3)>>3), size1 is the value of the segment header information of the kth code stream segment, that is, the segment header information is used to indicate the length of size1, and the value is used as size1.
[0571] Step 4: decode each slice based on the bitstream buffer of each slice.
[0572] In a possible implementation, when there are stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices, decoding of the stream segments corresponding to SliceNumX slices begins. The presence of stream segments corresponding to SliceNumX slices in the bitstream buffer corresponding to SliceNumX slices may include but is not limited to: for each slice, there are T stream segments corresponding to the slice in the bitstream buffer corresponding to the slice, T is greater than or equal to 1, and T is less than the number of stream segments.
[0573] Step 5: After decoding of each strip is completed, a reconstructed image of each strip is obtained.
[0574] Step 6: Determine whether the parsing of the code streams of all strip lines is completed. If not, return to step 3 to parse the next strip line. If it is completed, the decoding process of the current image is completed and the next image can be parsed.
[0575] Exemplarily, the above embodiments can be implemented separately or in combination. For example, each embodiment in Embodiment 1 to Embodiment 21 can be implemented separately, and at least two embodiments in Embodiment 1 to Embodiment 21 can be implemented in combination. The parameter explanations in the above embodiments can also be applied to other embodiments. For example, the explanation of Embodiment 1 can be applied to Embodiment 2 to Embodiment 21, and the explanation of Embodiment 3 can be applied to Embodiment 4 to Embodiment 21.
[0576] Illustratively, in the above embodiments, the content of the encoding end can also be applied to the decoding end, that is, the decoding end can be processed in the same way, and the content of the decoding end can also be applied to the encoding end, that is, the encoding end can be processed in the same way.
[0577] Example 22: Based on the same application concept as the above method, a decoding device is also proposed in the embodiment of the present application. The decoding device is applied to the decoding end, and the decoding device includes: a memory, which is configured to store video data; a decoder, which is configured to implement the decoding method in the above-mentioned embodiment 1-embodiment 21, that is, the processing flow of the decoding end.
[0578] For example, in one possible implementation, the decoder is configured to implement:
[0579] Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1;
[0580] Determine the number of code stream segments in each slice;
[0581] Deinterleaving the bitstream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target bitstream to obtain the bitstream segments of the number of bitstream segments corresponding to each stripe; wherein, among the bitstream segments of the number of bitstream segments, there are at least two sizes of bitstream segments;
[0582] The X stripes are decoded based on the bitstream buffers corresponding to the X stripes in the horizontal direction of the same stripe row; wherein the bitstream buffer corresponding to each stripe includes a codestream segment corresponding to the stripe.
[0583] Based on the same application concept as the above method, an encoding device is also proposed in an embodiment of the present application, and the encoding device is applied to an encoding end, and the encoding device includes: a memory, which is configured to store video data; an encoder, which is configured to implement the encoding method in the above embodiments 1 to 21, that is, the processing flow of the encoding end.
[0584] For example, in one possible implementation, the encoder is configured to implement:
[0585] Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1;
[0586] Determine the number of code stream segments in each slice;
[0587] Encode X stripes in the horizontal direction of the same stripe row to obtain X bit stream buffers corresponding to the X stripes;
[0588] For each bitstream buffer, the bitstream buffer is divided into the number of bitstream segments, wherein there are at least two sizes of bitstream segments in the number of bitstream segments;
[0589] Interweave the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target code stream;
[0590] The target code stream is sent to the decoding end.
[0591] Based on the same application concept as the above method, the decoding end device (also referred to as a video decoder) provided in the embodiment of the present application, from the hardware level, its hardware architecture diagram can be specifically referred to as Fig. 9A The system includes a processor 911 and a machine-readable storage medium 912, wherein the machine-readable storage medium 912 stores machine-executable instructions that can be executed by the processor 911; the processor 911 is used to execute the machine-executable instructions to implement the decoding method disclosed in the above-mentioned embodiments 1-21 of the present application.
[0592] Based on the same application concept as the above method, the encoding end device (also referred to as a video encoder) provided in the embodiment of the present application, from the hardware level, its hardware architecture diagram can be specifically referred to as Fig. 9B The system includes a processor 921 and a machine-readable storage medium 922, wherein the machine-readable storage medium 922 stores machine-executable instructions that can be executed by the processor 921; the processor 921 is used to execute the machine-executable instructions to implement the encoding method disclosed in the above-mentioned embodiments 1-21 of the present application.
[0593] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented, such as the decoding method or encoding method in the above embodiments.
[0594] Based on the same application concept as the above method, an embodiment of the present application also provides a computer application, which, when executed by a processor, can implement the decoding method or encoding method disclosed in the above example of the present application.
[0595] Based on the same application concept as the above method, a decoding device is also proposed in an embodiment of the present application. The decoding device is applied to a decoding end, and the decoding device includes: a division module, used to divide the image to be processed into X*Y strips, X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; a determination module, used to determine the number of code stream segments in each stripe; a decoding module, used to deinterleave the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target code stream, and obtain the code stream segments corresponding to the code stream segments number corresponding to each stripe; wherein, among the code stream segments number, there are at least two sizes of code stream segments; based on the bit stream buffer corresponding to the X stripes in the horizontal direction of the same stripe row, the X stripes are decoded; wherein the bit stream buffer corresponding to each stripe includes the code stream segment corresponding to the stripe.
[0596] Exemplarily, when determining the number of code stream segments in each stripe, the determination module is specifically used to: determine the target number of transmission bits according to the stripe width, the stripe height and the target number of bits per pixel, and determine the number of code stream segments according to the target number of transmission bits and the configured segment size value; or, determine the number of code stream segments according to the stripe height.
[0597] Exemplarily, when the decoding module deinterleaves the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target code stream to obtain the number of code stream segments corresponding to each stripe, it is specifically used to: based on the order of the X stripes in the horizontal direction of the same stripe row, parse one code stream segment corresponding to each stripe in sequence to the bit stream buffer corresponding to the stripe, and judge whether all the code stream segments have been parsed; if so, complete the deinterleaving of the X stripes to obtain all the code stream segments corresponding to each stripe; if not, return to perform the operation of sequentially parsing one code stream segment corresponding to each stripe to the bit stream buffer corresponding to the stripe based on the order of the X stripes in the horizontal direction of the same stripe row.
[0598] Exemplarily, when the decoding module decodes the X stripes based on the bitstream buffers corresponding to the X stripes in the horizontal direction of the same stripe row, it is specifically used to: when the bitstream buffers corresponding to the X stripes contain the codestream segments corresponding to the X stripes, start decoding the codestream segments corresponding to the X stripes. The codestream segments corresponding to the X stripes exist in the bitstream buffers corresponding to the X stripes, including: for each stripe, the bitstream buffer corresponding to the stripe contains T codestream segments corresponding to the stripe, T is greater than or equal to 1, and T is less than the number of codestream segments.
[0599] Based on the same application concept as the above method, an encoding device is also proposed in an embodiment of the present application. The encoding device is applied to an encoding end, and the encoding device includes: a division module, used to divide the image to be processed into X*Y strips, X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; a determination module, used to determine the number of code stream segments in each strip; an encoding module, used to encode X strips in the horizontal direction of the same strip row to obtain X bit stream buffers corresponding to the X strips; for each bit stream buffer, the bit stream buffer is divided into code stream segments of the number of code stream segments; wherein, among the code stream segments of the number of code stream segments, there are at least two sizes of code stream segments; the code stream segments corresponding to the X strips in the horizontal direction of the same strip row are interleaved to obtain a target code stream; and a sending module, used to send the target code stream to a decoding end.
[0600] Exemplarily, when determining the number of code stream segments in each stripe, the determination module is specifically used to: determine the target number of transmission bits according to the stripe width, the stripe height and the target number of bits per pixel, and determine the number of code stream segments according to the target number of transmission bits and the configured segment size value; or, determine the number of code stream segments according to the stripe height.
[0601] Exemplarily, when the encoding module interleaves the bitstream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target bitstream, it is specifically configured to: based on the order of the X stripes in the horizontal direction of the same stripe row, sequentially add a bitstream segment corresponding to each stripe to the current bitstream, and determine whether all the bitstream segments have been added to the current bitstream; if so, stop adding the bitstream segments and use the current bitstream as the target bitstream; if not, continue to add a bitstream segment corresponding to each stripe to the current bitstream, and return to perform the operation of determining whether all the bitstream segments have been added to the current bitstream.
[0602] Exemplarily, when the encoding module interleaves the code stream segments corresponding to X stripes in the horizontal direction of the same stripe row to obtain the target code stream, it is specifically used to: when the code stream segments corresponding to the X stripes have been obtained, start to interleave the code stream segments corresponding to the X stripes to obtain the target code stream; wherein the code stream segments corresponding to the X stripes have been obtained, including: for each stripe, S code stream segments corresponding to the stripe have been obtained, S is greater than or equal to 1, and S is less than the number of code stream segments.
[0603] Based on the same application concept as the above method, a camera device is also provided in an embodiment of the present application. The camera device may include an encoding end and / or a decoding end in any of the above embodiments.
[0604] Based on the same application concept as the above method, the embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by the processor, the encoding and decoding method disclosed in the above example of the present application can be implemented. Among them, 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, the machine-readable storage medium can be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state hard disk, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.
[0605] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a tablet computer, a wearable device or a combination of any of these devices.
[0606] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0607] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. The present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0608] The present application is described with reference to the flow chart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that the combination of each flow and / or box in the flow chart and / or block diagram and the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart or multiple flows and / or one box or multiple boxes of the block diagram. Moreover, these computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which realizes the function specified in one flow chart or multiple flows and / or one box or multiple boxes of the block diagram.
[0609] These computer program instructions may also be loaded onto a computer or other programmable data processing device, so that a series of operating steps are performed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes of the flowchart and / or one or more boxes of the block diagram. The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of the claims of the present application.
Claims
1. A decoding method, characterized in that: The method comprises: Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; wherein the number of strips X is calculated as follows: X=(ImageWidth+SliceWidth–1) / SliceWidth, and the number of strips Y is calculated as follows: Y=(ImageHeight+SliceHeight–1) / SliceHeight; wherein ImageWidth represents the image width of the image to be processed, the value of ImageWidth is not 0 and is an integer multiple of 16, SliceWidth represents the strip width, ImageHeight represents the image height of the image to be processed, the value of ImageHeight is not 0 and is an integer multiple of 2, and SliceHeight represents the strip height; Determine the number of code stream segments in each slice; Deinterleaving the bitstream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target bitstream to obtain the bitstream segments of the number of bitstream segments corresponding to each stripe; wherein, among the bitstream segments of the number of bitstream segments, there are at least two sizes of bitstream segments; The X stripes are decoded based on the bitstream buffers corresponding to the X stripes in the horizontal direction of the same stripe row; wherein the bitstream buffer corresponding to each stripe includes a codestream segment corresponding to the stripe.
2. The method according to claim 1, characterized in that: The determining the number of code stream segments in each slice includes: Determine a target number of transmission bits according to a stripe width, a stripe height, and a target number of bits per pixel, and determine the number of code stream segments according to the target number of transmission bits and a configured segment size value; Alternatively, the number of code stream segments is determined according to the slice height.
3. The method according to claim 1, characterized in that The deinterleaving of the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target code stream to obtain the code stream segments corresponding to each stripe includes: Based on the order of the X stripes in the horizontal direction of the same stripe row, parse a stream segment corresponding to each stripe in turn into a bit stream buffer corresponding to the stripe, and determine whether all the stream segments have been parsed; If not, the operation of returning to executing the order of the X stripes in the horizontal direction of the same stripe row and sequentially parsing a code stream segment corresponding to each stripe into the bit stream buffer corresponding to the stripe.
4. The method according to claim 1 or 3, characterized in that: The decoding of the X stripes based on the bit stream buffer corresponding to the X stripes in the horizontal direction of the same stripe row includes: When the bitstream segments corresponding to the X slices exist in the bitstream buffers corresponding to the X slices, decoding of the bitstream segments corresponding to the X slices begins.
5. The method according to claim 4, characterized in that The bitstream buffer corresponding to the X slices contains codestream segments corresponding to the X slices, including: for each slice, the bitstream buffer corresponding to the slice contains T codestream segments corresponding to the slice, T is greater than or equal to 1, and T is less than the number of codestream segments.
6. A coding method, characterized in that: The method comprises: Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; wherein the number of strips X is calculated as follows: X=(ImageWidth+SliceWidth–1) / SliceWidth, and the number of strips Y is calculated as follows: Y=(ImageHeight+SliceHeight–1) / SliceHeight; wherein ImageWidth represents the image width of the image to be processed, the value of ImageWidth is not 0 and is an integer multiple of 16, SliceWidth represents the strip width, ImageHeight represents the image height of the image to be processed, the value of ImageHeight is not 0 and is an integer multiple of 2, and SliceHeight represents the strip height; Determine the number of code stream segments in each slice; Encode X stripes in the horizontal direction of the same stripe row to obtain X bit stream buffers corresponding to the X stripes; For each bitstream buffer, the bitstream buffer is divided into the number of bitstream segments, wherein there are at least two sizes of bitstream segments in the number of bitstream segments; Interweave the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target code stream; The target code stream is sent to the decoding end.
7. The method according to claim 6, characterized in that The determining the number of code stream segments in each slice includes: Determine a target number of transmission bits according to a stripe width, a stripe height, and a target number of bits per pixel, and determine the number of code stream segments according to the target number of transmission bits and a configured segment size value; Alternatively, the number of code stream segments is determined according to the slice height.
8. The method according to claim 6, characterized in that The step of interleaving the bitstream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target bitstream includes: Based on the order of the X stripes in the horizontal direction of the same stripe row, add a stream segment corresponding to each stripe to the current stream in turn, and determine whether all the stream segments have been added to the current stream; If yes, stop adding stream segments and use the current stream as the target stream; If not, continue to add a code stream segment corresponding to each stripe to the current code stream, and return to execute the operation of determining whether all code stream segments have been added to the current code stream.
9. The method according to claim 6, characterized in that The step of interleaving the bitstream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target bitstream includes: When the code stream segments corresponding to the X stripes have been obtained, the code stream segments corresponding to the X stripes are interleaved to obtain a target code stream; wherein the code stream segments corresponding to the X stripes have been obtained, including: for each stripe, S code stream segments corresponding to the stripe have been obtained, S is greater than or equal to 1, and S is less than the number of the code stream segments.
10. A coding device, characterized in that: The encoding device comprises: a memory configured to store video data; An encoder configured to implement: Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; wherein the number of strips X is calculated as follows: X=(ImageWidth+SliceWidth–1) / SliceWidth, and the number of strips Y is calculated as follows: Y=(ImageHeight+SliceHeight–1) / SliceHeight; wherein ImageWidth represents the image width of the image to be processed, the value of ImageWidth is not 0 and is an integer multiple of 16, SliceWidth represents the strip width, ImageHeight represents the image height of the image to be processed, the value of ImageHeight is not 0 and is an integer multiple of 2, and SliceHeight represents the strip height; Determine the number of code stream segments in each slice; Encode X stripes in the horizontal direction of the same stripe row to obtain X bit stream buffers corresponding to the X stripes; For each bitstream buffer, the bitstream buffer is divided into the number of bitstream segments, wherein there are at least two sizes of bitstream segments in the number of bitstream segments; Interweave the code stream segments corresponding to the X stripes in the horizontal direction of the same stripe row to obtain the target code stream; The target code stream is sent to the decoding end.
11. A decoding device, characterized in that: The decoding device comprises: a memory configured to store video data; A decoder configured to implement: Divide the image to be processed into X*Y strips, where X is the number of strips in the horizontal direction, Y is the number of strips in the vertical direction, X is a positive integer greater than 1, and Y is a positive integer greater than or equal to 1; wherein the number of strips X is calculated as follows: X=(ImageWidth+SliceWidth–1) / SliceWidth, and the number of strips Y is calculated as follows: Y=(ImageHeight+SliceHeight–1) / SliceHeight; wherein ImageWidth represents the image width of the image to be processed, the value of ImageWidth is not 0 and is an integer multiple of 16, SliceWidth represents the strip width, ImageHeight represents the image height of the image to be processed, the value of ImageHeight is not 0 and is an integer multiple of 2, and SliceHeight represents the strip height; Determine the number of code stream segments in each slice; Deinterleaving the bitstream segments corresponding to the X stripes in the horizontal direction of the same stripe row in the target bitstream to obtain the bitstream segments of the number of bitstream segments corresponding to each stripe; wherein, among the bitstream segments of the number of bitstream segments, there are at least two sizes of bitstream segments; The X stripes are decoded based on the bitstream buffers corresponding to the X stripes in the horizontal direction of the same stripe row; wherein the bitstream buffer corresponding to each stripe includes a codestream segment corresponding to the stripe.
12. A coding end device, characterized in that: include: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; The processor is used to execute machine executable instructions to implement the method steps described in any one of claims 6-9.
13. A decoding end device, characterized in that: include: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; The processor is used to execute machine executable instructions to implement the method steps described in any one of claims 1-5.
