annotate libmpcodecs/vf_rgb2bgr.c @ 31134:92755ba89e79

Ignore (but print out) offset with libtheora decoder. Patch by Giorgio Vazzana, mywing81 gmail
author cehoyos
date Sat, 22 May 2010 16:32:39 +0000
parents a972c1a4a012
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
19 #include <stdio.h>
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
20 #include <stdlib.h>
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
21 #include <string.h>
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
22 #include <inttypes.h>
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
23
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
24 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
25 #include "mp_msg.h"
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
26
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5596
diff changeset
27 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5596
diff changeset
28 #include "mp_image.h"
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
29 #include "vf.h"
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
30
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents: 17906
diff changeset
31 #include "libswscale/rgb2rgb.h"
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
32
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
33 //===========================================================================//
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
34
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
35 struct vf_priv_s {
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
36 unsigned int fmt;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
37 int forced;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
38 };
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
39
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
40 static unsigned int getfmt(unsigned int outfmt,int forced){
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
41 if(forced) switch(outfmt){
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
42 case IMGFMT_RGB24:
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
43 case IMGFMT_RGB32:
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
44 case IMGFMT_BGR24:
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
45 case IMGFMT_BGR32:
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
46 return outfmt;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
47 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
48 switch(outfmt){
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
49 case IMGFMT_RGB24: return IMGFMT_BGR24;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
50 case IMGFMT_RGB32: return IMGFMT_BGR32;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
51 case IMGFMT_BGR24: return IMGFMT_RGB24;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
52 case IMGFMT_BGR32: return IMGFMT_RGB32;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
53 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
54 return 0;
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
55 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
56
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
57 static int config(struct vf_instance *vf,
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
58 int width, int height, int d_width, int d_height,
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
59 unsigned int flags, unsigned int outfmt){
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
60 vf->priv->fmt=getfmt(outfmt,vf->priv->forced);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
61 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
62 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
63
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
64 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
65 mp_image_t *dmpi;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
66
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
67 // hope we'll get DR buffer:
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
68 dmpi=vf_get_image(vf->next,vf->priv->fmt,
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
69 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
70 mpi->w, mpi->h);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
71
5596
70e88ec799b4 handle width*bpp!=stride
arpi
parents: 5595
diff changeset
72 if(mpi->stride[0]!=dmpi->stride[0] || mpi->stride[0]!=mpi->w*(mpi->bpp/8)){
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
73 int y;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
74 unsigned char* src=mpi->planes[0];
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
75 unsigned char* dst=dmpi->planes[0];
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
76 int srcsize=mpi->w*mpi->bpp/8;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
77 for(y=0;y<mpi->h;y++){
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
78 if(mpi->bpp==32)
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
79 rgb32tobgr32(src,dst,srcsize);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
80 else
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
81 rgb24tobgr24(src,dst,srcsize);
5595
arpi
parents: 5594
diff changeset
82 src+=mpi->stride[0];
arpi
parents: 5594
diff changeset
83 dst+=dmpi->stride[0];
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
84 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
85 } else {
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
86 if(mpi->bpp==32)
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
87 rgb32tobgr32(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*4);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
88 else
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
89 rgb24tobgr24(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*3);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
90 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
91
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
92 return vf_next_put_image(vf,dmpi, pts);
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
93 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
94
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
95 //===========================================================================//
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
96
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
97 static int query_format(struct vf_instance *vf, unsigned int outfmt){
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
98 unsigned int fmt=getfmt(outfmt,vf->priv->forced);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
99 if(!fmt) return 0;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
100 return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW);
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
101 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
102
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
103 static int vf_open(vf_instance_t *vf, char *args){
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
104 vf->config=config;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
105 vf->put_image=put_image;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
106 vf->query_format=query_format;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
107 vf->priv=malloc(sizeof(struct vf_priv_s));
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
108 vf->priv->forced=args && !strcasecmp(args,"swap");
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
109 return 1;
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
110 }
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
111
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
112 const vf_info_t vf_info_rgb2bgr = {
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
113 "fast 24/32bpp RGB<->BGR conversion",
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
114 "rgb2bgr",
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
115 "A'rpi",
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
116 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
117 vf_open,
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 7368
diff changeset
118 NULL
5594
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
119 };
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
120
dc8ebd9736f4 rgb2bgr converter
arpi
parents:
diff changeset
121 //===========================================================================//