00001 /* 00002 * Copyright (c) 2000-2002 Fabrice Bellard 00003 * Copyright (c) 2002-2004 Michael Niedermayer 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 00027 #ifndef FFMPEG_RL_H 00028 #define FFMPEG_RL_H 00029 00030 #include <stdint.h> 00031 #include "bitstream.h" 00032 #include "mpegvideo.h" 00033 00035 typedef struct RLTable { 00036 int n; 00037 int last; 00038 const uint16_t (*table_vlc)[2]; 00039 const int8_t *table_run; 00040 const int8_t *table_level; 00041 uint8_t *index_run[2]; 00042 int8_t *max_level[2]; 00043 int8_t *max_run[2]; 00044 VLC vlc; 00045 RL_VLC_ELEM *rl_vlc[32]; 00046 } RLTable; 00047 00053 void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]); 00054 void init_vlc_rl(RLTable *rl, int use_static); 00055 00056 static inline int get_rl_index(const RLTable *rl, int last, int run, int level) 00057 { 00058 int index; 00059 index = rl->index_run[last][run]; 00060 if (index >= rl->n) 00061 return rl->n; 00062 if (level > rl->max_level[last][run]) 00063 return rl->n; 00064 return index + level - 1; 00065 } 00066 00067 #endif /* FFMPEG_RL_H */