43 #if CONFIG_VP7_DECODER && CONFIG_VP8_DECODER 44 #define VPX(vp7, f) (vp7 ? vp7_ ## f : vp8_ ## f) 45 #elif CONFIG_VP7_DECODER 46 #define VPX(vp7, f) vp7_ ## f 47 #else // CONFIG_VP8_DECODER 48 #define VPX(vp7, f) vp8_ ## f 104 #if CONFIG_VP8_DECODER 153 for (i = 0; i < 5; i++)
174 #if CONFIG_VP8_VAAPI_HWACCEL 177 #if CONFIG_VP8_NVDEC_HWACCEL 191 int i,
ret, dim_reset = 0;
274 for (i = 0; i < 4; i++)
277 for (i = 0; i < 4; i++)
281 for (i = 0; i < 3; i++)
290 for (i = 0; i < 4; i++) {
324 if (buf_size - size < 0)
372 for (i = 0; i < 4; i++) {
425 for (i = 0; i < 4; i++)
426 for (j = 0; j < 16; j++)
436 for (i = 0; i < 4; i++)
437 for (j = 0; j < 8; j++)
438 for (k = 0; k < 3; k++)
447 #define VP7_MVC_SIZE 17 448 #define VP8_MVC_SIZE 19 457 for (i = 0; i < 4; i++)
460 for (i = 0; i < 3; i++)
464 for (i = 0; i < 2; i++)
465 for (j = 0; j < mvc_size; j++)
485 for (j = 1; j < 3; j++) {
486 for (i = 0; i < height / 2; i++)
493 const uint8_t *src, ptrdiff_t src_linesize,
498 for (j = 0; j <
height; j++) {
499 const uint8_t *src2 = src + j * src_linesize;
500 uint8_t *dst2 = dst + j * dst_linesize;
501 for (i = 0; i <
width; i++) {
512 if (!s->
keyframe && (alpha || beta)) {
539 width, height, alpha, beta);
548 int part1_size, hscale, vscale,
i, j,
ret;
558 s->
profile = (buf[0] >> 1) & 7;
566 part1_size =
AV_RL24(buf) >> 4;
568 if (buf_size < 4 - s->
profile + part1_size) {
582 buf_size -= part1_size;
590 if (hscale || vscale)
599 for (i = 0; i < 2; i++)
611 for (i = 0; i < 4; i++) {
616 for (j = 0; j < 3; j++)
621 for (j = 0; j < 4; j++)
679 for (i = 1; i < 16; i++)
712 int header_size, hscale, vscale,
ret;
724 header_size =
AV_RL24(buf) >> 5;
740 if (header_size > buf_size - 7 * s->
keyframe) {
746 if (
AV_RL24(buf) != 0x2a019d) {
748 "Invalid start code 0x%x\n",
AV_RL24(buf));
751 width =
AV_RL16(buf + 3) & 0x3fff;
752 height =
AV_RL16(buf + 5) & 0x3fff;
753 hscale = buf[4] >> 6;
754 vscale = buf[6] >> 6;
758 if (hscale || vscale)
777 buf_size -= header_size;
868 for (i = 0; i < 3; i++)
870 for (i = (vp7 ? 7 : 9); i > 3; i--)
925 const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
935 top_mv = top_mb->
bmv;
951 for (n = 0; n < num; n++) {
953 uint32_t
left, above;
957 left =
AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
959 left =
AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
961 above =
AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
963 above =
AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
1000 int xoffset,
int yoffset,
int boundary,
1001 int *edge_x,
int *edge_y)
1003 int vwidth = mb_width + 1;
1004 int new = (mb_y + yoffset) * vwidth + mb_x + xoffset;
1005 if (
new < boundary ||
new % vwidth == vwidth - 1)
1007 *edge_y =
new / vwidth;
1008 *edge_x =
new % vwidth;
1019 int mb_x,
int mb_y,
int layout)
1022 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
1023 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1047 if (
AV_RN32A(&near_mv[CNT_NEAREST])) {
1048 if (mv ==
AV_RN32A(&near_mv[CNT_NEAREST])) {
1050 }
else if (
AV_RN32A(&near_mv[CNT_NEAR])) {
1051 if (mv !=
AV_RN32A(&near_mv[CNT_NEAR]))
1059 AV_WN32A(&near_mv[CNT_NEAREST], mv);
1080 if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
1081 AV_WN32A(&mb->
mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 :
AV_RN32A(&near_mv[CNT_NEAREST]));
1091 mb->
bmv[0] = mb->
mv;
1094 mb->
mv = near_mv[CNT_NEAR];
1095 mb->
bmv[0] = mb->
mv;
1098 mb->
mv = near_mv[CNT_NEAREST];
1099 mb->
bmv[0] = mb->
mv;
1104 mb->
bmv[0] = mb->
mv;
1110 int mb_x,
int mb_y,
int layout)
1115 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
1116 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1125 mb_edge[0] = mb + 2;
1126 mb_edge[2] = mb + 1;
1137 #define MV_EDGE_CHECK(n) \ 1139 VP8Macroblock *edge = mb_edge[n]; \ 1140 int edge_ref = edge->ref_frame; \ 1141 if (edge_ref != VP56_FRAME_CURRENT) { \ 1142 uint32_t mv = AV_RN32A(&edge->mv); \ 1144 if (cur_sign_bias != sign_bias[edge_ref]) { \ 1147 mv = ((mv & 0x7fff7fff) + \ 1148 0x00010001) ^ (mv & 0x80008000); \ 1150 if (!n || mv != AV_RN32A(&near_mv[idx])) \ 1151 AV_WN32A(&near_mv[++idx], mv); \ 1152 cnt[idx] += 1 + (n != 2); \ 1154 cnt[CNT_ZERO] += 1 + (n != 2); \ 1167 if (cnt[CNT_SPLITMV] &&
1168 AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) ==
AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
1169 cnt[CNT_NEAREST] += 1;
1172 if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
1174 FFSWAP(
VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
1180 clamp_mv(mv_bounds, &mb->
mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
1191 mb->
bmv[0] = mb->
mv;
1194 clamp_mv(mv_bounds, &mb->
mv, &near_mv[CNT_NEAR]);
1195 mb->
bmv[0] = mb->
mv;
1198 clamp_mv(mv_bounds, &mb->
mv, &near_mv[CNT_NEAREST]);
1199 mb->
bmv[0] = mb->
mv;
1204 mb->
bmv[0] = mb->
mv;
1210 int mb_x,
int keyframe,
int layout)
1226 for (y = 0; y < 4; y++) {
1227 for (x = 0; x < 4; x++) {
1231 left[y] = top[x] = *intra4x4;
1237 for (i = 0; i < 16; i++)
1249 static const char *
const vp7_feature_name[] = {
"q-index",
1251 "partial-golden-update",
1256 for (i = 0; i < 4; i++) {
1262 "Feature %s present in macroblock (value 0x%x)\n",
1271 *segment = ref ? *ref : *segment;
1338 int i,
uint8_t *token_prob, int16_t qmul[2],
1339 const uint8_t scan[16],
int vp7)
1353 token_prob = probs[
i][0];
1361 token_prob = probs[i + 1][1];
1381 int cat = (a << 1) + b;
1382 coeff = 3 + (8 <<
cat);
1386 token_prob = probs[i + 1][2];
1398 int16_t
dc = block[0];
1407 block[0] = pred[0] =
dc;
1412 block[0] = pred[0] =
dc;
1426 token_prob, qmul, scan,
IS_VP7);
1429 #ifndef vp8_decode_block_coeffs_internal 1457 int i,
int zero_nhood, int16_t qmul[2],
1458 const uint8_t scan[16],
int vp7)
1460 uint8_t *token_prob = probs[
i][zero_nhood];
1464 token_prob, qmul, scan)
1474 int i, x, y, luma_start = 0, luma_ctx = 3;
1475 int nnz_pred, nnz, nnz_total = 0;
1480 nnz_pred = t_nnz[8] + l_nnz[8];
1486 l_nnz[8] = t_nnz[8] = !!nnz;
1506 for (y = 0; y < 4; y++)
1507 for (x = 0; x < 4; x++) {
1508 nnz_pred = l_nnz[y] + t_nnz[x];
1511 luma_start, nnz_pred,
1517 t_nnz[x] = l_nnz[y] = !!nnz;
1524 for (i = 4; i < 6; i++)
1525 for (y = 0; y < 2; y++)
1526 for (x = 0; x < 2; x++) {
1527 nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x];
1533 t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz;
1547 ptrdiff_t linesize, ptrdiff_t uvlinesize,
int simple)
1549 AV_COPY128(top_border, src_y + 15 * linesize);
1551 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
1552 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
1558 uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize,
int mb_x,
1559 int mb_y,
int mb_width,
int simple,
int xchg)
1561 uint8_t *top_border_m1 = top_border - 32;
1563 src_cb -= uvlinesize;
1564 src_cr -= uvlinesize;
1566 #define XCHG(a, b, xchg) \ 1574 XCHG(top_border_m1 + 8, src_y - 8, xchg);
1575 XCHG(top_border, src_y, xchg);
1576 XCHG(top_border + 8, src_y + 8, 1);
1577 if (mb_x < mb_width - 1)
1578 XCHG(top_border + 32, src_y + 16, 1);
1582 if (!simple || !mb_y) {
1583 XCHG(top_border_m1 + 16, src_cb - 8, xchg);
1584 XCHG(top_border_m1 + 24, src_cr - 8, xchg);
1585 XCHG(top_border + 16, src_cb, 1);
1586 XCHG(top_border + 24, src_cr, 1);
1636 int *copy_buf,
int vp7)
1640 if (!mb_x && mb_y) {
1674 int x, y,
mode, nnz;
1690 const uint8_t lo = is_vp7 ? 128 : 127;
1691 const uint8_t hi = is_vp7 ? 128 : 129;
1692 uint8_t tr_top[4] = { lo, lo, lo, lo };
1700 if (mb_y && mb_x == s->
mb_width - 1) {
1701 tr = tr_right[-1] * 0x01010101
u;
1708 for (y = 0; y < 4; y++) {
1710 for (x = 0; x < 4; x++) {
1716 if ((y == 0 || x == 3) && mb_y == 0) {
1719 topright = tr_right;
1722 mb_y + y, ©, is_vp7);
1724 dst = copy_dst + 12;
1728 AV_WN32A(copy_dst + 4, lo * 0x01010101U);
1734 copy_dst[3] = ptr[4 * x - s->
linesize - 1];
1743 copy_dst[11] = ptr[4 * x - 1];
1744 copy_dst[19] = ptr[4 * x + s->
linesize - 1];
1745 copy_dst[27] = ptr[4 * x + s->
linesize * 2 - 1];
1746 copy_dst[35] = ptr[4 * x + s->
linesize * 3 - 1];
1775 mb_x, mb_y, is_vp7);
1786 { 0, 1, 2, 1, 2, 1, 2, 1 },
1788 { 0, 3, 5, 3, 5, 3, 5, 3 },
1789 { 0, 2, 3, 2, 3, 2, 3, 2 },
1811 int x_off,
int y_off,
int block_w,
int block_h,
1818 ptrdiff_t src_linesize = linesize;
1820 int mx = (mv->
x * 2) & 7, mx_idx =
subpel_idx[0][mx];
1821 int my = (mv->
y * 2) & 7, my_idx =
subpel_idx[0][my];
1823 x_off += mv->
x >> 2;
1824 y_off += mv->
y >> 2;
1828 src += y_off * linesize + x_off;
1829 if (x_off < mx_idx || x_off >= width - block_w -
subpel_idx[2][mx] ||
1830 y_off < my_idx || y_off >= height - block_h -
subpel_idx[2][my]) {
1832 src - my_idx * linesize - mx_idx,
1836 x_off - mx_idx, y_off - my_idx,
1841 mc_func[my_idx][mx_idx](dst, linesize,
src, src_linesize, block_h, mx, my);
1844 mc_func[0][0](dst, linesize, src + y_off * linesize + x_off,
1845 linesize, block_h, 0, 0);
1869 int x_off,
int y_off,
int block_w,
int block_h,
1879 x_off += mv->
x >> 3;
1880 y_off += mv->
y >> 3;
1883 src1 += y_off * linesize + x_off;
1884 src2 += y_off * linesize + x_off;
1886 if (x_off < mx_idx || x_off >= width - block_w -
subpel_idx[2][mx] ||
1887 y_off < my_idx || y_off >= height - block_h -
subpel_idx[2][my]) {
1889 src1 - my_idx * linesize - mx_idx,
1893 x_off - mx_idx, y_off - my_idx, width, height);
1898 src2 - my_idx * linesize - mx_idx,
1899 EDGE_EMU_LINESIZE, linesize,
1902 x_off - mx_idx, y_off - my_idx, width, height);
1904 mc_func[my_idx][mx_idx](dst2, linesize, src2,
EDGE_EMU_LINESIZE, block_h, mx, my);
1906 mc_func[my_idx][mx_idx](dst1, linesize,
src1, linesize, block_h, mx, my);
1907 mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
1911 mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1912 mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1919 int bx_off,
int by_off,
int block_w,
int block_h,
1926 ref_frame, mv, x_off + bx_off, y_off + by_off,
1927 block_w, block_h, width, height, s->
linesize,
1946 dst[2] + by_off * s->
uvlinesize + bx_off, ref_frame,
1947 &uvmv, x_off + bx_off, y_off + by_off,
1948 block_w, block_h, width, height, s->
uvlinesize,
1959 if (s->
ref_count[ref - 1] > (mb_xy >> 5)) {
1960 int x_off = mb_x << 4, y_off = mb_y << 4;
1961 int mx = (mb->
mv.
x >> 2) + x_off + 8;
1962 int my = (mb->
mv.
y >> 2) + y_off;
1964 int off = mx + (my + (mb_x & 3) * 4) * s->
linesize + 64;
1969 off = (mx >> 1) + ((my >> 1) + (mb_x & 7)) * s->
uvlinesize + 64;
1981 int x_off = mb_x << 4, y_off = mb_y << 4;
1989 0, 0, 16, 16, width,
height, &mb->
mv);
1996 for (y = 0; y < 4; y++) {
1997 for (x = 0; x < 4; x++) {
1999 ref, &bmv[4 * y + x],
2000 4 * x + x_off, 4 * y + y_off, 4, 4,
2011 for (y = 0; y < 2; y++) {
2012 for (x = 0; x < 2; x++) {
2013 uvmv.
x = mb->
bmv[2 * y * 4 + 2 * x ].
x +
2014 mb->
bmv[2 * y * 4 + 2 * x + 1].
x +
2015 mb->
bmv[(2 * y + 1) * 4 + 2 * x ].x +
2016 mb->
bmv[(2 * y + 1) * 4 + 2 * x + 1].
x;
2017 uvmv.
y = mb->
bmv[2 * y * 4 + 2 * x ].
y +
2018 mb->
bmv[2 * y * 4 + 2 * x + 1].
y +
2019 mb->
bmv[(2 * y + 1) * 4 + 2 * x ].y +
2020 mb->
bmv[(2 * y + 1) * 4 + 2 * x + 1].
y;
2029 &uvmv, 4 * x + x_off, 4 * y + y_off, 4, 4,
2038 0, 0, 16, 8, width,
height, &bmv[0]);
2040 0, 8, 16, 8, width,
height, &bmv[1]);
2044 0, 0, 8, 16, width,
height, &bmv[0]);
2046 8, 0, 8, 16, width,
height, &bmv[1]);
2050 0, 0, 8, 8, width,
height, &bmv[0]);
2052 8, 0, 8, 8, width,
height, &bmv[1]);
2054 0, 8, 8, 8, width,
height, &bmv[2]);
2056 8, 8, 8, 8, width,
height, &bmv[3]);
2068 for (y = 0; y < 4; y++) {
2071 if (nnz4 & ~0x01010101) {
2072 for (x = 0; x < 4; x++) {
2093 for (ch = 0; ch < 2; ch++) {
2096 uint8_t *ch_dst = dst[1 + ch];
2097 if (nnz4 & ~0x01010101) {
2098 for (y = 0; y < 2; y++) {
2099 for (x = 0; x < 2; x++) {
2102 td->
block[4 + ch][(y << 1) + x],
2106 td->
block[4 + ch][(y << 1) + x],
2110 goto chroma_idct_end;
2127 int interior_limit, filter_level;
2143 interior_limit = filter_level;
2148 interior_limit =
FFMAX(interior_limit, 1);
2158 int mb_x,
int mb_y,
int is_vp7)
2160 int mbedge_lim, bedge_lim_y, bedge_lim_uv, hev_thresh;
2166 static const uint8_t hev_thresh_lut[2][64] = {
2167 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2169 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2171 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2172 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2181 bedge_lim_y = filter_level;
2182 bedge_lim_uv = filter_level * 2;
2183 mbedge_lim = filter_level + 2;
2186 bedge_lim_uv = filter_level * 2 + inner_limit;
2187 mbedge_lim = bedge_lim_y + 4;
2190 hev_thresh = hev_thresh_lut[s->
keyframe][filter_level];
2194 mbedge_lim, inner_limit, hev_thresh);
2196 mbedge_lim, inner_limit, hev_thresh);
2199 #define H_LOOP_FILTER_16Y_INNER(cond) \ 2200 if (cond && inner_filter) { \ 2201 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 4, linesize, \ 2202 bedge_lim_y, inner_limit, \ 2204 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 8, linesize, \ 2205 bedge_lim_y, inner_limit, \ 2207 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 12, linesize, \ 2208 bedge_lim_y, inner_limit, \ 2210 s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4, \ 2211 uvlinesize, bedge_lim_uv, \ 2212 inner_limit, hev_thresh); \ 2219 mbedge_lim, inner_limit, hev_thresh);
2221 mbedge_lim, inner_limit, hev_thresh);
2226 linesize, bedge_lim_y,
2227 inner_limit, hev_thresh);
2229 linesize, bedge_lim_y,
2230 inner_limit, hev_thresh);
2232 linesize, bedge_lim_y,
2233 inner_limit, hev_thresh);
2235 dst[2] + 4 * uvlinesize,
2236 uvlinesize, bedge_lim_uv,
2237 inner_limit, hev_thresh);
2247 int mbedge_lim, bedge_lim;
2256 bedge_lim = 2 * filter_level + inner_limit;
2257 mbedge_lim = bedge_lim + 4;
2276 #define MARGIN (16 << 2) 2286 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
2288 ((s->
mb_width + 1) * (mb_y + 1) + 1);
2296 for (mb_x = 0; mb_x < s->
mb_width; mb_x++, mb_xy++, mb++) {
2304 prev_frame && prev_frame->
seg_map ?
2328 #define check_thread_pos(td, otd, mb_x_check, mb_y_check) \ 2330 int tmp = (mb_y_check << 16) | (mb_x_check & 0xFFFF); \ 2331 if (atomic_load(&otd->thread_mb_pos) < tmp) { \ 2332 pthread_mutex_lock(&otd->lock); \ 2333 atomic_store(&td->wait_mb_pos, tmp); \ 2335 if (atomic_load(&otd->thread_mb_pos) >= tmp) \ 2337 pthread_cond_wait(&otd->cond, &otd->lock); \ 2339 atomic_store(&td->wait_mb_pos, INT_MAX); \ 2340 pthread_mutex_unlock(&otd->lock); \ 2344 #define update_pos(td, mb_y, mb_x) \ 2346 int pos = (mb_y << 16) | (mb_x & 0xFFFF); \ 2347 int sliced_threading = (avctx->active_thread_type == FF_THREAD_SLICE) && \ 2349 int is_null = !next_td || !prev_td; \ 2350 int pos_check = (is_null) ? 1 : \ 2351 (next_td != td && pos >= atomic_load(&next_td->wait_mb_pos)) || \ 2352 (prev_td != td && pos >= atomic_load(&prev_td->wait_mb_pos)); \ 2353 atomic_store(&td->thread_mb_pos, pos); \ 2354 if (sliced_threading && pos_check) { \ 2355 pthread_mutex_lock(&td->lock); \ 2356 pthread_cond_broadcast(&td->cond); \ 2357 pthread_mutex_unlock(&td->lock); \ 2361 #define check_thread_pos(td, otd, mb_x_check, mb_y_check) while(0) 2362 #define update_pos(td, mb_y, mb_x) while(0) 2366 int jobnr,
int threadnr,
int is_vp7)
2371 int mb_x, mb_xy = mb_y * s->
mb_width;
2388 prev_td = &s->
thread_data[(jobnr + num_jobs - 1) % num_jobs];
2392 next_td = &s->
thread_data[(jobnr + 1) % num_jobs];
2402 memset(mb - 1, 0,
sizeof(*mb));
2406 if (!is_vp7 || mb_y == 0)
2412 for (mb_x = 0; mb_x < s->
mb_width; mb_x++, mb_xy++, mb++) {
2416 if (prev_td != td) {
2417 if (threadnr != 0) {
2419 mb_x + (is_vp7 ? 2 : 1),
2420 mb_y - (is_vp7 ? 2 : 1));
2423 mb_x + (is_vp7 ? 2 : 1) + s->
mb_width + 3,
2424 mb_y - (is_vp7 ? 2 : 1));
2431 dst[2] - dst[1], 2);
2435 prev_frame && prev_frame->seg_map ?
2436 prev_frame->seg_map->data + mb_xy :
NULL, 0, is_vp7);
2467 if (s->
deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
2494 int jobnr,
int threadnr)
2500 int jobnr,
int threadnr)
2506 int jobnr,
int threadnr,
int is_vp7)
2528 prev_td = &s->
thread_data[(jobnr + num_jobs - 1) % num_jobs];
2532 next_td = &s->
thread_data[(jobnr + 1) % num_jobs];
2534 for (mb_x = 0; mb_x < s->
mb_width; mb_x++, mb++) {
2538 (mb_x + 1) + (s->
mb_width + 3), mb_y - 1);
2543 if (num_jobs == 1) {
2555 filter_mb(s, dst, f, mb_x, mb_y, is_vp7);
2565 int jobnr,
int threadnr)
2571 int jobnr,
int threadnr)
2578 int threadnr,
int is_vp7)
2590 for (mb_y = jobnr; mb_y < s->
mb_height; mb_y += num_jobs) {
2612 int jobnr,
int threadnr)
2618 int jobnr,
int threadnr)
2628 int ret,
i, referenced, num_jobs;
2668 for (i = 0; i < 5; i++)
2670 &s->
frames[i] != prev_frame &&
2693 "Discarding interframe without a prior keyframe!\n");
2698 curframe->tf.f->key_frame = s->
keyframe;
2739 s->
linesize = curframe->tf.f->linesize[0];
2816 #if CONFIG_VP7_DECODER 2864 if (CONFIG_VP7_DECODER && is_vp7) {
2869 }
else if (CONFIG_VP8_DECODER && !is_vp7) {
2887 #if CONFIG_VP7_DECODER 2899 #if CONFIG_VP8_DECODER 2901 #define REBASE(pic) ((pic) ? (pic) - &s_src->frames[0] + &s->frames[0] : NULL) 2917 s->
prob[0] = s_src->
prob[!s_src->update_probabilities];
2923 if (s_src->frames[i].tf.f->buf[0]) {
2924 int ret = vp8_ref_frame(s, &s->
frames[i], &s_src->frames[i]);
2930 s->
framep[0] = REBASE(s_src->next_framep[0]);
2931 s->
framep[1] = REBASE(s_src->next_framep[1]);
2932 s->
framep[2] = REBASE(s_src->next_framep[2]);
2933 s->
framep[3] = REBASE(s_src->next_framep[3]);
2940 #if CONFIG_VP7_DECODER 2947 .
init = vp7_decode_init,
2949 .
decode = vp7_decode_frame,
2955 #if CONFIG_VP8_DECODER 2970 #if CONFIG_VP8_VAAPI_HWACCEL 2973 #if CONFIG_VP8_NVDEC_HWACCEL
VP8Macroblock * macroblocks
static const uint8_t vp8_dc_qlookup[VP8_MAX_QUANT+1]
static av_always_inline void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], VP8Macroblock *mb, int mb_x, int mb_y, int is_vp7)
static const uint8_t vp8_submv_prob[5][3]
static const uint16_t vp7_ydc_qlookup[]
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
const struct AVCodec * codec
discard all frames except keyframes
void(* vp8_idct_dc_add)(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const uint8_t vp7_mv_default_prob[2][17]
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
static void copy(const float *p1, float *p2, const int length)
(only used in prediction) no split MVs
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
void ff_vp7dsp_init(VP8DSPContext *c)
static void update_lf_deltas(VP8Context *s)
This structure describes decoded (raw) audio or video data.
#define atomic_store(object, desired)
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
static int vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static const uint8_t vp7_pred4x4_mode[]
int8_t sign_bias[4]
one state [0, 1] per ref frame type
int coded_width
Bitstream width / height, may be different from width/height e.g.
static av_always_inline int inter_predict_dc(int16_t block[16], int16_t pred[2])
#define AV_LOG_WARNING
Something somehow does not look correct.
struct VP8Context::@171 quant
void(* vp8_idct_dc_add4y)(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
#define VP7_MV_PRED_COUNT
static av_always_inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t(*tree)[2], const uint8_t *probs)
uint8_t feature_value[4][4]
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static av_cold int init(AVCodecContext *avctx)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
#define avpriv_request_sample(...)
uint8_t * intra4x4_pred_mode_top
static VP56Frame ref_to_update(VP8Context *s, int update, VP56Frame ref)
Determine which buffers golden and altref should be updated with after this frame.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define LOCAL_ALIGNED(a, t, v,...)
static int vp7_decode_block_coeffs_internal(VP56RangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS-1], int i, uint8_t *token_prob, int16_t qmul[2], const uint8_t scan[16])
uint8_t token[4][16][3][NUM_DCT_TOKENS-1]
#define HWACCEL_NVDEC(codec)
static void vp8_decode_flush(AVCodecContext *avctx)
vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, int chroma_format_idc)
Set the intra prediction function pointers.
void(* vp8_v_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
#define FF_ARRAY_ELEMS(a)
static const int8_t vp8_pred8x8c_tree[3][2]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static const uint16_t vp7_y2dc_qlookup[]
void(* prefetch)(uint8_t *buf, ptrdiff_t stride, int h)
Prefetch memory into cache (if supported by hardware).
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before ff_thread_await_progress() has been called on them.reget_buffer() and buffer age optimizations no longer work.*The contents of buffers must not be written to after ff_thread_report_progress() has been called on them.This includes draw_edges().Porting codecs to frame threading
static void copy_chroma(AVFrame *dst, AVFrame *src, int width, int height)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
int update_probabilities
If this flag is not set, all the probability updates are discarded after this frame is decoded...
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static int vp8_decode_block_coeffs_internal(VP56RangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS-1], int i, uint8_t *token_prob, int16_t qmul[2])
static void vp7_filter_mb_row(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static int vp7_read_mv_component(VP56RangeCoder *c, const uint8_t *p)
vp8_mc_func put_vp8_epel_pixels_tab[3][3][3]
first dimension: 4-log2(width) second dimension: 0 if no vertical interpolation is needed; 1 4-tap ve...
static av_always_inline const uint8_t * get_submv_prob(uint32_t left, uint32_t top, int is_vp7)
struct VP8Context::@168 segmentation
Base parameters for segmentation, i.e.
static const uint8_t vp8_pred8x8c_prob_inter[3]
static av_always_inline int decode_block_coeffs(VP56RangeCoder *c, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS-1], int i, int zero_nhood, int16_t qmul[2], const uint8_t scan[16], int vp7)
static const uint8_t vp8_mbsplits[5][16]
enum AVDiscard skip_frame
Skip decoding for selected frames.
static const int8_t vp8_pred16x16_tree_intra[4][2]
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
int update_golden
VP56_FRAME_NONE if not updated, or which frame to copy if so.
static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7)
uint8_t intra4x4_pred_mode_top[4]
static enum AVPixelFormat get_pixel_format(VP8Context *s)
static av_always_inline void clamp_mv(VP8mvbounds *s, VP56mv *dst, const VP56mv *src)
The exact code depends on how similar the blocks are and how related they are to the block
static int vp7_update_dimensions(VP8Context *s, int width, int height)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int fade_present
Fade bit present in bitstream (VP7)
static av_always_inline void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
static VP8Frame * vp8_find_free_buffer(VP8Context *s)
static av_always_inline int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf, int vp7)
void(* vp8_luma_dc_wht_dc)(int16_t block[4][4][16], int16_t dc[16])
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
void(* vp8_idct_dc_add4uv)(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
Multithreading support functions.
int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define u(width, name, range_min, range_max)
static const uint8_t vp8_mv_update_prob[2][19]
void(* pred8x8[4+3+4])(uint8_t *src, ptrdiff_t stride)
int update_last
update VP56_FRAME_PREVIOUS with the current one
static av_always_inline int vpX_rac_is_end(VP56RangeCoder *c)
vp5689 returns 1 if the end of the stream has been reached, 0 otherwise.
static void parse_segment_info(VP8Context *s)
int num_coeff_partitions
All coefficients are contained in separate arith coding contexts.
static const uint8_t vp8_token_default_probs[4][8][3][NUM_DCT_TOKENS-1]
vp8_mc_func put_pixels_tab[3][3][3]
void(* pred4x4[9+3+3])(uint8_t *src, const uint8_t *topright, ptrdiff_t stride)
void(* vp8_v_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
uint8_t feature_index_prob[4][3]
uint8_t intra4x4_pred_mode_mb[16]
static av_always_inline int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt, int is_vp7)
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
#define prob(name, subs,...)
uint8_t intra4x4_pred_mode_left[4]
#define VERT_VP8_PRED
for VP8, VERT_PRED is the average of
uint8_t colorspace
0 is the only value allowed (meaning bt601)
static const VP56mv * get_bmv_ptr(const VP8Macroblock *mb, int subblock)
static const uint8_t vp8_mbsplit_count[4]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const int8_t vp8_coeff_band_indexes[8][10]
struct VP8Context::@169 filter
static const uint8_t vp8_pred4x4_mode[]
static av_always_inline void prefetch_motion(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int mb_xy, int ref)
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
static const uint8_t vp8_dct_cat2_prob[]
static const uint8_t vp8_mv_default_prob[2][19]
#define atomic_load(object)
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base)
static const int sizes[][2]
static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
static void fade(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, int width, int height, int alpha, int beta)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_always_inline int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y, int vp7)
static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int active_thread_type
Which multithreading methods are in use by the codec.
void(* vp8_idct_add)(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
const uint8_t ff_zigzag_scan[16+1]
VP8 compatible video decoder.
static const uint8_t vp8_mbfirstidx[4][16]
#define EDGE_EMU_LINESIZE
uint16_t inter_dc_pred[2][2]
Interframe DC prediction (VP7) [0] VP56_FRAME_PREVIOUS [1] VP56_FRAME_GOLDEN.
const char * name
Name of the codec implementation.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
VP8Macroblock * macroblocks_base
static av_always_inline void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], ThreadFrame *ref_frame, int x_off, int y_off, int bx_off, int by_off, int block_w, int block_h, int width, int height, VP56mv *mv)
static av_always_inline void decode_mb_mode(VP8Context *s, VP8mvbounds *mv_bounds, VP8Macroblock *mb, int mb_x, int mb_y, uint8_t *segment, uint8_t *ref, int layout, int is_vp7)
static const uint8_t vp8_pred4x4_prob_inter[9]
uint8_t edge_emu_buffer[21 *EDGE_EMU_LINESIZE]
static av_always_inline int decode_block_coeffs_internal(VP56RangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS-1], int i, uint8_t *token_prob, int16_t qmul[2], const uint8_t scan[16], int vp7)
static const int vp7_mode_contexts[31][4]
static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static void vp7_get_quants(VP8Context *s)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
static int vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame)
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames.The frames must then be freed with ff_thread_release_buffer().Otherwise decode directly into the user-supplied frames.Call ff_thread_report_progress() after some part of the current picture has decoded.A good place to put this is where draw_horiz_band() is called-add this if it isn't called anywhere
static const uint8_t vp8_pred16x16_prob_inter[4]
useful rectangle filling function
int ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
int(* update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src)
Copy necessary context variables from a previous thread context to the current one.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define H_LOOP_FILTER_16Y_INNER(cond)
uint8_t feature_present_prob[4]
static av_always_inline void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1, uint8_t *dst2, ThreadFrame *ref, const VP56mv *mv, int x_off, int y_off, int block_w, int block_h, int width, int height, ptrdiff_t linesize, vp8_mc_func mc_func[3][3])
chroma MC function
uint8_t fullrange
whether we can skip clamping in dsp functions
static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call ff_thread_finish_setup() afterwards.If some code can't be moved
int width
picture width / height.
int8_t ref[4]
filter strength adjustment for macroblocks that reference: [0] - intra / VP56_FRAME_CURRENT [1] - VP5...
static int vp7_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static av_cold int vp8_init_frames(VP8Context *s)
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
static void free_buffers(VP8Context *s)
#define check_thread_pos(td, otd, mb_x_check, mb_y_check)
static int vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int vp8_read_mv_component(VP56RangeCoder *c, const uint8_t *p)
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static av_always_inline int vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, VP8Frame *prev_frame, int is_vp7)
int16_t luma_dc_qmul[2]
luma dc-only block quant
static const uint8_t vp8_pred4x4_prob_intra[10][10][9]
uint8_t(* top_border)[16+8+8]
static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7)
static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f, int is_vp7)
static const int8_t vp7_feature_index_tree[4][2]
static const uint8_t vp7_feature_value_size[2][4]
#define vp56_rac_get_prob
static void vp8_decode_flush_impl(AVCodecContext *avctx, int free_mem)
static av_always_inline void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9], int is_vp7)
HW acceleration through CUDA.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
static const float pred[4]
static int vp7_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static const int8_t mv[256][2]
static av_always_inline int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y, int vp7)
static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
int coeff_partition_size[8]
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
static av_always_inline void inter_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], VP8Macroblock *mb, int mb_x, int mb_y)
Apply motion vectors to prediction buffer, chapter 18.
Libavcodec external API header.
static const uint8_t vp8_pred8x8c_prob_intra[3]
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
void(* vp8_mc_func)(uint8_t *dst, ptrdiff_t dstStride, uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
void(* vp8_v_loop_filter16y)(uint8_t *dst, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static void vp8_release_frame(VP8Context *s, VP8Frame *f)
struct VP8Context::@172 lf_delta
static const int16_t alpha[]
static const uint16_t vp7_yac_qlookup[]
main external API structure.
static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2]...the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so...,+,-,+,-,+,+,-,+,-,+,...hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32-hcoeff[1]-hcoeff[2]-...a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2}an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||.........intra?||||:Block01:yes no||||:Block02:.................||||:Block03::y DC::ref index:||||:Block04::cb DC::motion x:||||.........:cr DC::motion y:||||.................|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------------------------------|||Y subbands||Cb subbands||Cr subbands||||------||------||------|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||------||------||------||||------||------||------|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||------||------||------||||------||------||------|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||------||------||------||||------||------||------|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------------------------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction------------|\Dequantization-------------------\||Reference frames|\IDWT|--------------|Motion\|||Frame 0||Frame 1||Compensation.OBMC v-------|--------------|--------------.\------> Frame n output Frame Frame<----------------------------------/|...|-------------------Range Coder:============Binary Range Coder:-------------------The implemented range coder is an adapted version based upon"Range encoding: an algorithm for removing redundancy from a digitised message."by G.N.N.Martin.The symbols encoded by the Snow range coder are bits(0|1).The associated probabilities are not fix but change depending on the symbol mix seen so far.bit seen|new state---------+-----------------------------------------------0|256-state_transition_table[256-old_state];1|state_transition_table[old_state];state_transition_table={0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:-------------------------FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1.the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff)*mv_scale Intra DC Prediction block[y][x] dc[1]
uint8_t * data
The data buffer.
VP8Frame * next_framep[4]
int mb_layout
This describes the macroblock memory layout.
uint8_t left_nnz[9]
For coeff decode, we need to know whether the above block had non-zero coefficients.
static const uint8_t vp8_mbsplit_prob[3]
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2]...the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so...,+,-,+,-,+,+,-,+,-,+,...hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32-hcoeff[1]-hcoeff[2]-...a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2}an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||.........intra?||||:Block01:yes no||||:Block02:.................||||:Block03::y DC::ref index:||||:Block04::cb DC::motion x:||||.........:cr DC::motion y:||||.................|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------------------------------|||Y subbands||Cb subbands||Cr subbands||||------||------||------|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||------||------||------||||------||------||------|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||------||------||------||||------||------||------|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||------||------||------||||------||------||------|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------------------------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction------------|\Dequantization-------------------\||Reference frames|\IDWT|--------------|Motion\|||Frame 0||Frame 1||Compensation.OBMC v-------|--------------|--------------.\------> Frame n output Frame Frame<----------------------------------/|...|-------------------Range Coder:============Binary Range Coder:-------------------The implemented range coder is an adapted version based upon"Range encoding: an algorithm for removing redundancy from a digitised message."by G.N.N.Martin.The symbols encoded by the Snow range coder are bits(0|1).The associated probabilities are not fix but change depending on the symbol mix seen so far.bit seen|new state---------+-----------------------------------------------0|256-state_transition_table[256-old_state];1|state_transition_table[old_state];state_transition_table={0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:-------------------------FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1.the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
VP56RangeCoder c
header context, includes mb modes and motion vectors
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread.Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities.There will be very little speed gain at this point but it should work.If there are inter-frame dependencies
void(* pred16x16[4+3+2])(uint8_t *src, ptrdiff_t stride)
VP56RangeCoder coeff_partition[8]
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
static const int8_t vp8_pred16x16_tree_inter[4][2]
AVBufferRef * hwaccel_priv_buf
static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
static int vp8_update_dimensions(VP8Context *s, int width, int height)
VP8FilterStrength * filter_strength
enum AVColorSpace colorspace
YUV colorspace type.
void(* filter_mb_row)(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static av_always_inline int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
static void vp78_update_probability_tables(VP8Context *s)
static const int8_t vp8_pred4x4_tree[9][2]
uint8_t enabled
whether each mb can have a different strength based on mode/ref
static av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], VP8Macroblock *mb)
static void vp78_update_pred16x16_pred8x8_mvc_probabilities(VP8Context *s, int mvc_size)
static av_always_inline int read_mv_component(VP56RangeCoder *c, const uint8_t *p, int vp7)
Motion vector coding, 17.1.
static const uint8_t subpel_idx[3][8]
static void update_refs(VP8Context *s)
static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob)
static const uint8_t vp8_coeff_band[16]
struct VP8Context::@174 prob[2]
These are all of the updatable probabilities for binary decisions.
void(* vp8_h_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
static const uint16_t vp8_ac_qlookup[VP8_MAX_QUANT+1]
static const uint8_t vp8_pred16x16_prob_intra[4]
int header_partition_size
uint8_t update_feature_data
static enum AVPixelFormat pix_fmts[]
static av_always_inline void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int mb_x, int keyframe, int layout)
static int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
void * hwaccel_picture_private
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
uint8_t feature_enabled[4]
Macroblock features (VP7)
int8_t mode[VP8_MVMODE_SPLIT+1]
filter strength adjustment for the following macroblock modes: [0-3] - i16x16 (always zero) [4] - i4x...
2 8x16 blocks (horizontal)
av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
Narrow or limited range content.
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
void(* vp8_luma_dc_wht)(int16_t block[4][4][16], int16_t dc[16])
void(* vp8_v_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim)
discard all non reference
void(* vp8_h_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
static void vp8_get_quants(VP8Context *s)
void(* vp8_v_loop_filter16y_inner)(uint8_t *dst, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
static int ref[MAX_W *MAX_W]
static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref)
#define bit(string, value)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static av_always_inline void backup_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize, int simple)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
enum AVDiscard skip_loop_filter
Skip loop filtering for selected frames.
static av_always_inline int vp8_rac_get(VP56RangeCoder *c)
static av_always_inline int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int layout, int is_vp7)
Split motion vector prediction, 16.4.
static const SiprModeParam modes[MODE_COUNT]
static av_always_inline int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y, int vp7)
static int vp7_calculate_mb_offset(int mb_x, int mb_y, int mb_width, int xoffset, int yoffset, int boundary, int *edge_x, int *edge_y)
The vp7 reference decoder uses a padding macroblock column (added to right edge of the frame) to guar...
#define HWACCEL_VAAPI(codec)
#define update_pos(td, mb_y, mb_x)
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
#define HOR_VP8_PRED
unaveraged version of HOR_PRED, see
static av_always_inline int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
static av_always_inline void xchg_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize, int mb_x, int mb_y, int mb_width, int simple, int xchg)
static av_always_inline int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7)
static const double coeff[2][5]
static av_unused int vp8_rac_get_nn(VP56RangeCoder *c)
static av_always_inline void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst, ThreadFrame *ref, const VP56mv *mv, int x_off, int y_off, int block_w, int block_h, int width, int height, ptrdiff_t linesize, vp8_mc_func mc_func[3][3])
luma MC function
static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS-1]
static av_always_inline void filter_mb(VP8Context *s, uint8_t *dst[3], VP8FilterStrength *f, int mb_x, int mb_y, int is_vp7)
#define atomic_init(obj, value)
int8_t filter_level[4]
base loop filter level
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
static const int vp8_mode_contexts[6][4]
static const uint8_t vp8_dct_cat1_prob[]
#define FFSWAP(type, a, b)
void(* vp8_h_loop_filter16y)(uint8_t *dst, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
static av_always_inline void vp8_decode_mvs(VP8Context *s, VP8mvbounds *mv_bounds, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
uint8_t non_zero_count_cache[6][4]
This is the index plus one of the last non-zero coeff for each of the blocks in the current macrobloc...
void ff_vp8dsp_init(VP8DSPContext *c)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPixelFormat
Pixel format.
static void vp78_reset_probability_tables(VP8Context *s)
This structure stores compressed data.
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
const uint8_t *const ff_vp8_dct_cat_prob[]
mode
Use these values in ebur128_init (or'ed).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
VP8ThreadData * thread_data
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
enum AVPixelFormat pix_fmt
struct VP8Context::@170 qmat[4]
Macroblocks can have one of 4 different quants in a frame when segmentation is enabled.
struct VP8Context::@173 coder_state_at_header_end
static av_always_inline void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f, int mb_x, int mb_y)
static const VP7MVPred vp7_mv_pred[VP7_MV_PRED_COUNT]
static const uint16_t vp7_y2ac_qlookup[]
static const uint8_t vp7_submv_prob[3]
static av_always_inline int vp78_decode_init(AVCodecContext *avctx, int is_vp7)
int(* decode_mb_row_no_filter)(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)