42 #if CONFIG_VP7_DECODER && CONFIG_VP8_DECODER
43 #define VPX(vp7, f) (vp7 ? vp7_ ## f : vp8_ ## f)
44 #elif CONFIG_VP7_DECODER
45 #define VPX(vp7, f) vp7_ ## f
46 #else // CONFIG_VP8_DECODER
47 #define VPX(vp7, f) vp8_ ## f
103 #if CONFIG_VP8_DECODER
152 for (i = 0; i < 5; i++)
173 #if CONFIG_VP8_VAAPI_HWACCEL
176 #if CONFIG_VP8_NVDEC_HWACCEL
270 for (i = 0; i < 4; i++)
273 for (i = 0; i < 4; i++)
277 for (i = 0; i < 3; i++)
286 for (i = 0; i < 4; i++) {
320 if (buf_size - size < 0)
368 for (i = 0; i < 4; i++) {
421 for (i = 0; i < 4; i++)
422 for (j = 0; j < 16; j++)
432 for (i = 0; i < 4; i++)
433 for (j = 0; j < 8; j++)
434 for (k = 0; k < 3; k++)
443 #define VP7_MVC_SIZE 17
444 #define VP8_MVC_SIZE 19
453 for (i = 0; i < 4; i++)
456 for (i = 0; i < 3; i++)
460 for (i = 0; i < 2; i++)
461 for (j = 0; j < mvc_size; j++)
481 for (j = 1; j < 3; j++) {
482 for (i = 0; i < height / 2; i++)
489 const uint8_t *src, ptrdiff_t src_linesize,
494 for (j = 0; j <
height; j++) {
495 const uint8_t *src2 = src + j * src_linesize;
496 uint8_t *dst2 = dst + j * dst_linesize;
497 for (i = 0; i <
width; i++) {
499 dst2[i] = av_clip_uint8(y + ((y * beta) >> 8) + alpha);
513 if (!s->
keyframe && (alpha || beta)) {
540 width, height, alpha, beta);
549 int part1_size, hscale, vscale, i, j, ret;
557 s->
profile = (buf[0] >> 1) & 7;
565 part1_size =
AV_RL24(buf) >> 4;
567 if (buf_size < 4 - s->
profile + part1_size) {
581 buf_size -= part1_size;
589 if (hscale || vscale)
598 for (i = 0; i < 2; i++)
610 for (i = 0; i < 4; i++) {
615 for (j = 0; j < 3; j++)
620 for (j = 0; j < 4; j++)
678 for (i = 1; i < 16; i++)
705 int header_size, hscale, vscale, ret;
717 header_size =
AV_RL24(buf) >> 5;
733 if (header_size > buf_size - 7 * s->
keyframe) {
739 if (
AV_RL24(buf) != 0x2a019d) {
741 "Invalid start code 0x%x\n",
AV_RL24(buf));
744 width =
AV_RL16(buf + 3) & 0x3fff;
745 height =
AV_RL16(buf + 5) & 0x3fff;
746 hscale = buf[4] >> 6;
747 vscale = buf[6] >> 6;
751 if (hscale || vscale)
770 buf_size -= header_size;
845 dst->
x = av_clip(src->
x, av_clip(s->
mv_min.
x, INT16_MIN, INT16_MAX),
846 av_clip(s->
mv_max.
x, INT16_MIN, INT16_MAX));
847 dst->
y = av_clip(src->
y, av_clip(s->
mv_min.
y, INT16_MIN, INT16_MAX),
848 av_clip(s->
mv_max.
y, INT16_MIN, INT16_MAX));
861 for (i = 0; i < 3; i++)
863 for (i = (vp7 ? 7 : 9); i > 3; i--)
918 const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
928 top_mv = top_mb->
bmv;
944 for (n = 0; n < num; n++) {
946 uint32_t left, above;
950 left =
AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
952 left =
AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
954 above =
AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
956 above =
AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
993 int xoffset,
int yoffset,
int boundary,
994 int *edge_x,
int *edge_y)
996 int vwidth = mb_width + 1;
997 int new = (mb_y + yoffset) * vwidth + mb_x + xoffset;
998 if (
new < boundary ||
new % vwidth == vwidth - 1)
1000 *edge_y =
new / vwidth;
1001 *edge_x =
new % vwidth;
1012 int mb_x,
int mb_y,
int layout)
1015 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
1016 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1040 if (
AV_RN32A(&near_mv[CNT_NEAREST])) {
1041 if (mv ==
AV_RN32A(&near_mv[CNT_NEAREST])) {
1043 }
else if (
AV_RN32A(&near_mv[CNT_NEAR])) {
1044 if (mv !=
AV_RN32A(&near_mv[CNT_NEAR]))
1052 AV_WN32A(&near_mv[CNT_NEAREST], mv);
1073 if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
1074 AV_WN32A(&mb->
mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 :
AV_RN32A(&near_mv[CNT_NEAREST]));
1084 mb->
bmv[0] = mb->
mv;
1087 mb->
mv = near_mv[CNT_NEAR];
1088 mb->
bmv[0] = mb->
mv;
1091 mb->
mv = near_mv[CNT_NEAREST];
1092 mb->
bmv[0] = mb->
mv;
1097 mb->
bmv[0] = mb->
mv;
1103 int mb_x,
int mb_y,
int layout)
1108 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
1109 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1118 mb_edge[0] = mb + 2;
1119 mb_edge[2] = mb + 1;
1130 #define MV_EDGE_CHECK(n) \
1132 VP8Macroblock *edge = mb_edge[n]; \
1133 int edge_ref = edge->ref_frame; \
1134 if (edge_ref != VP56_FRAME_CURRENT) { \
1135 uint32_t mv = AV_RN32A(&edge->mv); \
1137 if (cur_sign_bias != sign_bias[edge_ref]) { \
1140 mv = ((mv & 0x7fff7fff) + \
1141 0x00010001) ^ (mv & 0x80008000); \
1143 if (!n || mv != AV_RN32A(&near_mv[idx])) \
1144 AV_WN32A(&near_mv[++idx], mv); \
1145 cnt[idx] += 1 + (n != 2); \
1147 cnt[CNT_ZERO] += 1 + (n != 2); \
1160 if (cnt[CNT_SPLITMV] &&
1161 AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) ==
AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
1162 cnt[CNT_NEAREST] += 1;
1165 if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
1167 FFSWAP(
VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
1173 clamp_mv(mv_bounds, &mb->
mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
1184 mb->
bmv[0] = mb->
mv;
1187 clamp_mv(mv_bounds, &mb->
mv, &near_mv[CNT_NEAR]);
1188 mb->
bmv[0] = mb->
mv;
1191 clamp_mv(mv_bounds, &mb->
mv, &near_mv[CNT_NEAREST]);
1192 mb->
bmv[0] = mb->
mv;
1197 mb->
bmv[0] = mb->
mv;
1203 int mb_x,
int keyframe,
int layout)
1219 for (y = 0; y < 4; y++) {
1220 for (x = 0; x < 4; x++) {
1224 left[y] = top[x] = *intra4x4;
1230 for (i = 0; i < 16; i++)
1242 static const char *
const vp7_feature_name[] = {
"q-index",
1244 "partial-golden-update",
1249 for (i = 0; i < 4; i++) {
1255 "Feature %s present in macroblock (value 0x%x)\n",
1264 *segment = ref ? *ref : *segment;
1331 int i,
uint8_t *token_prob, int16_t qmul[2],
1332 const uint8_t scan[16],
int vp7)
1346 token_prob = probs[i][0];
1354 token_prob = probs[i + 1][1];
1374 int cat = (a << 1) + b;
1375 coeff = 3 + (8 <<
cat);
1379 token_prob = probs[i + 1][2];
1391 int16_t
dc = block[0];
1400 block[0] = pred[0] =
dc;
1405 block[0] = pred[0] =
dc;
1419 token_prob, qmul, scan,
IS_VP7);
1422 #ifndef vp8_decode_block_coeffs_internal
1450 int i,
int zero_nhood, int16_t qmul[2],
1451 const uint8_t scan[16],
int vp7)
1453 uint8_t *token_prob = probs[i][zero_nhood];
1457 token_prob, qmul, scan)
1467 int i, x, y, luma_start = 0, luma_ctx = 3;
1468 int nnz_pred, nnz, nnz_total = 0;
1473 nnz_pred = t_nnz[8] + l_nnz[8];
1479 l_nnz[8] = t_nnz[8] = !!nnz;
1499 for (y = 0; y < 4; y++)
1500 for (x = 0; x < 4; x++) {
1501 nnz_pred = l_nnz[y] + t_nnz[x];
1504 luma_start, nnz_pred,
1510 t_nnz[x] = l_nnz[y] = !!nnz;
1517 for (i = 4; i < 6; i++)
1518 for (y = 0; y < 2; y++)
1519 for (x = 0; x < 2; x++) {
1520 nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x];
1526 t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz;
1540 ptrdiff_t linesize, ptrdiff_t uvlinesize,
int simple)
1542 AV_COPY128(top_border, src_y + 15 * linesize);
1544 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
1545 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
1551 uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize,
int mb_x,
1552 int mb_y,
int mb_width,
int simple,
int xchg)
1554 uint8_t *top_border_m1 = top_border - 32;
1556 src_cb -= uvlinesize;
1557 src_cr -= uvlinesize;
1559 #define XCHG(a, b, xchg) \
1567 XCHG(top_border_m1 + 8, src_y - 8, xchg);
1568 XCHG(top_border, src_y, xchg);
1569 XCHG(top_border + 8, src_y + 8, 1);
1570 if (mb_x < mb_width - 1)
1571 XCHG(top_border + 32, src_y + 16, 1);
1575 if (!simple || !mb_y) {
1576 XCHG(top_border_m1 + 16, src_cb - 8, xchg);
1577 XCHG(top_border_m1 + 24, src_cr - 8, xchg);
1578 XCHG(top_border + 16, src_cb, 1);
1579 XCHG(top_border + 24, src_cr, 1);
1629 int *copy_buf,
int vp7)
1633 if (!mb_x && mb_y) {
1667 int x, y,
mode, nnz;
1683 const uint8_t lo = is_vp7 ? 128 : 127;
1684 const uint8_t hi = is_vp7 ? 128 : 129;
1685 uint8_t tr_top[4] = { lo, lo, lo, lo };
1693 if (mb_y && mb_x == s->
mb_width - 1) {
1694 tr = tr_right[-1] * 0x01010101
u;
1701 for (y = 0; y < 4; y++) {
1703 for (x = 0; x < 4; x++) {
1709 if ((y == 0 || x == 3) && mb_y == 0) {
1712 topright = tr_right;
1715 mb_y + y, ©, is_vp7);
1717 dst = copy_dst + 12;
1721 AV_WN32A(copy_dst + 4, lo * 0x01010101U);
1727 copy_dst[3] = ptr[4 * x - s->
linesize - 1];
1736 copy_dst[11] = ptr[4 * x - 1];
1737 copy_dst[19] = ptr[4 * x + s->
linesize - 1];
1738 copy_dst[27] = ptr[4 * x + s->
linesize * 2 - 1];
1739 copy_dst[35] = ptr[4 * x + s->
linesize * 3 - 1];
1768 mb_x, mb_y, is_vp7);
1779 { 0, 1, 2, 1, 2, 1, 2, 1 },
1781 { 0, 3, 5, 3, 5, 3, 5, 3 },
1782 { 0, 2, 3, 2, 3, 2, 3, 2 },
1804 int x_off,
int y_off,
int block_w,
int block_h,
1811 ptrdiff_t src_linesize = linesize;
1813 int mx = (mv->
x * 2) & 7, mx_idx = subpel_idx[0][mx];
1814 int my = (mv->
y * 2) & 7, my_idx = subpel_idx[0][my];
1816 x_off += mv->
x >> 2;
1817 y_off += mv->
y >> 2;
1821 src += y_off * linesize + x_off;
1822 if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
1823 y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
1825 src - my_idx * linesize - mx_idx,
1827 block_w + subpel_idx[1][mx],
1828 block_h + subpel_idx[1][my],
1829 x_off - mx_idx, y_off - my_idx,
1834 mc_func[my_idx][mx_idx](dst, linesize,
src, src_linesize, block_h, mx, my);
1837 mc_func[0][0](dst, linesize, src + y_off * linesize + x_off,
1838 linesize, block_h, 0, 0);
1862 int x_off,
int y_off,
int block_w,
int block_h,
1869 int mx = mv->
x & 7, mx_idx = subpel_idx[0][mx];
1870 int my = mv->
y & 7, my_idx = subpel_idx[0][my];
1872 x_off += mv->
x >> 3;
1873 y_off += mv->
y >> 3;
1876 src1 += y_off * linesize + x_off;
1877 src2 += y_off * linesize + x_off;
1879 if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
1880 y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
1882 src1 - my_idx * linesize - mx_idx,
1884 block_w + subpel_idx[1][mx],
1885 block_h + subpel_idx[1][my],
1886 x_off - mx_idx, y_off - my_idx, width, height);
1891 src2 - my_idx * linesize - mx_idx,
1892 EDGE_EMU_LINESIZE, linesize,
1893 block_w + subpel_idx[1][mx],
1894 block_h + subpel_idx[1][my],
1895 x_off - mx_idx, y_off - my_idx, width, height);
1897 mc_func[my_idx][mx_idx](dst2, linesize, src2,
EDGE_EMU_LINESIZE, block_h, mx, my);
1899 mc_func[my_idx][mx_idx](dst1, linesize,
src1, linesize, block_h, mx, my);
1900 mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
1904 mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1905 mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1912 int bx_off,
int by_off,
int block_w,
int block_h,
1919 ref_frame, mv, x_off + bx_off, y_off + by_off,
1920 block_w, block_h, width, height, s->
linesize,
1939 dst[2] + by_off * s->
uvlinesize + bx_off, ref_frame,
1940 &uvmv, x_off + bx_off, y_off + by_off,
1941 block_w, block_h, width, height, s->
uvlinesize,
1952 if (s->
ref_count[ref - 1] > (mb_xy >> 5)) {
1953 int x_off = mb_x << 4, y_off = mb_y << 4;
1954 int mx = (mb->
mv.
x >> 2) + x_off + 8;
1955 int my = (mb->
mv.
y >> 2) + y_off;
1957 int off = mx + (my + (mb_x & 3) * 4) * s->
linesize + 64;
1962 off = (mx >> 1) + ((my >> 1) + (mb_x & 7)) * s->
uvlinesize + 64;
1974 int x_off = mb_x << 4, y_off = mb_y << 4;
1982 0, 0, 16, 16, width,
height, &mb->
mv);
1989 for (y = 0; y < 4; y++) {
1990 for (x = 0; x < 4; x++) {
1992 ref, &bmv[4 * y + x],
1993 4 * x + x_off, 4 * y + y_off, 4, 4,
2004 for (y = 0; y < 2; y++) {
2005 for (x = 0; x < 2; x++) {
2006 uvmv.
x = mb->
bmv[2 * y * 4 + 2 * x ].
x +
2007 mb->
bmv[2 * y * 4 + 2 * x + 1].
x +
2008 mb->
bmv[(2 * y + 1) * 4 + 2 * x ].x +
2009 mb->
bmv[(2 * y + 1) * 4 + 2 * x + 1].
x;
2010 uvmv.
y = mb->
bmv[2 * y * 4 + 2 * x ].
y +
2011 mb->
bmv[2 * y * 4 + 2 * x + 1].
y +
2012 mb->
bmv[(2 * y + 1) * 4 + 2 * x ].y +
2013 mb->
bmv[(2 * y + 1) * 4 + 2 * x + 1].
y;
2022 &uvmv, 4 * x + x_off, 4 * y + y_off, 4, 4,
2031 0, 0, 16, 8, width,
height, &bmv[0]);
2033 0, 8, 16, 8, width,
height, &bmv[1]);
2037 0, 0, 8, 16, width,
height, &bmv[0]);
2039 8, 0, 8, 16, width,
height, &bmv[1]);
2043 0, 0, 8, 8, width,
height, &bmv[0]);
2045 8, 0, 8, 8, width,
height, &bmv[1]);
2047 0, 8, 8, 8, width,
height, &bmv[2]);
2049 8, 8, 8, 8, width,
height, &bmv[3]);
2061 for (y = 0; y < 4; y++) {
2064 if (nnz4 & ~0x01010101) {
2065 for (x = 0; x < 4; x++) {
2086 for (ch = 0; ch < 2; ch++) {
2090 if (nnz4 & ~0x01010101) {
2091 for (y = 0; y < 2; y++) {
2092 for (x = 0; x < 2; x++) {
2095 td->
block[4 + ch][(y << 1) + x],
2099 td->
block[4 + ch][(y << 1) + x],
2103 goto chroma_idct_end;
2120 int interior_limit, filter_level;
2134 filter_level = av_clip_uintp2(filter_level, 6);
2136 interior_limit = filter_level;
2141 interior_limit =
FFMAX(interior_limit, 1);
2151 int mb_x,
int mb_y,
int is_vp7)
2153 int mbedge_lim, bedge_lim_y, bedge_lim_uv, hev_thresh;
2159 static const uint8_t hev_thresh_lut[2][64] = {
2160 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2162 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2164 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2165 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2174 bedge_lim_y = filter_level;
2175 bedge_lim_uv = filter_level * 2;
2176 mbedge_lim = filter_level + 2;
2179 bedge_lim_uv = filter_level * 2 + inner_limit;
2180 mbedge_lim = bedge_lim_y + 4;
2183 hev_thresh = hev_thresh_lut[s->
keyframe][filter_level];
2187 mbedge_lim, inner_limit, hev_thresh);
2189 mbedge_lim, inner_limit, hev_thresh);
2192 #define H_LOOP_FILTER_16Y_INNER(cond) \
2193 if (cond && inner_filter) { \
2194 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 4, linesize, \
2195 bedge_lim_y, inner_limit, \
2197 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 8, linesize, \
2198 bedge_lim_y, inner_limit, \
2200 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 12, linesize, \
2201 bedge_lim_y, inner_limit, \
2203 s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4, \
2204 uvlinesize, bedge_lim_uv, \
2205 inner_limit, hev_thresh); \
2212 mbedge_lim, inner_limit, hev_thresh);
2214 mbedge_lim, inner_limit, hev_thresh);
2219 linesize, bedge_lim_y,
2220 inner_limit, hev_thresh);
2222 linesize, bedge_lim_y,
2223 inner_limit, hev_thresh);
2225 linesize, bedge_lim_y,
2226 inner_limit, hev_thresh);
2228 dst[2] + 4 * uvlinesize,
2229 uvlinesize, bedge_lim_uv,
2230 inner_limit, hev_thresh);
2240 int mbedge_lim, bedge_lim;
2249 bedge_lim = 2 * filter_level + inner_limit;
2250 mbedge_lim = bedge_lim + 4;
2269 #define MARGIN (16 << 2)
2279 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
2281 ((s->
mb_width + 1) * (mb_y + 1) + 1);
2288 for (mb_x = 0; mb_x < s->
mb_width; mb_x++, mb_xy++, mb++) {
2293 prev_frame && prev_frame->
seg_map ?
2316 #define check_thread_pos(td, otd, mb_x_check, mb_y_check) \
2318 int tmp = (mb_y_check << 16) | (mb_x_check & 0xFFFF); \
2319 if (atomic_load(&otd->thread_mb_pos) < tmp) { \
2320 pthread_mutex_lock(&otd->lock); \
2321 atomic_store(&td->wait_mb_pos, tmp); \
2323 if (atomic_load(&otd->thread_mb_pos) >= tmp) \
2325 pthread_cond_wait(&otd->cond, &otd->lock); \
2327 atomic_store(&td->wait_mb_pos, INT_MAX); \
2328 pthread_mutex_unlock(&otd->lock); \
2332 #define update_pos(td, mb_y, mb_x) \
2334 int pos = (mb_y << 16) | (mb_x & 0xFFFF); \
2335 int sliced_threading = (avctx->active_thread_type == FF_THREAD_SLICE) && \
2337 int is_null = !next_td || !prev_td; \
2338 int pos_check = (is_null) ? 1 : \
2339 (next_td != td && pos >= atomic_load(&next_td->wait_mb_pos)) || \
2340 (prev_td != td && pos >= atomic_load(&prev_td->wait_mb_pos)); \
2341 atomic_store(&td->thread_mb_pos, pos); \
2342 if (sliced_threading && pos_check) { \
2343 pthread_mutex_lock(&td->lock); \
2344 pthread_cond_broadcast(&td->cond); \
2345 pthread_mutex_unlock(&td->lock); \
2349 #define check_thread_pos(td, otd, mb_x_check, mb_y_check) while(0)
2350 #define update_pos(td, mb_y, mb_x) while(0)
2354 int jobnr,
int threadnr,
int is_vp7)
2359 int mb_x, mb_xy = mb_y * s->
mb_width;
2376 prev_td = &s->
thread_data[(jobnr + num_jobs - 1) % num_jobs];
2380 next_td = &s->
thread_data[(jobnr + 1) % num_jobs];
2390 memset(mb - 1, 0,
sizeof(*mb));
2394 if (!is_vp7 || mb_y == 0)
2400 for (mb_x = 0; mb_x < s->
mb_width; mb_x++, mb_xy++, mb++) {
2404 if (prev_td != td) {
2405 if (threadnr != 0) {
2407 mb_x + (is_vp7 ? 2 : 1),
2408 mb_y - (is_vp7 ? 2 : 1));
2411 mb_x + (is_vp7 ? 2 : 1) + s->
mb_width + 3,
2412 mb_y - (is_vp7 ? 2 : 1));
2419 dst[2] - dst[1], 2);
2423 prev_frame && prev_frame->seg_map ?
2424 prev_frame->seg_map->data + mb_xy :
NULL, 0, is_vp7);
2455 if (s->
deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
2482 int jobnr,
int threadnr)
2488 int jobnr,
int threadnr)
2494 int jobnr,
int threadnr,
int is_vp7)
2516 prev_td = &s->
thread_data[(jobnr + num_jobs - 1) % num_jobs];
2520 next_td = &s->
thread_data[(jobnr + 1) % num_jobs];
2522 for (mb_x = 0; mb_x < s->
mb_width; mb_x++, mb++) {
2526 (mb_x + 1) + (s->
mb_width + 3), mb_y - 1);
2531 if (num_jobs == 1) {
2543 filter_mb(s, dst, f, mb_x, mb_y, is_vp7);
2553 int jobnr,
int threadnr)
2559 int jobnr,
int threadnr)
2566 int threadnr,
int is_vp7)
2578 for (mb_y = jobnr; mb_y < s->
mb_height; mb_y += num_jobs) {
2600 int jobnr,
int threadnr)
2606 int jobnr,
int threadnr)
2616 int ret, i, referenced, num_jobs;
2656 for (i = 0; i < 5; i++)
2658 &s->
frames[i] != prev_frame &&
2681 "Discarding interframe without a prior keyframe!\n");
2686 curframe->tf.f->key_frame = s->
keyframe;
2726 s->
linesize = curframe->tf.f->linesize[0];
2801 #if CONFIG_VP7_DECODER
2850 if (CONFIG_VP7_DECODER && is_vp7) {
2855 }
else if (CONFIG_VP8_DECODER && !is_vp7) {
2873 #if CONFIG_VP7_DECODER
2885 #if CONFIG_VP8_DECODER
2902 #define REBASE(pic) ((pic) ? (pic) - &s_src->frames[0] + &s->frames[0] : NULL)
2918 s->
prob[0] = s_src->
prob[!s_src->update_probabilities];
2924 if (s_src->frames[i].tf.f->buf[0]) {
2925 int ret = vp8_ref_frame(s, &s->
frames[i], &s_src->frames[i]);
2931 s->
framep[0] = REBASE(s_src->next_framep[0]);
2932 s->
framep[1] = REBASE(s_src->next_framep[1]);
2933 s->
framep[2] = REBASE(s_src->next_framep[2]);
2934 s->
framep[3] = REBASE(s_src->next_framep[3]);
2941 #if CONFIG_VP7_DECODER
2948 .
init = vp7_decode_init,
2950 .
decode = vp7_decode_frame,
2956 #if CONFIG_VP8_DECODER
2972 #if CONFIG_VP8_VAAPI_HWACCEL
2975 #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
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
void(* prefetch)(uint8_t *buf, ptrdiff_t stride, int h)
Prefetch memory into cache (if supported by hardware).
#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.
struct VP8Context::@175 quant
#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
#define HWACCEL_NVDEC(codec)
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.
static int init_thread_copy(AVCodecContext *avctx)
#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 ...
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.
void(* vp8_v_loop_filter16y)(uint8_t *dst, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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]
static void vp8_decode_flush(AVCodecContext *avctx)
vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3]
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.
av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
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 ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
static void copy_chroma(AVFrame *dst, AVFrame *src, int width, int height)
struct VP8Context::@177 coder_state_at_header_end
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)
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...
struct VP8Context::@176 lf_delta
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
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)
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)
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
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
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 ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
void(* pred4x4[9+3+3])(uint8_t *src, const uint8_t *topright, ptrdiff_t stride)
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 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)
struct VP8Context::@173 filter
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]
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.
void(* vp8_luma_dc_wht_dc)(int16_t block[4][4][16], int16_t dc[16])
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]
void(* vp8_h_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
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.
const uint8_t ff_zigzag_scan[16+1]
VP8 compatible video decoder.
void(* vp8_v_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
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.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
int(* decode_mb_row_no_filter)(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
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)
#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)
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)
void(* filter_mb_row)(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
void(* vp8_idct_dc_add4y)(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
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 av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
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.
void(* vp8_mc_func)(uint8_t *dst, ptrdiff_t dstStride, uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
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.
struct VP8Context::@174 qmat[4]
Macroblocks can have one of 4 different quants in a frame when segmentation is enabled.
static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame)
#define FF_ARRAY_ELEMS(a)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
the normal 2^n-1 "JPEG" YUV ranges
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 void vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame)
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]
void(* vp8_v_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
void(* vp8_h_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim)
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.
void(* vp8_idct_add)(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
Libavcodec external API header.
static const uint8_t vp8_pred8x8c_prob_intra[3]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static void vp8_release_frame(VP8Context *s, VP8Frame *f)
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
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)
static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
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]
VP56RangeCoder c
header context, includes mb modes and motion vectors
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(* vp8_idct_dc_add4uv)(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
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]
int allocate_progress
Whether to allocate progress for frame threading.
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)
#define HWACCEL_VAAPI(codec)
void(* vp8_luma_dc_wht)(int16_t block[4][4][16], int16_t dc[16])
struct VP8Context::@178 prob[2]
These are all of the updatable probabilities for binary decisions.
av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
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)
the normal 219*2^(n-8) "MPEG" YUV ranges
discard all non reference
static av_always_inline void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, VP8Frame *prev_frame, int is_vp7)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void(* vp8_v_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim)
common internal api header.
static void vp8_get_quants(VP8Context *s)
static int ref[MAX_W *MAX_W]
#define LOCAL_ALIGNED(a, t, v,...)
static int ref_frame(Vp3DecodeContext *s, ThreadFrame *dst, ThreadFrame *src)
static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref)
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)
void(* vp8_h_loop_filter16y)(uint8_t *dst, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
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...
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.
#define update_pos(td, mb_y, mb_x)
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
struct VP8Context::@172 segmentation
Base parameters for segmentation, i.e.
struct AVCodecInternal * internal
Private context used for internal 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]
void(* vp8_idct_dc_add)(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
static av_unused int vp8_rac_get_nn(VP56RangeCoder *c)
void(* vp8_v_loop_filter16y_inner)(uint8_t *dst, ptrdiff_t stride, int flim_E, int flim_I, int hev_thresh)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
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)
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
static av_always_inline void vp8_decode_mvs(VP8Context *s, VP8mvbounds *mv_bounds, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
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
enum AVPixelFormat pix_fmt
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]
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
static av_always_inline int vp78_decode_init(AVCodecContext *avctx, int is_vp7)