Mercurial > libavcodec.hg
annotate h264_direct.c @ 11092:64c36264b13f libavcodec
Set direct MB partitioning for 16x8 and 8x16 colocated MBs to the respective true partitioning.
author | michael |
---|---|
date | Sun, 07 Feb 2010 17:40:22 +0000 |
parents | 74748a220032 |
children | 788db3371366 |
rev | line source |
---|---|
1168 | 1 /* |
10857
b20434143fd5
Split direct mode (macro)block decoding off h264.c.
michael
parents:
10854
diff
changeset
|
2 * H.26L/H.264/AVC/JVT/14496-10/... direct mb/block decoding |
1168 | 3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> |
4 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1168 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1168 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1168 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3927
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
3029
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1168 | 20 */ |
2967 | 21 |
1168 | 22 /** |
10857
b20434143fd5
Split direct mode (macro)block decoding off h264.c.
michael
parents:
10854
diff
changeset
|
23 * @file libavcodec/h264_direct.c |
b20434143fd5
Split direct mode (macro)block decoding off h264.c.
michael
parents:
10854
diff
changeset
|
24 * H.264 / AVC / MPEG4 part10 direct mb/block decoding. |
1168 | 25 * @author Michael Niedermayer <michaelni@gmx.at> |
26 */ | |
27 | |
9012
15a3df8c01fd
More approved hunks for VAAPI & our new and cleaner hwaccel API.
michael
parents:
9004
diff
changeset
|
28 #include "internal.h" |
1168 | 29 #include "dsputil.h" |
30 #include "avcodec.h" | |
31 #include "mpegvideo.h" | |
4975 | 32 #include "h264.h" |
10864 | 33 #include "h264_mvpred.h" |
6020 | 34 #include "rectangle.h" |
1168 | 35 |
3284
a224d9752912
don't force asserts in release builds. 2% faster h264.
lorenm
parents:
3219
diff
changeset
|
36 //#undef NDEBUG |
1168 | 37 #include <assert.h> |
38 | |
39 | |
7898
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
40 static int get_scale_factor(H264Context * const h, int poc, int poc1, int i){ |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
41 int poc0 = h->ref_list[0][i].poc; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
42 int td = av_clip(poc1 - poc0, -128, 127); |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
43 if(td == 0 || h->ref_list[0][i].long_ref){ |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
44 return 256; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
45 }else{ |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
46 int tb = av_clip(poc - poc0, -128, 127); |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
47 int tx = (16384 + (FFABS(td) >> 1)) / td; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
48 return av_clip((tb*tx + 32) >> 6, -1024, 1023); |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
49 } |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
50 } |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
51 |
10857
b20434143fd5
Split direct mode (macro)block decoding off h264.c.
michael
parents:
10854
diff
changeset
|
52 void ff_h264_direct_dist_scale_factor(H264Context * const h){ |
7462
5cbf11f56c02
Picture.ref_count/ref_poc have to be stored per field (actually also per
michael
parents:
7450
diff
changeset
|
53 MpegEncContext * const s = &h->s; |
5cbf11f56c02
Picture.ref_count/ref_poc have to be stored per field (actually also per
michael
parents:
7450
diff
changeset
|
54 const int poc = h->s.current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ]; |
2396 | 55 const int poc1 = h->ref_list[1][0].poc; |
7898
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
56 int i, field; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
57 for(field=0; field<2; field++){ |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
58 const int poc = h->s.current_picture_ptr->field_poc[field]; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
59 const int poc1 = h->ref_list[1][0].field_poc[field]; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
60 for(i=0; i < 2*h->ref_count[0]; i++) |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
61 h->dist_scale_factor_field[field][i^field] = get_scale_factor(h, poc, poc1, i+16); |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
62 } |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
63 |
2396 | 64 for(i=0; i<h->ref_count[0]; i++){ |
7898
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
65 h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i); |
3316 | 66 } |
2396 | 67 } |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
68 |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
69 static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){ |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
70 MpegEncContext * const s = &h->s; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
71 Picture * const ref1 = &h->ref_list[1][0]; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
72 int j, old_ref, rfield; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
73 int start= mbafi ? 16 : 0; |
11086 | 74 int end = mbafi ? 16+2*h->ref_count[0] : h->ref_count[0]; |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
75 int interl= mbafi || s->picture_structure != PICT_FRAME; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
76 |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
77 /* bogus; fills in for missing frames */ |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
78 memset(map[list], 0, sizeof(map[list])); |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
79 |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
80 for(rfield=0; rfield<2; rfield++){ |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
81 for(old_ref=0; old_ref<ref1->ref_count[colfield][list]; old_ref++){ |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
82 int poc = ref1->ref_poc[colfield][list][old_ref]; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
83 |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
84 if (!interl) |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
85 poc |= 3; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
86 else if( interl && (poc&3) == 3) //FIXME store all MBAFF references so this isnt needed |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
87 poc= (poc&~3) + rfield + 1; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
88 |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
89 for(j=start; j<end; j++){ |
11086 | 90 if(4*h->ref_list[0][j].frame_num + (h->ref_list[0][j].reference&3) == poc){ |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
91 int cur_ref= mbafi ? (j-16)^field : j; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
92 map[list][2*old_ref + (rfield^field) + 16] = cur_ref; |
11086 | 93 if(rfield == field || !interl) |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
94 map[list][old_ref] = cur_ref; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
95 break; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
96 } |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
97 } |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
98 } |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
99 } |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
100 } |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
101 |
10857
b20434143fd5
Split direct mode (macro)block decoding off h264.c.
michael
parents:
10854
diff
changeset
|
102 void ff_h264_direct_ref_list_init(H264Context * const h){ |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
103 MpegEncContext * const s = &h->s; |
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
104 Picture * const ref1 = &h->ref_list[1][0]; |
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
105 Picture * const cur = s->current_picture_ptr; |
7928 | 106 int list, j, field; |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
107 int sidx= (s->picture_structure&1)^1; |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
108 int ref1sidx= (ref1->reference&1)^1; |
7907 | 109 |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
110 for(list=0; list<2; list++){ |
7462
5cbf11f56c02
Picture.ref_count/ref_poc have to be stored per field (actually also per
michael
parents:
7450
diff
changeset
|
111 cur->ref_count[sidx][list] = h->ref_count[list]; |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
112 for(j=0; j<h->ref_count[list]; j++) |
7487
13937730e79d
Use frame_num and reference instead of poc for matching frames for direct
michael
parents:
7486
diff
changeset
|
113 cur->ref_poc[sidx][list][j] = 4*h->ref_list[list][j].frame_num + (h->ref_list[list][j].reference&3); |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
114 } |
7907 | 115 |
7482 | 116 if(s->picture_structure == PICT_FRAME){ |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
117 memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0])); |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
118 memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0])); |
7482 | 119 } |
7907 | 120 |
7902
8b8be8f2b647
Fix ref_shift so that it is correct for more/all? MBAFF/PAFF mixes.
michael
parents:
7901
diff
changeset
|
121 cur->mbaff= FRAME_MBAFF; |
7907 | 122 |
6481 | 123 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred) |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
124 return; |
7907 | 125 |
11085
27b5a2bd1dfe
Fix reference selection for colocated MBs from frames to fields.
michael
parents:
11084
diff
changeset
|
126 if(s->picture_structure == PICT_FRAME){ |
27b5a2bd1dfe
Fix reference selection for colocated MBs from frames to fields.
michael
parents:
11084
diff
changeset
|
127 int cur_poc = s->current_picture_ptr->poc; |
27b5a2bd1dfe
Fix reference selection for colocated MBs from frames to fields.
michael
parents:
11084
diff
changeset
|
128 int *col_poc = h->ref_list[1]->field_poc; |
27b5a2bd1dfe
Fix reference selection for colocated MBs from frames to fields.
michael
parents:
11084
diff
changeset
|
129 ref1sidx=sidx= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc)); |
27b5a2bd1dfe
Fix reference selection for colocated MBs from frames to fields.
michael
parents:
11084
diff
changeset
|
130 } |
27b5a2bd1dfe
Fix reference selection for colocated MBs from frames to fields.
michael
parents:
11084
diff
changeset
|
131 |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
132 for(list=0; list<2; list++){ |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
133 fill_colmap(h, h->map_col_to_list0, list, sidx, ref1sidx, 0); |
11088
1bfb70c225bb
Skip the fill_colmap() case thats for MBAFF if we dont have an MBAFF frame.
michael
parents:
11086
diff
changeset
|
134 if(FRAME_MBAFF) |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
135 for(field=0; field<2; field++) |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
136 fill_colmap(h, h->map_col_to_list0_field[field], list, field, field, 1); |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
137 } |
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
138 } |
2396 | 139 |
10857
b20434143fd5
Split direct mode (macro)block decoding off h264.c.
michael
parents:
10854
diff
changeset
|
140 void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type){ |
2396 | 141 MpegEncContext * const s = &h->s; |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
142 int b8_stride = h->b8_stride; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
143 int b4_stride = h->b_stride; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
144 int mb_xy = h->mb_xy; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
145 int mb_type_col[2]; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
146 const int16_t (*l1mv0)[2], (*l1mv1)[2]; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
147 const int8_t *l1ref0, *l1ref1; |
2396 | 148 const int is_b8x8 = IS_8X8(*mb_type); |
4365
9cebff821565
checking bitstream values and other related changes
michael
parents:
4364
diff
changeset
|
149 unsigned int sub_mb_type; |
2396 | 150 int i8, i4; |
151 | |
9416
d863de897b41
Assert that the first list1 entry is a reference frame.
michael
parents:
9415
diff
changeset
|
152 assert(h->ref_list[1][0].reference&3); |
d863de897b41
Assert that the first list1 entry is a reference frame.
michael
parents:
9415
diff
changeset
|
153 |
3316 | 154 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM) |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
155 |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
156 if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL |
7900 | 157 if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL |
7901 | 158 int cur_poc = s->current_picture_ptr->poc; |
159 int *col_poc = h->ref_list[1]->field_poc; | |
160 int col_parity = FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc); | |
161 mb_xy= s->mb_x + ((s->mb_y&~1) + col_parity)*s->mb_stride; | |
162 b8_stride = 0; | |
7918
84b37de61d98
Field -> MBAFF direct mode can use data from fields that are not
michael
parents:
7907
diff
changeset
|
163 }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){// FL -> FL & differ parity |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
164 int fieldoff= 2*(h->ref_list[1][0].reference)-3; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
165 mb_xy += s->mb_stride*fieldoff; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
166 } |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
167 goto single_col; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
168 }else{ // AFL/AFR/FR/FL -> AFR/FR |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
169 if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
170 mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
171 mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
172 mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
173 b8_stride *= 3; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
174 b4_stride *= 6; |
11090
eda7b4f6db51
Remove FIXMEs for cases that are disallowed by the spec.
michael
parents:
11088
diff
changeset
|
175 |
11091 | 176 sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
177 if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
178 && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
179 && !is_b8x8){ |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
180 *mb_type |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2; /* B_16x8 */ |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
181 }else{ |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
182 *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1; |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
183 } |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
184 }else{ // AFR/FR -> AFR/FR |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
185 single_col: |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
186 mb_type_col[0] = |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
187 mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; |
7494 | 188 if(IS_8X8(mb_type_col[0]) && !h->sps.direct_8x8_inference_flag){ |
189 /* FIXME save sub mb types from previous frames (or derive from MVs) | |
190 * so we know exactly what block size to use */ | |
191 sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_4x4 */ | |
192 *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1; | |
193 }else if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){ | |
194 sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ | |
195 *mb_type |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_16x16 */ | |
11092
64c36264b13f
Set direct MB partitioning for 16x8 and 8x16 colocated MBs to the respective true partitioning.
michael
parents:
11091
diff
changeset
|
196 }else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){ |
64c36264b13f
Set direct MB partitioning for 16x8 and 8x16 colocated MBs to the respective true partitioning.
michael
parents:
11091
diff
changeset
|
197 sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ |
64c36264b13f
Set direct MB partitioning for 16x8 and 8x16 colocated MBs to the respective true partitioning.
michael
parents:
11091
diff
changeset
|
198 *mb_type |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16)); |
7494 | 199 }else{ |
200 sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ | |
201 *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1; | |
202 } | |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
203 } |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
204 } |
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
205 |
7497 | 206 l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; |
207 l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; | |
208 l1ref0 = &h->ref_list[1][0].ref_index [0][h->mb2b8_xy[mb_xy]]; | |
209 l1ref1 = &h->ref_list[1][0].ref_index [1][h->mb2b8_xy[mb_xy]]; | |
7496 | 210 if(!b8_stride){ |
211 if(s->mb_y&1){ | |
212 l1ref0 += h->b8_stride; | |
213 l1ref1 += h->b8_stride; | |
214 l1mv0 += 2*b4_stride; | |
215 l1mv1 += 2*b4_stride; | |
216 } | |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
217 } |
2967 | 218 |
2396 | 219 if(h->direct_spatial_mv_pred){ |
220 int ref[2]; | |
221 int mv[2][2]; | |
222 int list; | |
223 | |
3316 | 224 /* FIXME interlacing + spatial direct uses wrong colocated block positions */ |
225 | |
2396 | 226 /* ref = min(neighbors) */ |
227 for(list=0; list<2; list++){ | |
228 int refa = h->ref_cache[list][scan8[0] - 1]; | |
229 int refb = h->ref_cache[list][scan8[0] - 8]; | |
230 int refc = h->ref_cache[list][scan8[0] - 8 + 4]; | |
7445
a202753ce99d
Use #define instead of a constant. Patch by Paul Kendall.
darkshikari
parents:
7444
diff
changeset
|
231 if(refc == PART_NOT_AVAILABLE) |
2396 | 232 refc = h->ref_cache[list][scan8[0] - 8 - 1]; |
7336
aaf3e396f094
Simplify spatial direct ref selection with FFMIN3()
michael
parents:
7332
diff
changeset
|
233 ref[list] = FFMIN3((unsigned)refa, (unsigned)refb, (unsigned)refc); |
2396 | 234 if(ref[list] < 0) |
235 ref[list] = -1; | |
236 } | |
237 | |
238 if(ref[0] < 0 && ref[1] < 0){ | |
239 ref[0] = ref[1] = 0; | |
240 mv[0][0] = mv[0][1] = | |
241 mv[1][0] = mv[1][1] = 0; | |
242 }else{ | |
243 for(list=0; list<2; list++){ | |
244 if(ref[list] >= 0) | |
245 pred_motion(h, 0, 4, list, ref[list], &mv[list][0], &mv[list][1]); | |
246 else | |
247 mv[list][0] = mv[list][1] = 0; | |
248 } | |
249 } | |
250 | |
251 if(ref[1] < 0){ | |
6309 | 252 if(!is_b8x8) |
253 *mb_type &= ~MB_TYPE_L1; | |
254 sub_mb_type &= ~MB_TYPE_L1; | |
2396 | 255 }else if(ref[0] < 0){ |
6309 | 256 if(!is_b8x8) |
257 *mb_type &= ~MB_TYPE_L0; | |
258 sub_mb_type &= ~MB_TYPE_L0; | |
259 } | |
260 | |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
261 if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ |
6309 | 262 for(i8=0; i8<4; i8++){ |
263 int x8 = i8&1; | |
264 int y8 = i8>>1; | |
265 int xy8 = x8+y8*b8_stride; | |
266 int xy4 = 3*x8+y8*b4_stride; | |
267 int a=0, b=0; | |
268 | |
269 if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) | |
270 continue; | |
271 h->sub_mb_type[i8] = sub_mb_type; | |
272 | |
273 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); | |
274 fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); | |
11078
e1eb8879e368
Long term references behave different from short term in spatial direct MV calculation.
michael
parents:
10929
diff
changeset
|
275 if(!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref |
6309 | 276 && ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1) |
277 || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){ | |
278 if(ref[0] > 0) | |
279 a= pack16to32(mv[0][0],mv[0][1]); | |
280 if(ref[1] > 0) | |
281 b= pack16to32(mv[1][0],mv[1][1]); | |
282 }else{ | |
283 a= pack16to32(mv[0][0],mv[0][1]); | |
284 b= pack16to32(mv[1][0],mv[1][1]); | |
285 } | |
286 fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4); | |
287 fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4); | |
288 } | |
289 }else if(IS_16X16(*mb_type)){ | |
4540 | 290 int a=0, b=0; |
291 | |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
292 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); |
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
293 fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); |
11078
e1eb8879e368
Long term references behave different from short term in spatial direct MV calculation.
michael
parents:
10929
diff
changeset
|
294 if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref |
4001 | 295 && ( (l1ref0[0] == 0 && FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][1]) <= 1) |
296 || (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1 | |
2834 | 297 && (h->x264_build>33 || !h->x264_build)))){ |
2396 | 298 if(ref[0] > 0) |
4540 | 299 a= pack16to32(mv[0][0],mv[0][1]); |
2396 | 300 if(ref[1] > 0) |
4540 | 301 b= pack16to32(mv[1][0],mv[1][1]); |
2396 | 302 }else{ |
4540 | 303 a= pack16to32(mv[0][0],mv[0][1]); |
304 b= pack16to32(mv[1][0],mv[1][1]); | |
305 } | |
306 fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, a, 4); | |
307 fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, b, 4); | |
2396 | 308 }else{ |
309 for(i8=0; i8<4; i8++){ | |
310 const int x8 = i8&1; | |
311 const int y8 = i8>>1; | |
2967 | 312 |
2396 | 313 if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) |
314 continue; | |
315 h->sub_mb_type[i8] = sub_mb_type; | |
2967 | 316 |
2396 | 317 fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mv[0][0],mv[0][1]), 4); |
318 fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mv[1][0],mv[1][1]), 4); | |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
319 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); |
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
320 fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); |
2967 | 321 |
2396 | 322 /* col_zero_flag */ |
11078
e1eb8879e368
Long term references behave different from short term in spatial direct MV calculation.
michael
parents:
10929
diff
changeset
|
323 if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( l1ref0[x8 + y8*b8_stride] == 0 |
7498
e7006afcb1c6
Use local variabes for *stride, where local variables exist.
michael
parents:
7497
diff
changeset
|
324 || (l1ref0[x8 + y8*b8_stride] < 0 && l1ref1[x8 + y8*b8_stride] == 0 |
2834 | 325 && (h->x264_build>33 || !h->x264_build)))){ |
7498
e7006afcb1c6
Use local variabes for *stride, where local variables exist.
michael
parents:
7497
diff
changeset
|
326 const int16_t (*l1mv)[2]= l1ref0[x8 + y8*b8_stride] == 0 ? l1mv0 : l1mv1; |
3002 | 327 if(IS_SUB_8X8(sub_mb_type)){ |
7498
e7006afcb1c6
Use local variabes for *stride, where local variables exist.
michael
parents:
7497
diff
changeset
|
328 const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride]; |
4001 | 329 if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){ |
3002 | 330 if(ref[0] == 0) |
331 fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); | |
332 if(ref[1] == 0) | |
333 fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); | |
334 } | |
335 }else | |
2396 | 336 for(i4=0; i4<4; i4++){ |
7498
e7006afcb1c6
Use local variabes for *stride, where local variables exist.
michael
parents:
7497
diff
changeset
|
337 const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride]; |
4001 | 338 if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){ |
2396 | 339 if(ref[0] == 0) |
340 *(uint32_t*)h->mv_cache[0][scan8[i8*4+i4]] = 0; | |
341 if(ref[1] == 0) | |
342 *(uint32_t*)h->mv_cache[1][scan8[i8*4+i4]] = 0; | |
343 } | |
344 } | |
345 } | |
346 } | |
347 } | |
348 }else{ /* direct temporal mv pred */ | |
3316 | 349 const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]}; |
350 const int *dist_scale_factor = h->dist_scale_factor; | |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
351 int ref_offset= 0; |
3316 | 352 |
7494 | 353 if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){ |
7898
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
354 map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0]; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
355 map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1]; |
a33287a39a55
Make MBAFF temporal direct mode closer to the spec.
michael
parents:
7897
diff
changeset
|
356 dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1]; |
7902
8b8be8f2b647
Fix ref_shift so that it is correct for more/all? MBAFF/PAFF mixes.
michael
parents:
7901
diff
changeset
|
357 } |
8b8be8f2b647
Fix ref_shift so that it is correct for more/all? MBAFF/PAFF mixes.
michael
parents:
7901
diff
changeset
|
358 if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
359 ref_offset += 16; |
7902
8b8be8f2b647
Fix ref_shift so that it is correct for more/all? MBAFF/PAFF mixes.
michael
parents:
7901
diff
changeset
|
360 |
7494 | 361 if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ |
7495 | 362 int y_shift = 2*!IS_INTERLACED(*mb_type); |
11084
6e564ab180d1
Add assert(sps.direct_8x8_inference_flag) to FIXME comment.
michael
parents:
11083
diff
changeset
|
363 assert(h->sps.direct_8x8_inference_flag); |
7494 | 364 |
365 for(i8=0; i8<4; i8++){ | |
366 const int x8 = i8&1; | |
367 const int y8 = i8>>1; | |
368 int ref0, scale; | |
369 const int16_t (*l1mv)[2]= l1mv0; | |
370 | |
371 if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) | |
372 continue; | |
373 h->sub_mb_type[i8] = sub_mb_type; | |
374 | |
375 fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1); | |
376 if(IS_INTRA(mb_type_col[y8])){ | |
377 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1); | |
378 fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); | |
379 fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); | |
380 continue; | |
3316 | 381 } |
382 | |
7494 | 383 ref0 = l1ref0[x8 + y8*b8_stride]; |
384 if(ref0 >= 0) | |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
385 ref0 = map_col_to_list0[0][ref0 + ref_offset]; |
7494 | 386 else{ |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
387 ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset]; |
7494 | 388 l1mv= l1mv1; |
3316 | 389 } |
7494 | 390 scale = dist_scale_factor[ref0]; |
391 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1); | |
392 | |
393 { | |
394 const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride]; | |
395 int my_col = (mv_col[1]<<y_shift)/2; | |
396 int mx = (scale * mv_col[0] + 128) >> 8; | |
397 int my = (scale * my_col + 128) >> 8; | |
398 fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4); | |
399 fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4); | |
400 } | |
401 } | |
402 return; | |
403 } | |
3316 | 404 |
405 /* one-to-one mv scaling */ | |
406 | |
2396 | 407 if(IS_16X16(*mb_type)){ |
4541 | 408 int ref, mv0, mv1; |
409 | |
2396 | 410 fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1); |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
411 if(IS_INTRA(mb_type_col[0])){ |
4541 | 412 ref=mv0=mv1=0; |
2396 | 413 }else{ |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
414 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset] |
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
415 : map_col_to_list0[1][l1ref1[0] + ref_offset]; |
3316 | 416 const int scale = dist_scale_factor[ref0]; |
2809
75400dfbe117
fixing colocated mv if colocated block is L1 predicted for the temporal direct case
michael
parents:
2808
diff
changeset
|
417 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0]; |
2396 | 418 int mv_l0[2]; |
3316 | 419 mv_l0[0] = (scale * mv_col[0] + 128) >> 8; |
420 mv_l0[1] = (scale * mv_col[1] + 128) >> 8; | |
4541 | 421 ref= ref0; |
422 mv0= pack16to32(mv_l0[0],mv_l0[1]); | |
423 mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]); | |
424 } | |
425 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); | |
426 fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4); | |
427 fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4); | |
2396 | 428 }else{ |
429 for(i8=0; i8<4; i8++){ | |
430 const int x8 = i8&1; | |
431 const int y8 = i8>>1; | |
3316 | 432 int ref0, scale; |
2834 | 433 const int16_t (*l1mv)[2]= l1mv0; |
2809
75400dfbe117
fixing colocated mv if colocated block is L1 predicted for the temporal direct case
michael
parents:
2808
diff
changeset
|
434 |
2396 | 435 if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) |
436 continue; | |
437 h->sub_mb_type[i8] = sub_mb_type; | |
3316 | 438 fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1); |
7493
e5b93d01b472
Factorize some code between temporal and spatial direct mode.
michael
parents:
7488
diff
changeset
|
439 if(IS_INTRA(mb_type_col[0])){ |
2396 | 440 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1); |
441 fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); | |
442 fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); | |
443 continue; | |
444 } | |
2967 | 445 |
11083
a270b4c67089
ref_offset must be added after checking references validity.
michael
parents:
11078
diff
changeset
|
446 ref0 = l1ref0[x8 + y8*b8_stride]; |
2537
14fef0f3f532
H.264: decode arbitrary frame orders and allow B-frames as references.
lorenm
parents:
2536
diff
changeset
|
447 if(ref0 >= 0) |
11083
a270b4c67089
ref_offset must be added after checking references validity.
michael
parents:
11078
diff
changeset
|
448 ref0 = map_col_to_list0[0][ref0 + ref_offset]; |
2809
75400dfbe117
fixing colocated mv if colocated block is L1 predicted for the temporal direct case
michael
parents:
2808
diff
changeset
|
449 else{ |
7906
5be944626072
Another try to fix temporal direct mode references.
michael
parents:
7902
diff
changeset
|
450 ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset]; |
2809
75400dfbe117
fixing colocated mv if colocated block is L1 predicted for the temporal direct case
michael
parents:
2808
diff
changeset
|
451 l1mv= l1mv1; |
75400dfbe117
fixing colocated mv if colocated block is L1 predicted for the temporal direct case
michael
parents:
2808
diff
changeset
|
452 } |
3316 | 453 scale = dist_scale_factor[ref0]; |
2967 | 454 |
2396 | 455 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1); |
3002 | 456 if(IS_SUB_8X8(sub_mb_type)){ |
7498
e7006afcb1c6
Use local variabes for *stride, where local variables exist.
michael
parents:
7497
diff
changeset
|
457 const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride]; |
3316 | 458 int mx = (scale * mv_col[0] + 128) >> 8; |
459 int my = (scale * mv_col[1] + 128) >> 8; | |
3002 | 460 fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4); |
461 fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4); | |
462 }else | |
2396 | 463 for(i4=0; i4<4; i4++){ |
7498
e7006afcb1c6
Use local variabes for *stride, where local variables exist.
michael
parents:
7497
diff
changeset
|
464 const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride]; |
2396 | 465 int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]]; |
3316 | 466 mv_l0[0] = (scale * mv_col[0] + 128) >> 8; |
467 mv_l0[1] = (scale * mv_col[1] + 128) >> 8; | |
2396 | 468 *(uint32_t*)h->mv_cache[1][scan8[i8*4+i4]] = |
469 pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]); | |
470 } | |
471 } | |
472 } | |
473 } | |
474 } |