X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264.h;h=920e3fc1c8412943200353106b329d98b4fb05f1;hb=01f6df01b6fdc2d71b82370374cde4bf102928c7;hp=6eda2a693f5b2301716294633553488a617f1f5f;hpb=94ee7da08d2af875f485d4f784d50726cf3078f4;p=ffmpeg diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 6eda2a693f5..920e3fc1c84 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -30,6 +30,7 @@ #include "libavutil/intreadwrite.h" #include "cabac.h" +#include "error_resilience.h" #include "get_bits.h" #include "mpegvideo.h" #include "h264chroma.h" @@ -58,19 +59,19 @@ #define MAX_SLICES 16 #ifdef ALLOW_INTERLACE -#define MB_MBAFF h->mb_mbaff -#define MB_FIELD h->mb_field_decoding_flag -#define FRAME_MBAFF h->mb_aff_frame -#define FIELD_PICTURE (h->picture_structure != PICT_FRAME) +#define MB_MBAFF(h) h->mb_mbaff +#define MB_FIELD(h) h->mb_field_decoding_flag +#define FRAME_MBAFF(h) h->mb_aff_frame +#define FIELD_PICTURE(h) (h->picture_structure != PICT_FRAME) #define LEFT_MBS 2 #define LTOP 0 #define LBOT 1 #define LEFT(i) (i) #else -#define MB_MBAFF 0 -#define MB_FIELD 0 -#define FRAME_MBAFF 0 -#define FIELD_PICTURE 0 +#define MB_MBAFF(h) 0 +#define MB_FIELD(h) 0 +#define FRAME_MBAFF(h) 0 +#define FIELD_PICTURE(h) 0 #undef IS_INTERLACED #define IS_INTERLACED(mb_type) 0 #define LEFT_MBS 1 @@ -78,14 +79,14 @@ #define LBOT 0 #define LEFT(i) 0 #endif -#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) +#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h)) #ifndef CABAC -#define CABAC h->pps.cabac +#define CABAC(h) h->pps.cabac #endif -#define CHROMA422 (h->sps.chroma_format_idc == 2) -#define CHROMA444 (h->sps.chroma_format_idc == 3) +#define CHROMA422(h) (h->sps.chroma_format_idc == 2) +#define CHROMA444(h) (h->sps.chroma_format_idc == 3) #define EXTENDED_SAR 255 @@ -163,6 +164,8 @@ typedef struct SPS { int mb_aff; ///< mb_adaptive_frame_field_flag int direct_8x8_inference_flag; int crop; ///< frame_cropping_flag + + /* those 4 are already in luma samples */ unsigned int crop_left; ///< frame_cropping_rect_left_offset unsigned int crop_right; ///< frame_cropping_rect_right_offset unsigned int crop_top; ///< frame_cropping_rect_top_offset @@ -265,16 +268,15 @@ typedef struct H264Context { Picture *DPB; Picture *cur_pic_ptr; Picture cur_pic; - int picture_count; - int picture_range_start, picture_range_end; int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264 int chroma_qp[2]; // QPc int qp_thresh; ///< QP threshold to skip loopfilter + /* coded dimensions -- 16 * mb w/h */ int width, height; - int linesize, uvlinesize; + ptrdiff_t linesize, uvlinesize; int chroma_x_shift, chroma_y_shift; int qscale; @@ -347,8 +349,8 @@ typedef struct H264Context { uint32_t *mb2br_xy; int b_stride; // FIXME use s->b4_stride - int mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff - int mb_uvlinesize; + ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff + ptrdiff_t mb_uvlinesize; unsigned current_sps_id; ///< id of the current SPS SPS sps; ///< current sps @@ -609,6 +611,27 @@ typedef struct H264Context { */ int sei_recovery_frame_cnt; + /** + * recovery_frame is the frame_num at which the next frame should + * be fully constructed. + * + * Set to -1 when not expecting a recovery point. + */ + int recovery_frame; + +/** + * We have seen an IDR, so all the following frames in coded order are correctly + * decodable. + */ +#define FRAME_RECOVERED_IDR (1 << 0) +/** + * Sufficient number of frames have been decoded since a SEI recovery point, + * so all the following frames in presentation order are correct. + */ +#define FRAME_RECOVERED_SEI (1 << 1) + + int frame_recovered; ///< Initial frame has been completely recovered + int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag @@ -620,6 +643,11 @@ typedef struct H264Context { uint8_t *bipred_scratchpad; uint8_t *edge_emu_buffer; int16_t *dc_val_base; + + AVBufferPool *qscale_table_pool; + AVBufferPool *mb_type_pool; + AVBufferPool *motion_val_pool; + AVBufferPool *ref_index_pool; } H264Context; extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM + 1]; ///< One chroma qp table for each supported bit depth (8, 9, 10). @@ -705,7 +733,6 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h); int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma); void ff_h264_hl_decode_mb(H264Context *h); -int ff_h264_frame_start(H264Context *h); int ff_h264_decode_extradata(H264Context *h); int ff_h264_decode_init(AVCodecContext *avctx); void ff_h264_decode_init_vlc(void); @@ -875,13 +902,13 @@ static av_always_inline void write_back_motion_list(H264Context *h, int b_xy, int b8_xy, int mb_type, int list) { - int16_t(*mv_dst)[2] = &h->cur_pic.f.motion_val[list][b_xy]; + int16_t(*mv_dst)[2] = &h->cur_pic.motion_val[list][b_xy]; int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]]; AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); - if (CABAC) { + if (CABAC(h)) { uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8 * h->mb_xy : h->mb2br_xy[h->mb_xy]]; uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; @@ -896,7 +923,7 @@ static av_always_inline void write_back_motion_list(H264Context *h, } { - int8_t *ref_index = &h->cur_pic.f.ref_index[list][b8_xy]; + int8_t *ref_index = &h->cur_pic.ref_index[list][b8_xy]; int8_t *ref_cache = h->ref_cache[list]; ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; @@ -914,13 +941,13 @@ static av_always_inline void write_back_motion(H264Context *h, int mb_type) if (USES_LIST(mb_type, 0)) { write_back_motion_list(h, b_stride, b_xy, b8_xy, mb_type, 0); } else { - fill_rectangle(&h->cur_pic.f.ref_index[0][b8_xy], + fill_rectangle(&h->cur_pic.ref_index[0][b8_xy], 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); } if (USES_LIST(mb_type, 1)) write_back_motion_list(h, b_stride, b_xy, b8_xy, mb_type, 1); - if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) { + if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) { if (IS_8X8(mb_type)) { uint8_t *direct_table = &h->direct_table[4 * h->mb_xy]; direct_table[1] = h->sub_mb_type[1] >> 1; @@ -943,5 +970,8 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h) } void ff_h264_draw_horiz_band(H264Context *h, int y, int height); +int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc); +int ff_pred_weight_table(H264Context *h); +int ff_set_ref_count(H264Context *h); #endif /* AVCODEC_H264_H */