| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkMSAN.h" | 9 #include "SkMSAN.h" |
| 10 #include "SkJpegCodec.h" | 10 #include "SkJpegCodec.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 // The definition of samp_factor is kind of the opposite of what SkCodec | 561 // The definition of samp_factor is kind of the opposite of what SkCodec |
| 562 // thinks of as a sampling factor. samp_factor is essentially a | 562 // thinks of as a sampling factor. samp_factor is essentially a |
| 563 // multiplier, and the larger the samp_factor is, the more samples that | 563 // multiplier, and the larger the samp_factor is, the more samples that |
| 564 // there will be. Ex: | 564 // there will be. Ex: |
| 565 // U_plane_width = image_width * (U_h_samp_factor / max_h_samp_factor) | 565 // U_plane_width = image_width * (U_h_samp_factor / max_h_samp_factor) |
| 566 // | 566 // |
| 567 // Supporting cases where the samp_factors for U or V were larger than | 567 // Supporting cases where the samp_factors for U or V were larger than |
| 568 // that of Y would be an extremely difficult change, given that clients | 568 // that of Y would be an extremely difficult change, given that clients |
| 569 // allocate memory as if the size of the Y plane is always the size of the | 569 // allocate memory as if the size of the Y plane is always the size of the |
| 570 // image. However, this case is very, very rare. | 570 // image. However, this case is very, very rare. |
| 571 if (!(1 == dinfo->comp_info[1].h_samp_factor) && | 571 if ((1 != dinfo->comp_info[1].h_samp_factor) || |
| 572 (1 == dinfo->comp_info[1].v_samp_factor) && | 572 (1 != dinfo->comp_info[1].v_samp_factor) || |
| 573 (1 == dinfo->comp_info[2].h_samp_factor) && | 573 (1 != dinfo->comp_info[2].h_samp_factor) || |
| 574 (1 == dinfo->comp_info[2].v_samp_factor)) { | 574 (1 != dinfo->comp_info[2].v_samp_factor)) |
| 575 { |
| 575 return false; | 576 return false; |
| 576 } | 577 } |
| 577 | 578 |
| 578 // Support all common cases of Y samp_factors. | 579 // Support all common cases of Y samp_factors. |
| 579 // TODO (msarett): As mentioned above, it would be possible to support | 580 // TODO (msarett): As mentioned above, it would be possible to support |
| 580 // more combinations of samp_factors. The issues are: | 581 // more combinations of samp_factors. The issues are: |
| 581 // (1) Are there actually any images that are not covered | 582 // (1) Are there actually any images that are not covered |
| 582 // by these cases? | 583 // by these cases? |
| 583 // (2) How much complexity would be added to the | 584 // (2) How much complexity would be added to the |
| 584 // implementation in order to support these rare | 585 // implementation in order to support these rare |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 | 725 |
| 725 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 726 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
| 726 if (linesRead < remainingRows) { | 727 if (linesRead < remainingRows) { |
| 727 // FIXME: Handle incomplete YUV decodes without signalling an error. | 728 // FIXME: Handle incomplete YUV decodes without signalling an error. |
| 728 return kInvalidInput; | 729 return kInvalidInput; |
| 729 } | 730 } |
| 730 } | 731 } |
| 731 | 732 |
| 732 return kSuccess; | 733 return kSuccess; |
| 733 } | 734 } |
| OLD | NEW |