27 #include "libavutil/attributes.h"
28 #include "libavutil/common.h"
30 #include "libavutil/md5.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/pixdesc.h"
88 int pic_size = width *
height;
89 int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
90 ((height >> log2_min_cb_size) + 1);
94 int pic_size_in_min_pu = min_pu_width * pic_height_in_min_pu;
146 uint8_t luma_weight_l0_flag[16];
147 uint8_t chroma_weight_l0_flag[16];
148 uint8_t luma_weight_l1_flag[16];
149 uint8_t chroma_weight_l1_flag[16];
159 if (!luma_weight_l0_flag[i]) {
166 chroma_weight_l0_flag[i] =
get_bits1(gb);
169 chroma_weight_l0_flag[i] = 0;
172 if (luma_weight_l0_flag[i]) {
177 if (chroma_weight_l0_flag[i]) {
178 for (j = 0; j < 2; j++) {
195 if (!luma_weight_l1_flag[i]) {
202 chroma_weight_l1_flag[i] =
get_bits1(gb);
205 chroma_weight_l1_flag[i] = 0;
208 if (luma_weight_l1_flag[i]) {
213 if (chroma_weight_l1_flag[i]) {
214 for (j = 0; j < 2; j++) {
235 int prev_delta_msb = 0;
236 int nb_sps = 0, nb_sh;
252 for (i = 0; i < rps->
nb_refs; i++) {
269 if (delta_poc_msb_present) {
272 if (i && i != nb_sps)
273 delta += prev_delta_msb;
276 prev_delta_msb =
delta;
331 "TODO: s->sps->chroma_format_idc == 0 || "
332 "s->sps->separate_colour_plane_flag\n");
351 int slice_address_length;
396 int short_term_ref_pic_set_sps_flag;
403 "Ignoring POC change between slices: %d -> %d\n", s->
poc, poc);
410 short_term_ref_pic_set_sps_flag =
get_bits1(gb);
411 if (!short_term_ref_pic_set_sps_flag) {
418 int numbits, rps_idx;
426 rps_idx = (numbits > 0) ?
get_bits(gb, numbits) : 0;
541 "Invalid number of merging MVP candidates: %d.\n",
557 int deblocking_filter_override_flag = 0;
560 deblocking_filter_override_flag =
get_bits1(gb);
562 if (deblocking_filter_override_flag) {
597 int segments = offset_len >> 4;
598 int rest = (offset_len & 15);
607 for (j = 0; j < segments; j++) {
628 for (i = 0; i <
length; i++)
647 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
649 #define SET_SAO(elem, value) \
651 if (!sao_merge_up_flag && !sao_merge_left_flag) \
653 else if (sao_merge_left_flag) \
654 sao->elem = CTB(s->sao, rx-1, ry).elem; \
655 else if (sao_merge_up_flag) \
656 sao->elem = CTB(s->sao, rx, ry-1).elem; \
664 int sao_merge_left_flag = 0;
665 int sao_merge_up_flag = 0;
676 if (ry > 0 && !sao_merge_left_flag) {
682 for (c_idx = 0; c_idx < 3; c_idx++) {
698 for (i = 0; i < 4; i++)
702 for (i = 0; i < 4; i++) {
710 }
else if (c_idx != 2) {
716 for (i = 0; i < 4; i++) {
733 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
734 int log2_cb_size,
int log2_trafo_size,
735 int trafo_depth,
int blk_idx)
740 int trafo_size = 1 << log2_trafo_size;
744 if (log2_trafo_size > 2) {
745 trafo_size = trafo_size << (s->
sps->
hshift[1] - 1);
749 }
else if (blk_idx == 3) {
750 trafo_size = trafo_size << (s->
sps->
hshift[1]);
792 if (log2_trafo_size > 2) {
797 }
else if (blk_idx == 3) {
808 int cb_size = 1 << log2_cb_size;
816 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
817 for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
818 s->
is_pcm[i + j * min_pu_width] = 2;
822 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
823 int log2_cb_size,
int log2_trafo_size,
824 int trafo_depth,
int blk_idx)
829 if (trafo_depth > 0 && log2_trafo_size == 2) {
840 if (trafo_depth == 1)
852 if (log2_trafo_size <= s->sps->log2_max_trafo_size &&
854 trafo_depth < lc->cu.max_trafo_depth &&
863 if (log2_trafo_size > 2) {
864 if (trafo_depth == 0 ||
876 if (split_transform_flag) {
877 int x1 = x0 + ((1 << log2_trafo_size) >> 1);
878 int y1 = y0 + ((1 << log2_trafo_size) >> 1);
881 log2_trafo_size - 1, trafo_depth + 1, 0);
883 log2_trafo_size - 1, trafo_depth + 1, 1);
885 log2_trafo_size - 1, trafo_depth + 1, 2);
887 log2_trafo_size - 1, trafo_depth + 1, 3);
900 log2_cb_size, log2_trafo_size, trafo_depth, blk_idx);
905 for (i = 0; i < (1 << log2_trafo_size); i += min_tu_size)
906 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
907 int x_tu = (x0 + j) >> log2_min_tu_size;
908 int y_tu = (y0 + i) >> log2_min_tu_size;
909 s->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
927 int cb_size = 1 << log2_cb_size;
968 int block_w,
int block_h)
972 ptrdiff_t srcstride = ref->
linesize[0];
985 if (x_off < extra_left || y_off < extra_top ||
992 x_off - extra_left, y_off - extra_top,
993 pic_width, pic_height);
1015 const Mv *
mv,
int x_off,
int y_off,
int block_w,
int block_h)
1020 ptrdiff_t src1stride = ref->
linesize[1];
1021 ptrdiff_t src2stride = ref->
linesize[2];
1022 int pic_width = s->
sps->
width >> 1;
1028 x_off += mv->
x >> 3;
1029 y_off += mv->
y >> 3;
1043 pic_width, pic_height);
1047 block_w, block_h, mx, my, lc->
mc_buffer);
1053 pic_width, pic_height);
1056 block_w, block_h, mx, my,
1060 block_w, block_h, mx, my,
1063 block_w, block_h, mx, my,
1071 int y = (mv->
y >> 2) + y0 + height + 9;
1079 int log2_cb_size,
int partIdx)
1081 #define POS(c_idx, x, y) \
1082 &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1083 (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)]
1086 struct MvField current_mv = {{{ 0 }}};
1101 int x_cb = x0 >> log2_min_cb_size;
1102 int y_cb = y0 >> log2_min_cb_size;
1115 log2_cb_size, partIdx, merge_idx, ¤t_mv);
1121 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1131 partIdx, merge_idx, ¤t_mv);
1137 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1144 if (inter_pred_idc !=
PRED_L1) {
1147 current_mv.
ref_idx[0] = ref_idx[0];
1153 partIdx, merge_idx, ¤t_mv, mvp_flag[0], 0);
1158 if (inter_pred_idc !=
PRED_L0) {
1161 current_mv.
ref_idx[1] = ref_idx[1];
1174 partIdx, merge_idx, ¤t_mv, mvp_flag[1], 1);
1184 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
1189 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1195 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1206 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH);
1214 tmpstride, nPbW, nPbH);
1219 ¤t_mv.
mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
1227 nPbW / 2, nPbH / 2);
1232 nPbW / 2, nPbH / 2);
1245 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH);
1259 ¤t_mv.
mv[1], x0/2, y0/2, nPbW/2, nPbH/2);
1266 dst1, s->
frame->
linesize[1], tmp, tmpstride, nPbW/2, nPbH/2);
1270 dst2, s->
frame->
linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2);
1287 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH);
1289 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH);
1299 tmp, tmp2, tmpstride, nPbW, nPbH);
1302 tmp, tmp2, tmpstride, nPbW, nPbH);
1306 ¤t_mv.
mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
1308 ¤t_mv.
mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2);
1318 tmpstride, nPbW / 2, nPbH / 2);
1325 tmpstride, nPbW / 2, nPbH / 2);
1337 int prev_intra_luma_pred_flag)
1355 int intra_pred_mode;
1360 if ((y0 - 1) < y_ctb)
1363 if (cand_left == cand_up) {
1364 if (cand_left < 2) {
1369 candidate[0] = cand_left;
1370 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
1371 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
1374 candidate[0] = cand_left;
1375 candidate[1] = cand_up;
1385 if (prev_intra_luma_pred_flag) {
1386 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
1388 if (candidate[0] > candidate[1])
1390 if (candidate[0] > candidate[2])
1392 if (candidate[1] > candidate[2])
1396 for (i = 0; i < 3; i++)
1397 if (intra_pred_mode >= candidate[i])
1404 for (i = 0; i < size_in_pus; i++) {
1405 memset(&s->
tab_ipm[(y_pu + i) * min_pu_width + x_pu],
1406 intra_pred_mode, size_in_pus);
1408 for (j = 0; j < size_in_pus; j++) {
1409 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
is_intra = 1;
1410 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
pred_flag[0] = 0;
1411 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
pred_flag[1] = 0;
1412 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
ref_idx[0] = 0;
1413 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
ref_idx[1] = 0;
1414 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[0].x = 0;
1415 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[0].
y = 0;
1416 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[1].x = 0;
1417 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].
mv[1].
y = 0;
1421 return intra_pred_mode;
1425 int log2_cb_size,
int ct_depth)
1441 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
1442 uint8_t prev_intra_luma_pred_flag[4];
1444 int pb_size = (1 << log2_cb_size) >> split;
1445 int side = split + 1;
1449 for (i = 0; i < side; i++)
1450 for (j = 0; j < side; j++)
1453 for (i = 0; i < side; i++) {
1454 for (j = 0; j < side; j++) {
1455 if (prev_intra_luma_pred_flag[2 * i + j])
1462 prev_intra_luma_pred_flag[2 * i + j]);
1467 if (chroma_mode != 4) {
1482 int pb_size = 1 << log2_cb_size;
1490 if (size_in_pus == 0)
1492 for (j = 0; j < size_in_pus; j++) {
1493 memset(&s->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
1494 for (k = 0; k < size_in_pus; k++)
1501 int cb_size = 1 << log2_cb_size;
1504 int length = cb_size >> log2_min_cb_size;
1506 int x_cb = x0 >> log2_min_cb_size;
1507 int y_cb = y0 >> log2_min_cb_size;
1519 for (x = 0; x < 4; x++)
1532 x = y_cb * min_cb_width + x_cb;
1533 for (y = 0; y <
length; y++) {
1534 memset(&s->
skip_flag[x], skip_flag, length);
1561 log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) {
1610 hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3);
1625 log2_cb_size, 0, 0);
1638 x = y_cb * min_cb_width + x_cb;
1639 for (y = 0; y <
length; y++) {
1650 int log2_cb_size,
int cb_depth)
1653 const int cb_size = 1 << log2_cb_size;
1657 if ((x0 + cb_size <= s->sps->width) &&
1658 (y0 + cb_size <= s->sps->height) &&
1673 const int cb_size_split = cb_size >> 1;
1674 const int x1 = x0 + cb_size_split;
1675 const int y1 = y0 + cb_size_split;
1682 if (more_data && x1 < s->sps->width)
1684 if (more_data && y1 < s->sps->height)
1686 if (more_data && x1 < s->sps->width &&
1687 y1 < s->sps->height) {
1691 return ((x1 + cb_size_split) < s->
sps->
width ||
1699 if ((!((x0 + cb_size) %
1701 (x0 + cb_size >= s->
sps->
width)) &&
1706 return !end_of_slice_flag;
1720 int ctb_addr_in_slice = ctb_addr_rs - s->
sh.
slice_addr;
1722 int tile_left_boundary;
1723 int tile_up_boundary;
1724 int slice_left_boundary;
1725 int slice_up_boundary;
1730 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
1747 tile_left_boundary = ((x_ctb > 0) &&
1749 slice_left_boundary = ((x_ctb > 0) &&
1751 tile_up_boundary = ((y_ctb > 0) &&
1753 slice_up_boundary = ((y_ctb > 0) &&
1756 tile_left_boundary =
1757 tile_up_boundary = 1;
1758 slice_left_boundary = ctb_addr_in_slice > 0;
1759 slice_up_boundary = ctb_addr_in_slice >= s->
sps->
ctb_width;
1763 lc->
ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && tile_left_boundary);
1778 while (more_data && ctb_addr_ts < s->sps->ctb_size) {
1802 if (x_ctb + ctb_size >= s->
sps->
width &&
1826 int *ctb_row_p = input_ctb_row;
1827 int ctb_row = ctb_row_p[job];
1837 ret =
init_get_bits8(&lc->
gb,
s->data +
s->sh.offset[ctb_row - 1],
s->sh.size[ctb_row - 1]);
1844 while(more_data && ctb_addr_ts < s->sps->ctb_size) {
1845 int x_ctb = (ctb_addr_rs %
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
1846 int y_ctb = (ctb_addr_rs /
s->sps->ctb_width) <<
s->sps->log2_ctb_size;
1858 hls_sao_param(
s, x_ctb >>
s->sps->log2_ctb_size, y_ctb >>
s->sps->log2_ctb_size);
1870 if (!more_data && (x_ctb+ctb_size) <
s->sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
1876 if ((x_ctb+ctb_size) >=
s->sps->width && (y_ctb+ctb_size) >=
s->sps->height ) {
1881 ctb_addr_rs =
s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
1884 if(x_ctb >=
s->sps->width) {
1899 int startheader, cmpt = 0;
1918 for (j = 0, cmpt = 0, startheader = offset + s->
sh.
entry_point_offset[0]; j < s->skipped_bytes; j++) {
1927 for (j = 0, cmpt = 0, startheader = offset
1991 "nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
1994 return nuh_layer_id == 0;
2002 for (c_idx = 0; c_idx < 3; c_idx++) {
2010 int len = min_pu_size >> hshift;
2013 for (n = 0; n < (min_pu_size >> vshift); n++) {
2014 memcpy(dst, src, len);
2136 if (s->
max_ra == INT_MAX) {
2158 }
else if (!s->
ref) {
2168 "Error constructing the reference lists for the current slice.\n");
2187 if (ctb_addr_ts < 0)
2215 #define STARTCODE_TEST \
2216 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
2217 if (src[i + 2] != 3) { \
2223 #if HAVE_FAST_UNALIGNED
2224 #define FIND_FIRST_ZERO \
2225 if (i > 0 && !src[i]) \
2230 for (i = 0; i + 1 <
length; i += 9) {
2232 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
2233 0x8000800080008080ULL))
2240 for (i = 0; i + 1 <
length; i += 5) {
2242 (
AV_RN32A(src + i) - 0x01000101U)) &
2251 for (i = 0; i + 1 <
length; i += 2) {
2254 if (i > 0 && src[i - 1] == 0)
2260 if (i >= length - 1) {
2273 memcpy(dst, src, i);
2275 while (si + 2 < length) {
2277 if (src[si + 2] > 3) {
2278 dst[di++] = src[si++];
2279 dst[di++] = src[si++];
2280 }
else if (src[si] == 0 && src[si + 1] == 0) {
2281 if (src[si + 2] == 3) {
2302 dst[di++] = src[si++];
2305 dst[di++] = src[si++];
2317 int i, consumed,
ret = 0;
2325 while (length >= 4) {
2327 int extract_length = 0;
2332 extract_length = (extract_length << 8) | buf[i];
2336 if (extract_length > length) {
2343 while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
2406 for (i = 0; i < s->
nb_nals; i++) {
2414 "Error parsing NAL unit #%d.\n", i);
2430 for (i = 0; i < 16; i++)
2431 av_log(log_ctx, level,
"%02"PRIx8, md5[i]);
2460 for (i = 0; frame->
data[i]; i++) {
2468 for (j = 0; j < h; j++) {
2473 (
const uint16_t*)src, w);
2481 if (!memcmp(md5, s->
md5[i], 16)) {
2759 int i, j, num_arrays;
2765 nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
2766 num_arrays = bytestream2_get_byte(&gb);
2773 for (i = 0; i < num_arrays; i++) {
2774 int type = bytestream2_get_byte(&gb) & 0x3f;
2775 int cnt = bytestream2_get_be16(&gb);
2777 for (j = 0; j < cnt; j++) {
2779 int nalsize = bytestream2_peek_be16(&gb) + 2;
2782 "Invalid NAL unit size in extradata.\n");
2789 "Decoding nal unit %d %d from hvcC failed\n", type, i);
2848 memset(s, 0,
sizeof(*s));
2864 #define OFFSET(x) offsetof(HEVCContext, x)
2865 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
2867 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(strict_def_disp_win),
2885 .priv_class = &hevc_decoder_class,
VPS * vps_list[MAX_VPS_COUNT]
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth)
unsigned int log2_min_cb_size
const char const char void * val
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
#define SAMPLE_CTB(tab, x, y)
#define AVERROR_PATCHWELCOME
static int shift(int a, int b)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
static void hevc_await_progress(HEVCContext *s, HEVCFrame *ref, const Mv *mv, int y0, int height)
This structure describes decoded (raw) audio or video data.
static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
void(* put_hevc_epel[2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int width, int height, int mx, int my, int16_t *mcbuffer)
void(* emulated_edge_mc)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
int coded_width
Bitstream width / height, may be different from width/height e.g.
void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
int ff_hevc_sao_band_position_decode(HEVCContext *s)
int16_t x
horizontal component of motion vector
static av_cold int init(AVCodecContext *avctx)
int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size)
uint8_t intra_split_flag
IntraSplitFlag.
int rem_intra_luma_pred_mode
void(* put_hevc_qpel[4][4])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int width, int height, int16_t *mcbuffer)
static void pic_arrays_free(HEVCContext *s)
NOTE: Each function hls_foo correspond to the function foo in the specification (HLS stands for High ...
int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s)
void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size)
uint8_t weighted_bipred_flag
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define DECLARE_ALIGNED(n, t, v)
static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void(* put_unweighted_pred)(uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride, int width, int height)
Clip a signed integer value into the amin-amax range.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt)
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX)
int * ctb_addr_ts_to_rs
CtbAddrTSToRS.
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
struct HEVCFrame * ref[MAX_REFS]
ShortTermRPS st_rps[MAX_SHORT_TERM_RPS_COUNT]
static int hls_slice_header(HEVCContext *s)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint16_t seq_decode
Sequence counters for decoded and output frames, so that old frames are output first after a POC rese...
static void intra_prediction_unit_default_value(HEVCContext *s, int x0, int y0, int log2_cb_size)
void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len)
Update hash value.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int ff_hevc_decode_nal_sei(HEVCContext *s)
int ff_hevc_frame_nb_refs(HEVCContext *s)
Get the number of candidate references for the current frame.
uint8_t entropy_coding_sync_enabled_flag
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
AVBufferPool * rpl_tab_pool
candidate references for the current frame
static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
static int verify_md5(HEVCContext *s, AVFrame *frame)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
unsigned int log2_max_trafo_size
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
const char * av_default_item_name(void *ctx)
Return the context name.
int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, HEVCNAL *nal)
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s)
int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0)
uint8_t ctb_up_right_flag
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
Compute POC of the current frame and return it.
static const uint8_t offset[511][2]
#define SAMPLE(tab, x, y)
Value of the luma sample at position (x, y) in the 2D array tab.
void(* put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int size, GetBitContext *gb, int pcm_bit_depth)
void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
const char * name
Name of the codec implementation.
unsigned int log2_min_pcm_cb_size
static int hls_nal_unit(HEVCContext *s)
static av_cold int hevc_decode_init(AVCodecContext *avctx)
int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
#define avpriv_atomic_int_set
struct HEVCSPS::@63 temporal_layer[MAX_SUB_LAYERS]
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s)
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size, int slice_or_tiles_up_boundary, int slice_or_tiles_left_boundary)
struct AVCodecInternal * internal
Private context used for internal data.
void ff_hevc_clear_refs(HEVCContext *s)
Mark all frames in DPB as unused for reference.
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
void(* put_weighted_pred_avg)(uint8_t *dst, ptrdiff_t dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width, int height)
uint8_t loop_filter_disable_flag
uint8_t cu_transquant_bypass_flag
#define FFSWAP(type, a, b)
int * skipped_bytes_pos_size_nal
const OptionDef options[]
static av_unused const uint8_t * skip_bytes(CABACContext *c, int n)
Skip n bytes and reset the decoder.
uint8_t transquant_bypass_enable_flag
int temporal_id
temporal_id_plus1 - 1
HEVCLocalContext * HEVClcList[MAX_NB_THREADS]
const uint8_t ff_hevc_qpel_extra_after[4]
int slice_idx
number of the slice being currently decoded
int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH)
uint8_t intra_pred_mode[4]
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx)
uint16_t depth_minus1
number of bits in the component minus 1
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t slice_initialized
1 if the independent slice segment header was successfully parsed
unsigned int log2_max_poc_lsb
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
static void restore_tqb_pixels(HEVCContext *s)
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
AVBufferRef * rpl_tab_buf
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
#define avpriv_atomic_int_get
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static void hevc_decode_flush(AVCodecContext *avctx)
int active_thread_type
Which multithreading methods are in use by the codec.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int ff_hevc_mvp_lx_flag_decode(HEVCContext *s)
static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h)
8.5.3.2.2.1 Luma sample interpolation process
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
unsigned int log2_ctb_size
int ** skipped_bytes_pos_nal
void(* weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag, uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride, int width, int height)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void ff_init_cabac_states(void)
#define EPEL_EXTRA_BEFORE
uint8_t max_trafo_depth
MaxTrafoDepth.
uint16_t sequence
A sequence counter, so that old frames are output first after a POC reset.
static av_cold int hevc_init_context(AVCodecContext *avctx)
static char * split(char *message, char delim)
uint8_t tiles_enabled_flag
int eo_class[3]
sao_eo_class
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
struct HEVCContext * sList[MAX_NB_THREADS]
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static int pic_arrays_init(HEVCContext *s)
#define SAMPLE_CBF(tab, x, y)
int ff_hevc_intra_chroma_pred_mode_decode(HEVCContext *s)
#define FF_ARRAY_ELEMS(a)
uint8_t lists_modification_present_flag
static void intra_prediction_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
AVBufferRef * tab_mvf_buf
uint8_t type_idx[3]
sao_type_idx
int ff_hevc_pred_mode_decode(HEVCContext *s)
int ff_hevc_sao_eo_class_decode(HEVCContext *s)
uint8_t * data
The data buffer.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int ff_hevc_sao_offset_sign_decode(HEVCContext *s)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int max_transform_hierarchy_depth_inter
void(* weighted_pred_avg)(uint8_t denom, int16_t wl0Flag, int16_t wl1Flag, int16_t ol0Flag, int16_t ol1Flag, uint8_t *dst, ptrdiff_t dststride, int16_t *src1, int16_t *src2, ptrdiff_t srcstride, int width, int height)
int16_t mc_buffer[(64+7)*64]
static int hevc_frame_start(HEVCContext *s)
int offset_abs[3][4]
sao_offset_abs
int num_tile_columns
num_tile_columns_minus1 + 1
int * column_width
ColumnWidth.
int width
picture width / height.
int ff_hevc_sao_type_idx_decode(HEVCContext *s)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
uint8_t * edge_emu_buffer
AVBufferRef * sps_list[MAX_SPS_COUNT]
int ff_hevc_end_of_slice_flag_decode(HEVCContext *s)
uint8_t cu_qp_delta_enabled_flag
uint8_t used_by_curr_pic_lt_sps_flag[32]
const uint8_t ff_hevc_qpel_extra_before[4]
Context Adaptive Binary Arithmetic Coder inline functions.
int ff_alloc_entries(AVCodecContext *avctx, int count)
uint8_t output_flag_present_flag
static av_cold int hevc_init_thread_copy(AVCodecContext *avctx)
static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size)
int offset_val[3][5]
SaoOffsetVal.
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s)
void ff_reset_entries(AVCodecContext *avctx)
AVBufferRef * pps_list[MAX_PPS_COUNT]
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
static void flush(AVCodecContext *avctx)
int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush)
Find next frame in output order and put a reference to it in frame.
static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
8.4.1
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int sps_id
seq_parameter_set_id
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
static const int8_t mv[256][2]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
enum AVPixelFormat pix_fmt
void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
#define AV_LOG_INFO
Standard information.
int ff_hevc_merge_idx_decode(HEVCContext *s)
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
int * ctb_addr_rs_to_ts
CtbAddrRSToTS.
static av_always_inline void set_ct_depth(HEVCContext *s, int x0, int y0, int log2_cb_size, int ct_depth)
int ff_hevc_merge_flag_decode(HEVCContext *s)
unsigned int log2_min_pu_size
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
static void close(AVCodecParserContext *s)
enum PredMode pred_mode
PredMode.
#define FF_THREAD_FRAME
Decode more than one frame at once.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everythnig contained in src to dst and reset src.
int num_extra_slice_header_bits
#define AV_EF_EXPLODE
abort decoding on minor error detection
int16_t y
vertical component of motion vector
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t num_long_term_ref_pics_sps
void av_md5_init(struct AVMD5 *ctx)
Initialize MD5 hashing.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
uint8_t deblocking_filter_control_present_flag
static unsigned int get_bits1(GetBitContext *s)
BYTE int const BYTE int int int height
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
uint8_t sps_temporal_mvp_enabled_flag
Describe the class of an AVClass context structure.
int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth)
int num_tile_rows
num_tile_rows_minus1 + 1
static void skip_bits(GetBitContext *s, int n)
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
void av_buffer_pool_uninit(AVBufferPool **pool)
Mark the pool as being available for freeing.
void(* intra_pred)(struct HEVCContext *s, int x0, int y0, int log2_size, int c_idx)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int enable_parallel_tiles
void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
unsigned int log2_min_tb_size
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum PartMode part_mode
PartMode.
uint16_t lt_ref_pic_poc_lsb_sps[32]
static int hevc_decode_extradata(HEVCContext *s)
enum NALUnitType nal_unit_type
void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
void av_md5_final(struct AVMD5 *ctx, uint8_t *dst)
Finish hashing and output digest value.
int allocate_progress
Whether to allocate progress for frame threading.
int ff_hevc_frame_rps(HEVCContext *s)
Construct the reference picture sets for the current frame.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
int tc_offset
tc_offset_div2 * 2
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
HEVCLocalContext * HEVClc
int ff_hevc_cu_qp_delta_abs(HEVCContext *s)
static void * av_malloc_array(size_t nmemb, size_t size)
uint8_t intra_pred_mode_c
static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
int eos
current packet contains an EOS/EOB NAL
int skipped_bytes_pos_size
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts)
int max_transform_hierarchy_depth_intra
coded frame dimension in various units
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
uint8_t slice_or_tiles_up_boundary
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
uint8_t weighted_pred_flag
int32_t * tab_slice_address
uint8_t * filter_slice_edges
uint8_t slice_header_extension_present_flag
int ff_hevc_sao_merge_flag_decode(HEVCContext *s)
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
AVBufferPool * tab_mvf_pool
static int hevc_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
#define SET_SAO(elem, value)
int ff_hevc_decode_nal_sps(HEVCContext *s)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
int ff_hevc_mpm_idx_decode(HEVCContext *s)
#define AVERROR_INVALIDDATA
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
int ff_hevc_decode_nal_pps(HEVCContext *s)
int ff_hevc_decode_nal_vps(HEVCContext *s)
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.
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0, int nPbW, int nPbH)
const uint8_t ff_hevc_qpel_extra[4]
int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth)
uint8_t slice_or_tiles_left_boundary
uint8_t long_term_ref_pics_present_flag
static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
static const AVClass hevc_decoder_class
static void * av_mallocz_array(size_t nmemb, size_t size)
static void hls_sao_param(HEVCContext *s, int rx, int ry)
int diff_cu_qp_delta_depth
#define AV_EF_CRCCHECK
verify embedded CRCs
static int init_thread_copy(AVCodecContext *avctx)
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int ff_hevc_sao_offset_abs_decode(HEVCContext *s)
static void print_md5(void *log_ctx, int level, uint8_t md5[16])
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...
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
static av_cold int hevc_decode_free(AVCodecContext *avctx)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int hls_slice_data(HEVCContext *s)
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
static void hls_transform_tree(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx)
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
void ff_hevc_hls_filter(HEVCContext *s, int x, int y)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int job, int self_id)
static void chroma_mc(HEVCContext *s, int16_t *dst1, int16_t *dst2, ptrdiff_t dststride, AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h)
8.5.3.2.2.2 Chroma sample interpolation process
uint8_t dependent_slice_segments_enabled_flag
int offset_sign[3][4]
sao_offset_sign
int ff_hevc_pcm_flag_decode(HEVCContext *s)
static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx)