yading@10: /* yading@10: * Copyright (c) 2000-2002 Fabrice Bellard yading@10: * Copyright (c) 2002-2004 Michael Niedermayer yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: /** yading@10: * @file yading@10: * rl header. yading@10: */ yading@10: yading@10: #ifndef AVCODEC_RL_H yading@10: #define AVCODEC_RL_H yading@10: yading@10: #include yading@10: #include "get_bits.h" yading@10: yading@10: /* run length table */ yading@10: #define MAX_RUN 64 yading@10: #define MAX_LEVEL 64 yading@10: yading@10: /** RLTable. */ yading@10: typedef struct RLTable { yading@10: int n; ///< number of entries of table_vlc minus 1 yading@10: int last; ///< number of values for last = 0 yading@10: const uint16_t (*table_vlc)[2]; yading@10: const int8_t *table_run; yading@10: const int8_t *table_level; yading@10: uint8_t *index_run[2]; ///< encoding only yading@10: int8_t *max_level[2]; ///< encoding & decoding yading@10: int8_t *max_run[2]; ///< encoding & decoding yading@10: VLC vlc; ///< decoding only deprecated FIXME remove yading@10: RL_VLC_ELEM *rl_vlc[32]; ///< decoding only yading@10: } RLTable; yading@10: yading@10: /** yading@10: * yading@10: * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold yading@10: * the level and run tables, if this is NULL av_malloc() will be used yading@10: */ yading@10: void ff_init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]); yading@10: void ff_init_vlc_rl(RLTable *rl); yading@10: yading@10: #define INIT_VLC_RL(rl, static_size)\ yading@10: {\ yading@10: int q;\ yading@10: static RL_VLC_ELEM rl_vlc_table[32][static_size];\ yading@10: INIT_VLC_STATIC(&rl.vlc, 9, rl.n + 1,\ yading@10: &rl.table_vlc[0][1], 4, 2,\ yading@10: &rl.table_vlc[0][0], 4, 2, static_size);\ yading@10: \ yading@10: if(!rl.rl_vlc[0]){\ yading@10: for(q=0; q<32; q++)\ yading@10: rl.rl_vlc[q]= rl_vlc_table[q];\ yading@10: \ yading@10: ff_init_vlc_rl(&rl);\ yading@10: }\ yading@10: } yading@10: yading@10: static inline int get_rl_index(const RLTable *rl, int last, int run, int level) yading@10: { yading@10: int index; yading@10: index = rl->index_run[last][run]; yading@10: if (index >= rl->n) yading@10: return rl->n; yading@10: if (level > rl->max_level[last][run]) yading@10: return rl->n; yading@10: return index + level - 1; yading@10: } yading@10: yading@10: #endif /* AVCODEC_RL_H */