Statistics
| Branch: | Revision:

ffmpeg / libavfilter / libmpcodecs / vf_swapuv.c @ e4852fb3

History | View | Annotate | Download (2.99 KB)

1
/*
2
 * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
3
 *
4
 * This file is part of MPlayer.
5
 *
6
 * MPlayer is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * MPlayer is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along
17
 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 */
20

    
21
#include <stdio.h>
22
#include <stdlib.h>
23
#include <string.h>
24
#include <inttypes.h>
25
#include <assert.h>
26

    
27
#include "mp_msg.h"
28
#include "img_format.h"
29
#include "mp_image.h"
30
#include "vf.h"
31

    
32

    
33
//===========================================================================//
34

    
35
static void get_image(struct vf_instance *vf, mp_image_t *mpi){
36
    mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt,
37
        mpi->type, mpi->flags, mpi->w, mpi->h);
38

    
39
    mpi->planes[0]=dmpi->planes[0];
40
    mpi->planes[1]=dmpi->planes[2];
41
    mpi->planes[2]=dmpi->planes[1];
42
    mpi->stride[0]=dmpi->stride[0];
43
    mpi->stride[1]=dmpi->stride[2];
44
    mpi->stride[2]=dmpi->stride[1];
45
    mpi->width=dmpi->width;
46

    
47
    mpi->flags|=MP_IMGFLAG_DIRECT;
48
    mpi->priv=(void*)dmpi;
49
}
50

    
51
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
52
    mp_image_t *dmpi;
53

    
54
    if(mpi->flags&MP_IMGFLAG_DIRECT){
55
        dmpi=(mp_image_t*)mpi->priv;
56
    } else {
57
        dmpi=vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
58
        assert(mpi->flags&MP_IMGFLAG_PLANAR);
59
        dmpi->planes[0]=mpi->planes[0];
60
        dmpi->planes[1]=mpi->planes[2];
61
        dmpi->planes[2]=mpi->planes[1];
62
        dmpi->stride[0]=mpi->stride[0];
63
        dmpi->stride[1]=mpi->stride[2];
64
        dmpi->stride[2]=mpi->stride[1];
65
        dmpi->width=mpi->width;
66
    }
67

    
68
    vf_clone_mpi_attributes(dmpi, mpi);
69

    
70
    return vf_next_put_image(vf,dmpi, pts);
71
}
72

    
73
//===========================================================================//
74

    
75
static int query_format(struct vf_instance *vf, unsigned int fmt){
76
        switch(fmt)
77
        {
78
        case IMGFMT_YV12:
79
        case IMGFMT_I420:
80
        case IMGFMT_IYUV:
81
        case IMGFMT_YVU9:
82
        case IMGFMT_444P:
83
        case IMGFMT_422P:
84
        case IMGFMT_411P:
85
                return vf_next_query_format(vf, fmt);
86
        }
87
        return 0;
88
}
89

    
90
static int vf_open(vf_instance_t *vf, char *args){
91
    vf->put_image=put_image;
92
    vf->get_image=get_image;
93
    vf->query_format=query_format;
94
    return 1;
95
}
96

    
97
const vf_info_t vf_info_swapuv = {
98
    "UV swapper",
99
    "swapuv",
100
    "Michael Niedermayer",
101
    "",
102
    vf_open,
103
    NULL
104
};
105

    
106
//===========================================================================//