• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavfilter/libmpcodecs/vf_yuvcsp.c

Go to the documentation of this file.
00001 /*
00002  * This file is part of MPlayer.
00003  *
00004  * MPlayer is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * MPlayer is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License along
00015  * with MPlayer; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022 #include <inttypes.h>
00023 
00024 #include "config.h"
00025 #include "mp_msg.h"
00026 
00027 #include "img_format.h"
00028 #include "mp_image.h"
00029 #include "vf.h"
00030 
00031 struct vf_priv_s {
00032     int csp;
00033 };
00034 
00035 //===========================================================================//
00036 
00037 static int config(struct vf_instance *vf,
00038         int width, int height, int d_width, int d_height,
00039         unsigned int flags, unsigned int outfmt){
00040     return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
00041 }
00042 
00043 static inline int clamp_y(int x){
00044     return (x > 235) ? 235 : (x < 16) ? 16 : x;
00045 }
00046 
00047 static inline int clamp_c(int x){
00048     return (x > 240) ? 240 : (x < 16) ? 16 : x;
00049 }
00050 
00051 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
00052     int i,j;
00053     uint8_t *y_in, *cb_in, *cr_in;
00054     uint8_t *y_out, *cb_out, *cr_out;
00055 
00056     vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
00057         MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
00058         mpi->width, mpi->height);
00059 
00060     y_in = mpi->planes[0];
00061     cb_in = mpi->planes[1];
00062     cr_in = mpi->planes[2];
00063 
00064     y_out = vf->dmpi->planes[0];
00065     cb_out = vf->dmpi->planes[1];
00066     cr_out = vf->dmpi->planes[2];
00067 
00068     for (i = 0; i < mpi->height; i++)
00069         for (j = 0; j < mpi->width; j++)
00070             y_out[i*vf->dmpi->stride[0]+j] = clamp_y(y_in[i*mpi->stride[0]+j]);
00071 
00072     for (i = 0; i < mpi->chroma_height; i++)
00073         for (j = 0; j < mpi->chroma_width; j++)
00074         {
00075             cb_out[i*vf->dmpi->stride[1]+j] = clamp_c(cb_in[i*mpi->stride[1]+j]);
00076             cr_out[i*vf->dmpi->stride[2]+j] = clamp_c(cr_in[i*mpi->stride[2]+j]);
00077         }
00078 
00079     return vf_next_put_image(vf,vf->dmpi, pts);
00080 }
00081 
00082 //===========================================================================//
00083 
00084 /*
00085 static void uninit(struct vf_instance *vf){
00086         free(vf->priv);
00087 }
00088 */
00089 
00090 static int query_format(struct vf_instance *vf, unsigned int fmt){
00091     switch(fmt){
00092         case IMGFMT_YV12:
00093         case IMGFMT_I420:
00094         case IMGFMT_IYUV:
00095             return 1;
00096     }
00097     return 0;
00098 }
00099 
00100 static int vf_open(vf_instance_t *vf, char *args){
00101     vf->config=config;
00102     vf->put_image=put_image;
00103 //    vf->uninit=uninit;
00104     vf->query_format=query_format;
00105 //    vf->priv=calloc(1, sizeof(struct vf_priv_s));
00106 //    if (args)
00107 //        vf->priv->csp = atoi(args);
00108     return 1;
00109 }
00110 
00111 const vf_info_t vf_info_yuvcsp = {
00112     "yuv colorspace converter",
00113     "yuvcsp",
00114     "Alex Beregszaszi",
00115     "",
00116     vf_open,
00117     NULL
00118 };
00119 
00120 //===========================================================================//
Generated on Fri Feb 1 2013 14:34:49 for FFmpeg by doxygen 1.7.1