Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
external
libvpx
Commits
b0526522
Commit
b0526522
authored
11 years ago
by
Dmitry Kovalev
Committed by
Gerrit Code Review
11 years ago
Browse files
Options
Download
Plain Diff
Merge "Adding VP9 support to decode_to_md5 example."
parents
6cd63498
0f8787d6
v1.14.0-linphone
1.4.X
feature/update_to_v1.9.0-linphone
feature/uwp_nuget
frame_parallel
highbitdepth
indianrunnerduck
javanwhistlingduck
khakicampbell
linphone
linphone-android
linphone-old
longtailedduck
m49-2623
m52-2743
m54-2840
m56-2924
m66-3359
m68-3440
mandarinduck
mcw
mcw2
nextgen
nextgenv2
playground
sandbox/Jingning/experimental
sandbox/Jingning/transcode
sandbox/Jingning/vpx
sandbox/aconverse@google.com/ansbench
sandbox/hkuang/frame_parallel
sandbox/hkuang@google.com/decode
sandbox/jimbankoski@google.com/proposed-aom
sandbox/jingning@google.com/decoder_test_suite
sandbox/jingning@google.com/experimental
sandbox/jzern@google.com/test
sandbox/wangch@google.com/vp9
sandbox/yaowu@google.com/mergeaom
v1.12.0-linphone
v1.6.1_linphone
v1.7.0-linphone
v1.9.0-linphone
v1.9.0
v1.9.0-rc1
v1.8.2
v1.8.1
v1.8.0
v1.7.0
v1.6.1
v1.6.0
v1.5.0
v1.4.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/decode_to_md5.c
+38
-16
examples/decode_to_md5.c
with
38 additions
and
16 deletions
examples/decode_to_md5.c
+
38
−
16
View file @
b0526522
...
@@ -37,12 +37,24 @@
...
@@ -37,12 +37,24 @@
#include
"./vpx_config.h"
#include
"./vpx_config.h"
#include
"vpx/vp8dx.h"
#include
"vpx/vp8dx.h"
#include
"vpx/vpx_decoder.h"
#include
"vpx/vpx_decoder.h"
#define interface (vpx_codec_vp8_dx())
#include
"md5_utils.h"
#include
"md5_utils.h"
#define VP8_FOURCC 0x30385056
#define VP9_FOURCC 0x30395056
#define IVF_FILE_HDR_SZ (32)
#define IVF_FILE_HDR_SZ (32)
#define IVF_FRAME_HDR_SZ (12)
#define IVF_FRAME_HDR_SZ (12)
static
vpx_codec_iface_t
*
get_codec_interface
(
unsigned
int
fourcc
)
{
switch
(
fourcc
)
{
case
VP8_FOURCC
:
return
vpx_codec_vp8_dx
();
case
VP9_FOURCC
:
return
vpx_codec_vp9_dx
();
}
return
NULL
;
}
static
unsigned
int
mem_get_le32
(
const
unsigned
char
*
mem
)
{
static
unsigned
int
mem_get_le32
(
const
unsigned
char
*
mem
)
{
return
(
mem
[
3
]
<<
24
)
|
(
mem
[
2
]
<<
16
)
|
(
mem
[
1
]
<<
8
)
|
(
mem
[
0
]);
return
(
mem
[
3
]
<<
24
)
|
(
mem
[
2
]
<<
16
)
|
(
mem
[
1
]
<<
8
)
|
(
mem
[
0
]);
}
}
...
@@ -52,7 +64,7 @@ static void die(const char *fmt, ...) {
...
@@ -52,7 +64,7 @@ static void die(const char *fmt, ...) {
va_start
(
ap
,
fmt
);
va_start
(
ap
,
fmt
);
vprintf
(
fmt
,
ap
);
vprintf
(
fmt
,
ap
);
if
(
fmt
[
strlen
(
fmt
)
-
1
]
!=
'\n'
)
if
(
fmt
[
strlen
(
fmt
)
-
1
]
!=
'\n'
)
printf
(
"
\n
"
);
printf
(
"
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -66,7 +78,7 @@ static void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
...
@@ -66,7 +78,7 @@ static void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
static
void
get_image_md5
(
const
vpx_image_t
*
img
,
unsigned
char
md5_sum
[
16
])
{
static
void
get_image_md5
(
const
vpx_image_t
*
img
,
unsigned
char
digest
[
16
])
{
int
plane
,
y
;
int
plane
,
y
;
MD5Context
md5
;
MD5Context
md5
;
...
@@ -84,12 +96,20 @@ static void get_image_md5(const vpx_image_t *img, unsigned char md5_sum[16]) {
...
@@ -84,12 +96,20 @@ static void get_image_md5(const vpx_image_t *img, unsigned char md5_sum[16]) {
}
}
}
}
MD5Final
(
md5_sum
,
&
md5
);
MD5Final
(
digest
,
&
md5
);
}
static
void
print_md5
(
FILE
*
stream
,
unsigned
char
digest
[
16
])
{
int
i
;
for
(
i
=
0
;
i
<
16
;
++
i
)
fprintf
(
stream
,
"%02x"
,
digest
[
i
]);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
FILE
*
infile
,
*
outfile
;
FILE
*
infile
,
*
outfile
;
vpx_codec_ctx_t
codec
;
vpx_codec_ctx_t
codec
;
vpx_codec_iface_t
*
iface
;
int
flags
=
0
,
frame_cnt
=
0
;
int
flags
=
0
,
frame_cnt
=
0
;
unsigned
char
file_hdr
[
IVF_FILE_HDR_SZ
];
unsigned
char
file_hdr
[
IVF_FILE_HDR_SZ
];
unsigned
char
frame_hdr
[
IVF_FRAME_HDR_SZ
];
unsigned
char
frame_hdr
[
IVF_FRAME_HDR_SZ
];
...
@@ -109,9 +129,14 @@ int main(int argc, char **argv) {
...
@@ -109,9 +129,14 @@ int main(int argc, char **argv) {
file_hdr
[
2
]
==
'I'
&&
file_hdr
[
3
]
==
'F'
))
file_hdr
[
2
]
==
'I'
&&
file_hdr
[
3
]
==
'F'
))
die
(
"%s is not an IVF file."
,
argv
[
1
]);
die
(
"%s is not an IVF file."
,
argv
[
1
]);
printf
(
"Using %s
\n
"
,
vpx_codec_iface_name
(
interface
));
iface
=
get_codec_interface
(
mem_get_le32
(
file_hdr
+
8
));
if
(
!
iface
)
die
(
"Unknown FOURCC code."
);
if
(
vpx_codec_dec_init
(
&
codec
,
interface
,
NULL
,
flags
))
printf
(
"Using %s
\n
"
,
vpx_codec_iface_name
(
iface
));
if
(
vpx_codec_dec_init
(
&
codec
,
iface
,
NULL
,
flags
))
die_codec
(
&
codec
,
"Failed to initialize decoder"
);
die_codec
(
&
codec
,
"Failed to initialize decoder"
);
while
(
fread
(
frame_hdr
,
1
,
IVF_FRAME_HDR_SZ
,
infile
)
==
IVF_FRAME_HDR_SZ
)
{
while
(
fread
(
frame_hdr
,
1
,
IVF_FRAME_HDR_SZ
,
infile
)
==
IVF_FRAME_HDR_SZ
)
{
...
@@ -119,25 +144,22 @@ int main(int argc, char **argv) {
...
@@ -119,25 +144,22 @@ int main(int argc, char **argv) {
vpx_codec_iter_t
iter
=
NULL
;
vpx_codec_iter_t
iter
=
NULL
;
vpx_image_t
*
img
;
vpx_image_t
*
img
;
frame_cnt
++
;
if
(
frame_size
>
sizeof
(
frame
))
if
(
frame_size
>
sizeof
(
frame
))
die
(
"Frame %d data too big for example code buffer"
,
frame_size
);
die
(
"Frame %d data too big for example code buffer"
,
frame_size
);
if
(
fread
(
frame
,
1
,
frame_size
,
infile
)
!=
frame_size
)
if
(
fread
(
frame
,
1
,
frame_size
,
infile
)
!=
frame_size
)
die
(
"F
rame %d f
ailed to read complete frame"
,
frame_cnt
);
die
(
"Failed to read complete frame"
);
if
(
vpx_codec_decode
(
&
codec
,
frame
,
frame_size
,
NULL
,
0
))
if
(
vpx_codec_decode
(
&
codec
,
frame
,
frame_size
,
NULL
,
0
))
die_codec
(
&
codec
,
"Failed to decode frame"
);
die_codec
(
&
codec
,
"Failed to decode frame"
);
while
((
img
=
vpx_codec_get_frame
(
&
codec
,
&
iter
))
!=
NULL
)
{
while
((
img
=
vpx_codec_get_frame
(
&
codec
,
&
iter
))
!=
NULL
)
{
int
i
;
unsigned
char
digest
[
16
];
unsigned
char
md5_sum
[
16
];
get_image_md5
(
img
,
digest
);
get_image_md5
(
img
,
md5_sum
);
print_md5
(
outfile
,
digest
);
for
(
i
=
0
;
i
<
16
;
++
i
)
fprintf
(
outfile
,
" img-%dx%d-%04d.i420
\n
"
,
fprintf
(
outfile
,
"%02x"
,
md5_sum
[
i
]);
img
->
d_w
,
img
->
d_h
,
++
frame_cnt
);
fprintf
(
outfile
,
" img-%dx%d-%04d.i420
\n
"
,
img
->
d_w
,
img
->
d_h
,
frame_cnt
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets