Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 23.25 KB | None | 0 0
  1. From d0974fd9e01cd4be6deb56c53dc867e876945926 Mon Sep 17 00:00:00 2001
  2. From: Jason Garrett-Glaser <jason@x264.com>
  3. Date: Tue, 5 Jul 2011 18:08:22 -0700
  4. Subject: [PATCH 1/6] H.264: av_always_inline some more functions
  5.  
  6. These weren't getting inlined all the time in all gcc versions.
  7. ---
  8. libavcodec/h264.c        |    4 ++--
  9.  libavcodec/h264.h        |    4 ++--
  10.  libavcodec/h264_mvpred.h |    8 ++++----
  11.  3 files changed, 8 insertions(+), 8 deletions(-)
  12.  
  13. diff --git a/libavcodec/h264.c b/libavcodec/h264.c
  14. index dbac4fd..f7c0345 100644
  15. --- a/libavcodec/h264.c
  16. +++ b/libavcodec/h264.c
  17. @@ -1443,7 +1443,7 @@ static void decode_postinit(H264Context *h, int setup_finished){
  18.          ff_thread_finish_setup(s->avctx);
  19.  }
  20.  
  21. -static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int chroma444, int simple){
  22. +static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int chroma444, int simple){
  23.      MpegEncContext * const s = &h->s;
  24.      uint8_t *top_border;
  25.      int top_idx = 1;
  26. @@ -1518,7 +1518,7 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src
  27.      }
  28.  }
  29.  
  30. -static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
  31. +static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
  32.                                    uint8_t *src_cb, uint8_t *src_cr,
  33.                                    int linesize, int uvlinesize,
  34.                                    int xchg, int chroma444,
  35. diff --git a/libavcodec/h264.h b/libavcodec/h264.h
  36. index dad06e2..a2abab9 100644
  37. --- a/libavcodec/h264.h
  38. +++ b/libavcodec/h264.h
  39. @@ -766,11 +766,11 @@ static av_always_inline uint16_t pack8to16(int a, int b){
  40.  /**
  41.   * gets the chroma qp.
  42.   */
  43. -static inline int get_chroma_qp(H264Context *h, int t, int qscale){
  44. +static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){
  45.      return h->pps.chroma_qp_table[t][qscale];
  46.  }
  47.  
  48. -static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my);
  49. +static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my);
  50.  
  51.  static void fill_decode_neighbors(H264Context *h, int mb_type){
  52.      MpegEncContext * const s = &h->s;
  53. diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
  54. index f603e7f..c4e65b5 100644
  55. --- a/libavcodec/h264_mvpred.h
  56. +++ b/libavcodec/h264_mvpred.h
  57. @@ -35,7 +35,7 @@
  58.  //#undef NDEBUG
  59.  #include <assert.h>
  60.  
  61. -static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){
  62. +static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){
  63.      const int topright_ref= h->ref_cache[list][ i - 8 + part_width ];
  64.      MpegEncContext *s = &h->s;
  65.  
  66. @@ -92,7 +92,7 @@ static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, in
  67.   * @param mx the x component of the predicted motion vector
  68.   * @param my the y component of the predicted motion vector
  69.   */
  70. -static inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){
  71. +static av_always_inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){
  72.      const int index8= scan8[n];
  73.      const int top_ref=      h->ref_cache[list][ index8 - 8 ];
  74.      const int left_ref=     h->ref_cache[list][ index8 - 1 ];
  75. @@ -147,7 +147,7 @@ static inline void pred_motion(H264Context * const h, int n, int part_width, int
  76.   * @param mx the x component of the predicted motion vector
  77.   * @param my the y component of the predicted motion vector
  78.   */
  79. -static inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){
  80. +static av_always_inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){
  81.      if(n==0){
  82.          const int top_ref=      h->ref_cache[list][ scan8[0] - 8 ];
  83.          const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];
  84. @@ -182,7 +182,7 @@ static inline void pred_16x8_motion(H264Context * const h, int n, int list, int
  85.   * @param mx the x component of the predicted motion vector
  86.   * @param my the y component of the predicted motion vector
  87.   */
  88. -static inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){
  89. +static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){
  90.      if(n==0){
  91.          const int left_ref=      h->ref_cache[list][ scan8[0] - 1 ];
  92.          const int16_t * const A=  h->mv_cache[list][ scan8[0] - 1 ];
  93. --
  94. 1.7.3.2.146.gca209
  95.  
  96.  
  97. From e61600fa054188eea481a55233b67b2d33f41892 Mon Sep 17 00:00:00 2001
  98. From: Jason Garrett-Glaser <jason@x264.com>
  99. Date: Tue, 5 Jul 2011 17:55:14 -0700
  100. Subject: [PATCH 2/6] H.264: faster P-SKIP decoding
  101.  
  102. Inline the relevant parts of fill_decode_caches into P-SKIP mv prediction to
  103. avoid calling the whole thing.
  104. ---
  105. libavcodec/h264.h        |    1 -
  106.  libavcodec/h264_mvpred.h |  108 ++++++++++++++++++++++++++++++++++++++++++----
  107.  2 files changed, 99 insertions(+), 10 deletions(-)
  108.  
  109. diff --git a/libavcodec/h264.h b/libavcodec/h264.h
  110. index a2abab9..d34e6db 100644
  111. --- a/libavcodec/h264.h
  112. +++ b/libavcodec/h264.h
  113. @@ -1331,7 +1331,6 @@ static void av_unused decode_mb_skip(H264Context *h){
  114.          mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP;
  115.  
  116.          fill_decode_neighbors(h, mb_type);
  117. -        fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ...
  118.          pred_pskip_motion(h, &mx, &my);
  119.          fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
  120.          fill_rectangle(  h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4);
  121. diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
  122. index c4e65b5..27adac6 100644
  123. --- a/libavcodec/h264_mvpred.h
  124. +++ b/libavcodec/h264_mvpred.h
  125. @@ -213,21 +213,111 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int
  126.      pred_motion(h, n, 2, list, ref, mx, my);
  127.  }
  128.  
  129. -static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){
  130. -    const int top_ref = h->ref_cache[0][ scan8[0] - 8 ];
  131. -    const int left_ref= h->ref_cache[0][ scan8[0] - 1 ];
  132. -
  133. -    tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);
  134. +#define FIX_MV_MBAFF(type, refn, mvn, idx)\
  135. +    if(FRAME_MBAFF){\
  136. +        if(MB_FIELD){\
  137. +            if(!IS_INTERLACED(type)){\
  138. +                refn <<= 1;\
  139. +                AV_COPY32(mvbuf[idx], mvn);\
  140. +                mvbuf[idx][1] /= 2;\
  141. +                mvn = mvbuf[idx];\
  142. +            }\
  143. +        }else{\
  144. +            if(IS_INTERLACED(type)){\
  145. +                refn >>= 1;\
  146. +                AV_COPY32(mvbuf[idx], mvn);\
  147. +                mvbuf[idx][1] <<= 1;\
  148. +                mvn = mvbuf[idx];\
  149. +            }\
  150. +        }\
  151. +    }
  152.  
  153. -    if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE
  154. -       || !( top_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 8 ]))
  155. -       || !(left_ref | AV_RN32A(h->mv_cache[0][ scan8[0] - 1 ]))){
  156. +static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){
  157. +    DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0};
  158. +    DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];
  159. +    MpegEncContext * const s = &h->s;
  160. +    int8_t *ref = s->current_picture.ref_index[0];
  161. +    int16_t (*mv)[2] = s->current_picture.motion_val[0];
  162. +    int top_ref, left_ref, diagonal_ref, match_count;
  163. +    const int16_t *A, *B, *C;
  164. +    int b_stride = h->b_stride;
  165. +
  166. +    /* To avoid doing an entire fill_decode_caches, we inline the relevant parts here. */
  167. +    if(USES_LIST(h->left_type[LTOP], 0)){
  168. +        left_ref = ref[4*h->left_mb_xy[LTOP] + 1 + (h->left_block[0]&~1)];
  169. +        A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride*h->left_block[0]];
  170. +        FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0);
  171. +        if(!(left_ref | AV_RN32A(A))){
  172. +            *mx = *my = 0;
  173. +            return;
  174. +        }
  175. +    }else if(h->left_type[LTOP]){
  176. +        left_ref = LIST_NOT_USED;
  177. +        A = zeromv;
  178. +    }else{
  179. +        *mx = *my = 0;
  180. +        return;
  181. +    }
  182.  
  183. +    if(USES_LIST(h->top_type, 0)){
  184. +        top_ref = ref[4*h->top_mb_xy + 2];
  185. +        B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride];
  186. +        FIX_MV_MBAFF(h->top_type, top_ref, B, 1);
  187. +        if(!(top_ref | AV_RN32A(B))){
  188. +            *mx = *my = 0;
  189. +            return;
  190. +        }
  191. +    }else if(h->top_type){
  192. +        top_ref = LIST_NOT_USED;
  193. +        B = zeromv;
  194. +    }else{
  195.          *mx = *my = 0;
  196.          return;
  197.      }
  198.  
  199. -    pred_motion(h, 0, 4, 0, 0, mx, my);
  200. +    tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);
  201. +
  202. +    if(USES_LIST(h->topright_type, 0)){
  203. +        diagonal_ref = ref[4*h->topright_mb_xy + 2];
  204. +        C = mv[h->mb2b_xy[h->topright_mb_xy] + 3*b_stride];
  205. +        FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2);
  206. +    }else if(h->topright_type){
  207. +        diagonal_ref = LIST_NOT_USED;
  208. +        C = zeromv;
  209. +    }else{
  210. +        if(USES_LIST(h->topleft_type, 0)){
  211. +            diagonal_ref = ref[4*h->topleft_mb_xy + 1 + (h->topleft_partition & 2)];
  212. +            C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride + (h->topleft_partition & 2*b_stride)];
  213. +            FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2);
  214. +        }else if(h->topleft_type){
  215. +            diagonal_ref = LIST_NOT_USED;
  216. +            C = zeromv;
  217. +        }else{
  218. +            diagonal_ref = PART_NOT_AVAILABLE;
  219. +            C = zeromv;
  220. +        }
  221. +    }
  222. +
  223. +    match_count= !diagonal_ref + !top_ref + !left_ref;
  224. +    tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count);
  225. +    if(match_count > 1){
  226. +        *mx= mid_pred(A[0], B[0], C[0]);
  227. +        *my= mid_pred(A[1], B[1], C[1]);
  228. +    }else if(match_count==1){
  229. +        if(!left_ref){
  230. +            *mx= A[0];
  231. +            *my= A[1];
  232. +        }else if(!top_ref){
  233. +            *mx= B[0];
  234. +            *my= B[1];
  235. +        }else{
  236. +            *mx= C[0];
  237. +            *my= C[1];
  238. +        }
  239. +    }else{
  240. +        *mx= mid_pred(A[0], B[0], C[0]);
  241. +        *my= mid_pred(A[1], B[1], C[1]);
  242. +    }
  243.  
  244.      return;
  245.  }
  246. --
  247. 1.7.3.2.146.gca209
  248.  
  249.  
  250. From d35a5612ef3aa50d7b91d495c0318639d2415a62 Mon Sep 17 00:00:00 2001
  251. From: Jason Garrett-Glaser <jason@x264.com>
  252. Date: Wed, 6 Jul 2011 07:58:50 -0700
  253. Subject: [PATCH 3/6] H.264: merge fill_rectangle into P-SKIP MV prediction, to match B-SKIP
  254.  
  255. ---
  256. libavcodec/h264.h        |    7 ++-----
  257.  libavcodec/h264_mvpred.h |   42 ++++++++++++++++++++++--------------------
  258.  2 files changed, 24 insertions(+), 25 deletions(-)
  259.  
  260. diff --git a/libavcodec/h264.h b/libavcodec/h264.h
  261. index d34e6db..e88005a 100644
  262. --- a/libavcodec/h264.h
  263. +++ b/libavcodec/h264.h
  264. @@ -770,7 +770,7 @@ static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){
  265.      return h->pps.chroma_qp_table[t][qscale];
  266.  }
  267.  
  268. -static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my);
  269. +static av_always_inline void pred_pskip_motion(H264Context * const h);
  270.  
  271.  static void fill_decode_neighbors(H264Context *h, int mb_type){
  272.      MpegEncContext * const s = &h->s;
  273. @@ -1327,13 +1327,10 @@ static void av_unused decode_mb_skip(H264Context *h){
  274.      }
  275.      else
  276.      {
  277. -        int mx, my;
  278.          mb_type|= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP;
  279.  
  280.          fill_decode_neighbors(h, mb_type);
  281. -        pred_pskip_motion(h, &mx, &my);
  282. -        fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
  283. -        fill_rectangle(  h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4);
  284. +        pred_pskip_motion(h);
  285.      }
  286.  
  287.      write_back_motion(h, mb_type);
  288. diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
  289. index 27adac6..178eb24 100644
  290. --- a/libavcodec/h264_mvpred.h
  291. +++ b/libavcodec/h264_mvpred.h
  292. @@ -232,31 +232,31 @@ static av_always_inline void pred_8x16_motion(H264Context * const h, int n, int
  293.          }\
  294.      }
  295.  
  296. -static av_always_inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){
  297. +static av_always_inline void pred_pskip_motion(H264Context * const h){
  298.      DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = {0};
  299.      DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];
  300.      MpegEncContext * const s = &h->s;
  301.      int8_t *ref = s->current_picture.ref_index[0];
  302.      int16_t (*mv)[2] = s->current_picture.motion_val[0];
  303. -    int top_ref, left_ref, diagonal_ref, match_count;
  304. +    int top_ref, left_ref, diagonal_ref, match_count, mx, my;
  305.      const int16_t *A, *B, *C;
  306.      int b_stride = h->b_stride;
  307.  
  308. +    fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
  309. +
  310.      /* To avoid doing an entire fill_decode_caches, we inline the relevant parts here. */
  311.      if(USES_LIST(h->left_type[LTOP], 0)){
  312.          left_ref = ref[4*h->left_mb_xy[LTOP] + 1 + (h->left_block[0]&~1)];
  313.          A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride*h->left_block[0]];
  314.          FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0);
  315.          if(!(left_ref | AV_RN32A(A))){
  316. -            *mx = *my = 0;
  317. -            return;
  318. +            goto zeromv;
  319.          }
  320.      }else if(h->left_type[LTOP]){
  321.          left_ref = LIST_NOT_USED;
  322.          A = zeromv;
  323.      }else{
  324. -        *mx = *my = 0;
  325. -        return;
  326. +        goto zeromv;
  327.      }
  328.  
  329.      if(USES_LIST(h->top_type, 0)){
  330. @@ -264,15 +264,13 @@ static av_always_inline void pred_pskip_motion(H264Context * const h, int * cons
  331.          B = mv[h->mb2b_xy[h->top_mb_xy] + 3*b_stride];
  332.          FIX_MV_MBAFF(h->top_type, top_ref, B, 1);
  333.          if(!(top_ref | AV_RN32A(B))){
  334. -            *mx = *my = 0;
  335. -            return;
  336. +            goto zeromv;
  337.          }
  338.      }else if(h->top_type){
  339.          top_ref = LIST_NOT_USED;
  340.          B = zeromv;
  341.      }else{
  342. -        *mx = *my = 0;
  343. -        return;
  344. +        goto zeromv;
  345.      }
  346.  
  347.      tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);
  348. @@ -301,24 +299,28 @@ static av_always_inline void pred_pskip_motion(H264Context * const h, int * cons
  349.      match_count= !diagonal_ref + !top_ref + !left_ref;
  350.      tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count);
  351.      if(match_count > 1){
  352. -        *mx= mid_pred(A[0], B[0], C[0]);
  353. -        *my= mid_pred(A[1], B[1], C[1]);
  354. +        mx = mid_pred(A[0], B[0], C[0]);
  355. +        my = mid_pred(A[1], B[1], C[1]);
  356.      }else if(match_count==1){
  357.          if(!left_ref){
  358. -            *mx= A[0];
  359. -            *my= A[1];
  360. +            mx = A[0];
  361. +            my = A[1];
  362.          }else if(!top_ref){
  363. -            *mx= B[0];
  364. -            *my= B[1];
  365. +            mx = B[0];
  366. +            my = B[1];
  367.          }else{
  368. -            *mx= C[0];
  369. -            *my= C[1];
  370. +            mx = C[0];
  371. +            my = C[1];
  372.          }
  373.      }else{
  374. -        *mx= mid_pred(A[0], B[0], C[0]);
  375. -        *my= mid_pred(A[1], B[1], C[1]);
  376. +        mx = mid_pred(A[0], B[0], C[0]);
  377. +        my = mid_pred(A[1], B[1], C[1]);
  378.      }
  379.  
  380. +    fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4);
  381. +    return;
  382. +zeromv:
  383. +    fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
  384.      return;
  385.  }
  386.  
  387. --
  388. 1.7.3.2.146.gca209
  389.  
  390.  
  391. From eda7f1ca1b9748a2027dfe81259b9140bddbdd61 Mon Sep 17 00:00:00 2001
  392. From: Jason Garrett-Glaser <jason@x264.com>
  393. Date: Wed, 6 Jul 2011 12:26:04 -0700
  394. Subject: [PATCH 4/6] H.264: Remove redundant hl_motion_16/8 code
  395.  
  396. ---
  397. libavcodec/h264.c |   52 ++++++++++------------------------------------------
  398.  1 files changed, 10 insertions(+), 42 deletions(-)
  399.  
  400. diff --git a/libavcodec/h264.c b/libavcodec/h264.c
  401. index f7c0345..f79f4d1 100644
  402. --- a/libavcodec/h264.c
  403. +++ b/libavcodec/h264.c
  404. @@ -778,24 +778,6 @@ static av_always_inline void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t
  405.      prefetch_motion(h, 1, pixel_shift, chroma444);
  406.  }
  407.  
  408. -#define hl_motion_fn(sh, bits) \
  409. -static av_always_inline void hl_motion_ ## bits(H264Context *h, \
  410. -                                       uint8_t *dest_y, \
  411. -                                       uint8_t *dest_cb, uint8_t *dest_cr, \
  412. -                                       qpel_mc_func (*qpix_put)[16], \
  413. -                                       h264_chroma_mc_func (*chroma_put), \
  414. -                                       qpel_mc_func (*qpix_avg)[16], \
  415. -                                       h264_chroma_mc_func (*chroma_avg), \
  416. -                                       h264_weight_func *weight_op, \
  417. -                                       h264_biweight_func *weight_avg, \
  418. -                                       int chroma444) \
  419. -{ \
  420. -    hl_motion(h, dest_y, dest_cb, dest_cr, qpix_put, chroma_put, \
  421. -              qpix_avg, chroma_avg, weight_op, weight_avg, sh, chroma444); \
  422. -}
  423. -hl_motion_fn(0, 8);
  424. -hl_motion_fn(1, 16);
  425. -
  426.  static void free_tables(H264Context *h, int free_rbsp){
  427.      int i;
  428.      H264Context *hx;
  429. @@ -1876,18 +1858,11 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i
  430.              if(h->deblocking_filter)
  431.                  xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, simple, pixel_shift);
  432.          }else if(is_h264){
  433. -            if (pixel_shift) {
  434. -                hl_motion_16(h, dest_y, dest_cb, dest_cr,
  435. -                             s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
  436. -                             s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
  437. -                             h->h264dsp.weight_h264_pixels_tab,
  438. -                             h->h264dsp.biweight_h264_pixels_tab, 0);
  439. -            } else
  440. -                hl_motion_8(h, dest_y, dest_cb, dest_cr,
  441. -                            s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
  442. -                            s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
  443. -                            h->h264dsp.weight_h264_pixels_tab,
  444. -                            h->h264dsp.biweight_h264_pixels_tab, 0);
  445. +            hl_motion(h, dest_y, dest_cb, dest_cr,
  446. +                      s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
  447. +                      s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
  448. +                      h->h264dsp.weight_h264_pixels_tab,
  449. +                      h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 0);
  450.          }
  451.  
  452.          hl_decode_mb_idct_luma(h, mb_type, is_h264, simple, transform_bypass, pixel_shift, block_offset, linesize, dest_y, 0);
  453. @@ -2017,18 +1992,11 @@ static av_always_inline void hl_decode_mb_444_internal(H264Context *h, int simpl
  454.              if(h->deblocking_filter)
  455.                  xchg_mb_border(h, dest[0], dest[1], dest[2], linesize, linesize, 0, 1, simple, pixel_shift);
  456.          }else{
  457. -            if (pixel_shift) {
  458. -                hl_motion_16(h, dest[0], dest[1], dest[2],
  459. -                             s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
  460. -                             s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
  461. -                             h->h264dsp.weight_h264_pixels_tab,
  462. -                             h->h264dsp.biweight_h264_pixels_tab, 1);
  463. -            } else
  464. -                hl_motion_8(h, dest[0], dest[1], dest[2],
  465. -                            s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
  466. -                            s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
  467. -                            h->h264dsp.weight_h264_pixels_tab,
  468. -                            h->h264dsp.biweight_h264_pixels_tab, 1);
  469. +            hl_motion(h, dest[0], dest[1], dest[2],
  470. +                      s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
  471. +                      s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
  472. +                      h->h264dsp.weight_h264_pixels_tab,
  473. +                      h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 1);
  474.          }
  475.  
  476.          for (p = 0; p < plane_count; p++)
  477. --
  478. 1.7.3.2.146.gca209
  479.  
  480.  
  481. From 50f29cfa15d6ddafd7ebc41f91b9131deebdfa03 Mon Sep 17 00:00:00 2001
  482. From: Jason Garrett-Glaser <jason@x264.com>
  483. Date: Wed, 6 Jul 2011 13:25:13 -0700
  484. Subject: [PATCH 5/6] H.264: use fill_rectangle in CABAC decoding
  485.  
  486. ---
  487. libavcodec/h264_cabac.c |    3 +--
  488.  1 files changed, 1 insertions(+), 2 deletions(-)
  489.  
  490. diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
  491. index 6dacf7a..390a7b6 100644
  492. --- a/libavcodec/h264_cabac.c
  493. +++ b/libavcodec/h264_cabac.c
  494. @@ -1818,8 +1818,7 @@ static av_always_inline void decode_cabac_luma_residual( H264Context *h, const u
  495.                      }
  496.                  }
  497.              } else {
  498. -                uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8+16*p] ];
  499. -                nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
  500. +                fill_rectangle(&h->non_zero_count_cache[scan8[4*i8x8+16*p]], 2, 2, 8, 0, 1);
  501.              }
  502.          }
  503.      }
  504. --
  505. 1.7.3.2.146.gca209
  506.  
  507.  
  508. From 1644142d17d231cd9a077db600587785dd8a354c Mon Sep 17 00:00:00 2001
  509. From: Jason Garrett-Glaser <jason@x264.com>
  510. Date: Wed, 6 Jul 2011 14:08:30 -0700
  511. Subject: [PATCH 6/6] H.264: improve qp_thresh check
  512.  
  513. Eliminate redundant check in filter_mb_fast, consider bit depth in calculating qp_thresh.
  514. ---
  515. libavcodec/h264.c            |    4 +++-
  516.  libavcodec/h264_loopfilter.c |    6 +-----
  517.  2 files changed, 4 insertions(+), 6 deletions(-)
  518.  
  519. diff --git a/libavcodec/h264.c b/libavcodec/h264.c
  520. index f79f4d1..33c9527 100644
  521. --- a/libavcodec/h264.c
  522. +++ b/libavcodec/h264.c
  523. @@ -2931,7 +2931,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
  524.              }
  525.          }
  526.      }
  527. -    h->qp_thresh= 15 + 52 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]);
  528. +    h->qp_thresh = 15 + 52 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset)
  529. +                 - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1])
  530. +                 + 6 * (h->sps.bit_depth_luma - 8);
  531.  
  532.  #if 0 //FMO
  533.      if( h->pps.num_slice_groups > 1  && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5)
  534. diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
  535. index c716347..5de9f78 100644
  536. --- a/libavcodec/h264_loopfilter.c
  537. +++ b/libavcodec/h264_loopfilter.c
  538. @@ -216,7 +216,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
  539.      MpegEncContext * const s = &h->s;
  540.      int mb_xy;
  541.      int mb_type, left_type, top_type;
  542. -    int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh;
  543. +    int qp, qp0, qp1, qpc, qpc0, qpc1;
  544.      int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
  545.      int chroma444 = CHROMA444;
  546.  
  547. @@ -241,10 +241,6 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
  548.      qp1 = (qp + qp1 + 1) >> 1;
  549.      qpc0 = (qpc + qpc0 + 1) >> 1;
  550.      qpc1 = (qpc + qpc1 + 1) >> 1;
  551. -    qp_thresh = 15+52 - h->slice_alpha_c0_offset;
  552. -    if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh &&
  553. -       qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh)
  554. -        return;
  555.  
  556.      if( IS_INTRA(mb_type) ) {
  557.          static const int16_t bS4[4] = {4,4,4,4};
  558. --
  559. 1.7.3.2.146.gca209
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement