diff libavcodec/h264_data.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavcodec/h264_data.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,243 @@
     1.4 +/*
     1.5 + * H26L/H264/AVC/JVT/14496-10/... encoder/decoder
     1.6 + * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
     1.7 + *
     1.8 + * This file is part of FFmpeg.
     1.9 + *
    1.10 + * FFmpeg is free software; you can redistribute it and/or
    1.11 + * modify it under the terms of the GNU Lesser General Public
    1.12 + * License as published by the Free Software Foundation; either
    1.13 + * version 2.1 of the License, or (at your option) any later version.
    1.14 + *
    1.15 + * FFmpeg is distributed in the hope that it will be useful,
    1.16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.18 + * Lesser General Public License for more details.
    1.19 + *
    1.20 + * You should have received a copy of the GNU Lesser General Public
    1.21 + * License along with FFmpeg; if not, write to the Free Software
    1.22 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.23 + */
    1.24 +
    1.25 +/**
    1.26 + * @file
    1.27 + * @brief
    1.28 + *     H264 / AVC / MPEG4 part10 codec data table
    1.29 + * @author Michael Niedermayer <michaelni@gmx.at>
    1.30 + */
    1.31 +
    1.32 +#ifndef AVCODEC_H264DATA_H
    1.33 +#define AVCODEC_H264DATA_H
    1.34 +
    1.35 +#include <stdint.h>
    1.36 +#include "avcodec.h"
    1.37 +//#include "h264.h"
    1.38 +
    1.39 +/*
    1.40 +o-o o-o
    1.41 + / / /
    1.42 +o-o o-o
    1.43 + ,---'
    1.44 +o-o o-o
    1.45 + / / /
    1.46 +o-o o-o
    1.47 +*/
    1.48 +//This table must be here because scan8[constant] must be known at compiletime
    1.49 +static const uint8_t scan8[16 + 2*4]={
    1.50 + 4+1*8, 5+1*8, 4+2*8, 5+2*8,
    1.51 + 6+1*8, 7+1*8, 6+2*8, 7+2*8,
    1.52 + 4+3*8, 5+3*8, 4+4*8, 5+4*8,
    1.53 + 6+3*8, 7+3*8, 6+4*8, 7+4*8,
    1.54 + 1+1*8, 2+1*8,
    1.55 + 1+2*8, 2+2*8,
    1.56 + 1+4*8, 2+4*8,
    1.57 + 1+5*8, 2+5*8,
    1.58 +};
    1.59 +
    1.60 +static const uint8_t golomb_to_pict_type[5]=
    1.61 +{FF_P_TYPE, FF_B_TYPE, FF_I_TYPE, FF_SP_TYPE, FF_SI_TYPE};
    1.62 +
    1.63 +static const uint8_t golomb_to_intra4x4_cbp[48]={
    1.64 + 47, 31, 15,  0, 23, 27, 29, 30,  7, 11, 13, 14, 39, 43, 45, 46,
    1.65 + 16,  3,  5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44,  1,  2,  4,
    1.66 +  8, 17, 18, 20, 24,  6,  9, 22, 25, 32, 33, 34, 36, 40, 38, 41
    1.67 +};
    1.68 +
    1.69 +static const uint8_t golomb_to_inter_cbp[48]={
    1.70 +  0, 16,  1,  2,  4,  8, 32,  3,  5, 10, 12, 15, 47,  7, 11, 13,
    1.71 + 14,  6,  9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
    1.72 + 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
    1.73 +};
    1.74 +
    1.75 +static const uint8_t zigzag_scan[16]={
    1.76 + 0+0*4, 1+0*4, 0+1*4, 0+2*4,
    1.77 + 1+1*4, 2+0*4, 3+0*4, 2+1*4,
    1.78 + 1+2*4, 0+3*4, 1+3*4, 2+2*4,
    1.79 + 3+1*4, 3+2*4, 2+3*4, 3+3*4,
    1.80 +};
    1.81 +
    1.82 +static const uint8_t field_scan[16]={
    1.83 + 0+0*4, 0+1*4, 1+0*4, 0+2*4,
    1.84 + 0+3*4, 1+1*4, 1+2*4, 1+3*4,
    1.85 + 2+0*4, 2+1*4, 2+2*4, 2+3*4,
    1.86 + 3+0*4, 3+1*4, 3+2*4, 3+3*4,
    1.87 +};
    1.88 +
    1.89 +static const uint8_t luma_dc_zigzag_scan[16]={
    1.90 + 0*16 + 0*64, 1*16 + 0*64, 2*16 + 0*64, 0*16 + 2*64,
    1.91 + 3*16 + 0*64, 0*16 + 1*64, 1*16 + 1*64, 2*16 + 1*64,
    1.92 + 1*16 + 2*64, 2*16 + 2*64, 3*16 + 2*64, 0*16 + 3*64,
    1.93 + 3*16 + 1*64, 1*16 + 3*64, 2*16 + 3*64, 3*16 + 3*64,
    1.94 +};
    1.95 +
    1.96 +static const uint8_t luma_dc_field_scan[16]={
    1.97 + 0*16 + 0*64, 2*16 + 0*64, 1*16 + 0*64, 0*16 + 2*64,
    1.98 + 2*16 + 2*64, 3*16 + 0*64, 1*16 + 2*64, 3*16 + 2*64,
    1.99 + 0*16 + 1*64, 2*16 + 1*64, 0*16 + 3*64, 2*16 + 3*64,
   1.100 + 1*16 + 1*64, 3*16 + 1*64, 1*16 + 3*64, 3*16 + 3*64,
   1.101 +};
   1.102 +
   1.103 +static const uint8_t chroma_dc_scan[4]={
   1.104 + (0+0*2)*16, (1+0*2)*16,
   1.105 + (0+1*2)*16, (1+1*2)*16,  //FIXME
   1.106 +};
   1.107 +
   1.108 +
   1.109 +static const uint8_t field_scan8x8[64]={
   1.110 + 0+0*8, 0+1*8, 0+2*8, 1+0*8,
   1.111 + 1+1*8, 0+3*8, 0+4*8, 1+2*8,
   1.112 + 2+0*8, 1+3*8, 0+5*8, 0+6*8,
   1.113 + 0+7*8, 1+4*8, 2+1*8, 3+0*8,
   1.114 + 2+2*8, 1+5*8, 1+6*8, 1+7*8,
   1.115 + 2+3*8, 3+1*8, 4+0*8, 3+2*8,
   1.116 + 2+4*8, 2+5*8, 2+6*8, 2+7*8,
   1.117 + 3+3*8, 4+1*8, 5+0*8, 4+2*8,
   1.118 + 3+4*8, 3+5*8, 3+6*8, 3+7*8,
   1.119 + 4+3*8, 5+1*8, 6+0*8, 5+2*8,
   1.120 + 4+4*8, 4+5*8, 4+6*8, 4+7*8,
   1.121 + 5+3*8, 6+1*8, 6+2*8, 5+4*8,
   1.122 + 5+5*8, 5+6*8, 5+7*8, 6+3*8,
   1.123 + 7+0*8, 7+1*8, 6+4*8, 6+5*8,
   1.124 + 6+6*8, 6+7*8, 7+2*8, 7+3*8,
   1.125 + 7+4*8, 7+5*8, 7+6*8, 7+7*8,
   1.126 +};
   1.127 +
   1.128 +typedef struct IMbInfo{
   1.129 +    uint16_t type;
   1.130 +    uint8_t pred_mode;
   1.131 +    uint8_t cbp;
   1.132 +} IMbInfo;
   1.133 +
   1.134 +static const IMbInfo i_mb_type_info[26]={
   1.135 +{MB_TYPE_INTRA4x4  , -1, -1},
   1.136 +{MB_TYPE_INTRA16x16,  2,  0},
   1.137 +{MB_TYPE_INTRA16x16,  1,  0},
   1.138 +{MB_TYPE_INTRA16x16,  0,  0},
   1.139 +{MB_TYPE_INTRA16x16,  3,  0},
   1.140 +{MB_TYPE_INTRA16x16,  2,  16},
   1.141 +{MB_TYPE_INTRA16x16,  1,  16},
   1.142 +{MB_TYPE_INTRA16x16,  0,  16},
   1.143 +{MB_TYPE_INTRA16x16,  3,  16},
   1.144 +{MB_TYPE_INTRA16x16,  2,  32},
   1.145 +{MB_TYPE_INTRA16x16,  1,  32},
   1.146 +{MB_TYPE_INTRA16x16,  0,  32},
   1.147 +{MB_TYPE_INTRA16x16,  3,  32},
   1.148 +{MB_TYPE_INTRA16x16,  2,  15+0},
   1.149 +{MB_TYPE_INTRA16x16,  1,  15+0},
   1.150 +{MB_TYPE_INTRA16x16,  0,  15+0},
   1.151 +{MB_TYPE_INTRA16x16,  3,  15+0},
   1.152 +{MB_TYPE_INTRA16x16,  2,  15+16},
   1.153 +{MB_TYPE_INTRA16x16,  1,  15+16},
   1.154 +{MB_TYPE_INTRA16x16,  0,  15+16},
   1.155 +{MB_TYPE_INTRA16x16,  3,  15+16},
   1.156 +{MB_TYPE_INTRA16x16,  2,  15+32},
   1.157 +{MB_TYPE_INTRA16x16,  1,  15+32},
   1.158 +{MB_TYPE_INTRA16x16,  0,  15+32},
   1.159 +{MB_TYPE_INTRA16x16,  3,  15+32},
   1.160 +{MB_TYPE_INTRA_PCM , -1, -1},
   1.161 +};
   1.162 +
   1.163 +typedef struct PMbInfo{
   1.164 +    uint16_t type;
   1.165 +    uint8_t partition_count;
   1.166 +} PMbInfo;
   1.167 +
   1.168 +static const PMbInfo p_mb_type_info[5]={
   1.169 +{MB_TYPE_16x16|MB_TYPE_P0L0             , 1},
   1.170 +{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2},
   1.171 +{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2},
   1.172 +{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P1L0, 4},
   1.173 +{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_REF0, 4},
   1.174 +};
   1.175 +
   1.176 +static const PMbInfo p_sub_mb_type_info[4]={
   1.177 +{MB_TYPE_16x16|MB_TYPE_P0L0             , 1},
   1.178 +{MB_TYPE_16x8 |MB_TYPE_P0L0             , 2},
   1.179 +{MB_TYPE_8x16 |MB_TYPE_P0L0             , 2},
   1.180 +{MB_TYPE_8x8  |MB_TYPE_P0L0             , 4},
   1.181 +};
   1.182 +
   1.183 +static const PMbInfo b_mb_type_info[23]={
   1.184 +{MB_TYPE_DIRECT2|MB_TYPE_L0L1                                      , 1, },
   1.185 +{MB_TYPE_16x16|MB_TYPE_P0L0                                       , 1, },
   1.186 +{MB_TYPE_16x16             |MB_TYPE_P0L1                          , 1, },
   1.187 +{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1                          , 1, },
   1.188 +{MB_TYPE_16x8 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
   1.189 +{MB_TYPE_8x16 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
   1.190 +{MB_TYPE_16x8              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
   1.191 +{MB_TYPE_8x16              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
   1.192 +{MB_TYPE_16x8 |MB_TYPE_P0L0                          |MB_TYPE_P1L1, 2, },
   1.193 +{MB_TYPE_8x16 |MB_TYPE_P0L0                          |MB_TYPE_P1L1, 2, },
   1.194 +{MB_TYPE_16x8              |MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
   1.195 +{MB_TYPE_8x16              |MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
   1.196 +{MB_TYPE_16x8 |MB_TYPE_P0L0             |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.197 +{MB_TYPE_8x16 |MB_TYPE_P0L0             |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.198 +{MB_TYPE_16x8              |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.199 +{MB_TYPE_8x16              |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.200 +{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
   1.201 +{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
   1.202 +{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
   1.203 +{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
   1.204 +{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.205 +{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.206 +{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, },
   1.207 +};
   1.208 +
   1.209 +static const PMbInfo b_sub_mb_type_info[13]={
   1.210 +{MB_TYPE_DIRECT2                                                   , 1, },
   1.211 +{MB_TYPE_16x16|MB_TYPE_P0L0                                       , 1, },
   1.212 +{MB_TYPE_16x16             |MB_TYPE_P0L1                          , 1, },
   1.213 +{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1                          , 1, },
   1.214 +{MB_TYPE_16x8 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
   1.215 +{MB_TYPE_8x16 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
   1.216 +{MB_TYPE_16x8              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
   1.217 +{MB_TYPE_8x16              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
   1.218 +{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.219 +{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
   1.220 +{MB_TYPE_8x8  |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 4, },
   1.221 +{MB_TYPE_8x8               |MB_TYPE_P0L1             |MB_TYPE_P1L1, 4, },
   1.222 +{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, },
   1.223 +};
   1.224 +
   1.225 +static const uint8_t dequant4_coeff_init[6][3]={
   1.226 +  {10,13,16},
   1.227 +  {11,14,18},
   1.228 +  {13,16,20},
   1.229 +  {14,18,23},
   1.230 +  {16,20,25},
   1.231 +  {18,23,29},
   1.232 +};
   1.233 +
   1.234 +static const uint8_t dequant8_coeff_init_scan[16] = {
   1.235 +  0,3,4,3, 3,1,5,1, 4,5,2,5, 3,1,5,1
   1.236 +};
   1.237 +static const uint8_t dequant8_coeff_init[6][6]={
   1.238 +  {20,18,32,19,25,24},
   1.239 +  {22,19,35,21,28,26},
   1.240 +  {26,23,42,24,33,31},
   1.241 +  {28,25,45,26,35,33},
   1.242 +  {32,28,51,30,40,38},
   1.243 +  {36,32,58,34,46,43},
   1.244 +};
   1.245 +
   1.246 +#endif /* AVCODEC_H264DATA_H */