00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #ifndef AVCODEC_H264_H
00029 #define AVCODEC_H264_H
00030
00031 #include "libavutil/intreadwrite.h"
00032 #include "dsputil.h"
00033 #include "cabac.h"
00034 #include "mpegvideo.h"
00035 #include "h264dsp.h"
00036 #include "h264pred.h"
00037 #include "rectangle.h"
00038
00039 #define interlaced_dct interlaced_dct_is_a_bad_name
00040 #define mb_intra mb_intra_is_not_initialized_see_mb_type
00041
00042 #define MAX_SPS_COUNT 32
00043 #define MAX_PPS_COUNT 256
00044
00045 #define MAX_MMCO_COUNT 66
00046
00047 #define MAX_DELAYED_PIC_COUNT 16
00048
00049 #define MAX_MBPAIR_SIZE (256*1024) // a tighter bound could be calculated if someone cares about a few bytes
00050
00051
00052
00053 #define ALLOW_INTERLACE
00054
00055 #define FMO 0
00056
00061 #define MAX_SLICES 16
00062
00063 #ifdef ALLOW_INTERLACE
00064 #define MB_MBAFF h->mb_mbaff
00065 #define MB_FIELD h->mb_field_decoding_flag
00066 #define FRAME_MBAFF h->mb_aff_frame
00067 #define FIELD_PICTURE (s->picture_structure != PICT_FRAME)
00068 #define LEFT_MBS 2
00069 #define LTOP 0
00070 #define LBOT 1
00071 #define LEFT(i) (i)
00072 #else
00073 #define MB_MBAFF 0
00074 #define MB_FIELD 0
00075 #define FRAME_MBAFF 0
00076 #define FIELD_PICTURE 0
00077 #undef IS_INTERLACED
00078 #define IS_INTERLACED(mb_type) 0
00079 #define LEFT_MBS 1
00080 #define LTOP 0
00081 #define LBOT 0
00082 #define LEFT(i) 0
00083 #endif
00084 #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE)
00085
00086 #ifndef CABAC
00087 #define CABAC h->pps.cabac
00088 #endif
00089
00090 #define CHROMA422 (h->sps.chroma_format_idc == 2)
00091 #define CHROMA444 (h->sps.chroma_format_idc == 3)
00092
00093 #define EXTENDED_SAR 255
00094
00095 #define MB_TYPE_REF0 MB_TYPE_ACPRED //dirty but it fits in 16 bit
00096 #define MB_TYPE_8x8DCT 0x01000000
00097 #define IS_REF0(a) ((a) & MB_TYPE_REF0)
00098 #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
00099
00104 #define DELAYED_PIC_REF 4
00105
00106 #define QP_MAX_NUM (51 + 4*6) // The maximum supported qp
00107
00108
00109 enum {
00110 NAL_SLICE=1,
00111 NAL_DPA,
00112 NAL_DPB,
00113 NAL_DPC,
00114 NAL_IDR_SLICE,
00115 NAL_SEI,
00116 NAL_SPS,
00117 NAL_PPS,
00118 NAL_AUD,
00119 NAL_END_SEQUENCE,
00120 NAL_END_STREAM,
00121 NAL_FILLER_DATA,
00122 NAL_SPS_EXT,
00123 NAL_AUXILIARY_SLICE=19
00124 };
00125
00129 typedef enum {
00130 SEI_BUFFERING_PERIOD = 0,
00131 SEI_TYPE_PIC_TIMING = 1,
00132 SEI_TYPE_USER_DATA_UNREGISTERED = 5,
00133 SEI_TYPE_RECOVERY_POINT = 6
00134 } SEI_Type;
00135
00139 typedef enum {
00140 SEI_PIC_STRUCT_FRAME = 0,
00141 SEI_PIC_STRUCT_TOP_FIELD = 1,
00142 SEI_PIC_STRUCT_BOTTOM_FIELD = 2,
00143 SEI_PIC_STRUCT_TOP_BOTTOM = 3,
00144 SEI_PIC_STRUCT_BOTTOM_TOP = 4,
00145 SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5,
00146 SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6,
00147 SEI_PIC_STRUCT_FRAME_DOUBLING = 7,
00148 SEI_PIC_STRUCT_FRAME_TRIPLING = 8
00149 } SEI_PicStructType;
00150
00154 typedef struct SPS{
00155
00156 int profile_idc;
00157 int level_idc;
00158 int chroma_format_idc;
00159 int transform_bypass;
00160 int log2_max_frame_num;
00161 int poc_type;
00162 int log2_max_poc_lsb;
00163 int delta_pic_order_always_zero_flag;
00164 int offset_for_non_ref_pic;
00165 int offset_for_top_to_bottom_field;
00166 int poc_cycle_length;
00167 int ref_frame_count;
00168 int gaps_in_frame_num_allowed_flag;
00169 int mb_width;
00170 int mb_height;
00171 int frame_mbs_only_flag;
00172 int mb_aff;
00173 int direct_8x8_inference_flag;
00174 int crop;
00175 unsigned int crop_left;
00176 unsigned int crop_right;
00177 unsigned int crop_top;
00178 unsigned int crop_bottom;
00179 int vui_parameters_present_flag;
00180 AVRational sar;
00181 int video_signal_type_present_flag;
00182 int full_range;
00183 int colour_description_present_flag;
00184 enum AVColorPrimaries color_primaries;
00185 enum AVColorTransferCharacteristic color_trc;
00186 enum AVColorSpace colorspace;
00187 int timing_info_present_flag;
00188 uint32_t num_units_in_tick;
00189 uint32_t time_scale;
00190 int fixed_frame_rate_flag;
00191 short offset_for_ref_frame[256];
00192 int bitstream_restriction_flag;
00193 int num_reorder_frames;
00194 int scaling_matrix_present;
00195 uint8_t scaling_matrix4[6][16];
00196 uint8_t scaling_matrix8[6][64];
00197 int nal_hrd_parameters_present_flag;
00198 int vcl_hrd_parameters_present_flag;
00199 int pic_struct_present_flag;
00200 int time_offset_length;
00201 int cpb_cnt;
00202 int initial_cpb_removal_delay_length;
00203 int cpb_removal_delay_length;
00204 int dpb_output_delay_length;
00205 int bit_depth_luma;
00206 int bit_depth_chroma;
00207 int residual_color_transform_flag;
00208 int constraint_set_flags;
00209 }SPS;
00210
00214 typedef struct PPS{
00215 unsigned int sps_id;
00216 int cabac;
00217 int pic_order_present;
00218 int slice_group_count;
00219 int mb_slice_group_map_type;
00220 unsigned int ref_count[2];
00221 int weighted_pred;
00222 int weighted_bipred_idc;
00223 int init_qp;
00224 int init_qs;
00225 int chroma_qp_index_offset[2];
00226 int deblocking_filter_parameters_present;
00227 int constrained_intra_pred;
00228 int redundant_pic_cnt_present;
00229 int transform_8x8_mode;
00230 uint8_t scaling_matrix4[6][16];
00231 uint8_t scaling_matrix8[6][64];
00232 uint8_t chroma_qp_table[2][QP_MAX_NUM+1];
00233 int chroma_qp_diff;
00234 }PPS;
00235
00239 typedef enum MMCOOpcode{
00240 MMCO_END=0,
00241 MMCO_SHORT2UNUSED,
00242 MMCO_LONG2UNUSED,
00243 MMCO_SHORT2LONG,
00244 MMCO_SET_MAX_LONG,
00245 MMCO_RESET,
00246 MMCO_LONG,
00247 } MMCOOpcode;
00248
00252 typedef struct MMCO{
00253 MMCOOpcode opcode;
00254 int short_pic_num;
00255 int long_arg;
00256 } MMCO;
00257
00261 typedef struct H264Context{
00262 MpegEncContext s;
00263 H264DSPContext h264dsp;
00264 int pixel_shift;
00265 int chroma_qp[2];
00266
00267 int qp_thresh;
00268
00269 int prev_mb_skipped;
00270 int next_mb_skipped;
00271
00272
00273 int chroma_pred_mode;
00274 int intra16x16_pred_mode;
00275
00276 int topleft_mb_xy;
00277 int top_mb_xy;
00278 int topright_mb_xy;
00279 int left_mb_xy[LEFT_MBS];
00280
00281 int topleft_type;
00282 int top_type;
00283 int topright_type;
00284 int left_type[LEFT_MBS];
00285
00286 const uint8_t * left_block;
00287 int topleft_partition;
00288
00289 int8_t intra4x4_pred_mode_cache[5*8];
00290 int8_t (*intra4x4_pred_mode);
00291 H264PredContext hpc;
00292 unsigned int topleft_samples_available;
00293 unsigned int top_samples_available;
00294 unsigned int topright_samples_available;
00295 unsigned int left_samples_available;
00296 uint8_t (*top_borders[2])[(16*3)*2];
00297
00302 DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15*8];
00303
00304 uint8_t (*non_zero_count)[48];
00305
00309 DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5*8][2];
00310 DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5*8];
00311 #define LIST_NOT_USED -1 //FIXME rename?
00312 #define PART_NOT_AVAILABLE -2
00313
00317 int neighbor_transform_size;
00318
00323 int block_offset[2*(16*3)];
00324
00325 uint32_t *mb2b_xy;
00326 uint32_t *mb2br_xy;
00327 int b_stride;
00328
00329 int mb_linesize;
00330 int mb_uvlinesize;
00331
00332 int emu_edge_width;
00333 int emu_edge_height;
00334
00335 SPS sps;
00336
00340 PPS pps;
00341
00342 uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16];
00343 uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64];
00344 uint32_t (*dequant4_coeff[6])[16];
00345 uint32_t (*dequant8_coeff[6])[64];
00346
00347 int slice_num;
00348 uint16_t *slice_table;
00349 int slice_type;
00350 int slice_type_nos;
00351 int slice_type_fixed;
00352
00353
00354 int mb_aff_frame;
00355 int mb_field_decoding_flag;
00356 int mb_mbaff;
00357
00358 DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
00359
00360
00361 int use_weight;
00362 int use_weight_chroma;
00363 int luma_log2_weight_denom;
00364 int chroma_log2_weight_denom;
00365
00366 int luma_weight[48][2][2];
00367 int chroma_weight[48][2][2][2];
00368 int implicit_weight[48][48][2];
00369
00370 int direct_spatial_mv_pred;
00371 int col_parity;
00372 int col_fieldoff;
00373 int dist_scale_factor[16];
00374 int dist_scale_factor_field[2][32];
00375 int map_col_to_list0[2][16+32];
00376 int map_col_to_list0_field[2][2][16+32];
00377
00381 uint8_t *list_counts;
00382 unsigned int ref_count[2];
00383 unsigned int list_count;
00384 Picture ref_list[2][48];
00387 int ref2frm[MAX_SLICES][2][64];
00388
00389
00390 GetBitContext intra_gb;
00391 GetBitContext inter_gb;
00392 GetBitContext *intra_gb_ptr;
00393 GetBitContext *inter_gb_ptr;
00394
00395 DECLARE_ALIGNED(16, DCTELEM, mb)[16*48*2];
00396 DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[3][16*2];
00397 DCTELEM mb_padding[256*2];
00398
00402 CABACContext cabac;
00403 uint8_t cabac_state[1024];
00404
00405
00406 uint16_t *cbp_table;
00407 int cbp;
00408 int top_cbp;
00409 int left_cbp;
00410
00411 uint8_t *chroma_pred_mode_table;
00412 int last_qscale_diff;
00413 uint8_t (*mvd_table[2])[2];
00414 DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5*8][2];
00415 uint8_t *direct_table;
00416 uint8_t direct_cache[5*8];
00417
00418 uint8_t zigzag_scan[16];
00419 uint8_t zigzag_scan8x8[64];
00420 uint8_t zigzag_scan8x8_cavlc[64];
00421 uint8_t field_scan[16];
00422 uint8_t field_scan8x8[64];
00423 uint8_t field_scan8x8_cavlc[64];
00424 const uint8_t *zigzag_scan_q0;
00425 const uint8_t *zigzag_scan8x8_q0;
00426 const uint8_t *zigzag_scan8x8_cavlc_q0;
00427 const uint8_t *field_scan_q0;
00428 const uint8_t *field_scan8x8_q0;
00429 const uint8_t *field_scan8x8_cavlc_q0;
00430
00431 int x264_build;
00432
00433 int mb_xy;
00434
00435 int is_complex;
00436
00437
00438 int deblocking_filter;
00439 int slice_alpha_c0_offset;
00440 int slice_beta_offset;
00441
00442
00443
00444
00445 int nal_ref_idc;
00446 int nal_unit_type;
00447 uint8_t *rbsp_buffer[2];
00448 unsigned int rbsp_buffer_size[2];
00449
00453 int is_avc;
00454 int nal_length_size;
00455 int got_first;
00456
00457 SPS *sps_buffers[MAX_SPS_COUNT];
00458 PPS *pps_buffers[MAX_PPS_COUNT];
00459
00460 int dequant_coeff_pps;
00461
00462 uint16_t *slice_table_base;
00463
00464
00465
00466 int poc_lsb;
00467 int poc_msb;
00468 int delta_poc_bottom;
00469 int delta_poc[2];
00470 int frame_num;
00471 int prev_poc_msb;
00472 int prev_poc_lsb;
00473 int frame_num_offset;
00474 int prev_frame_num_offset;
00475 int prev_frame_num;
00476
00480 int curr_pic_num;
00481
00485 int max_pic_num;
00486
00487 int redundant_pic_count;
00488
00489 Picture *short_ref[32];
00490 Picture *long_ref[32];
00491 Picture default_ref_list[2][32];
00492 Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2];
00493 int last_pocs[MAX_DELAYED_PIC_COUNT];
00494 Picture *next_output_pic;
00495 int outputed_poc;
00496 int next_outputed_poc;
00497
00501 MMCO mmco[MAX_MMCO_COUNT];
00502 int mmco_index;
00503 int mmco_reset;
00504
00505 int long_ref_count;
00506 int short_ref_count;
00507
00508 int cabac_init_idc;
00509
00514 struct H264Context *thread_context[MAX_THREADS];
00515
00519 int current_slice;
00520
00527 int max_contexts;
00528
00533 int single_decode_warning;
00534
00535 int last_slice_type;
00541 SEI_PicStructType sei_pic_struct;
00542
00549 int prev_interlaced_frame;
00550
00556 int sei_ct_type;
00557
00561 int sei_dpb_output_delay;
00562
00566 int sei_cpb_removal_delay;
00567
00575 int sei_recovery_frame_cnt;
00582 int recovery_frame;
00583
00584 int luma_weight_flag[2];
00585 int chroma_weight_flag[2];
00586
00587
00588 int sei_buffering_period_present;
00589 int initial_cpb_removal_delay[32];
00590
00591 int cur_chroma_format_idc;
00592
00593 int16_t slice_row[MAX_SLICES];
00594
00595 int sync;
00596
00597 uint8_t parse_history[4];
00598 int parse_history_count;
00599 int parse_last_mb;
00600 }H264Context;
00601
00602
00603 extern const uint8_t ff_h264_chroma_qp[5][QP_MAX_NUM+1];
00604
00608 int ff_h264_decode_sei(H264Context *h);
00609
00613 int ff_h264_decode_seq_parameter_set(H264Context *h);
00614
00618 int ff_h264_get_profile(SPS *sps);
00619
00623 int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
00624
00632 const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length);
00633
00637 av_cold void ff_h264_free_context(H264Context *h);
00638
00642 int ff_h264_get_slice_type(const H264Context *h);
00643
00648 int ff_h264_alloc_tables(H264Context *h);
00649
00653 int ff_h264_fill_default_ref_list(H264Context *h);
00654
00655 int ff_h264_decode_ref_pic_list_reordering(H264Context *h);
00656 void ff_h264_fill_mbaff_ref_list(H264Context *h);
00657 void ff_h264_remove_all_refs(H264Context *h);
00658
00662 int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count);
00663
00664 int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb);
00665
00666 void ff_generate_sliding_window_mmcos(H264Context *h);
00667
00668
00672 int ff_h264_check_intra4x4_pred_mode(H264Context *h);
00673
00677 int ff_h264_check_intra16x16_pred_mode(H264Context *h, int mode);
00678
00682 int ff_h264_check_intra_chroma_pred_mode(H264Context *h, int mode);
00683
00684 void ff_h264_hl_decode_mb(H264Context *h);
00685 int ff_h264_frame_start(H264Context *h);
00686 int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size);
00687 av_cold int ff_h264_decode_init(AVCodecContext *avctx);
00688 av_cold int ff_h264_decode_end(AVCodecContext *avctx);
00689 av_cold void ff_h264_decode_init_vlc(void);
00690
00695 int ff_h264_decode_mb_cavlc(H264Context *h);
00696
00701 int ff_h264_decode_mb_cabac(H264Context *h);
00702
00703 void ff_h264_init_cabac_states(H264Context *h);
00704
00705 void ff_h264_direct_dist_scale_factor(H264Context * const h);
00706 void ff_h264_direct_ref_list_init(H264Context * const h);
00707 void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type);
00708
00709 void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
00710 void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
00711
00717 void ff_h264_reset_sei(H264Context *h);
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750 #define LUMA_DC_BLOCK_INDEX 48
00751 #define CHROMA_DC_BLOCK_INDEX 49
00752
00753
00754 static const uint8_t scan8[16*3 + 3]={
00755 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8,
00756 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8,
00757 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8,
00758 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8,
00759 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8,
00760 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8,
00761 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8,
00762 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8,
00763 4+11*8, 5+11*8, 4+12*8, 5+12*8,
00764 6+11*8, 7+11*8, 6+12*8, 7+12*8,
00765 4+13*8, 5+13*8, 4+14*8, 5+14*8,
00766 6+13*8, 7+13*8, 6+14*8, 7+14*8,
00767 0+ 0*8, 0+ 5*8, 0+10*8
00768 };
00769
00770 static av_always_inline uint32_t pack16to32(int a, int b){
00771 #if HAVE_BIGENDIAN
00772 return (b&0xFFFF) + (a<<16);
00773 #else
00774 return (a&0xFFFF) + (b<<16);
00775 #endif
00776 }
00777
00778 static av_always_inline uint16_t pack8to16(int a, int b){
00779 #if HAVE_BIGENDIAN
00780 return (b&0xFF) + (a<<8);
00781 #else
00782 return (a&0xFF) + (b<<8);
00783 #endif
00784 }
00785
00789 static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){
00790 return h->pps.chroma_qp_table[t][qscale];
00791 }
00792
00796 static av_always_inline int pred_intra_mode(H264Context *h, int n){
00797 const int index8= scan8[n];
00798 const int left= h->intra4x4_pred_mode_cache[index8 - 1];
00799 const int top = h->intra4x4_pred_mode_cache[index8 - 8];
00800 const int min= FFMIN(left, top);
00801
00802 tprintf(h->s.avctx, "mode:%d %d min:%d\n", left ,top, min);
00803
00804 if(min<0) return DC_PRED;
00805 else return min;
00806 }
00807
00808 static av_always_inline void write_back_intra_pred_mode(H264Context *h){
00809 int8_t *i4x4= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy];
00810 int8_t *i4x4_cache= h->intra4x4_pred_mode_cache;
00811
00812 AV_COPY32(i4x4, i4x4_cache + 4 + 8*4);
00813 i4x4[4]= i4x4_cache[7+8*3];
00814 i4x4[5]= i4x4_cache[7+8*2];
00815 i4x4[6]= i4x4_cache[7+8*1];
00816 }
00817
00818 static av_always_inline void write_back_non_zero_count(H264Context *h){
00819 const int mb_xy= h->mb_xy;
00820 uint8_t *nnz = h->non_zero_count[mb_xy];
00821 uint8_t *nnz_cache = h->non_zero_count_cache;
00822
00823 AV_COPY32(&nnz[ 0], &nnz_cache[4+8* 1]);
00824 AV_COPY32(&nnz[ 4], &nnz_cache[4+8* 2]);
00825 AV_COPY32(&nnz[ 8], &nnz_cache[4+8* 3]);
00826 AV_COPY32(&nnz[12], &nnz_cache[4+8* 4]);
00827 AV_COPY32(&nnz[16], &nnz_cache[4+8* 6]);
00828 AV_COPY32(&nnz[20], &nnz_cache[4+8* 7]);
00829 AV_COPY32(&nnz[32], &nnz_cache[4+8*11]);
00830 AV_COPY32(&nnz[36], &nnz_cache[4+8*12]);
00831
00832 if(!h->s.chroma_y_shift){
00833 AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]);
00834 AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]);
00835 AV_COPY32(&nnz[40], &nnz_cache[4+8*13]);
00836 AV_COPY32(&nnz[44], &nnz_cache[4+8*14]);
00837 }
00838 }
00839
00840 static av_always_inline void write_back_motion_list(H264Context *h, MpegEncContext * const s, int b_stride,
00841 int b_xy, int b8_xy, int mb_type, int list )
00842 {
00843 int16_t (*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy];
00844 int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]];
00845 AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0);
00846 AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1);
00847 AV_COPY128(mv_dst + 2*b_stride, mv_src + 8*2);
00848 AV_COPY128(mv_dst + 3*b_stride, mv_src + 8*3);
00849 if( CABAC ) {
00850 uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8*h->mb_xy : h->mb2br_xy[h->mb_xy]];
00851 uint8_t (*mvd_src)[2] = &h->mvd_cache[list][scan8[0]];
00852 if(IS_SKIP(mb_type))
00853 AV_ZERO128(mvd_dst);
00854 else{
00855 AV_COPY64(mvd_dst, mvd_src + 8*3);
00856 AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8*0);
00857 AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8*1);
00858 AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8*2);
00859 }
00860 }
00861
00862 {
00863 int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy];
00864 int8_t *ref_cache = h->ref_cache[list];
00865 ref_index[0+0*2]= ref_cache[scan8[0]];
00866 ref_index[1+0*2]= ref_cache[scan8[4]];
00867 ref_index[0+1*2]= ref_cache[scan8[8]];
00868 ref_index[1+1*2]= ref_cache[scan8[12]];
00869 }
00870 }
00871
00872 static av_always_inline void write_back_motion(H264Context *h, int mb_type){
00873 MpegEncContext * const s = &h->s;
00874 const int b_stride = h->b_stride;
00875 const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride;
00876 const int b8_xy= 4*h->mb_xy;
00877
00878 if(USES_LIST(mb_type, 0)){
00879 write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0);
00880 }else{
00881 fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy],
00882 2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
00883 }
00884 if(USES_LIST(mb_type, 1)){
00885 write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1);
00886 }
00887
00888 if(h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC){
00889 if(IS_8X8(mb_type)){
00890 uint8_t *direct_table = &h->direct_table[4*h->mb_xy];
00891 direct_table[1] = h->sub_mb_type[1]>>1;
00892 direct_table[2] = h->sub_mb_type[2]>>1;
00893 direct_table[3] = h->sub_mb_type[3]>>1;
00894 }
00895 }
00896 }
00897
00898 static av_always_inline int get_dct8x8_allowed(H264Context *h){
00899 if(h->sps.direct_8x8_inference_flag)
00900 return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8 )*0x0001000100010001ULL));
00901 else
00902 return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8|MB_TYPE_DIRECT2)*0x0001000100010001ULL));
00903 }
00904
00905 #endif