Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-24 16:38:29 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-05-24 17:24:22 +0400
commit558ce3e5b74c37546c66a26e4e03733d4f09ed76 (patch)
treed1d50c8ceb7a34309a7dc01bca27bfc93cc00879 /libavfilter/vf_fade.c
parent2516b393d4dda849851cc44ccb610bd87cec1798 (diff)
parent8a994b7406b3ab24a6444037da9d1659f3125a01 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: vf_fade: support slice threading vf_yadif: support slice threading Conflicts: libavfilter/vf_fade.c libavfilter/vf_yadif.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_fade.c')
-rw-r--r--libavfilter/vf_fade.c81
1 files changed, 60 insertions, 21 deletions
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index a24fb2ac8e..60a690b9e9 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -158,11 +158,61 @@ static void fade_plane(int y, int h, int w,
}
}
-static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
+static int filter_slice_luma(AVFilterContext *ctx, void *arg, int jobnr,
+ int nb_jobs)
{
- FadeContext *s = inlink->dst->priv;
- uint8_t *p;
+ FadeContext *s = ctx->priv;
+ AVFrame *frame = arg;
+ int slice_h = frame->height / nb_jobs;
+ int slice_start = jobnr * slice_h;
+ int slice_end = (jobnr == nb_jobs - 1) ? frame->height : (jobnr + 1) * slice_h;
+ int i, j;
+
+ for (i = slice_start; i < slice_end; i++) {
+ uint8_t *p = frame->data[0] + i * frame->linesize[0];
+ for (j = 0; j < frame->width * s->bpp; j++) {
+ /* s->factor is using 16 lower-order bits for decimal
+ * places. 32768 = 1 << 15, it is an integer representation
+ * of 0.5 and is for rounding. */
+ *p = ((*p - s->black_level) * s->factor + s->black_level_scaled) >> 16;
+ p++;
+ }
+ }
+
+ return 0;
+}
+
+static int filter_slice_chroma(AVFilterContext *ctx, void *arg, int jobnr,
+ int nb_jobs)
+{
+ FadeContext *s = ctx->priv;
+ AVFrame *frame = arg;
+ int slice_h = FFALIGN(frame->height / nb_jobs, 1 << s->vsub);
+ int slice_start = jobnr * slice_h;
+ int slice_end = (jobnr == nb_jobs - 1) ? frame->height : (jobnr + 1) * slice_h;
int i, j, plane;
+ const int width = FF_CEIL_RSHIFT(frame->width, s->hsub);
+
+ for (plane = 1; plane < 3; plane++) {
+ for (i = slice_start; i < slice_end; i++) {
+ uint8_t *p = frame->data[plane] + (i >> s->vsub) * frame->linesize[plane];
+ for (j = 0; j < width; j++) {
+ /* 8421367 = ((128 << 1) + 1) << 15. It is an integer
+ * representation of 128.5. The .5 is for rounding
+ * purposes. */
+ *p = ((*p - 128) * s->factor + 8421367) >> 16;
+ p++;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
+{
+ AVFilterContext *ctx = inlink->dst;
+ FadeContext *s = ctx->priv;
double frame_timestamp = frame->pts == AV_NOPTS_VALUE ? -1 : frame->pts * av_q2d(inlink->time_base);
// Calculate Fade assuming this is a Fade In
@@ -216,7 +266,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if (s->factor < UINT16_MAX) {
if (s->alpha) {
// alpha only
- plane = s->is_packed_rgb ? 0 : A; // alpha is on plane 0 for packed formats
+ int plane = s->is_packed_rgb ? 0 : A; // alpha is on plane 0 for packed formats
// or plane 3 for planar formats
fade_plane(0, frame->height, inlink->w,
s->factor, s->black_level, s->black_level_scaled,
@@ -225,25 +275,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
1, frame->data[plane], frame->linesize[plane]);
} else {
/* luma or rgb plane */
- fade_plane(0, frame->height, inlink->w,
- s->factor, s->black_level, s->black_level_scaled,
- 0, 1, // offset & pixstep for Y plane or RGB packed format
- s->bpp, frame->data[0], frame->linesize[0]);
+ ctx->internal->execute(ctx, filter_slice_luma, frame, NULL,
+ FFMIN(frame->height, ctx->graph->nb_threads));
+
if (frame->data[1] && frame->data[2]) {
/* chroma planes */
- for (plane = 1; plane < 3; plane++) {
- for (i = 0; i < frame->height; i++) {
- const int width = FF_CEIL_RSHIFT(inlink->w, s->hsub);
- p = frame->data[plane] + (i >> s->vsub) * frame->linesize[plane];
- for (j = 0; j < width; j++) {
- /* 8421367 = ((128 << 1) + 1) << 15. It is an integer
- * representation of 128.5. The .5 is for rounding
- * purposes. */
- *p = ((*p - 128) * s->factor + 8421367) >> 16;
- p++;
- }
- }
- }
+ ctx->internal->execute(ctx, filter_slice_chroma, frame, NULL,
+ FFMIN(frame->height, ctx->graph->nb_threads));
}
}
}
@@ -314,4 +352,5 @@ AVFilter avfilter_vf_fade = {
.inputs = avfilter_vf_fade_inputs,
.outputs = avfilter_vf_fade_outputs,
+ .flags = AVFILTER_FLAG_SLICE_THREADS,
};