Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
a9b5b6a9
Commit
a9b5b6a9
authored
7 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
tools: Eliminate codec_type complexity from fuzzer
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
7796f290
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/Makefile
+2
-9
2 additions, 9 deletions
tools/Makefile
tools/target_dec_fuzzer.c
+9
-10
9 additions, 10 deletions
tools/target_dec_fuzzer.c
with
11 additions
and
19 deletions
tools/Makefile
+
2
−
9
View file @
a9b5b6a9
TOOLS
=
qt-faststart trasher uncoded_frame
TOOLS
=
qt-faststart trasher uncoded_frame
TOOLS-$(CONFIG_ZLIB)
+=
cws2fws
TOOLS-$(CONFIG_ZLIB)
+=
cws2fws
tools/target_dec_video_%_fuzzer.o
:
tools/target_dec_fuzzer.c
tools/target_dec_%_fuzzer.o
:
tools/target_dec_fuzzer.c
$(
COMPILE_C
)
-DFFMPEG_CODEC
=
AV_CODEC_ID_
$*
-DFUZZ_FFMPEG_VIDEO
$(
COMPILE_C
)
-DFFMPEG_CODEC
=
AV_CODEC_ID_
$*
tools/target_dec_audio_%_fuzzer.o
:
tools/target_dec_fuzzer.c
$(
COMPILE_C
)
-DFFMPEG_CODEC
=
AV_CODEC_ID_
$*
-DFUZZ_FFMPEG_AUDIO
tools/target_dec_subtitle_%_fuzzer.o
:
tools/target_dec_fuzzer.c
$(
COMPILE_C
)
-DFFMPEG_CODEC
=
AV_CODEC_ID_
$*
-DFUZZ_FFMPEG_SUBTITLE
OBJDIRS
+=
tools
OBJDIRS
+=
tools
...
...
This diff is collapsed.
Click to expand it.
tools/target_dec_fuzzer.c
+
9
−
10
View file @
a9b5b6a9
...
@@ -74,11 +74,6 @@ static AVCodec *AVCodecInitialize(enum AVCodecID codec_id)
...
@@ -74,11 +74,6 @@ static AVCodec *AVCodecInitialize(enum AVCodecID codec_id)
return
res
;
return
res
;
}
}
#if defined(FUZZ_FFMPEG_VIDEO)
#define decode_handler avcodec_decode_video2
#elif defined(FUZZ_FFMPEG_AUDIO)
#define decode_handler avcodec_decode_audio4
#elif defined(FUZZ_FFMPEG_SUBTITLE)
static
int
subtitle_handler
(
AVCodecContext
*
avctx
,
void
*
frame
,
static
int
subtitle_handler
(
AVCodecContext
*
avctx
,
void
*
frame
,
int
*
got_sub_ptr
,
AVPacket
*
avpkt
)
int
*
got_sub_ptr
,
AVPacket
*
avpkt
)
{
{
...
@@ -89,11 +84,6 @@ static int subtitle_handler(AVCodecContext *avctx, void *frame,
...
@@ -89,11 +84,6 @@ static int subtitle_handler(AVCodecContext *avctx, void *frame,
return
ret
;
return
ret
;
}
}
#define decode_handler subtitle_handler
#else
#error "Specify encoder type" // To catch mistakes
#endif
// Class to handle buffer allocation and resize for each frame
// Class to handle buffer allocation and resize for each frame
typedef
struct
FuzzDataBuffer
{
typedef
struct
FuzzDataBuffer
{
size_t
size_
;
size_t
size_
;
...
@@ -146,10 +136,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
...
@@ -146,10 +136,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
const
uint8_t
*
last
=
data
;
const
uint8_t
*
last
=
data
;
const
uint8_t
*
end
=
data
+
size
;
const
uint8_t
*
end
=
data
+
size
;
uint32_t
it
=
0
;
uint32_t
it
=
0
;
int
(
*
decode_handler
)(
AVCodecContext
*
avctx
,
AVFrame
*
picture
,
int
*
got_picture_ptr
,
const
AVPacket
*
avpkt
)
=
NULL
;
if
(
!
c
)
if
(
!
c
)
c
=
AVCodecInitialize
(
FFMPEG_CODEC
);
// Done once.
c
=
AVCodecInitialize
(
FFMPEG_CODEC
);
// Done once.
switch
(
c
->
type
)
{
case
AVMEDIA_TYPE_AUDIO
:
decode_handler
=
avcodec_decode_audio4
;
break
;
case
AVMEDIA_TYPE_VIDEO
:
decode_handler
=
avcodec_decode_video2
;
break
;
case
AVMEDIA_TYPE_SUBTITLE
:
decode_handler
=
subtitle_handler
;
break
;
}
AVCodecContext
*
ctx
=
avcodec_alloc_context3
(
NULL
);
AVCodecContext
*
ctx
=
avcodec_alloc_context3
(
NULL
);
if
(
!
ctx
)
if
(
!
ctx
)
error
(
"Failed memory allocation"
);
error
(
"Failed memory allocation"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment