Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
x264
Commits
9da19fbe
Commit
9da19fbe
authored
Feb 13, 2012
by
Fiona Glaser
Browse files
Export PSNR/SSIM in x264 API
parent
3a5f2fe3
Changes
2
Hide whitespace changes
Inline
Side-by-side
encoder/encoder.c
View file @
9da19fbe
...
...
@@ -3231,26 +3231,28 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
};
int
luma_size
=
h
->
param
.
i_width
*
h
->
param
.
i_height
;
int
chroma_size
=
CHROMA_SIZE
(
luma_size
);
double
psnr_y
=
x264_psnr
(
ssd
[
0
],
luma_size
);
double
psnr_u
=
x264_psnr
(
ssd
[
1
],
chroma_size
);
double
psnr_v
=
x264_psnr
(
ssd
[
2
],
chroma_size
);
pic_out
->
prop
.
f_psnr
[
0
]
=
x264_psnr
(
ssd
[
0
],
luma_size
);
pic_out
->
prop
.
f_psnr
[
1
]
=
x264_psnr
(
ssd
[
1
],
chroma_size
);
pic_out
->
prop
.
f_psnr
[
2
]
=
x264_psnr
(
ssd
[
2
],
chroma_size
);
pic_out
->
prop
.
f_psnr_avg
=
x264_psnr
(
ssd
[
0
]
+
ssd
[
1
]
+
ssd
[
2
],
luma_size
+
chroma_size
*
2
);
h
->
stat
.
f_ssd_global
[
h
->
sh
.
i_type
]
+=
dur
*
(
ssd
[
0
]
+
ssd
[
1
]
+
ssd
[
2
]);
h
->
stat
.
f_psnr_average
[
h
->
sh
.
i_type
]
+=
dur
*
x264_psnr
(
ssd
[
0
]
+
ssd
[
1
]
+
ssd
[
2
],
luma_size
+
chroma_size
*
2
)
;
h
->
stat
.
f_psnr_mean_y
[
h
->
sh
.
i_type
]
+=
dur
*
p
snr_y
;
h
->
stat
.
f_psnr_mean_u
[
h
->
sh
.
i_type
]
+=
dur
*
p
snr_u
;
h
->
stat
.
f_psnr_mean_v
[
h
->
sh
.
i_type
]
+=
dur
*
p
snr_v
;
h
->
stat
.
f_psnr_average
[
h
->
sh
.
i_type
]
+=
dur
*
pic_out
->
prop
.
f_psnr_avg
;
h
->
stat
.
f_psnr_mean_y
[
h
->
sh
.
i_type
]
+=
dur
*
p
ic_out
->
prop
.
f_psnr
[
0
]
;
h
->
stat
.
f_psnr_mean_u
[
h
->
sh
.
i_type
]
+=
dur
*
p
ic_out
->
prop
.
f_psnr
[
1
]
;
h
->
stat
.
f_psnr_mean_v
[
h
->
sh
.
i_type
]
+=
dur
*
p
ic_out
->
prop
.
f_psnr
[
2
]
;
snprintf
(
psz_message
,
80
,
" PSNR Y:%5.2f U:%5.2f V:%5.2f"
,
psnr_y
,
psnr_u
,
psnr_v
);
snprintf
(
psz_message
,
80
,
" PSNR Y:%5.2f U:%5.2f V:%5.2f"
,
pic_out
->
prop
.
f_psnr
[
0
],
pic_out
->
prop
.
f_psnr
[
1
],
pic_out
->
prop
.
f_psnr
[
2
]
);
}
if
(
h
->
param
.
analyse
.
b_ssim
)
{
double
ssim_y
=
h
->
stat
.
frame
.
f_ssim
/
h
->
stat
.
frame
.
i_ssim_cnt
;
h
->
stat
.
f_ssim_mean_y
[
h
->
sh
.
i_type
]
+=
ssim_y
*
dur
;
pic_out
->
prop
.
f_ssim
=
h
->
stat
.
frame
.
f_ssim
/
h
->
stat
.
frame
.
i_ssim_cnt
;
h
->
stat
.
f_ssim_mean_y
[
h
->
sh
.
i_type
]
+=
pic_out
->
prop
.
f_ssim
*
dur
;
snprintf
(
psz_message
+
strlen
(
psz_message
),
80
-
strlen
(
psz_message
),
" SSIM Y:%.5f"
,
ssim
_y
);
" SSIM Y:%.5f"
,
pic_out
->
prop
.
f_
ssim
);
}
psz_message
[
79
]
=
'\0'
;
...
...
x264.h
View file @
9da19fbe
...
...
@@ -41,7 +41,7 @@
#include
"x264_config.h"
#define X264_BUILD 12
0
#define X264_BUILD 12
1
/* x264_t:
* opaque handler for encoder */
...
...
@@ -689,6 +689,12 @@ typedef struct
/* In: optional callback to free quant_offsets when used.
* Useful if one wants to use a different quant_offset array for each frame. */
void
(
*
quant_offsets_free
)(
void
*
);
/* Out: SSIM of the the frame luma (if x264_param_t.b_ssim is set) */
double
f_ssim
;
/* Out: Average PSNR of the frame (if x264_param_t.b_psnr is set) */
double
f_psnr_avg
;
/* Out: PSNR of Y, U, and V (if x264_param_t.b_psnr is set) */
double
f_psnr
[
3
];
}
x264_image_properties_t
;
typedef
struct
...
...
@@ -723,7 +729,8 @@ typedef struct
x264_param_t
*
param
;
/* In: raw data */
x264_image_t
img
;
/* In: optional information to modify encoder decisions for this frame */
/* In: optional information to modify encoder decisions for this frame
* Out: information about the encoded frame */
x264_image_properties_t
prop
;
/* Out: HRD timing information. Output only when i_nal_hrd is set. */
x264_hrd_t
hrd_timing
;
...
...
Write
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!
Cancel
Please
register
or
sign in
to comment