static void init_pullup(struct vf_instance *vf, mp_image_t *mpi)
{
	struct pullup_context *c = vf->priv->ctx;

	if (mpi->flags & MP_IMGFLAG_PLANAR) {
		c->format = PULLUP_FMT_Y;
		c->nplanes = 4;
		pullup_preinit_context(c);
		c->bpp[0] = c->bpp[1] = c->bpp[2] = 8;
		c->w[0] = mpi->w;
		c->h[0] = mpi->h;
		c->w[1] = c->w[2] = mpi->chroma_width;
		c->h[1] = c->h[2] = mpi->chroma_height;
		c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16);
		c->h[3] = 2;
		c->stride[0] = mpi->width;
		c->stride[1] = c->stride[2] = mpi->chroma_width;
		c->stride[3] = c->w[3];
		c->background[1] = c->background[2] = 128;
	}

	if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX;
	if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2;
	if (gCpuCaps.has3DNow) c->cpu |= PULLUP_CPU_3DNOW;
	if (gCpuCaps.has3DNowExt) c->cpu |= PULLUP_CPU_3DNOWEXT;
	if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE;
	if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2;

	pullup_init_context(c);

	vf->priv->init = 1;
	vf->priv->qbuf = malloc(c->w[3]);
}
Exemple #2
0
static VideoFilter *NewIvtcFilter(VideoFrameType inpixfmt,
                                  VideoFrameType outpixfmt,
                                  int *width, int *height, char *options,
                                  int threads)
{
    (void) threads;

    ThisFilter *filter;

    options = NULL;
    if (inpixfmt != FMT_YV12)
        return NULL;
    if (outpixfmt != FMT_YV12)
        return NULL;

    filter = malloc (sizeof (ThisFilter));

    if (filter == NULL)
    {
        fprintf (stderr, "Ivtc: failed to allocate memory for filter\n");
        return NULL;
    }

    memset(filter, 0, sizeof(ThisFilter));
    filter->progressive_frame_seen = 0;
    filter->interlaced_frame_seen = 0;
    filter->apply_filter = 0;
    filter->context = pullup_alloc_context();
    struct pullup_context *c = filter->context;
    c->metric_plane = 0;
    c->strict_breaks = 0;
    c->junk_left = c->junk_right = 1;
    c->junk_top = c->junk_bottom = 4;
    c->verbose = 0;
    c->format = PULLUP_FMT_Y;
    c->nplanes = 4;
    pullup_preinit_context(c);
    c->bpp[0] = c->bpp[1] = c->bpp[2] = 0;
    c->background[1] = c->background[2]  = 128;

    int pitches[3] = { *width, *width >> 1, *width >> 1 };
    SetupFilter(filter, *width, *height, pitches);

#if HAVE_MMX
    c->cpu      |= PULLUP_CPU_MMX;
#endif

    pullup_init_context(c);
    filter->vf.filter = &IvtcFilter;
    filter->vf.cleanup = &IvtcFilterCleanup;
    return (VideoFilter *) filter;
}