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
74e1830b
Commit
74e1830b
authored
11 years ago
by
Ivan Maltz
Browse files
Options
Download
Patches
Plain Diff
log overall psnr, average psnr, and overall mse
Change-Id: I0b4fa1f8104b7fa5780d4e99e5401c14271a992d
parent
801754ee
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
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
vpx/src/svc_encodeframe.c
+58
-11
vpx/src/svc_encodeframe.c
with
58 additions
and
11 deletions
vpx/src/svc_encodeframe.c
+
58
−
11
View file @
74e1830b
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* VP9 SVC encoding support via libvpx
* VP9 SVC encoding support via libvpx
*/
*/
#include
<math.h>
#include
<stdarg.h>
#include
<stdarg.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
...
@@ -40,6 +41,7 @@ _CRTIMP char *__cdecl strtok_s(char *str, const char *delim, char **context);
...
@@ -40,6 +41,7 @@ _CRTIMP char *__cdecl strtok_s(char *str, const char *delim, char **context);
#define SUPERFRAME_SLOTS (8)
#define SUPERFRAME_SLOTS (8)
#define SUPERFRAME_BUFFER_SIZE (SUPERFRAME_SLOTS * sizeof(uint32_t) + 2)
#define SUPERFRAME_BUFFER_SIZE (SUPERFRAME_SLOTS * sizeof(uint32_t) + 2)
#define OPTION_BUFFER_SIZE 256
#define OPTION_BUFFER_SIZE 256
#define COMPONENTS 4 // psnr & sse statistics maintained for total, y, u, v
static
const
char
*
DEFAULT_QUANTIZER_VALUES
=
"60,53,39,33,27"
;
static
const
char
*
DEFAULT_QUANTIZER_VALUES
=
"60,53,39,33,27"
;
static
const
char
*
DEFAULT_SCALE_FACTORS
=
"4/16,5/16,7/16,11/16,16/16"
;
static
const
char
*
DEFAULT_SCALE_FACTORS
=
"4/16,5/16,7/16,11/16,16/16"
;
...
@@ -55,8 +57,9 @@ typedef struct SvcInternal {
...
@@ -55,8 +57,9 @@ typedef struct SvcInternal {
int
quantizer
[
VPX_SS_MAX_LAYERS
];
int
quantizer
[
VPX_SS_MAX_LAYERS
];
// accumulated statistics
// accumulated statistics
double
psnr_in_layer
[
VPX_SS_MAX_LAYERS
];
double
psnr_sum
[
VPX_SS_MAX_LAYERS
][
COMPONENTS
];
// total/Y/U/V
uint32_t
bytes_in_layer
[
VPX_SS_MAX_LAYERS
];
uint64_t
sse_sum
[
VPX_SS_MAX_LAYERS
][
COMPONENTS
];
uint32_t
bytes_sum
[
VPX_SS_MAX_LAYERS
];
// codec encoding values
// codec encoding values
int
width
;
// width of highest layer
int
width
;
// width of highest layer
...
@@ -814,7 +817,7 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
...
@@ -814,7 +817,7 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
switch
(
cx_pkt
->
kind
)
{
switch
(
cx_pkt
->
kind
)
{
case
VPX_CODEC_CX_FRAME_PKT
:
{
case
VPX_CODEC_CX_FRAME_PKT
:
{
const
uint32_t
frame_pkt_size
=
(
uint32_t
)(
cx_pkt
->
data
.
frame
.
sz
);
const
uint32_t
frame_pkt_size
=
(
uint32_t
)(
cx_pkt
->
data
.
frame
.
sz
);
si
->
bytes_
in_layer
[
si
->
layer
]
+=
frame_pkt_size
;
si
->
bytes_
sum
[
si
->
layer
]
+=
frame_pkt_size
;
svc_log
(
svc_ctx
,
SVC_LOG_DEBUG
,
svc_log
(
svc_ctx
,
SVC_LOG_DEBUG
,
"SVC frame: %d, layer: %d, size: %u
\n
"
,
"SVC frame: %d, layer: %d, size: %u
\n
"
,
si
->
encode_frame_count
,
si
->
layer
,
frame_pkt_size
);
si
->
encode_frame_count
,
si
->
layer
,
frame_pkt_size
);
...
@@ -832,13 +835,23 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
...
@@ -832,13 +835,23 @@ vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
break
;
break
;
}
}
case
VPX_CODEC_PSNR_PKT
:
{
case
VPX_CODEC_PSNR_PKT
:
{
int
i
;
svc_log
(
svc_ctx
,
SVC_LOG_DEBUG
,
svc_log
(
svc_ctx
,
SVC_LOG_DEBUG
,
"SVC frame: %d, layer: %d, PSNR(Total/Y/U/V): "
"SVC frame: %d, layer: %d, PSNR(Total/Y/U/V): "
"%2.3f %2.3f %2.3f %2.3f
\n
"
,
"%2.3f %2.3f %2.3f %2.3f
\n
"
,
si
->
encode_frame_count
,
si
->
layer
,
si
->
encode_frame_count
,
si
->
layer
,
cx_pkt
->
data
.
psnr
.
psnr
[
0
],
cx_pkt
->
data
.
psnr
.
psnr
[
1
],
cx_pkt
->
data
.
psnr
.
psnr
[
0
],
cx_pkt
->
data
.
psnr
.
psnr
[
1
],
cx_pkt
->
data
.
psnr
.
psnr
[
2
],
cx_pkt
->
data
.
psnr
.
psnr
[
3
]);
cx_pkt
->
data
.
psnr
.
psnr
[
2
],
cx_pkt
->
data
.
psnr
.
psnr
[
3
]);
si
->
psnr_in_layer
[
si
->
layer
]
+=
cx_pkt
->
data
.
psnr
.
psnr
[
0
];
svc_log
(
svc_ctx
,
SVC_LOG_DEBUG
,
"SVC frame: %d, layer: %d, SSE(Total/Y/U/V): "
"%2.3f %2.3f %2.3f %2.3f
\n
"
,
si
->
encode_frame_count
,
si
->
layer
,
cx_pkt
->
data
.
psnr
.
sse
[
0
],
cx_pkt
->
data
.
psnr
.
sse
[
1
],
cx_pkt
->
data
.
psnr
.
sse
[
2
],
cx_pkt
->
data
.
psnr
.
sse
[
3
]);
for
(
i
=
0
;
i
<
COMPONENTS
;
i
++
)
{
si
->
psnr_sum
[
si
->
layer
][
i
]
+=
cx_pkt
->
data
.
psnr
.
psnr
[
i
];
si
->
sse_sum
[
si
->
layer
][
i
]
+=
cx_pkt
->
data
.
psnr
.
sse
[
i
];
}
break
;
break
;
}
}
default:
{
default:
{
...
@@ -916,11 +929,21 @@ void vpx_svc_set_keyframe(SvcContext *svc_ctx) {
...
@@ -916,11 +929,21 @@ void vpx_svc_set_keyframe(SvcContext *svc_ctx) {
si
->
frame_within_gop
=
0
;
si
->
frame_within_gop
=
0
;
}
}
static
double
calc_psnr
(
double
d
)
{
if
(
d
==
0
)
return
100
;
return
-
10
.
0
*
log
(
d
)
/
log
(
10
.
0
);
}
// dump accumulated statistics and reset accumulated values
// dump accumulated statistics and reset accumulated values
const
char
*
vpx_svc_dump_statistics
(
SvcContext
*
svc_ctx
)
{
const
char
*
vpx_svc_dump_statistics
(
SvcContext
*
svc_ctx
)
{
int
number_of_frames
,
number_of_keyframes
,
encode_frame_count
;
int
number_of_frames
,
number_of_keyframes
,
encode_frame_count
;
int
i
;
int
i
,
j
;
uint32_t
bytes_total
=
0
;
uint32_t
bytes_total
=
0
;
double
scale
[
COMPONENTS
];
double
psnr
[
COMPONENTS
];
double
mse
[
COMPONENTS
];
double
y_scale
;
SvcInternal
*
const
si
=
get_svc_internal
(
svc_ctx
);
SvcInternal
*
const
si
=
get_svc_internal
(
svc_ctx
);
if
(
svc_ctx
==
NULL
||
si
==
NULL
)
return
NULL
;
if
(
svc_ctx
==
NULL
||
si
==
NULL
)
return
NULL
;
...
@@ -938,12 +961,36 @@ const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) {
...
@@ -938,12 +961,36 @@ const char *vpx_svc_dump_statistics(SvcContext *svc_ctx) {
(
i
==
1
||
i
==
3
))
{
(
i
==
1
||
i
==
3
))
{
number_of_frames
-=
number_of_keyframes
;
number_of_frames
-=
number_of_keyframes
;
}
}
svc_log
(
svc_ctx
,
SVC_LOG_INFO
,
"Layer %d PSNR=[%2.3f], Bytes=[%u]
\n
"
,
i
,
svc_log
(
svc_ctx
,
SVC_LOG_INFO
,
(
double
)
si
->
psnr_in_layer
[
i
]
/
number_of_frames
,
"Layer %d Average PSNR=[%2.3f, %2.3f, %2.3f, %2.3f], Bytes=[%u]
\n
"
,
si
->
bytes_in_layer
[
i
]);
i
,
(
double
)
si
->
psnr_sum
[
i
][
0
]
/
number_of_frames
,
bytes_total
+=
si
->
bytes_in_layer
[
i
];
(
double
)
si
->
psnr_sum
[
i
][
1
]
/
number_of_frames
,
si
->
psnr_in_layer
[
i
]
=
0
;
(
double
)
si
->
psnr_sum
[
i
][
2
]
/
number_of_frames
,
si
->
bytes_in_layer
[
i
]
=
0
;
(
double
)
si
->
psnr_sum
[
i
][
3
]
/
number_of_frames
,
si
->
bytes_sum
[
i
]);
// the following psnr calculation is deduced from ffmpeg.c#print_report
y_scale
=
si
->
width
*
si
->
height
*
255
.
0
*
255
.
0
*
number_of_frames
;
scale
[
1
]
=
y_scale
;
scale
[
2
]
=
scale
[
3
]
=
y_scale
/
4
;
// U or V
scale
[
0
]
=
y_scale
*
1
.
5
;
// total
for
(
j
=
0
;
j
<
COMPONENTS
;
j
++
)
{
psnr
[
j
]
=
calc_psnr
(
si
->
sse_sum
[
i
][
j
]
/
scale
[
j
]);
mse
[
j
]
=
si
->
sse_sum
[
i
][
j
]
*
255
.
0
*
255
.
0
/
scale
[
j
];
}
svc_log
(
svc_ctx
,
SVC_LOG_INFO
,
"Layer %d Overall PSNR=[%2.3f, %2.3f, %2.3f, %2.3f]
\n
"
,
i
,
psnr
[
0
],
psnr
[
1
],
psnr
[
2
],
psnr
[
3
]);
svc_log
(
svc_ctx
,
SVC_LOG_INFO
,
"Layer %d Overall MSE=[%2.3f, %2.3f, %2.3f, %2.3f]
\n
"
,
i
,
mse
[
0
],
mse
[
1
],
mse
[
2
],
mse
[
3
]);
bytes_total
+=
si
->
bytes_sum
[
i
];
// clear sums for next time
si
->
bytes_sum
[
i
]
=
0
;
for
(
j
=
0
;
j
<
COMPONENTS
;
++
j
)
{
si
->
psnr_sum
[
i
][
j
]
=
0
;
si
->
sse_sum
[
i
][
j
]
=
0
;
}
}
}
// only display statistics once
// only display statistics once
...
...
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