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

libavcodec/pixdesc.h

Go to the documentation of this file.
00001 /*
00002  * pixel format descriptor
00003  * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #include <inttypes.h>
00023 
00024 #include "libavutil/intreadwrite.h"
00025 
00026 typedef struct AVComponentDescriptor{
00027     uint16_t plane        :2;            
00028     uint16_t step_minus1  :3;            
00029     uint16_t offset_plus1 :3;            
00030     uint16_t shift        :3;            
00031     uint16_t depth_minus1 :4;            
00032 }AVComponentDescriptor;
00033 
00043 typedef struct AVPixFmtDescriptor{
00044     uint8_t nb_channels;        
00045 
00052     uint8_t log2_chroma_w;      
00053 
00060     uint8_t log2_chroma_h;
00061     uint8_t flags;
00062     AVComponentDescriptor comp[4]; 
00063 }AVPixFmtDescriptor;
00064 
00065 #define PIX_FMT_BE        1 ///< big-endian
00066 #define PIX_FMT_PAL       2 ///< Pixel format has a palette i data[1], values are indexes in this palette.
00067 #define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end.
00068 
00069 
00070 static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], AVPixFmtDescriptor *desc, int x, int y, int c, int w)
00071 {
00072     AVComponentDescriptor comp= desc->comp[c];
00073     int plane= comp.plane;
00074     int depth= comp.depth_minus1+1;
00075     int mask = (1<<depth)-1;
00076     int shift= comp.shift;
00077     int step = comp.step_minus1+1;
00078     int flags= desc->flags;
00079     const uint8_t *p= data[plane]+y*linesize[plane] + x * step + comp.offset_plus1 - 1;
00080 
00081     //FIXME initial x in case of PIX_FMT_BITSTREAM is wrong
00082 
00083     while(w--){
00084         int val;
00085         if(flags & PIX_FMT_BE) val= AV_RB16(p);
00086         else                   val= AV_RL16(p);
00087         val = (val>>shift) & mask;
00088         if(flags & PIX_FMT_PAL)
00089             val= data[1][4*val + c];
00090         if(flags & PIX_FMT_BITSTREAM){
00091             shift-=depth;
00092             while(shift<0){
00093                 shift+=8;
00094                 p++;
00095             }
00096         }else
00097             p+= step;
00098         *dst++= val;
00099     }
00100 }

Generated on Tue Nov 4 2014 12:59:22 for ffmpeg by  doxygen 1.7.1