History

avcodec/motion_est: Avoid branches for put(_no_rnd) selection

MotionEstContext contains pointers (to function pointers) that have been set on a per-frame basis depending upon no_rounding in ff_me_init_pic() to avoid branches like these. Also makes MotionEstContext more independent of MpegEncContext.

Andreas Rheinhardt committed 2 years ago

Commit d4fd4751 parent b3ba9611 file · +5 −20Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/motion_est.c+5−20
@@ -661,18 +661,12 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) · 660 unmodified lines
661661 const uint8_t *ref = c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
662662 dxy = ((my4 & 3) << 2) | (mx4 & 3);
663663
664− if(s->no_rounding)
665− s->qdsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
666− else
667− s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
664+ c->qpel_put[1][dxy](dest_y, ref, stride);
668665 }else{
669666 const uint8_t *ref = c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
670667 dxy = ((my4 & 1) << 1) | (mx4 & 1);
671668
672− if(s->no_rounding)
673− s->hdsp.put_no_rnd_pixels_tab[1][dxy](dest_y , ref , stride, h);
674− else
675− s->hdsp.put_pixels_tab [1][dxy](dest_y , ref , stride, h);
669+ c->hpel_put[1][dxy](dest_y, ref, stride, h);
676670 }
677671 dmin_sum+= (mv_penalty[mx4-pred_x4] + mv_penalty[my4-pred_y4])*c->mb_penalty_factor;
678672 }else
@@ -713,13 +707,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift) · 34 unmodified lines
713707
714708 offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
715709
716− if(s->no_rounding){
717− s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_pic.data[1] + offset, s->uvlinesize, 8);
718− s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8);
719− }else{
720− s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_pic.data[1] + offset, s->uvlinesize, 8);
721− s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8);
722− }
710+ c->hpel_put[1][dxy](c->scratchpad , s->last_pic.data[1] + offset, s->uvlinesize, 8);
711+ c->hpel_put[1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8);
723712
724713 dmin_sum += c->mb_cmp[1](s, s->new_pic->data[1] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad, s->uvlinesize, 8);
725714 dmin_sum += c->mb_cmp[1](s, s->new_pic->data[2] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad + 8, s->uvlinesize, 8);
@@ -825,11 +814,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index, · 99 unmodified lines
825814 const uint8_t *ref = c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
826815 dxy = ((my_i & 1) << 1) | (mx_i & 1);
827816
828− if(s->no_rounding){
829− s->hdsp.put_no_rnd_pixels_tab[size][dxy](c->scratchpad, ref , stride, h);
830− }else{
831− s->hdsp.put_pixels_tab [size][dxy](c->scratchpad, ref , stride, h);
832− }
817+ c->hpel_put[size][dxy](c->scratchpad, ref, stride, h);
833818 dmin = c->mb_cmp[size](s, c->src[block][0], c->scratchpad, stride, h);
834819 dmin+= (mv_penalty[mx_i-c->pred_x] + mv_penalty[my_i-c->pred_y] + 1)*c->mb_penalty_factor;
835820 }else

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t