6 #include <schroedinger/schro.h>
7 #include <schroedinger/schroorc.h>
10 schro_encoder_frame_downsample (SchroEncoderFrame
* frame
)
15 SCHRO_DEBUG ("downsampling frame %d", frame
->frame_number
);
17 last
= frame
->filtered_frame
;
18 for (i
= 0; i
< frame
->encoder
->downsample_levels
; i
++) {
19 frame
->downsampled_frames
[i
] =
20 schro_frame_new_and_alloc_extended (NULL
, frame
->filtered_frame
->format
,
21 ROUND_UP_SHIFT (frame
->filtered_frame
->width
, i
+ 1),
22 ROUND_UP_SHIFT (frame
->filtered_frame
->height
, i
+ 1),
23 MAX (frame
->params
.xbsep_luma
, frame
->params
.ybsep_luma
));
24 schro_frame_downsample (frame
->downsampled_frames
[i
], last
);
25 schro_frame_mc_edgeextend (frame
->downsampled_frames
[i
]);
26 last
= frame
->downsampled_frames
[i
];
31 schro_encoder_frame_upsample (SchroEncoderFrame
* frame
)
34 SCHRO_DEBUG ("upsampling frame %d", frame
->frame_number
);
36 if (frame
->upsampled_original_frame
) {
39 schro_frame_ref (frame
->filtered_frame
);
40 frame
->upsampled_original_frame
= frame
->filtered_frame
;
41 schro_upsampled_frame_upsample (frame
->upsampled_original_frame
);
45 schro_frame_component_squared_error (SchroFrameData
* a
, SchroFrameData
* b
)
50 SCHRO_ASSERT (a
->width
== b
->width
);
51 SCHRO_ASSERT (a
->height
== b
->height
);
54 for (j
= 0; j
< a
->height
; j
++) {
57 orc_sum_square_diff_u8 (&linesum
,
58 SCHRO_FRAME_DATA_GET_LINE (a
, j
),
59 SCHRO_FRAME_DATA_GET_LINE (b
, j
), a
->width
);
66 schro_frame_mean_squared_error (SchroFrame
* a
, SchroFrame
* b
, double *mse
)
70 sum
= schro_frame_component_squared_error (&a
->components
[0],
72 n
= a
->components
[0].width
* a
->components
[0].height
;
75 sum
= schro_frame_component_squared_error (&a
->components
[1],
77 n
= a
->components
[1].width
* a
->components
[1].height
;
80 sum
= schro_frame_component_squared_error (&a
->components
[2],
82 n
= a
->components
[2].width
* a
->components
[2].height
;