Mercurial > libavcodec.hg
comparison h264.c @ 10864:e3f5eb016712 libavcodec
Split motion vector prediction off h264.c/h.
author | michael |
---|---|
date | Tue, 12 Jan 2010 21:36:26 +0000 |
parents | 974ac220c93a |
children | d26e9b4d2ca1 |
comparison
equal
deleted
inserted
replaced
10863:974ac220c93a | 10864:e3f5eb016712 |
---|---|
29 #include "dsputil.h" | 29 #include "dsputil.h" |
30 #include "avcodec.h" | 30 #include "avcodec.h" |
31 #include "mpegvideo.h" | 31 #include "mpegvideo.h" |
32 #include "h264.h" | 32 #include "h264.h" |
33 #include "h264data.h" | 33 #include "h264data.h" |
34 #include "h264_mvpred.h" | |
34 #include "h264_parser.h" | 35 #include "h264_parser.h" |
35 #include "golomb.h" | 36 #include "golomb.h" |
36 #include "mathops.h" | 37 #include "mathops.h" |
37 #include "rectangle.h" | 38 #include "rectangle.h" |
38 #include "vdpau_internal.h" | 39 #include "vdpau_internal.h" |
663 if(i<64) i= (i+1)>>1; | 664 if(i<64) i= (i+1)>>1; |
664 | 665 |
665 tprintf(h->s.avctx, "pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31); | 666 tprintf(h->s.avctx, "pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31); |
666 | 667 |
667 return i&31; | 668 return i&31; |
668 } | |
669 | |
670 /** | |
671 * gets the directionally predicted 16x8 MV. | |
672 * @param n the block index | |
673 * @param mx the x component of the predicted motion vector | |
674 * @param my the y component of the predicted motion vector | |
675 */ | |
676 static inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ | |
677 if(n==0){ | |
678 const int top_ref= h->ref_cache[list][ scan8[0] - 8 ]; | |
679 const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; | |
680 | |
681 tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list); | |
682 | |
683 if(top_ref == ref){ | |
684 *mx= B[0]; | |
685 *my= B[1]; | |
686 return; | |
687 } | |
688 }else{ | |
689 const int left_ref= h->ref_cache[list][ scan8[8] - 1 ]; | |
690 const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ]; | |
691 | |
692 tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); | |
693 | |
694 if(left_ref == ref){ | |
695 *mx= A[0]; | |
696 *my= A[1]; | |
697 return; | |
698 } | |
699 } | |
700 | |
701 //RARE | |
702 pred_motion(h, n, 4, list, ref, mx, my); | |
703 } | |
704 | |
705 /** | |
706 * gets the directionally predicted 8x16 MV. | |
707 * @param n the block index | |
708 * @param mx the x component of the predicted motion vector | |
709 * @param my the y component of the predicted motion vector | |
710 */ | |
711 static inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ | |
712 if(n==0){ | |
713 const int left_ref= h->ref_cache[list][ scan8[0] - 1 ]; | |
714 const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; | |
715 | |
716 tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); | |
717 | |
718 if(left_ref == ref){ | |
719 *mx= A[0]; | |
720 *my= A[1]; | |
721 return; | |
722 } | |
723 }else{ | |
724 const int16_t * C; | |
725 int diagonal_ref; | |
726 | |
727 diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2); | |
728 | |
729 tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list); | |
730 | |
731 if(diagonal_ref == ref){ | |
732 *mx= C[0]; | |
733 *my= C[1]; | |
734 return; | |
735 } | |
736 } | |
737 | |
738 //RARE | |
739 pred_motion(h, n, 2, list, ref, mx, my); | |
740 } | |
741 | |
742 static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){ | |
743 const int top_ref = h->ref_cache[0][ scan8[0] - 8 ]; | |
744 const int left_ref= h->ref_cache[0][ scan8[0] - 1 ]; | |
745 | |
746 tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y); | |
747 | |
748 if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE | |
749 || !( top_ref | *(uint32_t*)h->mv_cache[0][ scan8[0] - 8 ]) | |
750 || !(left_ref | *(uint32_t*)h->mv_cache[0][ scan8[0] - 1 ])){ | |
751 | |
752 *mx = *my = 0; | |
753 return; | |
754 } | |
755 | |
756 pred_motion(h, 0, 4, 0, 0, mx, my); | |
757 | |
758 return; | |
759 } | 669 } |
760 | 670 |
761 static inline void write_back_motion(H264Context *h, int mb_type){ | 671 static inline void write_back_motion(H264Context *h, int mb_type){ |
762 MpegEncContext * const s = &h->s; | 672 MpegEncContext * const s = &h->s; |
763 const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; | 673 const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; |