Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Issue 1240143002: Add the ability to decode a subset to SkCodec. (Closed)

Created:
5 years, 5 months ago by scroggo_chromium
Modified:
5 years, 5 months ago
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Add the ability to decode a subset to SkCodec This allows codecs that support subsets natively (i.e. WEBP) to do so. Add a field on SkCodec::Options representing the subset. Add a method on SkCodec to find a valid subset which approximately matches a desired subset. Implement subset decodes in SkWebpCodec. Add a test in DM for decoding subsets. Notice that we only start on even boundaries. This is due to the way libwebp's API works. SkWEBPImageDecoder does not take this into account, which results in visual artifacts. FIXME: Subsets with scaling are not pixel identical, but close. (This may be fine, though - they are not perceptually different. We'll just need to mark another set of images in gold as valid, once https://skbug.com/4038 is fixed, so we can tests scaled webp without generating new images on each run.) Committed: https://skia.googlesource.com/skia/+/b636b45971bc5e64e3b103169577cbc874bc064d

Patch Set 1 #

Patch Set 2 : Fix line endings #

Total comments: 14

Patch Set 3 : Respond to comments in patch set 2 #

Patch Set 4 : Add getValidSubset plus tests #

Patch Set 5 : Update comment #

Total comments: 9

Patch Set 6 : Change fSubset to a pointer. #

Patch Set 7 : Only allow subsets contained fully inside image. #

Patch Set 8 : Fix test. #

Total comments: 2

Patch Set 9 : Remove unnecessary assert. #

Patch Set 10 : Do not treat kInvalidConversion as a failure. #

Patch Set 11 : Fix some conversion warning/errors. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+284 lines, -36 lines) Patch
M dm/DM.cpp View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M dm/DMSrcSink.h View 1 chunk +1 line, -0 lines 0 comments Download
M dm/DMSrcSink.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +77 lines, -0 lines 0 comments Download
M include/codec/SkCodec.h View 1 2 3 4 5 6 3 chunks +36 lines, -1 line 0 comments Download
M src/codec/SkCodec_libbmp.cpp View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M src/codec/SkCodec_libgif.cpp View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M src/codec/SkCodec_libico.cpp View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M src/codec/SkCodec_libpng.cpp View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M src/codec/SkCodec_wbmp.cpp View 1 2 3 4 5 2 chunks +5 lines, -1 line 0 comments Download
M src/codec/SkJpegCodec.cpp View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M src/codec/SkWebpCodec.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M src/codec/SkWebpCodec.cpp View 1 2 3 4 5 6 2 chunks +59 lines, -5 lines 0 comments Download
M tests/CodexTest.cpp View 1 2 3 4 5 6 7 8 3 chunks +78 lines, -29 lines 0 comments Download

Messages

