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

Side by Side Diff: media/filters/vpx_video_decoder_fuzzertest.cc

Issue 2324843004: Generate more valid configurations in media_vpx_video_decoder_fuzzer. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <random> 8 #include <random>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 26 matching lines...) Expand all
37 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 37 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
38 std::mt19937_64 rng; 38 std::mt19937_64 rng;
39 39
40 { // Seed rng from data. 40 { // Seed rng from data.
41 std::string str = std::string(reinterpret_cast<const char*>(data), size); 41 std::string str = std::string(reinterpret_cast<const char*>(data), size);
42 std::size_t data_hash = std::hash<std::string>()(str); 42 std::size_t data_hash = std::hash<std::string>()(str);
43 rng.seed(data_hash); 43 rng.seed(data_hash);
44 } 44 }
45 45
46 // Compute randomized constants. Put all rng() usages here. 46 // Compute randomized constants. Put all rng() usages here.
47 auto codec = static_cast<VideoCodec>(rng() % kVideoCodecMax); 47 // Use only values that pass DCHECK in VpxVideoDecoder::ConfigureDecoder().
48 VideoCodec codec;
49 VideoPixelFormat pixel_format;
50 if (rng() & 1) {
51 codec = kCodecVP8;
52 if (rng() & 1) {
53 // PIXEL_FORMAT_YV12 disabled if !defined(DISABLE_FFMPEG_VIDEO_DECODERS).
jrummell 2016/09/09 17:33:00 I wouldn't worry about this case. DISABLE_FFMPEG_V
mmoroz 2016/09/15 17:56:02 Hmmm, it quickly crashes on Linux if I use PIXEL_F
54 pixel_format = PIXEL_FORMAT_YV12A;
55 } else {
56 pixel_format = PIXEL_FORMAT_YV12A;
jrummell 2016/09/09 17:33:00 This is the same format. Did you mean YV12 for one
mmoroz 2016/09/15 17:56:01 I left it here to discuss the point we've discusse
57 }
58 } else {
59 codec = kCodecVP9;
60 switch (rng() % 3) {
61 case 0:
62 pixel_format = PIXEL_FORMAT_YV12;
jrummell 2016/09/09 17:33:00 Since this is a common format, I would make this c
mmoroz 2016/09/15 17:56:02 It doesn't work with kCodecVP8, crashes pretty qui
63 break;
64 case 1:
65 pixel_format = PIXEL_FORMAT_YV12A;
66 break;
67 case 2:
68 pixel_format = PIXEL_FORMAT_YV24;
69 break;
70 default:
71 return 0;
72 }
73 }
74
48 auto profile = 75 auto profile =
49 static_cast<VideoCodecProfile>(rng() % VIDEO_CODEC_PROFILE_MAX); 76 static_cast<VideoCodecProfile>(rng() % VIDEO_CODEC_PROFILE_MAX);
50 auto pixel_format = static_cast<VideoPixelFormat>(rng() % PIXEL_FORMAT_MAX);
51 auto color_space = static_cast<ColorSpace>(rng() % COLOR_SPACE_MAX); 77 auto color_space = static_cast<ColorSpace>(rng() % COLOR_SPACE_MAX);
52 auto coded_size = gfx::Size(rng() % 128, rng() % 128); 78 auto coded_size = gfx::Size(rng() % 128, rng() % 128);
jrummell 2016/09/09 17:33:00 width and height must be > 0, so use (rng() % 127)
mmoroz 2016/09/15 17:56:01 Done.
53 auto visible_rect = gfx::Rect(rng() % 128, rng() % 128); 79 auto visible_rect = gfx::Rect(rng() % 128, rng() % 128);
jrummell 2016/09/09 17:33:00 Since visible_rect <= coded_size, I would just mak
mmoroz 2016/09/15 17:56:01 Done.
54 auto natural_size = gfx::Size(rng() % 128, rng() % 128); 80 auto natural_size = gfx::Size(rng() % 128, rng() % 128);
55 81
56 VideoDecoderConfig config(codec, profile, pixel_format, color_space, 82 VideoDecoderConfig config(codec, profile, pixel_format, color_space,
57 coded_size, visible_rect, natural_size, 83 coded_size, visible_rect, natural_size,
58 EmptyExtraData(), Unencrypted()); 84 EmptyExtraData(), Unencrypted());
59 85
86 if (!config.IsValidConfig())
87 return 0;
88
60 VpxVideoDecoder decoder; 89 VpxVideoDecoder decoder;
61 base::RunLoop run_loop; 90 base::RunLoop run_loop;
62 91
63 decoder.Initialize(config, true /* low_delay */, nullptr /* cdm_context */, 92 decoder.Initialize(config, true /* low_delay */, nullptr /* cdm_context */,
64 base::Bind(&OnInitDone), base::Bind(&OnOutputComplete)); 93 base::Bind(&OnInitDone), base::Bind(&OnOutputComplete));
65 run_loop.RunUntilIdle(); 94 run_loop.RunUntilIdle();
66 95
67 auto buffer = DecoderBuffer::CopyFrom(data, size); 96 auto buffer = DecoderBuffer::CopyFrom(data, size);
68 decoder.Decode(buffer, base::Bind(&OnDecodeComplete)); 97 decoder.Decode(buffer, base::Bind(&OnDecodeComplete));
jrummell 2016/09/09 17:33:00 Decode() has a DCHECK to make sure Initialize pass
mmoroz 2016/09/15 17:56:02 Actually, the restrictions implemented above provi
69 run_loop.RunUntilIdle(); 98 // Otherwise crashes on DCHECK in RunLoop::BeforeRun().
99 run_loop.QuitWhenIdle();
70 100
71 return 0; 101 return 0;
72 } 102 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698