99#define MAX_VLC_SIZE 864
105 int counts[17] = {0};
112 codes[0] = counts[0] = 0;
113 for (
int i = 0;
i < 17;
i++)
114 codes[
i+1] = (codes[
i] + counts[
i]) << 1;
126 for (
int i = 0;
i < count;
i++) {
127 for (
int j = 0; j < 2; j++) {
140 for (
int i = 0;
i < 7;
i++)
141 for (
int j = 0; j < 4; j++)
144 for (
int i = 0;
i < 7;
i++)
145 for (
int j = 0; j < 3; j++)
146 for (
int k = 0; k < 4; k++)
235 if (
s->nb_progress < count) {
240 memset(
s->progress +
s->nb_progress, 0, (count -
s->nb_progress) *
sizeof(*
s->progress));
241 for (
int i =
s->nb_progress;
i < count;
i++) {
245 s->nb_progress =
i + 1;
249 for (
int i = 0;
i < count;
i++)
266 for (
int i = 0;
i < 3;
i++) {
268 if (!
s->last_frame[
i])
281 if (
width !=
s->avctx->width ||
height !=
s->avctx->height) {
285 for (
int i = 0;
i < 3;
i++)
291 if (
s->avctx->width <= 64 ||
s->avctx->height <= 64)
292 av_log(
s->avctx,
AV_LOG_WARNING,
"unable to faithfully reproduce emulated edges; expect visual artefacts\n");
298 s->cu_width = (
width + 63) >> 6;
299 s->cu_height = (
height + 63) >> 6;
301 s->pu_stride =
s->cu_width << 3;
302 s->blk_stride =
s->cu_width << 4;
313 memset(
s->pu_info, 0,
s->pu_stride * (
s->cu_height << 3) *
sizeof(
s->pu_info[0]));
314 memset(
s->blk_info, 0,
s->blk_stride * (
s->cu_height << 4) *
sizeof(
s->blk_info[0]));
316 for (
int j = 0; j <
s->cu_height << 4; j++)
317 for (
int i = 0;
i <
s->cu_width << 4;
i++)
323 s->dblk_stride =
s->awidth >> 2;
325 size =
s->dblk_stride * (
s->aheight >> 2);
333 memset(
s->top_str, 0,
size);
334 memset(
s->left_str, 0,
size);
386 for (
int i = 0;
i < count;
i++)
387 for (
int j = 0; j < 2 <<
i; j++)
400 for (
int i = 0;
i <
s->cu_height;
i++)
405 if (last_size < 0 || last_size > INT32_MAX)
408 for (
int i = 1;
i <
s->cu_height;
i++) {
410 if (
s->slice[
i].sign)
414 if (last_size <= 0 || last_size > INT32_MAX)
416 s->slice[
i].size = last_size;
436 return ypos + dy && xpos + dx +
size <=
s->awidth;
441 return xpos + dx && ypos + dy +
size <=
s->aheight;
490 memset(
i->t, 0x80,
sizeof(
i->t));
491 memset(
i->l, 0x80,
sizeof(
i->l));
492 i->has_t =
i->has_tr =
i->has_l =
i->has_ld = 0;
504 if (cu->
ypos + yoff > 0) {
516 if (cu->
xpos + xoff > 0)
520 if (cu->
xpos + xoff > 0) {
523 for (
int y = 0; y <
size; y++)
529 for (
int y =
size; y <
size * 2; y++)
534 if (cu->
ypos + yoff > 0)
541 int lastl = p->l[
size + 1];
542 int lastt = p->t[
size + 1];
543 int tmp1[64], tmp2[64];
544 int top_ref[64], left_ref[64];
547 for (
int i = 0;
i <
size;
i++) {
548 tmp1[
i] = lastl - p->t[
i + 1];
549 tmp2[
i] = lastt - p->l[
i + 1];
553 for (
int i = 0;
i <
size;
i++) {
554 top_ref[
i] = p->t[
i + 1] << (
shift - 1);
555 left_ref[
i] = p->l[
i + 1] << (
shift - 1);
558 for (
int y = 0; y <
size; y++) {
560 int sum = left_ref[y] +
size;
561 for (
int x = 0; x <
size; x++) {
562 int v = tmp1[x] + top_ref[x];
574 if (!p->has_t && !p->has_l)
579 for (
int x = 0; x <
size; x++)
582 for (
int y = 0; y <
size; y++)
584 if (p->has_t && p->has_l)
590 for (
int y = 0; y <
size; y++)
593 if (
filter && p->has_t && p->has_l) {
594 dst[0] = (p->t[1] + p->l[1] + 2 *
dst[0] + 2) >> 2;
595 for (
int x = 1; x <
size; x++)
596 dst[x] = (p->t[x + 1] + 3 *
dst[x] + 2) >> 2;
597 for (
int y = 1; y <
size; y++)
605 for (
int i = 1;
i <
size - 1;
i++)
613 int sum = (v0 << 5) + (1 << (5 - 1));
614 for (
int i = 0;
i <
size;
i++) {
623 for (
int x = 0; x <
size; x++) {
626 off = (sum >> 5) + 32;
629 for (
int y = 0; y <
size; y++)
632 for (
int y = 0; y <
size; y++) {
633 int a =
src[off + y];
634 int b =
src[off + y + 1];
635 dst[y*
stride + x] = ((32 - frac) *
a + frac *
b + 16) >> 5;
644 for (
int y = 0; y <
size; y++) {
647 off = (sum >> 5) + 32;
652 for (
int x = 0; x <
size; x++) {
653 int a =
src[off + x];
654 int b =
src[off + x + 1];
655 dst[y*
stride + x] = ((32 - frac) *
a + frac *
b + 16) >> 5;
663 uint8_t filtered1[96], filtered2[96];
670 }
else if (imode == 1) {
672 }
else if (imode <= 9) {
674 int add_size = (
size * ang_weight + 31) >> 5;
676 const int filtered_size =
size + add_size;
677 if (filtered_size < 1 || filtered_size > 64)
679 filter_weak(filtered1 + 32, &p->l[1], filtered_size);
681 if (add_size < 0 || add_size > 32)
687 }
else if (imode == 10) {
692 for (
int y = 0; y <
size; y++)
693 for (
int x = 0; x <
size; x++)
697 for (
int x = 0; x <
size; x++)
700 }
else if (imode <= 17) {
703 int add_size = (
size * ang_weight + 31) >> 5;
705 memcpy(filtered1 + 32 - 1, p->l,
size + 1);
706 memcpy(filtered2 + 32 - 1, p->t,
size + 1);
708 filtered1[32 - 1] = p->l[0];
710 filtered2[32 - 1] = p->t[0];
715 for (
int i = 1;
i < add_size;
i++) {
717 filtered1[32 - 1 -
i] = filtered2[32 - 1 + (sum >> 8)];
721 }
else if (imode <= 25) {
724 int add_size = (
size * ang_weight + 31) >> 5;
726 memcpy(filtered1 + 32 - 1, p->t,
size + 1);
727 memcpy(filtered2 + 32 - 1, p->l,
size + 1);
729 filtered1[32 - 1] = p->t[0];
731 filtered2[32 - 1] = p->l[0];
736 for (
int i = 1;
i < add_size;
i++) {
738 filtered1[32 - 1 -
i] = filtered2[32 - 1 + (sum >> 8)];
742 }
else if (imode == 26) {
751 for (
int y = 0; y <
size; y++)
754 }
else if (imode <= 34) {
756 int add_size = (
size * ang_weight + 31) >> 5;
758 const int filtered_size =
size + add_size;
759 if (filtered_size < 1 || filtered_size > 64)
761 filter_weak(&filtered1[32], &p->t[1], filtered_size);
763 if (add_size < 0 || add_size > 32)
784#define MK_UNIQUELIST(name, type, max_size) \
786 type list[max_size]; \
788} unique_list_##name; \
790static void unique_list_##name##_init(unique_list_##name * s) \
792 memset(s->list, 0, sizeof(s->list)); \
796static void unique_list_##name##_add(unique_list_##name * s, type cand) \
798 if (s->size == max_size) \
801 for (int i = 0; i < s->size; i++) { \
802 if (!memcmp(&s->list[i], &cand, sizeof(type))) { \
806 s->list[s->size++] = cand; \
814 int blk_pos, tl_x, tl_y;
815 unique_list_intramode ipm_cand;
823 unique_list_intramode_init(&ipm_cand);
826 const PUInfo * pu = &s->pu_info[cu->pu_pos - s->pu_stride];
828 unique_list_intramode_add(&ipm_cand, s->blk_info[cu->blk_pos - s->blk_stride + (sub & 1)].imode);
831 blk_pos = cu->blk_pos + (sub >> 1) *
s->blk_stride + (sub & 1);
834 const PUInfo * pu = &s->pu_info[cu->pu_pos - 1];
836 unique_list_intramode_add(&ipm_cand, s->blk_info[blk_pos - 1 - (sub & 1)].imode);
839 tl_x = !(sub & 2) ? (cu->xpos + (sub & 1) * 4) : cu->xpos;
840 tl_y = cu->ypos + (sub & 2) * 4;
841 if (tl_x > 0 && tl_y > 0) {
844 case 0: pu = &
s->pu_info[cu->pu_pos -
s->pu_stride - 1];
break;
845 case 1: pu = &
s->pu_info[cu->pu_pos -
s->pu_stride];
break;
846 default: pu = &
s->pu_info[cu->pu_pos - 1];
850 unique_list_intramode_add(&ipm_cand,
s->blk_info[blk_pos -
s->blk_stride - 1].imode);
852 unique_list_intramode_add(&ipm_cand,
s->blk_info[blk_pos -
s->blk_stride - 2].imode);
860 return ipm_cand.list[cu->imode_param[sub]];
863 enum IntraMode imode = cu->imode_param[sub];
864 qsort(ipm_cand.list, 3,
sizeof(ipm_cand.list[0]),
ipm_compar);
865 for (
int i = 0;
i < 3;
i++)
866 if (imode >= ipm_cand.list[
i])
888 unique_list_mvinfo_add(skip_cand, *mvi);
893 int mv_size =
size >> 2;
910 for (
int i = skip_cand->size;
i < 4;
i++)
920 int mv_size =
size >> 2;
923 dim->w =
dim->h = mv_size;
927 dim->h = mv_size >> 1;
930 dim->w = mv_size >> 1;
934 dim->w =
dim->h = mv_size >> 1;
938 dim->h = !part_no ? (mv_size >> 2) : ((3 * mv_size) >> 2);
942 dim->h = !part_no ? ((3 * mv_size) >> 2) : (mv_size >> 2);
945 dim->w = !part_no ? (mv_size >> 2) : ((3 * mv_size) >> 2);
949 dim->w = !part_no ? ((3 * mv_size) >> 2) : (mv_size >> 2);
981 *mv_pos +=
dim->h*
s->blk_stride -
dim->w;
986 *mv_pos +=
dim->h *
s->blk_stride;
1023 if (
a->mvref !=
b->mvref)
1028 int dx =
a->f_mv.x -
b->f_mv.x;
1029 int dy =
a->f_mv.y -
b->f_mv.y;
1033 int dx =
a->b_mv.x -
b->b_mv.x;
1034 int dy =
a->b_mv.y -
b->b_mv.y;
1047 ret->x = a.x < c.x ? c.x : a.x; \
1050 ret->x = a.x < c.x ? a.x : c.x; \
1060 int mv_pos = mv_y *
s->blk_stride + mv_x;
1069 const MVInfo *
mv = &
s->blk_info[mv_pos - 1].mv;
1071 cand[cand_size++] =
mv->f_mv;
1074 const MVInfo *
mv = &
s->blk_info[mv_pos -
s->blk_stride].mv;
1076 cand[cand_size++] =
mv->f_mv;
1079 const MVInfo *
mv = &
s->blk_info[mv_pos -
s->blk_stride + mv_w].mv;
1081 cand[cand_size++] =
mv->f_mv;
1084 switch (cand_size) {
1090 f_mv.
x = (cand[0].
x + cand[1].
x) >> 1;
1091 f_mv.
y = (cand[0].
y + cand[1].
y) >> 1;
1094 mv_pred(&f_mv, cand[0], cand[1], cand[2]);
1104 dst->f_mv.x =
src->f_mv.x + f_mv.
x;
1105 dst->f_mv.y =
src->f_mv.y + f_mv.
y;
1111 const MVInfo *
mv = &
s->blk_info[mv_pos - 1].mv;
1113 cand[cand_size++] =
mv->b_mv;
1116 const MVInfo *
mv = &
s->blk_info[mv_pos -
s->blk_stride].mv;
1118 cand[cand_size++] =
mv->b_mv;
1121 const MVInfo *
mv = &
s->blk_info[mv_pos -
s->blk_stride + mv_w].mv;
1123 cand[cand_size++] =
mv->b_mv;
1126 switch (cand_size) {
1132 b_mv.
x = (cand[0].
x + cand[1].
x) >> 1;
1133 b_mv.
y = (cand[0].
y + cand[1].
y) >> 1;
1136 mv_pred(&b_mv, cand[0], cand[1], cand[2]);
1146 dst->b_mv.x =
src->b_mv.x + b_mv.
x;
1147 dst->b_mv.y =
src->b_mv.y + b_mv.
y;
1152 int pu_size =
size >> 3;
1154 int imode, mv_x, mv_y, mv_pos, count, mv_size;
1155 unique_list_mvinfo skip_cand;
1164 for (
int y = 0; y < 2; y++)
1165 for (
int x = 0; x < 2; x++)
1166 s->blk_info[cu->
blk_pos + y*
s->blk_stride + x].imode =
1174 for (
int y = 0; y < size >> 2; y++)
1175 for (
int x = 0; x < size >> 2; x++)
1176 s->blk_info[cu->
blk_pos + y*
s->blk_stride + x].imode = imode;
1179 mv_x = cu->
xpos >> 2;
1180 mv_y = cu->
ypos >> 2;
1183 for (
int part_no = 0; part_no < count; part_no++) {
1187 for (
int y = 0; y <
dim.h; y++)
1188 for (
int x = 0; x <
dim.w; x++)
1189 s->blk_info[mv_pos + y*
s->blk_stride + x].mv =
mv;
1194 unique_list_mvinfo_init(&skip_cand);
1197 mv_size =
size >> 2;
1198 for (
int y = 0; y < mv_size; y++)
1199 for (
int x = 0; x < mv_size; x++)
1200 s->blk_info[cu->
blk_pos + y*
s->blk_stride + x].mv =
mv;
1203 for (
int y = 0; y < pu_size; y++)
1204 for (
int x = 0; x < pu_size; x++)
1205 s->pu_info[cu->
pu_pos + y*
s->pu_stride + x] = pui;
1242#define FILTER1(src, src_stride, src_y_ofs, step) \
1243 ( (src)[(y + src_y_ofs)*(src_stride) + x - 2*step] \
1244 - 5 * (src)[(y + src_y_ofs)*(src_stride) + x - 1*step] \
1245 +52 * (src)[(y + src_y_ofs)*(src_stride) + x ] \
1246 +20 * (src)[(y + src_y_ofs)*(src_stride) + x + 1*step] \
1247 - 5 * (src)[(y + src_y_ofs)*(src_stride) + x + 2*step] \
1248 + (src)[(y + src_y_ofs)*(src_stride) + x + 3*step] + 32) >> 6
1250#define FILTER2(src, src_stride, src_y_ofs, step) \
1251 ( (src)[(y + src_y_ofs)*(src_stride) + x - 2*step] \
1252 - 5 * (src)[(y + src_y_ofs)*(src_stride) + x - 1*step] \
1253 +20 * (src)[(y + src_y_ofs)*(src_stride) + x ] \
1254 +20 * (src)[(y + src_y_ofs)*(src_stride) + x + 1*step] \
1255 - 5 * (src)[(y + src_y_ofs)*(src_stride) + x + 2*step] \
1256 + (src)[(y + src_y_ofs)*(src_stride) + x + 3*step] + 16) >> 5
1258#define FILTER3(src, src_stride, src_y_ofs, step) \
1259 ( (src)[(y + src_y_ofs)*(src_stride) + x - 2*step] \
1260 - 5 * (src)[(y + src_y_ofs)*(src_stride) + x - 1*step] \
1261 +20 * (src)[(y + src_y_ofs)*(src_stride) + x ] \
1262 +52 * (src)[(y + src_y_ofs)*(src_stride) + x + 1*step] \
1263 - 5 * (src)[(y + src_y_ofs)*(src_stride) + x + 2*step] \
1264 + (src)[(y + src_y_ofs)*(src_stride) + x + 3*step] + 32) >> 6
1266#define FILTER_CASE(idx, dst, dst_stride, filter, w, h) \
1268 for (int y = 0; y < h; y++) \
1269 for (int x = 0; x < w; x++) \
1270 (dst)[y*dst_stride + x] = av_clip_uint8(filter); \
1273#define FILTER_BLOCK(dst, dst_stride, src, src_stride, src_y_ofs, w, h, cond, step) \
1275 FILTER_CASE(1, dst, dst_stride, FILTER1(src, src_stride, src_y_ofs, step), w, h) \
1276 FILTER_CASE(2, dst, dst_stride, FILTER2(src, src_stride, src_y_ofs, step), w, h) \
1277 FILTER_CASE(3, dst, dst_stride, FILTER3(src, src_stride, src_y_ofs, step), w, h) \
1280static void luma_mc(uint8_t *
dst,
int dst_stride,
const uint8_t *
src,
int src_stride,
int w,
int h,
int cx,
int cy)
1283 for (
int y = 0; y <
h; y++)
1284 memcpy(
dst + y*dst_stride,
src + y*src_stride,
w);
1289 }
else if (cx != 3 || cy != 3) {
1290 uint8_t
tmp[70 * 64];
1294 for (
int j = 0; j <
h; j++)
1295 for (
int i = 0;
i <
w;
i++)
1296 dst[j*dst_stride +
i] = (
1297 src[j*src_stride +
i] +
1298 src[j*src_stride +
i + 1] +
1299 src[(j + 1)*src_stride +
i] +
1300 src[(j + 1)*src_stride +
i + 1] + 2) >> 2;
1304static void chroma_mc(uint8_t *
dst,
int dst_stride,
const uint8_t *
src,
int src_stride,
int w,
int h,
int x,
int y)
1307 for (
int j = 0; j <
h; j++)
1308 memcpy(
dst + j*dst_stride,
src + j*src_stride,
w);
1309 }
else if (x > 0 && y > 0) {
1312 if (x == 3 && y == 3)
1315 a = (4 - x) * (4 - y);
1319 for (
int j = 0; j <
h; j++)
1320 for (
int i = 0;
i <
w;
i++)
1321 dst[j*dst_stride +
i] =
1322 (
a *
src[j*src_stride +
i] +
1323 b *
src[j*src_stride +
i + 1] +
1324 c *
src[(j + 1)*src_stride +
i] +
1325 d *
src[(j + 1)*src_stride +
i + 1] + 8) >> 4;
1327 int a = (4 - x) * (4 - y);
1328 int e = x * (4 - y) + (4 - x) * y;
1329 int step = y > 0 ? src_stride : 1;
1330 for (
int j = 0; j <
h; j++)
1331 for (
int i = 0;
i <
w;
i++)
1332 dst[j*dst_stride +
i] =
1333 (
a *
src[j*src_stride +
i] +
1334 e *
src[j*src_stride +
i + step] + 8) >> 4;
1338static int check_pos(
int x,
int y,
int cw,
int ch,
int w,
int h,
int dx,
int dy,
int e0,
int e1,
int e2,
int e3)
1342 return x2 - e0 >= 0 && x2 + cw + e1 <=
w && y2 - e2 >= 0 && y2 + ch + e3 <=
h;
1348 int off = !
avg ? y * frame_linesize[0] + x : 0;
1350 int fh =
s->aheight;
1356 if (
check_pos(x, y,
w,
h, fw, fh, dx, dy,
rv60_edge1[cx],
rv60_edge2[cx],
rv60_edge1[cy],
rv60_edge2[cy])) {
1360 ref->data[0] + (y + dy) *
ref->linesize[0] + x + dx,
1365 int xoff = x + dx - 2;
1366 int yoff = y + dy - 2;
1367 s->vdsp.emulated_edge_mc(buf,
1368 ref->data[0] + yoff *
ref->linesize[0] + xoff,
1369 70,
ref->linesize[0],
1375 buf + 70 * 2 + 2, 70,
w,
h, cx, cy);
1379 int fw =
s->awidth >> 1;
1380 int fh =
s->aheight >> 1;
1390 for (
int plane = 1; plane < 3; plane++) {
1391 int off = !
avg ? (y >> 1) * frame_linesize[plane] + (x >> 1) : 0;
1392 if (
check_pos(x >> 1, y >> 1, cw, ch, fw, fh, dx, dy, 0, 1, 0, 1)) {
1395 frame_linesize[plane],
1396 ref->data[plane] + ((y >> 1) + dy) *
ref->linesize[plane] + (x >> 1) + dx,
1397 ref->linesize[plane],
1401 s->vdsp.emulated_edge_mc(buf,
1402 ref->data[plane] + ((y >> 1) + dy) *
ref->linesize[plane] + (x >> 1) + dx,
1403 40,
ref->linesize[plane],
1405 (x >> 1) + dx, (y >> 1) + dy,
1413static void avg_plane(uint8_t *
dst,
int dst_stride,
const uint8_t *
src,
int src_stride,
int w,
int h)
1415 for (
int j = 0; j <
h; j++)
1416 for (
int i = 0;
i <
w;
i++)
1417 dst[j*dst_stride +
i] = (
dst[j*dst_stride +
i] +
src[j*src_stride +
i]) >> 1;
1420static void avg(
AVFrame *
frame, uint8_t * prev_frame_data[3],
int prev_frame_linesize[3],
int x,
int y,
int w,
int h)
1422 for (
int plane = 0; plane < 3; plane++) {
1423 int shift = !plane ? 0 : 1;
1425 prev_frame_data[plane], prev_frame_linesize[plane],
1440 return (v * q + 8) >> 4;
1448 return inval &&
get_bits1(gb) ? -inval : inval;
1452 int esc_bits = esc_sym - 23;
1453 val += (1 << esc_bits) +
get_bits(gb, esc_bits) + 22;
1500 int sym0 =
get_vlc2(gb, vlcs->
l0[!is_luma], 9, 2);
1501 int grp0 = sym0 >> 3;
1507 int grp =
get_vlc2(gb, vlcs->
l12[!is_luma], 9, 2);
1511 int grp =
get_vlc2(gb, vlcs->
l12[!is_luma], 9, 2);
1515 int grp =
get_vlc2(gb, vlcs->
l3[!is_luma], 9, 2);
1522 int sym0 =
get_vlc2(gb, vlcs->
l0[!is_luma], 9, 2);
1523 int grp0 = (sym0 >> 3);
1529 int grp =
get_vlc2(gb, vlcs->
l12[!is_luma], 9, 2);
1533 int grp =
get_vlc2(gb, vlcs->
l12[!is_luma], 9, 2);
1537 int grp =
get_vlc2(gb, vlcs->
l3[!is_luma], 9, 2);
1550 memset(y_coeffs, 0,
sizeof(y_coeffs[0])*256);
1551 for (
int i = 0;
i < 16;
i++)
1555 memset(u_coeffs, 0,
sizeof(u_coeffs[0])*64);
1556 for (
int i = 0;
i < 4;
i++)
1557 if ((cbp >> (16 +
i)) & 1)
1560 memset(v_coeffs, 0,
sizeof(v_coeffs[0])*64);
1561 for (
int i = 0;
i < 4;
i++)
1562 if ((cbp >> (20 +
i)) & 1)
1572static void decode_cu_8x8(
GetBitContext * gb,
int is_intra,
int qp,
int sel_qp, int16_t * y_coeffs, int16_t * u_coeffs, int16_t * v_coeffs,
int ccbp,
int mode4x4)
1580 memset(y_coeffs, 0,
sizeof(y_coeffs[0])*64);
1581 for (
int i = 0;
i < 4;
i++) {
1582 if ((ccbp >>
i) & 1) {
1588 offset = (
i & 1) * 4 + (
i & 2) * 2 * 8;
1595 if ((ccbp >> 4) & 1) {
1596 memset(u_coeffs, 0,
sizeof(u_coeffs[0])*16);
1600 if ((ccbp >> 5) & 1) {
1601 memset(v_coeffs, 0,
sizeof(u_coeffs[0])*16);
1614 memset(y_coeffs, 0,
sizeof(y_coeffs[0])*256);
1615 for (
int i = 0;
i < 16;
i++)
1616 if ((ccbp >>
i) & 1) {
1617 int off = (
i & 3) * 4 + (
i >> 2) * 4 * 16;
1621 memset(u_coeffs, 0,
sizeof(u_coeffs[0])*64);
1622 for (
int i = 0;
i < 4;
i++)
1623 if ((ccbp >> (16 +
i)) & 1) {
1624 int off = (
i & 1) * 4 + (
i & 2) * 2 * 8;
1631 memset(v_coeffs, 0,
sizeof(v_coeffs[0])*64);
1632 for (
int i = 0;
i < 4;
i++)
1633 if ((ccbp >> (20 +
i)) & 1) {
1634 int off = (
i & 1) * 4 + (
i & 2) * 2 * 8;
1644 int sym0 =
get_vlc2(gb, vlc[0], 9, 2);
1645 int sym1 =
get_vlc2(gb, vlc[1], 9, 2);
1646 int sym2 =
get_vlc2(gb, vlc[2], 9, 2);
1647 int sym3 =
get_vlc2(gb, vlc[3], 9, 2);
1649 + ((sym0 & 0x03) << 0)
1650 + ((sym0 & 0x0C) << 2)
1651 + ((sym0 & 0x10) << 12)
1652 + ((sym0 & 0x20) << 15)
1653 + ((sym1 & 0x03) << 2)
1654 + ((sym1 & 0x0C) << 4)
1655 + ((sym1 & 0x10) << 13)
1656 + ((sym1 & 0x20) << 16)
1657 + ((sym2 & 0x03) << 8)
1658 + ((sym2 & 0x0C) << 10)
1659 + ((sym2 & 0x10) << 14)
1660 + ((sym2 & 0x20) << 17)
1661 + ((sym3 & 0x03) << 10)
1662 + ((sym3 & 0x0C) << 12)
1663 + ((sym3 & 0x10) << 15)
1664 + ((sym3 & 0x20) << 18);
1675 int size = 1 << log_size;
1676 int split,
ret, ttype, count, is_intra, cu_pos, subset, cbp8, imode, split_i4x4, num_clusters, cl_cbp, super_cbp, mv_x, mv_y, mv_pos;
1677 int16_t y_coeffs[16*16], u_coeffs[8*8], v_coeffs[8*8];
1680 if (xpos >=
s->awidth || ypos >=
s->aheight)
1698 cu.
pu_pos = (xpos >> 3) + (ypos >> 3) *
s->pu_stride;
1699 cu.
blk_pos = (xpos >> 2) + (ypos >> 2) *
s->blk_stride;
1706 for (
int i = 0;
i < 4;
i++)
1708 else if (
size <= 32)
1716 for (
int i = 0;
i < count;
i++)
1731 imode =
s->blk_info[cu.
blk_pos].imode;
1733 int off = ypos *
frame->linesize[0] + xpos;
1738 for (
int plane = 1; plane < 3; plane++) {
1739 int off = (ypos >> 1) *
frame->linesize[plane] + (xpos >> 1);
1748 mv_pos = mv_y *
s->blk_stride + mv_x;
1750 for (
int part_no = 0; part_no < count; part_no++) {
1755 mv =
s->blk_info[mv_pos].mv;
1762 if (!(
mv.mvref & 2)) {
1763 if (!
s->last_frame[
LAST_PIC]->data[0]) {
1769 if (!
s->last_frame[
NEXT_PIC]->data[0]) {
1800 else if (
size >= 32)
1802 else if (
size == 16)
1810 cu_pos = ((xpos & 63) >> 3) + ((ypos & 63) >> 3) * 8;
1814 subset = is_intra ? 0 : 2;
1819 for (
int y = 0; y < 4; y++)
1820 for (
int x = 0; x < 4; x++) {
1822 if ((cbp16 >>
i) & 1) {
1823 int off = (ypos + y * 4)*
frame->linesize[0] + xpos + x * 4;
1825 thread->
coded_blk[cu_pos + (y/2)*8 + (x/2)] = 1;
1828 for (
int y = 0; y < 2; y++)
1829 for (
int x = 0; x < 2; x++) {
1831 int xoff = (xpos >> 1) + x * 4;
1832 int yoff = (ypos >> 1) + y * 4;
1833 if ((cbp16 >> (16 +
i)) & 1) {
1834 int off = yoff *
frame->linesize[1] + xoff;
1836 thread->
coded_blk[cu_pos + y*8 + x] = 1;
1838 if ((cbp16 >> (20 +
i)) & 1) {
1839 int off = yoff *
frame->linesize[2] + xoff;
1841 thread->
coded_blk[cu_pos + y*8 + x] = 1;
1849 decode_cu_8x8(gb, is_intra, qp, sel_qp, y_coeffs, u_coeffs, v_coeffs, cbp8, 1);
1851 for (
int i = 0;
i < 4;
i++) {
1852 int xoff = (
i & 1) << 2;
1853 int yoff = (
i & 2) << 1;
1855 int off = (ypos + yoff) *
frame->linesize[0] + xpos + xoff;
1856 int imode =
s->blk_info[cu.
blk_pos + (
i >> 1) *
s->blk_stride + (
i & 1)].imode;
1861 if ((cbp8 >>
i) & 1) {
1862 int off = (ypos + yoff) *
frame->linesize[0] + xpos + xoff;
1866 if ((cbp8 >> 4) & 1) {
1867 int off = (ypos >> 1) *
frame->linesize[1] + (xpos >> 1);
1870 if ((cbp8 >> 5) & 1) {
1871 int off = (ypos >> 1) *
frame->linesize[2] + (xpos >> 1);
1877 subset = is_intra ? 1 : 3;
1881 decode_cu_8x8(gb, is_intra, qp, sel_qp, y_coeffs, u_coeffs, v_coeffs, cbp8, 0);
1883 int off = ypos *
frame->linesize[0] + xpos;
1886 if ((cbp8 >> 4) & 1) {
1887 int off = (ypos >> 1) *
frame->linesize[1] + (xpos >> 1);
1890 if ((cbp8 >> 5) & 1) {
1891 int off = (ypos >> 1) *
frame->linesize[2] + (xpos >> 1);
1897 subset = is_intra ? 1 : 3;
1898 num_clusters =
size >> 4;
1899 cl_cbp =
get_bits(gb, num_clusters * num_clusters);
1900 for (
int y = 0; y < num_clusters; y++) {
1901 for (
int x = 0; x < num_clusters; x++) {
1902 if (!((cl_cbp >> (y*num_clusters + x)) & 1))
1904 thread->
coded_blk[cu_pos + y*2*8 + x*2 + 0] = 1;
1905 thread->
coded_blk[cu_pos + y*2*8 + x*2 + 1] = 1;
1906 thread->
coded_blk[cu_pos + y*2*8 + x*2 + 8] = 1;
1907 thread->
coded_blk[cu_pos + y*2*8 + x*2 + 9] = 1;
1910 decode_cu_16x16(gb, is_intra, qp, sel_qp, y_coeffs, u_coeffs, v_coeffs, super_cbp);
1911 if (super_cbp & 0xFFFF) {
1912 int off = (ypos + y * 16) *
frame->linesize[0] + xpos + x * 16;
1915 if ((super_cbp >> 16) & 0xF) {
1916 int off = ((ypos >> 1) + y * 8) *
frame->linesize[1] + (xpos >> 1) + x * 8;
1919 if ((super_cbp >> 20) & 0xF) {
1920 int off = ((ypos >> 1) + y * 8) *
frame->linesize[2] + (xpos >> 1) + x * 8;
1934 return (ypos >> 2) *
s->dblk_stride + (xpos >> 2);
1940 int dsize =
size >> 2;
1941 int dval = (q << 2) + strength;
1943 for (
int x = 0; x < dsize; x++) {
1944 s->top_str[
pos + x] = dval;
1945 s->top_str[
pos + (dsize - 1)*
s->dblk_stride + x] = dval;
1948 for (
int y = 0; y < dsize; y++) {
1949 s->left_str[
pos + y*
s->dblk_stride] = dval;
1950 s->left_str[
pos + y*
s->dblk_stride + dsize - 1] = dval;
1956 return s->top_str[
pos] & 3;
1961 return s->left_str[
pos] & 3;
1966 s->top_str[
pos] |= strength;
1971 s->left_str[
pos] |= strength;
1976 int blk_pos = (ypos >> 2) *
s->blk_stride + (xpos >> 2);
1979 for (
int i = 0;
i <
size;
i++)
1983 for (
int i = 0;
i <
size;
i++)
1988#define STRENGTH(el, lim) (FFABS(el) < (lim) ? 3 : 1)
1989#define CLIP_SYMM(a, b) av_clip(a, -(b), b)
1993 int16_t diff_q1q0[4];
1994 int16_t diff_p1p0[4];
1995 int str_p, str_q, msum, maxprod, weak;
1997 for (
int i = 0;
i < 4;
i++) {
2002 str_p =
STRENGTH(diff_q1q0[0] + diff_q1q0[1] + diff_q1q0[2] + diff_q1q0[3], lim2);
2003 str_q =
STRENGTH(diff_p1p0[0] + diff_p1p0[1] + diff_p1p0[2] + diff_p1p0[3], lim2);
2005 if (str_p + str_q <= 2)
2008 msum = (mode1 + mode2 + str_q + str_p) >> 1;
2009 if (str_q == 1 || str_p == 1) {
2017 for (
int y = 0; y < 4; y++) {
2018 int diff_p0q0 =
dst[0] -
dst[-step];
2019 int result = (lim1 *
FFABS(diff_p0q0)) & -128;
2020 if (diff_p0q0 && result <= maxprod) {
2021 int diff_q1q2 =
dst[-2*step] -
dst[-3*step];
2022 int diff_p1p2 =
dst[step] -
dst[2*step];
2027 int diff_strg = (
dst[-2*step] -
dst[step] + 4 * diff_p0q0 + 4) >> 3;
2032 if (str_p != 1 &&
FFABS(diff_q1q2) <= (lim2 >> 2)) {
2033 int diff = (diff_q1q0[y] + diff_q1q2 -
delta) >> 1;
2037 if (str_q != 1 &&
FFABS(diff_p1p2) <= (lim2 >> 2)) {
2038 int diff = (diff_p1p0[y] + diff_p1p2 +
delta) >> 1;
2049 int diff_q = 4 *
FFABS(
dst[-2*step] -
dst[-step]);
2051 int str_q =
STRENGTH(diff_q, lim2);
2052 int str_p =
STRENGTH(diff_p, lim2);
2053 int msum, maxprod, weak;
2055 if (str_p + str_q <= 2)
2058 msum = (mode1 + mode2 + str_q + str_p) >> 1;
2059 if (str_q == 1 || str_p == 1) {
2067 for (
int y = 0; y < 2; y++) {
2068 int diff_pq =
dst[0] -
dst[-step];
2069 int result = (lim1 *
FFABS(diff_pq)) & -128;
2070 if (diff_pq && result <= maxprod) {
2075 int diff_strg = (
dst[-2*step] -
dst[step] + 4 * diff_pq + 4) >> 3;
2087 int qp_l = dblk_l >> 2;
2088 int str_l = dblk_l & 3;
2089 int qp_r = dblk_r >> 2;
2090 int str_r = dblk_r & 3;
2093 int mode_l = str_l ? dl_l[str_l - 1] : 0;
2094 int mode_r = str_r ? dl_r[str_r - 1] : 0;
2096 int lim2 = dl_r[3] * 4;
2099 if ((str_l | str_r) >= 2 && deblock_chroma)
2100 for (
int plane = 1; plane < 3; plane++)
2106 int qp_t = dblk_t >> 2;
2107 int str_t = dblk_t & 3;
2108 int qp_d = dblk_d >> 2;
2109 int str_d = dblk_d & 3;
2112 int mode_t = str_t ? dl_t[str_t - 1] : 0;
2113 int mode_d = str_d ? dl_d[str_d - 1] : 0;
2115 int lim2 = dl_d[3] * 4;
2118 if ((str_t | str_d) >= 2 && deblock_chroma)
2119 for (
int plane = 1; plane < 3; plane++)
2127 int str_l =
s->left_str[dblkpos -
s->dblk_stride - 1];
2128 int str_r =
s->left_str[dblkpos -
s->dblk_stride];
2129 if ((str_l | str_r) & 3)
2133 int str_l =
s->left_str[dblkpos - 1];
2134 int str_r =
s->left_str[dblkpos];
2135 if ((str_l | str_r) & 3)
2138 if (ypos + 8 >=
s->aheight) {
2139 int str_l =
s->left_str[dblkpos +
s->dblk_stride - 1];
2140 int str_r =
s->left_str[dblkpos +
s->dblk_stride];
2141 if ((str_l | str_r) & 3)
2147 int str_t =
s->top_str[dblkpos -
s->dblk_stride - 1];
2148 int str_d =
s->top_str[dblkpos - 1];
2149 if ((str_t | str_d) & 3)
2153 int str_t =
s->top_str[dblkpos -
s->dblk_stride];
2154 int str_d =
s->top_str[dblkpos];
2155 if ((str_t | str_d) & 3)
2158 if (xpos + 8 >=
s->awidth) {
2159 int str_t =
s->top_str[dblkpos -
s->dblk_stride + 1];
2160 int str_d =
s->top_str[dblkpos + 1];
2161 if ((str_t | str_d) & 3)
2169 for (
int x = 0; x < size >> 3; x++)
2172 for (
int y = 1; y < size >> 3; y++)
2178 int pu_pos, tsize, ntiles;
2181 if (xpos >=
s->awidth || ypos >=
s->aheight)
2185 int hsize = 1 << (log_size - 1);
2194 pu_pos = (ypos >> 3) *
s->pu_stride + (xpos >> 3);
2195 cu_type =
s->pu_info[pu_pos].cu_type;
2197 case 3: tsize = 3;
break;
2198 case 4: tsize = cu_type &&
s->pu_info[pu_pos].pu_type ? 3 : 4;
break;
2200 case 6: tsize = 4;
break;
2202 ntiles = 1 << (log_size - tsize);
2204 for (
int ty = 0; ty < ntiles; ty++)
2205 for (
int tx = 0; tx < ntiles; tx++) {
2206 int x = xpos + (tx << tsize);
2207 int y = ypos + (ty << tsize);
2208 int cu_pos = ((y & 63) >> 3) * 8 + ((x & 63) >> 3);
2227 switch (qp_off_type) {
2232 return val != 2 ?
val : -1;
2240 return -((
val & 1) + 1);
2248 case 1:
return qp <= 25 ? qp + 5 : qp;
2265 int qp, sel_qp,
ret;
2277 for (
int cu_x = 0; cu_x <
s->cu_width; cu_x++) {
2282 if (qp < 0 || qp >= 64) {
2316 if (avpkt->
size == 0) {
2324 if (avpkt->
size < 9)
2327 header_size = avpkt->
data[0] * 8 + 9;
2328 if (avpkt->
size < header_size)
2351 s->last_frame[
CUR_PIC]->pict_type =
s->pict_type;
2358 if (!
s->last_frame[
CUR_PIC]->data[0])
2367 for (
int i = 0;
i <
s->cu_height;
i++) {
2368 if (ofs >= avpkt->
size - header_size)
2370 s->slice[
i].data = avpkt->
data + header_size + ofs;
2371 s->slice[
i].data_size =
FFMIN(
s->slice[
i].size, avpkt->
size - header_size - ofs);
2372 if (
s->slice[
i].size > INT32_MAX - ofs)
2374 ofs +=
s->slice[
i].size;
2386 else if (
s->last_frame[
LAST_PIC]->data[0])
2400 s->ref_pts[0] =
s->ref_pts[1];
2401 s->ref_pts[1] = avpkt->
pts;
2403 s->ref_ts[0] =
s->ref_ts[1];
2404 s->ref_ts[1] =
s->ts;
2406 if (
s->ref_pts[1] >
s->ref_pts[0] &&
s->ref_ts[1] >
s->ref_ts[0])
2407 s->ts_scale = (
s->ref_pts[1] -
s->ref_pts[0]) / (
s->ref_ts[1] -
s->ref_ts[0]);
2409 frame->pts =
s->ref_pts[0] + (
s->ts -
s->ref_ts[0]) *
s->ts_scale;
2419 for (
int i = 0;
i < 3;
i++)
2427 for (
int i = 0;
i < 3;
i++)
2436 for (
int i = 0;
i <
s->nb_progress;
i++)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static char * split(char *message, char delim)
const FFCodec ff_rv60_decoder
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
#define MV(nP, nC, mode, size, ref)
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
static int decode_slice(AVCodecContext *c, void *arg)
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t * align_get_bits(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int get_interleaved_se_golomb(GetBitContext *gb)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_NONREF
discard all non reference
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_NONE
Undefined.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static const int8_t mv[256][2]
static int shift(int a, int b)
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
#define FFSWAP(type, a, b)
Memory handling functions.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
const h264_weight_func weight
static VLCElem table_data[117592]
static const uint8_t rv60_edge1[4]
static const uint16_t rv60_ipred_inv_angle[9]
static const uint8_t rv60_avail_mask[64]
static const uint8_t rv60_qp_to_idx[64]
static const uint8_t rv60_dsc_to_lx[][4]
static const uint8_t rv60_deblock_limits[32][4]
static const uint16_t rv60_quants_b[32]
static const uint8_t rv60_ipred_angle[9]
static const uint8_t rv60_edge2[4]
static const uint8_t rv60_candidate_intra_angles[6]
static const uint8_t rv60_chroma_quant_ac[32]
static const uint8_t rv60_chroma_quant_dc[32]
static void pred_plane(const IntraPredContext *p, uint8_t *dst, int stride, int size)
static const VLCElem * cbp8_vlc[7][4]
static int mvinfo_is_deblock_cand(const MVInfo *a, const MVInfo *b)
static void add_if_valid(unique_list_mvinfo *skip_cand, const MVInfo *mvi)
static int decode_cbp16(GetBitContext *gb, int subset, int qp)
static int read_code012(GetBitContext *gb)
static void fill_mv_skip_cand(RV60Context *s, const CUContext *cu, unique_list_mvinfo *skip_cand, int size)
static void get_next_mv(const RV60Context *s, const Dimensions *dim, enum PUType pu_type, int part_no, int *mv_pos, int *mv_x, int *mv_y)
static av_cold int rv60_decode_end(AVCodecContext *avctx)
static void reconstruct(RV60Context *s, const CUContext *cu, int size)
static int reconstruct_intra(const RV60Context *s, const CUContext *cu, int size, int sub)
static CoeffVLCs inter_coeff_vlc[7]
static int decode_slice(AVCodecContext *avctx, void *tdata, int cu_y, int threadnr)
static int decode_super_cbp(GetBitContext *gb, const VLCElem *vlc[4])
static CoeffVLCs intra_coeff_vlc[5]
static int get_skip_mv_index(enum MVRefEnum mvref)
static int mvinfo_matches_backward(const MVInfo *a, const MVInfo *b)
static int mv_is_ref0(enum MVRefEnum mvref)
static void decode_cu_8x8(GetBitContext *gb, int is_intra, int qp, int sel_qp, int16_t *y_coeffs, int16_t *u_coeffs, int16_t *v_coeffs, int ccbp, int mode4x4)
static void read_mv_info(RV60Context *s, GetBitContext *gb, MVInfo *mvinfo, int size, enum PUType pu_type)
static int has_top_right_block(const RV60Context *s, int xpos, int ypos, int dx, int dy, int size)
static void deblock_edge_hor(AVFrame *frame, int xpos, int ypos, int dblk_t, int dblk_d, int deblock_chroma)
static int read_qp_offset(GetBitContext *gb, int qp_off_type)
static av_cold void rv60_flush(AVCodecContext *avctx)
static int read_slice_sizes(RV60Context *s, GetBitContext *gb)
static int check_pos(int x, int y, int cw, int ch, int w, int h, int dx, int dy, int e0, int e1, int e2, int e3)
static void deblock_set_strength(RV60Context *s, int xpos, int ypos, int size, int q, int strength)
static void ipred_init(IntraPredContext *i)
static void decode_cu_4x4in16x16(GetBitContext *gb, int is_intra, int qp, int sel_qp, int16_t *y_coeffs, int16_t *u_coeffs, int16_t *v_coeffs, int cbp)
static void avg_plane(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
static int get_c4x4_set(int qp, int is_intra)
static void populate_ipred(const RV60Context *s, CUContext *cu, const uint8_t *src, int stride, int xoff, int yoff, int size, int is_luma)
static void pred_dc(const IntraPredContext *p, uint8_t *dst, int stride, int size, int filter)
static av_cold void rv60_init_static_data(void)
static int read_intra_mode(GetBitContext *gb, int *param)
static void build_coeff_vlc(const CoeffLens *lens, CoeffVLCs *vlc, int count, VLCInitState *state)
static int read_frame_header(RV60Context *s, GetBitContext *gb, int *width, int *height)
static void filter_luma_edge(uint8_t *dst, int step, int stride, int mode1, int mode2, int lim1, int lim2)
static int has_ver_split(enum PUType pu_type)
static av_cold int rv60_decode_init(AVCodecContext *avctx)
static int calc_sel_qp(int osvquant, int qp)
static void deblock_set_top_strength(RV60Context *s, int pos, int strength)
static int rv60_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
static void decode_2x2_dc(GetBitContext *gb, const CoeffVLCs *vlcs, int16_t *coeffs, int stride, int block2, int dsc, int q_dc, int q_ac)
static void decode_cu_16x16(GetBitContext *gb, int is_intra, int qp, int sel_qp, int16_t *y_coeffs, int16_t *u_coeffs, int16_t *v_coeffs, int ccbp)
static void deblock_set_left_strength(RV60Context *s, int pos, int strength)
static void filter_weak(uint8_t *dst, const uint8_t *src, int size)
static const VLCElem * cbp16_vlc[7][4][4]
static int decode_coeff(GetBitContext *gb, const CoeffVLCs *vlcs, int inval, int val)
static void deblock_edge_ver(AVFrame *frame, int xpos, int ypos, int dblk_l, int dblk_r, int deblock_chroma)
static void pred_hor_angle(uint8_t *dst, int stride, int size, int weight, const uint8_t *src)
static int decode_cu_r(RV60Context *s, AVFrame *frame, ThreadContext *thread, GetBitContext *gb, int xpos, int ypos, int log_size, int qp, int sel_qp)
static void deblock8x8(const RV60Context *s, AVFrame *frame, int xpos, int ypos, int dblkpos)
static void luma_mc(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h, int cx, int cy)
static const uint8_t skip_mv_ref[4]
static int ipm_compar(const void *a, const void *b)
static int pu_is_intra(const PUInfo *pu)
static int mvinfo_matches_forward(const MVInfo *a, const MVInfo *b)
static int progress_init(RV60Context *s, unsigned count)
static int has_hor_split(enum PUType pu_type)
static void decode_4x4_block_dc(GetBitContext *gb, const CoeffVLCs *vlcs, int is_luma, int16_t *coeffs, int stride, int q_dc, int q_ac)
static void derive_deblock_strength(RV60Context *s, int xpos, int ypos, int size)
static int pred_angle(const IntraPredContext *p, uint8_t *dst, int stride, int size, int imode, int filter)
static int deblock_get_pos(RV60Context *s, int xpos, int ypos)
static void decode_2x2(GetBitContext *gb, const CoeffVLCs *vlcs, int16_t *coeffs, int stride, int block2, int dsc, int q_ac)
static void deblock_cu_r(RV60Context *s, AVFrame *frame, ThreadContext *thread, int xpos, int ypos, int log_size, int qp)
#define MK_UNIQUELIST(name, type, max_size)
static const VLCElem * gen_vlc(const uint8_t *bits, int size, VLCInitState *state)
#define FILTER_BLOCK(dst, dst_stride, src, src_stride, src_y_ofs, w, h, cond, step)
static int mv_is_backward(enum MVRefEnum mvref)
static void filter_chroma_edge(uint8_t *dst, int step, int stride, int mode1, int mode2, int lim1, int lim2)
static int has_left_block(const RV60Context *s, int xpos, int ypos, int dx, int dy, int size)
static int update_dimensions_clear_info(RV60Context *s, int width, int height)
static int decode_cbp8(GetBitContext *gb, int subset, int qp)
static int pu_type_num_parts(enum PUType pu_type)
static void get_mv_dimensions(Dimensions *dim, enum PUType pu_type, int part_no, int size)
static void decode_4x4_block(GetBitContext *gb, const CoeffVLCs *vlcs, int is_luma, int16_t *coeffs, int stride, int q_ac)
static void predict_mv(const RV60Context *s, MVInfo *dst, int mv_x, int mv_y, int mv_w, const MVInfo *src)
static void pred_ver_angle(uint8_t *dst, int stride, int size, int weight, const uint8_t *src)
#define STRENGTH(el, lim)
static int mv_is_forward(enum MVRefEnum mvref)
static int has_top_block(const RV60Context *s, int xpos, int ypos, int dx, int dy, int size)
static void read_mv(GetBitContext *gb, MV *mv)
static int deblock_get_left_strength(const RV60Context *s, int pos)
static int deblock_get_top_strength(const RV60Context *s, int pos)
static void filter_bilin32(uint8_t *dst, int v0, int v1, int size)
static int has_left_down_block(const RV60Context *s, int xpos, int ypos, int dx, int dy, int size)
static void mv_pred(MV *ret, MV a, MV b, MV c)
static void deblock(const RV60Context *s, AVFrame *frame, int xpos, int ypos, int size, int dpos)
static const int8_t frame_types[4]
void ff_rv60_idct8x8_add(const int16_t *block, uint8_t *dst, int dst_stride)
void ff_rv60_idct16x16_add(const int16_t *block, uint8_t *dst, int dst_stride)
void ff_rv60_idct4x4_add(const int16_t *block, uint8_t *dst, int dst_stride)
static const CoeffLens rv60_intra_lens[5]
static const uint8_t rv60_cbp8_lens[7][4][64]
static const uint8_t rv60_cbp16_lens[7][3][4][64]
static const CoeffLens rv60_inter_lens[7]
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
enum AVDiscard skip_frame
Skip decoding for selected frames.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
struct ThreadProgress * progress
uint8_t avg_buffer[64 *64+32 *32 *2]
uint8_t cu_split[1+4+16+64]
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
For static VLCs, the number of bits can often be hardcoded at each get_vlc2() callsite.
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static int ref[MAX_W *MAX_W]
static struct @232240247175332074307271266321204261331170211232 state
av_cold void ff_thread_progress_destroy(ThreadProgress *pro)
Destroy a ThreadProgress.
av_cold int ff_thread_progress_init(ThreadProgress *pro, int init_mode)
Initialize a ThreadProgress.
void ff_thread_progress_report(ThreadProgress *pro, int n)
This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of p...
void ff_thread_progress_await(const ThreadProgress *pro_c, int n)
This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain...
static void ff_thread_progress_reset(ThreadProgress *pro)
Reset the ThreadProgress.progress counter; must only be called if the ThreadProgress is not in use in...
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Core video DSP helper functions.
#define VLC_INIT_STATE(_table)
static const VLCElem * ff_vlc_init_tables(VLCInitState *state, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, int flags)
static const uint8_t quant[64]