Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From cc2ad6dcb3131a8ae0339e95f64a319b7ed25356 Mon Sep 17 00:00:00 2001
- From: Michael Niedermayer <michaelni@gmx.at>
- Date: Wed, 29 Apr 2015 15:13:24 +0200
- Subject: [PATCH 1/6] avcodec/h264_slice: Also copy x264_build in
- ff_h264_update_thread_context()
- Fixes fate-h264-lossless
- Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
- ---
- libavcodec/h264_slice.c | 1 +
- 1 file changed, 1 insertion(+)
- diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
- index c9f1dbb86..0ce4127a1 100644
- --- a/libavcodec/h264_slice.c
- +++ b/libavcodec/h264_slice.c
- @@ -408,6 +408,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
- // extradata/NAL handling
- h->is_avc = h1->is_avc;
- h->nal_length_size = h1->nal_length_size;
- + h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
- memcpy(&h->poc, &h1->poc, sizeof(h->poc));
- --
- 2.13.0.windows.1
- From 08f803b1ca24a95fed43ea022299f31454ff9858 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Tue, 13 Jun 2017 22:48:47 +0300
- Subject: [PATCH 2/6] avcodec/h264: Don't reset the x264 build info once read
- In order to fix fate-h264-lossless (change by Hendrik)
- ---
- libavcodec/h264_sei.c | 1 -
- libavcodec/h264dec.c | 1 +
- 2 files changed, 1 insertion(+), 1 deletion(-)
- diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
- index 3ca2b7a6c..a2151bfaf 100644
- --- a/libavcodec/h264_sei.c
- +++ b/libavcodec/h264_sei.c
- @@ -38,7 +38,6 @@ static const uint8_t sei_num_clock_ts_table[9] = {
- void ff_h264_sei_uninit(H264SEIContext *h)
- {
- - h->unregistered.x264_build = -1;
- h->recovery_point.recovery_frame_cnt = -1;
- h->picture_timing.dpb_output_delay = 0;
- diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
- index 2a532a7ef..c81510fc0 100644
- --- a/libavcodec/h264dec.c
- +++ b/libavcodec/h264dec.c
- @@ -294,6 +294,7 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
- h->poc.prev_poc_msb = 1 << 16;
- h->recovery_frame = -1;
- h->frame_recovered = 0;
- + h->sei.unregistered.x264_build = -1;
- h->next_outputed_poc = INT_MIN;
- for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
- --
- 2.13.0.windows.1
- From f00b6921631f9b206c9acf0679366cb6f38e2a4e Mon Sep 17 00:00:00 2001
- From: Yogender Kumar Gupta <yogender.gupta@gmail.com>
- Date: Tue, 18 Mar 2014 16:01:15 +0530
- Subject: [PATCH 3/6] avcodec/h264: fix Lossless Decoding (Profile 244) for 8x8
- Intra Prediction
- This is limited to the case where x264_build = -1, to not break x264 decoding
- Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
- ---
- libavcodec/h264_mb.c | 7 +++-
- libavcodec/h264pred.c | 2 ++
- libavcodec/h264pred.h | 2 ++
- libavcodec/h264pred_template.c | 73 ++++++++++++++++++++++++++++++++++++++++++
- 4 files changed, 83 insertions(+), 1 deletion(-)
- diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
- index f037bd516..da6a31d57 100644
- --- a/libavcodec/h264_mb.c
- +++ b/libavcodec/h264_mb.c
- @@ -636,7 +636,12 @@ static av_always_inline void hl_decode_mb_predict_luma(const H264Context *h,
- uint8_t *const ptr = dest_y + block_offset[i];
- const int dir = sl->intra4x4_pred_mode_cache[scan8[i]];
- if (transform_bypass && h->ps.sps->profile_idc == 244 && dir <= 1) {
- - h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- + if (h->sei.unregistered.x264_build != -1) {
- + h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- + } else
- + h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
- + (sl-> topleft_samples_available << i) & 0x8000,
- + (sl->topright_samples_available << i) & 0x4000, linesize);
- } else {
- const int nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
- h->hpc.pred8x8l[dir](ptr, (sl->topleft_samples_available << i) & 0x8000,
- diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c
- index 7627eb076..135babcab 100644
- --- a/libavcodec/h264pred.c
- +++ b/libavcodec/h264pred.c
- @@ -552,6 +552,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
- h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\
- h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\
- h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\
- + h->pred8x8l_filter_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_filter_add , depth);\
- + h->pred8x8l_filter_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_filter_add , depth);\
- if (chroma_format_idc <= 1) {\
- h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
- h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
- diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h
- index 60e74349c..6e495f9fc 100644
- --- a/libavcodec/h264pred.h
- +++ b/libavcodec/h264pred.h
- @@ -101,6 +101,8 @@ typedef struct H264PredContext {
- int16_t *block /*align 16*/, ptrdiff_t stride);
- void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/,
- int16_t *block /*align 16*/, ptrdiff_t stride);
- + void(*pred8x8l_filter_add[2])(uint8_t *pix /*align 8*/,
- + int16_t *block /*align 16*/, int topleft, int topright, ptrdiff_t stride);
- void(*pred8x8_add[3])(uint8_t *pix /*align 8*/,
- const int *block_offset,
- int16_t *block /*align 16*/, ptrdiff_t stride);
- diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c
- index 8492b2b0a..42ff350b4 100644
- --- a/libavcodec/h264pred_template.c
- +++ b/libavcodec/h264pred_template.c
- @@ -1123,6 +1123,79 @@ static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft,
- SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
- SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
- }
- +
- +static void FUNCC(pred8x8l_vertical_filter_add)(uint8_t *_src, int16_t *_block, int has_topleft,
- + int has_topright, ptrdiff_t _stride)
- +{
- + int i;
- + pixel *src = (pixel*)_src;
- + const dctcoef *block = (const dctcoef*)_block;
- + pixel pix[8];
- + int stride = _stride/sizeof(pixel);
- + PREDICT_8x8_LOAD_TOP;
- +
- + pix[0] = t0;
- + pix[1] = t1;
- + pix[2] = t2;
- + pix[3] = t3;
- + pix[4] = t4;
- + pix[5] = t5;
- + pix[6] = t6;
- + pix[7] = t7;
- +
- + for(i=0; i<8; i++){
- + pixel v = pix[i];
- + src[0*stride]= v += block[0];
- + src[1*stride]= v += block[8];
- + src[2*stride]= v += block[16];
- + src[3*stride]= v += block[24];
- + src[4*stride]= v += block[32];
- + src[5*stride]= v += block[40];
- + src[6*stride]= v += block[48];
- + src[7*stride]= v + block[56];
- + src++;
- + block++;
- + }
- +
- + memset(_block, 0, sizeof(dctcoef) * 64);
- +}
- +
- +static void FUNCC(pred8x8l_horizontal_filter_add)(uint8_t *_src, int16_t *_block, int has_topleft,
- + int has_topright, ptrdiff_t _stride)
- +{
- + int i;
- + pixel *src = (pixel*)_src;
- + const dctcoef *block = (const dctcoef*)_block;
- + pixel pix[8];
- + int stride = _stride/sizeof(pixel);
- + PREDICT_8x8_LOAD_LEFT;
- +
- + pix[0] = l0;
- + pix[1] = l1;
- + pix[2] = l2;
- + pix[3] = l3;
- + pix[4] = l4;
- + pix[5] = l5;
- + pix[6] = l6;
- + pix[7] = l7;
- +
- + for(i=0; i<8; i++){
- + pixel v = pix[i];
- + src[0]= v += block[0];
- + src[1]= v += block[1];
- + src[2]= v += block[2];
- + src[3]= v += block[3];
- + src[4]= v += block[4];
- + src[5]= v += block[5];
- + src[6]= v += block[6];
- + src[7]= v + block[7];
- + src+= stride;
- + block+= 8;
- + }
- +
- + memset(_block, 0, sizeof(dctcoef) * 64);
- +}
- +
- #undef PREDICT_8x8_LOAD_LEFT
- #undef PREDICT_8x8_LOAD_TOP
- #undef PREDICT_8x8_LOAD_TOPLEFT
- --
- 2.13.0.windows.1
- From 459a04551e39b726ecb253fbfa81e5d28a17b80f Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Wed, 31 May 2017 02:37:41 +0300
- Subject: [PATCH 4/6] avcodec/h264_cabac: Fix CABAC+8x8dct in 4:4:4
- Use the correct ctxIdxInc calculation for coded_block_flag.
- Keep old behavior for old versions of x264 for backward compatibility.
- ---
- libavcodec/h264_cabac.c | 47 +++++++++++++++++++++++++++++++++--------------
- 1 file changed, 33 insertions(+), 14 deletions(-)
- diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
- index b28e486e5..c28f5680d 100644
- --- a/libavcodec/h264_cabac.c
- +++ b/libavcodec/h264_cabac.c
- @@ -2329,21 +2329,40 @@ decode_intra_mb:
- if (CHROMA444(h) && IS_8x8DCT(mb_type)){
- int i;
- uint8_t *nnz_cache = sl->non_zero_count_cache;
- - for (i = 0; i < 2; i++){
- - if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
- - nnz_cache[3+8* 1 + 2*8*i]=
- - nnz_cache[3+8* 2 + 2*8*i]=
- - nnz_cache[3+8* 6 + 2*8*i]=
- - nnz_cache[3+8* 7 + 2*8*i]=
- - nnz_cache[3+8*11 + 2*8*i]=
- - nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
- + if (h->sei.unregistered.x264_build < 151U) {
- + for (i = 0; i < 2; i++){
- + if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
- + nnz_cache[3+8* 1 + 2*8*i]=
- + nnz_cache[3+8* 2 + 2*8*i]=
- + nnz_cache[3+8* 6 + 2*8*i]=
- + nnz_cache[3+8* 7 + 2*8*i]=
- + nnz_cache[3+8*11 + 2*8*i]=
- + nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
- + }
- + }
- + if (sl->top_type && !IS_8x8DCT(sl->top_type)){
- + uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
- + AV_WN32A(&nnz_cache[4+8* 0], top_empty);
- + AV_WN32A(&nnz_cache[4+8* 5], top_empty);
- + AV_WN32A(&nnz_cache[4+8*10], top_empty);
- + }
- + } else {
- + for (i = 0; i < 2; i++){
- + if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
- + nnz_cache[3+8* 1 + 2*8*i]=
- + nnz_cache[3+8* 2 + 2*8*i]=
- + nnz_cache[3+8* 6 + 2*8*i]=
- + nnz_cache[3+8* 7 + 2*8*i]=
- + nnz_cache[3+8*11 + 2*8*i]=
- + nnz_cache[3+8*12 + 2*8*i]= !IS_INTRA_PCM(sl->left_type[LEFT(i)]) ? 0 : 64;
- + }
- + }
- + if (sl->top_type && !IS_8x8DCT(sl->top_type)){
- + uint32_t top_empty = !IS_INTRA_PCM(sl->top_type) ? 0 : 0x40404040;
- + AV_WN32A(&nnz_cache[4+8* 0], top_empty);
- + AV_WN32A(&nnz_cache[4+8* 5], top_empty);
- + AV_WN32A(&nnz_cache[4+8*10], top_empty);
- }
- - }
- - if (sl->top_type && !IS_8x8DCT(sl->top_type)){
- - uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
- - AV_WN32A(&nnz_cache[4+8* 0], top_empty);
- - AV_WN32A(&nnz_cache[4+8* 5], top_empty);
- - AV_WN32A(&nnz_cache[4+8*10], top_empty);
- }
- }
- h->cur_pic.mb_type[mb_xy] = mb_type;
- --
- 2.13.0.windows.1
- From bad5a983d004c2683148b06972c03740a2ef2753 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Tue, 13 Jun 2017 23:37:29 +0300
- Subject: [PATCH 5/6] avcodec/h264_mb: Fix 8x8dct in lossless for new versions
- of x264
- ---
- libavcodec/h264_mb.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
- index da6a31d57..917c6aa3f 100644
- --- a/libavcodec/h264_mb.c
- +++ b/libavcodec/h264_mb.c
- @@ -636,7 +636,7 @@ static av_always_inline void hl_decode_mb_predict_luma(const H264Context *h,
- uint8_t *const ptr = dest_y + block_offset[i];
- const int dir = sl->intra4x4_pred_mode_cache[scan8[i]];
- if (transform_bypass && h->ps.sps->profile_idc == 244 && dir <= 1) {
- - if (h->sei.unregistered.x264_build != -1) {
- + if (h->sei.unregistered.x264_build < 151U) {
- h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
- } else
- h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
- --
- 2.13.0.windows.1
- From 60810af3feaf1e8d9ccf5be02f649c85d5f27575 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Wed, 14 Jun 2017 03:01:56 +0300
- Subject: [PATCH 6/6] avcodec/h264: Fix mix of lossless and lossy MBs decoding
- ---
- libavcodec/h264_cabac.c | 16 ++++++++--------
- libavcodec/h264_cavlc.c | 16 ++++++++--------
- 2 files changed, 16 insertions(+), 16 deletions(-)
- diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
- index c28f5680d..e6dc5258a 100644
- --- a/libavcodec/h264_cabac.c
- +++ b/libavcodec/h264_cabac.c
- @@ -2371,14 +2371,6 @@ decode_intra_mb:
- const uint8_t *scan, *scan8x8;
- const uint32_t *qmul;
- - if(IS_INTERLACED(mb_type)){
- - scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
- - scan = sl->qscale ? h->field_scan : h->field_scan_q0;
- - }else{
- - scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
- - scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- - }
- -
- // decode_cabac_mb_dqp
- if(get_cabac_noinline( &sl->cabac, &sl->cabac_state[60 + (sl->last_qscale_diff != 0)])){
- int val = 1;
- @@ -2409,6 +2401,14 @@ decode_intra_mb:
- }else
- sl->last_qscale_diff=0;
- + if(IS_INTERLACED(mb_type)){
- + scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
- + scan = sl->qscale ? h->field_scan : h->field_scan_q0;
- + }else{
- + scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
- + scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- + }
- +
- decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 0);
- if (CHROMA444(h)) {
- decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
- diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
- index c11e211bd..d57062bc5 100644
- --- a/libavcodec/h264_cavlc.c
- +++ b/libavcodec/h264_cavlc.c
- @@ -1093,14 +1093,6 @@ decode_intra_mb:
- const uint8_t *scan, *scan8x8;
- const int max_qp = 51 + 6 * (h->ps.sps->bit_depth_luma - 8);
- - if(IS_INTERLACED(mb_type)){
- - scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0;
- - scan = sl->qscale ? h->field_scan : h->field_scan_q0;
- - }else{
- - scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0;
- - scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- - }
- -
- dquant= get_se_golomb(&sl->gb);
- sl->qscale += dquant;
- @@ -1117,6 +1109,14 @@ decode_intra_mb:
- sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
- sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
- + if(IS_INTERLACED(mb_type)){
- + scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0;
- + scan = sl->qscale ? h->field_scan : h->field_scan_q0;
- + }else{
- + scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0;
- + scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- + }
- +
- if ((ret = decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 0)) < 0 ) {
- return -1;
- }
- --
- 2.13.0.windows.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement