annotate ffmpeg/libavcodec/rl.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Copyright (c) 2000-2002 Fabrice Bellard
yading@10 3 * Copyright (c) 2002-2004 Michael Niedermayer
yading@10 4 *
yading@10 5 * This file is part of FFmpeg.
yading@10 6 *
yading@10 7 * FFmpeg is free software; you can redistribute it and/or
yading@10 8 * modify it under the terms of the GNU Lesser General Public
yading@10 9 * License as published by the Free Software Foundation; either
yading@10 10 * version 2.1 of the License, or (at your option) any later version.
yading@10 11 *
yading@10 12 * FFmpeg is distributed in the hope that it will be useful,
yading@10 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 15 * Lesser General Public License for more details.
yading@10 16 *
yading@10 17 * You should have received a copy of the GNU Lesser General Public
yading@10 18 * License along with FFmpeg; if not, write to the Free Software
yading@10 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 20 */
yading@10 21
yading@10 22 /**
yading@10 23 * @file
yading@10 24 * rl header.
yading@10 25 */
yading@10 26
yading@10 27 #ifndef AVCODEC_RL_H
yading@10 28 #define AVCODEC_RL_H
yading@10 29
yading@10 30 #include <stdint.h>
yading@10 31 #include "get_bits.h"
yading@10 32
yading@10 33 /* run length table */
yading@10 34 #define MAX_RUN 64
yading@10 35 #define MAX_LEVEL 64
yading@10 36
yading@10 37 /** RLTable. */
yading@10 38 typedef struct RLTable {
yading@10 39 int n; ///< number of entries of table_vlc minus 1
yading@10 40 int last; ///< number of values for last = 0
yading@10 41 const uint16_t (*table_vlc)[2];
yading@10 42 const int8_t *table_run;
yading@10 43 const int8_t *table_level;
yading@10 44 uint8_t *index_run[2]; ///< encoding only
yading@10 45 int8_t *max_level[2]; ///< encoding & decoding
yading@10 46 int8_t *max_run[2]; ///< encoding & decoding
yading@10 47 VLC vlc; ///< decoding only deprecated FIXME remove
yading@10 48 RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
yading@10 49 } RLTable;
yading@10 50
yading@10 51 /**
yading@10 52 *
yading@10 53 * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold
yading@10 54 * the level and run tables, if this is NULL av_malloc() will be used
yading@10 55 */
yading@10 56 void ff_init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
yading@10 57 void ff_init_vlc_rl(RLTable *rl);
yading@10 58
yading@10 59 #define INIT_VLC_RL(rl, static_size)\
yading@10 60 {\
yading@10 61 int q;\
yading@10 62 static RL_VLC_ELEM rl_vlc_table[32][static_size];\
yading@10 63 INIT_VLC_STATIC(&rl.vlc, 9, rl.n + 1,\
yading@10 64 &rl.table_vlc[0][1], 4, 2,\
yading@10 65 &rl.table_vlc[0][0], 4, 2, static_size);\
yading@10 66 \
yading@10 67 if(!rl.rl_vlc[0]){\
yading@10 68 for(q=0; q<32; q++)\
yading@10 69 rl.rl_vlc[q]= rl_vlc_table[q];\
yading@10 70 \
yading@10 71 ff_init_vlc_rl(&rl);\
yading@10 72 }\
yading@10 73 }
yading@10 74
yading@10 75 static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
yading@10 76 {
yading@10 77 int index;
yading@10 78 index = rl->index_run[last][run];
yading@10 79 if (index >= rl->n)
yading@10 80 return rl->n;
yading@10 81 if (level > rl->max_level[last][run])
yading@10 82 return rl->n;
yading@10 83 return index + level - 1;
yading@10 84 }
yading@10 85
yading@10 86 #endif /* AVCODEC_RL_H */