summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-08-19 14:24:45 +0200
committerDiego Biurrun <diego@biurrun.de>2016-03-25 15:56:14 +0100
commita7da517f6a5c472f46f67dd33bb6b95ccc919923 (patch)
tree4d81c15ee42203fc381ffba5f763e1e8278723a4 /libavcodec
parentf4d581cda3897f66c1dda7586b93f86a591dbbef (diff)
h264data: Move all data tables from a header to a .c file
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/Makefile3
-rw-r--r--libavcodec/dxva2_h264.c2
-rw-r--r--libavcodec/h264_cabac.c27
-rw-r--r--libavcodec/h264_cavlc.c35
-rw-r--r--libavcodec/h264_parser.c2
-rw-r--r--libavcodec/h264_slice.c2
-rw-r--r--libavcodec/h264data.c149
-rw-r--r--libavcodec/h264data.h132
-rw-r--r--libavcodec/svq3.c16
9 files changed, 204 insertions, 164 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ba1661d1df..f484180f67 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -251,7 +251,8 @@ OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \
OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
h264_direct.o h264_loopfilter.o \
h264_mb.o h264_picture.o h264_ps.o \
- h264_refs.o h264_sei.o h264_slice.o
+ h264_refs.o h264_sei.o \
+ h264_slice.o h264data.o
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h2645.o
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 8f7c4a7eb0..eceb956dcf 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -176,7 +176,7 @@ static void fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx,
} else {
for (i = 0; i < 6; i++)
for (j = 0; j < 16; j++)
- qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]];
+ qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][ff_zigzag_scan[j]];
for (i = 0; i < 64; i++) {
qm->bScalingLists8x8[0][i] = h->pps.scaling_matrix8[0][ff_zigzag_direct[i]];
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 2b847edfb9..37f98ddd8a 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1986,8 +1986,8 @@ int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
mb_type= bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */
}
}
- partition_count= b_mb_type_info[mb_type].partition_count;
- mb_type= b_mb_type_info[mb_type].type;
+ partition_count = ff_h264_b_mb_type_info[mb_type].partition_count;
+ mb_type = ff_h264_b_mb_type_info[mb_type].type;
} else if (sl->slice_type_nos == AV_PICTURE_TYPE_P) {
if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[14] ) == 0 ) {
/* P-type */
@@ -1998,8 +1998,8 @@ int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
/* P_L0_D8x16, P_L0_D16x8 */
mb_type= 2 - get_cabac_noinline( &sl->cabac, &sl->cabac_state[17] );
}
- partition_count= p_mb_type_info[mb_type].partition_count;
- mb_type= p_mb_type_info[mb_type].type;
+ partition_count = ff_h264_p_mb_type_info[mb_type].partition_count;
+ mb_type = ff_h264_p_mb_type_info[mb_type].type;
} else {
mb_type = decode_cabac_intra_mb_type(sl, 17, 0);
goto decode_intra_mb;
@@ -2011,9 +2011,9 @@ int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
assert(sl->slice_type_nos == AV_PICTURE_TYPE_I);
decode_intra_mb:
partition_count = 0;
- cbp= i_mb_type_info[mb_type].cbp;
- sl->intra16x16_pred_mode = i_mb_type_info[mb_type].pred_mode;
- mb_type= i_mb_type_info[mb_type].type;
+ cbp = ff_h264_i_mb_type_info[mb_type].cbp;
+ sl->intra16x16_pred_mode = ff_h264_i_mb_type_info[mb_type].pred_mode;
+ mb_type = ff_h264_i_mb_type_info[mb_type].type;
}
if (MB_FIELD(sl))
mb_type |= MB_TYPE_INTERLACED;
@@ -2097,8 +2097,8 @@ decode_intra_mb:
if (sl->slice_type_nos == AV_PICTURE_TYPE_B ) {
for( i = 0; i < 4; i++ ) {
sl->sub_mb_type[i] = decode_cabac_b_mb_sub_type(sl);
- sub_partition_count[i] = b_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
- sl->sub_mb_type[i] = b_sub_mb_type_info[sl->sub_mb_type[i]].type;
+ sub_partition_count[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
+ sl->sub_mb_type[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].type;
}
if (IS_DIRECT(sl->sub_mb_type[0] | sl->sub_mb_type[1] |
sl->sub_mb_type[2] | sl->sub_mb_type[3])) {
@@ -2113,8 +2113,8 @@ decode_intra_mb:
} else {
for( i = 0; i < 4; i++ ) {
sl->sub_mb_type[i] = decode_cabac_p_mb_sub_type(sl);
- sub_partition_count[i] = p_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
- sl->sub_mb_type[i] = p_sub_mb_type_info[sl->sub_mb_type[i]].type;
+ sub_partition_count[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
+ sl->sub_mb_type[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].type;
}
}
@@ -2397,7 +2397,7 @@ decode_intra_mb:
for (c = 0; c < 2; c++)
decode_cabac_residual_dc_422(h, sl, sl->mb + ((256 + 16*16*c) << pixel_shift), 3,
CHROMA_DC_BLOCK_INDEX + c,
- chroma422_dc_scan, 8);
+ ff_h264_chroma422_dc_scan, 8);
}
if( cbp&0x20 ) {
@@ -2421,7 +2421,8 @@ decode_intra_mb:
if( cbp&0x30 ){
int c;
for (c = 0; c < 2; c++)
- decode_cabac_residual_dc(h, sl, sl->mb + ((256 + 16*16*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
+ decode_cabac_residual_dc(h, sl, sl->mb + ((256 + 16 * 16 * c) << pixel_shift),
+ 3, CHROMA_DC_BLOCK_INDEX + c, ff_h264_chroma_dc_scan, 4);
}
if( cbp&0x20 ) {
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 636b5f6182..45a838603e 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -30,8 +30,8 @@
#include "internal.h"
#include "avcodec.h"
#include "h264.h"
-#include "h264data.h" // FIXME FIXME FIXME
#include "h264_mvpred.h"
+#include "h264data.h"
#include "golomb.h"
#include "mpegutils.h"
@@ -733,16 +733,16 @@ int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl)
mb_type= get_ue_golomb(&sl->gb);
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
if(mb_type < 23){
- partition_count= b_mb_type_info[mb_type].partition_count;
- mb_type= b_mb_type_info[mb_type].type;
+ partition_count = ff_h264_b_mb_type_info[mb_type].partition_count;
+ mb_type = ff_h264_b_mb_type_info[mb_type].type;
}else{
mb_type -= 23;
goto decode_intra_mb;
}
} else if (sl->slice_type_nos == AV_PICTURE_TYPE_P) {
if(mb_type < 5){
- partition_count= p_mb_type_info[mb_type].partition_count;
- mb_type= p_mb_type_info[mb_type].type;
+ partition_count = ff_h264_p_mb_type_info[mb_type].partition_count;
+ mb_type = ff_h264_p_mb_type_info[mb_type].type;
}else{
mb_type -= 5;
goto decode_intra_mb;
@@ -757,9 +757,9 @@ decode_intra_mb:
return -1;
}
partition_count=0;
- cbp= i_mb_type_info[mb_type].cbp;
- sl->intra16x16_pred_mode = i_mb_type_info[mb_type].pred_mode;
- mb_type= i_mb_type_info[mb_type].type;
+ cbp = ff_h264_i_mb_type_info[mb_type].cbp;
+ sl->intra16x16_pred_mode = ff_h264_i_mb_type_info[mb_type].pred_mode;
+ mb_type = ff_h264_i_mb_type_info[mb_type].type;
}
if (MB_FIELD(sl))
@@ -843,8 +843,8 @@ decode_intra_mb:
av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y);
return -1;
}
- sub_partition_count[i]= b_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count;
- sl->sub_mb_type[i]= b_sub_mb_type_info[ sl->sub_mb_type[i] ].type;
+ sub_partition_count[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
+ sl->sub_mb_type[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].type;
}
if( IS_DIRECT(sl->sub_mb_type[0]|sl->sub_mb_type[1]|sl->sub_mb_type[2]|sl->sub_mb_type[3])) {
ff_h264_pred_direct_motion(h, sl, &mb_type);
@@ -861,8 +861,8 @@ decode_intra_mb:
av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y);
return -1;
}
- sub_partition_count[i]= p_sub_mb_type_info[ sl->sub_mb_type[i] ].partition_count;
- sl->sub_mb_type[i]= p_sub_mb_type_info[ sl->sub_mb_type[i] ].type;
+ sub_partition_count[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
+ sl->sub_mb_type[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].type;
}
}
@@ -1062,8 +1062,10 @@ decode_intra_mb:
av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, sl->mb_x, sl->mb_y);
return -1;
}
- if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp];
- else cbp= golomb_to_inter_cbp [cbp];
+ if (IS_INTRA4x4(mb_type))
+ cbp = ff_h264_golomb_to_intra4x4_cbp[cbp];
+ else
+ cbp = ff_h264_golomb_to_inter_cbp[cbp];
}else{
if(cbp > 15){
av_log(h->avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, sl->mb_x, sl->mb_y);
@@ -1128,7 +1130,7 @@ decode_intra_mb:
if(cbp&0x30){
for(chroma_idx=0; chroma_idx<2; chroma_idx++)
if (decode_residual(h, sl, gb, sl->mb + ((256 + 16*16*chroma_idx) << pixel_shift),
- CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma422_dc_scan,
+ CHROMA_DC_BLOCK_INDEX + chroma_idx, ff_h264_chroma422_dc_scan,
NULL, 8) < 0) {
return -1;
}
@@ -1154,7 +1156,8 @@ decode_intra_mb:
} else /* yuv420 */ {
if(cbp&0x30){
for(chroma_idx=0; chroma_idx<2; chroma_idx++)
- if( decode_residual(h, sl, gb, sl->mb + ((256 + 16*16*chroma_idx) << pixel_shift), CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){
+ if (decode_residual(h, sl, gb, sl->mb + ((256 + 16 * 16 * chroma_idx) << pixel_shift),
+ CHROMA_DC_BLOCK_INDEX + chroma_idx, ff_h264_chroma_dc_scan, NULL, 4) < 0) {
return -1;
}
}
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 27c78d9480..0f970ae096 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -261,7 +261,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
init_get_bits(&sl->gb, ptr, 8 * dst_length);
get_ue_golomb(&sl->gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&sl->gb);
- s->pict_type = golomb_to_pict_type[slice_type % 5];
+ s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];
if (h->sei_recovery_frame_cnt >= 0) {
/* key frame, since recovery_frame_cnt is set */
s->key_frame = 1;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index b44aa3e3a4..408cc48d73 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1081,7 +1081,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
} else
sl->slice_type_fixed = 0;
- slice_type = golomb_to_pict_type[slice_type];
+ slice_type = ff_h264_golomb_to_pict_type[slice_type];
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
diff --git a/libavcodec/h264data.c b/libavcodec/h264data.c
new file mode 100644
index 0000000000..f7aed48181
--- /dev/null
+++ b/libavcodec/h264data.c
@@ -0,0 +1,149 @@
+/*
+ * H26L/H264/AVC/JVT/14496-10/... encoder/decoder
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * @brief
+ * H264 / AVC / MPEG4 part10 codec data table
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
+#include <stdint.h>
+
+#include "libavutil/avutil.h"
+
+#include "avcodec.h"
+#include "h264data.h"
+
+const uint8_t ff_h264_golomb_to_pict_type[5] = {
+ AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I,
+ AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI
+};
+
+const uint8_t ff_h264_golomb_to_intra4x4_cbp[48] = {
+ 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46,
+ 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4,
+ 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41
+};
+
+const uint8_t ff_h264_golomb_to_inter_cbp[48] = {
+ 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13,
+ 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
+ 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
+};
+
+const uint8_t ff_h264_chroma_dc_scan[4] = {
+ (0 + 0 * 2) * 16, (1 + 0 * 2) * 16,
+ (0 + 1 * 2) * 16, (1 + 1 * 2) * 16,
+};
+
+const uint8_t ff_h264_chroma422_dc_scan[8] = {
+ (0 + 0 * 2) * 16, (0 + 1 * 2) * 16,
+ (1 + 0 * 2) * 16, (0 + 2 * 2) * 16,
+ (0 + 3 * 2) * 16, (1 + 1 * 2) * 16,
+ (1 + 2 * 2) * 16, (1 + 3 * 2) * 16,
+};
+
+const IMbInfo ff_h264_i_mb_type_info[26] = {
+ { MB_TYPE_INTRA4x4, -1, -1 },
+ { MB_TYPE_INTRA16x16, 2, 0 },
+ { MB_TYPE_INTRA16x16, 1, 0 },
+ { MB_TYPE_INTRA16x16, 0, 0 },
+ { MB_TYPE_INTRA16x16, 3, 0 },
+ { MB_TYPE_INTRA16x16, 2, 16 },
+ { MB_TYPE_INTRA16x16, 1, 16 },
+ { MB_TYPE_INTRA16x16, 0, 16 },
+ { MB_TYPE_INTRA16x16, 3, 16 },
+ { MB_TYPE_INTRA16x16, 2, 32 },
+ { MB_TYPE_INTRA16x16, 1, 32 },
+ { MB_TYPE_INTRA16x16, 0, 32 },
+ { MB_TYPE_INTRA16x16, 3, 32 },
+ { MB_TYPE_INTRA16x16, 2, 15 + 0 },
+ { MB_TYPE_INTRA16x16, 1, 15 + 0 },
+ { MB_TYPE_INTRA16x16, 0, 15 + 0 },
+ { MB_TYPE_INTRA16x16, 3, 15 + 0 },
+ { MB_TYPE_INTRA16x16, 2, 15 + 16 },
+ { MB_TYPE_INTRA16x16, 1, 15 + 16 },
+ { MB_TYPE_INTRA16x16, 0, 15 + 16 },
+ { MB_TYPE_INTRA16x16, 3, 15 + 16 },
+ { MB_TYPE_INTRA16x16, 2, 15 + 32 },
+ { MB_TYPE_INTRA16x16, 1, 15 + 32 },
+ { MB_TYPE_INTRA16x16, 0, 15 + 32 },
+ { MB_TYPE_INTRA16x16, 3, 15 + 32 },
+ { MB_TYPE_INTRA_PCM, -1, -1 },
+};
+
+const PMbInfo ff_h264_p_mb_type_info[5] = {
+ { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
+ { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4 },
+ { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 },
+};
+
+const PMbInfo ff_h264_p_sub_mb_type_info[4] = {
+ { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 },
+ { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 },
+};
+
+const PMbInfo ff_h264_b_mb_type_info[23] = {
+ { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, },
+ { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
+ { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
+ { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
+};
+
+const PMbInfo ff_h264_b_sub_mb_type_info[13] = {
+ { MB_TYPE_DIRECT2, 1, },
+ { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
+ { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
+ { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
+ { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, },
+ { MB_TYPE_8x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 4, },
+ { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
+};
diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h
index 1196987cea..bb3fb6a7c9 100644
--- a/libavcodec/h264data.h
+++ b/libavcodec/h264data.h
@@ -1,7 +1,4 @@
/*
- * H26L/H264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
- *
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
@@ -19,49 +16,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/**
- * @file
- * @brief
- * H264 / AVC / MPEG4 part10 codec data table
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
#ifndef AVCODEC_H264DATA_H
#define AVCODEC_H264DATA_H
#include <stdint.h>
-#include "libavutil/rational.h"
#include "h264.h"
-static const uint8_t golomb_to_pict_type[5] = {
- AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I,
- AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI
-};
-
-static const uint8_t golomb_to_intra4x4_cbp[48] = {
- 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46,
- 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4,
- 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41
-};
-
-static const uint8_t golomb_to_inter_cbp[48] = {
- 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13,
- 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
- 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
-};
+extern const uint8_t ff_h264_golomb_to_pict_type[5];
+extern const uint8_t ff_h264_golomb_to_intra4x4_cbp[48];
+extern const uint8_t ff_h264_golomb_to_inter_cbp[48];
-static const uint8_t chroma_dc_scan[4] = {
- (0 + 0 * 2) * 16, (1 + 0 * 2) * 16,
- (0 + 1 * 2) * 16, (1 + 1 * 2) * 16,
-};
-
-static const uint8_t chroma422_dc_scan[8] = {
- (0 + 0 * 2) * 16, (0 + 1 * 2) * 16,
- (1 + 0 * 2) * 16, (0 + 2 * 2) * 16,
- (0 + 3 * 2) * 16, (1 + 1 * 2) * 16,
- (1 + 2 * 2) * 16, (1 + 3 * 2) * 16,
-};
+extern const uint8_t ff_h264_chroma_dc_scan[4];
+extern const uint8_t ff_h264_chroma422_dc_scan[8];
typedef struct IMbInfo {
uint16_t type;
@@ -69,95 +36,16 @@ typedef struct IMbInfo {
uint8_t cbp;
} IMbInfo;
-static const IMbInfo i_mb_type_info[26] = {
- { MB_TYPE_INTRA4x4, -1, -1 },
- { MB_TYPE_INTRA16x16, 2, 0 },
- { MB_TYPE_INTRA16x16, 1, 0 },
- { MB_TYPE_INTRA16x16, 0, 0 },
- { MB_TYPE_INTRA16x16, 3, 0 },
- { MB_TYPE_INTRA16x16, 2, 16 },
- { MB_TYPE_INTRA16x16, 1, 16 },
- { MB_TYPE_INTRA16x16, 0, 16 },
- { MB_TYPE_INTRA16x16, 3, 16 },
- { MB_TYPE_INTRA16x16, 2, 32 },
- { MB_TYPE_INTRA16x16, 1, 32 },
- { MB_TYPE_INTRA16x16, 0, 32 },
- { MB_TYPE_INTRA16x16, 3, 32 },
- { MB_TYPE_INTRA16x16, 2, 15 + 0 },
- { MB_TYPE_INTRA16x16, 1, 15 + 0 },
- { MB_TYPE_INTRA16x16, 0, 15 + 0 },
- { MB_TYPE_INTRA16x16, 3, 15 + 0 },
- { MB_TYPE_INTRA16x16, 2, 15 + 16 },
- { MB_TYPE_INTRA16x16, 1, 15 + 16 },
- { MB_TYPE_INTRA16x16, 0, 15 + 16 },
- { MB_TYPE_INTRA16x16, 3, 15 + 16 },
- { MB_TYPE_INTRA16x16, 2, 15 + 32 },
- { MB_TYPE_INTRA16x16, 1, 15 + 32 },
- { MB_TYPE_INTRA16x16, 0, 15 + 32 },
- { MB_TYPE_INTRA16x16, 3, 15 + 32 },
- { MB_TYPE_INTRA_PCM, -1, -1 },
-};
+extern const IMbInfo ff_h264_i_mb_type_info[26];
typedef struct PMbInfo {
uint16_t type;
uint8_t partition_count;
} PMbInfo;
-static const PMbInfo p_mb_type_info[5] = {
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4 },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 },
-};
-
-static const PMbInfo p_sub_mb_type_info[4] = {
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
- { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 },
- { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 },
- { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 },
-};
-
-static const PMbInfo b_mb_type_info[23] = {
- { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
-};
-
-static const PMbInfo b_sub_mb_type_info[13] = {
- { MB_TYPE_DIRECT2, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, },
- { MB_TYPE_8x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 4, },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
-};
+extern const PMbInfo ff_h264_p_mb_type_info[5];
+extern const PMbInfo ff_h264_p_sub_mb_type_info[4];
+extern const PMbInfo ff_h264_b_mb_type_info[23];
+extern const PMbInfo ff_h264_b_sub_mb_type_info[13];
#endif /* AVCODEC_H264DATA_H */
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 5208317afa..b91099c0ff 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -47,10 +47,8 @@
#include "avcodec.h"
#include "mpegutils.h"
#include "h264.h"
-
-#include "h264data.h" // FIXME FIXME FIXME
-
#include "h264_mvpred.h"
+#include "h264data.h"
#include "golomb.h"
#include "hpeldsp.h"
#include "mathops.h"
@@ -241,7 +239,7 @@ static inline int svq3_decode_block(GetBitContext *gb, int16_t *block,
int index, const int type)
{
static const uint8_t *const scan_patterns[4] = {
- luma_dc_zigzag_scan, ff_zigzag_scan, svq3_scan, chroma_dc_scan
+ luma_dc_zigzag_scan, ff_zigzag_scan, svq3_scan, ff_h264_chroma_dc_scan
};
int run, level, limit;
@@ -663,7 +661,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
mb_type = MB_TYPE_INTRA4x4;
} else { /* INTRA16x16 */
- dir = i_mb_type_info[mb_type - 8].pred_mode;
+ dir = ff_h264_i_mb_type_info[mb_type - 8].pred_mode;
dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;
if ((sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, sl, dir, 0)) < 0) {
@@ -671,7 +669,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
return sl->intra16x16_pred_mode;
}
- cbp = i_mb_type_info[mb_type - 8].cbp;
+ cbp = ff_h264_i_mb_type_info[mb_type - 8].cbp;
mb_type = MB_TYPE_INTRA16x16;
}
@@ -699,8 +697,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
return -1;
}
- cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc]
- : golomb_to_inter_cbp[vlc];
+ cbp = IS_INTRA(mb_type) ? ff_h264_golomb_to_intra4x4_cbp[vlc]
+ : ff_h264_golomb_to_inter_cbp[vlc];
}
if (IS_INTRA16x16(mb_type) ||
(h->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) {
@@ -828,7 +826,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
return -1;
}
- sl->slice_type = golomb_to_pict_type[slice_id];
+ sl->slice_type = ff_h264_golomb_to_pict_type[slice_id];
if ((header & 0x9F) == 2) {
i = (h->mb_num < 64) ? 6 : (1 + av_log2(h->mb_num - 1));