Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This file is part of FFmpeg, ported from MPlayer.
- *
- * FFmpeg is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * FFmpeg 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- /**
- * @file
- * field filter, ported from MPlayer
- * libmpcodecs/vf_field.c.
- */
- // Original includes
- /*#include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "config.h"
- #include "mp_msg.h"
- #include "mp_image.h"
- #include "vf.h"
- */
- #include "libavutil/pixdesc.h"
- #include "avfilter.h"
- #include "libavutil/avassert.h"
- #include "formats.h"
- #include "internal.h"
- #include "video.h"
- typedef struct {
- int field;
- } FieldContext;
- //===========================================================================//
- /*static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt){
- return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
- }*/
- /*static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
- vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
- MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
- mpi->width, mpi->height/2);
- // set up mpi as a double-stride image of dmpi:
- vf->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
- vf->dmpi->stride[0]=2*mpi->stride[0];
- if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
- vf->dmpi->planes[1]=mpi->planes[1]+
- mpi->stride[1]*vf->priv->field;
- vf->dmpi->stride[1]=2*mpi->stride[1];
- vf->dmpi->planes[2]=mpi->planes[2]+
- mpi->stride[2]*vf->priv->field;
- vf->dmpi->stride[2]=2*mpi->stride[2];
- } else
- vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
- return vf_next_put_image(vf,vf->dmpi, pts);
- }*/
- static int end_frame(AVFilterLink *inlink)
- {
- FieldContext *field = inlink->dst->priv;
- AVFilterLink *outlink = inlink->dst->outputs[0];
- AVFilterBufferRef *inpic = inlink ->cur_buf;
- AVFilterBufferRef *outpic = outlink->out_buf;
- int ret;
- // vf->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
- outpic->data[0] = inpic->data[0] + inpic->linesize[0] * field->field;
- //vf->dmpi->stride[0]=2*mpi->stride[0];
- outpic->linesize[0] = 2 * inpic->linesize[0];
- //if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
- // This still needs to be ported
- if (vf->dmpi->flags&MP_IMGFLAG_PLANAR) {
- // vf->dmpi->planes[1]=mpi->planes[1]+
- outpic->data[1] = inpic->data[1];
- //mpi->stride[1]*vf->priv->field;
- inpic->linesize[1] * field->field;
- // vf->dmpi->stride[1]=2*mpi->stride[1];
- outpic->linesize[1] = 2 * inpic->linesize[1];
- //vf->dmpi->planes[2]=mpi->planes[2]+
- outpic->data[2] = inpic->data[2] +
- // mpi->stride[2]*vf->priv->field;
- inpic->linesize[2] * field->field;
- //vf->dmpi->stride[2]=2*mpi->stride[2];
- outpic->linesize[2] = 2 * inpic->linesize[2];
- } else
- // vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
- outpic->data[1] = inpic->data[1]; // passthru bgr8 palette
- // return vf_next_put_image(vf,vf->dmpi, pts);
- if ((ret = ff_draw_slice(outlink, 0, inpic->video->h, 1)) < 0 ||
- (ret = ff_end_frame(outlink)) < 0)
- return ret;
- return 0;
- }
- //===========================================================================//
- /*static void uninit(struct vf_instance *vf)
- {
- free(vf->priv);
- }*/
- static av_cold void uninit(AVFilterContext *ctx)
- {
- FieldContext *field = ctx->priv;
- av_freep(&field->field);
- }
- /*static int vf_open(vf_instance_t *vf, char *args){
- vf->config=config;
- vf->put_image=put_image;
- vf->uninit=uninit;
- vf->default_reqs=VFCAP_ACCEPT_STRIDE;
- vf->priv=calloc(1, sizeof(struct vf_priv_s));
- if (args) sscanf(args, "%d", &vf->priv->field);
- vf->priv->field &= 1;
- return 1;
- }
- const vf_info_t vf_info_field = {
- "extract single field",
- "field",
- "Rich Felker",
- "",
- vf_open,
- NULL
- };*/
- static av_cold int init(AVFilterContext *ctx, const char *args)
- {
- FieldContext *field = ctx->priv;
- if (args)
- sscanf(args, "%d", field->field);
- return 0;
- }
- static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
- {
- return 0;
- }
- AVFilter avfilter_vf_field = {
- .name = "field",
- .description = NULL_IF_CONFIG_SMALL("Extract a single field."),
- .priv_size = sizeof(FieldContext),
- .init = init,
- .uninit = uninit,
- .query_formats = query_formats,
- .inputs = (const AVFilterPad[]) {
- { .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .draw_slice = null_draw_slice,
- .config_props = config_input,
- .end_frame = end_frame },
- { .name = NULL}
- },
- .outputs = (const AVFilterPad[]) {
- { .name = "default",
- .type = AVMEDIA_TYPE_VIDEO },
- { .name = NULL}
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement