A 360 video specific tool see https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9503377 passed files: DMVR_A_Huawei_3.bit WRAP_D_InterDigital_4.bit WRAP_A_InterDigital_4.bit WRAP_B_InterDigital_4.bit WRAP_C_InterDigital_4.bit ERP_A_MediaTek_3.bit
Showing the changes to libavcodec (1 of 2 files). Show all
Unified · Split
| @@ -95,20 +95,97 @@ static void emulated_edge_no_wrap(const VVCLocalContext *lc, uint8_t *dst, · 94 unmodified lines | ||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | +static void emulated_half(const VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, | |
| 99 | + const uint8_t *src, const ptrdiff_t src_stride, const int ps, | |
| 100 | + int x_off, int y_off, const int block_w, const int block_h, | |
| 101 | + const VVCRect *subpic,const VVCRect *half_sb, const int dmvr_clip) | |
| 102 | +{ | |
| 103 | + const VVCFrameContext *fc = lc->fc; | |
| 104 | + int pic_width, pic_height; | |
| 105 | + | |
| 106 | + src += y_off * src_stride + x_off * (1 << ps); | |
| 107 | + | |
| 108 | + clip_to_subpic(&x_off, &y_off, &pic_width, &pic_height, subpic, half_sb, dmvr_clip); | |
| 109 | + | |
| 110 | + fc->vdsp.emulated_edge_mc(dst, src, dst_stride, src_stride, | |
| 111 | + block_w, block_h, x_off, y_off, pic_width, pic_height); | |
| 112 | +} | |
| 113 | + | |
| 114 | +static void sb_set_lr(VVCRect *sb, const int l, const int r) | |
| 115 | +{ | |
| 116 | + sb->l = l; | |
| 117 | + sb->r = r; | |
| 118 | +} | |
| 119 | + | |
| 120 | +static void sb_wrap(VVCRect *sb, const int wrap) | |
| 121 | +{ | |
| 122 | + sb_set_lr(sb, sb->l + wrap, sb->r + wrap); | |
| 123 | +} | |
| 124 | + | |
| 98 | 125 | static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst, |
| 99 | 126 | const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame, |
| 100 | 127 | int x_sb, int y_sb, int x_off, int y_off, int block_w, int block_h, const int wrap_enabled, |
| 101 | 128 | const int is_chroma, const int extra_before, const int extra_after) |
| 102 | 129 | { |
| 130 | + const VVCSPS *sps = src_frame->sps; | |
| 131 | + const VVCPPS *pps = src_frame->pps; | |
| 132 | + const int ps = sps->pixel_shift; | |
| 103 | 133 | const int subpic_idx = lc->sc->sh.r->curr_subpic_idx; |
| 134 | + const int extra = extra_before + extra_after; | |
| 104 | 135 | const int dmvr_clip = x_sb != x_off || y_sb != y_off; |
| 136 | + const int dmvr_left = FFMAX(x_off, x_sb) - extra_before; | |
| 137 | + const int dmvr_right = FFMIN(x_off, x_sb) + block_w + extra_after; | |
| 138 | + const int left = x_off - extra_before; | |
| 139 | + const int top = y_off - extra_before; | |
| 140 | + const int pic_width = pps->width >> sps->hshift[is_chroma]; | |
| 141 | + const int wrap = pps->ref_wraparound_offset << (sps->min_cb_log2_size_y - sps->hshift[is_chroma]); | |
| 142 | + const ptrdiff_t dst_stride = EDGE_EMU_BUFFER_STRIDE << ps; | |
| 105 | 143 | VVCRect sb = { x_sb - extra_before, y_sb - extra_before, x_sb + block_w + extra_after, y_sb + block_h + extra_after }; |
| 106 | 144 | VVCRect subpic; |
| 107 | 145 | |
| 108 | 146 | subpic_get_rect(&subpic, src_frame, subpic_idx, is_chroma); |
| 109 | 147 | |
| 110 | − return emulated_edge_no_wrap(lc, dst, src, src_stride, | |
| 111 | − x_off, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip); | |
| 148 | + if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) { | |
| 149 | + return emulated_edge_no_wrap(lc, dst, src, src_stride, | |
| 150 | + x_off, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip); | |
| 151 | + } | |
| 152 | + if (dmvr_right <= 0) { | |
| 153 | + sb_wrap(&sb, wrap); | |
| 154 | + return emulated_edge_no_wrap(lc, dst, src, src_stride, | |
| 155 | + x_off + wrap, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip); | |
| 156 | + } | |
| 157 | + if (dmvr_left >= pic_width) { | |
| 158 | + sb_wrap(&sb, -wrap); | |
| 159 | + return emulated_edge_no_wrap(lc, dst, src, src_stride, | |
| 160 | + x_off - wrap, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip); | |
| 161 | + } | |
| 162 | + | |
| 163 | + block_w += extra; | |
| 164 | + block_h += extra; | |
| 165 | + | |
| 166 | + // half block are wrapped | |
| 167 | + if (dmvr_left < 0 ) { | |
| 168 | + const int w = -left; | |
| 169 | + VVCRect half_sb = { sb.l + wrap, sb.t, 0 + wrap, sb.b }; | |
| 170 | + emulated_half(lc, dst, dst_stride, *src, *src_stride, ps, | |
| 171 | + left + wrap, top, w, block_h, &subpic, &half_sb, dmvr_clip); | |
| 172 | + | |
| 173 | + sb_set_lr(&half_sb, 0, sb.r); | |
| 174 | + emulated_half(lc, dst + (w << ps), dst_stride, *src, *src_stride, ps, | |
| 175 | + 0, top, block_w - w, block_h, &subpic, &half_sb, dmvr_clip); | |
| 176 | + } else { | |
| 177 | + const int w = pic_width - left; | |
| 178 | + VVCRect half_sb = { sb.l, sb.t, pic_width, sb.b }; | |
| 179 | + emulated_half(lc, dst, dst_stride, *src, *src_stride, ps, | |
| 180 | + left, top, w, block_h, &subpic, &half_sb, dmvr_clip); | |
| 181 | + | |
| 182 | + sb_set_lr(&half_sb, pic_width - wrap, sb.r - wrap); | |
| 183 | + emulated_half(lc, dst + (w << ps), dst_stride, *src, *src_stride, ps, | |
| 184 | + pic_width - wrap , top, block_w - w, block_h, &subpic, &half_sb, dmvr_clip); | |
| 185 | + } | |
| 186 | + | |
| 187 | + *src = dst + extra_before * dst_stride + (extra_before << ps); | |
| 188 | + *src_stride = dst_stride; | |
| 112 | 189 | } |
| 113 | 190 | |
| 114 | 191 | #define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off) \ |