--- libavcodec/Makefile | 3 +- libavcodec/dxva2_h264.c | 2 +- libavcodec/h264_cabac.c | 27 +++---- libavcodec/h264_cavlc.c | 35 +++++---- libavcodec/h264_parser.c | 2 +- libavcodec/h264_ps.c | 4 +- libavcodec/h264_slice.c | 6 +- libavcodec/{h264data.h => h264data.c} | 44 ++++------- libavcodec/h264data.h | 140 +++------------------------------- libavcodec/ppc/h264dsp.c | 1 + libavcodec/svq3.c | 16 ++-- libavcodec/vp8data.h | 2 +- 12 files changed, 77 insertions(+), 205 deletions(-) copy libavcodec/{h264data.h => h264data.c} (89%)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ba1661d..f484180 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 8f7c4a7..f04cd6d 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_h264_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 2b847ed..37f98dd 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 636b5f6..45a8386 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 27c78d9..0f970ae 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_ps.c b/libavcodec/h264_ps.c index 6b29966..cffd82f 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -31,7 +31,7 @@ #include "internal.h" #include "avcodec.h" #include "h264.h" -#include "h264data.h" //FIXME FIXME FIXME (just for zigzag_scan) +#include "h264data.h" #include "golomb.h" #define MAX_LOG2_MAX_FRAME_NUM (12 + 4) @@ -266,7 +266,7 @@ static void decode_scaling_list(H264Context *h, uint8_t *factors, int size, const uint8_t *fallback_list) { int i, last = 8, next = 8; - const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct; + const uint8_t *scan = size == 16 ? ff_h264_zigzag_scan : ff_zigzag_direct; if (!get_bits1(&h->gb)) /* matrix not written, we use the predicted one */ memcpy(factors, fallback_list, size * sizeof(uint8_t)); else diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index a94ff28..1996900 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -790,7 +790,7 @@ static void init_scan_tables(H264Context *h) int i; for (i = 0; i < 16; i++) { #define TRANSPOSE(x) (x >> 2) | ((x << 2) & 0xF) - h->zigzag_scan[i] = TRANSPOSE(zigzag_scan[i]); + h->zigzag_scan[i] = TRANSPOSE(ff_h264_zigzag_scan[i]); h->field_scan[i] = TRANSPOSE(field_scan[i]); #undef TRANSPOSE } @@ -803,7 +803,7 @@ static void init_scan_tables(H264Context *h) #undef TRANSPOSE } if (h->sps.transform_bypass) { // FIXME same ugly - h->zigzag_scan_q0 = zigzag_scan; + h->zigzag_scan_q0 = ff_h264_zigzag_scan; h->zigzag_scan8x8_q0 = ff_zigzag_direct; h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc; h->field_scan_q0 = field_scan; @@ -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.h b/libavcodec/h264data.c similarity index 89% copy from libavcodec/h264data.h copy to libavcodec/h264data.c index 6b40b39..f379a40 100644 --- a/libavcodec/h264data.h +++ b/libavcodec/h264data.c @@ -26,57 +26,50 @@ * @author Michael Niedermayer <michae...@gmx.at> */ -#ifndef AVCODEC_H264DATA_H -#define AVCODEC_H264DATA_H - #include <stdint.h> -#include "libavutil/rational.h" -#include "h264.h" +#include "libavutil/avutil.h" + +#include "avcodec.h" +#include "h264data.h" -static const uint8_t golomb_to_pict_type[5] = { +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 }; -static const uint8_t golomb_to_intra4x4_cbp[48] = { +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 }; -static const uint8_t golomb_to_inter_cbp[48] = { +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 }; -static const uint8_t zigzag_scan[16] = { +const uint8_t ff_h264_zigzag_scan[16] = { 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, }; -static const uint8_t chroma_dc_scan[4] = { +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, }; -static const uint8_t chroma422_dc_scan[8] = { +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, }; -typedef struct IMbInfo { - uint16_t type; - uint8_t pred_mode; - uint8_t cbp; -} IMbInfo; - -static const IMbInfo i_mb_type_info[26] = { +const IMbInfo ff_h264_i_mb_type_info[26] = { { MB_TYPE_INTRA4x4, -1, -1 }, { MB_TYPE_INTRA16x16, 2, 0 }, { MB_TYPE_INTRA16x16, 1, 0 }, @@ -105,12 +98,7 @@ static const IMbInfo i_mb_type_info[26] = { { MB_TYPE_INTRA_PCM, -1, -1 }, }; -typedef struct PMbInfo { - uint16_t type; - uint8_t partition_count; -} PMbInfo; - -static const PMbInfo p_mb_type_info[5] = { +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 }, @@ -118,14 +106,14 @@ static const PMbInfo p_mb_type_info[5] = { { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 }, }; -static const PMbInfo p_sub_mb_type_info[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 }, }; -static const PMbInfo b_mb_type_info[23] = { +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, }, @@ -151,7 +139,7 @@ static const PMbInfo b_mb_type_info[23] = { { 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] = { +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, }, @@ -166,5 +154,3 @@ static const PMbInfo b_sub_mb_type_info[13] = { { 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, }, }; - -#endif /* AVCODEC_H264DATA_H */ diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h index 6b40b39..e3de7bc 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 <michae...@gmx.at> - * * This file is part of Libav. * * Libav is free software; you can redistribute it and/or @@ -19,56 +16,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file - * @brief - * H264 / AVC / MPEG4 part10 codec data table - * @author Michael Niedermayer <michae...@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 zigzag_scan[16] = { - 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, - 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, - 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, - 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, -}; - -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_zigzag_scan[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; @@ -76,95 +37,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/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c index 2312e0e..bc760bd 100644 --- a/libavcodec/ppc/h264dsp.c +++ b/libavcodec/ppc/h264dsp.c @@ -27,6 +27,7 @@ #include "libavutil/ppc/types_altivec.h" #include "libavutil/ppc/util_altivec.h" +#include "libavcodec/h264.h" #include "libavcodec/h264dsp.h" #if HAVE_ALTIVEC && HAVE_BIGENDIAN diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 90b20af..6aa9366 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 "rectangle.h" @@ -240,7 +238,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, zigzag_scan, svq3_scan, chroma_dc_scan }; + { luma_dc_zigzag_scan, ff_h264_zigzag_scan, svq3_scan, ff_h264_chroma_dc_scan }; int run, level, limit; unsigned vlc; @@ -661,7 +659,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) { @@ -669,7 +667,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; } @@ -697,8 +695,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)) { @@ -826,7 +824,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)); diff --git a/libavcodec/vp8data.h b/libavcodec/vp8data.h index b49dea9..079d43b 100644 --- a/libavcodec/vp8data.h +++ b/libavcodec/vp8data.h @@ -708,7 +708,7 @@ static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS - 1] = { }, }; -// fixme: copied from h264data.h +// fixme: copied from h264data.c static const uint8_t zigzag_scan[16]={ 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, -- 2.4.10 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel