43 #if CONFIG_VP7_DECODER && CONFIG_VP8_DECODER
44 #define VPX(vp7, f) (vp7 ? vp7_ ## f : vp8_ ## f)
45 #elif CONFIG_VP7_DECODER
46 #define VPX(vp7, f) vp7_ ## f
48 #define VPX(vp7, f) vp8_ ## f
68 s->macroblocks =
NULL;
79 if (
s->avctx->hwaccel) {
83 if (!
f->hwaccel_priv_buf)
85 f->hwaccel_picture_private =
f->hwaccel_priv_buf->data;
100 f->hwaccel_picture_private =
NULL;
104 #if CONFIG_VP8_DECODER
118 if (
src->hwaccel_picture_private) {
136 memset(
s->framep, 0,
sizeof(
s->framep));
153 for (
i = 0;
i < 5;
i++)
174 #if CONFIG_VP8_VAAPI_HWACCEL
177 #if CONFIG_VP8_NVDEC_HWACCEL
191 int i, ret, dim_reset = 0;
193 if (
width !=
s->avctx->width || ((
width+15)/16 !=
s->mb_width || (
height+15)/16 !=
s->mb_height) &&
s->macroblocks_base ||
201 dim_reset = (
s->macroblocks_base !=
NULL);
205 !
s->actually_webp && !is_vp7) {
212 s->mb_width = (
s->avctx->coded_width + 15) / 16;
213 s->mb_height = (
s->avctx->coded_height + 15) / 16;
218 s->macroblocks_base =
av_mallocz((
s->mb_width +
s->mb_height * 2 + 1) *
219 sizeof(*
s->macroblocks));
220 s->intra4x4_pred_mode_top =
av_mallocz(
s->mb_width * 4);
222 s->macroblocks_base =
av_mallocz((
s->mb_width + 2) * (
s->mb_height + 2) *
223 sizeof(*
s->macroblocks));
225 s->top_border =
av_mallocz((
s->mb_width + 1) *
sizeof(*
s->top_border));
228 if (!
s->macroblocks_base || !
s->top_nnz || !
s->top_border ||
229 !
s->thread_data || (!
s->intra4x4_pred_mode_top && !
s->mb_layout)) {
235 s->thread_data[
i].filter_strength =
236 av_mallocz(
s->mb_width *
sizeof(*
s->thread_data[0].filter_strength));
237 if (!
s->thread_data[
i].filter_strength) {
255 s->macroblocks =
s->macroblocks_base + 1;
279 if (
s->segmentation.update_feature_data) {
282 for (
i = 0;
i < 4;
i++)
285 for (
i = 0;
i < 4;
i++)
288 if (
s->segmentation.update_map)
289 for (
i = 0;
i < 3;
i++)
298 for (
i = 0;
i < 4;
i++) {
303 s->lf_delta.ref[
i] = -
s->lf_delta.ref[
i];
312 s->lf_delta.mode[
i] = -
s->lf_delta.mode[
i];
325 buf += 3 * (
s->num_coeff_partitions - 1);
326 buf_size -= 3 * (
s->num_coeff_partitions - 1);
330 for (
i = 0;
i <
s->num_coeff_partitions - 1;
i++) {
332 if (buf_size -
size < 0)
334 s->coeff_partition_size[
i] =
size;
343 s->coeff_partition_size[
i] = buf_size;
380 for (
i = 0;
i < 4;
i++) {
381 if (
s->segmentation.enabled) {
382 base_qi =
s->segmentation.base_quant[
i];
383 if (!
s->segmentation.absolute_vals)
384 base_qi +=
s->quant.yac_qi;
386 base_qi =
s->quant.yac_qi;
396 s->qmat[
i].luma_dc_qmul[1] =
FFMAX(
s->qmat[
i].luma_dc_qmul[1], 8);
397 s->qmat[
i].chroma_qmul[0] =
FFMIN(
s->qmat[
i].chroma_qmul[0], 132);
433 for (
i = 0;
i < 4;
i++)
434 for (j = 0; j < 16; j++)
436 sizeof(
s->prob->token[
i][j]));
444 for (
i = 0;
i < 4;
i++)
445 for (j = 0; j < 8; j++)
446 for (k = 0; k < 3; k++)
455 #define VP7_MVC_SIZE 17
456 #define VP8_MVC_SIZE 19
465 for (
i = 0;
i < 4;
i++)
468 for (
i = 0;
i < 3;
i++)
472 for (
i = 0;
i < 2;
i++)
473 for (j = 0; j < mvc_size; j++)
493 for (j = 1; j < 3; j++) {
506 for (j = 0; j <
height; j++) {
508 uint8_t *dst2 = dst + j * dst_linesize;
520 if (!
s->keyframe && (
alpha || beta)) {
521 int width =
s->mb_width * 16;
522 int height =
s->mb_height * 16;
546 src->data[0],
src->linesize[0],
556 int part1_size, hscale, vscale,
i, j, ret;
557 int width =
s->avctx->width;
566 s->profile = (buf[0] >> 1) & 7;
567 if (
s->profile > 1) {
572 s->keyframe = !(buf[0] & 1);
574 part1_size =
AV_RL24(buf) >> 4;
576 if (buf_size < 4 - s->
profile + part1_size) {
577 av_log(
s->avctx,
AV_LOG_ERROR,
"Buffer size %d is too small, needed : %d\n", buf_size, 4 -
s->profile + part1_size);
581 buf += 4 -
s->profile;
582 buf_size -= 4 -
s->profile;
584 memcpy(
s->put_pixels_tab,
s->vp8dsp.put_vp8_epel_pixels_tab,
sizeof(
s->put_pixels_tab));
590 buf_size -= part1_size;
598 if (hscale || vscale)
604 sizeof(
s->prob->pred16x16));
606 sizeof(
s->prob->pred8x8c));
607 for (
i = 0;
i < 2;
i++)
610 memset(&
s->segmentation, 0,
sizeof(
s->segmentation));
611 memset(&
s->lf_delta, 0,
sizeof(
s->lf_delta));
615 if (
s->keyframe ||
s->profile > 0)
616 memset(
s->inter_dc_pred, 0 ,
sizeof(
s->inter_dc_pred));
619 for (
i = 0;
i < 4;
i++) {
621 if (
s->feature_enabled[
i]) {
624 for (j = 0; j < 3; j++)
625 s->feature_index_prob[
i][j] =
629 for (j = 0; j < 4; j++)
630 s->feature_value[
i][j] =
635 s->segmentation.enabled = 0;
636 s->segmentation.update_map = 0;
637 s->lf_delta.enabled = 0;
639 s->num_coeff_partitions = 1;
644 if (!
s->macroblocks_base ||
646 (
width + 15) / 16 !=
s->mb_width || (
height + 15) / 16 !=
s->mb_height) {
661 s->update_probabilities = 1;
664 if (
s->profile > 0) {
666 if (!
s->update_probabilities)
667 s->prob[1] =
s->prob[0];
687 for (
i = 1;
i < 16;
i++)
699 s->mbskip_enabled = 0;
720 int header_size, hscale, vscale, ret;
721 int width =
s->avctx->width;
729 s->keyframe = !(buf[0] & 1);
730 s->profile = (buf[0]>>1) & 7;
731 s->invisible = !(buf[0] & 0x10);
732 header_size =
AV_RL24(buf) >> 5;
736 s->header_partition_size = header_size;
742 memcpy(
s->put_pixels_tab,
s->vp8dsp.put_vp8_epel_pixels_tab,
743 sizeof(
s->put_pixels_tab));
745 memcpy(
s->put_pixels_tab,
s->vp8dsp.put_vp8_bilinear_pixels_tab,
746 sizeof(
s->put_pixels_tab));
748 if (header_size > buf_size - 7 *
s->keyframe) {
754 if (
AV_RL24(buf) != 0x2a019d) {
756 "Invalid start code 0x%x\n",
AV_RL24(buf));
761 hscale = buf[4] >> 6;
762 vscale = buf[6] >> 6;
766 if (hscale || vscale)
772 sizeof(
s->prob->pred16x16));
774 sizeof(
s->prob->pred8x8c));
776 sizeof(
s->prob->mvc));
777 memset(&
s->segmentation, 0,
sizeof(
s->segmentation));
778 memset(&
s->lf_delta, 0,
sizeof(
s->lf_delta));
785 buf_size -= header_size;
797 s->segmentation.update_map = 0;
805 if (
s->lf_delta.update)
814 if (!
s->macroblocks_base ||
816 (
width+15)/16 !=
s->mb_width || (
height+15)/16 !=
s->mb_height)
831 s->prob[1] =
s->prob[0];
849 s->coder_state_at_header_end.input =
s->c.buffer - (-
s->c.bits / 8);
850 s->coder_state_at_header_end.range =
s->c.high;
851 s->coder_state_at_header_end.value =
s->c.code_word >> 16;
852 s->coder_state_at_header_end.bit_count = -
s->c.bits % 8;
861 av_clip(
s->mv_max.x, INT16_MIN, INT16_MAX));
863 av_clip(
s->mv_max.y, INT16_MIN, INT16_MAX));
876 for (
i = 0;
i < 3;
i++)
878 for (
i = (vp7 ? 7 : 9);
i > 3;
i--)
933 const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
941 top_mb = &
mb[-
s->mb_width - 1];
943 top_mv = top_mb->
bmv;
957 mb->partitioning = part_idx;
959 for (n = 0; n < num; n++) {
961 uint32_t left, above;
965 left =
AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
967 left =
AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
969 above =
AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
971 above =
AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
978 mb->bmv[n].y =
mb->mv.y +
980 mb->bmv[n].x =
mb->mv.x +
1008 int xoffset,
int yoffset,
int boundary,
1009 int *edge_x,
int *edge_y)
1011 int vwidth = mb_width + 1;
1012 int new = (mb_y + yoffset) * vwidth + mb_x + xoffset;
1013 if (
new < boundary ||
new % vwidth == vwidth - 1)
1015 *edge_y =
new / vwidth;
1016 *edge_x =
new % vwidth;
1027 int mb_x,
int mb_y,
int layout)
1030 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
1031 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1047 pred->yoffset, !
s->profile, &edge_x, &edge_y)) {
1049 ?
s->macroblocks_base + 1 + edge_x +
1050 (
s->mb_width + 1) * (edge_y + 1)
1051 :
s->macroblocks + edge_x +
1052 (
s->mb_height - edge_y - 1) * 2;
1055 if (
AV_RN32A(&near_mv[CNT_NEAREST])) {
1058 }
else if (
AV_RN32A(&near_mv[CNT_NEAR])) {
1088 if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
1089 AV_WN32A(&
mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 :
AV_RN32A(&near_mv[CNT_NEAREST]));
1099 mb->bmv[0] =
mb->mv;
1102 mb->mv = near_mv[CNT_NEAR];
1103 mb->bmv[0] =
mb->mv;
1106 mb->mv = near_mv[CNT_NEAREST];
1107 mb->bmv[0] =
mb->mv;
1112 mb->bmv[0] =
mb->mv;
1118 int mb_x,
int mb_y,
int layout)
1123 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
1124 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1126 int cur_sign_bias =
s->sign_bias[
mb->ref_frame];
1127 int8_t *sign_bias =
s->sign_bias;
1133 mb_edge[0] =
mb + 2;
1134 mb_edge[2] =
mb + 1;
1136 mb_edge[0] =
mb -
s->mb_width - 1;
1137 mb_edge[2] =
mb -
s->mb_width - 2;
1145 #define MV_EDGE_CHECK(n) \
1147 VP8Macroblock *edge = mb_edge[n]; \
1148 int edge_ref = edge->ref_frame; \
1149 if (edge_ref != VP56_FRAME_CURRENT) { \
1150 uint32_t mv = AV_RN32A(&edge->mv); \
1152 if (cur_sign_bias != sign_bias[edge_ref]) { \
1155 mv = ((mv & 0x7fff7fff) + \
1156 0x00010001) ^ (mv & 0x80008000); \
1158 if (!n || mv != AV_RN32A(&near_mv[idx])) \
1159 AV_WN32A(&near_mv[++idx], mv); \
1160 cnt[idx] += 1 + (n != 2); \
1162 cnt[CNT_ZERO] += 1 + (n != 2); \
1175 if (cnt[CNT_SPLITMV] &&
1176 AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) ==
AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
1177 cnt[CNT_NEAREST] += 1;
1180 if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
1182 FFSWAP(
VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
1188 clamp_mv(mv_bounds, &
mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
1199 mb->bmv[0] =
mb->mv;
1202 clamp_mv(mv_bounds, &
mb->mv, &near_mv[CNT_NEAR]);
1203 mb->bmv[0] =
mb->mv;
1206 clamp_mv(mv_bounds, &
mb->mv, &near_mv[CNT_NEAREST]);
1207 mb->bmv[0] =
mb->mv;
1212 mb->bmv[0] =
mb->mv;
1218 int mb_x,
int keyframe,
int layout)
1220 uint8_t *intra4x4 =
mb->intra4x4_pred_mode_mb;
1229 uint8_t *
const left =
s->intra4x4_pred_mode_left;
1231 top =
mb->intra4x4_pred_mode_top;
1233 top =
s->intra4x4_pred_mode_top + 4 * mb_x;
1234 for (y = 0; y < 4; y++) {
1235 for (x = 0; x < 4; x++) {
1239 left[y] = top[x] = *intra4x4;
1245 for (
i = 0;
i < 16;
i++)
1257 static const char *
const vp7_feature_name[] = {
"q-index",
1259 "partial-golden-update",
1264 for (
i = 0;
i < 4;
i++) {
1265 if (
s->feature_enabled[
i]) {
1268 s->feature_index_prob[
i]);
1270 "Feature %s present in macroblock (value 0x%x)\n",
1271 vp7_feature_name[
i],
s->feature_value[
i][
index]);
1275 }
else if (
s->segmentation.update_map) {
1278 }
else if (
s->segmentation.enabled)
1311 s->ref_count[
mb->ref_frame - 1]++;
1346 int i,
uint8_t *token_prob, int16_t qmul[2],
1347 const uint8_t scan[16],
int vp7)
1361 token_prob = probs[
i][0];
1369 token_prob = probs[
i + 1][1];
1389 int cat = (
a << 1) +
b;
1394 token_prob = probs[
i + 1][2];
1434 token_prob, qmul, scan,
IS_VP7);
1437 #ifndef vp8_decode_block_coeffs_internal
1465 int i,
int zero_nhood, int16_t qmul[2],
1466 const uint8_t scan[16],
int vp7)
1468 uint8_t *token_prob = probs[
i][zero_nhood];
1472 token_prob, qmul, scan)
1482 int i, x, y, luma_start = 0, luma_ctx = 3;
1483 int nnz_pred, nnz, nnz_total = 0;
1488 nnz_pred = t_nnz[8] + l_nnz[8];
1492 nnz_pred,
s->qmat[
segment].luma_dc_qmul,
1494 l_nnz[8] = t_nnz[8] = !!nnz;
1498 s->inter_dc_pred[
mb->ref_frame - 1]);
1505 s->vp8dsp.vp8_luma_dc_wht_dc(
td->block,
td->block_dc);
1507 s->vp8dsp.vp8_luma_dc_wht(
td->block,
td->block_dc);
1514 for (y = 0; y < 4; y++)
1515 for (x = 0; x < 4; x++) {
1516 nnz_pred = l_nnz[y] + t_nnz[x];
1518 s->prob->token[luma_ctx],
1519 luma_start, nnz_pred,
1521 s->prob[0].scan, is_vp7);
1524 td->non_zero_count_cache[y][x] = nnz + block_dc;
1525 t_nnz[x] = l_nnz[y] = !!nnz;
1532 for (
i = 4;
i < 6;
i++)
1533 for (y = 0; y < 2; y++)
1534 for (x = 0; x < 2; x++) {
1535 nnz_pred = l_nnz[
i + 2 * y] + t_nnz[
i + 2 * x];
1537 s->prob->token[2], 0, nnz_pred,
1539 s->prob[0].scan, is_vp7);
1540 td->non_zero_count_cache[
i][(y << 1) + x] = nnz;
1541 t_nnz[
i + 2 * x] = l_nnz[
i + 2 * y] = !!nnz;
1555 ptrdiff_t linesize, ptrdiff_t uvlinesize,
int simple)
1557 AV_COPY128(top_border, src_y + 15 * linesize);
1559 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
1560 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
1566 uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize,
int mb_x,
1567 int mb_y,
int mb_width,
int simple,
int xchg)
1569 uint8_t *top_border_m1 = top_border - 32;
1571 src_cb -= uvlinesize;
1572 src_cr -= uvlinesize;
1574 #define XCHG(a, b, xchg) \
1582 XCHG(top_border_m1 + 8, src_y - 8, xchg);
1583 XCHG(top_border, src_y, xchg);
1584 XCHG(top_border + 8, src_y + 8, 1);
1585 if (mb_x < mb_width - 1)
1586 XCHG(top_border + 32, src_y + 16, 1);
1590 if (!simple || !mb_y) {
1591 XCHG(top_border_m1 + 16, src_cb - 8, xchg);
1592 XCHG(top_border_m1 + 24, src_cr - 8, xchg);
1593 XCHG(top_border + 16, src_cb, 1);
1594 XCHG(top_border + 24, src_cr, 1);
1644 int *copy_buf,
int vp7)
1648 if (!mb_x && mb_y) {
1682 int x, y,
mode, nnz;
1687 if (mb_y && (
s->deblock_filter || !mb_y) &&
td->thread_nr == 0)
1689 s->linesize,
s->uvlinesize, mb_x, mb_y,
s->mb_width,
1690 s->filter.simple, 1);
1694 s->hpc.pred16x16[
mode](dst[0],
s->linesize);
1697 uint8_t *intra4x4 =
mb->intra4x4_pred_mode_mb;
1698 const uint8_t lo = is_vp7 ? 128 : 127;
1699 const uint8_t hi = is_vp7 ? 128 : 129;
1700 uint8_t tr_top[4] = { lo, lo, lo, lo };
1704 uint8_t *tr_right = ptr -
s->linesize + 16;
1708 if (mb_y && mb_x ==
s->mb_width - 1) {
1709 tr = tr_right[-1] * 0x01010101u;
1716 for (y = 0; y < 4; y++) {
1717 uint8_t *topright = ptr + 4 -
s->linesize;
1718 for (x = 0; x < 4; x++) {
1720 ptrdiff_t linesize =
s->linesize;
1724 if ((y == 0 || x == 3) && mb_y == 0) {
1727 topright = tr_right;
1730 mb_y + y, &
copy, is_vp7);
1732 dst = copy_dst + 12;
1736 AV_WN32A(copy_dst + 4, lo * 0x01010101U);
1738 AV_COPY32(copy_dst + 4, ptr + 4 * x -
s->linesize);
1742 copy_dst[3] = ptr[4 * x -
s->linesize - 1];
1751 copy_dst[11] = ptr[4 * x - 1];
1752 copy_dst[19] = ptr[4 * x +
s->linesize - 1];
1753 copy_dst[27] = ptr[4 * x +
s->linesize * 2 - 1];
1754 copy_dst[35] = ptr[4 * x +
s->linesize * 3 - 1];
1757 s->hpc.pred4x4[
mode](dst, topright, linesize);
1760 AV_COPY32(ptr + 4 * x +
s->linesize, copy_dst + 20);
1761 AV_COPY32(ptr + 4 * x +
s->linesize * 2, copy_dst + 28);
1762 AV_COPY32(ptr + 4 * x +
s->linesize * 3, copy_dst + 36);
1765 nnz =
td->non_zero_count_cache[y][x];
1768 s->vp8dsp.vp8_idct_dc_add(ptr + 4 * x,
1769 td->block[y][x],
s->linesize);
1771 s->vp8dsp.vp8_idct_add(ptr + 4 * x,
1772 td->block[y][x],
s->linesize);
1777 ptr += 4 *
s->linesize;
1783 mb_x, mb_y, is_vp7);
1784 s->hpc.pred8x8[
mode](dst[1],
s->uvlinesize);
1785 s->hpc.pred8x8[
mode](dst[2],
s->uvlinesize);
1787 if (mb_y && (
s->deblock_filter || !mb_y) &&
td->thread_nr == 0)
1789 s->linesize,
s->uvlinesize, mb_x, mb_y,
s->mb_width,
1790 s->filter.simple, 0);
1794 { 0, 1, 2, 1, 2, 1, 2, 1 },
1796 { 0, 3, 5, 3, 5, 3, 5, 3 },
1797 { 0, 2, 3, 2, 3, 2, 3, 2 },
1819 int x_off,
int y_off,
int block_w,
int block_h,
1826 ptrdiff_t src_linesize = linesize;
1831 x_off +=
mv->x >> 2;
1832 y_off +=
mv->y >> 2;
1836 src += y_off * linesize + x_off;
1839 s->vdsp.emulated_edge_mc(
td->edge_emu_buffer,
1840 src - my_idx * linesize - mx_idx,
1844 x_off - mx_idx, y_off - my_idx,
1849 mc_func[my_idx][mx_idx](dst, linesize,
src, src_linesize, block_h, mx, my);
1852 mc_func[0][0](dst, linesize,
src + y_off * linesize + x_off,
1853 linesize, block_h, 0, 0);
1877 int x_off,
int y_off,
int block_w,
int block_h,
1887 x_off +=
mv->x >> 3;
1888 y_off +=
mv->y >> 3;
1891 src1 += y_off * linesize + x_off;
1892 src2 += y_off * linesize + x_off;
1896 s->vdsp.emulated_edge_mc(
td->edge_emu_buffer,
1897 src1 - my_idx * linesize - mx_idx,
1905 s->vdsp.emulated_edge_mc(
td->edge_emu_buffer,
1906 src2 - my_idx * linesize - mx_idx,
1912 mc_func[my_idx][mx_idx](dst2, linesize, src2,
EDGE_EMU_LINESIZE, block_h, mx, my);
1914 mc_func[my_idx][mx_idx](dst1, linesize,
src1, linesize, block_h, mx, my);
1915 mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
1919 mc_func[0][0](dst1, linesize,
src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1920 mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1927 int bx_off,
int by_off,
int block_w,
int block_h,
1934 ref_frame,
mv, x_off + bx_off, y_off + by_off,
1936 s->put_pixels_tab[block_w == 8]);
1939 if (
s->profile == 3) {
1954 dst[2] + by_off *
s->uvlinesize + bx_off, ref_frame,
1955 &uvmv, x_off + bx_off, y_off + by_off,
1957 s->put_pixels_tab[1 + (block_w == 4)]);
1967 if (
s->ref_count[
ref - 1] > (mb_xy >> 5)) {
1968 int x_off = mb_x << 4, y_off = mb_y << 4;
1969 int mx = (
mb->mv.x >> 2) + x_off + 8;
1970 int my = (
mb->mv.y >> 2) + y_off;
1972 int off = mx + (my + (mb_x & 3) * 4) *
s->linesize + 64;
1976 s->vdsp.prefetch(
src[0] + off,
s->linesize, 4);
1977 off = (mx >> 1) + ((my >> 1) + (mb_x & 7)) *
s->uvlinesize + 64;
1978 s->vdsp.prefetch(
src[1] + off,
src[2] -
src[1], 2);
1989 int x_off = mb_x << 4, y_off = mb_y << 4;
1994 switch (
mb->partitioning) {
2004 for (y = 0; y < 4; y++) {
2005 for (x = 0; x < 4; x++) {
2007 ref, &bmv[4 * y + x],
2008 4 * x + x_off, 4 * y + y_off, 4, 4,
2010 s->put_pixels_tab[2]);
2019 for (y = 0; y < 2; y++) {
2020 for (x = 0; x < 2; x++) {
2021 uvmv.
x =
mb->bmv[2 * y * 4 + 2 * x ].x +
2022 mb->bmv[2 * y * 4 + 2 * x + 1].x +
2023 mb->bmv[(2 * y + 1) * 4 + 2 * x ].x +
2024 mb->bmv[(2 * y + 1) * 4 + 2 * x + 1].x;
2025 uvmv.
y =
mb->bmv[2 * y * 4 + 2 * x ].y +
2026 mb->bmv[2 * y * 4 + 2 * x + 1].y +
2027 mb->bmv[(2 * y + 1) * 4 + 2 * x ].y +
2028 mb->bmv[(2 * y + 1) * 4 + 2 * x + 1].y;
2031 if (
s->profile == 3) {
2036 dst[2] + 4 * y *
s->uvlinesize + x * 4,
ref,
2037 &uvmv, 4 * x + x_off, 4 * y + y_off, 4, 4,
2039 s->put_pixels_tab[2]);
2076 for (y = 0; y < 4; y++) {
2077 uint32_t nnz4 =
AV_RL32(
td->non_zero_count_cache[y]);
2079 if (nnz4 & ~0x01010101) {
2080 for (x = 0; x < 4; x++) {
2082 s->vp8dsp.vp8_idct_dc_add(y_dst + 4 * x,
2086 s->vp8dsp.vp8_idct_add(y_dst + 4 * x,
2094 s->vp8dsp.vp8_idct_dc_add4y(y_dst,
td->block[y],
s->linesize);
2097 y_dst += 4 *
s->linesize;
2101 for (ch = 0; ch < 2; ch++) {
2102 uint32_t nnz4 =
AV_RL32(
td->non_zero_count_cache[4 + ch]);
2104 uint8_t *ch_dst = dst[1 + ch];
2105 if (nnz4 & ~0x01010101) {
2106 for (y = 0; y < 2; y++) {
2107 for (x = 0; x < 2; x++) {
2109 s->vp8dsp.vp8_idct_dc_add(ch_dst + 4 * x,
2110 td->block[4 + ch][(y << 1) + x],
2113 s->vp8dsp.vp8_idct_add(ch_dst + 4 * x,
2114 td->block[4 + ch][(y << 1) + x],
2118 goto chroma_idct_end;
2120 ch_dst += 4 *
s->uvlinesize;
2123 s->vp8dsp.vp8_idct_dc_add4uv(ch_dst,
td->block[4 + ch],
s->uvlinesize);
2135 int interior_limit, filter_level;
2137 if (
s->segmentation.enabled) {
2138 filter_level =
s->segmentation.filter_level[
mb->segment];
2139 if (!
s->segmentation.absolute_vals)
2140 filter_level +=
s->filter.level;
2142 filter_level =
s->filter.level;
2144 if (
s->lf_delta.enabled) {
2145 filter_level +=
s->lf_delta.ref[
mb->ref_frame];
2146 filter_level +=
s->lf_delta.mode[
mb->mode];
2151 interior_limit = filter_level;
2152 if (
s->filter.sharpness) {
2153 interior_limit >>= (
s->filter.sharpness + 3) >> 2;
2154 interior_limit =
FFMIN(interior_limit, 9 -
s->filter.sharpness);
2156 interior_limit =
FFMAX(interior_limit, 1);
2158 f->filter_level = filter_level;
2159 f->inner_limit = interior_limit;
2160 f->inner_filter = is_vp7 || !
mb->skip ||
mb->mode ==
MODE_I4x4 ||
2166 int mb_x,
int mb_y,
int is_vp7)
2168 int mbedge_lim, bedge_lim_y, bedge_lim_uv, hev_thresh;
2169 int filter_level =
f->filter_level;
2170 int inner_limit =
f->inner_limit;
2171 int inner_filter =
f->inner_filter;
2172 ptrdiff_t linesize =
s->linesize;
2173 ptrdiff_t uvlinesize =
s->uvlinesize;
2174 static const uint8_t hev_thresh_lut[2][64] = {
2175 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2177 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2179 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2180 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2189 bedge_lim_y = filter_level;
2190 bedge_lim_uv = filter_level * 2;
2191 mbedge_lim = filter_level + 2;
2194 bedge_lim_uv = filter_level * 2 + inner_limit;
2195 mbedge_lim = bedge_lim_y + 4;
2198 hev_thresh = hev_thresh_lut[
s->keyframe][filter_level];
2201 s->vp8dsp.vp8_h_loop_filter16y(dst[0], linesize,
2202 mbedge_lim, inner_limit, hev_thresh);
2203 s->vp8dsp.vp8_h_loop_filter8uv(dst[1], dst[2], uvlinesize,
2204 mbedge_lim, inner_limit, hev_thresh);
2207 #define H_LOOP_FILTER_16Y_INNER(cond) \
2208 if (cond && inner_filter) { \
2209 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 4, linesize, \
2210 bedge_lim_y, inner_limit, \
2212 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 8, linesize, \
2213 bedge_lim_y, inner_limit, \
2215 s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0] + 12, linesize, \
2216 bedge_lim_y, inner_limit, \
2218 s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4, \
2219 uvlinesize, bedge_lim_uv, \
2220 inner_limit, hev_thresh); \
2226 s->vp8dsp.vp8_v_loop_filter16y(dst[0], linesize,
2227 mbedge_lim, inner_limit, hev_thresh);
2228 s->vp8dsp.vp8_v_loop_filter8uv(dst[1], dst[2], uvlinesize,
2229 mbedge_lim, inner_limit, hev_thresh);
2233 s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 4 * linesize,
2234 linesize, bedge_lim_y,
2235 inner_limit, hev_thresh);
2236 s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 8 * linesize,
2237 linesize, bedge_lim_y,
2238 inner_limit, hev_thresh);
2239 s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0] + 12 * linesize,
2240 linesize, bedge_lim_y,
2241 inner_limit, hev_thresh);
2242 s->vp8dsp.vp8_v_loop_filter8uv_inner(dst[1] + 4 * uvlinesize,
2243 dst[2] + 4 * uvlinesize,
2244 uvlinesize, bedge_lim_uv,
2245 inner_limit, hev_thresh);
2255 int mbedge_lim, bedge_lim;
2256 int filter_level =
f->filter_level;
2257 int inner_limit =
f->inner_limit;
2258 int inner_filter =
f->inner_filter;
2259 ptrdiff_t linesize =
s->linesize;
2264 bedge_lim = 2 * filter_level + inner_limit;
2265 mbedge_lim = bedge_lim + 4;
2268 s->vp8dsp.vp8_h_loop_filter_simple(dst, linesize, mbedge_lim);
2270 s->vp8dsp.vp8_h_loop_filter_simple(dst + 4, linesize, bedge_lim);
2271 s->vp8dsp.vp8_h_loop_filter_simple(dst + 8, linesize, bedge_lim);
2272 s->vp8dsp.vp8_h_loop_filter_simple(dst + 12, linesize, bedge_lim);
2276 s->vp8dsp.vp8_v_loop_filter_simple(dst, linesize, mbedge_lim);
2278 s->vp8dsp.vp8_v_loop_filter_simple(dst + 4 * linesize, linesize, bedge_lim);
2279 s->vp8dsp.vp8_v_loop_filter_simple(dst + 8 * linesize, linesize, bedge_lim);
2280 s->vp8dsp.vp8_v_loop_filter_simple(dst + 12 * linesize, linesize, bedge_lim);
2284 #define MARGIN (16 << 2)
2292 s->mv_bounds.mv_min.y = -
MARGIN;
2293 s->mv_bounds.mv_max.y = ((
s->mb_height - 1) << 6) +
MARGIN;
2294 for (mb_y = 0; mb_y <
s->mb_height; mb_y++) {
2296 ((
s->mb_width + 1) * (mb_y + 1) + 1);
2297 int mb_xy = mb_y *
s->mb_width;
2301 s->mv_bounds.mv_min.x = -
MARGIN;
2302 s->mv_bounds.mv_max.x = ((
s->mb_width - 1) << 6) +
MARGIN;
2304 for (mb_x = 0; mb_x <
s->mb_width; mb_x++, mb_xy++,
mb++) {
2309 AV_WN32A((
mb -
s->mb_width - 1)->intra4x4_pred_mode_top,
2312 prev_frame && prev_frame->
seg_map ?
2314 s->mv_bounds.mv_min.x -= 64;
2315 s->mv_bounds.mv_max.x -= 64;
2317 s->mv_bounds.mv_min.y -= 64;
2318 s->mv_bounds.mv_max.y -= 64;
2336 #define check_thread_pos(td, otd, mb_x_check, mb_y_check) \
2338 int tmp = (mb_y_check << 16) | (mb_x_check & 0xFFFF); \
2339 if (atomic_load(&otd->thread_mb_pos) < tmp) { \
2340 pthread_mutex_lock(&otd->lock); \
2341 atomic_store(&td->wait_mb_pos, tmp); \
2343 if (atomic_load(&otd->thread_mb_pos) >= tmp) \
2345 pthread_cond_wait(&otd->cond, &otd->lock); \
2347 atomic_store(&td->wait_mb_pos, INT_MAX); \
2348 pthread_mutex_unlock(&otd->lock); \
2352 #define update_pos(td, mb_y, mb_x) \
2354 int pos = (mb_y << 16) | (mb_x & 0xFFFF); \
2355 int sliced_threading = (avctx->active_thread_type == FF_THREAD_SLICE) && \
2357 int is_null = !next_td || !prev_td; \
2358 int pos_check = (is_null) ? 1 : \
2359 (next_td != td && pos >= atomic_load(&next_td->wait_mb_pos)) || \
2360 (prev_td != td && pos >= atomic_load(&prev_td->wait_mb_pos)); \
2361 atomic_store(&td->thread_mb_pos, pos); \
2362 if (sliced_threading && pos_check) { \
2363 pthread_mutex_lock(&td->lock); \
2364 pthread_cond_broadcast(&td->cond); \
2365 pthread_mutex_unlock(&td->lock); \
2369 #define check_thread_pos(td, otd, mb_x_check, mb_y_check) while(0)
2370 #define update_pos(td, mb_y, mb_x) while(0)
2374 int jobnr,
int threadnr,
int is_vp7)
2379 int mb_x, mb_xy = mb_y *
s->mb_width;
2380 int num_jobs =
s->num_jobs;
2381 VP8Frame *curframe =
s->curframe, *prev_frame =
s->prev_frame;
2385 curframe->
tf.
f->
data[0] + 16 * mb_y *
s->linesize,
2386 curframe->
tf.
f->
data[1] + 8 * mb_y *
s->uvlinesize,
2387 curframe->
tf.
f->
data[2] + 8 * mb_y *
s->uvlinesize
2396 prev_td = &
s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
2397 if (mb_y ==
s->mb_height - 1)
2400 next_td = &
s->thread_data[(jobnr + 1) % num_jobs];
2401 if (
s->mb_layout == 1)
2402 mb =
s->macroblocks_base + ((
s->mb_width + 1) * (mb_y + 1) + 1);
2406 if (prev_frame &&
s->segmentation.enabled &&
2407 !
s->segmentation.update_map)
2409 mb =
s->macroblocks + (
s->mb_height - mb_y - 1) * 2;
2410 memset(
mb - 1, 0,
sizeof(*
mb));
2414 if (!is_vp7 || mb_y == 0)
2415 memset(
td->left_nnz, 0,
sizeof(
td->left_nnz));
2418 td->mv_bounds.mv_max.x = ((
s->mb_width - 1) << 6) +
MARGIN;
2420 for (mb_x = 0; mb_x <
s->mb_width; mb_x++, mb_xy++,
mb++) {
2424 if (prev_td !=
td) {
2425 if (threadnr != 0) {
2427 mb_x + (is_vp7 ? 2 : 1),
2428 mb_y - (is_vp7 ? 2 : 1));
2431 mb_x + (is_vp7 ? 2 : 1) +
s->mb_width + 3,
2432 mb_y - (is_vp7 ? 2 : 1));
2436 s->vdsp.prefetch(dst[0] + (mb_x & 3) * 4 *
s->linesize + 64,
2438 s->vdsp.prefetch(dst[1] + (mb_x & 7) *
s->uvlinesize + 64,
2439 dst[2] - dst[1], 2);
2443 prev_frame && prev_frame->seg_map ?
2444 prev_frame->seg_map->data + mb_xy :
NULL, 0, is_vp7);
2467 td->left_nnz[8] = 0;
2468 s->top_nnz[mb_x][8] = 0;
2472 if (
s->deblock_filter)
2475 if (
s->deblock_filter && num_jobs != 1 && threadnr == num_jobs - 1) {
2476 if (
s->filter.simple)
2481 dst[1], dst[2],
s->linesize,
s->uvlinesize, 0);
2489 td->mv_bounds.mv_min.x -= 64;
2490 td->mv_bounds.mv_max.x -= 64;
2492 if (mb_x ==
s->mb_width + 1) {
2502 int jobnr,
int threadnr)
2508 int jobnr,
int threadnr)
2514 int jobnr,
int threadnr,
int is_vp7)
2518 int mb_x, mb_y =
atomic_load(&
td->thread_mb_pos) >> 16, num_jobs =
s->num_jobs;
2519 AVFrame *curframe =
s->curframe->tf.f;
2523 curframe->
data[0] + 16 * mb_y *
s->linesize,
2524 curframe->
data[1] + 8 * mb_y *
s->uvlinesize,
2525 curframe->
data[2] + 8 * mb_y *
s->uvlinesize
2528 if (
s->mb_layout == 1)
2529 mb =
s->macroblocks_base + ((
s->mb_width + 1) * (mb_y + 1) + 1);
2531 mb =
s->macroblocks + (
s->mb_height - mb_y - 1) * 2;
2536 prev_td = &
s->thread_data[(jobnr + num_jobs - 1) % num_jobs];
2537 if (mb_y ==
s->mb_height - 1)
2540 next_td = &
s->thread_data[(jobnr + 1) % num_jobs];
2542 for (mb_x = 0; mb_x <
s->mb_width; mb_x++,
mb++) {
2546 (mb_x + 1) + (
s->mb_width + 3), mb_y - 1);
2548 if (next_td != &
s->thread_data[0])
2551 if (num_jobs == 1) {
2552 if (
s->filter.simple)
2557 dst[1], dst[2],
s->linesize,
s->uvlinesize, 0);
2560 if (
s->filter.simple)
2573 int jobnr,
int threadnr)
2579 int jobnr,
int threadnr)
2586 int threadnr,
int is_vp7)
2592 int mb_y, num_jobs =
s->num_jobs;
2595 td->thread_nr = threadnr;
2596 td->mv_bounds.mv_min.y = -
MARGIN - 64 * threadnr;
2597 td->mv_bounds.mv_max.y = ((
s->mb_height - 1) << 6) +
MARGIN - 64 * threadnr;
2598 for (mb_y = jobnr; mb_y <
s->mb_height; mb_y += num_jobs) {
2600 ret =
s->decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr);
2605 if (
s->deblock_filter)
2606 s->filter_mb_row(avctx, tdata, jobnr, threadnr);
2609 td->mv_bounds.mv_min.y -= 64 * num_jobs;
2610 td->mv_bounds.mv_max.y -= 64 * num_jobs;
2620 int jobnr,
int threadnr)
2626 int jobnr,
int threadnr)
2636 int ret,
i, referenced, num_jobs;
2648 if (
s->actually_webp) {
2652 if (
s->pix_fmt < 0) {
2670 memcpy(&
s->next_framep[0], &
s->framep[0],
sizeof(
s->framep[0]) * 4);
2676 for (
i = 0;
i < 5;
i++)
2677 if (
s->frames[
i].tf.f->buf[0] &&
2678 &
s->frames[
i] != prev_frame &&
2701 "Discarding interframe without a prior keyframe!\n");
2706 curframe->tf.f->key_frame =
s->keyframe;
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);
2824 #if CONFIG_VP7_DECODER
2852 if (!
s->frames[
i].tf.f)
2895 #if CONFIG_VP7_DECODER
2907 #if CONFIG_VP8_DECODER
2909 #define REBASE(pic) ((pic) ? (pic) - &s_src->frames[0] + &s->frames[0] : NULL)
2917 if (
s->macroblocks_base &&
2918 (s_src->mb_width !=
s->mb_width || s_src->mb_height !=
s->mb_height)) {
2920 s->mb_width = s_src->mb_width;
2921 s->mb_height = s_src->mb_height;
2924 s->pix_fmt = s_src->pix_fmt;
2925 s->prob[0] = s_src->prob[!s_src->update_probabilities];
2926 s->segmentation = s_src->segmentation;
2927 s->lf_delta = s_src->lf_delta;
2928 memcpy(
s->sign_bias, s_src->sign_bias,
sizeof(
s->sign_bias));
2931 if (s_src->frames[
i].tf.f->buf[0]) {
2932 int ret = vp8_ref_frame(
s, &
s->frames[
i], &s_src->frames[
i]);
2938 s->framep[0] = REBASE(s_src->next_framep[0]);
2939 s->framep[1] = REBASE(s_src->next_framep[1]);
2940 s->framep[2] = REBASE(s_src->next_framep[2]);
2941 s->framep[3] = REBASE(s_src->next_framep[3]);
2948 #if CONFIG_VP7_DECODER
2955 .
init = vp7_decode_init,
2957 .
decode = vp7_decode_frame,
2963 #if CONFIG_VP8_DECODER
2978 #if CONFIG_VP8_VAAPI_HWACCEL
2981 #if CONFIG_VP8_NVDEC_HWACCEL
static void flush(AVCodecContext *avctx)
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
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 av_cold int init(AVCodecContext *avctx)
#define bit(string, value)
#define prob(name, subs,...)
#define FFSWAP(type, a, b)
#define CONFIG_VP7_DECODER
#define CONFIG_VP8_DECODER
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define atomic_store(object, desired)
#define atomic_load(object)
#define atomic_init(obj, value)
mode
Use these values in ebur128_init (or'ed).
#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
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_allocz(buffer_size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#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.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
#define HOR_VP8_PRED
unaveraged version of HOR_PRED, see
#define VERT_VP8_PRED
for VP8, VERT_PRED is the average of
#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.
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
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.
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
static enum AVPixelFormat pix_fmts[]
const uint8_t ff_zigzag_scan[16+1]
#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.
@ 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_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
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 ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
useful rectangle filling function
#define FF_ARRAY_ELEMS(a)
static const SiprModeParam modes[MODE_COUNT]
static const float pred[4]
uint8_t * data
The data buffer.
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.
const struct AVCodec * codec
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.
int(* update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src)
Copy necessary context variables from a previous thread context to the current one.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
This structure stores compressed data.
AVBufferRef * hwaccel_priv_buf
void * hwaccel_picture_private
uint8_t intra4x4_pred_mode_top[4]
#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)
int ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob)
static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
static av_always_inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t(*tree)[2], const uint8_t *probs)
#define vp56_rac_get_prob
static av_always_inline int vp8_rac_get(VP56RangeCoder *c)
static av_always_inline int vpX_rac_is_end(VP56RangeCoder *c)
vp5689 returns 1 if the end of the stream has been reached, 0 otherwise.
static av_unused int vp8_rac_get_nn(VP56RangeCoder *c)
static int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
static void vp8_decode_flush_impl(AVCodecContext *avctx, int free_mem)
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 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 void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f, int is_vp7)
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])
static av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3], VP8Macroblock *mb)
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 int vp7_read_mv_component(VP56RangeCoder *c, const uint8_t *p)
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 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 vp7_update_dimensions(VP8Context *s, int width, int height)
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 int vp8_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static void vp78_update_pred16x16_pred8x8_mvc_probabilities(VP8Context *s, int mvc_size)
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 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 int vp7_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
av_cold int ff_vp8_decode_init(AVCodecContext *avctx)
static av_always_inline void vp8_decode_mvs(VP8Context *s, VP8mvbounds *mv_bounds, VP8Macroblock *mb, int mb_x, int mb_y, int layout)
static const VP56mv * get_bmv_ptr(const VP8Macroblock *mb, int subblock)
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 void vp8_release_frame(VP8Context *s, VP8Frame *f)
static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
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_cold int vp8_init_frames(VP8Context *s)
static av_always_inline void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f, int mb_x, int mb_y)
static av_always_inline int vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe, 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 int vp78_decode_init(AVCodecContext *avctx, int is_vp7)
static void vp7_filter_mb_row(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static void vp8_get_quants(VP8Context *s)
static av_always_inline void prefetch_motion(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int mb_xy, int ref)
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 read_mv_component(VP56RangeCoder *c, const uint8_t *p, int vp7)
Motion vector coding, 17.1.
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.
static int vp8_update_dimensions(VP8Context *s, int width, int height)
#define check_thread_pos(td, otd, mb_x_check, mb_y_check)
static VP8Frame * vp8_find_free_buffer(VP8Context *s)
static int vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame)
static int vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame, VP8Frame *prev_frame)
static av_always_inline int inter_predict_dc(int16_t block[16], int16_t pred[2])
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 copy_chroma(AVFrame *dst, AVFrame *src, int width, int height)
static av_always_inline int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y, int vp7)
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
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 filter_mb(VP8Context *s, uint8_t *dst[3], VP8FilterStrength *f, int mb_x, int mb_y, int is_vp7)
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 av_always_inline int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y, int vp7)
static void update_refs(VP8Context *s)
static av_always_inline void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, int mb_x, int keyframe, int layout)
static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
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 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 void vp78_reset_probability_tables(VP8Context *s)
static enum AVPixelFormat get_pixel_format(VP8Context *s)
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 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 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)
static void free_buffers(VP8Context *s)
static int vp7_decode_mb_row_no_filter(AVCodecContext *avctx, void *tdata, int jobnr, int threadnr)
static void parse_segment_info(VP8Context *s)
static av_always_inline void clamp_mv(VP8mvbounds *s, VP56mv *dst, const VP56mv *src)
static av_always_inline const uint8_t * get_submv_prob(uint32_t left, uint32_t top, int is_vp7)
int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int vp8_read_mv_component(VP56RangeCoder *c, const uint8_t *p)
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 VP56Frame ref_to_update(VP8Context *s, int update, VP56Frame ref)
Determine which buffers golden and altref should be updated with after this frame.
static av_always_inline int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, const AVPacket *avpkt, int is_vp7)
#define update_pos(td, mb_y, mb_x)
static void vp8_decode_flush(AVCodecContext *avctx)
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
@ 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)
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[]
const uint8_t *const ff_vp8_dct_cat_prob[]
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_token_update_probs[4][8][3][NUM_DCT_TOKENS - 1]
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 ff_vp7dsp_init(VP8DSPContext *c)
void ff_vp8dsp_init(VP8DSPContext *c)
void(* vp8_mc_func)(uint8_t *dst, ptrdiff_t dstStride, uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)