55
49
me->encoder_frame = frame;
56
50
me->params = &frame->params;
58
me->src0 = frame->ref_frame0->reconstructed_frame;
59
me->downsampled_src0[0] = frame->ref_frame0->filtered_frame;
60
me->downsampled_src0[1] = frame->ref_frame0->downsampled_frames[0];
61
me->downsampled_src0[2] = frame->ref_frame0->downsampled_frames[1];
62
me->downsampled_src0[3] = frame->ref_frame0->downsampled_frames[2];
63
me->downsampled_src0[4] = frame->ref_frame0->downsampled_frames[3];
52
me->src0 = frame->ref_frame[0]->reconstructed_frame;
53
me->downsampled_src0[0] = frame->ref_frame[0]->filtered_frame;
54
me->downsampled_src0[1] = frame->ref_frame[0]->downsampled_frames[0];
55
me->downsampled_src0[2] = frame->ref_frame[0]->downsampled_frames[1];
56
me->downsampled_src0[3] = frame->ref_frame[0]->downsampled_frames[2];
57
me->downsampled_src0[4] = frame->ref_frame[0]->downsampled_frames[3];
65
59
if (me->params->num_refs > 1) {
66
me->src1 = frame->ref_frame1->reconstructed_frame;
67
me->downsampled_src1[0] = frame->ref_frame1->filtered_frame;
68
me->downsampled_src1[1] = frame->ref_frame1->downsampled_frames[0];
69
me->downsampled_src1[2] = frame->ref_frame1->downsampled_frames[1];
70
me->downsampled_src1[3] = frame->ref_frame1->downsampled_frames[2];
71
me->downsampled_src1[4] = frame->ref_frame1->downsampled_frames[3];
60
me->src1 = frame->ref_frame[1]->reconstructed_frame;
61
me->downsampled_src1[0] = frame->ref_frame[1]->filtered_frame;
62
me->downsampled_src1[1] = frame->ref_frame[1]->downsampled_frames[0];
63
me->downsampled_src1[2] = frame->ref_frame[1]->downsampled_frames[1];
64
me->downsampled_src1[3] = frame->ref_frame[1]->downsampled_frames[2];
65
me->downsampled_src1[4] = frame->ref_frame[1]->downsampled_frames[3];
74
68
n = params->x_num_blocks * params->y_num_blocks / 16;
113
108
me = schro_motionest_new (frame);
115
110
frame->motion = schro_motion_new (params,
116
frame->ref_frame0->reconstructed_frame,
117
(params->num_refs > 1) ? frame->ref_frame1->reconstructed_frame : NULL);
111
frame->ref_frame[0]->reconstructed_frame,
112
(params->num_refs > 1) ? frame->ref_frame[1]->reconstructed_frame : NULL);
118
113
me->motion = frame->motion;
120
115
frame->motion_field_list = schro_list_new_full ((SchroListFreeFunc)schro_motion_field_free, NULL);
123
if (frame->encoder->enable_bigblock_estimation) {
126
for(ref=0;ref<params->num_refs;ref++){
127
schro_motionest_rough_scan_nohint (me, 3, ref, 12);
128
schro_motionest_rough_scan_hint (me, 2, ref, 2);
129
schro_motionest_rough_scan_hint (me, 1, ref, 2);
132
//schro_encoder_bigblock_estimation (me);
133
schro_encoder_bigblock2_estimation (me);
135
schro_encoder_dc_estimation (me);
118
for(ref=0;ref<params->num_refs;ref++){
119
schro_motionest_rough_scan_nohint (me, 3, ref, 12);
120
schro_motionest_rough_scan_hint (me, 2, ref, 2);
121
schro_motionest_rough_scan_hint (me, 1, ref, 2);
124
schro_encoder_bigblock_estimation (me);
137
127
if (frame->encoder->enable_phasecorr_estimation) {
138
128
schro_encoder_phasecorr_estimation (me);
141
if (frame->encoder->enable_hierarchical_estimation) {
142
schro_encoder_hierarchical_estimation (me);
145
if (frame->encoder->enable_zero_estimation) {
146
schro_encoder_zero_estimation (me);
149
if (frame->encoder->enable_fullscan_estimation) {
150
schro_encoder_fullscan_estimation (me);
153
130
if (params->have_global_motion) {
154
131
schro_encoder_global_estimation (me);
157
schro_motion_merge (frame->motion, frame->motion_field_list);
158
schro_motion_cleanup (frame->motion,
159
(params->video_format->width + params->xbsep_luma - 1)/params->xbsep_luma,
160
(params->video_format->height + params->ybsep_luma - 1)/params->ybsep_luma);
162
schro_motion_combine (frame->motion);
165
134
schro_motion_calculate_stats (frame->motion, frame);
166
135
frame->estimated_mc_bits = schro_motion_estimate_entropy (frame->motion);
174
schro_motion_merge (SchroMotion *motion, SchroList *list)
177
SchroMotionVector *mv;
178
SchroMotionVector *mvk;
179
SchroMotionField **fields = (SchroMotionField **)list->members;
180
int n = schro_list_get_size (list);
183
SCHRO_ASSERT(fields[k]->x_num_blocks == motion->params->x_num_blocks);
184
SCHRO_ASSERT(fields[k]->y_num_blocks == motion->params->y_num_blocks);
187
for(j=0;j<motion->params->y_num_blocks;j++){
188
for(i=0;i<motion->params->x_num_blocks;i++){
189
mv = SCHRO_MOTION_GET_BLOCK(motion,i,j);
191
mvk = &fields[0]->motion_vectors[j*motion->params->x_num_blocks + i];
194
mvk = &fields[k]->motion_vectors[j*motion->params->x_num_blocks + i];
195
if (mvk->metric < mv->metric) {
199
if (mv->pred_mode == 2) {
200
mv->dx[1] = mv->dx[0];
201
mv->dy[1] = mv->dy[0];
203
SCHRO_ASSERT (!(mv->pred_mode == 0 && mv->using_global));
209
schro_motion_cleanup (SchroMotion *motion, int x_blocks, int y_blocks)
212
SchroMotionVector *mv;
214
SCHRO_DEBUG("motion field cleanup %dx%d to %dx%d",
216
motion->params->x_num_blocks, motion->params->y_num_blocks);
217
if (x_blocks < motion->params->x_num_blocks) {
218
for(j=0;j<motion->params->y_num_blocks;j++){
219
for(i=x_blocks;i<motion->params->x_num_blocks;i++){
220
mv = SCHRO_MOTION_GET_BLOCK(motion,i,j);
221
*mv = *SCHRO_MOTION_GET_BLOCK(motion,i-1,j);
225
if (y_blocks < motion->params->y_num_blocks) {
226
for(j=y_blocks;j<motion->params->y_num_blocks;j++){
227
for(i=0;i<motion->params->x_num_blocks;i++){
228
mv = SCHRO_MOTION_GET_BLOCK(motion,i,j);
229
*mv = *SCHRO_MOTION_GET_BLOCK(motion,i,j-1);
236
schro_motion_combine (SchroMotion *motion)
239
SchroMotionVector *mv;
240
SchroMotionVector *mv2;
242
for(j=0;j<motion->params->y_num_blocks;j+=4){
243
for(i=0;i<motion->params->x_num_blocks;i+=4){
244
mv = SCHRO_MOTION_GET_BLOCK(motion,i,j);
245
if (mv->pred_mode == 0) {
247
int dc[3] = { 0, 0, 0 };
250
if (mv[k*mf->x_num_blocks + l].pred_mode != 0) goto next_mb;
251
dc[0] += mv[k*mf->x_num_blocks + l].u.dc[0];
252
dc[1] += mv[k*mf->x_num_blocks + l].u.dc[1];
253
dc[2] += mv[k*mf->x_num_blocks + l].u.dc[2];
257
mv->u.dc[0] = (dc[0] + 8)>>4;
258
mv->u.dc[1] = (dc[1] + 8)>>4;
259
mv->u.dc[2] = (dc[2] + 8)>>4;
263
} else if (mv->using_global) {
266
mv2 = SCHRO_MOTION_GET_BLOCK(motion,i+k,j+l);
267
if (!mv2->using_global ||
268
mv2->pred_mode != mv->pred_mode) {
280
mv2 = SCHRO_MOTION_GET_BLOCK(motion,i+k,j+l);
293
143
schro_motion_field_lshift (SchroMotionField *mf, int n)
902
schro_encoder_hierarchical_estimation (SchroMotionEst *me)
904
SchroParams *params = me->params;
908
SchroFrame *downsampled_ref;
909
SchroFrame *downsampled_frame;
911
SchroMotionField *mf;
912
SchroMotionField *parent_mf = NULL;
913
SchroMotionField *mf1 = NULL;
914
SchroMotionField *mf2 = NULL;
916
for(ref=0;ref<params->num_refs;ref++){
920
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame0,shift);
922
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame1,shift);
924
downsampled_frame = get_downsampled(me->encoder_frame,shift);
926
x_blocks = params->x_num_blocks>>shift;
927
y_blocks = params->y_num_blocks>>shift;
928
parent_mf = schro_motion_field_new (x_blocks, y_blocks);
930
schro_motion_field_set (parent_mf, 2, 1<<ref);
931
schro_motion_field_scan (parent_mf, params, downsampled_frame, downsampled_ref,
934
for(shift=2;shift>=0;shift--) {
936
SchroMotionVector *mv;
938
x_blocks = params->x_num_blocks>>shift;
939
y_blocks = params->y_num_blocks>>shift;
941
mf = schro_motion_field_new (x_blocks, y_blocks);
944
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame0,shift);
946
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame1,shift);
948
downsampled_frame = get_downsampled(me->encoder_frame,shift);
950
for(j=0;j<mf->y_num_blocks;j++){
951
for(i=0;i<mf->x_num_blocks;i++){
952
#define LIST_LENGTH 20
953
int list_x[LIST_LENGTH], list_y[LIST_LENGTH];
959
/* always test the zero vector */
964
/* inherit from parent */
966
int l = (i-1+2*(k&1))>>1;
967
int m = (j-1+(k&2))>>1;
968
if (l >= 0 && l < parent_mf->x_num_blocks &&
969
m >= 0 && m < parent_mf->y_num_blocks) {
970
mv = motion_field_get(parent_mf, l, m);
971
list_x[n] = mv->dx[0] * 2;
972
list_y[n] = mv->dy[0] * 2;
977
/* inherit from neighbors (only towards SE) */
979
mv = motion_field_get (mf, i-1, j);
980
list_x[n] = mv->dx[0];
981
list_y[n] = mv->dy[0];
985
mv = motion_field_get (mf, i, j-1);
986
list_x[n] = mv->dx[0];
987
list_y[n] = mv->dy[0];
990
if (i > 0 && j > 0) {
991
mv = motion_field_get (mf, i-1, j-1);
992
list_x[n] = mv->dx[0];
993
list_y[n] = mv->dy[0];
997
SCHRO_ASSERT(n<=LIST_LENGTH);
998
metric = schro_frame_get_metric (downsampled_frame,
999
i * 8, j * 8, downsampled_ref, i*8 + list_x[0],
1003
for (l = 1; l < n; l++) {
1006
m = schro_frame_get_metric (downsampled_frame,
1007
i * 8, j * 8, downsampled_ref, i*8 + list_x[l],
1016
mv = motion_field_get (mf, i, j);
1019
mv->metric = metric;
1021
mv->pred_mode = (1<<ref);
1025
schro_motion_field_scan (mf, params, downsampled_frame, downsampled_ref, 4);
1027
schro_motion_field_free (parent_mf);
1031
schro_motion_field_lshift (parent_mf, params->mv_precision);
1033
schro_motion_predict_subpixel (frame->motion, frame->filtered_frame,
1036
schro_list_append (me->encoder_frame->motion_field_list, parent_mf);
1045
if (params->num_refs == 2) {
1047
SchroMotionVector *mv;
1048
SchroMotionVector *mv1;
1049
SchroMotionVector *mv2;
1051
mf = schro_motion_field_new (params->x_num_blocks, params->y_num_blocks);
1052
for(j=0;j<mf->y_num_blocks;j++){
1053
for(i=0;i<mf->x_num_blocks;i++){
1054
mv = motion_field_get (mf, i, j);
1055
mv1 = motion_field_get (mf1, i, j);
1056
mv2 = motion_field_get (mf2, i, j);
1060
mv->dx[1] = mv2->dx[0];
1061
mv->dy[1] = mv2->dy[0];
1062
if (mv1->metric < BIDIR_LIMIT && mv2->metric < BIDIR_LIMIT) {
1063
mv->metric = MIN(mv1->metric, mv2->metric) - 1;
1069
schro_list_append (me->encoder_frame->motion_field_list, mf);
1074
schro_encoder_zero_estimation (SchroMotionEst *me)
1076
SchroParams *params = me->params;
1080
SchroFrame *downsampled_ref;
1081
SchroFrame *downsampled_frame;
1082
SchroMotionField *mf;
1084
for(ref=0;ref<params->num_refs;ref++){
1086
SchroMotionVector *mv;
1088
x_blocks = params->x_num_blocks;
1089
y_blocks = params->y_num_blocks;
1091
mf = schro_motion_field_new (x_blocks, y_blocks);
1094
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame0,0);
1096
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame1,0);
1098
downsampled_frame = get_downsampled(me->encoder_frame,0);
1100
for(j=0;j<mf->y_num_blocks;j++){
1101
for(i=0;i<mf->x_num_blocks;i++){
1104
metric = schro_frame_get_metric (downsampled_frame,
1105
i * params->xbsep_luma, j * params->ybsep_luma,
1106
downsampled_ref, i*params->xbsep_luma, j*params->ybsep_luma);
1108
mv = motion_field_get (mf, i, j);
1111
mv->metric = metric;
1113
mv->pred_mode = (1<<ref);
1117
schro_motion_field_lshift (mf, params->mv_precision);
1118
schro_list_append (me->encoder_frame->motion_field_list, mf);
1123
schro_encoder_fullscan_estimation (SchroMotionEst *me)
1125
SchroParams *params = me->params;
1127
SchroFrame *downsampled_ref;
1128
SchroFrame *downsampled_frame;
1129
SchroMotionField *mf;
1131
for(ref=0;ref<params->num_refs;ref++){
1132
mf = schro_motion_field_new (params->x_num_blocks, params->y_num_blocks);
1135
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame0,0);
1137
downsampled_ref = get_downsampled(me->encoder_frame->ref_frame1,0);
1139
downsampled_frame = get_downsampled(me->encoder_frame,0);
1141
schro_motion_field_set (mf, 2, (1<<ref));
1142
schro_motion_field_scan (mf, params, downsampled_frame,
1143
downsampled_ref, 20);
1145
schro_motion_field_lshift (mf, params->mv_precision);
1146
schro_list_append (me->encoder_frame->motion_field_list, mf);
1152
753
schro_motionest_rough_scan_nohint (SchroMotionEst *me, int shift, int ref,
1354
948
SchroParams *params = me->params;
1355
949
SchroMotionVector *mv;
1356
SchroMetricScan scan2;
950
SchroMetricScan scan;
1357
951
SchroMotionField *hint_mf;
1358
952
SchroMotionVector *hint_mv;
1361
scan2.frame = get_downsampled (me->encoder_frame, 0);
1363
scan2.ref_frame = get_downsampled (me->encoder_frame->ref_frame0, 0);
1365
scan2.ref_frame = get_downsampled (me->encoder_frame->ref_frame1, 0);
955
scan.frame = get_downsampled (me->encoder_frame, 0);
956
scan.ref_frame = get_downsampled (me->encoder_frame->ref_frame[ref], 0);
1368
958
hint_mf = me->downsampled_mf[ref][2];
1370
scan2.x = i * params->xbsep_luma;
1371
scan2.y = j * params->ybsep_luma;
1372
scan2.block_width = MIN(4*params->xbsep_luma, scan2.frame->width - scan2.x);
1373
scan2.block_height = MIN(4*params->ybsep_luma, scan2.frame->height - scan2.y);
1374
scan2.gravity_scale = 0;
1375
scan2.gravity_x = 0;
1376
scan2.gravity_y = 0;
960
scan.x = i * params->xbsep_luma;
961
scan.y = j * params->ybsep_luma;
962
scan.block_width = MIN(4*params->xbsep_luma, scan.frame->width - scan.x);
963
scan.block_height = MIN(4*params->ybsep_luma, scan.frame->height - scan.y);
964
scan.gravity_scale = 0;
1378
968
mv = &block->mv[0][0];
1379
969
hint_mv = motion_field_get (hint_mf, i, j);
1640
static SchroMotionField *
1641
schro_motionest_block_scan (SchroMotionEst *me, SchroMotionField *mask_mf,
1644
SchroMetricScan scan;
1645
SchroMotionVector *mv;
1646
SchroMotionField *mf;
1647
SchroMotionVector *hint_mv;
1648
SchroMotionField *hint_mf;
1649
SchroMotionVector *mask_mv;
1650
SchroParams *params = me->params;
1655
scan.frame = get_downsampled (me->encoder_frame, 0);
1657
scan.ref_frame = get_downsampled (me->encoder_frame->ref_frame0, 0);
1659
scan.ref_frame = get_downsampled (me->encoder_frame->ref_frame1, 0);
1662
hint_mf = me->downsampled_mf[ref][2];
1663
mf = schro_motion_field_new (params->x_num_blocks, params->y_num_blocks);
1665
schro_motion_field_set (mf, 2, 1<<ref);
1667
scan.block_width = params->xbsep_luma;
1668
scan.block_height = params->ybsep_luma;
1669
scan.gravity_scale = 0;
1673
for(j=0;j<params->y_num_blocks;j++){
1674
for(i=0;i<params->x_num_blocks;i++){
1677
mask_mv = motion_field_get (mask_mf, i&(~3), j&(~3));
1679
//if (mask_mv->metric != SCHRO_METRIC_INVALID) continue;
1681
hint_mv = motion_field_get (hint_mf, i, j);
1683
scan.x = i * params->xbsep_luma;
1684
scan.y = j * params->ybsep_luma;
1685
schro_metric_scan_setup (&scan, hint_mv->dx[ref], hint_mv->dy[ref],
1688
mv = motion_field_get (mf, i, j);
1689
if (scan.scan_width <= 0 || scan.scan_height <= 0) {
1690
mv->pred_mode = 1<<ref;
1694
mv->metric = SCHRO_METRIC_INVALID;
1698
schro_metric_scan_do_scan (&scan);
1699
mv->metric = schro_metric_scan_get_min (&scan, &dx, &dy);
1705
mv->pred_mode = 1<<ref;
1706
if (mv->metric > (scan.block_width * scan.block_height)*50) {
1707
mv->metric = SCHRO_METRIC_INVALID;
1716
schro_encoder_dc_predict (SchroEncoderFrame *frame, int i, int j)
1718
SchroParams *params = &frame->params;
1720
int chroma_w, chroma_h;
1721
SchroFrame *orig_frame = frame->filtered_frame;
1722
SchroMotionVectorDC *mvdc;
1724
luma_w = params->xbsep_luma;
1725
luma_h = params->xbsep_luma;
1726
chroma_w = luma_w>>params->video_format->chroma_h_shift;
1727
chroma_h = luma_h>>params->video_format->chroma_v_shift;
1729
mvdc = SCHRO_MOTION_GET_DC_BLOCK (frame->motion, i, j);
1731
memset(mvdc, 0, sizeof(*mvdc));
1732
mvdc->pred_mode = 0;
1734
mvdc->using_global = 0;
1735
schro_block_average (&mvdc->dc[0], orig_frame->components + 0,
1736
i*luma_w, j*luma_h, luma_w, luma_h);
1737
schro_block_average (&mvdc->dc[1], orig_frame->components + 1,
1738
i*chroma_w, j*chroma_h, chroma_w, chroma_h);
1739
schro_block_average (&mvdc->dc[2], orig_frame->components + 2,
1740
i*chroma_w, j*chroma_h, chroma_w, chroma_h);
1742
mvdc->metric = DC_METRIC*8*8;
1745
1212
#define MAGIC_SUPERBLOCK_METRIC 5
1746
1213
#define MAGIC_BLOCK_METRIC 50
1749
schro_encoder_bigblock2_estimation (SchroMotionEst *me)
1216
schro_encoder_bigblock_estimation (SchroMotionEst *me)
1751
1218
SchroParams *params = me->params;
1806
1281
me->encoder_frame->mc_error = total_error;
1810
schro_encoder_bigblock_estimation (SchroMotionEst *me)
1812
SchroMotionField *mf1;
1813
SchroMotionField *mf2 = NULL;
1814
SchroMotionField *mf3;
1815
SchroMotionField *mf4 = NULL;
1816
SchroMotionVector *mv;
1817
SchroMotionVector *mv1;
1818
SchroMotionVector *mv2;
1819
SchroParams *params = me->params;
1824
n = params->xbsep_luma * params->ybsep_luma;
1826
mf1 = schro_motionest_superblock_scan (me, 0, 4);
1827
schro_motion_field_lshift (mf1, params->mv_precision);
1829
mf3 = schro_motionest_block_scan (me, mf1, 0);
1831
if (me->encoder_frame->num_refs > 1) {
1832
mf2 = schro_motionest_superblock_scan (me, 1, 4);
1833
schro_motion_field_lshift (mf2, params->mv_precision);
1835
mf4 = schro_motionest_block_scan (me, mf2, 1);
1838
for(j=0;j<params->y_num_blocks;j+=4){
1839
for(i=0;i<params->x_num_blocks;i+=4){
1840
mv = SCHRO_MOTION_GET_BLOCK (me->motion, i, j);
1842
if (me->encoder_frame->num_refs == 1) {
1843
mv1 = motion_field_get (mf1, i, j);
1844
if (mv1->metric < n*MAGIC_SUPERBLOCK_METRIC) {
1847
schro_motion_splat_4x4 (me->motion, i, j);
1853
mv1 = motion_field_get (mf1, i, j);
1854
mv2 = motion_field_get (mf2, i, j);
1856
if (mv1->metric < n*MAGIC_SUPERBLOCK_METRIC) pred_mode |= 1;
1857
if (mv2->metric < n*MAGIC_SUPERBLOCK_METRIC) pred_mode |= 2;
1859
if (pred_mode != 0) {
1860
mv->pred_mode = pred_mode;
1862
mv->dx[0] = mv1->dx[0];
1863
mv->dy[0] = mv1->dy[0];
1864
mv->dx[1] = mv2->dx[1];
1865
mv->dy[1] = mv2->dy[1];
1866
mv->metric = MIN(mv1->metric, mv2->metric);
1868
schro_motion_splat_4x4 (me->motion, i, j);
1873
for(l=j;l<j+4;l++) {
1874
for(k=i;k<i+4;k++) {
1875
mv = SCHRO_MOTION_GET_BLOCK (me->motion, k, l);
1877
if (me->encoder_frame->num_refs == 1) {
1878
mv1 = motion_field_get (mf3, k, l);
1879
if (mv1->metric < n*MAGIC_BLOCK_METRIC) {
1888
mv1 = motion_field_get (mf3, k, l);
1889
mv2 = motion_field_get (mf4, k, l);
1891
if (mv1->metric < n*MAGIC_BLOCK_METRIC) pred_mode |= 1;
1892
if (mv2->metric < n*MAGIC_BLOCK_METRIC) pred_mode |= 2;
1894
if (pred_mode == 3) {
1895
if (mv1->metric < mv2->metric/2) {
1897
} else if (mv2->metric < mv1->metric/2) {
1902
if (pred_mode != 0) {
1903
mv->pred_mode = pred_mode;
1905
mv->dx[0] = mv1->dx[0];
1906
mv->dy[0] = mv1->dy[0];
1907
mv->dx[1] = mv2->dx[1];
1908
mv->dy[1] = mv2->dy[1];
1909
mv->metric = MIN(mv1->metric, mv2->metric);
1914
schro_encoder_dc_predict (me->encoder_frame, k, l);
1919
schro_motion_cleanup (me->motion,
1920
(params->video_format->width + params->xbsep_luma - 1)/params->xbsep_luma,
1921
(params->video_format->height + params->ybsep_luma - 1)/params->ybsep_luma);
1923
schro_motion_field_free (mf1);
1924
schro_motion_field_free (mf3);
1925
if (me->encoder_frame->num_refs > 1) {
1926
schro_motion_field_free (mf2);
1927
schro_motion_field_free (mf4);
1934
1285
schro_motion_block_estimate_entropy (SchroMotion *motion, int i, int j)
2069
1421
SchroFrameData ref0_data;
2070
1422
SchroFrameData ref1_data;
2072
schro_frame_get_subdata (get_downsampled (me->encoder_frame->ref_frame0, 0),
1424
if (i*me->params->xbsep_luma + mv->dx[0] < 0 ||
1425
j*me->params->ybsep_luma + mv->dy[0] < 0 ||
1426
i*me->params->xbsep_luma + mv->dx[1] < 0 ||
1427
j*me->params->ybsep_luma + mv->dy[1] < 0) {
1428
return SCHRO_METRIC_INVALID_2;
1431
schro_frame_get_subdata (get_downsampled (me->encoder_frame->ref_frame[0], 0),
2073
1432
&ref0_data, 0, i*me->params->xbsep_luma + mv->dx[0],
2074
1433
j*me->params->ybsep_luma + mv->dy[0]);
2075
schro_frame_get_subdata (get_downsampled (me->encoder_frame->ref_frame1, 0),
1434
schro_frame_get_subdata (get_downsampled (me->encoder_frame->ref_frame[1], 0),
2076
1435
&ref1_data, 0, i*me->params->xbsep_luma + mv->dx[1],
2077
1436
j*me->params->ybsep_luma + mv->dy[1]);
2079
1438
if (ref0_data.width < width || ref0_data.height < height ||
2080
1439
ref1_data.width < width || ref1_data.height < height) {
2081
return SCHRO_METRIC_INVALID;
1440
return SCHRO_METRIC_INVALID_2;
2084
1443
return schro_metric_get_biref (&orig, &ref0_data, 1, &ref1_data, 1, 1, width, height);