42 int td = av_clip(poc1 - poc0, -128, 127);
46 int tb = av_clip(poc - poc0, -128, 127);
47 int tx = (16384 + (
FFABS(td) >> 1)) / td;
48 return av_clip((tb*tx + 32) >> 6, -1024, 1023);
58 for (field = 0; field < 2; field++){
73 int j, old_ref, rfield;
74 int start= mbafi ? 16 : 0;
79 memset(map[list], 0,
sizeof(map[list]));
81 for(rfield=0; rfield<2; rfield++){
82 for(old_ref=0; old_ref<ref1->
ref_count[colfield][list]; old_ref++){
83 int poc = ref1->
ref_poc[colfield][list][old_ref];
87 else if( interl && (poc&3) == 3)
88 poc= (poc&~3) + rfield + 1;
90 for(j=start; j<end; j++){
92 int cur_ref= mbafi ? (j-16)^field : j;
94 map[list][2 * old_ref + (rfield^field) + 16] = cur_ref;
95 if(rfield == field || !interl)
96 map[list][old_ref] = cur_ref;
111 for(list=0; list<2; list++){
137 for(list=0; list<2; list++){
140 for(field=0; field<2; field++)
149 int ref_height = 16*h->
mb_height >> ref_field_picture;
158 FFMIN(16 * mb_y >> ref_field_picture, ref_height - 1),
159 ref_field_picture && ref_field);
167 const int16_t (*l1mv0)[2], (*l1mv1)[2];
168 const int8_t *l1ref0, *l1ref1;
169 const int is_b8x8 =
IS_8X8(*mb_type);
180 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
184 for(list=0; list<2; list++){
193 ref[list] =
FFMIN3((
unsigned)left_ref, (
unsigned)top_ref, (
unsigned)refc);
199 int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]);
204 assert(match_count==1);
205 if(left_ref==ref[list]){
207 }
else if(top_ref==ref[list]){
222 if(ref[0] < 0 && ref[1] < 0){
229 if(!(is_b8x8|mv[0]|mv[1])){
300 l1mv0 += 2*b4_stride;
301 l1mv1 += 2*b4_stride;
308 for(i8=0; i8<4; i8++){
311 int xy8 = x8+y8*b8_stride;
312 int xy4 = 3*x8+y8*b4_stride;
322 && ( (l1ref0[xy8] == 0 &&
FFABS(l1mv0[xy4][0]) <= 1 &&
FFABS(l1mv0[xy4][1]) <= 1)
323 || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 &&
FFABS(l1mv1[xy4][0]) <= 1 &&
FFABS(l1mv1[xy4][1]) <= 1))){
337 if(!is_b8x8 && !(n&3))
345 && ( (l1ref0[0] == 0 &&
FFABS(l1mv0[0][0]) <= 1 &&
FFABS(l1mv0[0][1]) <= 1)
346 || (l1ref0[0] < 0 && l1ref1[0] == 0 &&
FFABS(l1mv1[0][0]) <= 1 &&
FFABS(l1mv1[0][1]) <= 1
361 for(i8=0; i8<4; i8++){
363 const int y8 = i8>>1;
374 assert(b8_stride==2);
377 || (l1ref0[i8] < 0 && l1ref1[i8] == 0
379 const int16_t (*l1mv)[2]= l1ref0[i8] == 0 ? l1mv0 : l1mv1;
381 const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
382 if(
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1){
391 for(i4=0; i4<4; i4++){
392 const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
393 if(
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1){
407 if(!is_b8x8 && !(n&15))
417 const int16_t (*l1mv0)[2], (*l1mv1)[2];
418 const int8_t *l1ref0, *l1ref1;
419 const int is_b8x8 =
IS_8X8(*mb_type);
490 l1mv0 += 2*b4_stride;
491 l1mv1 += 2*b4_stride;
505 ref_offset = (h->
ref_list[1][0].
mbaff<<4) & (mb_type_col[0]>>3);
511 for(i8=0; i8<4; i8++){
513 const int y8 = i8>>1;
515 const int16_t (*l1mv)[2]= l1mv0;
529 ref0 = l1ref0[x8 + y8*b8_stride];
531 ref0 = map_col_to_list0[0][ref0 + ref_offset];
533 ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
536 scale = dist_scale_factor[ref0];
540 const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride];
541 int my_col = (mv_col[1]<<y_shift)/2;
542 int mx = (scale * mv_col[0] + 128) >> 8;
543 int my = (scale * my_col + 128) >> 8;
560 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
561 : map_col_to_list0[1][l1ref1[0] + ref_offset];
562 const int scale = dist_scale_factor[ref0];
563 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
565 mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
566 mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
569 mv1=
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
575 for(i8=0; i8<4; i8++){
577 const int y8 = i8>>1;
579 const int16_t (*l1mv)[2]= l1mv0;
592 assert(b8_stride == 2);
595 ref0 = map_col_to_list0[0][ref0 + ref_offset];
597 ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
600 scale = dist_scale_factor[ref0];
604 const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
605 int mx = (scale * mv_col[0] + 128) >> 8;
606 int my = (scale * mv_col[1] + 128) >> 8;
610 for(i4=0; i4<4; i4++){
611 const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
613 mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
614 mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
616 pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]));
#define PICT_BOTTOM_FIELD
void ff_h264_direct_dist_scale_factor(H264Context *const h)
int field_picture
whether or not the picture was encoded in separate fields
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
static av_always_inline uint32_t pack16to32(int a, int b)
void ff_h264_pred_direct_motion(H264Context *const h, int *mb_type)
int ref_poc[2][2][32]
h264 POCs of the frames used as reference (FIXME need per slice)
int long_ref
1->long term reference 0->short term reference
int ref_count[2][2]
number of entries in ref_poc (FIXME need per slice)
Picture ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
static void pred_temp_direct_motion(H264Context *const h, int *mb_type)
H.264 / AVC / MPEG4 part10 codec.
void ff_h264_direct_ref_list_init(H264Context *const h)
Multithreading support functions.
static const uint16_t mask[17]
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
int active_thread_type
Which multithreading methods are in use by the codec.
#define MB_TYPE_INTERLACED
int direct_spatial_mv_pred
int map_col_to_list0[2][16+32]
#define MB_TYPE_16x16_OR_INTRA
static const uint8_t scan8[16 *3+3]
useful rectangle filling function
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color)
int dist_scale_factor[32]
int frame_num
h264 frame_num (raw frame_num from slice header)
int direct_8x8_inference_flag
static int get_scale_factor(H264Context *const h, int poc, int poc1, int i)
#define PART_NOT_AVAILABLE
static const int8_t mv[256][2]
uint32_t * mb_type
macroblock type table mb_type_base + mb_width + 2
static void pred_spatial_direct_motion(H264Context *const h, int *mb_type)
int mbaff
h264 1 -> MBAFF frame 0-> not MBAFF
void ff_thread_await_progress(AVFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
int16_t(*[2] motion_val)[2]
motion vector table
int8_t * ref_index[2]
motion reference frame index the order in which these are stored can depend on the codec...
int field_poc[2]
h264 top/bottom POC
static const uint16_t scale[4]
int dist_scale_factor_field[2][32]
static void await_reference_mb_row(H264Context *const h, Picture *ref, int mb_y)
common internal api header.
int map_col_to_list0_field[2][2][16+32]
static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi)
int8_t ref_cache[2][5 *8]
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)