Total messages: 33 (10 generated)
scroggo
5 years, 5 months ago (2015-07-17 20:03:56 UTC) #2
emmaleer
https://codereview.chromium.org/1240143002/diff/20001/dm/DM.cpp File dm/DM.cpp (right): https://codereview.chromium.org/1240143002/diff/20001/dm/DM.cpp#newcode222 dm/DM.cpp:222: case kGray_8_SkColorType: Should run the Codec Subset test for ...
5 years, 5 months ago (2015-07-17 22:31:05 UTC) #3
scroggo
https://codereview.chromium.org/1240143002/diff/20001/dm/DM.cpp File dm/DM.cpp (right): https://codereview.chromium.org/1240143002/diff/20001/dm/DM.cpp#newcode222 dm/DM.cpp:222: case kGray_8_SkColorType: On 2015/07/17 22:31:05, emmaleer wrote: > Should ...
5 years, 5 months ago (2015-07-20 14:25:42 UTC) #4
djsollen
https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h File dm/DMSrcSink.h (right): https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h#newcode102 dm/DMSrcSink.h:102: kSubset_Mode, // For codecs that support subsets directly. Is ...
5 years, 5 months ago (2015-07-20 14:29:24 UTC) #5
scroggo
https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h File dm/DMSrcSink.h (right): https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h#newcode102 dm/DMSrcSink.h:102: kSubset_Mode, // For codecs that support subsets directly. On ...
5 years, 5 months ago (2015-07-20 14:47:02 UTC) #6
djsollen
https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h File dm/DMSrcSink.h (right): https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h#newcode102 dm/DMSrcSink.h:102: kSubset_Mode, // For codecs that support subsets directly. On ...
5 years, 5 months ago (2015-07-20 16:54:34 UTC) #7
scroggo
https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h File dm/DMSrcSink.h (right): https://codereview.chromium.org/1240143002/diff/20001/dm/DMSrcSink.h#newcode102 dm/DMSrcSink.h:102: kSubset_Mode, // For codecs that support subsets directly. On ...
5 years, 5 months ago (2015-07-20 18:55:54 UTC) #8
djsollen
api lgtm
5 years, 5 months ago (2015-07-20 19:23:28 UTC) #9
scroggo
Derek has reviewed the API, can I get a review of the code? Matt or ...
5 years, 5 months ago (2015-07-21 14:53:45 UTC) #10
msarett
lgtm plus comments https://codereview.chromium.org/1240143002/diff/80001/include/codec/SkCodec.h File include/codec/SkCodec.h (right): https://codereview.chromium.org/1240143002/diff/80001/include/codec/SkCodec.h#newcode164 include/codec/SkCodec.h:164: SkIRect fSubset; On 2015/07/21 14:53:45, scroggo ...
5 years, 5 months ago (2015-07-21 15:19:37 UTC) #11
emmaleer
https://codereview.chromium.org/1240143002/diff/80001/include/codec/SkCodec.h File include/codec/SkCodec.h (right): https://codereview.chromium.org/1240143002/diff/80001/include/codec/SkCodec.h#newcode164 include/codec/SkCodec.h:164: SkIRect fSubset; On 2015/07/21 14:53:45, scroggo wrote: > This ...
5 years, 5 months ago (2015-07-21 15:24:55 UTC) #12
scroggo
https://codereview.chromium.org/1240143002/diff/80001/src/codec/SkWebpCodec.cpp File src/codec/SkWebpCodec.cpp (right): https://codereview.chromium.org/1240143002/diff/80001/src/codec/SkWebpCodec.cpp#newcode177 src/codec/SkWebpCodec.cpp:177: if (!bounds.intersect(options.fSubset)) { On 2015/07/21 15:19:37, msarett wrote: > ...
5 years, 5 months ago (2015-07-21 16:48:56 UTC) #13
emmaleer
lgtm https://codereview.chromium.org/1240143002/diff/140001/src/codec/SkJpegCodec.cpp File src/codec/SkJpegCodec.cpp (right): https://codereview.chromium.org/1240143002/diff/140001/src/codec/SkJpegCodec.cpp#newcode311 src/codec/SkJpegCodec.cpp:311: if (options.fSubset) { On 2015/07/21 16:48:56, scroggo wrote: ...
5 years, 5 months ago (2015-07-21 18:26:25 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1240143002/160001
5 years, 5 months ago (2015-07-22 13:41:13 UTC) #17
commit-bot: I haz the power
Try jobs failed on following builders: Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared-Trybot on client.skia (JOB_FAILED, http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared-Trybot/builds/2099)
5 years, 5 months ago (2015-07-22 13:43:36 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1240143002/180001
5 years, 5 months ago (2015-07-22 13:50:54 UTC) #22
commit-bot: I haz the power
Try jobs failed on following builders: Build-Win-MSVC-x86-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86-Debug-Trybot/builds/2162)
5 years, 5 months ago (2015-07-22 13:54:25 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1240143002/200001
5 years, 5 months ago (2015-07-22 14:08:48 UTC) #27
commit-bot: I haz the power
Committed patchset #11 (id:200001) as https://skia.googlesource.com/skia/+/b636b45971bc5e64e3b103169577cbc874bc064d
5 years, 5 months ago (2015-07-22 14:16:23 UTC) #28
reed2
This api is a little unexpected to me. What motivates it? - some codecs would ...
5 years, 5 months ago (2015-07-22 16:04:59 UTC) #30
scroggo
On 2015/07/22 16:04:59, reed2 wrote: > This api is a little unexpected to me. > ...
5 years, 5 months ago (2015-07-22 17:55:58 UTC) #31
reed2
If we possibly can, I'd vote to push webp (the only codec that is forcing ...
5 years, 5 months ago (2015-07-23 10:03:59 UTC) #32
scroggo
5 years, 5 months ago (2015-07-23 14:26:49 UTC) #33
Message was sent while issue was closed.
On 2015/07/23 10:03:59, reed2 wrote:
> If we possibly can, I'd vote to push webp (the only codec that is forcing the
> subset to be larger?)

(Yes - webp is the only codec that supports subsets natively.)

> to perform the trim inside, so the caller doesn't have to
> deal with this complication, or we perform it in our wrapper code.

I can ask the webp team why they have this restriction, and see if there's any
way around it. That said, I do not see a clear way to do a trim that does not
involve a copy (in SkCodec or in libwebp), given the current APIs [1], which
seems like it would be unnecessarily expensive.

To me, this API feels analogous to getValidDimensions, which lets the client
know what the codec can do efficiently.

[1] An API like SkImageDecoder's would allow hiding this from the caller - since
SkImageDecoder handles deciding how much memory to allocate and uses an
SkBitmap, it could allocate the extra memory and then use extractSubset to
return a bitmap that represents the subset the client actually wanted. On the
other hand, that uses a little bit more memory, and SkCodec's API allows the
client to decide whether to take the memory or speed hit. libwebp's API is
similar to SkCodec, in that the client provides a pointer to memory into which
it writes directly.

Powered by Google App Engine
This is Rietveld 408576698