[FFmpeg-devel] [PATCH 1/2] lavfi/transpose: support slice threading

Michael Niedermayer michaelni at gmx.at
Fri Aug 16 00:29:17 CEST 2013


On Wed, Aug 14, 2013 at 09:39:32PM +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libavfilter/vf_transpose.c | 72 ++++++++++++++++++++++++++++++----------------
>  1 file changed, 47 insertions(+), 25 deletions(-)
> 
> diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
> index 3ee9c6d..82f68e5 100644
> --- a/libavfilter/vf_transpose.c
> +++ b/libavfilter/vf_transpose.c
> @@ -133,31 +133,19 @@ static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
>          ff_default_get_video_buffer(inlink, w, h);
>  }
>  
> -static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> +typedef struct ThreadData {
> +    AVFrame *in, *out;
> +} ThreadData;
> +
> +static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
> +                        int nb_jobs)
>  {
> -    TransContext *trans = inlink->dst->priv;
> -    AVFilterLink *outlink = inlink->dst->outputs[0];
> -    AVFrame *out;
> +    TransContext *trans = ctx->priv;
> +    ThreadData *td = arg;
> +    AVFrame *out = td->out;
> +    AVFrame *in = td->in;
>      int plane;
>  
> -    if (trans->passthrough)
> -        return ff_filter_frame(outlink, in);
> -
> -    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> -    if (!out) {
> -        av_frame_free(&in);
> -        return AVERROR(ENOMEM);
> -    }
> -
> -    out->pts = in->pts;
> -
> -    if (in->sample_aspect_ratio.num == 0) {
> -        out->sample_aspect_ratio = in->sample_aspect_ratio;
> -    } else {
> -        out->sample_aspect_ratio.num = in->sample_aspect_ratio.den;
> -        out->sample_aspect_ratio.den = in->sample_aspect_ratio.num;
> -    }
> -
>      for (plane = 0; out->data[plane]; plane++) {
>          int hsub = plane == 1 || plane == 2 ? trans->hsub : 0;
>          int vsub = plane == 1 || plane == 2 ? trans->vsub : 0;
> @@ -165,12 +153,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>          int inh  = in->height  >> vsub;
>          int outw = FF_CEIL_RSHIFT(out->width,  hsub);
>          int outh = FF_CEIL_RSHIFT(out->height, vsub);
> +        int start = (outh *  jobnr   ) / nb_jobs;
> +        int end   = (outh * (jobnr+1)) / nb_jobs;

squares should be faster than long thin rectangles
(this should be also true for the single thread case)



[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130816/b425dca3/attachment.asc>


More information about the ffmpeg-devel mailing list