SHARE
TWEET

Untitled

a guest Jun 15th, 2017 499 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From cc2ad6dcb3131a8ae0339e95f64a319b7ed25356 Mon Sep 17 00:00:00 2001
  2. From: Michael Niedermayer <michaelni@gmx.at>
  3. Date: Wed, 29 Apr 2015 15:13:24 +0200
  4. Subject: [PATCH 1/6] avcodec/h264_slice: Also copy x264_build in
  5.  ff_h264_update_thread_context()
  6.  
  7. Fixes fate-h264-lossless
  8.  
  9. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  10. ---
  11. libavcodec/h264_slice.c | 1 +
  12.  1 file changed, 1 insertion(+)
  13.  
  14. diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
  15. index c9f1dbb86..0ce4127a1 100644
  16. --- a/libavcodec/h264_slice.c
  17. +++ b/libavcodec/h264_slice.c
  18. @@ -408,6 +408,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
  19.      // extradata/NAL handling
  20.      h->is_avc = h1->is_avc;
  21.      h->nal_length_size = h1->nal_length_size;
  22. +    h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
  23.  
  24.      memcpy(&h->poc,        &h1->poc,        sizeof(h->poc));
  25.  
  26. --
  27. 2.13.0.windows.1
  28.  
  29.  
  30. From 08f803b1ca24a95fed43ea022299f31454ff9858 Mon Sep 17 00:00:00 2001
  31. From: Anton Mitrofanov <BugMaster@narod.ru>
  32. Date: Tue, 13 Jun 2017 22:48:47 +0300
  33. Subject: [PATCH 2/6] avcodec/h264: Don't reset the x264 build info once read
  34.  
  35. In order to fix fate-h264-lossless (change by Hendrik)
  36. ---
  37. libavcodec/h264_sei.c | 1 -
  38.  libavcodec/h264dec.c  | 1 +
  39.  2 files changed, 1 insertion(+), 1 deletion(-)
  40.  
  41. diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
  42. index 3ca2b7a6c..a2151bfaf 100644
  43. --- a/libavcodec/h264_sei.c
  44. +++ b/libavcodec/h264_sei.c
  45. @@ -38,7 +38,6 @@ static const uint8_t sei_num_clock_ts_table[9] = {
  46.  
  47.  void ff_h264_sei_uninit(H264SEIContext *h)
  48.  {
  49. -    h->unregistered.x264_build           = -1;
  50.      h->recovery_point.recovery_frame_cnt = -1;
  51.  
  52.      h->picture_timing.dpb_output_delay  = 0;
  53. diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
  54. index 2a532a7ef..c81510fc0 100644
  55. --- a/libavcodec/h264dec.c
  56. +++ b/libavcodec/h264dec.c
  57. @@ -294,6 +294,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
  58.      h->poc.prev_poc_msb      = 1 << 16;
  59.      h->recovery_frame        = -1;
  60.      h->frame_recovered       = 0;
  61. +    h->sei.unregistered.x264_build = -1;
  62.  
  63.      h->next_outputed_poc = INT_MIN;
  64.      for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
  65. --
  66. 2.13.0.windows.1
  67.  
  68.  
  69. From f00b6921631f9b206c9acf0679366cb6f38e2a4e Mon Sep 17 00:00:00 2001
  70. From: Yogender Kumar Gupta <yogender.gupta@gmail.com>
  71. Date: Tue, 18 Mar 2014 16:01:15 +0530
  72. Subject: [PATCH 3/6] avcodec/h264: fix Lossless Decoding (Profile 244) for 8x8
  73.  Intra Prediction
  74.  
  75. This is limited to the case where x264_build = -1, to not break x264 decoding
  76.  
  77. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  78. ---
  79. libavcodec/h264_mb.c           |  7 +++-
  80.  libavcodec/h264pred.c          |  2 ++
  81.  libavcodec/h264pred.h          |  2 ++
  82.  libavcodec/h264pred_template.c | 73 ++++++++++++++++++++++++++++++++++++++++++
  83.  4 files changed, 83 insertions(+), 1 deletion(-)
  84.  
  85. diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
  86. index f037bd516..da6a31d57 100644
  87. --- a/libavcodec/h264_mb.c
  88. +++ b/libavcodec/h264_mb.c
  89. @@ -636,7 +636,12 @@ static av_always_inline void hl_decode_mb_predict_luma(const H264Context *h,
  90.                  uint8_t *const ptr = dest_y + block_offset[i];
  91.                  const int dir      = sl->intra4x4_pred_mode_cache[scan8[i]];
  92.                  if (transform_bypass && h->ps.sps->profile_idc == 244 && dir <= 1) {
  93. -                    h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
  94. +                    if (h->sei.unregistered.x264_build != -1) {
  95. +                        h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
  96. +                    } else
  97. +                        h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
  98. +                                                        (sl-> topleft_samples_available << i) & 0x8000,
  99. +                                                        (sl->topright_samples_available << i) & 0x4000, linesize);
  100.                  } else {
  101.                      const int nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
  102.                      h->hpc.pred8x8l[dir](ptr, (sl->topleft_samples_available << i) & 0x8000,
  103. diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c
  104. index 7627eb076..135babcab 100644
  105. --- a/libavcodec/h264pred.c
  106. +++ b/libavcodec/h264pred.c
  107. @@ -552,6 +552,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
  108.      h->pred4x4_add  [ HOR_PRED   ]= FUNCC(pred4x4_horizontal_add          , depth);\
  109.      h->pred8x8l_add [VERT_PRED   ]= FUNCC(pred8x8l_vertical_add           , depth);\
  110.      h->pred8x8l_add [ HOR_PRED   ]= FUNCC(pred8x8l_horizontal_add         , depth);\
  111. +    h->pred8x8l_filter_add [VERT_PRED   ]= FUNCC(pred8x8l_vertical_filter_add           , depth);\
  112. +    h->pred8x8l_filter_add [ HOR_PRED   ]= FUNCC(pred8x8l_horizontal_filter_add         , depth);\
  113.      if (chroma_format_idc <= 1) {\
  114.      h->pred8x8_add  [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add            , depth);\
  115.      h->pred8x8_add  [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add          , depth);\
  116. diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h
  117. index 60e74349c..6e495f9fc 100644
  118. --- a/libavcodec/h264pred.h
  119. +++ b/libavcodec/h264pred.h
  120. @@ -101,6 +101,8 @@ typedef struct H264PredContext {
  121.                            int16_t *block /*align 16*/, ptrdiff_t stride);
  122.      void(*pred8x8l_add[2])(uint8_t *pix /*align  8*/,
  123.                             int16_t *block /*align 16*/, ptrdiff_t stride);
  124. +    void(*pred8x8l_filter_add[2])(uint8_t *pix /*align  8*/,
  125. +                           int16_t *block /*align 16*/, int topleft, int topright, ptrdiff_t stride);
  126.      void(*pred8x8_add[3])(uint8_t *pix /*align  8*/,
  127.                            const int *block_offset,
  128.                            int16_t *block /*align 16*/, ptrdiff_t stride);
  129. diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c
  130. index 8492b2b0a..42ff350b4 100644
  131. --- a/libavcodec/h264pred_template.c
  132. +++ b/libavcodec/h264pred_template.c
  133. @@ -1123,6 +1123,79 @@ static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft,
  134.      SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
  135.      SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
  136.  }
  137. +
  138. +static void FUNCC(pred8x8l_vertical_filter_add)(uint8_t *_src, int16_t *_block, int has_topleft,
  139. +                                     int has_topright, ptrdiff_t _stride)
  140. +{
  141. +    int i;
  142. +    pixel *src = (pixel*)_src;
  143. +    const dctcoef *block = (const dctcoef*)_block;
  144. +    pixel pix[8];
  145. +    int stride = _stride/sizeof(pixel);
  146. +    PREDICT_8x8_LOAD_TOP;
  147. +
  148. +    pix[0] = t0;
  149. +    pix[1] = t1;
  150. +    pix[2] = t2;
  151. +    pix[3] = t3;
  152. +    pix[4] = t4;
  153. +    pix[5] = t5;
  154. +    pix[6] = t6;
  155. +    pix[7] = t7;
  156. +
  157. +    for(i=0; i<8; i++){
  158. +        pixel v = pix[i];
  159. +        src[0*stride]= v += block[0];
  160. +        src[1*stride]= v += block[8];
  161. +        src[2*stride]= v += block[16];
  162. +        src[3*stride]= v += block[24];
  163. +        src[4*stride]= v += block[32];
  164. +        src[5*stride]= v += block[40];
  165. +        src[6*stride]= v += block[48];
  166. +        src[7*stride]= v +  block[56];
  167. +        src++;
  168. +        block++;
  169. +    }
  170. +
  171. +    memset(_block, 0, sizeof(dctcoef) * 64);
  172. +}
  173. +
  174. +static void FUNCC(pred8x8l_horizontal_filter_add)(uint8_t *_src, int16_t *_block, int has_topleft,
  175. +                               int has_topright, ptrdiff_t _stride)
  176. +{
  177. +    int i;
  178. +    pixel *src = (pixel*)_src;
  179. +    const dctcoef *block = (const dctcoef*)_block;
  180. +    pixel pix[8];
  181. +    int stride = _stride/sizeof(pixel);
  182. +    PREDICT_8x8_LOAD_LEFT;
  183. +
  184. +    pix[0] = l0;
  185. +    pix[1] = l1;
  186. +    pix[2] = l2;
  187. +    pix[3] = l3;
  188. +    pix[4] = l4;
  189. +    pix[5] = l5;
  190. +    pix[6] = l6;
  191. +    pix[7] = l7;
  192. +
  193. +    for(i=0; i<8; i++){
  194. +        pixel v = pix[i];
  195. +        src[0]= v += block[0];
  196. +        src[1]= v += block[1];
  197. +        src[2]= v += block[2];
  198. +        src[3]= v += block[3];
  199. +        src[4]= v += block[4];
  200. +        src[5]= v += block[5];
  201. +        src[6]= v += block[6];
  202. +        src[7]= v +  block[7];
  203. +        src+= stride;
  204. +        block+= 8;
  205. +    }
  206. +
  207. +    memset(_block, 0, sizeof(dctcoef) * 64);
  208. +}
  209. +
  210.  #undef PREDICT_8x8_LOAD_LEFT
  211.  #undef PREDICT_8x8_LOAD_TOP
  212.  #undef PREDICT_8x8_LOAD_TOPLEFT
  213. --
  214. 2.13.0.windows.1
  215.  
  216.  
  217. From 459a04551e39b726ecb253fbfa81e5d28a17b80f Mon Sep 17 00:00:00 2001
  218. From: Anton Mitrofanov <BugMaster@narod.ru>
  219. Date: Wed, 31 May 2017 02:37:41 +0300
  220. Subject: [PATCH 4/6] avcodec/h264_cabac: Fix CABAC+8x8dct in 4:4:4
  221.  
  222. Use the correct ctxIdxInc calculation for coded_block_flag.
  223. Keep old behavior for old versions of x264 for backward compatibility.
  224. ---
  225. libavcodec/h264_cabac.c | 47 +++++++++++++++++++++++++++++++++--------------
  226.  1 file changed, 33 insertions(+), 14 deletions(-)
  227.  
  228. diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
  229. index b28e486e5..c28f5680d 100644
  230. --- a/libavcodec/h264_cabac.c
  231. +++ b/libavcodec/h264_cabac.c
  232. @@ -2329,21 +2329,40 @@ decode_intra_mb:
  233.      if (CHROMA444(h) && IS_8x8DCT(mb_type)){
  234.          int i;
  235.          uint8_t *nnz_cache = sl->non_zero_count_cache;
  236. -        for (i = 0; i < 2; i++){
  237. -            if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
  238. -                nnz_cache[3+8* 1 + 2*8*i]=
  239. -                nnz_cache[3+8* 2 + 2*8*i]=
  240. -                nnz_cache[3+8* 6 + 2*8*i]=
  241. -                nnz_cache[3+8* 7 + 2*8*i]=
  242. -                nnz_cache[3+8*11 + 2*8*i]=
  243. -                nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
  244. +        if (h->sei.unregistered.x264_build < 151U) {
  245. +            for (i = 0; i < 2; i++){
  246. +                if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
  247. +                    nnz_cache[3+8* 1 + 2*8*i]=
  248. +                    nnz_cache[3+8* 2 + 2*8*i]=
  249. +                    nnz_cache[3+8* 6 + 2*8*i]=
  250. +                    nnz_cache[3+8* 7 + 2*8*i]=
  251. +                    nnz_cache[3+8*11 + 2*8*i]=
  252. +                    nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
  253. +                }
  254. +            }
  255. +            if (sl->top_type && !IS_8x8DCT(sl->top_type)){
  256. +                uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
  257. +                AV_WN32A(&nnz_cache[4+8* 0], top_empty);
  258. +                AV_WN32A(&nnz_cache[4+8* 5], top_empty);
  259. +                AV_WN32A(&nnz_cache[4+8*10], top_empty);
  260. +            }
  261. +        } else {
  262. +            for (i = 0; i < 2; i++){
  263. +                if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
  264. +                    nnz_cache[3+8* 1 + 2*8*i]=
  265. +                    nnz_cache[3+8* 2 + 2*8*i]=
  266. +                    nnz_cache[3+8* 6 + 2*8*i]=
  267. +                    nnz_cache[3+8* 7 + 2*8*i]=
  268. +                    nnz_cache[3+8*11 + 2*8*i]=
  269. +                    nnz_cache[3+8*12 + 2*8*i]= !IS_INTRA_PCM(sl->left_type[LEFT(i)]) ? 0 : 64;
  270. +                }
  271. +            }
  272. +            if (sl->top_type && !IS_8x8DCT(sl->top_type)){
  273. +                uint32_t top_empty = !IS_INTRA_PCM(sl->top_type) ? 0 : 0x40404040;
  274. +                AV_WN32A(&nnz_cache[4+8* 0], top_empty);
  275. +                AV_WN32A(&nnz_cache[4+8* 5], top_empty);
  276. +                AV_WN32A(&nnz_cache[4+8*10], top_empty);
  277.              }
  278. -        }
  279. -        if (sl->top_type && !IS_8x8DCT(sl->top_type)){
  280. -            uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
  281. -            AV_WN32A(&nnz_cache[4+8* 0], top_empty);
  282. -            AV_WN32A(&nnz_cache[4+8* 5], top_empty);
  283. -            AV_WN32A(&nnz_cache[4+8*10], top_empty);
  284.          }
  285.      }
  286.      h->cur_pic.mb_type[mb_xy] = mb_type;
  287. --
  288. 2.13.0.windows.1
  289.  
  290.  
  291. From bad5a983d004c2683148b06972c03740a2ef2753 Mon Sep 17 00:00:00 2001
  292. From: Anton Mitrofanov <BugMaster@narod.ru>
  293. Date: Tue, 13 Jun 2017 23:37:29 +0300
  294. Subject: [PATCH 5/6] avcodec/h264_mb: Fix 8x8dct in lossless for new versions
  295.  of x264
  296.  
  297. ---
  298. libavcodec/h264_mb.c | 2 +-
  299.  1 file changed, 1 insertion(+), 1 deletion(-)
  300.  
  301. diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
  302. index da6a31d57..917c6aa3f 100644
  303. --- a/libavcodec/h264_mb.c
  304. +++ b/libavcodec/h264_mb.c
  305. @@ -636,7 +636,7 @@ static av_always_inline void hl_decode_mb_predict_luma(const H264Context *h,
  306.                  uint8_t *const ptr = dest_y + block_offset[i];
  307.                  const int dir      = sl->intra4x4_pred_mode_cache[scan8[i]];
  308.                  if (transform_bypass && h->ps.sps->profile_idc == 244 && dir <= 1) {
  309. -                    if (h->sei.unregistered.x264_build != -1) {
  310. +                    if (h->sei.unregistered.x264_build < 151U) {
  311.                          h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
  312.                      } else
  313.                          h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
  314. --
  315. 2.13.0.windows.1
  316.  
  317.  
  318. From 60810af3feaf1e8d9ccf5be02f649c85d5f27575 Mon Sep 17 00:00:00 2001
  319. From: Anton Mitrofanov <BugMaster@narod.ru>
  320. Date: Wed, 14 Jun 2017 03:01:56 +0300
  321. Subject: [PATCH 6/6] avcodec/h264: Fix mix of lossless and lossy MBs decoding
  322.  
  323. ---
  324. libavcodec/h264_cabac.c | 16 ++++++++--------
  325.  libavcodec/h264_cavlc.c | 16 ++++++++--------
  326.  2 files changed, 16 insertions(+), 16 deletions(-)
  327.  
  328. diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
  329. index c28f5680d..e6dc5258a 100644
  330. --- a/libavcodec/h264_cabac.c
  331. +++ b/libavcodec/h264_cabac.c
  332. @@ -2371,14 +2371,6 @@ decode_intra_mb:
  333.          const uint8_t *scan, *scan8x8;
  334.          const uint32_t *qmul;
  335.  
  336. -        if(IS_INTERLACED(mb_type)){
  337. -            scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
  338. -            scan    = sl->qscale ? h->field_scan : h->field_scan_q0;
  339. -        }else{
  340. -            scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
  341. -            scan    = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
  342. -        }
  343. -
  344.          // decode_cabac_mb_dqp
  345.          if(get_cabac_noinline( &sl->cabac, &sl->cabac_state[60 + (sl->last_qscale_diff != 0)])){
  346.              int val = 1;
  347. @@ -2409,6 +2401,14 @@ decode_intra_mb:
  348.          }else
  349.              sl->last_qscale_diff=0;
  350.  
  351. +        if(IS_INTERLACED(mb_type)){
  352. +            scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
  353. +            scan    = sl->qscale ? h->field_scan : h->field_scan_q0;
  354. +        }else{
  355. +            scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
  356. +            scan    = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
  357. +        }
  358. +
  359.          decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 0);
  360.          if (CHROMA444(h)) {
  361.              decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
  362. diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
  363. index c11e211bd..d57062bc5 100644
  364. --- a/libavcodec/h264_cavlc.c
  365. +++ b/libavcodec/h264_cavlc.c
  366. @@ -1093,14 +1093,6 @@ decode_intra_mb:
  367.          const uint8_t *scan, *scan8x8;
  368.          const int max_qp = 51 + 6 * (h->ps.sps->bit_depth_luma - 8);
  369.  
  370. -        if(IS_INTERLACED(mb_type)){
  371. -            scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0;
  372. -            scan    = sl->qscale ? h->field_scan : h->field_scan_q0;
  373. -        }else{
  374. -            scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0;
  375. -            scan    = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
  376. -        }
  377. -
  378.          dquant= get_se_golomb(&sl->gb);
  379.  
  380.          sl->qscale += dquant;
  381. @@ -1117,6 +1109,14 @@ decode_intra_mb:
  382.          sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
  383.          sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
  384.  
  385. +        if(IS_INTERLACED(mb_type)){
  386. +            scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0;
  387. +            scan    = sl->qscale ? h->field_scan : h->field_scan_q0;
  388. +        }else{
  389. +            scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0;
  390. +            scan    = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
  391. +        }
  392. +
  393.          if ((ret = decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 0)) < 0 ) {
  394.              return -1;
  395.          }
  396. --
  397. 2.13.0.windows.1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top