59 uint8_t *dest_cr,
int mb_x,
int mb_y)
62 int dc, dcu, dcv, y, i;
63 for (i = 0; i < 4; i++) {
64 dc = s->
dc_val[0][mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * s->
b8_stride];
69 for (y = 0; y < 8; y++) {
71 for (x = 0; x < 8; x++)
72 dest_y[x + (i & 1) * 8 + (y + (i >> 1) * 8) * linesize[0]] = dc / 8;
85 for (y = 0; y < 8; y++) {
87 for (x = 0; x < 8; x++) {
88 dest_cb[x + y * linesize[1]] = dcu / 8;
89 dest_cr[x + y * linesize[2]] = dcv / 8;
99 for (y = 1; y < height - 1; y++) {
100 int prev_dc = data[0 + y *
stride];
102 for (x = 1; x < width - 1; x++) {
105 data[x + y *
stride] * 8 -
107 dc = (dc * 10923 + 32768) >> 16;
108 prev_dc = data[x + y *
stride];
114 for (x = 1; x < width - 1; x++) {
115 int prev_dc = data[x];
117 for (y = 1; y < height - 1; y++) {
121 data[x + y *
stride] * 8 -
122 data[x + (y + 1) * stride];
123 dc = (dc * 10923 + 32768) >> 16;
124 prev_dc = data[x + y *
stride];
136 int h,
int stride,
int is_luma)
140 for (b_y = 0; b_y < h; b_y++) {
141 for (b_x = 0; b_x < w; b_x++) {
142 int color[4] = { 1024, 1024, 1024, 1024 };
143 int distance[4] = { 9999, 9999, 9999, 9999 };
144 int mb_index, error, j;
145 int64_t guess, weight_sum;
146 mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->
mb_stride;
155 for (j = b_x + 1; j < w; j++) {
156 int mb_index_j = (j >> is_luma) + (b_y >> is_luma) * s->
mb_stride;
159 if (intra_j == 0 || !(error_j & ER_DC_ERROR)) {
160 color[0] = dc[j + b_y *
stride];
161 distance[0] = j - b_x;
167 for (j = b_x - 1; j >= 0; j--) {
168 int mb_index_j = (j >> is_luma) + (b_y >> is_luma) * s->
mb_stride;
171 if (intra_j == 0 || !(error_j & ER_DC_ERROR)) {
172 color[1] = dc[j + b_y *
stride];
173 distance[1] = b_x - j;
179 for (j = b_y + 1; j < h; j++) {
180 int mb_index_j = (b_x >> is_luma) + (j >> is_luma) * s->
mb_stride;
184 if (intra_j == 0 || !(error_j & ER_DC_ERROR)) {
185 color[2] = dc[b_x + j *
stride];
186 distance[2] = j - b_y;
192 for (j = b_y - 1; j >= 0; j--) {
193 int mb_index_j = (b_x >> is_luma) + (j >> is_luma) * s->
mb_stride;
196 if (intra_j == 0 || !(error_j & ER_DC_ERROR)) {
197 color[3] = dc[b_x + j *
stride];
198 distance[3] = b_y - j;
205 for (j = 0; j < 4; j++) {
206 int64_t weight = 256 * 256 * 256 * 16 / distance[j];
207 guess += weight * (int64_t) color[j];
208 weight_sum += weight;
210 guess = (guess + weight_sum / 2) / weight_sum;
211 dc[b_x + b_y *
stride] = guess;
222 int h,
int stride,
int is_luma)
224 int b_x, b_y, mvx_stride, mvy_stride;
227 mvx_stride >>= is_luma;
228 mvy_stride *= mvx_stride;
230 for (b_y = 0; b_y < h; b_y++) {
231 for (b_x = 0; b_x < w - 1; b_x++) {
239 int offset = b_x * 8 + b_y * stride * 8;
240 int16_t *left_mv = s->
cur_pic.
motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
241 int16_t *right_mv = s->
cur_pic.
motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
242 if (!(left_damage || right_damage))
244 if ((!left_intra) && (!right_intra) &&
245 FFABS(left_mv[0] - right_mv[0]) +
246 FFABS(left_mv[1] + right_mv[1]) < 2)
249 for (y = 0; y < 8; y++) {
252 a = dst[offset + 7 + y *
stride] - dst[offset + 6 + y *
stride];
253 b = dst[offset + 8 + y *
stride] - dst[offset + 7 + y *
stride];
254 c = dst[offset + 9 + y *
stride] - dst[offset + 8 + y *
stride];
264 if (!(left_damage && right_damage))
268 dst[offset + 7 + y *
stride] = cm[dst[offset + 7 + y *
stride] + ((d * 7) >> 4)];
269 dst[offset + 6 + y *
stride] = cm[dst[offset + 6 + y *
stride] + ((d * 5) >> 4)];
270 dst[offset + 5 + y *
stride] = cm[dst[offset + 5 + y *
stride] + ((d * 3) >> 4)];
271 dst[offset + 4 + y *
stride] = cm[dst[offset + 4 + y *
stride] + ((d * 1) >> 4)];
274 dst[offset + 8 + y *
stride] = cm[dst[offset + 8 + y *
stride] - ((d * 7) >> 4)];
275 dst[offset + 9 + y *
stride] = cm[dst[offset + 9 + y *
stride] - ((d * 5) >> 4)];
276 dst[offset + 10+ y *
stride] = cm[dst[offset + 10 + y *
stride] - ((d * 3) >> 4)];
277 dst[offset + 11+ y *
stride] = cm[dst[offset + 11 + y *
stride] - ((d * 1) >> 4)];
292 int b_x, b_y, mvx_stride, mvy_stride;
295 mvx_stride >>= is_luma;
296 mvy_stride *= mvx_stride;
298 for (b_y = 0; b_y < h - 1; b_y++) {
299 for (b_x = 0; b_x < w; b_x++) {
307 int offset = b_x * 8 + b_y * stride * 8;
310 int16_t *bottom_mv = s->
cur_pic.
motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
312 if (!(top_damage || bottom_damage))
315 if ((!top_intra) && (!bottom_intra) &&
316 FFABS(top_mv[0] - bottom_mv[0]) +
317 FFABS(top_mv[1] + bottom_mv[1]) < 2)
320 for (x = 0; x < 8; x++) {
323 a = dst[offset + x + 7 *
stride] - dst[offset + x + 6 *
stride];
324 b = dst[offset + x + 8 *
stride] - dst[offset + x + 7 *
stride];
325 c = dst[offset + x + 9 *
stride] - dst[offset + x + 8 *
stride];
335 if (!(top_damage && bottom_damage))
339 dst[offset + x + 7 *
stride] = cm[dst[offset + x + 7 *
stride] + ((d * 7) >> 4)];
340 dst[offset + x + 6 *
stride] = cm[dst[offset + x + 6 *
stride] + ((d * 5) >> 4)];
341 dst[offset + x + 5 *
stride] = cm[dst[offset + x + 5 *
stride] + ((d * 3) >> 4)];
342 dst[offset + x + 4 *
stride] = cm[dst[offset + x + 4 *
stride] + ((d * 1) >> 4)];
345 dst[offset + x + 8 *
stride] = cm[dst[offset + x + 8 *
stride] - ((d * 7) >> 4)];
346 dst[offset + x + 9 *
stride] = cm[dst[offset + x + 9 *
stride] - ((d * 5) >> 4)];
347 dst[offset + x + 10 *
stride] = cm[dst[offset + x + 10 *
stride] - ((d * 3) >> 4)];
348 dst[offset + x + 11 *
stride] = cm[dst[offset + x + 11 *
stride] - ((d * 1) >> 4)];
360 #define MV_UNCHANGED 1 364 int i, depth, num_avail;
365 int mb_x, mb_y, mot_step, mot_stride;
370 for (i = 0; i < s->
mb_num; i++) {
386 num_avail <= mb_width / 2) {
387 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
388 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
389 const int mb_xy = mb_x + mb_y * s->
mb_stride;
406 for (depth = 0; ; depth++) {
407 int changed,
pass, none_left;
411 for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
416 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
417 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
418 const int mb_xy = mb_x + mb_y * s->
mb_stride;
419 int mv_predictor[8][2] = { { 0 } };
423 int best_score = 256 * 256 * 256 * 64;
425 const int mot_index = (mb_x + mb_y * mot_stride) * mot_step;
426 int prev_x, prev_y, prev_ref;
428 if ((mb_x ^ mb_y ^ pass) & 1)
435 if (mb_x > 0 && fixed[mb_xy - 1] ==
MV_FROZEN)
437 if (mb_x + 1 < mb_width && fixed[mb_xy + 1] ==
MV_FROZEN)
439 if (mb_y > 0 && fixed[mb_xy - mb_stride] ==
MV_FROZEN)
441 if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] ==
MV_FROZEN)
447 if (mb_x > 0 && fixed[mb_xy - 1 ] ==
MV_CHANGED)
449 if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] ==
MV_CHANGED)
451 if (mb_y > 0 && fixed[mb_xy - mb_stride] ==
MV_CHANGED)
453 if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] ==
MV_CHANGED)
455 if (j == 0 && pass > 1)
460 if (mb_x > 0 && fixed[mb_xy - 1]) {
461 mv_predictor[pred_count][0] =
463 mv_predictor[pred_count][1] =
469 if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
470 mv_predictor[pred_count][0] =
472 mv_predictor[pred_count][1] =
478 if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
479 mv_predictor[pred_count][0] =
481 mv_predictor[pred_count][1] =
487 if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) {
488 mv_predictor[pred_count][0] =
490 mv_predictor[pred_count][1] =
499 if (pred_count > 1) {
500 int sum_x = 0, sum_y = 0, sum_r = 0;
501 int max_x, max_y, min_x, min_y, max_r, min_r;
503 for (j = 0; j < pred_count; j++) {
504 sum_x += mv_predictor[j][0];
505 sum_y += mv_predictor[j][1];
507 if (j && ref[j] != ref[j - 1])
508 goto skip_mean_and_median;
512 mv_predictor[pred_count][0] = sum_x / j;
513 mv_predictor[pred_count][1] = sum_y / j;
514 ref[pred_count] = sum_r / j;
517 if (pred_count >= 3) {
518 min_y = min_x = min_r = 99999;
519 max_y = max_x = max_r = -99999;
521 min_x = min_y = max_x = max_y = min_r = max_r = 0;
523 for (j = 0; j < pred_count; j++) {
524 max_x =
FFMAX(max_x, mv_predictor[j][0]);
525 max_y =
FFMAX(max_y, mv_predictor[j][1]);
526 max_r =
FFMAX(max_r, ref[j]);
527 min_x =
FFMIN(min_x, mv_predictor[j][0]);
528 min_y =
FFMIN(min_y, mv_predictor[j][1]);
529 min_r =
FFMIN(min_r, ref[j]);
531 mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
532 mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
533 ref[pred_count + 1] = sum_r - max_r - min_r;
535 if (pred_count == 4) {
536 mv_predictor[pred_count + 1][0] /= 2;
537 mv_predictor[pred_count + 1][1] /= 2;
538 ref[pred_count + 1] /= 2;
543 skip_mean_and_median:
567 mv_predictor[pred_count][0] = prev_x;
568 mv_predictor[pred_count][1] = prev_y;
569 ref[pred_count] = prev_ref;
574 for (j = 0; j < pred_count; j++) {
578 mb_x * 16 + mb_y * 16 * linesize[0];
581 s->
mv[0][0][0] = mv_predictor[j][0];
583 s->
mv[0][0][1] = mv_predictor[j][1];
592 if (mb_x > 0 && fixed[mb_xy - 1]) {
594 for (k = 0; k < 16; k++)
595 score +=
FFABS(src[k * linesize[0] - 1] -
596 src[k * linesize[0]]);
598 if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
600 for (k = 0; k < 16; k++)
601 score +=
FFABS(src[k * linesize[0] + 15] -
602 src[k * linesize[0] + 16]);
604 if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
606 for (k = 0; k < 16; k++)
607 score +=
FFABS(src[k - linesize[0]] - src[k]);
609 if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) {
611 for (k = 0; k < 16; k++)
612 score +=
FFABS(src[k + linesize[0] * 15] -
613 src[k + linesize[0] * 16]);
616 if (score <= best_score) {
621 score_sum += best_score;
622 s->
mv[0][0][0] = mv_predictor[best_pred][0];
623 s->
mv[0][0][1] = mv_predictor[best_pred][1];
625 for (i = 0; i < mot_step; i++)
626 for (j = 0; j < mot_step; j++) {
635 if (s->
mv[0][0][0] != prev_x || s->
mv[0][0][1] != prev_y) {
647 for (i = 0; i < s->
mb_num; i++) {
657 int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
663 for (i = 0; i < s->
mb_num; i++) {
673 if (undamaged_count < 5)
680 s->
avctx->xvmc_acceleration &&
686 skip_amount =
FFMAX(undamaged_count / 50, 1);
690 for (mb_y = 0; mb_y < s->
mb_height - 1; mb_y++) {
691 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
693 const int mb_xy = mb_x + mb_y * s->
mb_stride;
701 if ((j % skip_amount) != 0)
707 mb_x * 16 + mb_y * 16 * linesize[0];
709 mb_x * 16 + mb_y * 16 * linesize[0];
716 is_intra_likely += s->
mecc->
sad[0](
NULL, last_mb_ptr, mb_ptr,
718 is_intra_likely -= s->
mecc->
sad[0](
NULL, last_mb_ptr,
719 last_mb_ptr + linesize[0] * 16,
729 return is_intra_likely > 0;
751 int endx,
int endy,
int status)
753 const int start_i = av_clip(startx + starty * s->
mb_width, 0, s->
mb_num - 1);
754 const int end_i = av_clip(endx + endy * s->
mb_width, 0, s->
mb_num);
762 if (start_i > end_i || start_xy > end_xy) {
764 "internal error, slice end before start\n");
792 (end_xy - start_xy) *
sizeof(
uint8_t));
795 for (i = start_xy; i < end_xy; i++)
821 int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
823 int threshold_part[4] = { 100, 100, 100 };
844 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
845 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
855 for (error_type = 1; error_type <= 3; error_type++) {
858 for (i = s->
mb_num - 1; i >= 0; i--) {
862 if (error & (1 << error_type))
864 if (error & (8 << error_type))
879 for (i = s->
mb_num - 1; i >= 0; i--) {
926 for (error_type = 1; error_type <= 3; error_type++) {
927 for (i = s->
mb_num - 1; i >= 0; i--) {
933 if (error & (1 << error_type))
937 if (distance < threshold_part[error_type - 1])
940 if (distance < threshold)
951 for (i = 0; i < s->
mb_num; i++) {
965 for (i = 0; i < s->
mb_num; i++) {
974 dc_error = ac_error = mv_error = 0;
975 for (i = 0; i < s->
mb_num; i++) {
986 dc_error, ac_error, mv_error);
991 for (i = 0; i < s->
mb_num; i++) {
1006 for (i = 0; i < s->
mb_num; i++) {
1013 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
1014 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
1015 const int mb_xy = mb_x + mb_y * s->
mb_stride;
1031 int mb_index = mb_x * 2 + mb_y * 2 * s->
b8_stride;
1034 for (j = 0; j < 4; j++) {
1045 mv_dir, mv_type, &s->
mv, mb_x, mb_y, 0, 0);
1051 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
1052 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
1053 int xy = mb_x * 2 + mb_y * 2 * s->
b8_stride;
1054 const int mb_xy = mb_x + mb_y * s->
mb_stride;
1104 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
1105 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
1106 int dc, dcu, dcv, y, n;
1108 uint8_t *dest_y, *dest_cb, *dest_cr;
1109 const int mb_xy = mb_x + mb_y * s->
mb_stride;
1119 dest_y = s->
cur_pic.
f->
data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1120 dest_cb = s->
cur_pic.
f->
data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1121 dest_cr = s->
cur_pic.
f->
data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1124 for (n = 0; n < 4; n++) {
1126 for (y = 0; y < 8; y++) {
1128 for (x = 0; x < 8; x++)
1129 dc += dest_y[x + (n & 1) * 8 +
1130 (y + (n >> 1) * 8) * linesize[0]];
1132 dc_ptr[(n & 1) + (n >> 1) * s->
b8_stride] = (dc + 4) >> 3;
1136 for (y = 0; y < 8; y++) {
1138 for (x = 0; x < 8; x++) {
1139 dcu += dest_cb[x + y * linesize[1]];
1140 dcv += dest_cr[x + y * linesize[2]];
1157 for (mb_y = 0; mb_y < s->
mb_height; mb_y++) {
1158 for (mb_x = 0; mb_x < s->
mb_width; mb_x++) {
1159 uint8_t *dest_y, *dest_cb, *dest_cr;
1160 const int mb_xy = mb_x + mb_y * s->
mb_stride;
1170 dest_y = s->
cur_pic.
f->
data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1171 dest_cb = s->
cur_pic.
f->
data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1172 dest_cr = s->
cur_pic.
f->
data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1174 put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1198 for (i = 0; i < s->
mb_num; i++) {
static void put_dc(ERContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int mb_x, int mb_y)
Replace the current MB with a flat dc-only version.
void ff_er_frame_end(ERContext *s)
static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h, int stride, int is_luma)
simple vertical deblocking filter used for error resilience
static void filter181(int16_t *data, int width, int height, int stride)
#define VP_START
< current MB is the first after a resync marker
static void guess_mv(ERContext *s)
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
struct AVHWAccel * hwaccel
Hardware accelerator in use.
Multithreading support functions.
static void guess_dc(ERContext *s, int16_t *dc, int w, int h, int stride, int is_luma)
guess the dc of blocks which do not have an undamaged dc
Libavcodec version macros.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
static const uint16_t mask[17]
int error_concealment
error concealment flags
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_log(void *avcl, int level, const char *fmt,...)
static float distance(float x, float y, int band)
uint8_t * error_status_table
common internal API header
useful rectangle filling function
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int skip_top
Number of macroblock rows at the top which are skipped.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
if(ac->has_optimized_func)
#define MV_TYPE_16X16
1 vector for the whole mb
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int skip_bottom
Number of macroblock rows at the bottom which are skipped.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define FF_DISABLE_DEPRECATION_WARNINGS
static const uint8_t color[]
static int is_intra_more_likely(ERContext *s)
int16_t(*[2] motion_val)[2]
#define FF_ENABLE_DEPRECATION_WARNINGS
void ff_er_frame_start(ERContext *s)
static void h_block_filter(ERContext *s, uint8_t *dst, int w, int h, int stride, int is_luma)
simple horizontal deblocking filter used for error resilience
#define MV_TYPE_8X8
4 vectors (h263, mpeg4 4MV)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
static void set_mv_strides(ERContext *s, int *mv_step, 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)