FFmpeg
Loading...
Searching...
No Matches
cavs.c
Go to the documentation of this file.
1/*
2 * Chinese AVS video (AVS1-P2/P16, JiZhun and Broadcasting profiles) decoder.
3 * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file
24 * Chinese AVS video (AVS1-P2/P16, JiZhun and Broadcasting profiles) decoder
25 * @author Stefan Gehrer <stefan.gehrer@gmx.de>
26 */
27
28#include "libavutil/mem.h"
29#include "avcodec.h"
30#include "golomb.h"
31#include "h264chroma.h"
32#include "idctdsp.h"
33#include "mathops.h"
34#include "qpeldsp.h"
35#include "cavs.h"
36
37static const uint8_t alpha_tab[64] = {
38 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,
39 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 20,
40 22, 24, 26, 28, 30, 33, 33, 35, 35, 36, 37, 37, 39, 39, 42, 44,
41 46, 48, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
42};
43
44static const uint8_t beta_tab[64] = {
45 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
46 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,
47 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14,
48 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27
49};
50
51static const uint8_t tc_tab[64] = {
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
54 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
55 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9
56};
57
58/** mark block as unavailable, i.e. out of picture
59 * or not yet decoded */
60static const cavs_vector un_mv = { 0, 0, 1, NOT_AVAIL, 0 };
61
62/**
63 * Inverse block scan method 2 (clause 9.5.3 c), figure 23), for field
64 * coded pictures, as the inverse ff_permute_scantable() expects.
65 */
66static const uint8_t cavs_scan_field[64] = {
67 0, 8, 16, 1, 24, 32, 9, 17, 40, 48, 25, 2, 10, 56, 33, 18,
68 3, 41, 49, 26, 11, 19, 4, 57, 34, 12, 42, 27, 20, 50, 35, 28,
69 5, 13, 58, 43, 36, 21, 6, 29, 51, 44, 14, 22, 37, 59, 52, 30,
70 45, 60, 38, 53, 46, 61, 54, 7, 62, 15, 23, 31, 39, 47, 55, 63,
71};
72
73static const int8_t left_modifier_l[8] = { 0, -1, 6, -1, -1, 7, 6, 7 };
74static const int8_t top_modifier_l[8] = { -1, 1, 5, -1, -1, 5, 7, 7 };
75static const int8_t left_modifier_c[7] = { 5, -1, 2, -1, 6, 5, 6 };
76static const int8_t top_modifier_c[7] = { 4, 1, -1, -1, 4, 6, 6 };
77
78/*****************************************************************************
79 *
80 * in-loop deblocking filter
81 *
82 ****************************************************************************/
83
84static inline int get_bs(cavs_vector *mvP, cavs_vector *mvQ, int b)
85{
86 if ((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA))
87 return 2;
88 if((abs(mvP->x - mvQ->x) >= 4) ||
89 (abs(mvP->y - mvQ->y) >= 4) ||
90 (mvP->ref != mvQ->ref))
91 return 1;
92 if (b) {
93 mvP += MV_BWD_OFFS;
94 mvQ += MV_BWD_OFFS;
95 if((abs(mvP->x - mvQ->x) >= 4) ||
96 (abs(mvP->y - mvQ->y) >= 4) ||
97 (mvP->ref != mvQ->ref))
98 return 1;
99 }
100 return 0;
101}
102
103#define SET_PARAMS \
104 alpha = alpha_tab[av_clip_uintp2(qp_avg + h->alpha_offset, 6)]; \
105 beta = beta_tab[av_clip_uintp2(qp_avg + h->beta_offset, 6)]; \
106 tc = tc_tab[av_clip_uintp2(qp_avg + h->alpha_offset, 6)];
107
108/**
109 * in-loop deblocking filter for a single macroblock
110 *
111 * boundary strength (bs) mapping:
112 *
113 * --4---5--
114 * 0 2 |
115 * | 6 | 7 |
116 * 1 3 |
117 * ---------
118 */
119void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type)
120{
121 uint8_t bs[8];
122 int qp_avg, alpha, beta, tc;
123 int i;
124
125 /* save un-deblocked lines */
126 h->topleft_border_y = h->top_border_y[h->mbx * 16 + 15];
127 h->topleft_border_u = h->top_border_u[h->mbx * 10 + 8];
128 h->topleft_border_v = h->top_border_v[h->mbx * 10 + 8];
129 memcpy(&h->top_border_y[h->mbx * 16], h->cy + 15 * h->l_stride, 16);
130 memcpy(&h->top_border_u[h->mbx * 10 + 1], h->cu + 7 * h->c_stride, 8);
131 memcpy(&h->top_border_v[h->mbx * 10 + 1], h->cv + 7 * h->c_stride, 8);
132 for (i = 0; i < 8; i++) {
133 h->left_border_y[i * 2 + 1] = *(h->cy + 15 + (i * 2 + 0) * h->l_stride);
134 h->left_border_y[i * 2 + 2] = *(h->cy + 15 + (i * 2 + 1) * h->l_stride);
135 h->left_border_u[i + 1] = *(h->cu + 7 + i * h->c_stride);
136 h->left_border_v[i + 1] = *(h->cv + 7 + i * h->c_stride);
137 }
138 if (!h->loop_filter_disable) {
139 /* determine bs */
140 if (mb_type == I_8X8)
141 memset(bs, 2, 8);
142 else {
143 memset(bs, 0, 8);
144 if (ff_cavs_partition_flags[mb_type] & SPLITV) {
145 bs[2] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1], mb_type > P_8X8);
146 bs[3] = get_bs(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3], mb_type > P_8X8);
147 }
148 if (ff_cavs_partition_flags[mb_type] & SPLITH) {
149 bs[6] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2], mb_type > P_8X8);
150 bs[7] = get_bs(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3], mb_type > P_8X8);
151 }
152 bs[0] = get_bs(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0], mb_type > P_8X8);
153 bs[1] = get_bs(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2], mb_type > P_8X8);
154 bs[4] = get_bs(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0], mb_type > P_8X8);
155 bs[5] = get_bs(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1], mb_type > P_8X8);
156 }
157 if (AV_RN64(bs)) {
158 if (h->flags & A_AVAIL) {
159 qp_avg = (h->qp + h->left_qp + 1) >> 1;
161 h->cdsp.cavs_filter_lv(h->cy, h->l_stride, alpha, beta, tc, bs[0], bs[1]);
162 qp_avg = (ff_cavs_chroma_qp[h->qp] + ff_cavs_chroma_qp[h->left_qp] + 1) >> 1;
164 h->cdsp.cavs_filter_cv(h->cu, h->c_stride, alpha, beta, tc, bs[0], bs[1]);
165 h->cdsp.cavs_filter_cv(h->cv, h->c_stride, alpha, beta, tc, bs[0], bs[1]);
166 }
167 qp_avg = h->qp;
169 h->cdsp.cavs_filter_lv(h->cy + 8, h->l_stride, alpha, beta, tc, bs[2], bs[3]);
170 h->cdsp.cavs_filter_lh(h->cy + 8 * h->l_stride, h->l_stride, alpha, beta, tc, bs[6], bs[7]);
171
172 if (h->flags & B_AVAIL) {
173 qp_avg = (h->qp + h->top_qp[h->mbx] + 1) >> 1;
175 h->cdsp.cavs_filter_lh(h->cy, h->l_stride, alpha, beta, tc, bs[4], bs[5]);
176 qp_avg = (ff_cavs_chroma_qp[h->qp] + ff_cavs_chroma_qp[h->top_qp[h->mbx]] + 1) >> 1;
178 h->cdsp.cavs_filter_ch(h->cu, h->c_stride, alpha, beta, tc, bs[4], bs[5]);
179 h->cdsp.cavs_filter_ch(h->cv, h->c_stride, alpha, beta, tc, bs[4], bs[5]);
180 }
181 }
182 }
183 h->left_qp = h->qp;
184 h->top_qp[h->mbx] = h->qp;
185}
186
187#undef SET_PARAMS
188
189/*****************************************************************************
190 *
191 * spatial intra prediction
192 *
193 ****************************************************************************/
194
196 uint8_t **left, int block)
197{
198 int i;
199
200 switch (block) {
201 case 0:
202 *left = h->left_border_y;
203 h->left_border_y[0] = h->left_border_y[1];
204 memset(&h->left_border_y[17], h->left_border_y[16], 9);
205 memcpy(&top[1], &h->top_border_y[h->mbx * 16], 16);
206 top[17] = top[16];
207 top[0] = top[1];
208 if ((h->flags & A_AVAIL) && (h->flags & B_AVAIL))
209 h->left_border_y[0] = top[0] = h->topleft_border_y;
210 break;
211 case 1:
212 *left = h->intern_border_y;
213 for (i = 0; i < 8; i++)
214 h->intern_border_y[i + 1] = *(h->cy + 7 + i * h->l_stride);
215 memset(&h->intern_border_y[9], h->intern_border_y[8], 9);
216 h->intern_border_y[0] = h->intern_border_y[1];
217 memcpy(&top[1], &h->top_border_y[h->mbx * 16 + 8], 8);
218 if (h->flags & C_AVAIL)
219 memcpy(&top[9], &h->top_border_y[(h->mbx + 1) * 16], 8);
220 else
221 memset(&top[9], top[8], 9);
222 top[17] = top[16];
223 top[0] = top[1];
224 if (h->flags & B_AVAIL)
225 h->intern_border_y[0] = top[0] = h->top_border_y[h->mbx * 16 + 7];
226 break;
227 case 2:
228 *left = &h->left_border_y[8];
229 memcpy(&top[1], h->cy + 7 * h->l_stride, 16);
230 top[17] = top[16];
231 top[0] = top[1];
232 if (h->flags & A_AVAIL)
233 top[0] = h->left_border_y[8];
234 break;
235 case 3:
236 *left = &h->intern_border_y[8];
237 for (i = 0; i < 8; i++)
238 h->intern_border_y[i + 9] = *(h->cy + 7 + (i + 8) * h->l_stride);
239 memset(&h->intern_border_y[17], h->intern_border_y[16], 9);
240 memcpy(&top[0], h->cy + 7 + 7 * h->l_stride, 9);
241 memset(&top[9], top[8], 9);
242 break;
243 }
244}
245
247{
248 /* extend borders by one pixel */
249 h->left_border_u[9] = h->left_border_u[8];
250 h->left_border_v[9] = h->left_border_v[8];
251 if(h->flags & C_AVAIL) {
252 h->top_border_u[h->mbx*10 + 9] = h->top_border_u[h->mbx*10 + 11];
253 h->top_border_v[h->mbx*10 + 9] = h->top_border_v[h->mbx*10 + 11];
254 } else {
255 h->top_border_u[h->mbx * 10 + 9] = h->top_border_u[h->mbx * 10 + 8];
256 h->top_border_v[h->mbx * 10 + 9] = h->top_border_v[h->mbx * 10 + 8];
257 }
258 if((h->flags & A_AVAIL) && (h->flags & B_AVAIL)) {
259 h->top_border_u[h->mbx * 10] = h->left_border_u[0] = h->topleft_border_u;
260 h->top_border_v[h->mbx * 10] = h->left_border_v[0] = h->topleft_border_v;
261 } else {
262 h->left_border_u[0] = h->left_border_u[1];
263 h->left_border_v[0] = h->left_border_v[1];
264 h->top_border_u[h->mbx * 10] = h->top_border_u[h->mbx * 10 + 1];
265 h->top_border_v[h->mbx * 10] = h->top_border_v[h->mbx * 10 + 1];
266 }
267}
268
269static void intra_pred_vert(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
270{
271 int y;
272 uint64_t a = AV_RN64(&top[1]);
273 for (y = 0; y < 8; y++)
274 *((uint64_t *)(d + y * stride)) = a;
275}
276
277static void intra_pred_horiz(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
278{
279 int y;
280 uint64_t a;
281 for (y = 0; y < 8; y++) {
282 a = left[y + 1] * 0x0101010101010101ULL;
283 *((uint64_t *)(d + y * stride)) = a;
284 }
285}
286
287static void intra_pred_dc_128(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
288{
289 int y;
290 uint64_t a = 0x8080808080808080ULL;
291 for (y = 0; y < 8; y++)
292 *((uint64_t *)(d + y * stride)) = a;
293}
294
295static void intra_pred_plane(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
296{
297 int x, y, ia;
298 int ih = 0;
299 int iv = 0;
300 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
301
302 for (x = 0; x < 4; x++) {
303 ih += (x + 1) * (top[5 + x] - top[3 - x]);
304 iv += (x + 1) * (left[5 + x] - left[3 - x]);
305 }
306 ia = (top[8] + left[8]) << 4;
307 ih = (17 * ih + 16) >> 5;
308 iv = (17 * iv + 16) >> 5;
309 for (y = 0; y < 8; y++)
310 for (x = 0; x < 8; x++)
311 d[y * stride + x] = cm[(ia + (x - 3) * ih + (y - 3) * iv + 16) >> 5];
312}
313
314#define LOWPASS(ARRAY, INDEX) \
315 ((ARRAY[(INDEX) - 1] + 2 * ARRAY[(INDEX)] + ARRAY[(INDEX) + 1] + 2) >> 2)
316
317static void intra_pred_lp(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
318{
319 int x, y;
320 for (y = 0; y < 8; y++)
321 for (x = 0; x < 8; x++)
322 d[y * stride + x] = (LOWPASS(top, x + 1) + LOWPASS(left, y + 1)) >> 1;
323}
324
325static void intra_pred_down_left(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
326{
327 int x, y;
328 for (y = 0; y < 8; y++)
329 for (x = 0; x < 8; x++)
330 d[y * stride + x] = (LOWPASS(top, x + y + 2) + LOWPASS(left, x + y + 2)) >> 1;
331}
332
333static void intra_pred_down_right(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
334{
335 int x, y;
336 for (y = 0; y < 8; y++)
337 for (x = 0; x < 8; x++)
338 if (x == y)
339 d[y * stride + x] = (left[1] + 2 * top[0] + top[1] + 2) >> 2;
340 else if (x > y)
341 d[y * stride + x] = LOWPASS(top, x - y);
342 else
343 d[y * stride + x] = LOWPASS(left, y - x);
344}
345
346static void intra_pred_lp_left(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
347{
348 int x, y;
349 for (y = 0; y < 8; y++)
350 for (x = 0; x < 8; x++)
351 d[y * stride + x] = LOWPASS(left, y + 1);
352}
353
354static void intra_pred_lp_top(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
355{
356 int x, y;
357 for (y = 0; y < 8; y++)
358 for (x = 0; x < 8; x++)
359 d[y * stride + x] = LOWPASS(top, x + 1);
360}
361
362#undef LOWPASS
363
364static inline void modify_pred(const int8_t *mod_table, int *mode)
365{
366 *mode = mod_table[*mode];
367 if (*mode < 0) {
368 av_log(NULL, AV_LOG_ERROR, "Illegal intra prediction mode\n");
369 *mode = 0;
370 }
371}
372
373void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv)
374{
375 /* save pred modes before they get modified */
376 h->pred_mode_Y[3] = h->pred_mode_Y[5];
377 h->pred_mode_Y[6] = h->pred_mode_Y[8];
378 h->top_pred_Y[h->mbx * 2 + 0] = h->pred_mode_Y[7];
379 h->top_pred_Y[h->mbx * 2 + 1] = h->pred_mode_Y[8];
380
381 /* modify pred modes according to availability of neighbour samples */
382 if (!(h->flags & A_AVAIL)) {
383 modify_pred(left_modifier_l, &h->pred_mode_Y[4]);
384 modify_pred(left_modifier_l, &h->pred_mode_Y[7]);
385 modify_pred(left_modifier_c, pred_mode_uv);
386 }
387 if (!(h->flags & B_AVAIL)) {
388 modify_pred(top_modifier_l, &h->pred_mode_Y[4]);
389 modify_pred(top_modifier_l, &h->pred_mode_Y[5]);
390 modify_pred(top_modifier_c, pred_mode_uv);
391 }
392}
393
394/*****************************************************************************
395 *
396 * motion compensation
397 *
398 ****************************************************************************/
399
400static inline void mc_dir_part(AVSContext *h, AVFrame *pic, int parity,
401 int chroma_height,
402 int list, uint8_t *dest_y,
403 uint8_t *dest_cb, uint8_t *dest_cr,
404 int src_x_offset, int src_y_offset,
405 qpel_mc_func *qpix_op,
407{
408 if (!pic->data[0])
409 return;
410
411 const int mx = mv->x + src_x_offset * 8;
412 const int my = mv->y + src_y_offset * 8;
413 const int luma_xy = (mx & 3) + ((my & 3) << 2);
414 uint8_t *src_y = pic->data[0] + parity * pic->linesize[0] +
415 (mx >> 2) + (my >> 2) * h->l_stride;
416 uint8_t *src_cb = pic->data[1] + parity * pic->linesize[1] +
417 (mx >> 3) + (my >> 3) * h->c_stride;
418 uint8_t *src_cr = pic->data[2] + parity * pic->linesize[2] +
419 (mx >> 3) + (my >> 3) * h->c_stride;
420 int extra_width = 0;
421 int extra_height = extra_width;
422 const int full_mx = mx >> 2;
423 const int full_my = my >> 2;
424 const int pic_width = 16 * h->mb_width;
425 /* motion vectors address a field in quarter field lines (9.9.2.1) */
426 const int pic_height = h->pic_structure ? 16 * h->mb_height
427 : 8 * h->mb_height;
428 int emu = 0;
429
430 if (mx & 7)
431 extra_width -= 3;
432 if (my & 7)
433 extra_height -= 3;
434
435 if (full_mx < 0 - extra_width ||
436 full_my < 0 - extra_height ||
437 full_mx + 16 /* FIXME */ > pic_width + extra_width ||
438 full_my + 16 /* FIXME */ > pic_height + extra_height) {
439 h->vdsp.emulated_edge_mc(h->edge_emu_buffer,
440 src_y - 2 - 2 * h->l_stride,
441 h->l_stride, h->l_stride,
442 16 + 5, 16 + 5 /* FIXME */,
443 full_mx - 2, full_my - 2,
444 pic_width, pic_height);
445 src_y = h->edge_emu_buffer + 2 + 2 * h->l_stride;
446 emu = 1;
447 }
448
449 // FIXME try variable height perhaps?
450 qpix_op[luma_xy](dest_y, src_y, h->l_stride);
451
452 if (emu) {
453 h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cb,
454 h->c_stride, h->c_stride,
455 9, 9 /* FIXME */,
456 mx >> 3, my >> 3,
457 pic_width >> 1, pic_height >> 1);
458 src_cb = h->edge_emu_buffer;
459 }
460 chroma_op(dest_cb, src_cb, h->c_stride, chroma_height, mx & 7, my & 7);
461
462 if (emu) {
463 h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src_cr,
464 h->c_stride, h->c_stride,
465 9, 9 /* FIXME */,
466 mx >> 3, my >> 3,
467 pic_width >> 1, pic_height >> 1);
468 src_cr = h->edge_emu_buffer;
469 }
470 chroma_op(dest_cr, src_cr, h->c_stride, chroma_height, mx & 7, my & 7);
471}
472
473static inline void mc_part_std(AVSContext *h, int chroma_height,
474 uint8_t *dest_y,
475 uint8_t *dest_cb,
476 uint8_t *dest_cr,
477 int x_offset, int y_offset,
478 qpel_mc_func *qpix_put,
479 h264_chroma_mc_func chroma_put,
480 qpel_mc_func *qpix_avg,
481 h264_chroma_mc_func chroma_avg,
483{
484 qpel_mc_func *qpix_op = qpix_put;
485 h264_chroma_mc_func chroma_op = chroma_put;
486
487 dest_y += x_offset * 2 + y_offset * h->l_stride * 2;
488 dest_cb += x_offset + y_offset * h->c_stride;
489 dest_cr += x_offset + y_offset * h->c_stride;
490 x_offset += 8 * h->mbx;
491 /* the row is counted inside the current field (clause 3.24) */
492 y_offset += 8 * h->field_mby;
493
494 if (mv->ref >= 0) {
495 mc_dir_part(h, h->ref[mv->ref].f, h->ref[mv->ref].parity,
496 chroma_height, 0,
497 dest_y, dest_cb, dest_cr, x_offset, y_offset,
498 qpix_op, chroma_op, mv);
499
500 qpix_op = qpix_avg;
501 chroma_op = chroma_avg;
502 }
503
504 mv += MV_BWD_OFFS;
505 if (mv->ref >= 0) {
506 mc_dir_part(h, h->ref[mv->ref].f, h->ref[mv->ref].parity,
507 chroma_height, 1,
508 dest_y, dest_cb, dest_cr, x_offset, y_offset,
509 qpix_op, chroma_op, mv);
510 }
511}
512
513void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type)
514{
515 if (ff_cavs_partition_flags[mb_type] == 0) { // 16x16
516 mc_part_std(h, 8, h->cy, h->cu, h->cv, 0, 0,
517 h->cdsp.put_cavs_qpel_pixels_tab[0],
518 h->h264chroma.put_h264_chroma_pixels_tab[0],
519 h->cdsp.avg_cavs_qpel_pixels_tab[0],
520 h->h264chroma.avg_h264_chroma_pixels_tab[0],
521 &h->mv[MV_FWD_X0]);
522 } else {
523 mc_part_std(h, 4, h->cy, h->cu, h->cv, 0, 0,
524 h->cdsp.put_cavs_qpel_pixels_tab[1],
525 h->h264chroma.put_h264_chroma_pixels_tab[1],
526 h->cdsp.avg_cavs_qpel_pixels_tab[1],
527 h->h264chroma.avg_h264_chroma_pixels_tab[1],
528 &h->mv[MV_FWD_X0]);
529 mc_part_std(h, 4, h->cy, h->cu, h->cv, 4, 0,
530 h->cdsp.put_cavs_qpel_pixels_tab[1],
531 h->h264chroma.put_h264_chroma_pixels_tab[1],
532 h->cdsp.avg_cavs_qpel_pixels_tab[1],
533 h->h264chroma.avg_h264_chroma_pixels_tab[1],
534 &h->mv[MV_FWD_X1]);
535 mc_part_std(h, 4, h->cy, h->cu, h->cv, 0, 4,
536 h->cdsp.put_cavs_qpel_pixels_tab[1],
537 h->h264chroma.put_h264_chroma_pixels_tab[1],
538 h->cdsp.avg_cavs_qpel_pixels_tab[1],
539 h->h264chroma.avg_h264_chroma_pixels_tab[1],
540 &h->mv[MV_FWD_X2]);
541 mc_part_std(h, 4, h->cy, h->cu, h->cv, 4, 4,
542 h->cdsp.put_cavs_qpel_pixels_tab[1],
543 h->h264chroma.put_h264_chroma_pixels_tab[1],
544 h->cdsp.avg_cavs_qpel_pixels_tab[1],
545 h->h264chroma.avg_h264_chroma_pixels_tab[1],
546 &h->mv[MV_FWD_X3]);
547 }
548}
549
550/*****************************************************************************
551 *
552 * motion vector prediction
553 *
554 ****************************************************************************/
555
556static inline void scale_mv(AVSContext *h, int *d_x, int *d_y,
557 cavs_vector *src, int distp)
558{
559 int64_t den = h->scale_den[FFMAX(src->ref, 0)];
560 *d_x = (src->x * distp * den + 256 + FF_SIGNBIT(src->x)) >> 9;
561 *d_y = (src->y * distp * den + 256 + FF_SIGNBIT(src->y)) >> 9;
562}
563
564static inline void mv_pred_median(AVSContext *h,
565 cavs_vector *mvP,
566 cavs_vector *mvA,
567 cavs_vector *mvB,
568 cavs_vector *mvC)
569{
570 int ax, ay, bx, by, cx, cy;
571 int len_ab, len_bc, len_ca, len_mid;
572
573 /* scale candidates according to their temporal span */
574 scale_mv(h, &ax, &ay, mvA, mvP->dist);
575 scale_mv(h, &bx, &by, mvB, mvP->dist);
576 scale_mv(h, &cx, &cy, mvC, mvP->dist);
577 /* find the geometrical median of the three candidates */
578 len_ab = abs(ax - bx) + abs(ay - by);
579 len_bc = abs(bx - cx) + abs(by - cy);
580 len_ca = abs(cx - ax) + abs(cy - ay);
581 len_mid = mid_pred(len_ab, len_bc, len_ca);
582 if (len_mid == len_ab) {
583 mvP->x = cx;
584 mvP->y = cy;
585 } else if (len_mid == len_bc) {
586 mvP->x = ax;
587 mvP->y = ay;
588 } else {
589 mvP->x = bx;
590 mvP->y = by;
591 }
592}
593
595 enum cavs_mv_pred mode, enum cavs_block size, int ref)
596{
597 cavs_vector *mvP = &h->mv[nP];
598 cavs_vector *mvA = &h->mv[nP-1];
599 cavs_vector *mvB = &h->mv[nP-4];
600 cavs_vector *mvC = &h->mv[nC];
601 const cavs_vector *mvP2 = NULL;
602
603 mvP->ref = ref;
604 mvP->dist = h->dist[mvP->ref];
605 /* a derived reference has index 0 (clause 9.4.5) */
606 if (mode >= MV_PRED_PSKIP)
607 mvP->ref_idx = 0;
608 if (mvC->ref == NOT_AVAIL || (nP == MV_FWD_X3) || (nP == MV_BWD_X3 ))
609 mvC = &h->mv[nP - 5]; // set to top-left (mvD)
610 if (mode == MV_PRED_PSKIP &&
611 (mvA->ref == NOT_AVAIL ||
612 mvB->ref == NOT_AVAIL ||
613 (mvA->x | mvA->y | mvA->ref) == 0 ||
614 (mvB->x | mvB->y | mvB->ref) == 0)) {
615 mvP2 = &un_mv;
616 /* if there is only one suitable candidate, take it */
617 } else if (mvA->ref >= 0 && mvB->ref < 0 && mvC->ref < 0) {
618 mvP2 = mvA;
619 } else if (mvA->ref < 0 && mvB->ref >= 0 && mvC->ref < 0) {
620 mvP2 = mvB;
621 } else if (mvA->ref < 0 && mvB->ref < 0 && mvC->ref >= 0) {
622 mvP2 = mvC;
623 } else if (mode == MV_PRED_LEFT && mvA->ref == ref) {
624 mvP2 = mvA;
625 } else if (mode == MV_PRED_TOP && mvB->ref == ref) {
626 mvP2 = mvB;
627 } else if (mode == MV_PRED_TOPRIGHT && mvC->ref == ref) {
628 mvP2 = mvC;
629 }
630 if (mvP2) {
631 mvP->x = mvP2->x;
632 mvP->y = mvP2->y;
633 } else
634 mv_pred_median(h, mvP, mvA, mvB, mvC);
635
636 if (mode < MV_PRED_PSKIP) {
637 int dx, dy, mx, my;
638
639 /* under AEC mv_diff is already in the cache (aec_mv() in cavsdec.c) */
640 if (h->aec_enable) {
641 dx = h->mvd[nP][0];
642 dy = h->mvd[nP][1];
643 } else {
644 dx = get_se_golomb(&h->gb);
645 dy = get_se_golomb(&h->gb);
646 h->mvd[nP][0] = dx;
647 h->mvd[nP][1] = dy;
648 }
649 mx = dx + (unsigned)mvP->x;
650 my = dy + (unsigned)mvP->y;
651
652 if (mx != (int16_t)mx || my != (int16_t)my) {
653 av_log(h->avctx, AV_LOG_ERROR, "MV %d %d out of supported range\n", mx, my);
654 } else {
655 mvP->x = mx;
656 mvP->y = my;
657 }
658 set_mvds(&h->mvd[nP], size);
659 }
660 set_mvs(mvP, size);
661}
662
663/*****************************************************************************
664 *
665 * macroblock level
666 *
667 ****************************************************************************/
668
669/**
670 * Point the macroblock sample pointers at macroblock row h->mby, addressed
671 * inside the macroblock's own field at the doubled stride (clause 7.2.3.1).
672 */
674{
675 int parity = 0;
676
677 h->field = !h->pic_structure && h->mby >= h->mb_height / 2;
678 h->field_mby = h->mby - h->field * (h->mb_height / 2);
679 /* the first row of a field has nothing above it */
680 if (!h->field_mby)
681 h->flags &= ~(B_AVAIL | C_AVAIL | D_AVAIL);
682 if (!h->pic_structure)
683 parity = h->field ^ !h->top_field_first;
684
685 h->cy = h->cur.f->data[0] + parity * h->cur.f->linesize[0] +
686 h->field_mby * 16 * h->l_stride;
687 h->cu = h->cur.f->data[1] + parity * h->cur.f->linesize[1] +
688 h->field_mby * 8 * h->c_stride;
689 h->cv = h->cur.f->data[2] + parity * h->cur.f->linesize[2] +
690 h->field_mby * 8 * h->c_stride;
691}
692
693/**
694 * initialise predictors for motion vectors and intra prediction
695 */
697{
698 int i;
699
700 /* a macroblock has no mv_diff until one is decoded for it */
701 memset(h->mvd[MV_FWD_X0], 0, 2 * sizeof(*h->mvd));
702 memset(h->mvd[MV_FWD_X2], 0, 2 * sizeof(*h->mvd));
703 memset(h->mvd[MV_BWD_X0], 0, 2 * sizeof(*h->mvd));
704 memset(h->mvd[MV_BWD_X2], 0, 2 * sizeof(*h->mvd));
705 /* copy predictors from top line (MB B and C) into cache */
706 for (i = 0; i < 3; i++) {
707 h->mv[MV_FWD_B2 + i] = h->top_mv[0][h->mbx * 2 + i];
708 h->mv[MV_BWD_B2 + i] = h->top_mv[1][h->mbx * 2 + i];
709 }
710 h->pred_mode_Y[1] = h->top_pred_Y[h->mbx * 2 + 0];
711 h->pred_mode_Y[2] = h->top_pred_Y[h->mbx * 2 + 1];
712 /* clear top predictors if MB B is not available */
713 if (!(h->flags & B_AVAIL)) {
714 h->mv[MV_FWD_B2] = un_mv;
715 h->mv[MV_FWD_B3] = un_mv;
716 h->mv[MV_BWD_B2] = un_mv;
717 h->mv[MV_BWD_B3] = un_mv;
718 h->pred_mode_Y[1] = h->pred_mode_Y[2] = NOT_AVAIL;
719 h->flags &= ~(C_AVAIL | D_AVAIL);
720 } else if (h->mbx) {
721 h->flags |= D_AVAIL;
722 }
723 if (h->mbx == h->mb_width - 1) // MB C not available
724 h->flags &= ~C_AVAIL;
725 /* clear top-right predictors if MB C is not available */
726 if (!(h->flags & C_AVAIL)) {
727 h->mv[MV_FWD_C2] = un_mv;
728 h->mv[MV_BWD_C2] = un_mv;
729 }
730 /* clear top-left predictors if MB D is not available */
731 if (!(h->flags & D_AVAIL)) {
732 h->mv[MV_FWD_D3] = un_mv;
733 h->mv[MV_BWD_D3] = un_mv;
734 }
735}
736
737/**
738 * save predictors for later macroblocks and increase
739 * macroblock address
740 * @return 0 if end of frame is reached, 1 otherwise
741 */
743{
744 int i;
745
746 h->flags |= A_AVAIL;
747 h->cy += 16;
748 h->cu += 8;
749 h->cv += 8;
750 /* copy mvs as predictors to the left */
751 for (i = 0; i <= 20; i += 4) {
752 h->mv[i] = h->mv[i + 2];
753 memcpy(h->mvd[i], h->mvd[i + 2], sizeof(*h->mvd));
754 }
755 /* copy bottom mvs from cache to top line */
756 h->top_mv[0][h->mbx * 2 + 0] = h->mv[MV_FWD_X2];
757 h->top_mv[0][h->mbx * 2 + 1] = h->mv[MV_FWD_X3];
758 h->top_mv[1][h->mbx * 2 + 0] = h->mv[MV_BWD_X2];
759 h->top_mv[1][h->mbx * 2 + 1] = h->mv[MV_BWD_X3];
760 /* next MB address */
761 h->mbidx++;
762 h->mbx++;
763 if (h->mbx == h->mb_width) { // New mb line
764 h->flags = B_AVAIL | C_AVAIL;
765 /* clear left pred_modes */
766 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
767 /* clear left mv predictors */
768 for (i = 0; i <= 20; i += 4) {
769 h->mv[i] = un_mv;
770 memset(h->mvd[i], 0, sizeof(*h->mvd));
771 }
772 h->mbx = 0;
773 h->mby++;
774 if (h->mby == h->mb_height) { // Frame end
775 return 0;
776 }
777 /* re-calculate sample pointers */
779 }
780 return 1;
781}
782
783/*****************************************************************************
784 *
785 * frame level
786 *
787 ****************************************************************************/
788
790{
791 int i;
792
793 /* clear some predictors */
794 for (i = 0; i <= 20; i += 4) {
795 h->mv[i] = un_mv;
796 memset(h->mvd[i], 0, sizeof(*h->mvd));
797 }
798 h->mv[MV_BWD_X0] = CAVS_DIR_MV;
800 h->mv[MV_FWD_X0] = CAVS_DIR_MV;
802 h->pred_mode_Y[3] = h->pred_mode_Y[6] = NOT_AVAIL;
803 /* a field is every other line of the frame (clause 6.1.2) */
804 h->l_stride = h->cur.f->linesize[0] << !h->pic_structure;
805 h->c_stride = h->cur.f->linesize[1] << !h->pic_structure;
806 h->luma_scan[2] = 8 * h->l_stride;
807 h->luma_scan[3] = 8 * h->l_stride + 8;
808 h->mbx = h->mby = h->mbidx = 0;
809 h->flags = 0;
811
812 return 0;
813}
814
815/*****************************************************************************
816 *
817 * headers and interface
818 *
819 ****************************************************************************/
820
821/**
822 * some predictions require data from the top-neighbouring macroblock.
823 * this data has to be stored for one complete row of macroblocks
824 * and this storage space is allocated here
825 */
827{
828 /* alloc top line of predictors */
829 h->top_qp = av_mallocz(h->mb_width);
830 h->top_mv[0] = av_calloc(h->mb_width * 2 + 1, sizeof(cavs_vector));
831 h->top_mv[1] = av_calloc(h->mb_width * 2 + 1, sizeof(cavs_vector));
832 h->top_pred_Y = av_calloc(h->mb_width * 2, sizeof(*h->top_pred_Y));
833 h->top_border_y = av_calloc(h->mb_width + 1, 16);
834 h->top_border_u = av_calloc(h->mb_width, 10);
835 h->top_border_v = av_calloc(h->mb_width, 10);
836
837 /* alloc space for co-located MVs and types */
838 h->col_mv = av_calloc(h->mb_width * h->mb_height,
839 4 * sizeof(*h->col_mv));
840 h->col_type_base = av_mallocz(h->mb_width * h->mb_height);
841
842 h->top_cbp = av_mallocz(h->mb_width);
843 h->top_mb_type = av_mallocz(h->mb_width);
844 h->top_c_pred_mode = av_mallocz(h->mb_width);
845
846 if (!h->top_qp || !h->top_mv[0] || !h->top_mv[1] || !h->top_pred_Y ||
847 !h->top_cbp || !h->top_c_pred_mode || !h->top_mb_type ||
848 !h->top_border_y || !h->top_border_u || !h->top_border_v ||
849 !h->col_mv || !h->col_type_base) {
850 av_freep(&h->top_qp);
851 av_freep(&h->top_cbp);
852 av_freep(&h->top_c_pred_mode);
853 av_freep(&h->top_mb_type);
854 av_freep(&h->top_mv[0]);
855 av_freep(&h->top_mv[1]);
856 av_freep(&h->top_pred_Y);
857 av_freep(&h->top_border_y);
858 av_freep(&h->top_border_u);
859 av_freep(&h->top_border_v);
860 av_freep(&h->col_mv);
861 av_freep(&h->col_type_base);
862 return AVERROR(ENOMEM);
863 }
864 return 0;
865}
866
868{
869 AVSContext *h = avctx->priv_data;
870 uint8_t permutation[64];
871
872 ff_blockdsp_init(&h->bdsp);
873 ff_h264chroma_init(&h->h264chroma, 8);
874 ff_videodsp_init(&h->vdsp, 8);
875 ff_cavsdsp_init(&h->cdsp);
876 ff_init_scantable_permutation(permutation, h->cdsp.idct_perm);
877 ff_permute_scantable(h->permutated_scantable, ff_zigzag_direct, permutation);
878 ff_permute_scantable(h->permutated_scantable_field, cavs_scan_field,
879 permutation);
880 h->scantable = h->permutated_scantable;
881
882 h->avctx = avctx;
884
885 h->cur.f = av_frame_alloc();
886 h->DPB[0].f = av_frame_alloc();
887 h->DPB[1].f = av_frame_alloc();
888 if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f)
889 return AVERROR(ENOMEM);
890
891 h->luma_scan[0] = 0;
892 h->luma_scan[1] = 8;
893 h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert;
894 h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz;
895 h->intra_pred_l[INTRA_L_LP] = intra_pred_lp;
898 h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left;
899 h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top;
900 h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128;
901 h->intra_pred_c[INTRA_C_LP] = intra_pred_lp;
902 h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz;
903 h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert;
904 h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane;
905 h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left;
906 h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top;
907 h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128;
908 h->mv[7] = un_mv;
909 h->mv[19] = un_mv;
910 for (int i = 0; i < FF_ARRAY_ELEMS(h->direct_den); i++)
911 h->direct_den[i] = i ? 16384 / i : 0;
912 return 0;
913}
914
916{
917 AVSContext *h = avctx->priv_data;
918
919 av_frame_free(&h->cur.f);
920 av_frame_free(&h->DPB[0].f);
921 av_frame_free(&h->DPB[1].f);
922
923 av_freep(&h->top_qp);
924 av_freep(&h->top_cbp);
925 av_freep(&h->top_c_pred_mode);
926 av_freep(&h->top_mb_type);
927 av_freep(&h->top_mv[0]);
928 av_freep(&h->top_mv[1]);
929 av_freep(&h->top_pred_Y);
930 av_freep(&h->top_border_y);
931 av_freep(&h->top_border_u);
932 av_freep(&h->top_border_v);
933 av_freep(&h->col_mv);
934 av_freep(&h->col_type_base);
935 av_freep(&h->edge_emu_buffer);
936 av_freep(&h->deemulated_buf);
937 h->deemulated_buf_size = 0;
938 av_freep(&h->stc_offset);
939 h->stc_offset_size = 0;
940 return 0;
941}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
Definition dsp.h:67
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Definition dsp.h:67
Libavcodec external API header.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
static const uint8_t tc_tab[64]
Definition cavs.c:51
int ff_cavs_init_pic(AVSContext *h)
Definition cavs.c:789
void ff_cavs_set_mb_row(AVSContext *h)
Point the macroblock sample pointers at macroblock row h->mby, addressed inside the macroblock's own ...
Definition cavs.c:673
int ff_cavs_next_mb(AVSContext *h)
save predictors for later macroblocks and increase macroblock address
Definition cavs.c:742
void ff_cavs_load_intra_pred_chroma(AVSContext *h)
Definition cavs.c:246
static void mc_dir_part(AVSContext *h, AVFrame *pic, int parity, int chroma_height, 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, cavs_vector *mv)
Definition cavs.c:400
static const uint8_t beta_tab[64]
Definition cavs.c:44
static const uint8_t alpha_tab[64]
Definition cavs.c:37
void ff_cavs_load_intra_pred_luma(AVSContext *h, uint8_t *top, uint8_t **left, int block)
Definition cavs.c:195
av_cold int ff_cavs_end(AVCodecContext *avctx)
Definition cavs.c:915
void ff_cavs_mv(AVSContext *h, enum cavs_mv_loc nP, enum cavs_mv_loc nC, enum cavs_mv_pred mode, enum cavs_block size, int ref)
Definition cavs.c:594
av_cold int ff_cavs_init(AVCodecContext *avctx)
Definition cavs.c:867
static void intra_pred_horiz(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:277
#define LOWPASS(ARRAY, INDEX)
Definition cavs.c:314
static const int8_t left_modifier_c[7]
Definition cavs.c:75
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type)
Definition cavs.c:513
static void modify_pred(const int8_t *mod_table, int *mode)
Definition cavs.c:364
static const int8_t top_modifier_c[7]
Definition cavs.c:76
static void mc_part_std(AVSContext *h, int chroma_height, 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, cavs_vector *mv)
Definition cavs.c:473
static void intra_pred_lp_left(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:346
static void intra_pred_lp_top(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:354
void ff_cavs_modify_mb_i(AVSContext *h, int *pred_mode_uv)
Definition cavs.c:373
static void intra_pred_down_left(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:325
static const int8_t left_modifier_l[8]
Definition cavs.c:73
static const int8_t top_modifier_l[8]
Definition cavs.c:74
int ff_cavs_init_top_lines(AVSContext *h)
some predictions require data from the top-neighbouring macroblock.
Definition cavs.c:826
static void intra_pred_dc_128(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:287
static const uint8_t cavs_scan_field[64]
Inverse block scan method 2 (clause 9.5.3 c), figure 23), for field coded pictures,...
Definition cavs.c:66
static void mv_pred_median(AVSContext *h, cavs_vector *mvP, cavs_vector *mvA, cavs_vector *mvB, cavs_vector *mvC)
Definition cavs.c:564
static void intra_pred_down_right(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:333
#define SET_PARAMS
Definition cavs.c:103
static int get_bs(cavs_vector *mvP, cavs_vector *mvQ, int b)
Definition cavs.c:84
static const cavs_vector un_mv
mark block as unavailable, i.e.
Definition cavs.c:60
void ff_cavs_init_mb(AVSContext *h)
initialise predictors for motion vectors and intra prediction
Definition cavs.c:696
void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type)
in-loop deblocking filter for a single macroblock
Definition cavs.c:119
static void intra_pred_vert(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:269
static void intra_pred_lp(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:317
static void intra_pred_plane(uint8_t *d, uint8_t *top, uint8_t *left, ptrdiff_t stride)
Definition cavs.c:295
#define C_AVAIL
Definition cavs.h:50
#define MV_BWD_OFFS
Definition cavs.h:67
cavs_mv_pred
Definition cavs.h:113
@ MV_PRED_TOP
Definition cavs.h:116
@ MV_PRED_PSKIP
Definition cavs.h:118
@ MV_PRED_LEFT
Definition cavs.h:115
@ MV_PRED_TOPRIGHT
Definition cavs.h:117
const uint8_t ff_cavs_chroma_qp[64]
Definition cavsdata.c:57
static void set_mvds(int16_t(*mvd)[2], enum cavs_block size)
replicate one partition's mv_diff over the 8x8 blocks it covers
Definition cavs.h:332
cavs_mb
Definition cavs.h:70
@ I_8X8
Definition cavs.h:71
@ P_8X8
Definition cavs.h:76
@ INTRA_L_DC_128
Definition cavs.h:100
@ INTRA_L_LP_TOP
Definition cavs.h:99
@ INTRA_L_LP_LEFT
Definition cavs.h:98
@ INTRA_L_DOWN_LEFT
Definition cavs.h:96
@ INTRA_L_LP
Definition cavs.h:95
@ INTRA_L_DOWN_RIGHT
Definition cavs.h:97
@ INTRA_L_HORIZ
Definition cavs.h:94
@ INTRA_L_VERT
Definition cavs.h:93
#define SPLITH
Definition cavs.h:64
static void set_mvs(cavs_vector *mv, enum cavs_block size)
Definition cavs.h:316
#define SPLITV
Definition cavs.h:65
cavs_mv_loc
Definition cavs.h:129
@ MV_BWD_D3
Definition cavs.h:140
@ MV_FWD_C2
Definition cavs.h:133
@ MV_FWD_X3
Definition cavs.h:139
@ MV_FWD_A3
Definition cavs.h:137
@ MV_FWD_X1
Definition cavs.h:136
@ MV_BWD_B2
Definition cavs.h:141
@ MV_BWD_X3
Definition cavs.h:149
@ MV_BWD_B3
Definition cavs.h:142
@ MV_FWD_X0
Definition cavs.h:135
@ MV_FWD_D3
Definition cavs.h:130
@ MV_BWD_X2
Definition cavs.h:148
@ MV_FWD_B2
Definition cavs.h:131
@ MV_FWD_B3
Definition cavs.h:132
@ MV_FWD_X2
Definition cavs.h:138
@ MV_FWD_A1
Definition cavs.h:134
@ MV_BWD_X0
Definition cavs.h:145
@ MV_BWD_C2
Definition cavs.h:143
@ INTRA_C_PLANE
Definition cavs.h:107
@ INTRA_C_HORIZ
Definition cavs.h:105
@ INTRA_C_VERT
Definition cavs.h:106
@ INTRA_C_DC_128
Definition cavs.h:110
@ INTRA_C_LP_LEFT
Definition cavs.h:108
@ INTRA_C_LP
Definition cavs.h:104
@ INTRA_C_LP_TOP
Definition cavs.h:109
cavs_block
Definition cavs.h:122
@ BLK_16X16
Definition cavs.h:123
#define D_AVAIL
Definition cavs.h:51
const uint8_t ff_cavs_partition_flags[30]
Definition cavsdata.c:24
#define A_AVAIL
Definition cavs.h:48
#define B_AVAIL
Definition cavs.h:49
#define CAVS_DIR_MV
mark block as using intra prediction
Definition cavs.h:311
#define REF_INTRA
Definition cavs.h:53
#define NOT_AVAIL
Definition cavs.h:52
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#define abs(x)
static int16_t block[64]
Definition dct.c:125
#define cm
Definition dvbsubdec.c:40
static ListView * list
Definition ffplay.c:377
exp golomb vlc stuff
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
Definition golomb.h:239
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:65
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:53
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
void(* h264_chroma_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
Definition h264chroma.h:25
int a
static const int16_t alpha[]
Definition ilbcdata.h:55
#define b
Definition input.c:43
#define AV_RN64(p)
static const int8_t mv[256][2]
Definition 4xm.c:81
av_cold void ff_blockdsp_init(BlockDSPContext *c)
Definition blockdsp.c:58
av_cold void ff_cavsdsp_init(CAVSDSPContext *c)
Definition cavsdsp.c:551
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
Definition h264chroma.c:43
av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type)
Definition idctdsp.c:39
av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64], const uint8_t permutation[64])
Definition idctdsp.c:30
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
Definition videodsp.c:39
#define av_cold
Definition attributes.h:117
#define FFMAX(a, b)
Definition macros.h:47
const uint8_t ff_zigzag_direct[64]
Definition mathtables.c:137
#define mid_pred
Definition mathops.h:115
#define MAX_NEG_CROP
Definition mathops.h:31
#define FF_SIGNBIT(x)
Definition mathops.h:132
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
#define ff_crop_tab
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
quarterpel DSP functions
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition qpeldsp.h:65
#define FF_ARRAY_ELEMS(a)
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:644
void * priv_data
Definition avcodec.h:470
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:500
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:524
int16_t x
Definition cavs.h:153
int16_t y
Definition cavs.h:154
int16_t dist
Definition cavs.h:155
int16_t ref_idx
mb_reference_index of the block, 0 when it codes none (clause 9.4.5); ref above is where the referenc...
Definition cavs.h:161
int16_t ref
Definition cavs.h:156
Definition swscale.c:85
#define stride
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
static int ref[MAX_W *MAX_W]
int size
mcdeint parity
Definition vf_mcdeint.c:293
#define scale_mv(n, dim)