X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff_plain/43945b2766befcb4b2a5eb9b57fd9c25d9f4c849..d4f89906e3b310609b636cf6071313ec557ec873:/libavfilter/vf_transpose.c diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index 8d44e56..49b54d7 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -1,21 +1,21 @@ /* - * Copyright (C) 2010 Stefano Sabatini - * Copyright (C) 2008 Vitor Sessak + * Copyright (c) 2010 Stefano Sabatini + * Copyright (c) 2008 Vitor Sessak * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -27,8 +27,11 @@ #include "libavutil/intreadwrite.h" #include "libavutil/pixdesc.h" -#include "libavcore/imgutils.h" +#include "libavutil/imgutils.h" #include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" typedef struct { int hsub, vsub; @@ -41,7 +44,7 @@ typedef struct { int dir; } TransContext; -static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +static av_cold int init(AVFilterContext *ctx, const char *args) { TransContext *trans = ctx->priv; trans->dir = 0; @@ -83,7 +86,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } @@ -102,19 +105,27 @@ static int config_props_output(AVFilterLink *outlink) outlink->w = inlink->h; outlink->h = inlink->w; - av_log(ctx, AV_LOG_INFO, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n", + if (inlink->sample_aspect_ratio.num){ + outlink->sample_aspect_ratio = av_div_q((AVRational){1,1}, inlink->sample_aspect_ratio); + } else + outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; + + av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n", inlink->w, inlink->h, trans->dir, outlink->w, outlink->h, trans->dir == 1 || trans->dir == 3 ? "clockwise" : "counterclockwise", trans->dir == 0 || trans->dir == 3); return 0; } -static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) +static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { AVFilterLink *outlink = inlink->dst->outputs[0]; - outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, - outlink->w, outlink->h); + outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, + outlink->w, outlink->h); + if (!outlink->out_buf) + return AVERROR(ENOMEM); + outlink->out_buf->pts = picref->pts; if (picref->video->pixel_aspect.num == 0) { @@ -124,16 +135,16 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) outlink->out_buf->video->pixel_aspect.den = picref->video->pixel_aspect.num; } - avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); + return ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { TransContext *trans = inlink->dst->priv; AVFilterBufferRef *inpic = inlink->cur_buf; AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf; AVFilterLink *outlink = inlink->dst->outputs[0]; - int plane; + int plane, ret; for (plane = 0; outpic->data[plane]; plane++) { int hsub = plane == 1 || plane == 2 ? trans->hsub : 0; @@ -184,10 +195,10 @@ static void end_frame(AVFilterLink *inlink) } } - avfilter_unref_buffer(inpic); - avfilter_draw_slice(outlink, 0, outpic->video->h, 1); - avfilter_end_frame(outlink); - avfilter_unref_buffer(outpic); + if ((ret = ff_draw_slice(outlink, 0, outpic->video->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_transpose = { @@ -199,14 +210,14 @@ AVFilter avfilter_vf_transpose = { .query_formats = query_formats, - .inputs = (AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .start_frame = start_frame, - .end_frame = end_frame, - .min_perms = AV_PERM_READ, }, - { .name = NULL}}, - .outputs = (AVFilterPad[]) {{ .name = "default", - .config_props = config_props_output, - .type = AVMEDIA_TYPE_VIDEO, }, - { .name = NULL}}, + .inputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .start_frame = start_frame, + .end_frame = end_frame, + .min_perms = AV_PERM_READ, }, + { .name = NULL}}, + .outputs = (const AVFilterPad[]) {{ .name = "default", + .config_props = config_props_output, + .type = AVMEDIA_TYPE_VIDEO, }, + { .name = NULL}}, };