Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Ganesh Ajjanagadde authored on 2015/09/01 00:07:56... | ... |
@@ -328,24 +328,24 @@ static int query_formats(AVFilterContext *ctx) |
328 | 328 |
|
329 | 329 |
static int config_input(AVFilterLink *inlink) |
330 | 330 |
{ |
331 |
- SPPContext *spp = inlink->dst->priv; |
|
331 |
+ SPPContext *s = inlink->dst->priv; |
|
332 | 332 |
const int h = FFALIGN(inlink->h + 16, 16); |
333 | 333 |
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); |
334 | 334 |
const int bps = desc->comp[0].depth_minus1 + 1; |
335 | 335 |
|
336 |
- av_opt_set_int(spp->dct, "bits_per_sample", bps, 0); |
|
337 |
- avcodec_dct_init(spp->dct); |
|
336 |
+ av_opt_set_int(s->dct, "bits_per_sample", bps, 0); |
|
337 |
+ avcodec_dct_init(s->dct); |
|
338 | 338 |
|
339 | 339 |
if (ARCH_X86) |
340 |
- ff_spp_init_x86(spp); |
|
340 |
+ ff_spp_init_x86(s); |
|
341 | 341 |
|
342 |
- spp->hsub = desc->log2_chroma_w; |
|
343 |
- spp->vsub = desc->log2_chroma_h; |
|
344 |
- spp->temp_linesize = FFALIGN(inlink->w + 16, 16); |
|
345 |
- spp->temp = av_malloc_array(spp->temp_linesize, h * sizeof(*spp->temp)); |
|
346 |
- spp->src = av_malloc_array(spp->temp_linesize, h * sizeof(*spp->src) * 2); |
|
342 |
+ s->hsub = desc->log2_chroma_w; |
|
343 |
+ s->vsub = desc->log2_chroma_h; |
|
344 |
+ s->temp_linesize = FFALIGN(inlink->w + 16, 16); |
|
345 |
+ s->temp = av_malloc_array(s->temp_linesize, h * sizeof(*s->temp)); |
|
346 |
+ s->src = av_malloc_array(s->temp_linesize, h * sizeof(*s->src) * 2); |
|
347 | 347 |
|
348 |
- if (!spp->temp || !spp->src) |
|
348 |
+ if (!s->temp || !s->src) |
|
349 | 349 |
return AVERROR(ENOMEM); |
350 | 350 |
return 0; |
351 | 351 |
} |
... | ... |
@@ -353,7 +353,7 @@ static int config_input(AVFilterLink *inlink) |
353 | 353 |
static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
354 | 354 |
{ |
355 | 355 |
AVFilterContext *ctx = inlink->dst; |
356 |
- SPPContext *spp = ctx->priv; |
|
356 |
+ SPPContext *s = ctx->priv; |
|
357 | 357 |
AVFilterLink *outlink = ctx->outputs[0]; |
358 | 358 |
AVFrame *out = in; |
359 | 359 |
int qp_stride = 0; |
... | ... |
@@ -365,10 +365,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
365 | 365 |
* the quantizers from the B-frames (B-frames often have a higher QP), we |
366 | 366 |
* need to save the qp table from the last non B-frame; this is what the |
367 | 367 |
* following code block does */ |
368 |
- if (!spp->qp) { |
|
369 |
- qp_table = av_frame_get_qp_table(in, &qp_stride, &spp->qscale_type); |
|
368 |
+ if (!s->qp) { |
|
369 |
+ qp_table = av_frame_get_qp_table(in, &qp_stride, &s->qscale_type); |
|
370 | 370 |
|
371 |
- if (qp_table && !spp->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) { |
|
371 |
+ if (qp_table && !s->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) { |
|
372 | 372 |
int w, h; |
373 | 373 |
|
374 | 374 |
/* if the qp stride is not set, it means the QP are only defined on |
... | ... |
@@ -381,27 +381,27 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
381 | 381 |
h = FF_CEIL_RSHIFT(inlink->h, 4); |
382 | 382 |
} |
383 | 383 |
|
384 |
- if (w * h > spp->non_b_qp_alloc_size) { |
|
385 |
- int ret = av_reallocp_array(&spp->non_b_qp_table, w, h); |
|
384 |
+ if (w * h > s->non_b_qp_alloc_size) { |
|
385 |
+ int ret = av_reallocp_array(&s->non_b_qp_table, w, h); |
|
386 | 386 |
if (ret < 0) { |
387 |
- spp->non_b_qp_alloc_size = 0; |
|
387 |
+ s->non_b_qp_alloc_size = 0; |
|
388 | 388 |
return ret; |
389 | 389 |
} |
390 |
- spp->non_b_qp_alloc_size = w * h; |
|
390 |
+ s->non_b_qp_alloc_size = w * h; |
|
391 | 391 |
} |
392 | 392 |
|
393 |
- av_assert0(w * h <= spp->non_b_qp_alloc_size); |
|
394 |
- memcpy(spp->non_b_qp_table, qp_table, w * h); |
|
393 |
+ av_assert0(w * h <= s->non_b_qp_alloc_size); |
|
394 |
+ memcpy(s->non_b_qp_table, qp_table, w * h); |
|
395 | 395 |
} |
396 | 396 |
} |
397 | 397 |
|
398 |
- if (spp->log2_count && !ctx->is_disabled) { |
|
399 |
- if (!spp->use_bframe_qp && spp->non_b_qp_table) |
|
400 |
- qp_table = spp->non_b_qp_table; |
|
398 |
+ if (s->log2_count && !ctx->is_disabled) { |
|
399 |
+ if (!s->use_bframe_qp && s->non_b_qp_table) |
|
400 |
+ qp_table = s->non_b_qp_table; |
|
401 | 401 |
|
402 |
- if (qp_table || spp->qp) { |
|
403 |
- const int cw = FF_CEIL_RSHIFT(inlink->w, spp->hsub); |
|
404 |
- const int ch = FF_CEIL_RSHIFT(inlink->h, spp->vsub); |
|
402 |
+ if (qp_table || s->qp) { |
|
403 |
+ const int cw = FF_CEIL_RSHIFT(inlink->w, s->hsub); |
|
404 |
+ const int ch = FF_CEIL_RSHIFT(inlink->h, s->vsub); |
|
405 | 405 |
|
406 | 406 |
/* get a new frame if in-place is not possible or if the dimensions |
407 | 407 |
* are not multiple of 8 */ |
... | ... |
@@ -419,11 +419,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
419 | 419 |
out->height = in->height; |
420 | 420 |
} |
421 | 421 |
|
422 |
- filter(spp, out->data[0], in->data[0], out->linesize[0], in->linesize[0], inlink->w, inlink->h, qp_table, qp_stride, 1, depth); |
|
422 |
+ filter(s, out->data[0], in->data[0], out->linesize[0], in->linesize[0], inlink->w, inlink->h, qp_table, qp_stride, 1, depth); |
|
423 | 423 |
|
424 | 424 |
if (out->data[2]) { |
425 |
- filter(spp, out->data[1], in->data[1], out->linesize[1], in->linesize[1], cw, ch, qp_table, qp_stride, 0, depth); |
|
426 |
- filter(spp, out->data[2], in->data[2], out->linesize[2], in->linesize[2], cw, ch, qp_table, qp_stride, 0, depth); |
|
425 |
+ filter(s, out->data[1], in->data[1], out->linesize[1], in->linesize[1], cw, ch, qp_table, qp_stride, 0, depth); |
|
426 |
+ filter(s, out->data[2], in->data[2], out->linesize[2], in->linesize[2], cw, ch, qp_table, qp_stride, 0, depth); |
|
427 | 427 |
} |
428 | 428 |
emms_c(); |
429 | 429 |
} |
... | ... |
@@ -442,13 +442,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
442 | 442 |
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, |
443 | 443 |
char *res, int res_len, int flags) |
444 | 444 |
{ |
445 |
- SPPContext *spp = ctx->priv; |
|
445 |
+ SPPContext *s = ctx->priv; |
|
446 | 446 |
|
447 | 447 |
if (!strcmp(cmd, "level")) { |
448 | 448 |
if (!strcmp(args, "max")) |
449 |
- spp->log2_count = MAX_LEVEL; |
|
449 |
+ s->log2_count = MAX_LEVEL; |
|
450 | 450 |
else |
451 |
- spp->log2_count = av_clip(strtol(args, NULL, 10), 0, MAX_LEVEL); |
|
451 |
+ s->log2_count = av_clip(strtol(args, NULL, 10), 0, MAX_LEVEL); |
|
452 | 452 |
return 0; |
453 | 453 |
} |
454 | 454 |
return AVERROR(ENOSYS); |
... | ... |
@@ -456,44 +456,44 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar |
456 | 456 |
|
457 | 457 |
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) |
458 | 458 |
{ |
459 |
- SPPContext *spp = ctx->priv; |
|
459 |
+ SPPContext *s = ctx->priv; |
|
460 | 460 |
int ret; |
461 | 461 |
|
462 |
- spp->avctx = avcodec_alloc_context3(NULL); |
|
463 |
- spp->dct = avcodec_dct_alloc(); |
|
464 |
- if (!spp->avctx || !spp->dct) |
|
462 |
+ s->avctx = avcodec_alloc_context3(NULL); |
|
463 |
+ s->dct = avcodec_dct_alloc(); |
|
464 |
+ if (!s->avctx || !s->dct) |
|
465 | 465 |
return AVERROR(ENOMEM); |
466 | 466 |
|
467 | 467 |
if (opts) { |
468 | 468 |
AVDictionaryEntry *e = NULL; |
469 | 469 |
|
470 | 470 |
while ((e = av_dict_get(*opts, "", e, AV_DICT_IGNORE_SUFFIX))) { |
471 |
- if ((ret = av_opt_set(spp->dct, e->key, e->value, 0)) < 0) |
|
471 |
+ if ((ret = av_opt_set(s->dct, e->key, e->value, 0)) < 0) |
|
472 | 472 |
return ret; |
473 | 473 |
} |
474 | 474 |
av_dict_free(opts); |
475 | 475 |
} |
476 | 476 |
|
477 |
- spp->store_slice = store_slice_c; |
|
478 |
- switch (spp->mode) { |
|
479 |
- case MODE_HARD: spp->requantize = hardthresh_c; break; |
|
480 |
- case MODE_SOFT: spp->requantize = softthresh_c; break; |
|
477 |
+ s->store_slice = store_slice_c; |
|
478 |
+ switch (s->mode) { |
|
479 |
+ case MODE_HARD: s->requantize = hardthresh_c; break; |
|
480 |
+ case MODE_SOFT: s->requantize = softthresh_c; break; |
|
481 | 481 |
} |
482 | 482 |
return 0; |
483 | 483 |
} |
484 | 484 |
|
485 | 485 |
static av_cold void uninit(AVFilterContext *ctx) |
486 | 486 |
{ |
487 |
- SPPContext *spp = ctx->priv; |
|
487 |
+ SPPContext *s = ctx->priv; |
|
488 | 488 |
|
489 |
- av_freep(&spp->temp); |
|
490 |
- av_freep(&spp->src); |
|
491 |
- if (spp->avctx) { |
|
492 |
- avcodec_close(spp->avctx); |
|
493 |
- av_freep(&spp->avctx); |
|
489 |
+ av_freep(&s->temp); |
|
490 |
+ av_freep(&s->src); |
|
491 |
+ if (s->avctx) { |
|
492 |
+ avcodec_close(s->avctx); |
|
493 |
+ av_freep(&s->avctx); |
|
494 | 494 |
} |
495 |
- av_freep(&spp->dct); |
|
496 |
- av_freep(&spp->non_b_qp_table); |
|
495 |
+ av_freep(&s->dct); |
|
496 |
+ av_freep(&s->non_b_qp_table); |
|
497 | 497 |
} |
498 | 498 |
|
499 | 499 |
static const AVFilterPad spp_inputs[] = { |