US 7567722 B2 Abstract A dynamically scaled file encoding method and apparatus are disclosed. A file encoding system using JPEG encoding can be configured to produce relatively constant compressed file sizes irrespective of the initial file size and file contents. The system retrieves an initial file or image that is to be compressed and determines a target bit rate corresponding to the compressed file. The target bit rate is used to determine an initial scaling factor. The initial file is encoded using a JPEG encoder having coefficients scaled by the initial scaling factor. The resultant bit rate can be adjusted in a second loop if greater than the desired bit rate. To adjust the bit rate, a recomputed scaling factor is determined from the resultant bit rate. The initial file is then encoded with coefficients scaled by the recomputed scaling factor to achieve a bit rate that is within the target bit rate.
Claims(33) 1. A method of scaling a file to produce an encoded file having a file size less than a file size constraint, the method comprising:
determining a target bit rate;
determining an initial scale factor;
at an encoder, encoding a source file using quantization parameters scaled with the initial scale factor to produce an initial encoded file;
determining a revised bit rate, wherein determining the revised bit rate comprises determining an AC bit rate of the initial encoded file;
determining a scaling factor; and
re-encoding the source file using quantization parameters scaled with the scaling factor to produce the encoded file.
2. The method of
3. The method of
4. The method of
estimating a number of DC bits in the source file; and
determining a difference of the number of DC bits from a target file size to produce a target AC bit estimate.
5. The method of
6. The method of
7. The method of
8. The method of
computing a correction factor based in part on the revised bit rate; and
determining the scaling factor as the product of the correction factor and the initial scale factor.
9. The method of
10. The method of
capturing an image file with a camera; and
storing the image file in memory as the source file.
11. The method of
12. An encoding system, the system comprising:
an encoder configured to encode a source file using quantization parameters scaled by a scaling factor to produce an encoded file having a target file size less than a file size of the source file; and
a scaling module configured to determine the scaling factor used by the encoder based in part on the target file size and the file size of the source file, wherein the scaling module is configured to generate an initial scale factor based in part on the file size of the source file;
wherein the encoder is configured to encode the source file using quantization parameters scaled by the initial scale factor to produce an initial encoded file;
wherein the scaling module determines the scaling factor based in part on a file size of the initial encoded file; and
wherein the scaling module is configured to determine a correction factor based on the file size of the initial encoded file and determines the scaling factor as a product of the initial scale factor and the correction factor.
13. The system of
14. The system of
15. The system of
16. The system of
17. The system of
18. The system of
19. The system of
20. The system of
21. The system of
22. The system of
23. The system of
24. The system of
memory coupled to the encoder and configured to store the source file; and
a camera configured to capture an image file and store it in the memory as the source file.
25. The system of
26. A computer readable medium storing computer executable code, comprising:
code executable by a computer to determine a target bit rate;
code executable by the computer to determine an initial scale factor;
code executable by the computer to encode a source file using quantization parameters scaled with the initial scale factor to produce an initial encoded file;
code executable by the computer to determine a revised bit rate by determining an AC bit rate of the initial encoded file;
code executable by a computer to determine a scaling factor; and
code executable by a computer to re-encode the source file using quantization parameters scaled with the scaling factor to produce the encoded file.
27. A method of scaling a file to produce an encoded file having a file size less than a file size constraint, the method comprising:
estimating a number of DC bits in an image file;
subtracting the number of DC bits from a target file size to produce an AC bit estimate;
determining a target rate as the value of the AC bit estimate divided by a number of pixels in the image file;
determining an initial scale factor based in part on the target rate;
at an encoder, encoding the image file using quantization parameters scaled by the initial scale factor to produce the encoded file;
determining a bit rate based in part on a size of the encoded file;
determining a correction factor based on the bit rate;
determining a recomputed scaling factor as the product of the correction factor and the initial scale factor; and
encoding the image file with the encoder using quantization parameters scaled by the recomputed scaling factor.
28. The method of
29. A method of scaling a file to produce an encoded file having a file size less than a file size constraint, the method comprising:
determining a target bit rate;
determining an initial scale factor;
at an encoder, encoding a source file using quantization parameters scaled with the initial scale factor to produce an initial encoded file;
determining a revised bit rate;
determining a scaling factor; wherein determining the scaling factor comprises computing a correction factor based in part on the revised bit rate; and
determining the scaling factor as the product of the correction factor and the initial scale factor; and
re-encoding the source file using quantization parameters scaled with the scaling factor to produce the encoded file.
30. An encoding system, the system comprising:
a JPEG encoder configured to encode a captured image file to produce an encoded image file, the JPEG encoder encoding at least AC bits of the captured image file using quantization parameters scaled by a scaling factor; and
a scaling module coupled to the JPEG encoder and configured to determine an initial scale factor based in part on a target file size and a number of pixels in the captured image file, and wherein the JPEG encoder is configured to encode the AC bits of the captured image file using quantization parameters scaled by the initial scale factor to produce an initial encoded file, wherein the scaling module determines the scaling factor based in part on a file size of the initial encoded file, and wherein the scaling module is configured to determine a correction factor based on the file size of the initial encoded file and configured to determine the scaling factor as a product of the initial scale factor and the correction factor.
31. The system of
memory coupled to the encoder and configured to store the captured image file; and
a camera configured to generate the captured image file and store the captured image file in the memory.
32. The system of
33. The system of
Description The disclosure relates to the field of electronic file compression. More particularly, the disclosure relates to dynamic determination of electronic file compression in a communication system. Wireless communication systems have evolved from systems dedicated to carrying voice communications, to third generation (3G) systems that are configured to support high data rates. As such, wireless communication systems are increasingly being used for distribution of data and information. The data and information distributed across wireless communication systems are often contained within large data files. Wireless communication systems, such as cellular telephone systems, have evolved to handle the large amounts of data being transmitted over the system. Wireless communication devices are often configured with the ability to send or receive data files. The data files may include ring tone files and picture files. However, even in 3G systems, efficient transmission of the data and information over the wireless system is a priority because wireless communication systems are often constrained to operate within a fixed bandwidth or frequency spectrum allocated by governing bodies. For example, with the rapid growing 3G wireless services, digital camera phones become increasingly popular in our daily life. People can exchange digital images instantly across the advanced 3G wireless networks. However, due to the tremendous data amount of each image, wireless carriers typically impose a file size limit to each compressed image, for example 100 KB, for efficient usage of the precious wireless bandwidth. A digital camera can easily capture an image that exceeds the constraints imposed by a service provider. Therefore, before a handset sends a picture over the wireless networks, it may have to ensure the picture file size is not over the limit enforced by the wireless carriers. A device, such as a wireless handset, may incorporate file compression in order to help conform to the file size limitations imposed by system providers. However, file compression and the resultant compression ratio can depend on the contents of the file. Two files of the exact same initial size may produce different compressed file sizes, due to the sensitivity of an encoding algorithm to file contents. Therefore, it is desirable to have a file encoding technique that is able to consistently produce a compressed file size and that is relatively insensitive to file contents or original file size. A dynamically scaled file encoding method and apparatus are disclosed. A file encoding system using Joint Photographic Experts Group (JPEG) encoding can be configured to produce relatively constant compressed file sizes irrespective of the initial file size and file contents. The system retrieves an initial file or image that is to be compressed and determines a target bit rate corresponding to the target compressed file size. The target bit rate is used to determine an initial scaling factor. The initial file is encoded using a JPEG encoder having coefficients scaled by the initial scaling factor. If the resultant bit rate is above or far below the target bit rate, a new scaling factor is derived from the resultant bit rate. The initial file is then encoded with coefficients scaled by the new scaling factor to achieve a bit rate that is within the target bit rate. One aspect of the method and apparatus includes an encoding system. The system includes an encoder configured to encode a source file using quantization parameters scaled by a scaling factor to produce an encoded file having a target file size less than a file size of the source file, and a scaling module configured determine the scaling factor used by the encoder based in part on the target file size and the file size of the source file. Another aspect is directed towards an encoding system that includes a JPEG encoder configured to encode a captured image file to produce an encoded image file, the JPEG encoder encoding at least AC bits of the captured image file using quantization parameters scaled by a scaling factor, and a scaling module coupled to the JPEG encoder and configured to determine an initial scale factor based in part on a target file size and a number of pixels in the captured image file, and wherein the JPEG encoder is configured to encode the AC bits of the captured image file using quantization parameters scaled by the initial scale factor to produce an initial encoded file, and wherein the scaling module determines the scaling factor based in part on a file size of the initial encoded file. Another aspect is further directed towards a method of scaling a file to produce an encoded file having a file size less than a file size constraint, including determining a target bit rate, determining an initial scale factor, encoding a source file using quantization parameters scaled with the initial scale factor to produce an initial encoded file, determining a revised bit rate, determining a scaling factor, and re-encoding the source file using quantization parameters scaled with the scaling factor to produce the encoded file. Another aspect is directed towards an encoding system that includes an encoder configured to encode a source file using quantization parameters scaled by a scaling factor to produce an encoded file having a target file size less than a file size of the source file, and a scaling module configured determine the scaling factor used by the encoder based in part on a rate distortion curve determined from an initial encoded file generated by the encoder. Another aspect is directed towards a method of scaling a file to produce an encoded file having a file size less than a file size constraint, including encoding a source file using an initial quantization table to produce an initial encoded file, determining a rate distortion curve based on the initial encoded file, determining a scaling factor based in part on the rate distortion curve, determining a scaled quantization table by scaling the initial quantization table by the scaling factor, and re-encoding the source file using the scaled quantization table to generate the encoded file. The features, objects, and advantages of embodiments of the disclosure will become more apparent from the detailed description set forth below when taken in conjunction with the drawings, in which like elements bear like reference numerals. A device within a wireless communication system may incorporate an apparatus and method of dynamically scaling a file size by scaling aspect of the encoding of the file. A file such as an image captured by a camera can have a size that is determined, in part, by the number of pixels used to define the picture. The image pixel width and pixel height can characterize a spatial dimension of the image. Based on a spatial dimension of the image, the file size can also be expressed as bit rate in terms of bits/pixel. The file size control can be viewed as the same problem as bit rate control. Since JPEG compression is one of the most popular image compression methods used in to compress source images, this disclosure focuses on the JPEG rate control problem. In the JPEG standard, the encoding bit rate (bits/pixel) is controlled by quantization parameters. The quantization parameters are provided in matrices used in a Discrete Cosine Transform (DCT) process performed in an encoder. Typically, the larger the quantization parameters, the lower bit rate in a resultant file. Based on extensive psycho-visual thresholding experiments, the JPEG standard recommends two standard quantization tables denoted by Q Although these tables may not be ideal for any particular application, they have been used for general 8-bit per sample image compression with good results. It is important to note that if the values in the tables are divided by 2, the reconstructed JPEG image is usually nearly indistinguishable from the original image.
In one embodiment, JPEG encoding of image files can implement optimization of the quantization parameters on an image by image basis. To encode a particular image at a given bit rate, the quantization tables can be redesigned to match the statistical properties of the given image so that the best image quality can be obtained for the given target bit rate. However, the high computational complexity of the optimization process may prohibits it from being a. practical solution, especially for those applications with limited computing horsepower and low-delay requirement. In an alternative embodiment, a device can initialize a JPEG encoder with the recommended quantization tables and can derive new quantization tables by scaling the quantization tables Q Therefore, the problem in the second embodiment can be characterized a one of estimating the scaling factor S for a given bit rate so that the encoding bit rate of the JPEG image compressed with the new quantization tables Q The system includes one or more fixed elements that can be in communication with a mobile station The mobile station The base station A communication device A user terminal The user terminal An encoder The user terminal The wireless communication system The user terminal The scaling module If the scaling module The encoder Although the JPEG encoder and scaling module are depicted as distinct modules, some or all of the functions performed by the modules may be performed by the processor In a JPEG file, the bit stream mainly comprises the following components: JPEG header bits, including Huffman tables and quantization tables as well as other optional headers specified in JPEG standard, DC bits that encode DC components, AC bits that encode AC components, and End of Block bits. The number of JPEG header bits and End of Block bits is usually fixed and known before encoding. The number of DC bits is typically a small portion of the JPEG bit stream and does not change significantly across different scaling factors applied to the quantization parameters. In one embodiment the DC quantization parameters are not scaled, and the number of DC bits does not change based on a scaling factor. In other embodiments, the DC quantization parameters can be scaled to provide a slight improvement in encoded file size. The AC bits represent the major part of the JPEG bit stream and the number of AC bits can change dramatically across different scaling factors. Hence, understanding the relationship between the number of AC bits and the scaling factor establishes the foundation for JPEG bit rate control. In the following discussion, ‘R’ represents the number of AC bits per pixel. In order to characterize the effects of the scaling factor (S) on JPEG encoding of captured images, a number of images with different characteristics were created. The various images were encoded with different scaling factors. The R-S curves for each of the sample images was plotted and compared. It was observed that the R-S curve changed dynamically from image to image. However, for S=0, the scaled quantization values in Q where A and B are constant coefficients, R is AC bits per pixel, and S is the scaling factor. The polynomial model of R-S curves is used to compute a generic R-S model by using the median values of all A and B values in all test images. As a result, the following values were obtained: A=0.6869, B=1.5825. The derived generic R-S model is:
However, the R-S curve can change dramatically from image to image. Thus, the generic R-S model may provide poor estimation accuracy when used to estimate the scaling factor S to apply to any particular image. The generic R-S model can be adapted in a two pass process to improve the accuracy of the scaling factor (S) estimate for a particular image. The scaling module and encoder implementing the method The method The scaling module can then determine a target bit rate in block The scaling module then determines a scaling factor in block After determining the initial scaling factor, the scaling module can provide the scaling factor to the encoder, or can generate one or more scaled quantization tables using the scaling factor. The encoder, in block The scaling module, at decision block Returning to decision block The scaling module can adjust the scaling factor using knowledge of the initial scaled bit rate. The captured image file can be encoded with the revised scaling factor to produce an encoded image file that is less than or equal to the target bit rate. In one embodiment, the scaling module adapts the generic scaling factor model to the particular image by using the initial scaling factor and the resultant bit rate obtained in the initial pass through the encoder. The adaptation process is: -
- If the resultant bit rate of pass one encoding R
_{1 }is greater then the target bit rate R_{T}, then revise the bit rate R_{1}=R_{1}+(R_{1}−R_{T})/4. - A correction factor (K) is then determined as K=S
_{1}/(0.6869R_{1}^{2}+1.5825R_{1}), where S_{1 }is the initial scaling factor given by the scaling module**184**. - The new scaling factor model for this particular image is S=K(0.6869R
^{2}+1.5825R), where S is the scaling factor and R is the AC bits per pixel.
- If the resultant bit rate of pass one encoding R
The scaling module can then proceed to block The encoder proceeds to block -
- F=JPEG file size in terms of bits
- H=number of JPEG header bits
- EOB=number of End of Block bits
- DC=number of DC bits
- AC=number of AC bits.
- W=image width in terms of pixels
- HT=image height in terms of pixels
Initially, in block As discussed earlier, H and EOB are constants and known before encoding. For example, if the default Huffman tables in JPEG standard are used in JPEG encoding, then EOB=4 for each 8×8 luminance block, and EOB=2 for each 8×8 chrominance block. DC is a small part of the JPEG bit stream but may be unknown before encoding. Thus, the number of DC bits may be estimated. The number of DC bits can be estimated by estimating four DC bits used to encode the DC component per 8×8 block. Then, the total number of DC bits in the file can be estimated as 4*W*HT*C/(8*8) with C=1.5 for YCbCr420 format and C=2 for YCbCr422 format. Once the target bit rate is determined, the scaling module proceeds to block After determining the scaling factor, the encoder, at block The scaling module, in block Once the actual rate is determined, the scaling module can proceed to block At block As discussed above, if the values in the standard quantization tables Q The encoder, at block In simulations of the method The simulation results were also examined for the control errors of the algorithm for some of the tested images. The analysis revealed that the algorithm can over shoot the target bit rate by 10% in some cases. To overcome this problem, the system or method can lower the target bit rate by approximately 10 percent before running the algorithm to minimize the probability of exceeding a predetermined file size limit. Other embodiments where the JPEG encoder returns the number of DC bits DC The flowcharts of In other embodiments, the intermediate results generated by the encoder The method The user terminal, in particular the scaling module, can be configured to determine a number of overhead bits, a number of zero DCT outputs from the encoder, and a fractional number of non-zero DCT outputs from the encoder. The scaling module can re-determine the statistics for quantization parameters scaled by a predetermined number of scaling factors. The scaling factors can be, for example, linearly spaced. The scaling module can then determine a rate distortion curve from the statistics of the initial encoding. The scaling module can determine a scaling factor by interpolating between statistics corresponding to the scaled quantization parameters. The scaling module scales the quantization parameters with the scaling factor. The encoder re-encodes the captured image file with the scaled quantization parameters. The resultant encoded file is typically less than the target file size. If not, the scaling module can slightly tweek the quantization parameters and the encoder can re-encode the captured image file. The scaling module can continue to tweek the quantization parameters and the encoder can re-encode the captured image file until the encoded file size is less than the target file size. The method The user terminal, at decision block If the file size is not constrained or otherwise specified, the user terminal proceeds to block Returning to decision block Therefore, if the user terminal determines that the bit rate is less than a minimum bit rate, the user terminal proceeds to block Returning to decision block At block The user terminal proceeds to decision block Returning to decision block The process of determining the scaling factor is detailed in the flowchart of From the statistics the user terminal can determine a rate distortion curve based on the statistics from the initial encoded file, including the fractional non-zero value and a number of AC bits in the encoded file. From the rate distortion curve, the user terminal can determine a target fractional non-zero value using the rate distortion curve and a target number of AC bits. The user terminal can then determine a scaling factor from the target fractional non-zero value. After determining the scaling factor, the user terminal proceeds to block After encoding the image file to produce an encoded file, the user terminal proceeds to decision block However, the encoded file may not meet the file size constraints. The size of the encoded file is likely less than the file size constraint. If not, the encoded file size is typically only slightly larger than the file size constraint. In those situations, the user terminal proceeds from decision block Although, the user terminal may implement any general technique to tweek the scaled quantization tables, the change needed to bring the encoded file size within the file size constraint is typically minor. In one embodiment, the user terminal can tweek the scaled quantization tables by adding a fixed amount to each of the parameters in the scaled quantization tables. For example, the user terminal can tweek the quantization parameters by adding 6, 8, 10, 15, or some other value to each of the quantization parameters of the scaled quantization tables. In another embodiment, the user terminal can tweek the scaled quantization tables by multiplying by an additional scale factor that may, for example, increase the parameter values by an additional 2, 5, 10, or 15 percent, or some other value. After tweeking the scaled quantization tables, the user terminal returns to block The scaling module proceeds to block The scaling module can determine the number of non-zero DCT outputs for a predetermined number of scaling factors applied to the quantization tables. For example, the scaling module may determine the number of non-zero DCT outputs after scaling the initial quantization table by a factor of 2, 3, 4, 5, and 6, or some other scaling factor. The scaling module can determine the total number of non-zero DCT outputs for scaled quantization table values or may determine a change in the number of non-zeros when scaling the quantization tables. After determining the number of non-zero DCT outputs for various scaling factors, the scaling module proceeds to block The value of TargetNbits is an input to the method and nbits_overhead represents the previously determined number of overhead bits. The scaling module can separately determine a target number of AC bits for the chrominance and luminance, and can take into account that the target number of bits is a target sum of luminance and chrominance bits. After determining the target number of bits, the scaling module proceeds to block The slope (κ) can be determined using the statistics gathered from the initial encoded file and equals the number of AC bits in the initial encoded image divided by the fractional number of non-zero value of DCT outputs. Thus, the slope can be determined by the formula:
The scaling module proceeds to block After determining the target fractional non-zero value, based at least in part on the rate distortion curve, the scaling module proceeds to block As shown in After determining the scaling factor, the scaling factor applies the scaling factor to the default quantization tables in block Apparatus, systems, and methods for dynamically scaling file encoding has been disclosed. The methods, systems, and apparatus can use a two pass encoding process whereby a target bit rate and associated target encoded file size can be achieved from an initial file. The initial unencoded file is encoded using a quantization parameters scaled by a scaling factor determined from a scaling factor model. The resultant encoded file can be examined for conformance with a predetermined encoded file size constraint. The scaling factor can be recomputed for those encoded files not initially conforming with the predetermined file size constraint. A scaling module can determine a corrected bit rate and a correction factor to be applied to the initial scaling factor to produce a recomputed scaling factor. The original file can then be re-encoded using the quantization factors scaled by the recomputed scaling factor to produce an encoded file that conforms to the predetermined file size constraint. The above description of the disclosed embodiments is provided to enable any person of ordinary skill in the art to make or use the disclosure. Various modifications to these embodiments will be readily apparent to those of ordinary skill in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein. Patent Citations
Non-Patent Citations
Referenced by
Classifications
Legal Events
Rotate |