24#include "config_components.h"
51#define VP9_SYNCCODE 0x498342
72static void vp9_report_tile_progress(
VP9Context *
s,
int field,
int n) {
79static void vp9_await_tile_progress(
VP9Context *
s,
int field,
int n) {
105 f->segmentation_map =
NULL;
117 if (!avctx->
hwaccel &&
f->tf.f->linesize[1] !=
f->tf.f->linesize[2]) {
123 sz = 64 *
s->sb_cols *
s->sb_rows;
124 if (sz !=
s->frame_extradata_pool_size) {
128 if (!
s->frame_extradata_pool) {
129 s->frame_extradata_pool_size = 0;
133 s->frame_extradata_pool_size = sz;
141 f->segmentation_map =
f->extradata;
158 dst->frame_header =
src->frame_header;
161 src->hwaccel_picture_private);
166 dst->segmentation_map =
src->segmentation_map;
168 dst->uses_2pass =
src->uses_2pass;
173#define HWACCEL_MAX (CONFIG_VP9_DXVA2_HWACCEL + \
174 CONFIG_VP9_D3D11VA_HWACCEL * 2 + \
175 CONFIG_VP9_D3D12VA_HWACCEL + \
176 CONFIG_VP9_NVDEC_HWACCEL + \
177 CONFIG_VP9_NVDEC_CUARRAY_HWACCEL + \
178 CONFIG_VP9_VAAPI_HWACCEL + \
179 CONFIG_VP9_VDPAU_HWACCEL + \
180 CONFIG_VP9_VIDEOTOOLBOX_HWACCEL + \
181 CONFIG_VP9_VULKAN_HWACCEL)
185 int bytesperpixel =
s->bytesperpixel,
ret, cols, rows;
191 if (!(
s->pix_fmt ==
s->gf_fmt &&
w ==
s->w &&
h ==
s->h)) {
196 switch (
s->pix_fmt) {
199#if CONFIG_VP9_DXVA2_HWACCEL
202#if CONFIG_VP9_D3D11VA_HWACCEL
206#if CONFIG_VP9_D3D12VA_HWACCEL
209#if CONFIG_VP9_NVDEC_HWACCEL
212#if CONFIG_VP9_NVDEC_CUARRAY_HWACCEL
215#if CONFIG_VP9_VAAPI_HWACCEL
218#if CONFIG_VP9_VDPAU_HWACCEL
221#if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL
224#if CONFIG_VP9_VULKAN_HWACCEL
229#if CONFIG_VP9_NVDEC_HWACCEL
232#if CONFIG_VP9_NVDEC_CUARRAY_HWACCEL
235#if CONFIG_VP9_VAAPI_HWACCEL
238#if CONFIG_VP9_VDPAU_HWACCEL
241#if CONFIG_VP9_VULKAN_HWACCEL
248#if CONFIG_VP9_VAAPI_HWACCEL
251#if CONFIG_VP9_VULKAN_HWACCEL
258#if CONFIG_VP9_VAAPI_HWACCEL
261#if CONFIG_VP9_VULKAN_HWACCEL
267 *fmtp++ =
s->pix_fmt;
277 s->gf_fmt =
s->pix_fmt;
285 if (
s->intra_pred_data[0] && cols ==
s->cols && rows ==
s->rows &&
s->pix_fmt ==
s->last_fmt)
288 s->last_fmt =
s->pix_fmt;
289 s->sb_cols = (
w + 63) >> 6;
290 s->sb_rows = (
h + 63) >> 6;
291 s->cols = (
w + 7) >> 3;
292 s->rows = (
h + 7) >> 3;
295#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)
299 p =
av_malloc(
s->sb_cols * (128 + 192 * bytesperpixel +
300 lflvl_len *
sizeof(*
s->lflvl) + 16 *
sizeof(*
s->above_mv_ctx)));
303 assign(
s->intra_pred_data[0], uint8_t *, 64 * bytesperpixel);
304 assign(
s->intra_pred_data[1], uint8_t *, 64 * bytesperpixel);
305 assign(
s->intra_pred_data[2], uint8_t *, 64 * bytesperpixel);
306 assign(
s->above_y_nnz_ctx, uint8_t *, 16);
307 assign(
s->above_mode_ctx, uint8_t *, 16);
309 assign(
s->above_uv_nnz_ctx[0], uint8_t *, 16);
310 assign(
s->above_uv_nnz_ctx[1], uint8_t *, 16);
311 assign(
s->above_partition_ctx, uint8_t *, 8);
312 assign(
s->above_skip_ctx, uint8_t *, 8);
313 assign(
s->above_txfm_ctx, uint8_t *, 8);
314 assign(
s->above_segpred_ctx, uint8_t *, 8);
315 assign(
s->above_intra_ctx, uint8_t *, 8);
316 assign(
s->above_comp_ctx, uint8_t *, 8);
317 assign(
s->above_ref_ctx, uint8_t *, 8);
318 assign(
s->above_filter_ctx, uint8_t *, 8);
323 for (
i = 0;
i <
s->active_tile_cols;
i++)
327 if (
s->s.h.bpp !=
s->last_bpp) {
330 s->last_bpp =
s->s.h.bpp;
341 int chroma_blocks, chroma_eobs, bytesperpixel =
s->bytesperpixel;
348 chroma_blocks = 64 * 64 >> (
s->ss_h +
s->ss_v);
349 chroma_eobs = 16 * 16 >> (
s->ss_h +
s->ss_v);
351 int sbs =
s->sb_cols *
s->sb_rows;
355 16 * 16 + 2 * chroma_eobs) * sbs);
370 for (
i = 1;
i <
s->active_tile_cols;
i++)
373 for (
i = 0;
i <
s->active_tile_cols;
i++) {
375 s->td[
i].block_base =
av_mallocz((64 * 64 + 2 * chroma_blocks) * bytesperpixel *
sizeof(int16_t) +
376 16 * 16 + 2 * chroma_eobs);
377 if (!
s->td[
i].b_base || !
s->td[
i].block_base)
379 s->td[
i].uvblock_base[0] =
s->td[
i].block_base + 64 * 64 * bytesperpixel;
380 s->td[
i].uvblock_base[1] =
s->td[
i].uvblock_base[0] + chroma_blocks * bytesperpixel;
381 s->td[
i].eob_base = (uint8_t *) (
s->td[
i].uvblock_base[1] + chroma_blocks * bytesperpixel);
382 s->td[
i].uveob_base[0] =
s->td[
i].eob_base + 16 * 16;
383 s->td[
i].uveob_base[1] =
s->td[
i].uveob_base[0] + chroma_eobs;
387 if (!
s->td[
i].block_structure)
392 s->block_alloc_using_2pass =
s->s.frames[
CUR_FRAME].uses_2pass;
409 return m - ((v + 1) >> 1);
416 static const uint8_t inv_map_table[255] = {
417 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
418 189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
419 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
420 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
421 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
422 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
423 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
424 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
425 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
426 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
427 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
428 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
429 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
430 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
431 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
432 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
433 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
434 237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
482 s->s.h.bpp = 8 +
bits * 2;
483 s->bytesperpixel = (7 +
s->s.h.bpp) >> 3;
489 s->ss_h =
s->ss_v = 0;
503 static const enum AVPixelFormat pix_fmt_for_ss[3][2 ][2 ] = {
515 s->pix_fmt = pix_fmt_for_ss[
bits][
s->ss_v][
s->ss_h];
526 s->ss_h =
s->ss_v = 1;
527 s->pix_fmt = pix_fmt_for_ss[
bits][1][1];
538 int c,
i, j, k, l, m, n,
w,
h,
max, size2,
ret, sharp;
540 const uint8_t *data2;
565 s->last_keyframe =
s->s.h.keyframe;
568 last_invisible =
s->s.h.invisible;
571 s->s.h.use_last_frame_mvs = !
s->s.h.errorres && !last_invisible;
573 if (
s->s.h.keyframe) {
581 s->s.h.refreshrefmask = 0xff;
587 s->s.h.intraonly =
s->s.h.invisible ?
get_bits1(&
s->gb) : 0;
588 s->s.h.resetctx =
s->s.h.errorres ? 0 :
get_bits(&
s->gb, 2);
589 if (
s->s.h.intraonly) {
598 s->ss_h =
s->ss_v = 1;
601 s->bytesperpixel = 1;
614 s->s.h.signbias[0] =
get_bits1(&
s->gb) && !
s->s.h.errorres;
616 s->s.h.signbias[1] =
get_bits1(&
s->gb) && !
s->s.h.errorres;
618 s->s.h.signbias[2] =
get_bits1(&
s->gb) && !
s->s.h.errorres;
619 if (!
s->s.refs[
s->s.h.refidx[0]].f ||
620 !
s->s.refs[
s->s.h.refidx[1]].f ||
621 !
s->s.refs[
s->s.h.refidx[2]].f) {
626 w =
s->s.refs[
s->s.h.refidx[0]].f->width;
627 h =
s->s.refs[
s->s.h.refidx[0]].f->height;
629 w =
s->s.refs[
s->s.h.refidx[1]].f->width;
630 h =
s->s.refs[
s->s.h.refidx[1]].f->height;
632 w =
s->s.refs[
s->s.h.refidx[2]].f->width;
633 h =
s->s.refs[
s->s.h.refidx[2]].f->height;
641 s->s.h.use_last_frame_mvs &=
s->s.frames[
CUR_FRAME].tf.f &&
649 s->s.h.allowcompinter =
s->s.h.signbias[0] !=
s->s.h.signbias[1] ||
650 s->s.h.signbias[0] !=
s->s.h.signbias[2];
651 if (
s->s.h.allowcompinter) {
652 if (
s->s.h.signbias[0] ==
s->s.h.signbias[1]) {
653 s->s.h.fixcompref = 2;
654 s->s.h.varcompref[0] = 0;
655 s->s.h.varcompref[1] = 1;
656 }
else if (
s->s.h.signbias[0] ==
s->s.h.signbias[2]) {
657 s->s.h.fixcompref = 1;
658 s->s.h.varcompref[0] = 0;
659 s->s.h.varcompref[1] = 2;
661 s->s.h.fixcompref = 0;
662 s->s.h.varcompref[0] = 1;
663 s->s.h.varcompref[1] = 2;
668 s->s.h.refreshctx =
s->s.h.errorres ? 0 :
get_bits1(&
s->gb);
669 s->s.h.parallelmode =
s->s.h.errorres ? 1 :
get_bits1(&
s->gb);
671 if (
s->s.h.keyframe ||
s->s.h.intraonly)
672 s->s.h.framectxid = 0;
675 if (
s->s.h.keyframe ||
s->s.h.errorres ||
s->s.h.intraonly) {
677 s->s.h.lf_delta.ref[0] = 1;
678 s->s.h.lf_delta.ref[1] = 0;
679 s->s.h.lf_delta.ref[2] = -1;
680 s->s.h.lf_delta.ref[3] = -1;
681 s->s.h.lf_delta.mode[0] = 0;
682 s->s.h.lf_delta.mode[1] = 0;
683 memset(
s->s.h.segmentation.feat, 0,
sizeof(
s->s.h.segmentation.feat));
689 if (
s->s.h.filter.sharpness != sharp) {
690 for (
i = 1;
i <= 63;
i++) {
694 limit >>= (sharp + 3) >> 2;
699 s->filter_lut.lim_lut[
i] =
limit;
700 s->filter_lut.mblim_lut[
i] = 2 * (
i + 2) +
limit;
703 s->s.h.filter.sharpness = sharp;
704 if ((
s->s.h.lf_delta.enabled =
get_bits1(&
s->gb))) {
705 if ((
s->s.h.lf_delta.updated =
get_bits1(&
s->gb))) {
706 for (
i = 0;
i < 4;
i++)
709 for (
i = 0;
i < 2;
i++)
720 s->s.h.lossless =
s->s.h.yac_qi == 0 &&
s->s.h.ydc_qdelta == 0 &&
721 s->s.h.uvdc_qdelta == 0 &&
s->s.h.uvac_qdelta == 0;
724 if ((
s->s.h.segmentation.enabled =
get_bits1(&
s->gb))) {
725 if ((
s->s.h.segmentation.update_map =
get_bits1(&
s->gb))) {
726 for (
i = 0;
i < 7;
i++)
729 if ((
s->s.h.segmentation.temporal =
get_bits1(&
s->gb)))
730 for (
i = 0;
i < 3;
i++)
736 s->s.h.segmentation.absolute_vals =
get_bits1(&
s->gb);
737 for (
i = 0;
i < 8;
i++) {
738 if ((
s->s.h.segmentation.feat[
i].q_enabled =
get_bits1(&
s->gb)))
740 if ((
s->s.h.segmentation.feat[
i].lf_enabled =
get_bits1(&
s->gb)))
742 if ((
s->s.h.segmentation.feat[
i].ref_enabled =
get_bits1(&
s->gb)))
743 s->s.h.segmentation.feat[
i].ref_val =
get_bits(&
s->gb, 2);
744 s->s.h.segmentation.feat[
i].skip_enabled =
get_bits1(&
s->gb);
751 s->s.h.segmentation.temporal = 0;
752 s->s.h.segmentation.update_map = 0;
756 for (
i = 0;
i < (
s->s.h.segmentation.enabled ? 8 : 1);
i++) {
757 int qyac, qydc, quvac, quvdc, lflvl, sh;
759 if (
s->s.h.segmentation.enabled &&
s->s.h.segmentation.feat[
i].q_enabled) {
760 if (
s->s.h.segmentation.absolute_vals)
765 qyac =
s->s.h.yac_qi;
777 sh =
s->s.h.filter.level >= 32;
778 if (
s->s.h.segmentation.enabled &&
s->s.h.segmentation.feat[
i].lf_enabled) {
779 if (
s->s.h.segmentation.absolute_vals)
782 lflvl =
av_clip_uintp2(
s->s.h.filter.level +
s->s.h.segmentation.feat[
i].lf_val, 6);
784 lflvl =
s->s.h.filter.level;
786 if (
s->s.h.lf_delta.enabled) {
787 s->s.h.segmentation.feat[
i].lflvl[0][0] =
788 s->s.h.segmentation.feat[
i].lflvl[0][1] =
790 for (j = 1; j < 4; j++) {
791 s->s.h.segmentation.feat[
i].lflvl[j][0] =
793 s->s.h.lf_delta.mode[0]) * (1 << sh)), 6);
794 s->s.h.segmentation.feat[
i].lflvl[j][1] =
796 s->s.h.lf_delta.mode[1]) * (1 << sh)), 6);
799 memset(
s->s.h.segmentation.feat[
i].lflvl, lflvl,
800 sizeof(
s->s.h.segmentation.feat[
i].lflvl));
810 for (
s->s.h.tiling.log2_tile_cols = 0;
811 s->sb_cols > (64 <<
s->s.h.tiling.log2_tile_cols);
812 s->s.h.tiling.log2_tile_cols++) ;
813 for (
max = 0; (
s->sb_cols >>
max) >= 4;
max++) ;
815 while (
max >
s->s.h.tiling.log2_tile_cols) {
817 s->s.h.tiling.log2_tile_cols++;
822 s->s.h.tiling.tile_rows = 1 <<
s->s.h.tiling.log2_tile_rows;
823 if (
s->s.h.tiling.tile_cols != (1 <<
s->s.h.tiling.log2_tile_cols) || changed) {
828 for (
i = 0;
i <
s->active_tile_cols;
i++)
833 s->s.h.tiling.tile_cols = 1 <<
s->s.h.tiling.log2_tile_cols;
835 s->s.h.tiling.tile_cols : 1;
840 n_range_coders =
s->s.h.tiling.tile_cols;
847 for (
i = 0;
i <
s->active_tile_cols;
i++) {
850 rc += n_range_coders;
855 if (!
s->s.h.keyframe && !
s->s.h.intraonly) {
856 int valid_ref_frame = 0;
857 for (
i = 0;
i < 3;
i++) {
859 int refw =
ref->width, refh =
ref->height;
863 "Ref pixfmt (%s) did not match current frame (%s)",
867 }
else if (refw ==
w && refh ==
h) {
868 s->mvscale[
i][0] =
s->mvscale[
i][1] = 0;
872 if (
w * 2 < refw ||
h * 2 < refh ||
w > 16 * refw ||
h > 16 * refh) {
874 "Invalid ref frame dimensions %dx%d for frame size %dx%d\n",
879 s->mvscale[
i][0] = (refw << 14) /
w;
880 s->mvscale[
i][1] = (refh << 14) /
h;
881 s->mvstep[
i][0] = 16 *
s->mvscale[
i][0] >> 14;
882 s->mvstep[
i][1] = 16 *
s->mvscale[
i][1] >> 14;
886 if (!valid_ref_frame) {
887 av_log(avctx,
AV_LOG_ERROR,
"No valid reference frame is found, bitstream not supported\n");
892 if (
s->s.h.keyframe ||
s->s.h.errorres || (
s->s.h.intraonly &&
s->s.h.resetctx == 3)) {
893 s->prob_ctx[0].p =
s->prob_ctx[1].p =
s->prob_ctx[2].p =
903 }
else if (
s->s.h.intraonly &&
s->s.h.resetctx == 2) {
910 s->s.h.compressed_header_size = size2 =
get_bits(&
s->gb, 16);
914 if (size2 >
size - (data2 -
data)) {
927 for (
i = 0;
i <
s->active_tile_cols;
i++) {
928 if (
s->s.h.keyframe ||
s->s.h.intraonly) {
929 memset(
s->td[
i].counts.coef, 0,
sizeof(
s->td[0].counts.coef));
930 memset(
s->td[
i].counts.eob, 0,
sizeof(
s->td[0].counts.eob));
932 memset(&
s->td[
i].counts, 0,
sizeof(
s->td[0].counts));
934 s->td[
i].nb_block_structure = 0;
940 s->prob.p =
s->prob_ctx[
c].p;
943 if (
s->s.h.lossless) {
947 if (
s->s.h.txfmmode == 3)
951 for (
i = 0;
i < 2;
i++)
954 for (
i = 0;
i < 2;
i++)
955 for (j = 0; j < 2; j++)
957 s->prob.p.tx16p[
i][j] =
959 for (
i = 0;
i < 2;
i++)
960 for (j = 0; j < 3; j++)
962 s->prob.p.tx32p[
i][j] =
968 for (
i = 0;
i < 4;
i++) {
969 uint8_t (*
ref)[2][6][6][3] =
s->prob_ctx[
c].coef[
i];
971 for (j = 0; j < 2; j++)
972 for (k = 0; k < 2; k++)
973 for (l = 0; l < 6; l++)
974 for (m = 0; m < 6; m++) {
975 uint8_t *p =
s->prob.coef[
i][j][k][l][m];
976 uint8_t *
r =
ref[j][k][l][m];
977 if (m >= 3 && l == 0)
979 for (n = 0; n < 3; n++) {
988 for (j = 0; j < 2; j++)
989 for (k = 0; k < 2; k++)
990 for (l = 0; l < 6; l++)
991 for (m = 0; m < 6; m++) {
992 uint8_t *p =
s->prob.coef[
i][j][k][l][m];
993 uint8_t *
r =
ref[j][k][l][m];
1000 if (
s->s.h.txfmmode ==
i)
1005 for (
i = 0;
i < 3;
i++)
1008 if (!
s->s.h.keyframe && !
s->s.h.intraonly) {
1009 for (
i = 0;
i < 7;
i++)
1010 for (j = 0; j < 3; j++)
1012 s->prob.p.mv_mode[
i][j] =
1016 for (
i = 0;
i < 4;
i++)
1017 for (j = 0; j < 2; j++)
1019 s->prob.p.filter[
i][j] =
1022 for (
i = 0;
i < 4;
i++)
1026 if (
s->s.h.allowcompinter) {
1028 if (
s->s.h.comppredmode)
1031 for (
i = 0;
i < 5;
i++)
1040 for (
i = 0;
i < 5;
i++) {
1042 s->prob.p.single_ref[
i][0] =
1045 s->prob.p.single_ref[
i][1] =
1051 for (
i = 0;
i < 5;
i++)
1053 s->prob.p.comp_ref[
i] =
1057 for (
i = 0;
i < 4;
i++)
1058 for (j = 0; j < 9; j++)
1060 s->prob.p.y_mode[
i][j] =
1063 for (
i = 0;
i < 4;
i++)
1064 for (j = 0; j < 4; j++)
1065 for (k = 0; k < 3; k++)
1067 s->prob.p.partition[3 -
i][j][k] =
1069 s->prob.p.partition[3 -
i][j][k]);
1072 for (
i = 0;
i < 3;
i++)
1076 for (
i = 0;
i < 2;
i++) {
1078 s->prob.p.mv_comp[
i].sign =
1081 for (j = 0; j < 10; j++)
1083 s->prob.p.mv_comp[
i].classes[j] =
1087 s->prob.p.mv_comp[
i].class0 =
1090 for (j = 0; j < 10; j++)
1092 s->prob.p.mv_comp[
i].bits[j] =
1096 for (
i = 0;
i < 2;
i++) {
1097 for (j = 0; j < 2; j++)
1098 for (k = 0; k < 3; k++)
1100 s->prob.p.mv_comp[
i].class0_fp[j][k] =
1103 for (j = 0; j < 3; j++)
1105 s->prob.p.mv_comp[
i].fp[j] =
1109 if (
s->s.h.highprecisionmvs) {
1110 for (
i = 0;
i < 2;
i++) {
1112 s->prob.p.mv_comp[
i].class0_hp =
1116 s->prob.p.mv_comp[
i].hp =
1122 return (data2 -
data) + size2;
1126 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
1129 int c = ((
s->above_partition_ctx[col] >> (3 - bl)) & 1) |
1132 s->prob.p.partition[bl][
c];
1134 ptrdiff_t hbs = 4 >> bl;
1136 ptrdiff_t y_stride =
f->linesize[0], uv_stride =
f->linesize[1];
1137 int bytesperpixel =
s->bytesperpixel;
1142 }
else if (col + hbs < s->cols) {
1143 if (row + hbs < s->rows) {
1151 yoff += hbs * 8 * y_stride;
1152 uvoff += hbs * 8 * uv_stride >>
s->ss_v;
1157 yoff += hbs * 8 * bytesperpixel;
1158 uvoff += hbs * 8 * bytesperpixel >>
s->ss_h;
1162 decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
1164 yoff + 8 * hbs * bytesperpixel,
1165 uvoff + (8 * hbs * bytesperpixel >>
s->ss_h), bl + 1);
1166 yoff += hbs * 8 * y_stride;
1167 uvoff += hbs * 8 * uv_stride >>
s->ss_v;
1168 decode_sb(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
1169 decode_sb(td, row + hbs, col + hbs, lflvl,
1170 yoff + 8 * hbs * bytesperpixel,
1171 uvoff + (8 * hbs * bytesperpixel >>
s->ss_h), bl + 1);
1175 "the four PARTITION_* terminal codes");
1179 decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
1181 yoff + 8 * hbs * bytesperpixel,
1182 uvoff + (8 * hbs * bytesperpixel >>
s->ss_h), bl + 1);
1187 }
else if (row + hbs < s->rows) {
1190 decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
1191 yoff += hbs * 8 * y_stride;
1192 uvoff += hbs * 8 * uv_stride >>
s->ss_v;
1193 decode_sb(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
1200 decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
1206 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
1210 ptrdiff_t hbs = 4 >> bl;
1212 ptrdiff_t y_stride =
f->linesize[0], uv_stride =
f->linesize[1];
1213 int bytesperpixel =
s->bytesperpixel;
1218 }
else if (td->
b->
bl == bl) {
1221 yoff += hbs * 8 * y_stride;
1222 uvoff += hbs * 8 * uv_stride >>
s->ss_v;
1224 }
else if (
b->bp ==
PARTITION_V && col + hbs < s->cols) {
1225 yoff += hbs * 8 * bytesperpixel;
1226 uvoff += hbs * 8 * bytesperpixel >>
s->ss_h;
1231 if (col + hbs < s->cols) {
1232 if (row + hbs < s->rows) {
1233 decode_sb_mem(td, row, col + hbs, lflvl, yoff + 8 * hbs * bytesperpixel,
1234 uvoff + (8 * hbs * bytesperpixel >>
s->ss_h), bl + 1);
1235 yoff += hbs * 8 * y_stride;
1236 uvoff += hbs * 8 * uv_stride >>
s->ss_v;
1237 decode_sb_mem(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
1239 yoff + 8 * hbs * bytesperpixel,
1240 uvoff + (8 * hbs * bytesperpixel >>
s->ss_h), bl + 1);
1242 yoff += hbs * 8 * bytesperpixel;
1243 uvoff += hbs * 8 * bytesperpixel >>
s->ss_h;
1244 decode_sb_mem(td, row, col + hbs, lflvl, yoff, uvoff, bl + 1);
1246 }
else if (row + hbs < s->rows) {
1247 yoff += hbs * 8 * y_stride;
1248 uvoff += hbs * 8 * uv_stride >>
s->ss_v;
1249 decode_sb_mem(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
1256 int sb_start = ( idx * n) >> log2_n;
1257 int sb_end = ((idx + 1) * n) >> log2_n;
1258 *start =
FFMIN(sb_start, n) << 3;
1259 *end =
FFMIN(sb_end, n) << 3;
1267 for (
i = 0;
i <
s->active_tile_cols;
i++)
1276 for (
int i = 0;
i < 3;
i++)
1279 for (
i = 0;
i < 8;
i++) {
1292 ff_cbs_fragment_free(&
s->current_frag);
1293 ff_cbs_close(&
s->cbc);
1304 int row, col, tile_row, tile_col,
ret;
1306 int tile_row_start, tile_row_end, tile_col_start, tile_col_end;
1308 ptrdiff_t yoff, uvoff, ls_y, ls_uv;
1311 ls_y =
f->linesize[0];
1312 ls_uv =
f->linesize[1];
1313 bytesperpixel =
s->bytesperpixel;
1316 for (tile_row = 0; tile_row <
s->s.h.tiling.tile_rows; tile_row++) {
1318 tile_row,
s->s.h.tiling.log2_tile_rows,
s->sb_rows);
1320 for (tile_col = 0; tile_col <
s->s.h.tiling.tile_cols; tile_col++) {
1323 if (tile_col ==
s->s.h.tiling.tile_cols - 1 &&
1324 tile_row ==
s->s.h.tiling.tile_rows - 1) {
1331 if (tile_size >
size)
1342 for (row = tile_row_start; row < tile_row_end;
1343 row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >>
s->ss_v) {
1345 ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
1347 for (tile_col = 0; tile_col <
s->s.h.tiling.tile_cols; tile_col++) {
1349 tile_col,
s->s.h.tiling.log2_tile_cols,
s->sb_cols);
1354 if (
s->s.h.keyframe ||
s->s.h.intraonly) {
1363 td->
c = &td->
c_b[tile_col];
1366 for (col = tile_col_start;
1368 col += 8, yoff2 += 64 * bytesperpixel,
1369 uvoff2 += 64 * bytesperpixel >>
s->ss_h, lflvl_ptr++) {
1373 memset(lflvl_ptr->
mask, 0,
sizeof(lflvl_ptr->
mask));
1394 if (row + 8 <
s->rows) {
1395 memcpy(
s->intra_pred_data[0],
1396 f->data[0] + yoff + 63 * ls_y,
1397 8 *
s->cols * bytesperpixel);
1398 memcpy(
s->intra_pred_data[1],
1399 f->data[1] + uvoff + ((64 >>
s->ss_v) - 1) * ls_uv,
1400 8 *
s->cols * bytesperpixel >>
s->ss_h);
1401 memcpy(
s->intra_pred_data[2],
1402 f->data[2] + uvoff + ((64 >>
s->ss_v) - 1) * ls_uv,
1403 8 *
s->cols * bytesperpixel >>
s->ss_h);
1407 if (
s->s.h.filter.level) {
1410 lflvl_ptr =
s->lflvl;
1411 for (col = 0; col <
s->cols;
1412 col += 8, yoff2 += 64 * bytesperpixel,
1413 uvoff2 += 64 * bytesperpixel >>
s->ss_h, lflvl_ptr++) {
1430int decode_tiles_mt(
AVCodecContext *avctx,
void *tdata,
int jobnr,
1435 ptrdiff_t uvoff, yoff, ls_y, ls_uv;
1436 int bytesperpixel =
s->bytesperpixel, row, col, tile_row;
1437 unsigned tile_cols_len;
1438 int tile_row_start, tile_row_end, tile_col_start, tile_col_end;
1443 ls_y =
f->linesize[0];
1444 ls_uv =
f->linesize[1];
1447 jobnr,
s->s.h.tiling.log2_tile_cols,
s->sb_cols);
1449 uvoff = (64 * bytesperpixel >>
s->ss_h)*(tile_col_start >> 3);
1450 yoff = (64 * bytesperpixel)*(tile_col_start >> 3);
1451 lflvl_ptr_base =
s->lflvl+(tile_col_start >> 3);
1453 for (tile_row = 0; tile_row <
s->s.h.tiling.tile_rows; tile_row++) {
1455 tile_row,
s->s.h.tiling.log2_tile_rows,
s->sb_rows);
1457 td->
c = &td->
c_b[tile_row];
1458 for (row = tile_row_start; row < tile_row_end;
1459 row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >>
s->ss_v) {
1460 ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
1461 VP9Filter *lflvl_ptr = lflvl_ptr_base+
s->sb_cols*(row >> 3);
1465 if (
s->s.h.keyframe ||
s->s.h.intraonly) {
1474 for (col = tile_col_start;
1476 col += 8, yoff2 += 64 * bytesperpixel,
1477 uvoff2 += 64 * bytesperpixel >>
s->ss_h, lflvl_ptr++) {
1480 memset(lflvl_ptr->
mask, 0,
sizeof(lflvl_ptr->
mask));
1487 tile_cols_len = tile_col_end - tile_col_start;
1488 if (row + 8 <
s->rows) {
1489 memcpy(
s->intra_pred_data[0] + (tile_col_start * 8 * bytesperpixel),
1490 f->data[0] + yoff + 63 * ls_y,
1491 8 * tile_cols_len * bytesperpixel);
1492 memcpy(
s->intra_pred_data[1] + (tile_col_start * 8 * bytesperpixel >>
s->ss_h),
1493 f->data[1] + uvoff + ((64 >>
s->ss_v) - 1) * ls_uv,
1494 8 * tile_cols_len * bytesperpixel >>
s->ss_h);
1495 memcpy(
s->intra_pred_data[2] + (tile_col_start * 8 * bytesperpixel >>
s->ss_h),
1496 f->data[2] + uvoff + ((64 >>
s->ss_v) - 1) * ls_uv,
1497 8 * tile_cols_len * bytesperpixel >>
s->ss_h);
1500 vp9_report_tile_progress(
s, row >> 3, 1);
1510 ptrdiff_t uvoff, yoff, ls_y, ls_uv;
1512 int bytesperpixel =
s->bytesperpixel, col,
i;
1516 ls_y =
f->linesize[0];
1517 ls_uv =
f->linesize[1];
1519 for (
i = 0;
i <
s->sb_rows;
i++) {
1520 vp9_await_tile_progress(
s,
i,
s->s.h.tiling.tile_cols);
1522 if (
s->s.h.filter.level) {
1523 yoff = (ls_y * 64)*
i;
1524 uvoff = (ls_uv * 64 >>
s->ss_v)*
i;
1525 lflvl_ptr =
s->lflvl+
s->sb_cols*
i;
1526 for (col = 0; col <
s->cols;
1527 col += 8, yoff += 64 * bytesperpixel,
1528 uvoff += 64 * bytesperpixel >>
s->ss_h, lflvl_ptr++) {
1541 unsigned int tile, nb_blocks = 0;
1543 if (
s->s.h.segmentation.enabled) {
1545 nb_blocks +=
s->td[
tile].nb_block_structure;
1553 par->
qp =
s->s.h.yac_qi;
1554 par->
delta_qp[0][0] =
s->s.h.ydc_qdelta;
1555 par->
delta_qp[1][0] =
s->s.h.uvdc_qdelta;
1556 par->
delta_qp[2][0] =
s->s.h.uvdc_qdelta;
1557 par->
delta_qp[1][1] =
s->s.h.uvac_qdelta;
1558 par->
delta_qp[2][1] =
s->s.h.uvac_qdelta;
1561 unsigned int block = 0;
1562 unsigned int tile, block_tile;
1571 uint8_t seg_id =
frame->segmentation_map[row * 8 *
s->sb_cols + col];
1578 if (
s->s.h.segmentation.feat[seg_id].q_enabled) {
1579 b->delta_qp =
s->s.h.segmentation.feat[seg_id].q_val;
1580 if (
s->s.h.segmentation.absolute_vals)
1581 b->delta_qp -= par->
qp;
1599 if (!sd || sd_size < 8 ||
AV_RB64(sd) != 1)
1603 &
s->webm_alpha_warned,
1604 "Ignoring unsupported WebM alpha channel side data; use the "
1605 "libvpx-vp9 decoder to decode it.\n");
1611 const uint8_t *
data =
pkt->data;
1619 (!
s->s.h.segmentation.enabled || !
s->s.h.segmentation.update_map);
1625 ret = ff_cbs_read_packet(
s->cbc, &
s->current_frag,
pkt);
1627 ff_cbs_fragment_reset(&
s->current_frag);
1632 unit = &
s->current_frag.units[0];
1636 s->frame_header = &rf->
header;
1639 ff_cbs_fragment_reset(&
s->current_frag);
1641 }
else if (
ret == 0) {
1642 if (!
s->s.refs[
ref].f) {
1644 ff_cbs_fragment_reset(&
s->current_frag);
1647 for (
int i = 0;
i < 8;
i++)
1651 ff_cbs_fragment_reset(&
s->current_frag);
1667 src = !
s->s.h.keyframe && !
s->s.h.intraonly && !
s->s.h.errorres ?
1669 if (!retain_segmap_ref ||
s->s.h.keyframe ||
s->s.h.intraonly)
1674 ff_cbs_fragment_reset(&
s->current_frag);
1679 s->s.frames[
CUR_FRAME].frame_header =
s->frame_header;
1682 if (
s->s.h.keyframe)
1686 if (
s->s.h.lossless)
1700 for (
i = 0;
i < 8;
i++) {
1702 s->s.h.refreshrefmask & (1 <<
i) ?
1718 for (
i = 0;
i < 8;
i++) {
1720 s->s.h.refreshrefmask & (1 <<
i) ?
1728 memset(
s->above_partition_ctx, 0,
s->cols);
1729 memset(
s->above_skip_ctx, 0,
s->cols);
1730 if (
s->s.h.keyframe ||
s->s.h.intraonly) {
1731 memset(
s->above_mode_ctx,
DC_PRED,
s->cols * 2);
1735 memset(
s->above_y_nnz_ctx, 0,
s->sb_cols * 16);
1736 memset(
s->above_uv_nnz_ctx[0], 0,
s->sb_cols * 16 >>
s->ss_h);
1737 memset(
s->above_uv_nnz_ctx[1], 0,
s->sb_cols * 16 >>
s->ss_h);
1738 memset(
s->above_segpred_ctx, 0,
s->cols);
1743 "Failed to allocate block buffers\n");
1746 if (
s->s.h.refreshctx &&
s->s.h.parallelmode) {
1749 for (
i = 0;
i < 4;
i++) {
1750 for (j = 0; j < 2; j++)
1751 for (k = 0; k < 2; k++)
1752 for (l = 0; l < 6; l++)
1753 for (m = 0; m < 6; m++)
1754 memcpy(
s->prob_ctx[
s->s.h.framectxid].coef[
i][j][k][l][m],
1755 s->prob.coef[
i][j][k][l][m], 3);
1756 if (
s->s.h.txfmmode ==
i)
1759 s->prob_ctx[
s->s.h.framectxid].p =
s->prob.p;
1761 }
else if (!
s->s.h.refreshctx) {
1767 for (
i = 0;
i <
s->sb_rows;
i++)
1773 for (
i = 0;
i <
s->active_tile_cols;
i++) {
1774 s->td[
i].b =
s->td[
i].b_base;
1775 s->td[
i].block =
s->td[
i].block_base;
1776 s->td[
i].uvblock[0] =
s->td[
i].uvblock_base[0];
1777 s->td[
i].uvblock[1] =
s->td[
i].uvblock_base[1];
1778 s->td[
i].eob =
s->td[
i].eob_base;
1779 s->td[
i].uveob[0] =
s->td[
i].uveob_base[0];
1780 s->td[
i].uveob[1] =
s->td[
i].uveob_base[1];
1781 s->td[
i].error_info = 0;
1786 int tile_row, tile_col;
1790 for (tile_row = 0; tile_row <
s->s.h.tiling.tile_rows; tile_row++) {
1791 for (tile_col = 0; tile_col <
s->s.h.tiling.tile_cols; tile_col++) {
1794 if (tile_col ==
s->s.h.tiling.tile_cols - 1 &&
1795 tile_row ==
s->s.h.tiling.tile_rows - 1) {
1802 if (tile_size >
size) {
1829 for (
i = 1;
i <
s->s.h.tiling.tile_cols;
i++)
1830 for (j = 0; j <
sizeof(
s->td[
i].counts) /
sizeof(unsigned); j++)
1831 ((
unsigned *)&
s->td[0].counts)[j] += ((
unsigned *)&
s->td[
i].counts)[j];
1833 if (
s->pass < 2 &&
s->s.h.refreshctx && !
s->s.h.parallelmode) {
1837 }
while (
s->pass++ == 1);
1839 if (
s->td->error_info < 0) {
1841 s->td->error_info = 0;
1852 ff_cbs_fragment_reset(&
s->current_frag);
1856 for (
int i = 0;
i < 8;
i++)
1859 if (!
s->s.h.invisible) {
1867 ff_cbs_fragment_reset(&
s->current_frag);
1877 for (
i = 0;
i < 3;
i++)
1880 for (
i = 0;
i < 8;
i++) {
1886 ff_cbs_fragment_reset(&
s->current_frag);
1887 ff_cbs_flush(
s->cbc);
1899 s->s.h.filter.sharpness = -1;
1921 for (
int i = 0;
i < 3;
i++)
1923 for (
int i = 0;
i < 8;
i++)
1926 s->frame_extradata_pool_size = ssrc->frame_extradata_pool_size;
1929 for (
int i = 0;
i < 8;
i++)
1932 s->frame_header = ssrc->frame_header;
1935 s->s.h.invisible = ssrc->s.h.invisible;
1936 s->s.h.keyframe = ssrc->s.h.keyframe;
1937 s->s.h.intraonly = ssrc->s.h.intraonly;
1938 s->ss_v = ssrc->ss_v;
1939 s->ss_h = ssrc->ss_h;
1940 s->s.h.segmentation.enabled = ssrc->s.h.segmentation.enabled;
1941 s->s.h.segmentation.update_map = ssrc->s.h.segmentation.update_map;
1942 s->s.h.segmentation.absolute_vals = ssrc->s.h.segmentation.absolute_vals;
1943 s->bytesperpixel = ssrc->bytesperpixel;
1944 s->gf_fmt = ssrc->gf_fmt;
1947 s->s.h.bpp = ssrc->s.h.bpp;
1948 s->bpp_index = ssrc->bpp_index;
1949 s->pix_fmt = ssrc->pix_fmt;
1950 s->webm_alpha_warned = ssrc->webm_alpha_warned;
1951 memcpy(&
s->prob_ctx, &ssrc->prob_ctx,
sizeof(
s->prob_ctx));
1952 memcpy(&
s->s.h.lf_delta, &ssrc->s.h.lf_delta,
sizeof(
s->s.h.lf_delta));
1953 memcpy(&
s->s.h.segmentation.feat, &ssrc->s.h.segmentation.feat,
1954 sizeof(
s->s.h.segmentation.feat));
1976 .bsfs =
"vp9_superframe_split",
1978#if CONFIG_VP9_DXVA2_HWACCEL
1981#if CONFIG_VP9_D3D11VA_HWACCEL
1984#if CONFIG_VP9_D3D11VA2_HWACCEL
1987#if CONFIG_VP9_D3D12VA_HWACCEL
1990#if CONFIG_VP9_NVDEC_HWACCEL
1993#if CONFIG_VP9_NVDEC_CUARRAY_HWACCEL
1996#if CONFIG_VP9_VAAPI_HWACCEL
1999#if CONFIG_VP9_VDPAU_HWACCEL
2002#if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL
2005#if CONFIG_VP9_VULKAN_HWACCEL
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_vp9_decoder
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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 decode012(BSCTX *bc)
Return decoded truncated unary code for the values 0, 1, 2.
static int FUNC tile(CodedBitstreamContext *ctx, RWContext *rw, APVRawTile *current, int tile_idx, uint32_t tile_size)
#define i(width, name, range_min, range_max)
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF
Codec initializes slice-based threading with a main function.
#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)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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)
static const uint8_t bits[8]
static const char * hwaccel
bitstream reader API header.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t * align_get_bits(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#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.
#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
Decoding only.
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_LOSSLESS
A decoder can use this flag to mark frames which were originally encoded losslessly.
#define AV_FRAME_FLAG_DISCARD
A flag to mark the frames which need to be decoded, but shouldn't be output.
#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_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
#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_DXVA2(codec)
#define HWACCEL_VDPAU(codec)
#define HWACCEL_D3D12VA(codec)
#define HWACCEL_VULKAN(codec)
#define HWACCEL_NVDEC(codec)
#define HWACCEL_VAAPI(codec)
#define HWACCEL_D3D11VA(codec)
#define HWACCEL_VIDEOTOOLBOX(codec)
#define HWACCEL_D3D11VA2(codec)
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
av_cold void ff_pthread_free(void *obj, const unsigned offsets[])
av_cold int ff_pthread_init(void *obj, const unsigned offsets[])
Initialize/destroy a list of mutexes/conditions contained in a structure.
Multithreading API for decoders.
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact)
Macro definitions for various function/variable attributes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmt_rgb[3]
static enum AVPixelFormat pix_fmts[]
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV440P12
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GBRP12
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
@ AV_PIX_FMT_CUARRAY
hardware decoding through openharmony
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV444P10
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
const AVProfile ff_vp9_profiles[]
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...
#define DEFINE_OFFSET_ARRAY(type, name, cnt_variable, mutexes, conds)
int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, action_func2 *func2, main_func *mainfunc, void *arg, int *ret, int job_count)
AVRefStructPool * av_refstruct_pool_alloc(size_t size, unsigned flags)
Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
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.
void * av_refstruct_pool_get(AVRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
void * av_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
#define AV_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME
If this flag is set, the entries will be zeroed before being returned to the user (after the init or ...
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
#define FF_ARRAY_ELEMS(a)
#define atomic_fetch_add_explicit(object, operand, order)
#define atomic_load_explicit(object, order)
#define atomic_init(obj, value)
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.
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
enum AVColorSpace colorspace
YUV colorspace type.
int flags
AV_CODEC_FLAG_*.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Data structure for storing block-level encoding information.
Video encoding parameters for a given frame.
int32_t delta_qp[4][2]
Quantisation parameter offset from the base (per-frame) qp for a given plane (first index) and AC/DC ...
int32_t qp
Base quantisation parameter for the frame.
Coded bitstream unit structure.
void * content
Pointer to the decomposed form of this unit.
void * content_ref
If content is reference counted, a RefStruct reference backing content.
uint8_t left_segpred_ctx[8]
unsigned int block_size_idx_x
uint8_t left_y_nnz_ctx[16]
unsigned int nb_block_structure
unsigned int block_size_idx_y
struct VP9TileData::@362347210250227013314212060146323350261010304114 counts
int16_t * uvblock_base[2]
unsigned partition[4][4][4]
struct VP9TileData::@101265210003061101033147345251051344325013111222 * block_structure
uint8_t left_uv_nnz_ctx[2][16]
uint8_t left_mode_ctx[16]
uint8_t left_partition_ctx[8]
#define av_malloc_array(a, b)
static int ref[MAX_W *MAX_W]
static double limit(double x)
AVVideoEncParams * av_video_enc_params_create_side_data(AVFrame *frame, enum AVVideoEncParamsType type, unsigned int nb_blocks)
Allocates memory for AVEncodeInfoFrame plus an array of nb_blocks AVEncodeInfoBlock in the given AVFr...
static av_always_inline AVVideoBlockParams * av_video_enc_params_block(AVVideoEncParams *par, unsigned int idx)
Get the block at the specified idx.
@ AV_VIDEO_ENC_PARAMS_VP9
VP9 stores:
Core video DSP helper functions.
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 void vp9_tile_data_free(VP9TileData *td)
static int read_colorspace_details(AVCodecContext *avctx)
static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f)
static int update_size(AVCodecContext *avctx, int w, int h)
static int update_prob(VPXRangeCoder *c, int p)
static void decode_sb_mem(VP9TileData *td, int row, int col, VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
static int decode_frame_header(AVCodecContext *avctx, const uint8_t *data, int size, int *ref)
static av_cold void vp9_decode_flush(AVCodecContext *avctx)
static av_cold int vp9_decode_init(AVCodecContext *avctx)
static void free_buffers(VP9Context *s)
static int vp9_alloc_entries(AVCodecContext *avctx, int n)
static void vp9_frame_replace(VP9Frame *dst, const VP9Frame *src)
static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
static av_always_inline int inv_recenter_nonneg(int v, int m)
static void vp9_warn_unsupported_webm_alpha(AVCodecContext *avctx, const AVPacket *pkt)
static av_always_inline int get_sbits_inv(GetBitContext *gb, int n)
static void set_tile_offset(int *start, int *end, int idx, int log2_n, int n)
static int decode_tiles(AVCodecContext *avctx, const uint8_t *data, int size)
static void vp9_frame_unref(VP9Frame *f)
static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame)
static void decode_sb(VP9TileData *td, int row, int col, VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
static av_cold int vp9_decode_free(AVCodecContext *avctx)
static int update_block_buffers(AVCodecContext *avctx)
#define assign(var, type, n)
void ff_vp9_decode_block(VP9TileData *td, int row, int col, VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl, enum BlockPartition bp)
const ProbContext ff_vp9_default_probs
const int16_t ff_vp9_ac_qlookup[3][256]
const uint8_t ff_vp9_default_kf_partition_probs[4][4][3]
const int16_t ff_vp9_dc_qlookup[3][256]
const uint8_t ff_vp9_default_coef_probs[4][2][2][6][6][3]
const uint8_t ff_vp9_model_pareto8[256][8]
const int8_t ff_vp9_partition_tree[3][2]
#define REF_INVALID_SCALE
void ff_vp9_loopfilter_sb(struct AVCodecContext *avctx, VP9Filter *lflvl, int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff)
void ff_vp9_adapt_probs(VP9Context *s)
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 int vpx_rac_is_end(VPXRangeCoder *c)
returns 1 if the end of the stream has been reached, 0 otherwise.