diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-02-03 11:10:05 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-02-15 16:35:16 +0100 |
commit | 2c541554076cc8a72e7145d4da30389ca763f32f (patch) | |
tree | b404051a202e1ffffe4ecee2df1b89f9f92a70f5 /libavcodec/h264.h | |
parent | 1d0feb5d1ac04d187b335f0e8d411c9f40b3a885 (diff) | |
download | ffmpeg-2c541554076cc8a72e7145d4da30389ca763f32f.tar.gz |
h264: deMpegEncContextize
Most of the changes are just trivial are just trivial replacements of
fields from MpegEncContext with equivalent fields in H264Context.
Everything in h264* other than h264.c are those trivial changes.
The nontrivial parts are:
1) extracting a simplified version of the frame management code from
mpegvideo.c. We don't need last/next_picture anymore, since h264 uses
its own more complex system already and those were set only to appease
the mpegvideo parts.
2) some tables that need to be allocated/freed in appropriate places.
3) hwaccels -- mostly trivial replacements.
for dxva, the draw_horiz_band() call is moved from
ff_dxva2_common_end_frame() to per-codec end_frame() callbacks,
because it's now different for h264 and MpegEncContext-based
decoders.
4) svq3 -- it does not use h264 complex reference system, so I just
added some very simplistic frame management instead and dropped the
use of ff_h264_frame_start(). Because of this I also had to move some
initialization code to svq3.
Additional fixes for chroma format and bit depth changes by
Janne Grunau <janne-libav@jannau.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/h264.h')
-rw-r--r-- | libavcodec/h264.h | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/libavcodec/h264.h b/libavcodec/h264.h index c4addbef48..45c134e877 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -30,6 +30,7 @@ #include "libavutil/intreadwrite.h" #include "cabac.h" +#include "get_bits.h" #include "mpegvideo.h" #include "h264chroma.h" #include "h264dsp.h" @@ -60,7 +61,7 @@ #define MB_MBAFF h->mb_mbaff #define MB_FIELD h->mb_field_decoding_flag #define FRAME_MBAFF h->mb_aff_frame -#define FIELD_PICTURE (s->picture_structure != PICT_FRAME) +#define FIELD_PICTURE (h->picture_structure != PICT_FRAME) #define LEFT_MBS 2 #define LTOP 0 #define LBOT 1 @@ -250,15 +251,42 @@ typedef struct MMCO { * H264Context */ typedef struct H264Context { - MpegEncContext s; + AVCodecContext *avctx; + DSPContext dsp; + VideoDSPContext vdsp; H264DSPContext h264dsp; H264ChromaContext h264chroma; H264QpelContext h264qpel; + MotionEstContext me; + ParseContext parse_context; + GetBitContext gb; + ERContext er; + + 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 + int width, height; + int linesize, uvlinesize; + int chroma_x_shift, chroma_y_shift; + + int qscale; + int droppable; + int data_partitioning; + int coded_picture_number; + int low_delay; + + int context_initialized; + int flags; + int workaround_bugs; + int prev_mb_skipped; int next_mb_skipped; @@ -348,6 +376,8 @@ typedef struct H264Context { int mb_aff_frame; int mb_field_decoding_flag; int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag + int picture_structure; + int first_field; DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; @@ -424,6 +454,13 @@ typedef struct H264Context { int x264_build; + int mb_x, mb_y; + int resync_mb_x; + int resync_mb_y; + int mb_skip_run; + int mb_height, mb_width; + int mb_stride; + int mb_num; int mb_xy; int is_complex; @@ -448,7 +485,8 @@ typedef struct H264Context { int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) int got_first; ///< this flag is != 0 if we've parsed a frame - int context_reinitialized; + int bit_depth_luma; ///< luma bit depth from sps to detect changes + int chroma_format_idc; ///< chroma format from sps to detect changes SPS *sps_buffers[MAX_SPS_COUNT]; PPS *pps_buffers[MAX_PPS_COUNT]; @@ -521,12 +559,16 @@ typedef struct H264Context { */ int max_contexts; + int slice_context_count; + /** * 1 if the single thread fallback warning has already been * displayed, 0 otherwise. */ int single_decode_warning; + enum AVPictureType pict_type; + int last_slice_type; /** @} */ @@ -578,6 +620,8 @@ typedef struct H264Context { int cur_chroma_format_idc; uint8_t *bipred_scratchpad; + uint8_t *edge_emu_buffer; + int16_t *dc_val_base; } 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). @@ -786,7 +830,7 @@ static av_always_inline int pred_intra_mode(H264Context *h, int n) const int top = h->intra4x4_pred_mode_cache[index8 - 8]; const int min = FFMIN(left, top); - tprintf(h->s.avctx, "mode:%d %d min:%d\n", left, top, min); + tprintf(h->avctx, "mode:%d %d min:%d\n", left, top, min); if (min < 0) return DC_PRED; @@ -820,7 +864,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h) AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); - if (!h->s.chroma_y_shift) { + if (!h->chroma_y_shift) { AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); @@ -829,12 +873,11 @@ static av_always_inline void write_back_non_zero_count(H264Context *h) } static av_always_inline void write_back_motion_list(H264Context *h, - MpegEncContext *const s, int b_stride, int b_xy, int b8_xy, int mb_type, int list) { - int16_t(*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; + int16_t(*mv_dst)[2] = &h->cur_pic.f.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); @@ -855,7 +898,7 @@ static av_always_inline void write_back_motion_list(H264Context *h, } { - int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; + int8_t *ref_index = &h->cur_pic.f.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]]; @@ -866,19 +909,18 @@ static av_always_inline void write_back_motion_list(H264Context *h, static av_always_inline void write_back_motion(H264Context *h, int mb_type) { - MpegEncContext *const s = &h->s; const int b_stride = h->b_stride; - const int b_xy = 4 * s->mb_x + 4 * s->mb_y * h->b_stride; // try mb2b(8)_xy + const int b_xy = 4 * h->mb_x + 4 * h->mb_y * h->b_stride; // try mb2b(8)_xy const int b8_xy = 4 * h->mb_xy; if (USES_LIST(mb_type, 0)) { - write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); + write_back_motion_list(h, b_stride, b_xy, b8_xy, mb_type, 0); } else { - fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], + fill_rectangle(&h->cur_pic.f.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, s, b_stride, b_xy, b8_xy, 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 (IS_8X8(mb_type)) { @@ -902,4 +944,6 @@ static av_always_inline int get_dct8x8_allowed(H264Context *h) 0x0001000100010001ULL)); } +void ff_h264_draw_horiz_band(H264Context *h, int y, int height); + #endif /* AVCODEC_H264_H */ |