27#include "config_components.h"
103 s->macroblocks =
NULL;
143 memset(
s->framep, 0,
sizeof(
s->framep));
163 for (
i = 0;
i < 5;
i++)
184#if CONFIG_VP8_VAAPI_HWACCEL
187#if CONFIG_VP8_NVDEC_HWACCEL
190#if CONFIG_VP8_NVDEC_CUARRAY_HWACCEL
204 int i, ret, dim_reset = 0;
206 if (
width !=
s->avctx->width || ((
width+15)/16 !=
s->mb_width || (
height+15)/16 !=
s->mb_height) &&
s->macroblocks_base ||
214 dim_reset = (
s->macroblocks_base !=
NULL);
218 !
s->actually_webp && !is_vp7) {
225 s->mb_width = (
s->avctx->coded_width + 15) / 16;
226 s->mb_height = (
s->avctx->coded_height + 15) / 16;
231 s->macroblocks_base =
av_mallocz((
s->mb_width +
s->mb_height * 2 + 1) *
232 sizeof(*
s->macroblocks));
233 s->intra4x4_pred_mode_top =
av_mallocz(
s->mb_width * 4);
235 s->macroblocks_base =
av_mallocz((
s->mb_width + 2) * (
s->mb_height + 2) *
236 sizeof(*
s->macroblocks));
238 s->top_border =
av_mallocz((
s->mb_width + 1) *
sizeof(*
s->top_border));
241 if (!
s->macroblocks_base || !
s->top_nnz || !
s->top_border ||
242 !
s->thread_data || (!
s->intra4x4_pred_mode_top && !
s->mb_layout)) {
248 s->thread_data[
i].filter_strength =
249 av_mallocz(
s->mb_width *
sizeof(*
s->thread_data[0].filter_strength));
250 if (!
s->thread_data[
i].filter_strength) {
268 s->macroblocks =
s->macroblocks_base + 1;
292 if (
s->segmentation.update_feature_data) {
295 for (
i = 0;
i < 4;
i++)
298 for (
i = 0;
i < 4;
i++)
301 if (
s->segmentation.update_map)
302 for (
i = 0;
i < 3;
i++)
311 for (
i = 0;
i < 4;
i++) {
316 s->lf_delta.ref[
i] = -
s->lf_delta.ref[
i];
325 s->lf_delta.mode[
i] = -
s->lf_delta.mode[
i];
332 const uint8_t *
sizes = buf;
338 buf += 3 * (
s->num_coeff_partitions - 1);
339 buf_size -= 3 * (
s->num_coeff_partitions - 1);
343 for (
i = 0;
i <
s->num_coeff_partitions - 1;
i++) {
345 if (buf_size -
size < 0)
347 s->coeff_partition_size[
i] =
size;
356 s->coeff_partition_size[
i] = buf_size;
392 for (
i = 0;
i < 4;
i++) {
393 if (
s->segmentation.enabled) {
394 base_qi =
s->segmentation.base_quant[
i];
395 if (!
s->segmentation.absolute_vals)
396 base_qi +=
s->quant.yac_qi;
398 base_qi =
s->quant.yac_qi;
408 s->qmat[
i].luma_dc_qmul[1] =
FFMAX(
s->qmat[
i].luma_dc_qmul[1], 8);
409 s->qmat[
i].chroma_qmul[0] =
FFMIN(
s->qmat[
i].chroma_qmul[0], 132);
445 for (
i = 0;
i < 4;
i++)
446 for (j = 0; j < 16; j++)
448 sizeof(
s->prob->token[
i][j]));
456 for (
i = 0;
i < 4;
i++)
457 for (j = 0; j < 8; j++)
458 for (k = 0; k < 3; k++)
467#define VP7_MVC_SIZE 17
468#define VP8_MVC_SIZE 19
477 for (
i = 0;
i < 4;
i++)
480 for (
i = 0;
i < 3;
i++)
484 for (
i = 0;
i < 2;
i++)
485 for (j = 0; j < mvc_size; j++)
505 for (j = 1; j < 3; j++) {
507 memcpy(
dst->data[j] +
i *
dst->linesize[j],
512static void fade(uint8_t *
dst, ptrdiff_t dst_linesize,
513 const uint8_t *
src, ptrdiff_t src_linesize,
518 for (j = 0; j <
height; j++) {
519 const uint8_t *
src2 =
src + j * src_linesize;
520 uint8_t *dst2 =
dst + j * dst_linesize;
532 if (!
s->keyframe && (
alpha || beta)) {
533 int width =
s->mb_width * 16;
534 int height =
s->mb_height * 16;
562 src->data[0],
src->linesize[0],
572 int part1_size, hscale, vscale,
i, j, ret;
573 int width =
s->avctx->width;
577 int fade_present = 1;
583 s->profile = (buf[0] >> 1) & 7;
584 if (
s->profile > 1) {
589 s->keyframe = !(buf[0] & 1);
591 part1_size =
AV_RL24(buf) >> 4;
593 if (buf_size < 4 - s->
profile + part1_size) {
594 av_log(
s->avctx,
AV_LOG_ERROR,
"Buffer size %d is too small, needed : %d\n", buf_size, 4 -
s->profile + part1_size);
598 buf += 4 -
s->profile;
599 buf_size -= 4 -
s->profile;
601 memcpy(
s->put_pixels_tab,
s->vp8dsp.put_vp8_epel_pixels_tab,
sizeof(
s->put_pixels_tab));
607 buf_size -= part1_size;
615 if (hscale || vscale)
621 sizeof(
s->prob->pred16x16));
623 sizeof(
s->prob->pred8x8c));
624 for (
i = 0;
i < 2;
i++)
627 memset(&
s->segmentation, 0,
sizeof(
s->segmentation));
628 memset(&
s->lf_delta, 0,
sizeof(
s->lf_delta));
632 if (
s->keyframe ||
s->profile > 0)
633 memset(
s->inter_dc_pred, 0 ,
sizeof(
s->inter_dc_pred));
636 for (
i = 0;
i < 4;
i++) {
638 if (
s->feature_enabled[
i]) {
641 for (j = 0; j < 3; j++)
642 s->feature_index_prob[
i][j] =
646 for (j = 0; j < 4; j++)
647 s->feature_value[
i][j] =
652 s->segmentation.enabled = 0;
653 s->segmentation.update_map = 0;
654 s->lf_delta.enabled = 0;
656 s->num_coeff_partitions = 1;
661 if (!
s->macroblocks_base ||
663 (
width + 15) / 16 !=
s->mb_width || (
height + 15) / 16 !=
s->mb_height) {
678 s->update_probabilities = 1;
680 if (
s->profile > 0) {
682 if (!
s->update_probabilities)
683 s->prob[1] =
s->prob[0];
703 for (
i = 1;
i < 16;
i++)
715 s->mbskip_enabled = 0;
736 int header_size, hscale, vscale, ret;
737 int width =
s->avctx->width;
745 s->keyframe = !(buf[0] & 1);
746 s->profile = (buf[0]>>1) & 7;
747 s->invisible = !(buf[0] & 0x10);
748 header_size =
AV_RL24(buf) >> 5;
752 s->header_partition_size = header_size;
758 memcpy(
s->put_pixels_tab,
s->vp8dsp.put_vp8_epel_pixels_tab,
759 sizeof(
s->put_pixels_tab));
761 memcpy(
s->put_pixels_tab,
s->vp8dsp.put_vp8_bilinear_pixels_tab,
762 sizeof(
s->put_pixels_tab));
764 if (header_size > buf_size - 7 *
s->keyframe) {
770 if (
AV_RL24(buf) != 0x2a019d) {
772 "Invalid start code 0x%x\n",
AV_RL24(buf));
777 hscale = buf[4] >> 6;
778 vscale = buf[6] >> 6;
782 if (hscale || vscale)
788 sizeof(
s->prob->pred16x16));
790 sizeof(
s->prob->pred8x8c));
792 sizeof(
s->prob->mvc));
793 memset(&
s->segmentation, 0,
sizeof(
s->segmentation));
794 memset(&
s->lf_delta, 0,
sizeof(
s->lf_delta));
801 buf_size -= header_size;
813 s->segmentation.update_map = 0;
821 if (
s->lf_delta.update)
830 if (!
s->macroblocks_base ||
832 (
width+15)/16 !=
s->mb_width || (
height+15)/16 !=
s->mb_height)
847 s->prob[1] =
s->prob[0];
865 s->coder_state_at_header_end.input =
s->c.buffer - (-
s->c.bits / 8);
866 s->coder_state_at_header_end.range =
s->c.high;
867 s->coder_state_at_header_end.value =
s->c.code_word >> 16;
868 s->coder_state_at_header_end.bit_count = -
s->c.bits % 8;
877 av_clip(
s->mv_max.x, INT16_MIN, INT16_MAX));
879 av_clip(
s->mv_max.y, INT16_MIN, INT16_MAX));
892 for (
i = 0;
i < 3;
i++)
894 for (
i = (vp7 ? 7 : 9);
i > 3;
i--)
900 const uint8_t *ps = p + 2;
949 const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
951 const VP8mv *left_mv = left_mb->
bmv;
957 top_mb = &
mb[-
s->mb_width - 1];
959 top_mv = top_mb->
bmv;
973 mb->partitioning = part_idx;
975 for (n = 0; n < num; n++) {
977 uint32_t
left, above;
978 const uint8_t *submv_prob;
985 above =
AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
987 above =
AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
994 mb->bmv[n].y =
mb->mv.y +
996 mb->bmv[n].x =
mb->mv.x +
1024 int xoffset,
int yoffset,
int boundary,
1025 int *edge_x,
int *edge_y)
1027 int vwidth = mb_width + 1;
1028 int new = (mb_y + yoffset) * vwidth + mb_x + xoffset;
1029 if (
new < boundary ||
new % vwidth == vwidth - 1)
1031 *edge_y =
new / vwidth;
1032 *edge_x =
new % vwidth;
1043 int mb_x,
int mb_y,
int layout)
1045 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
1046 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1049 uint8_t cnt[3] = { 0 };
1062 pred->yoffset, !
s->profile, &edge_x, &edge_y)) {
1064 ?
s->macroblocks_base + 1 + edge_x +
1065 (
s->mb_width + 1) * (edge_y + 1)
1066 :
s->macroblocks + edge_x +
1067 (
s->mb_height - edge_y - 1) * 2;
1070 if (
AV_RN32A(&near_mv[CNT_NEAREST])) {
1073 }
else if (
AV_RN32A(&near_mv[CNT_NEAR])) {
1103 if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
1104 AV_WN32A(&
mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 :
AV_RN32A(&near_mv[CNT_NEAREST]));
1114 mb->bmv[0] =
mb->mv;
1117 mb->mv = near_mv[CNT_NEAR];
1118 mb->bmv[0] =
mb->mv;
1121 mb->mv = near_mv[CNT_NEAREST];
1122 mb->bmv[0] =
mb->mv;
1127 mb->bmv[0] =
mb->mv;
1133 int mb_x,
int mb_y,
int layout)
1138 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
1139 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1141 int cur_sign_bias =
s->sign_bias[
mb->ref_frame];
1142 const int8_t *sign_bias =
s->sign_bias;
1144 uint8_t cnt[4] = { 0 };
1148 mb_edge[0] =
mb + 2;
1149 mb_edge[2] =
mb + 1;
1151 mb_edge[0] =
mb -
s->mb_width - 1;
1152 mb_edge[2] =
mb -
s->mb_width - 2;
1160#define MV_EDGE_CHECK(n) \
1162 const VP8Macroblock *edge = mb_edge[n]; \
1163 int edge_ref = edge->ref_frame; \
1164 if (edge_ref != VP8_FRAME_CURRENT) { \
1165 uint32_t mv = AV_RN32A(&edge->mv); \
1167 if (cur_sign_bias != sign_bias[edge_ref]) { \
1170 mv = ((mv & 0x7fff7fff) + \
1171 0x00010001) ^ (mv & 0x80008000); \
1173 if (!n || mv != AV_RN32A(&near_mv[idx])) \
1174 AV_WN32A(&near_mv[++idx], mv); \
1175 cnt[idx] += 1 + (n != 2); \
1177 cnt[CNT_ZERO] += 1 + (n != 2); \
1190 if (cnt[CNT_SPLITMV] &&
1191 AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) ==
AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
1192 cnt[CNT_NEAREST] += 1;
1195 if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
1196 FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
1197 FFSWAP(
VP8mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
1203 clamp_mv(mv_bounds, &
mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
1214 mb->bmv[0] =
mb->mv;
1217 clamp_mv(mv_bounds, &
mb->mv, &near_mv[CNT_NEAR]);
1218 mb->bmv[0] =
mb->mv;
1221 clamp_mv(mv_bounds, &
mb->mv, &near_mv[CNT_NEAREST]);
1222 mb->bmv[0] =
mb->mv;
1227 mb->bmv[0] =
mb->mv;
1233 int mb_x,
int keyframe,
int layout)
1235 uint8_t *intra4x4 =
mb->intra4x4_pred_mode_mb;
1244 uint8_t *
const left =
s->intra4x4_pred_mode_left;
1246 top =
mb->intra4x4_pred_mode_top;
1248 top =
s->intra4x4_pred_mode_top + 4 * mb_x;
1249 for (y = 0; y < 4; y++) {
1250 for (x = 0; x < 4; x++) {
1254 left[y] = top[x] = *intra4x4;
1260 for (
i = 0;
i < 16;
i++)
1272 static const char *
const vp7_feature_name[] = {
"q-index",
1274 "partial-golden-update",
1279 for (
i = 0;
i < 4;
i++) {
1280 if (
s->feature_enabled[
i]) {
1283 s->feature_index_prob[
i]);
1285 "Feature %s present in macroblock (value 0x%x)\n",
1286 vp7_feature_name[
i],
s->feature_value[
i][
index]);
1290 }
else if (
s->segmentation.update_map) {
1293 }
else if (
s->segmentation.enabled)
1326 s->ref_count[
mb->ref_frame - 1]++;
1336 s->prob->pred16x16);
1362 int i,
const uint8_t *token_prob,
const int16_t qmul[2],
1363 const uint8_t scan[16],
int vp7)
1377 token_prob = probs[
i][0];
1385 token_prob = probs[
i + 1][1];
1405 int cat = (
a << 1) +
b;
1410 token_prob = probs[
i + 1][2];
1422 int16_t dc =
block[0];
1445 int i,
const uint8_t *token_prob,
1446 const int16_t qmul[2],
1447 const uint8_t scan[16])
1450 token_prob, qmul, scan,
IS_VP7);
1453#ifndef vp8_decode_block_coeffs_internal
1457 int i,
const uint8_t *token_prob,
1458 const int16_t qmul[2])
1481 int i,
int zero_nhood,
const int16_t qmul[2],
1482 const uint8_t scan[16],
int vp7)
1484 const uint8_t *token_prob = probs[
i][zero_nhood];
1488 token_prob, qmul, scan)
1498 int i, x, y, luma_start = 0, luma_ctx = 3;
1499 int nnz_pred, nnz, nnz_total = 0;
1504 nnz_pred = t_nnz[8] + l_nnz[8];
1508 nnz_pred,
s->qmat[
segment].luma_dc_qmul,
1510 l_nnz[8] = t_nnz[8] = !!nnz;
1514 s->inter_dc_pred[
mb->ref_frame - 1]);
1530 for (y = 0; y < 4; y++)
1531 for (x = 0; x < 4; x++) {
1532 nnz_pred = l_nnz[y] + t_nnz[x];
1534 s->prob->token[luma_ctx],
1535 luma_start, nnz_pred,
1537 s->prob[0].scan, is_vp7);
1541 t_nnz[x] = l_nnz[y] = !!nnz;
1548 for (
i = 4;
i < 6;
i++)
1549 for (y = 0; y < 2; y++)
1550 for (x = 0; x < 2; x++) {
1551 nnz_pred = l_nnz[
i + 2 * y] + t_nnz[
i + 2 * x];
1553 s->prob->token[2], 0, nnz_pred,
1555 s->prob[0].scan, is_vp7);
1557 t_nnz[
i + 2 * x] = l_nnz[
i + 2 * y] = !!nnz;
1570 const uint8_t *src_cb,
const uint8_t *src_cr,
1571 ptrdiff_t linesize, ptrdiff_t uvlinesize,
int simple)
1573 AV_COPY128(top_border, src_y + 15 * linesize);
1575 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
1576 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
1582 uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize,
int mb_x,
1583 int mb_y,
int mb_width,
int simple,
int xchg)
1585 uint8_t *top_border_m1 = top_border - 32;
1587 src_cb -= uvlinesize;
1588 src_cr -= uvlinesize;
1590#define XCHG(a, b, xchg) \
1598 XCHG(top_border_m1 + 8, src_y - 8, xchg);
1599 XCHG(top_border, src_y, xchg);
1600 XCHG(top_border + 8, src_y + 8, 1);
1601 if (mb_x < mb_width - 1)
1602 XCHG(top_border + 32, src_y + 16, 1);
1606 if (!simple || !mb_y) {
1607 XCHG(top_border_m1 + 16, src_cb - 8, xchg);
1608 XCHG(top_border_m1 + 24, src_cr - 8, xchg);
1609 XCHG(top_border + 16, src_cb, 1);
1610 XCHG(top_border + 24, src_cr, 1);
1660 int *copy_buf,
int vp7)
1664 if (!mb_x && mb_y) {
1698 int x, y,
mode, nnz;
1703 if (mb_y && (
s->deblock_filter || !mb_y) && td->
thread_nr == 0)
1705 s->linesize,
s->uvlinesize, mb_x, mb_y,
s->mb_width,
1706 s->filter.simple, 1);
1710 s->hpc.pred16x16[
mode](
dst[0],
s->linesize);
1712 uint8_t *ptr =
dst[0];
1713 const uint8_t *intra4x4 =
mb->intra4x4_pred_mode_mb;
1714 const uint8_t lo = is_vp7 ? 128 : 127;
1715 const uint8_t hi = is_vp7 ? 128 : 129;
1716 const uint8_t tr_top[4] = { lo, lo, lo, lo };
1720 const uint8_t *tr_right = ptr -
s->linesize + 16;
1724 if (mb_y && mb_x ==
s->mb_width - 1) {
1725 tr = tr_right[-1] * 0x01010101u;
1726 tr_right = (uint8_t *) &tr;
1732 for (y = 0; y < 4; y++) {
1733 const uint8_t *topright = ptr + 4 -
s->linesize;
1734 for (x = 0; x < 4; x++) {
1736 ptrdiff_t linesize =
s->linesize;
1737 uint8_t *
dst = ptr + 4 * x;
1740 if ((y == 0 || x == 3) && mb_y == 0) {
1743 topright = tr_right;
1746 mb_y + y, &
copy, is_vp7);
1748 dst = copy_dst + 12;
1752 AV_WN32A(copy_dst + 4, lo * 0x01010101U);
1754 AV_COPY32(copy_dst + 4, ptr + 4 * x -
s->linesize);
1758 copy_dst[3] = ptr[4 * x -
s->linesize - 1];
1767 copy_dst[11] = ptr[4 * x - 1];
1768 copy_dst[19] = ptr[4 * x +
s->linesize - 1];
1769 copy_dst[27] = ptr[4 * x +
s->linesize * 2 - 1];
1770 copy_dst[35] = ptr[4 * x +
s->linesize * 3 - 1];
1773 s->hpc.pred4x4[
mode](
dst, topright, linesize);
1776 AV_COPY32(ptr + 4 * x +
s->linesize, copy_dst + 20);
1777 AV_COPY32(ptr + 4 * x +
s->linesize * 2, copy_dst + 28);
1778 AV_COPY32(ptr + 4 * x +
s->linesize * 3, copy_dst + 36);
1784 s->vp8dsp.vp8_idct_dc_add(ptr + 4 * x,
1785 td->
block[y][x],
s->linesize);
1787 s->vp8dsp.vp8_idct_add(ptr + 4 * x,
1788 td->
block[y][x],
s->linesize);
1793 ptr += 4 *
s->linesize;
1799 mb_x, mb_y, is_vp7);
1800 s->hpc.pred8x8[
mode](
dst[1],
s->uvlinesize);
1801 s->hpc.pred8x8[
mode](
dst[2],
s->uvlinesize);
1803 if (mb_y && (
s->deblock_filter || !mb_y) && td->
thread_nr == 0)
1805 s->linesize,
s->uvlinesize, mb_x, mb_y,
s->mb_width,
1806 s->filter.simple, 0);
1810 { 0, 1, 2, 1, 2, 1, 2, 1 },
1812 { 0, 3, 5, 3, 5, 3, 5, 3 },
1813 { 0, 2, 3, 2, 3, 2, 3, 2 },
1835 int x_off,
int y_off,
int block_w,
int block_h,
1839 const uint8_t *
src =
ref->f->data[0];
1842 ptrdiff_t src_linesize = linesize;
1847 x_off +=
mv->x >> 2;
1848 y_off +=
mv->y >> 2;
1852 src += y_off * linesize + x_off;
1856 src - my_idx * linesize - mx_idx,
1860 x_off - mx_idx, y_off - my_idx,
1865 mc_func[my_idx][mx_idx](
dst, linesize,
src, src_linesize, block_h,
mx,
my);
1868 mc_func[0][0](
dst, linesize,
src + y_off * linesize + x_off,
1869 linesize, block_h, 0, 0);
1893 int x_off,
int y_off,
int block_w,
int block_h,
1903 x_off +=
mv->x >> 3;
1904 y_off +=
mv->y >> 3;
1907 src1 += y_off * linesize + x_off;
1908 src2 += y_off * linesize + x_off;
1913 src1 - my_idx * linesize - mx_idx,
1922 src2 - my_idx * linesize - mx_idx,
1930 mc_func[my_idx][mx_idx](dst1, linesize,
src1, linesize, block_h,
mx,
my);
1931 mc_func[my_idx][mx_idx](dst2, linesize,
src2, linesize, block_h,
mx,
my);
1935 mc_func[0][0](dst1, linesize,
src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1936 mc_func[0][0](dst2, linesize,
src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1943 int bx_off,
int by_off,
int block_w,
int block_h,
1952 s->put_pixels_tab[block_w == 8]);
1955 if (
s->profile == 3) {
1971 &uvmv, x_off + bx_off, y_off + by_off,
1973 s->put_pixels_tab[1 + (block_w == 4)]);
1980 int mb_x,
int mb_y,
int mb_xy,
int ref)
1983 if (
s->ref_count[
ref - 1] > (mb_xy >> 5)) {
1984 int x_off = mb_x << 4, y_off = mb_y << 4;
1985 int mx = (
mb->mv.x >> 2) + x_off + 8;
1986 int my = (
mb->mv.y >> 2) + y_off;
1987 uint8_t **
src =
s->framep[
ref]->tf.f->data;
1988 int off =
mx + (
my + (mb_x & 3) * 4) *
s->linesize + 64;
1992 s->vdsp.prefetch(
src[0] + off,
s->linesize, 4);
1993 off = (
mx >> 1) + ((
my >> 1) + (mb_x & 7)) *
s->uvlinesize + 64;
1994 s->vdsp.prefetch(
src[1] + off,
src[2] -
src[1], 2);
2005 int x_off = mb_x << 4, y_off = mb_y << 4;
2010 switch (
mb->partitioning) {
2020 for (y = 0; y < 4; y++) {
2021 for (x = 0; x < 4; x++) {
2023 ref, &bmv[4 * y + x],
2024 4 * x + x_off, 4 * y + y_off, 4, 4,
2026 s->put_pixels_tab[2]);
2035 for (y = 0; y < 2; y++) {
2036 for (x = 0; x < 2; x++) {
2037 uvmv.
x =
mb->bmv[2 * y * 4 + 2 * x ].x +
2038 mb->bmv[2 * y * 4 + 2 * x + 1].x +
2039 mb->bmv[(2 * y + 1) * 4 + 2 * x ].x +
2040 mb->bmv[(2 * y + 1) * 4 + 2 * x + 1].x;
2041 uvmv.
y =
mb->bmv[2 * y * 4 + 2 * x ].y +
2042 mb->bmv[2 * y * 4 + 2 * x + 1].y +
2043 mb->bmv[(2 * y + 1) * 4 + 2 * x ].y +
2044 mb->bmv[(2 * y + 1) * 4 + 2 * x + 1].y;
2047 if (
s->profile == 3) {
2052 dst[2] + 4 * y *
s->uvlinesize + x * 4,
ref,
2053 &uvmv, 4 * x + x_off, 4 * y + y_off, 4, 4,
2055 s->put_pixels_tab[2]);
2092 uint8_t *y_dst =
dst[0];
2093 for (y = 0; y < 4; y++) {
2096 if (nnz4 & ~0x01010101) {
2097 for (x = 0; x < 4; x++) {
2098 if ((uint8_t) nnz4 == 1)
2099 s->vp8dsp.vp8_idct_dc_add(y_dst + 4 * x,
2102 else if ((uint8_t) nnz4 > 1)
2103 s->vp8dsp.vp8_idct_add(y_dst + 4 * x,
2111 s->vp8dsp.vp8_idct_dc_add4y(y_dst, td->
block[y],
s->linesize);
2114 y_dst += 4 *
s->linesize;
2118 for (ch = 0; ch < 2; ch++) {
2121 uint8_t *ch_dst =
dst[1 + ch];
2122 if (nnz4 & ~0x01010101) {
2123 for (y = 0; y < 2; y++) {
2124 for (x = 0; x < 2; x++) {
2125 if ((uint8_t) nnz4 == 1)
2126 s->vp8dsp.vp8_idct_dc_add(ch_dst + 4 * x,
2127 td->
block[4 + ch][(y << 1) + x],
2129 else if ((uint8_t) nnz4 > 1)
2130 s->vp8dsp.vp8_idct_add(ch_dst + 4 * x,
2131 td->
block[4 + ch][(y << 1) + x],
2135 goto chroma_idct_end;
2137 ch_dst += 4 *
s->uvlinesize;
2140 s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, td->
block[4 + ch],
s->uvlinesize);
2152 int interior_limit, filter_level;
2154 if (
s->segmentation.enabled) {
2155 filter_level =
s->segmentation.filter_level[
mb->segment];
2156 if (!
s->segmentation.absolute_vals)
2157 filter_level +=
s->filter.level;
2159 filter_level =
s->filter.level;
2161 if (
s->lf_delta.enabled) {
2162 filter_level +=
s->lf_delta.ref[
mb->ref_frame];
2163 filter_level +=
s->lf_delta.mode[
mb->mode];
2168 interior_limit = filter_level;
2169 if (
s->filter.sharpness) {
2170 interior_limit >>= (
s->filter.sharpness + 3) >> 2;
2171 interior_limit =
FFMIN(interior_limit, 9 -
s->filter.sharpness);
2173 interior_limit =
FFMAX(interior_limit, 1);
2175 f->filter_level = filter_level;
2176 f->inner_limit = interior_limit;
2177 f->inner_filter = is_vp7 || !
mb->skip ||
mb->mode ==
MODE_I4x4 ||
2183 int mb_x,
int mb_y,
int is_vp7)
2185 int mbedge_lim, bedge_lim_y, bedge_lim_uv, hev_thresh;
2186 int filter_level =
f->filter_level;
2187 int inner_limit =
f->inner_limit;
2188 int inner_filter =
f->inner_filter;
2189 ptrdiff_t linesize =
s->linesize;
2190 ptrdiff_t uvlinesize =
s->uvlinesize;
2191 static const uint8_t hev_thresh_lut[2][64] = {
2192 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2194 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2196 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2197 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2206 bedge_lim_y = filter_level;
2207 bedge_lim_uv = filter_level * 2;
2208 mbedge_lim = filter_level + 2;
2211 bedge_lim_uv = filter_level * 2 + inner_limit;
2212 mbedge_lim = bedge_lim_y + 4;
2215 hev_thresh = hev_thresh_lut[
s->keyframe][filter_level];
2218 s->vp8dsp.vp8_h_loop_filter16y(
dst[0], linesize,
2219 mbedge_lim, inner_limit, hev_thresh);
2220 s->vp8dsp.vp8_h_loop_filter8uv(
dst[1],
dst[2], uvlinesize,
2221 mbedge_lim, inner_limit, hev_thresh);
2224#define H_LOOP_FILTER_16Y_INNER(cond) \
2225 if (cond && inner_filter) { \
2226 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 4, linesize, \
2227 bedge_lim_y, inner_limit, \
2229 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 8, linesize, \
2230 bedge_lim_y, inner_limit, \
2232 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 12, linesize, \
2233 bedge_lim_y, inner_limit, \
2235 s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4, \
2236 uvlinesize, bedge_lim_uv, \
2237 inner_limit, hev_thresh); \
2243 s->vp8dsp.vp8_v_loop_filter16y(
dst[0], linesize,
2244 mbedge_lim, inner_limit, hev_thresh);
2245 s->vp8dsp.vp8_v_loop_filter8uv(
dst[1],
dst[2], uvlinesize,
2246 mbedge_lim, inner_limit, hev_thresh);
2250 s->vp8dsp.vp8_v_loop_filter16y_inner(
dst[0] + 4 * linesize,
2251 linesize, bedge_lim_y,
2252 inner_limit, hev_thresh);
2253 s->vp8dsp.vp8_v_loop_filter16y_inner(
dst[0] + 8 * linesize,
2254 linesize, bedge_lim_y,
2255 inner_limit, hev_thresh);
2256 s->vp8dsp.vp8_v_loop_filter16y_inner(
dst[0] + 12 * linesize,
2257 linesize, bedge_lim_y,
2258 inner_limit, hev_thresh);
2259 s->vp8dsp.vp8_v_loop_filter8uv_inner(
dst[1] + 4 * uvlinesize,
2260 dst[2] + 4 * uvlinesize,
2261 uvlinesize, bedge_lim_uv,
2262 inner_limit, hev_thresh);
2272 int mbedge_lim, bedge_lim;
2273 int filter_level =
f->filter_level;
2274 int inner_limit =
f->inner_limit;
2275 int inner_filter =
f->inner_filter;
2276 ptrdiff_t linesize =
s->linesize;
2281 bedge_lim = 2 * filter_level + inner_limit;
2282 mbedge_lim = bedge_lim + 4;
2285 s->vp8dsp.vp8_h_loop_filter_simple(
dst, linesize, mbedge_lim);
2287 s->vp8dsp.vp8_h_loop_filter_simple(
dst + 4, linesize, bedge_lim);
2288 s->vp8dsp.vp8_h_loop_filter_simple(
dst + 8, linesize, bedge_lim);
2289 s->vp8dsp.vp8_h_loop_filter_simple(
dst + 12, linesize, bedge_lim);
2293 s->vp8dsp.vp8_v_loop_filter_simple(
dst, linesize, mbedge_lim);
2295 s->vp8dsp.vp8_v_loop_filter_simple(
dst + 4 * linesize, linesize, bedge_lim);
2296 s->vp8dsp.vp8_v_loop_filter_simple(
dst + 8 * linesize, linesize, bedge_lim);
2297 s->vp8dsp.vp8_v_loop_filter_simple(
dst + 12 * linesize, linesize, bedge_lim);
2301#define MARGIN (16 << 2)
2304 const VP8Frame *prev_frame,
int is_vp7)
2309 s->mv_bounds.mv_min.y = -
MARGIN;
2310 s->mv_bounds.mv_max.y = ((
s->mb_height - 1) << 6) +
MARGIN;
2311 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
2313 ((
s->mb_width + 1) * (mb_y + 1) + 1);
2314 int mb_xy = mb_y *
s->mb_width;
2318 s->mv_bounds.mv_min.x = -
MARGIN;
2319 s->mv_bounds.mv_max.x = ((
s->mb_width - 1) << 6) +
MARGIN;
2321 for (mb_x = 0; mb_x <
s->mb_width; mb_x++, mb_xy++,
mb++) {
2326 AV_WN32A((
mb -
s->mb_width - 1)->intra4x4_pred_mode_top,
2329 prev_frame && prev_frame->
seg_map ?
2331 s->mv_bounds.mv_min.x -= 64;
2332 s->mv_bounds.mv_max.x -= 64;
2334 s->mv_bounds.mv_min.y -= 64;
2335 s->mv_bounds.mv_max.y -= 64;
2353#define check_thread_pos(td, otd, mb_x_check, mb_y_check) \
2355 int tmp = (mb_y_check << 16) | (mb_x_check & 0xFFFF); \
2356 if (atomic_load(&otd->thread_mb_pos) < tmp) { \
2357 pthread_mutex_lock(&otd->lock); \
2358 atomic_store(&td->wait_mb_pos, tmp); \
2360 if (atomic_load(&otd->thread_mb_pos) >= tmp) \
2362 pthread_cond_wait(&otd->cond, &otd->lock); \
2364 atomic_store(&td->wait_mb_pos, INT_MAX); \
2365 pthread_mutex_unlock(&otd->lock); \
2369#define update_pos(td, mb_y, mb_x) \
2371 int pos = (mb_y << 16) | (mb_x & 0xFFFF); \
2372 int sliced_threading = (avctx->active_thread_type == FF_THREAD_SLICE) && \
2374 int is_null = !next_td || !prev_td; \
2375 int pos_check = (is_null) ? 1 : \
2376 (next_td != td && pos >= atomic_load(&next_td->wait_mb_pos)) || \
2377 (prev_td != td && pos >= atomic_load(&prev_td->wait_mb_pos)); \
2378 atomic_store(&td->thread_mb_pos, pos); \
2379 if (sliced_threading && pos_check) { \
2380 pthread_mutex_lock(&td->lock); \
2381 pthread_cond_broadcast(&td->cond); \
2382 pthread_mutex_unlock(&td->lock); \
2386#define check_thread_pos(td, otd, mb_x_check, mb_y_check) while(0)
2387#define update_pos(td, mb_y, mb_x) while(0)
2391 int jobnr,
int threadnr,
int is_vp7)
2394 VP8ThreadData *prev_td, *next_td, *td = &
s->thread_data[threadnr];
2396 int mb_x, mb_xy = mb_y *
s->mb_width;
2397 int num_jobs =
s->num_jobs;
2398 const VP8Frame *prev_frame =
s->prev_frame;
2400 VPXRangeCoder *coeff_c = &
s->coeff_partition[mb_y & (
s->num_coeff_partitions - 1)];
2404 curframe->
tf.
f->
data[0] + 16 * mb_y *
s->linesize,
2405 curframe->
tf.
f->
data[1] + 8 * mb_y *
s->uvlinesize,
2406 curframe->
tf.
f->
data[2] + 8 * mb_y *
s->uvlinesize
2415 prev_td = &
s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
2416 if (mb_y ==
s->mb_height - 1)
2419 next_td = &
s->thread_data[(jobnr + 1) % num_jobs];
2420 if (
s->mb_layout == 1)
2421 mb =
s->macroblocks_base + ((
s->mb_width + 1) * (mb_y + 1) + 1);
2425 if (prev_frame &&
s->segmentation.enabled &&
2426 !
s->segmentation.update_map)
2428 mb =
s->macroblocks + (
s->mb_height - mb_y - 1) * 2;
2429 memset(
mb - 1, 0,
sizeof(*
mb));
2433 if (!is_vp7 || mb_y == 0)
2439 for (mb_x = 0; mb_x <
s->mb_width; mb_x++, mb_xy++,
mb++) {
2443 if (prev_td != td) {
2444 if (threadnr != 0) {
2446 mb_x + (is_vp7 ? 2 : 1),
2447 mb_y - (is_vp7 ? 2 : 1));
2450 mb_x + (is_vp7 ? 2 : 1) +
s->mb_width + 3,
2451 mb_y - (is_vp7 ? 2 : 1));
2455 s->vdsp.prefetch(
dst[0] + (mb_x & 3) * 4 *
s->linesize + 64,
2457 s->vdsp.prefetch(
dst[1] + (mb_x & 7) *
s->uvlinesize + 64,
2462 prev_frame && prev_frame->
seg_map ?
2490 s->top_nnz[mb_x][8] = 0;
2494 if (
s->deblock_filter)
2497 if (
s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
2498 if (
s->filter.simple)
2503 dst[1],
dst[2],
s->linesize,
s->uvlinesize, 0);
2514 if (mb_x ==
s->mb_width + 1) {
2524 int jobnr,
int threadnr,
int is_vp7)
2529 AVFrame *curframe =
s->curframe->tf.f;
2532 curframe->
data[0] + 16 * mb_y *
s->linesize,
2533 curframe->
data[1] + 8 * mb_y *
s->uvlinesize,
2534 curframe->
data[2] + 8 * mb_y *
s->uvlinesize
2540 prev_td = &
s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
2541 if (mb_y ==
s->mb_height - 1)
2544 next_td = &
s->thread_data[(jobnr + 1) % num_jobs];
2546 for (mb_x = 0; mb_x <
s->mb_width; mb_x++) {
2550 (mb_x + 1) + (
s->mb_width + 3), mb_y - 1);
2552 if (next_td != &
s->thread_data[0])
2555 if (num_jobs == 1) {
2556 if (
s->filter.simple)
2561 dst[1],
dst[2],
s->linesize,
s->uvlinesize, 0);
2564 if (
s->filter.simple)
2578 int threadnr,
int is_vp7)
2584 int mb_y, num_jobs =
s->num_jobs;
2590 for (mb_y = jobnr; mb_y <
s->mb_height; mb_y += num_jobs) {
2592 ret =
s->decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr);
2597 if (
s->deblock_filter)
2598 s->filter_mb_row(avctx, tdata, jobnr, threadnr);
2612 int jobnr,
int threadnr)
2618 int jobnr,
int threadnr)
2628 int ret,
i, referenced, num_jobs;
2640 if (!is_vp7 &&
s->actually_webp) {
2648 if (
s->pix_fmt < 0) {
2666 memcpy(&
s->next_framep[0], &
s->framep[0],
sizeof(
s->framep[0]) * 4);
2672 for (
i = 0;
i < 5;
i++)
2673 if (
s->frames[
i].tf.f &&
2674 &
s->frames[
i] != prev_frame &&
2695 "Discarding interframe without a prior keyframe!\n");
2729 if (!is_vp7 && !
s->actually_webp)
2732 if (!is_vp7 && avctx->
hwaccel) {
2742 ret =
hwaccel->end_frame(avctx);
2747 s->linesize = curframe->tf.f->linesize[0];
2748 s->uvlinesize = curframe->tf.f->linesize[1];
2750 memset(
s->top_nnz, 0,
s->mb_width *
sizeof(*
s->top_nnz));
2754 memset(
s->macroblocks +
s->mb_height * 2 - 1, 0,
2755 (
s->mb_width + 1) *
sizeof(*
s->macroblocks));
2756 if (!
s->mb_layout &&
s->keyframe)
2757 memset(
s->intra4x4_pred_mode_top,
DC_PRED,
s->mb_width * 4);
2759 memset(
s->ref_count, 0,
sizeof(
s->ref_count));
2761 if (
s->mb_layout == 1) {
2764 if (prev_frame &&
s->segmentation.enabled &&
2765 !
s->segmentation.update_map)
2779 s->num_jobs = num_jobs;
2780 s->curframe = curframe;
2781 s->prev_frame = prev_frame;
2782 s->mv_bounds.mv_min.y = -
MARGIN;
2783 s->mv_bounds.mv_max.y = ((
s->mb_height - 1) << 6) +
MARGIN;
2798 memcpy(&
s->framep[0], &
s->next_framep[0],
sizeof(
s->framep[0]) * 4);
2803 if (!
s->update_probabilities)
2804 s->prob[0] =
s->prob[1];
2806 if (!
s->invisible) {
2814 memcpy(&
s->next_framep[0], &
s->framep[0],
sizeof(
s->framep[0]) * 4);
2841#if CONFIG_VP8_DECODER
2842static int vp8_decode_mb_row_no_filter(
AVCodecContext *avctx,
void *tdata,
2843 int jobnr,
int threadnr)
2849 int jobnr,
int threadnr)
2854static void vp8_warn_unsupported_webm_alpha(
AVCodecContext *avctx,
2863 if (!sd || sd_size < 8 ||
AV_RB64(sd) != 1)
2867 &
s->webm_alpha_warned,
2868 "Ignoring unsupported WebM alpha channel side data; use the "
2869 "libvpx decoder to decode it.\n");
2881 vp8_warn_unsupported_webm_alpha(avctx, avpkt);
2893 s->decode_mb_row_no_filter = vp8_decode_mb_row_no_filter;
2894 s->filter_mb_row = vp8_filter_mb_row;
2905 src->hwaccel_picture_private);
2908#define REBASE(pic) ((pic) ? (pic) - &s_src->frames[0] + &s->frames[0] : NULL)
2915 if (
s->macroblocks_base &&
2916 (s_src->mb_width !=
s->mb_width || s_src->mb_height !=
s->mb_height)) {
2918 s->mb_width = s_src->mb_width;
2919 s->mb_height = s_src->mb_height;
2922 s->pix_fmt = s_src->pix_fmt;
2923 s->prob[0] = s_src->prob[!s_src->update_probabilities];
2924 s->segmentation = s_src->segmentation;
2925 s->lf_delta = s_src->lf_delta;
2926 s->webm_alpha_warned = s_src->webm_alpha_warned;
2927 memcpy(
s->sign_bias, s_src->sign_bias,
sizeof(
s->sign_bias));
2930 vp8_replace_frame(&
s->frames[
i], &s_src->frames[
i]);
2932 s->framep[0] = REBASE(s_src->next_framep[0]);
2933 s->framep[1] = REBASE(s_src->next_framep[1]);
2934 s->framep[2] = REBASE(s_src->next_framep[2]);
2935 s->framep[3] = REBASE(s_src->next_framep[3]);
2942#if CONFIG_VP7_DECODER
2943static int vp7_decode_mb_row_no_filter(
AVCodecContext *avctx,
void *tdata,
2944 int jobnr,
int threadnr)
2950 int jobnr,
int threadnr)
2968 s->decode_mb_row_no_filter = vp7_decode_mb_row_no_filter;
2969 s->filter_mb_row = vp7_filter_mb_row;
2980 .
init = vp7_decode_init,
2989#if CONFIG_VP8_DECODER
3005#if CONFIG_VP8_VAAPI_HWACCEL
3008#if CONFIG_VP8_NVDEC_HWACCEL
3011#if CONFIG_VP8_NVDEC_CUARRAY_HWACCEL
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static av_always_inline void update(AVFilterContext *ctx, AVFrame *insamples, int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base)
const FFCodec ff_vp7_decoder
const FFCodec ff_vp8_decoder
static AVFormatContext * ctx
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
#define bit(string, value)
const uint8_t ff_vp8_token_update_probs[4][8][3][11]
#define prob(name, subs,...)
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_CAP_USES_PROGRESSFRAMES
The decoder might make use of the ProgressFrame API.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
void ff_progress_frame_replace(ProgressFrame *dst, const ProgressFrame *src)
Do nothing if dst and src already refer to the same AVFrame; otherwise unreference dst and if src is ...
void ff_progress_frame_await(const ProgressFrame *f, int n)
Wait for earlier decoding threads to finish reference frames.
void ff_progress_frame_report(ProgressFrame *f, int n)
Notify later decoding threads when part of their reference frame is ready.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags)
Wrapper around ff_progress_frame_alloc() and ff_thread_get_buffer().
void ff_progress_frame_unref(ProgressFrame *f)
Give up a reference to the underlying frame contained in a ProgressFrame and reset the ProgressFrame,...
int ff_set_dimensions(AVCodecContext *s, int width, int height)
void(* flush)(AVBSFContext *ctx)
int(* init)(AVBSFContext *ctx)
#define atomic_store(object, desired)
#define atomic_load(object)
#define atomic_init(obj, value)
static const uint8_t bits[8]
static const char * hwaccel
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_NONREF
discard all non reference
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
#define HOR_VP8_PRED
unaveraged version of HOR_PRED, see VERT_VP8_PRED for details
#define VERT_VP8_PRED
for VP8, VERT_PRED is the average of (left col+cur col x2+right col) / 4; this is the "unaveraged" on...
#define VERT_PRED
Prediction types.
#define DIAG_DOWN_LEFT_PRED
#define TM_VP8_PRED
"True Motion", used instead of plane
#define DIAG_DOWN_RIGHT_PRED
#define FF_HW_HAS_CB(avctx, function)
#define FF_HW_SIMPLE_CALL(avctx, function)
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
#define HWACCEL_NVDEC_CUARRAY(codec)
#define HWACCEL_NVDEC(codec)
#define HWACCEL_VAAPI(codec)
static const int16_t alpha[]
static const int sizes[][2]
static const int8_t mv[256][2]
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.
Multithreading API for decoders.
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
Macro definitions for various function/variable attributes.
static enum AVPixelFormat pix_fmts[]
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
#define FFSWAP(type, a, b)
const uint8_t ff_zigzag_scan[16+1]
Memory handling functions.
#define LOCAL_ALIGNED(a, t, v,...)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_CUARRAY
hardware decoding through openharmony
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
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 av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
#define FF_ARRAY_ELEMS(a)
static const SiprModeParam modes[MODE_COUNT]
static const float pred[4]
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
int active_thread_type
Which multithreading methods are in use by the codec.
enum AVDiscard skip_loop_filter
Skip loop filtering for selected frames.
enum AVColorSpace colorspace
YUV colorspace type.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
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.
enum AVDiscard skip_frame
Skip decoding for selected frames.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
The ProgressFrame structure.
uint8_t * seg_map
RefStruct reference.
uint8_t intra4x4_pred_mode_top[4]
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...
uint8_t edge_emu_buffer[21 *EDGE_EMU_LINESIZE]
uint8_t left_nnz[9]
For coeff decode, we need to know whether the above block had non-zero coefficients.
VP8FilterStrength * filter_strength
#define avpriv_request_sample(...)
static int ref[MAX_W *MAX_W]
static const double coeff[2][5]
static void copy(const float *p1, float *p2, const int length)
Range decoder functions common to VP8 and VP9.
static av_always_inline int vp89_rac_get(VPXRangeCoder *c)
static av_always_inline int vp89_rac_get_tree(VPXRangeCoder *c, const int8_t(*tree)[2], const uint8_t *probs)
static av_unused int vp89_rac_get_uint(VPXRangeCoder *c, int bits)
static av_cold void vp78_decode_init(AVCodecContext *avctx)
static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
#define H_LOOP_FILTER_16Y_INNER(cond)
static av_always_inline void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
static av_always_inline void prefetch_motion(const VP8Context *s, const VP8Macroblock *mb, int mb_x, int mb_y, int mb_xy, int ref)
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...
av_cold int ff_vp8_decode_free(AVCodecContext *avctx)
static av_always_inline int decode_block_coeffs(VPXRangeCoder *c, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS - 1], int i, int zero_nhood, const int16_t qmul[2], const uint8_t scan[16], int vp7)
static av_always_inline int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7)
static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
static int vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, const VP8Frame *prev_frame)
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)
static int vp8_rac_get_coeff(VPXRangeCoder *c, const uint8_t *prob)
static int vp7_update_dimensions(VP8Context *s, int width, int height)
static void vp78_update_pred16x16_pred8x8_mvc_probabilities(VP8Context *s, int mvc_size)
static int vp8_rac_get_nn(VPXRangeCoder *c)
static av_always_inline void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst, const ProgressFrame *ref, const VP8mv *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 av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3], const VP8Macroblock *mb)
static const uint8_t subpel_idx[3][8]
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref)
static int vp8_read_mv_component(VPXRangeCoder *c, const uint8_t *p)
static av_always_inline void decode_mb_mode(VP8Context *s, const VP8mvbounds *mv_bounds, VP8Macroblock *mb, int mb_x, int mb_y, uint8_t *segment, const uint8_t *ref, int layout, int is_vp7)
static av_always_inline void filter_mb_simple(const VP8Context *s, uint8_t *dst, const VP8FilterStrength *f, int mb_x, int mb_y)
static int vp7_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static av_always_inline void clamp_mv(const VP8mvbounds *s, VP8mv *dst, const VP8mv *src)
static av_always_inline void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3], VP8Macroblock *mb, int mb_x, int mb_y, int is_vp7)
static void copy_chroma(AVFrame *dst, const AVFrame *src, int width, int height)
static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7)
static void vp7_get_quants(VP8Context *s)
static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
static av_always_inline const uint8_t * get_submv_prob(uint32_t left, uint32_t top, int is_vp7)
static av_always_inline int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf, int vp7)
static av_always_inline int vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, const VP8Frame *prev_frame, int is_vp7)
static av_always_inline int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
static av_always_inline void vp8_decode_mvs(VP8Context *s, const VP8mvbounds *mv_bounds, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
static av_always_inline void filter_level_for_mb(const VP8Context *s, const VP8Macroblock *mb, VP8FilterStrength *f, int is_vp7)
static av_always_inline void filter_mb(const VP8Context *s, uint8_t *const dst[3], const VP8FilterStrength *f, int mb_x, int mb_y, int is_vp7)
static void vp8_get_quants(VP8Context *s)
static av_cold void vp8_decode_flush_impl(AVCodecContext *avctx, int free_mem)
static void vp8_release_frame(VP8Frame *f)
static VP8Frame * vp8_find_free_buffer(VP8Context *s)
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 void backup_mb_border(uint8_t *top_border, const uint8_t *src_y, const uint8_t *src_cb, const uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize, int simple)
static int vp8_decode_block_coeffs_internal(VPXRangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS - 1], int i, const uint8_t *token_prob, const int16_t qmul[2])
static VP8FrameType ref_to_update(VP8Context *s, int update, VP8FrameType ref)
Determine which buffers golden and altref should be updated with after this frame.
static int vp8_update_dimensions(VP8Context *s, int width, int height)
static av_always_inline int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, const AVPacket *avpkt, int is_vp7)
#define check_thread_pos(td, otd, mb_x_check, mb_y_check)
static int vp7_decode_block_coeffs_internal(VPXRangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS - 1], int i, const uint8_t *token_prob, const int16_t qmul[2], const uint8_t scan[16])
static av_always_inline int inter_predict_dc(int16_t block[16], int16_t pred[2])
static av_always_inline int decode_splitmvs(const VP8Context *s, VPXRangeCoder *c, VP8Macroblock *mb, int layout, int is_vp7)
Split motion vector prediction, 16.4.
static av_always_inline void inter_predict(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3], VP8Macroblock *mb, int mb_x, int mb_y)
Apply motion vectors to prediction buffer, chapter 18.
static av_always_inline int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y, int vp7)
static av_always_inline int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y, int vp7)
static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
static av_always_inline void decode_intra4x4_modes(VP8Context *s, VPXRangeCoder *c, VP8Macroblock *mb, int mb_x, int keyframe, int layout)
static av_always_inline int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y, int vp7)
static av_cold void vp8_decode_flush(AVCodecContext *avctx)
static void update_refs(VP8Context *s)
static void vp78_reset_probability_tables(VP8Context *s)
static int vp7_read_mv_component(VPXRangeCoder *c, const uint8_t *p)
static av_always_inline int decode_block_coeffs_internal(VPXRangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS - 1], int i, const uint8_t *token_prob, const int16_t qmul[2], const uint8_t scan[16], int vp7)
static enum AVPixelFormat get_pixel_format(VP8Context *s)
static av_always_inline void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1, uint8_t *dst2, const ProgressFrame *ref, const VP8mv *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
static av_always_inline int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
static void vp78_update_probability_tables(VP8Context *s)
static void update_lf_deltas(VP8Context *s)
static void free_buffers(VP8Context *s)
static av_always_inline int read_mv_component(VPXRangeCoder *c, const uint8_t *p, int vp7)
Motion vector coding, 17.1.
static void parse_segment_info(VP8Context *s)
static av_always_inline void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VPXRangeCoder *c, VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9], int is_vp7)
static int vp8_rac_get_sint(VPXRangeCoder *c, int bits)
static const VP8mv * get_bmv_ptr(const VP8Macroblock *mb, int subblock)
static av_always_inline void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3], const ProgressFrame *ref_frame, int x_off, int y_off, int bx_off, int by_off, int block_w, int block_h, int width, int height, const VP8mv *mv)
#define update_pos(td, mb_y, mb_x)
static int vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, const VP8Frame *prev_frame)
static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr, int is_vp7)
#define EDGE_EMU_LINESIZE
int ff_vp8_decode_init(AVCodecContext *avctx)
@ VP8_SPLITMVMODE_8x8
2x2 blocks of 8x8px each
@ VP8_SPLITMVMODE_4x4
4x4 blocks of 4x4px each
@ VP8_SPLITMVMODE_16x8
2 16x8 blocks (vertical)
@ VP8_SPLITMVMODE_NONE
(only used in prediction) no split MVs
@ VP8_SPLITMVMODE_8x16
2 8x16 blocks (horizontal)
int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
const uint8_t *const ff_vp8_dct_cat_prob[]
VP8 compatible video decoder.
static const int vp7_mode_contexts[31][4]
static const int8_t vp8_pred8x8c_tree[3][2]
static const uint16_t vp7_y2dc_qlookup[]
static const uint16_t vp8_ac_qlookup[VP8_MAX_QUANT+1]
static const uint8_t vp8_pred4x4_mode[]
static const uint8_t vp8_mv_update_prob[2][19]
static const uint8_t vp7_feature_value_size[2][4]
static const int8_t vp8_pred16x16_tree_intra[4][2]
static const uint8_t vp8_mbsplit_prob[3]
static const uint16_t vp7_y2ac_qlookup[]
static const int8_t vp8_pred16x16_tree_inter[4][2]
static const int8_t vp8_coeff_band_indexes[8][10]
static const uint8_t vp8_pred16x16_prob_inter[4]
static const uint8_t vp8_dct_cat2_prob[]
static const uint8_t vp8_pred16x16_prob_intra[4]
static const int8_t vp7_feature_index_tree[4][2]
static const uint16_t vp7_ydc_qlookup[]
static const uint8_t vp8_pred8x8c_prob_intra[3]
static const uint8_t vp8_mv_default_prob[2][19]
static const uint8_t vp8_mbsplits[5][16]
static const int vp8_mode_contexts[6][4]
#define VP7_MV_PRED_COUNT
static const uint8_t vp7_mv_default_prob[2][17]
static const uint8_t vp8_mbfirstidx[4][16]
static const uint8_t vp8_pred8x8c_prob_inter[3]
static const uint16_t vp7_yac_qlookup[]
static const uint8_t vp8_mbsplit_count[4]
static const uint8_t vp8_pred4x4_prob_intra[10][10][9]
static const uint8_t vp7_pred4x4_mode[]
static const uint8_t vp8_dct_cat1_prob[]
static const uint8_t vp8_submv_prob[5][3]
static const uint8_t vp7_submv_prob[3]
static const VP7MVPred vp7_mv_pred[VP7_MV_PRED_COUNT]
static const uint8_t vp8_token_default_probs[4][8][3][NUM_DCT_TOKENS - 1]
static const int8_t vp8_pred4x4_tree[9][2]
static const uint8_t vp8_dc_qlookup[VP8_MAX_QUANT+1]
static const uint8_t vp8_coeff_band[16]
static const uint8_t vp8_pred4x4_prob_inter[9]
void(* vp8_mc_func)(uint8_t *dst, ptrdiff_t dstStride, const uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
void ff_vp7dsp_init(VP8DSPContext *c)
void ff_vp8dsp_init(VP8DSPContext *c)
int ff_vpx_init_range_decoder(VPXRangeCoder *c, const uint8_t *buf, int buf_size)
Common VP5-VP9 range decoder stuff.
static av_always_inline int vpx_rac_get_prob_branchy(VPXRangeCoder *c, int prob)
static av_always_inline unsigned int vpx_rac_renorm(VPXRangeCoder *c)
static av_always_inline int vpx_rac_is_end(VPXRangeCoder *c)
returns 1 if the end of the stream has been reached, 0 otherwise.
static int ref_frame(VVCFrame *dst, const VVCFrame *src)