54 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2,
55 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
56 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
60 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3,
61 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
62 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
66 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
67 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
68 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
69 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
73 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
74 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
75 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
76 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
77 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
78 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
79 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
80 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
81 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
82 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
83 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
84 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
85 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
86 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
87 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
88 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
92 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
93 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
94 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
95 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
96 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
97 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
98 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
99 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
100 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
101 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
102 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
103 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
104 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
105 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
106 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
107 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
112 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
113 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
114 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
115 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
116 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
117 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
118 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
119 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
120 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
121 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
122 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
123 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
124 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
125 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
126 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
127 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
140 0, 3, 4, 3, 3, 1, 5, 1, 4, 5, 2, 5, 3, 1, 5, 1
144 { 20, 18, 32, 19, 25, 24 },
145 { 22, 19, 35, 21, 28, 26 },
146 { 26, 23, 42, 24, 33, 31 },
147 { 28, 25, 45, 26, 35, 33 },
148 { 32, 28, 51, 30, 40, 38 },
149 { 36, 32, 58, 34, 46, 43 },
153 #if CONFIG_H264_DXVA2_HWACCEL
156 #if CONFIG_H264_VAAPI_HWACCEL
159 #if CONFIG_H264_VDA_HWACCEL
162 #if CONFIG_H264_VDPAU_HWACCEL
170 #if CONFIG_H264_DXVA2_HWACCEL
173 #if CONFIG_H264_VAAPI_HWACCEL
176 #if CONFIG_H264_VDA_HWACCEL
179 #if CONFIG_H264_VDPAU_HWACCEL
188 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
245 offset[2] = (y >> vshift) * src->
linesize[1];
269 for (i = 0; i < 2; i++) {
274 memset((
uint8_t*)pic + off, 0,
sizeof(*pic) - off);
310 for (i = 0; i < 2; i++) {
326 for (i = 0; i < 2; i++)
378 const int b4_stride = h->
mb_width * 4 + 1;
379 const int b4_array_size = b4_stride * h->
mb_height * 4;
441 for (i = 0; i < 2; i++) {
454 return (ret < 0) ? ret :
AVERROR(ENOMEM);
474 if (i == MAX_PICTURE_COUNT)
491 static const int8_t top[12] = {
494 static const int8_t left[12] = {
500 for (i = 0; i < 4; i++) {
504 "top block unavailable for requested intra4x4 mode %d at %d %d\n",
514 static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
515 for (i = 0; i < 4; i++)
520 "left block unavailable for requested intra4x4 mode %d at %d %d\n",
543 "out of range intra chroma pred mode at %d %d\n",
552 "top block unavailable for requested intra mode at %d %d\n",
568 "left block unavailable for requested intra mode at %d %d\n",
578 int *dst_length,
int *consumed,
int length)
591 #define STARTCODE_TEST \
592 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
593 if (src[i + 2] != 3) { \
600 #if HAVE_FAST_UNALIGNED
601 #define FIND_FIRST_ZERO \
602 if (i > 0 && !src[i]) \
608 for (i = 0; i + 1 < length; i += 9) {
610 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
611 0x8000800080008080ULL))
618 for (i = 0; i + 1 < length; i += 5) {
620 (
AV_RN32A(src + i) - 0x01000101U)) &
629 for (i = 0; i + 1 < length; i += 2) {
632 if (i > 0 && src[i - 1] == 0)
638 if (i >= length - 1) {
639 *dst_length = length;
640 *consumed = length + 1;
655 while (si + 2 < length) {
657 if (src[si + 2] > 3) {
658 dst[di++] = src[si++];
659 dst[di++] = src[si++];
660 }
else if (src[si] == 0 && src[si + 1] == 0) {
661 if (src[si + 2] == 3) {
670 dst[di++] = src[si++];
673 dst[di++] = src[si++];
696 for (r = 1; r < 9; r++) {
705 int height,
int y_offset,
int list)
708 int filter_height_up = (raw_my & 3) ? 2 : 0;
709 int filter_height_down = (raw_my & 3) ? 3 : 0;
710 int full_my = (raw_my >> 2) + y_offset;
711 int top = full_my - filter_height_up;
712 int bottom = full_my + filter_height_down +
height;
714 return FFMAX(abs(top), bottom);
718 int height,
int y_offset,
int list0,
719 int list1,
int *nrefs)
735 if (refs[0][ref_n] < 0)
737 refs[0][ref_n] =
FFMAX(refs[0][ref_n], my);
748 if (refs[1][ref_n] < 0)
750 refs[1][ref_n] =
FFMAX(refs[1][ref_n], my);
762 const int mb_xy = h->
mb_xy;
765 int nrefs[2] = { 0 };
768 memset(refs, -1,
sizeof(refs));
788 for (i = 0; i < 4; i++) {
791 int y_offset = (i & 2) << 2;
795 IS_DIR(sub_mb_type, 0, 0),
796 IS_DIR(sub_mb_type, 0, 1),
800 IS_DIR(sub_mb_type, 0, 0),
801 IS_DIR(sub_mb_type, 0, 1),
804 IS_DIR(sub_mb_type, 0, 0),
805 IS_DIR(sub_mb_type, 0, 1),
809 IS_DIR(sub_mb_type, 0, 0),
810 IS_DIR(sub_mb_type, 0, 1),
813 IS_DIR(sub_mb_type, 0, 0),
814 IS_DIR(sub_mb_type, 0, 1),
819 for (j = 0; j < 4; j++) {
820 int sub_y_offset = y_offset + 2 * (j & 2);
822 IS_DIR(sub_mb_type, 0, 0),
823 IS_DIR(sub_mb_type, 0, 1),
830 for (list = h->
list_count - 1; list >= 0; list--)
831 for (ref = 0; ref < 48 && nrefs[list]; ref++) {
832 int row = refs[list][ref];
837 int pic_height = 16 * h->
mb_height >> ref_field_picture;
844 FFMIN((row >> 1) - !(row & 1),
848 FFMIN((row >> 1), pic_height - 1),
852 FFMIN(row * 2 + ref_field,
857 FFMIN(row, pic_height - 1),
861 FFMIN(row, pic_height - 1),
873 int src_x_offset,
int src_y_offset,
876 int pixel_shift,
int chroma_idc)
878 const int mx = h->
mv_cache[list][
scan8[n]][0] + src_x_offset * 8;
880 const int luma_xy = (mx & 3) + ((my & 3) << 2);
881 ptrdiff_t offset = ((mx >> 2) << pixel_shift) + (my >> 2) * h->
mb_linesize;
885 int extra_height = 0;
887 const int full_mx = mx >> 2;
888 const int full_my = my >> 2;
889 const int pic_width = 16 * h->
mb_width;
898 if (full_mx < 0 - extra_width ||
899 full_my < 0 - extra_height ||
900 full_mx + 16 > pic_width + extra_width ||
901 full_my + 16 > pic_height + extra_height) {
905 16 + 5, 16 + 5 , full_mx - 2,
906 full_my - 2, pic_width, pic_height);
918 if (chroma_idc == 3 ) {
919 src_cb = pic->
f.
data[1] + offset;
925 full_mx - 2, full_my - 2,
926 pic_width, pic_height);
933 src_cr = pic->
f.
data[2] + offset;
939 full_mx - 2, full_my - 2,
940 pic_width, pic_height);
949 ysh = 3 - (chroma_idc == 2 );
950 if (chroma_idc == 1 &&
MB_FIELD(h)) {
953 emu |= (my >> 3) < 0 || (my >> 3) + 8 >= (pic_height >> 1);
956 src_cb = pic->
f.
data[1] + ((mx >> 3) << pixel_shift) +
958 src_cr = pic->
f.
data[2] + ((mx >> 3) << pixel_shift) +
964 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
965 pic_width >> 1, pic_height >> (chroma_idc == 1 ));
969 height >> (chroma_idc == 1 ),
970 mx & 7, (my << (chroma_idc == 2 )) & 7);
975 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
976 pic_width >> 1, pic_height >> (chroma_idc == 1 ));
979 chroma_op(dest_cr, src_cr, h->
mb_uvlinesize, height >> (chroma_idc == 1 ),
980 mx & 7, (my << (chroma_idc == 2 )) & 7);
987 int x_offset,
int y_offset,
992 int list0,
int list1,
993 int pixel_shift,
int chroma_idc)
998 dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
999 if (chroma_idc == 3 ) {
1000 dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
1001 dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
1002 }
else if (chroma_idc == 2 ) {
1003 dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
1004 dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
1006 dest_cb += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
1007 dest_cr += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
1009 x_offset += 8 * h->
mb_x;
1015 dest_y, dest_cb, dest_cr, x_offset, y_offset,
1016 qpix_op, chroma_op, pixel_shift, chroma_idc);
1019 chroma_op = chroma_avg;
1025 dest_y, dest_cb, dest_cr, x_offset, y_offset,
1026 qpix_op, chroma_op, pixel_shift, chroma_idc);
1034 int x_offset,
int y_offset,
1041 int list0,
int list1,
1042 int pixel_shift,
int chroma_idc)
1046 dest_y += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
1047 if (chroma_idc == 3 ) {
1049 chroma_weight_avg = luma_weight_avg;
1050 chroma_weight_op = luma_weight_op;
1051 dest_cb += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
1052 dest_cr += (2 * x_offset << pixel_shift) + 2 * y_offset * h->
mb_linesize;
1053 }
else if (chroma_idc == 2 ) {
1055 dest_cb += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
1056 dest_cr += (x_offset << pixel_shift) + 2 * y_offset * h->
mb_uvlinesize;
1058 chroma_height = height >> 1;
1059 dest_cb += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
1060 dest_cr += (x_offset << pixel_shift) + y_offset * h->
mb_uvlinesize;
1062 x_offset += 8 * h->
mb_x;
1065 if (list0 && list1) {
1075 dest_y, dest_cb, dest_cr,
1076 x_offset, y_offset, qpix_put, chroma_put,
1077 pixel_shift, chroma_idc);
1079 tmp_y, tmp_cb, tmp_cr,
1080 x_offset, y_offset, qpix_put, chroma_put,
1081 pixel_shift, chroma_idc);
1085 int weight1 = 64 - weight0;
1087 height, 5, weight0, weight1, 0);
1089 chroma_height, 5, weight0, weight1, 0);
1091 chroma_height, 5, weight0, weight1, 0);
1093 luma_weight_avg(dest_y, tmp_y, h->
mb_linesize, height,
1099 chroma_weight_avg(dest_cb, tmp_cb, h->
mb_uvlinesize, chroma_height,
1105 chroma_weight_avg(dest_cr, tmp_cr, h->
mb_uvlinesize, chroma_height,
1113 int list = list1 ? 1 : 0;
1116 mc_dir_part(h, ref, n, square, height, delta, list,
1117 dest_y, dest_cb, dest_cr, x_offset, y_offset,
1118 qpix_put, chroma_put, pixel_shift, chroma_idc);
1138 int pixel_shift,
int chroma_idc)
1147 int off = (mx << pixel_shift) +
1149 (64 << pixel_shift);
1151 if (chroma_idc == 3 ) {
1155 off = ((mx >> 1) << pixel_shift) +
1157 (64 << pixel_shift);
1187 if (free_rbsp && h->
DPB) {
1191 }
else if (h->
DPB) {
1230 for (i = 0; i < 6; i++) {
1232 for (j = 0; j < i; j++)
1241 for (q = 0; q < max_qp + 1; q++) {
1242 int shift =
div6[q];
1244 for (x = 0; x < 64; x++)
1256 for (i = 0; i < 6; i++) {
1258 for (j = 0; j < i; j++)
1267 for (q = 0; q < max_qp + 1; q++) {
1268 int shift =
div6[q] + 2;
1270 for (x = 0; x < 16; x++)
1285 for (i = 0; i < 6; i++)
1286 for (x = 0; x < 16; x++)
1289 for (i = 0; i < 6; i++)
1290 for (x = 0; x < 64; x++)
1302 row_mb_num * 8 *
sizeof(
uint8_t), fail)
1304 big_mb_num * 48 *
sizeof(
uint8_t), fail)
1308 big_mb_num *
sizeof(uint16_t), fail)
1310 big_mb_num *
sizeof(
uint8_t), fail)
1312 16 * row_mb_num *
sizeof(
uint8_t), fail);
1314 16 * row_mb_num *
sizeof(
uint8_t), fail);
1316 4 * big_mb_num *
sizeof(
uint8_t), fail);
1318 big_mb_num *
sizeof(
uint8_t), fail)
1325 big_mb_num *
sizeof(uint32_t), fail);
1327 big_mb_num *
sizeof(uint32_t), fail);
1329 for (x = 0; x < h->
mb_width; x++) {
1331 const int b_xy = 4 * x + 4 * y * h->
b_stride;
1392 int yc_size = y_size + 2 * c_size;
1431 mb_array_size *
sizeof(
uint8_t), fail);
1445 for (i = 0; i < yc_size; i++)
1456 int parse_extradata);
1464 int i, cnt, nalsize;
1478 cnt = *(p + 5) & 0x1f;
1480 for (i = 0; i < cnt; i++) {
1487 "Decoding sps %d from avcC failed\n", i);
1494 for (i = 0; i < cnt; i++) {
1501 "Decoding pps %d from avcC failed\n", i);
1594 #define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b) + (size))))
1595 #undef REBASE_PICTURE
1596 #define REBASE_PICTURE(pic, new_ctx, old_ctx) \
1597 ((pic && pic >= old_ctx->DPB && \
1598 pic < old_ctx->DPB + MAX_PICTURE_COUNT) ? \
1599 &new_ctx->DPB[pic - old_ctx->DPB] : NULL)
1607 for (i = 0; i < count; i++) {
1608 assert((
IN_RANGE(from[i], old_base,
sizeof(*old_base)) ||
1620 for (i = 0; i < count; i++) {
1621 if (to[i] && !from[i]) {
1623 }
else if (from[i] && !to[i]) {
1630 memcpy(to[i], from[i], size);
1655 #define copy_fields(to, from, start_field, end_field) \
1656 memcpy(&to->start_field, &from->start_field, \
1657 (char *)&to->end_field - (char *)&to->start_field)
1668 int context_reinitialized = 0;
1671 if (dst == src || !h1->context_initialized)
1675 (h->
width != h1->width ||
1676 h->
height != h1->height ||
1690 h->
width = h1->width;
1702 context_reinitialized = 1;
1720 memcpy(h, h1,
sizeof(*h1));
1723 memset(&h->
er, 0,
sizeof(h->
er));
1724 memset(&h->
me, 0,
sizeof(h->
me));
1725 memset(&h->
mb, 0,
sizeof(h->
mb));
1752 for (i = 0; i < 2; i++) {
1777 if (h1->DPB[i].f.buf[0] &&
1784 if (h1->cur_pic.f.buf[0]) {
1805 (
void **)h1->sps_buffers,
1810 (
void **)h1->pps_buffers,
1817 copy_fields(h, h1, dequant4_buffer, dequant4_coeff);
1819 for (i = 0; i < 6; i++)
1821 (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]);
1823 for (i = 0; i < 6; i++)
1825 (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]);
1842 if (context_reinitialized)
1904 for (i = 0; i < 16; i++) {
1908 for (i = 0; i < 16; i++) {
1959 int i, pics, out_of_order, out_idx;
1960 int invalid = 0, cnt = 0;
2123 invalid += out->
poc == INT_MIN;
2126 cnt + invalid == MAX_DELAYED_PIC_COUNT && cnt > 0) {
2135 invalid = MAX_DELAYED_PIC_COUNT;
2139 for (i = 1; i < MAX_DELAYED_PIC_COUNT &&
2158 if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
2178 sizeof(*h->
last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
2216 int linesize,
int uvlinesize,
2226 src_cb -= uvlinesize;
2227 src_cr -= uvlinesize;
2233 AV_COPY128(top_border, src_y + 15 * linesize);
2235 AV_COPY128(top_border + 16, src_y + 15 * linesize + 16);
2239 AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
2240 AV_COPY128(top_border + 48, src_cb + 15 * uvlinesize + 16);
2241 AV_COPY128(top_border + 64, src_cr + 15 * uvlinesize);
2242 AV_COPY128(top_border + 80, src_cr + 15 * uvlinesize + 16);
2244 AV_COPY128(top_border + 16, src_cb + 15 * uvlinesize);
2245 AV_COPY128(top_border + 32, src_cr + 15 * uvlinesize);
2247 }
else if (chroma422) {
2249 AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
2250 AV_COPY128(top_border + 48, src_cr + 15 * uvlinesize);
2252 AV_COPY64(top_border + 16, src_cb + 15 * uvlinesize);
2253 AV_COPY64(top_border + 24, src_cr + 15 * uvlinesize);
2257 AV_COPY128(top_border + 32, src_cb + 7 * uvlinesize);
2258 AV_COPY128(top_border + 48, src_cr + 7 * uvlinesize);
2260 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
2261 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
2275 AV_COPY128(top_border, src_y + 16 * linesize);
2277 AV_COPY128(top_border + 16, src_y + 16 * linesize + 16);
2282 AV_COPY128(top_border + 32, src_cb + 16 * linesize);
2283 AV_COPY128(top_border + 48, src_cb + 16 * linesize + 16);
2284 AV_COPY128(top_border + 64, src_cr + 16 * linesize);
2285 AV_COPY128(top_border + 80, src_cr + 16 * linesize + 16);
2287 AV_COPY128(top_border + 16, src_cb + 16 * linesize);
2288 AV_COPY128(top_border + 32, src_cr + 16 * linesize);
2290 }
else if (chroma422) {
2292 AV_COPY128(top_border + 32, src_cb + 16 * uvlinesize);
2293 AV_COPY128(top_border + 48, src_cr + 16 * uvlinesize);
2295 AV_COPY64(top_border + 16, src_cb + 16 * uvlinesize);
2296 AV_COPY64(top_border + 24, src_cr + 16 * uvlinesize);
2300 AV_COPY128(top_border + 32, src_cb + 8 * uvlinesize);
2301 AV_COPY128(top_border + 48, src_cr + 8 * uvlinesize);
2303 AV_COPY64(top_border + 16, src_cb + 8 * uvlinesize);
2304 AV_COPY64(top_border + 24, src_cr + 8 * uvlinesize);
2312 int linesize,
int uvlinesize,
2313 int xchg,
int chroma444,
2314 int simple,
int pixel_shift)
2316 int deblock_topleft;
2335 deblock_topleft = (h->
mb_x > 0);
2339 src_y -= linesize + 1 + pixel_shift;
2340 src_cb -= uvlinesize + 1 + pixel_shift;
2341 src_cr -= uvlinesize + 1 + pixel_shift;
2346 #define XCHG(a, b, xchg) \
2347 if (pixel_shift) { \
2349 AV_SWAP64(b + 0, a + 0); \
2350 AV_SWAP64(b + 8, a + 8); \
2360 if (deblock_topleft) {
2361 XCHG(top_border_m1 + (8 << pixel_shift),
2362 src_y - (7 << pixel_shift), 1);
2364 XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
2365 XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
2368 src_y + (17 << pixel_shift), 1);
2374 if (deblock_topleft) {
2375 XCHG(top_border_m1 + (24 << pixel_shift), src_cb - (7 << pixel_shift), 1);
2376 XCHG(top_border_m1 + (40 << pixel_shift), src_cr - (7 << pixel_shift), 1);
2378 XCHG(top_border + (16 << pixel_shift), src_cb + (1 << pixel_shift), xchg);
2379 XCHG(top_border + (24 << pixel_shift), src_cb + (9 << pixel_shift), 1);
2380 XCHG(top_border + (32 << pixel_shift), src_cr + (1 << pixel_shift), xchg);
2381 XCHG(top_border + (40 << pixel_shift), src_cr + (9 << pixel_shift), 1);
2383 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
2384 XCHG(h->
top_borders[top_idx][h->
mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
2389 if (deblock_topleft) {
2390 XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
2391 XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
2393 XCHG(top_border + (16 << pixel_shift), src_cb + 1 + pixel_shift, 1);
2394 XCHG(top_border + (24 << pixel_shift), src_cr + 1 + pixel_shift, 1);
2403 if (high_bit_depth) {
2410 int index,
int value)
2412 if (high_bit_depth) {
2419 int mb_type,
int is_h264,
2421 int transform_bypass,
2431 block_offset += 16 * p;
2434 if (transform_bypass) {
2441 for (i = 0; i < 16; i += 4) {
2442 uint8_t *
const ptr = dest_y + block_offset[i];
2445 h->
hpc.
pred8x8l_add[dir](ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
2451 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
2452 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
2454 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
2459 if (transform_bypass) {
2466 for (i = 0; i < 16; i++) {
2467 uint8_t *
const ptr = dest_y + block_offset[i];
2471 h->
hpc.
pred4x4_add[dir](ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
2478 assert(h->
mb_y || linesize <= block_offset[i]);
2479 if (!topright_avail) {
2481 tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
2482 topright = (
uint8_t *)&tr_high;
2484 tr = ptr[3 - linesize] * 0x01010101u;
2488 topright = ptr + (4 << pixel_shift) - linesize;
2492 h->
hpc.
pred4x4[dir](ptr, topright, linesize);
2496 if (nnz == 1 &&
dctcoef_get(h->
mb, pixel_shift, i * 16 + p * 256))
2497 idct_dc_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
2499 idct_add(ptr, h->
mb + (i * 16 + p * 256 << pixel_shift), linesize);
2510 if (!transform_bypass)
2515 static const uint8_t dc_mapping[16] = {
2516 0 * 16, 1 * 16, 4 * 16, 5 * 16,
2517 2 * 16, 3 * 16, 6 * 16, 7 * 16,
2518 8 * 16, 9 * 16, 12 * 16, 13 * 16,
2519 10 * 16, 11 * 16, 14 * 16, 15 * 16
2521 for (i = 0; i < 16; i++)
2523 pixel_shift, dc_mapping[i],
2535 int is_h264,
int simple,
2536 int transform_bypass,
2544 block_offset += 16 * p;
2548 if (transform_bypass) {
2553 h->
mb + (p * 256 << pixel_shift),
2556 for (i = 0; i < 16; i++)
2560 h->
mb + (i * 16 + p * 256 << pixel_shift),
2565 h->
mb + (p * 256 << pixel_shift),
2569 }
else if (h->
cbp & 15) {
2570 if (transform_bypass) {
2571 const int di =
IS_8x8DCT(mb_type) ? 4 : 1;
2574 for (i = 0; i < 16; i += di)
2577 h->
mb + (i * 16 + p * 256 << pixel_shift),
2582 h->
mb + (p * 256 << pixel_shift),
2587 h->
mb + (p * 256 << pixel_shift),
2593 for (i = 0; i < 16; i++)
2596 uint8_t *
const ptr = dest_y + block_offset[i];
2618 const int mb_xy = h->
mb_xy;
2625 hl_decode_mb_444_complex(h);
2627 hl_decode_mb_444_simple_8(h);
2628 }
else if (is_complex) {
2629 hl_decode_mb_complex(h);
2631 hl_decode_mb_simple_16(h);
2633 hl_decode_mb_simple_8(h);
2639 int luma_def, chroma_def;
2649 for (list = 0; list < 2; list++) {
2652 for (i = 0; i < h->
ref_count[list]; i++) {
2653 int luma_weight_flag, chroma_weight_flag;
2656 if (luma_weight_flag) {
2671 if (chroma_weight_flag) {
2673 for (j = 0; j < 2; j++) {
2684 for (j = 0; j < 2; j++) {
2705 int ref0, ref1, i, cur_poc, ref_start, ref_count0, ref_count1;
2707 for (i = 0; i < 2; i++) {
2739 for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
2741 for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
2745 int td = av_clip(poc1 - poc0, -128, 127);
2747 int tb = av_clip(cur_poc - poc0, -128, 127);
2748 int tx = (16384 + (
FFABS(td) >> 1)) / td;
2749 int dist_scale_factor = (tb * tx + 32) >> 8;
2750 if (dist_scale_factor >= -64 && dist_scale_factor <= 128)
2751 w = 64 - dist_scale_factor;
2855 int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
2866 expected_delta_per_poc_cycle = 0;
2871 if (abs_frame_num > 0) {
2875 expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
2876 for (i = 0; i <= frame_num_in_poc_cycle; i++)
2884 field_poc[0] = expectedpoc + h->
delta_poc[0];
2900 pic_field_poc[0] = field_poc[0];
2902 pic_field_poc[1] = field_poc[1];
2903 *pic_poc =
FFMIN(pic_field_poc[0], pic_field_poc[1]);
2914 for (i = 0; i < 16; i++) {
2915 #define T(x) (x >> 2) | ((x << 2) & 0xF)
2920 for (i = 0; i < 64; i++) {
2921 #define T(x) (x >> 3) | ((x & 7) << 3)
2969 "hardware accelerator failed to decode picture\n");
3059 "Reenabling low delay requires a codec flush.\n");
3167 if (width <= 0 || height <= 0) {
3230 " reducing to %d\n", nb_slices, max_slices);
3231 nb_slices = max_slices;
3293 int ref_count[2], list_count;
3294 int num_ref_idx_active_override_flag, max_refs;
3303 num_ref_idx_active_override_flag =
get_bits1(&h->
gb);
3305 if (num_ref_idx_active_override_flag) {
3307 if (ref_count[0] < 1)
3311 if (ref_count[1] < 1)
3322 ref_count[0] = ref_count[1] = 0;
3327 if (ref_count[0] > max_refs || ref_count[1] > max_refs) {
3357 unsigned int first_mb_in_slice;
3358 unsigned int pps_id;
3360 unsigned int slice_type, tmp, i, j;
3361 int default_ref_list_done = 0;
3362 int last_pic_structure, last_pic_droppable;
3363 int needs_reinit = 0;
3364 int field_pic_flag, bottom_field_flag;
3371 if (first_mb_in_slice == 0) {
3387 if (slice_type > 9) {
3389 "slice type %d too large at %d %d\n",
3393 if (slice_type > 4) {
3402 default_ref_list_done = 1;
3423 "non-existing PPS %u referenced\n",
3431 "non-existing SPS %u referenced\n",
3510 "h264_slice_header_init() failed\n");
3517 "Cannot (re-)initialize context during parallel decoding.\n");
3527 "h264_slice_header_init() failed\n");
3548 if (field_pic_flag) {
3562 "Changing field mode (%d -> %d) between slices is not allowed\n",
3569 "unset cur_pic_ptr on slice %d\n",
3580 if (unwrap_prev_frame_num > h->
frame_num)
3581 unwrap_prev_frame_num -= max_frame_num;
3585 if (unwrap_prev_frame_num < 0)
3586 unwrap_prev_frame_num += max_frame_num;
3606 if (!last_pic_droppable && last_pic_structure !=
PICT_FRAME) {
3616 if (!last_pic_droppable && last_pic_structure !=
PICT_FRAME) {
3627 "Invalid field mode combination %d/%d\n",
3632 }
else if (last_pic_droppable != h->
droppable) {
3634 "Found reference and non-reference fields in the same frame, which");
3734 first_mb_in_slice >= h->
mb_num) {
3779 default_ref_list_done = 0;
3781 if (!default_ref_list_done)
3801 for (i = 0; i < 2; i++) {
3865 "deblocking_filter_idc %u out of range\n", tmp);
3880 "deblocking filter parameters %d %d out of range\n",
3905 "Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
3910 "Deblocking switched inside frame.\n");
3926 "Too many slices, increase MAX_SLICES and recompile\n");
3929 for (j = 0; j < 2; j++) {
3932 for (i = 0; i < 16; i++) {
3934 if (j < h->list_count && i < h->ref_count[j] &&
3953 for (i = 0; i < 16; i++)
3956 ref2frm[18 + 1] = -1;
3957 for (i = 16; i < 48; i++)
3958 ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
3964 "slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
4005 int mb_type,
int top_xy,
4008 int left_type[LEFT_MBS],
4009 int mb_xy,
int list)
4016 const int b_xy = h->
mb2b_xy[top_xy] + 3 * b_stride;
4017 const int b8_xy = 4 * top_xy + 2;
4020 ref_cache[0 - 1 * 8] =
4021 ref_cache[1 - 1 * 8] = ref2frm[list][h->
cur_pic.
ref_index[list][b8_xy + 0]];
4022 ref_cache[2 - 1 * 8] =
4023 ref_cache[3 - 1 * 8] = ref2frm[list][h->
cur_pic.
ref_index[list][b8_xy + 1]];
4032 const int b8_xy = 4 * left_xy[
LTOP] + 1;
4039 ref_cache[-1 + 8] = ref2frm[list][h->
cur_pic.
ref_index[list][b8_xy + 2 * 0]];
4040 ref_cache[-1 + 16] =
4041 ref_cache[-1 + 24] = ref2frm[list][h->
cur_pic.
ref_index[list][b8_xy + 2 * 1]];
4049 ref_cache[-1 + 16] =
4067 uint32_t ref01 = (
pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101;
4068 uint32_t ref23 = (
pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101;
4069 AV_WN32A(&ref_cache[0 * 8], ref01);
4070 AV_WN32A(&ref_cache[1 * 8], ref01);
4071 AV_WN32A(&ref_cache[2 * 8], ref23);
4072 AV_WN32A(&ref_cache[3 * 8], ref23);
4077 AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride);
4078 AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride);
4079 AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride);
4080 AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride);
4090 const int mb_xy = h->
mb_xy;
4101 left_xy[
LBOT] = left_xy[
LTOP] = mb_xy - 1;
4106 if (left_mb_field_flag != curr_mb_field_flag)
4109 if (curr_mb_field_flag)
4112 if (left_mb_field_flag != curr_mb_field_flag)
4126 if (qp <= qp_thresh &&
4127 (left_xy[
LTOP] < 0 ||
4133 if ((left_xy[
LTOP] < 0 ||
4148 left_type[
LTOP] = left_type[
LBOT] = 0;
4153 left_type[
LTOP] = left_type[
LBOT] = 0;
4163 top_type, left_type, mb_xy, 0);
4166 top_type, left_type, mb_xy, 1);
4170 AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]);
4171 AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]);
4172 AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]);
4173 AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]);
4178 AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]);
4181 if (left_type[
LTOP]) {
4183 nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4];
4184 nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4];
4185 nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4];
4186 nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4];
4193 nnz_cache[4 + 8 * 0] =
4194 nnz_cache[5 + 8 * 0] = (h->
cbp_table[top_xy] & 0x4000) >> 12;
4195 nnz_cache[6 + 8 * 0] =
4196 nnz_cache[7 + 8 * 0] = (h->
cbp_table[top_xy] & 0x8000) >> 12;
4199 nnz_cache[3 + 8 * 1] =
4200 nnz_cache[3 + 8 * 2] = (h->
cbp_table[left_xy[
LTOP]] & 0x2000) >> 12;
4203 nnz_cache[3 + 8 * 3] =
4204 nnz_cache[3 + 8 * 4] = (h->
cbp_table[left_xy[
LBOT]] & 0x8000) >> 12;
4208 nnz_cache[
scan8[0]] =
4209 nnz_cache[scan8[1]] =
4210 nnz_cache[scan8[2]] =
4211 nnz_cache[scan8[3]] = (h->
cbp & 0x1000) >> 12;
4213 nnz_cache[scan8[0 + 4]] =
4214 nnz_cache[scan8[1 + 4]] =
4215 nnz_cache[scan8[2 + 4]] =
4216 nnz_cache[scan8[3 + 4]] = (h->
cbp & 0x2000) >> 12;
4218 nnz_cache[scan8[0 + 8]] =
4219 nnz_cache[scan8[1 + 8]] =
4220 nnz_cache[scan8[2 + 8]] =
4221 nnz_cache[scan8[3 + 8]] = (h->
cbp & 0x4000) >> 12;
4223 nnz_cache[scan8[0 + 12]] =
4224 nnz_cache[scan8[1 + 12]] =
4225 nnz_cache[scan8[2 + 12]] =
4226 nnz_cache[scan8[3 + 12]] = (h->
cbp & 0x8000) >> 12;
4235 uint8_t *dest_y, *dest_cb, *dest_cr;
4236 int linesize, uvlinesize, mb_x, mb_y;
4243 for (mb_x = start_x; mb_x < end_x; mb_x++)
4244 for (mb_y = end_mb_y -
FRAME_MBAFF(h); mb_y <= end_mb_y; mb_y++) {
4258 ((mb_x << pixel_shift) + mb_y * h->
linesize) * 16;
4260 (mb_x << pixel_shift) * (8 <<
CHROMA444(h)) +
4263 (mb_x << pixel_shift) * (8 <<
CHROMA444(h)) +
4288 linesize, uvlinesize);
4291 dest_cr, linesize, uvlinesize);
4323 if ((top + height) >= pic_height)
4324 height += deblock_border;
4325 top -= deblock_border;
4328 if (top >= pic_height || (top + height) < 0)
4331 height =
FFMIN(height, pic_height - top);
4347 int endx,
int endy,
int status)
4349 #if CONFIG_ERROR_RESILIENCE
4360 int lf_x_start = h->
mb_x;
4404 if (h->
mb_x >= lf_x_start)
4410 "error while decoding MB %d %d, bytestream %td\n",
4420 h->
mb_x = lf_x_start = 0;
4435 if (h->
mb_x > lf_x_start)
4459 "error while decoding MB %d %d\n", h->
mb_x, h->
mb_y);
4467 h->
mb_x = lf_x_start = 0;
4503 if (h->
mb_x > lf_x_start)
4532 "Input contains more MB rows than the frame height.\n");
4538 if (context_count == 1) {
4541 for (i = 1; i < context_count; i++) {
4547 NULL, context_count,
sizeof(
void *));
4555 for (i = 1; i < context_count; i++)
4563 int parse_extradata)
4568 unsigned context_count;
4571 int nals_needed = 0;
4583 for (; pass <= 1; pass++) {
4586 next_avc = h->
is_avc ? 0 : buf_size;
4596 if (buf_index >= next_avc) {
4601 nalsize = (nalsize << 8) | buf[buf_index++];
4602 if (nalsize <= 0 || nalsize > buf_size - buf_index) {
4604 "AVC: nal size %d\n", nalsize);
4607 next_avc = buf_index + nalsize;
4610 for (; buf_index + 3 < next_avc; buf_index++)
4612 if (buf[buf_index] == 0 &&
4613 buf[buf_index + 1] == 0 &&
4614 buf[buf_index + 2] == 1)
4617 if (buf_index + 3 >= buf_size) {
4618 buf_index = buf_size;
4623 if (buf_index >= next_avc)
4630 &consumed, next_avc - buf_index);
4631 if (ptr ==
NULL || dst_length < 0) {
4635 i = buf_index + consumed;
4637 buf[i] == 0x00 && buf[i + 1] == 0x00 &&
4638 buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
4642 while (dst_length > 0 && ptr[dst_length - 1] == 0)
4644 bit_length = !dst_length ? 0
4650 "NAL %d at %d/%d length %d\n",
4653 if (h->
is_avc && (nalsize != consumed) && nalsize)
4655 "AVC: Consumed only %d bytes instead of %d\n",
4658 buf_index += consumed;
4669 nals_needed = nal_index;
4676 nals_needed = nal_index;
4697 "Ignoring NAL unit %d during extradata parsing\n",
4706 "Invalid mix of idr and non-idr slices\n");
4759 &buf[buf_index - consumed],
4770 "Decoding in chunks is not supported for "
4771 "partitioned slices.\n");
4816 if (ret < 0 && h->is_avc && (nalsize != consumed) && nalsize) {
4818 "SPS decoding failure, trying again with the complete NAL\n");
4855 }
else if (err == 1) {
4877 return (ret < 0) ? ret : buf_index;
4887 if (pos + 10 > buf_size)
4903 for (i = 0; i < 3; i++) {
4908 dst->
data[i] += off;
4917 int buf_size = avpkt->
size;
4930 if (buf_size == 0) {
4998 assert(pict->
buf[0] || !*got_frame);
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free
Picture default_ref_list[2][32]
base reference list for all slices of a coded picture
#define PICT_BOTTOM_FIELD
#define FF_PROFILE_H264_MAIN
void ff_h264_direct_dist_scale_factor(H264Context *const h)
int video_signal_type_present_flag
void(* h264_idct_add)(uint8_t *dst, int16_t *block, int stride)
int ff_h264_decode_mb_cabac(H264Context *h)
Decode a CABAC coded macroblock.
static void clone_tables(H264Context *dst, H264Context *src, int i)
Mimic alloc_tables(), but for every context thread.
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int ff_h264_decode_seq_parameter_set(H264Context *h)
Decode SPS.
discard all frames except keyframes
uint8_t * edge_emu_buffer
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
void(* prefetch)(uint8_t *buf, ptrdiff_t stride, int h)
Prefetch memory into cache (if supported by hardware).
#define MAX_PICTURE_COUNT
unsigned int top_samples_available
#define FF_PROFILE_H264_CAVLC_444
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size, int parse_extradata)
unsigned int topleft_samples_available
int single_decode_warning
1 if the single thread fallback warning has already been displayed, 0 otherwise.
#define CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
Views are packed per line, as if interlaced.
#define AV_NUM_DATA_POINTERS
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG2 field pics)
5: top field, bottom field, top field repeated, in that order
static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
GetBitContext * intra_gb_ptr
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
void(* pred8x8l_add[2])(uint8_t *pix, int16_t *block, ptrdiff_t stride)
Views are alternated temporally.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
int coded_width
Bitstream width / height, may be different from width/height e.g.
3: top field, bottom field, in that order
const uint8_t * ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length)
Decode a network abstraction layer unit.
static const uint8_t field_scan8x8_cavlc[64]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Views are next to each other, but when upscaling apply a checkerboard pattern.
#define AV_LOG_WARNING
Something somehow does not look correct.
int chroma_qp_index_offset[2]
const uint8_t * bytestream_end
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
H264ChromaContext h264chroma
av_cold int ff_h264_decode_init(AVCodecContext *avctx)
int luma_weight_flag[2]
7.4.3.2 luma_weight_lX_flag
MMCO mmco[MAX_MMCO_COUNT]
memory management control operations buffer.
void ff_er_frame_end(ERContext *s)
static av_always_inline void mc_part_weighted(H264Context *h, int n, int square, int height, int delta, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int x_offset, int y_offset, qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, h264_weight_func luma_weight_op, h264_weight_func chroma_weight_op, h264_biweight_func luma_weight_avg, h264_biweight_func chroma_weight_avg, int list0, int list1, int pixel_shift, int chroma_idc)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
static void init_dequant_tables(H264Context *h)
int bitstream_restriction_flag
#define FF_PROFILE_H264_INTRA
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
static enum AVPixelFormat get_pixel_format(H264Context *h)
int repeat_pict
When decoding, this signals how much the picture must be delayed.
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
static void unref_picture(H264Context *h, Picture *pic)
#define AV_PIX_FMT_GBRP10
AVBufferPool * mb_type_pool
HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the b...
int field_picture
whether or not the picture was encoded in separate fields
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static void release_unused_pictures(H264Context *h, int remove_current)
const uint8_t * field_scan8x8_q0
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int is_avc
Used to parse AVC variant of h264.
static av_always_inline void fill_filter_caches_inter(H264Context *h, int mb_type, int top_xy, int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
AVBufferPool * ref_index_pool
static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
uint8_t zigzag_scan8x8_cavlc[64]
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
int ff_h264_get_profile(SPS *sps)
Compute profile from profile_idc and constraint_set?_flags.
uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64]
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
void ff_h264_decode_init_vlc(void)
static int context_init(H264Context *h)
Init context Allocate buffers which are not shared amongst multiple threads.
int mmco_reset
h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET...
int prev_poc_msb
poc_msb of the last reference pic for POC type 0
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
uint32_t num_units_in_tick
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
4: bottom field, top field, in that order
#define FRAME_RECOVERED_IDR
We have seen an IDR, so all the following frames in coded order are correctly decodable.
static int get_lowest_part_list_y(H264Context *h, Picture *pic, int n, int height, int y_offset, int list)
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
static const uint8_t rem6[QP_MAX_NUM+1]
static av_always_inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op, int pixel_shift, int chroma_idc)
#define CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
static av_always_inline uint32_t pack16to32(int a, int b)
void(* h264_add_pixels4_clear)(uint8_t *dst, int16_t *block, int stride)
static const uint8_t zigzag_scan[16]
int recovered
Picture at IDR or recovery point + recovery count.
void ff_h264_init_cabac_states(H264Context *h)
#define USES_LIST(a, list)
does this mb use listX, note does not work if subMBs
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
uint8_t * chroma_pred_mode_table
#define IS_DIR(a, part, list)
static const uint8_t div6[QP_MAX_NUM+1]
void(* pred16x16_add[3])(uint8_t *pix, const int *block_offset, int16_t *block, ptrdiff_t stride)
enum AVDiscard skip_frame
int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
static const uint8_t golomb_to_pict_type[5]
int ref_poc[2][2][32]
h264 POCs of the frames used as reference (FIXME need per slice)
void(* h264_idct_add16)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
struct AVHWAccel * hwaccel
Hardware accelerator in use.
unsigned int crop_top
frame_cropping_rect_top_offset
int long_ref
1->long term reference 0->short term reference
static av_always_inline void hl_decode_mb_idct_luma(H264Context *h, int mb_type, int is_h264, int simple, int transform_bypass, int pixel_shift, int *block_offset, int linesize, uint8_t *dest_y, int p)
static int decode_init_thread_copy(AVCodecContext *avctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint8_t scaling_matrix4[6][16]
const uint8_t * bytestream
int ref2frm[MAX_SLICES][2][64]
reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 ...
int deblocking_filter_parameters_present
deblocking_filter_parameters_present_flag
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
#define FF_PROFILE_H264_BASELINE
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint32_t(*[6] dequant4_coeff)[16]
#define CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries...
av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
int ref_count[2][2]
number of entries in ref_poc (FIXME need per slice)
int prev_frame_num_offset
for POC type 2
unsigned int crop_left
frame_cropping_rect_left_offset
int offset_for_non_ref_pic
void ff_h264_reset_sei(H264Context *h)
Reset SEI values at the beginning of the frame.
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
int luma_weight[48][2][2]
int bit_depth_chroma
bit_depth_chroma_minus8 + 8
#define FF_DEBUG_PICT_INFO
enum AVColorPrimaries color_primaries
static int find_unused_picture(H264Context *h)
Multithreading support functions.
Picture ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
static const uint8_t field_scan8x8[64]
int cabac
entropy_coding_mode_flag
qpel_mc_func(* qpel_put)[16]
#define LUMA_DC_BLOCK_INDEX
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
unsigned int crop_right
frame_cropping_rect_right_offset
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
void ff_h264_fill_mbaff_ref_list(H264Context *h)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int frame_recovered
Initial frame has been completely recovered.
int transform_bypass
qpprime_y_zero_transform_bypass_flag
void(* h264_add_pixels8_clear)(uint8_t *dst, int16_t *block, int stride)
static int get_bits_count(const GetBitContext *s)
static int decode_rbsp_trailing(H264Context *h, const uint8_t *src)
Identify the exact end of the bitstream.
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
int ff_h264_get_slice_type(const H264Context *h)
Reconstruct bitstream slice_type.
int redundant_pic_cnt_present
redundant_pic_cnt_present_flag
#define FF_PROFILE_H264_EXTENDED
AVBufferRef * mb_type_buf
int interlaced_frame
The content of the picture is interlaced.
#define MAX_DELAYED_PIC_COUNT
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
void(* pred4x4[9+3+3])(uint8_t *src, const uint8_t *topright, ptrdiff_t stride)
Picture * next_output_pic
high precision timer, useful to profile code
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int luma_log2_weight_denom
qpel_mc_func avg_h264_qpel_pixels_tab[4][16]
static int h264_set_parameter_from_sps(H264Context *h)
int chroma_weight[48][2][2][2]
int last_pocs[MAX_DELAYED_PIC_COUNT]
static void init_dequant4_coeff_table(H264Context *h)
static int pic_is_unused(H264Context *h, Picture *pic)
const uint8_t * zigzag_scan8x8_cavlc_q0
H.264 / AVC / MPEG4 part10 codec.
static int get_bits_left(GetBitContext *gb)
int mb_aff
mb_adaptive_frame_field_flag
enum AVColorTransferCharacteristic color_trc
static int output_frame(H264Context *h, AVFrame *dst, AVFrame *src)
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
Check if the top & left blocks are available if needed and change the dc mode so it only uses the ava...
#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.
int flags
Additional information about the frame packing.
int16_t mb_luma_dc[3][16 *2]
static enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[]
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static int decode_slice_header(H264Context *h, H264Context *h0)
Decode a slice header.
static int get_consumed_bytes(int pos, int buf_size)
Return the number of bytes consumed for building the current frame.
const uint8_t * zigzag_scan_q0
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
int poc_type
pic_order_cnt_type
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
static const uint8_t dequant8_coeff_init_scan[16]
void(* h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height, int log2_denom, int weightd, int weights, int offset)
static const uint16_t mask[17]
void ff_h264_hl_decode_mb(H264Context *h)
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
ParseContext parse_context
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
discard all bidirectional frames
void ff_h264_direct_ref_list_init(H264Context *const h)
static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale)
Get the chroma qp.
GetBitContext * inter_gb_ptr
#define ALZHEIMER_DC_L0T_PRED8x8
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Picture * delayed_pic[MAX_DELAYED_PIC_COUNT+2]
int active_thread_type
Which multithreading methods are in use by the codec.
int mb_field_decoding_flag
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
static void flush_dpb(AVCodecContext *avctx)
static int h264_slice_header_init(H264Context *, int)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void(* h264_idct8_add)(uint8_t *dst, int16_t *block, int stride)
void(* decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
uint8_t(*[2] mvd_table)[2]
#define FF_PROFILE_H264_HIGH_422
int prev_interlaced_frame
Complement sei_pic_struct SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced...
#define FF_PROFILE_H264_HIGH
struct Picture * next_pic
int direct_spatial_mv_pred
static int h264_frame_start(H264Context *h)
void(* h264_luma_dc_dequant_idct)(int16_t *output, int16_t *input, int qmul)
simple assert() macros that are a bit more flexible than ISO C assert().
int weighted_pred
weighted_pred_flag
int overread_index
the index into ParseContext.buffer of the overread bytes
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
static void predict_field_decoding_flag(H264Context *h)
void ff_init_cabac_states(void)
int ff_h264_decode_mb_cavlc(H264Context *h)
Decode a macroblock.
Video is not stereoscopic (and metadata has to be there).
uint8_t * list_counts
Array of list_count per MB specifying the slice type.
static void er_add_slice(H264Context *h, int startx, int starty, int endx, int endy, int status)
qpel_mc_func put_h264_qpel_pixels_tab[4][16]
int delta_pic_order_always_zero_flag
#define CODEC_FLAG_LOW_DELAY
Force low delay.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int new
flag to keep track if the decoder context needs re-init due to changed SPS
int offset_for_top_to_bottom_field
#define IN_RANGE(a, b, size)
#define FIELD_OR_MBAFF_PICTURE(h)
int priv_data_size
Size of HW accelerator private data.
uint8_t zigzag_scan8x8[64]
static int execute_decode_slices(H264Context *h, unsigned context_count)
Call decode_slice() for each context.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static const uint8_t scan8[16 *3+3]
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
the normal 2^n-1 "JPEG" YUV ranges
int crop
frame_cropping_flag
uint8_t * error_status_table
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
AVBufferRef * hwaccel_priv_buf
int ff_pred_weight_table(H264Context *h)
static av_always_inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int chroma444, int simple, int pixel_shift)
uint8_t scaling_matrix8[6][64]
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static void copy_picture_range(Picture **to, Picture **from, int count, H264Context *new_base, H264Context *old_base)
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc)
useful rectangle filling function
the normal 219*2^(n-8) "MPEG" YUV ranges
#define AV_PIX_FMT_YUV422P9
int refs
number of reference frames
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
unsigned int left_samples_available
AVBufferRef * motion_val_buf[2]
static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, 'draw_horiz_band' is called by the libavcodec decoder to draw a horizontal band...
int ref_frame_count
num_ref_frames
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
enum AVPictureType pict_type
Picture type of the frame.
void ff_h264_filter_mb(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize)
struct Picture * last_pic
int frame_num_offset
for POC type 2
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define FF_THREAD_FRAME
Decode more than one frame at once.
int overread
the number of bytes which where irreversibly read from the next frame
uint16_t * slice_table
slice_table_base + 2*mb_stride + 1
av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
uint8_t field_scan8x8_cavlc[64]
int poc_cycle_length
num_ref_frames_in_pic_order_cnt_cycle
int colour_description_present_flag
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int sei_frame_packing_present
frame_packing_arrangment SEI message
int width
picture width / height.
int16_t(*[2] motion_val)[2]
#define FF_PROFILE_UNKNOWN
void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
int long_ref_count
number of actual long term references
void(* h264_idct_dc_add)(uint8_t *dst, int16_t *block, int stride)
static void implicit_weight_table(H264Context *h, int field)
Initialize implicit_weight table.
void * hwaccel_picture_private
hardware accelerator private data
static av_always_inline int dctcoef_get(int16_t *mb, int high_bit_depth, int index)
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
PPS * pps_buffers[MAX_PPS_COUNT]
static av_always_inline void prefetch_motion(H264Context *h, int list, int pixel_shift, int chroma_idc)
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color)
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
Decode PPS.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
Context Adaptive Binary Arithmetic Coder inline functions.
int init_qp
pic_init_qp_minus26 + 26
int frame_num
h264 frame_num (raw frame_num from slice header)
int8_t intra4x4_pred_mode_cache[5 *8]
uint8_t * bipred_scratchpad
int max_pic_num
max_frame_num or 2 * max_frame_num for field pics.
void(* pred4x4_add[2])(uint8_t *pix, int16_t *block, ptrdiff_t stride)
static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
static int decode_slice(struct AVCodecContext *avctx, void *arg)
int ff_set_ref_count(H264Context *h)
unsigned int topright_samples_available
const uint8_t * zigzag_scan8x8_q0
int curr_pic_num
frame_num for frames or 2 * frame_num + 1 for field pics.
static void init_scan_tables(H264Context *h)
initialize scan tables
static int av_unused get_cabac_terminate(CABACContext *c)
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
#define AV_PIX_FMT_YUV444P9
static void loop_filter(H264Context *h, int start_x, int end_x)
av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc)
Set the intra prediction function pointers.
uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16]
#define PART_NOT_AVAILABLE
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
static const uint8_t dequant8_coeff_init[6][6]
if(ac->has_optimized_func)
int dequant_coeff_pps
reinit tables when pps changes
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
int pic_order_present
pic_order_present_flag
SPS * sps_buffers[MAX_SPS_COUNT]
static const int8_t mv[256][2]
struct H264Context * thread_context[MAX_THREADS]
int chroma_log2_weight_denom
int bit_depth_luma
luma bit depth from sps to detect changes
static void flush_change(H264Context *h)
short offset_for_ref_frame[256]
int chroma_format_idc
chroma format from sps to detect changes
int timing_info_present_flag
AVBufferRef * qscale_table_buf
static void decode_finish_row(H264Context *h)
Draw edges and report progress for the last MB row.
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
Execute the reference picture marking (memory management control operations).
int mbaff
h264 1 -> MBAFF frame 0-> not MBAFF
int coded_picture_number
picture number in bitstream order
enum AVStereo3DType type
How views are packed within the video.
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
H264 / AVC / MPEG4 part10 codec data table
#define FF_PROFILE_H264_HIGH_422_INTRA
int slice_alpha_c0_offset
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
void ff_h264_remove_all_refs(H264Context *h)
int prev_frame_num
frame_num of the last pic for POC type 1/2
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int height, int y_offset, int list0, int list1, int *nrefs)
int ff_h264_decode_sei(H264Context *h)
Decode SEI.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
int implicit_weight[48][48][2]
int max_contexts
Max number of threads / contexts.
int recovery_frame
recovery_frame is the frame_num at which the next frame should be fully constructed.
main external API structure.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
static void close(AVCodecParserContext *s)
int ff_h264_check_intra4x4_pred_mode(H264Context *h)
Check if the top & left blocks are available if needed and change the dc mode so it only uses the ava...
uint8_t * data
The data buffer.
void(* qpel_mc_func)(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
static void decode_postinit(H264Context *h, int setup_finished)
Run setup operations that must be run after slice header decoding.
int ff_h264_alloc_tables(H264Context *h)
Allocate tables.
int16_t mb[16 *48 *2]
as a dct coeffecient is int32_t in high depth, we need to reserve twice the space.
static void init_dequant8_coeff_table(H264Context *h)
int frame_packing_arrangement_type
uint32_t state
contains the last few bytes in MSB order
void(* pred16x16[4+3+2])(uint8_t *src, ptrdiff_t stride)
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int constraint_set_flags
constraint_set[0-3]_flag
static unsigned int get_bits1(GetBitContext *s)
SEI_PicStructType sei_pic_struct
pic_struct in picture timing SEI message
#define AV_PIX_FMT_YUV420P10
#define FF_PROFILE_H264_HIGH_10_INTRA
int slice_flags
slice flags
void(* h264_idct8_add4)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
static const uint8_t zigzag_scan8x8_cavlc[64]
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
const uint8_t * field_scan8x8_cavlc_q0
static void idct_add(uint8_t *dest, int line_size, int16_t *block)
uint32_t(*[6] dequant8_coeff)[64]
static av_cold int h264_decode_end(AVCodecContext *avctx)
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
int qp_thresh
QP threshold to skip loopfilter.
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
A reference counted buffer type.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int pixel_shift
0 for 8-bit H264, 1 for high-bit-depth H264
int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb, int first_slice)
static void await_references(H264Context *h)
Wait until all reference frames are available for MC operations.
void(* h264_weight_func)(uint8_t *block, int stride, int height, int log2_denom, int weight, int offset)
int16_t mb_padding[256 *2]
as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too lar...
#define FF_PROFILE_H264_HIGH_444
#define AV_PIX_FMT_YUV420P9
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
int allocate_progress
Whether to allocate progress for frame threading.
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
6: bottom field, top field, bottom field repeated, in that order
static int init_dimensions(H264Context *h)
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
void ff_h264_draw_horiz_band(H264Context *h, int y, int height)
void(* h264_idct8_dc_add)(uint8_t *dst, int16_t *block, int stride)
Views are on top of each other.
int block_offset[2 *(16 *3)]
block_offset[ 0..23] for frame macroblocks block_offset[24..47] for field macroblocks ...
int field_poc[2]
h264 top/bottom POC
#define FF_BUG_AUTODETECT
autodetection
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int transform_8x8_mode
transform_8x8_mode_flag
#define AV_PIX_FMT_YUV422P10
int pic_struct_present_flag
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
av_cold void ff_h264_free_context(H264Context *h)
Free any data that may have been allocated in the H264 context like SPS, PPS etc. ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
qpel_mc_func(* qpel_avg)[16]
void ff_h264_filter_mb_fast(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize)
void(* h264_chroma_mc_func)(uint8_t *dst, uint8_t *src, int srcStride, int h, int x, int y)
static const uint8_t dequant4_coeff_init[6][3]
Views are next to each other.
static void idr(H264Context *h)
instantaneous decoder refresh.
static int field_end(H264Context *h, int in_setup)
hardware decoding through VDA
discard all non reference
AVBufferPool * qscale_table_pool
static enum AVPixelFormat h264_hwaccel_pixfmt_list_420[]
int mb_height
pic_height_in_map_units_minus1 + 1
AVBufferPool * motion_val_pool
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
common internal api header.
const uint8_t ff_zigzag_direct[64]
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
ptrdiff_t mb_linesize
may be equal to s->linesize or s->linesize * 2, for mbaff
#define FRAME_RECOVERED_SEI
Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames...
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
uint16_t * slice_table_base
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
H.264 / AVC / MPEG4 part10 motion vector predicion.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
FF_ENABLE_DEPRECATION_WARNINGS int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
AVHWAccel * ff_find_hwaccel(AVCodecContext *avctx)
Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.
int cur_chroma_format_idc
enum AVDiscard skip_loop_filter
int sei_ct_type
Bit set of clock types for fields/frames in picture timing SEI message.
static av_cold int init(AVCodecParserContext *s)
static av_always_inline void dctcoef_set(int16_t *mb, int high_bit_depth, int index, int value)
int bit_depth_luma
bit_depth_luma_minus8 + 8
static const uint8_t field_scan[16]
int prev_poc_lsb
poc_lsb of the last reference pic for POC type 0
#define FF_DEBUG_STARTCODE
void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int simple)
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.
void(* h264_idct_add16intra)(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 *8])
int top_field_first
If the content is interlaced, is top field displayed first.
const uint16_t ff_h264_mb_sizes[4]
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
int ff_h264_decode_extradata(H264Context *h)
uint8_t(*[2] top_borders)[(16 *3)*2]
struct AVCodecInternal * internal
Private context used for internal data.
static int fill_filter_caches(H264Context *h, int mb_type)
Views are packed in a checkerboard-like structure per pixel.
int pic_id
h264 pic_num (short -> no wrap version of pic_num, pic_num & max_pic_num; long -> long_pic_num) ...
int content_interpretation_type
int key_frame
1 -> keyframe, 0-> not
Views are packed per column.
enum AVPictureType pict_type
int current_slice
current slice number, used to initalize slice_num of each thread/context
static const uint8_t * align_get_bits(GetBitContext *s)
int mb_width
pic_width_in_mbs_minus1 + 1
#define FF_PROFILE_H264_HIGH_444_INTRA
static int copy_parameter_set(void **to, void **from, int count, int size)
#define SLICE_FLAG_CODED_ORDER
draw_horiz_band() is called in coded order instead of display
const uint8_t * field_scan_q0
static void * av_mallocz_array(size_t nmemb, size_t size)
static void free_tables(H264Context *h, int free_rbsp)
int ff_h264_fill_default_ref_list(H264Context *h)
Fill the default_ref_list.
#define REBASE_PICTURE(pic, new_ctx, old_ctx)
void ff_er_frame_start(ERContext *s)
uint8_t field_scan8x8[64]
#define copy_fields(to, from, start_field, end_field)
int chroma_weight_flag[2]
7.4.3.2 chroma_weight_lX_flag
static av_always_inline void mc_part_std(H264Context *h, int n, int square, int height, int delta, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int x_offset, int y_offset, qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, int list0, int list1, int pixel_shift, int chroma_idc)
int8_t * intra4x4_pred_mode
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
static int init_table_pools(H264Context *h)
#define FF_PROFILE_H264_CONSTRAINED
static int ref_picture(H264Context *h, Picture *dst, Picture *src)
#define FF_PROFILE_H264_CONSTRAINED_BASELINE
static int clone_slice(H264Context *dst, H264Context *src)
Replicate H264 "master" context to thread contexts.
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
int deblocking_filter
disable_deblocking_filter_idc with 1 <-> 0
static int alloc_scratch_buffers(H264Context *h, int linesize)
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
static int alloc_picture(H264Context *h, Picture *pic)
uint8_t(* non_zero_count)[48]
#define FF_PROFILE_H264_HIGH_10
unsigned int crop_bottom
frame_cropping_rect_bottom_offset
AVPixelFormat
Pixel format.
This structure stores compressed data.
int sei_recovery_frame_cnt
recovery_frame_cnt from SEI message
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
void(* pred8x8l[9+3])(uint8_t *src, int topleft, int topright, ptrdiff_t stride)
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
unsigned int rbsp_buffer_size[2]
Context Adaptive Binary Arithmetic Coder.
int8_t ref_cache[2][5 *8]
AVBufferRef * ref_index_buf[2]
int mb_mbaff
mb_aff_frame && mb_field_decoding_flag
int short_ref_count
number of actual short term references
static const AVProfile profiles[]
enum AVColorSpace colorspace