Commit 92656787 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '6d2b6f21'

* commit '6d2b6f21':
  h264: add a parameter to the CABAC macro.
  h264: add a parameter to the FIELD_OR_MBAFF_PICTURE macro.

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents bf4d0f83 6d2b6f21
...@@ -206,7 +206,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice, ...@@ -206,7 +206,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->SliceBytesInBuffer = size; slice->SliceBytesInBuffer = size;
slice->wBadSliceChopping = 0; slice->wBadSliceChopping = 0;
slice->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE) * h->mb_width + h->mb_x; slice->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + h->mb_x;
slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */ slice->NumMbsForSlice = 0; /* XXX it is set once we have all slices */
slice->BitOffsetToSliceData = get_bits_count(&h->gb); slice->BitOffsetToSliceData = get_bits_count(&h->gb);
slice->slice_type = ff_h264_get_slice_type(h); slice->slice_type = ff_h264_get_slice_type(h);
......
...@@ -1940,7 +1940,7 @@ static void decode_postinit(H264Context *h, int setup_finished) ...@@ -1940,7 +1940,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
break; break;
case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_TOP_BOTTOM:
case SEI_PIC_STRUCT_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP:
if (FIELD_OR_MBAFF_PICTURE) if (FIELD_OR_MBAFF_PICTURE(h))
cur->f.interlaced_frame = 1; cur->f.interlaced_frame = 1;
else else
// try to flag soft telecine progressive // try to flag soft telecine progressive
...@@ -1966,7 +1966,7 @@ static void decode_postinit(H264Context *h, int setup_finished) ...@@ -1966,7 +1966,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0; cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
} else { } else {
/* Derive interlacing flag from used decoding process. */ /* Derive interlacing flag from used decoding process. */
cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE; cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE(h);
} }
h->prev_interlaced_frame = cur->f.interlaced_frame; h->prev_interlaced_frame = cur->f.interlaced_frame;
...@@ -3587,13 +3587,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0) ...@@ -3587,13 +3587,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup h->cur_pic_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup
av_assert1(h->mb_num == h->mb_width * h->mb_height); av_assert1(h->mb_num == h->mb_width * h->mb_height);
if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE >= h->mb_num || if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
first_mb_in_slice >= h->mb_num) { first_mb_in_slice >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n"); av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return -1; return -1;
} }
h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width; h->resync_mb_x = h->mb_x = first_mb_in_slice % h->mb_width;
h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) << FIELD_OR_MBAFF_PICTURE; h->resync_mb_y = h->mb_y = (first_mb_in_slice / h->mb_width) << FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD) if (h->picture_structure == PICT_BOTTOM_FIELD)
h->resync_mb_y = h->mb_y = h->mb_y + 1; h->resync_mb_y = h->mb_y = h->mb_y + 1;
av_assert1(h->mb_y < h->mb_height); av_assert1(h->mb_y < h->mb_height);
...@@ -4078,7 +4078,7 @@ static int fill_filter_caches(H264Context *h, int mb_type) ...@@ -4078,7 +4078,7 @@ static int fill_filter_caches(H264Context *h, int mb_type)
/* CAVLC 8x8dct requires NNZ values for residual decoding that differ /* CAVLC 8x8dct requires NNZ values for residual decoding that differ
* from what the loop filter needs */ * from what the loop filter needs */
if (!CABAC && h->pps.transform_8x8_mode) { if (!CABAC(h) && h->pps.transform_8x8_mode) {
if (IS_8x8DCT(top_type)) { if (IS_8x8DCT(top_type)) {
nnz_cache[4 + 8 * 0] = nnz_cache[4 + 8 * 0] =
nnz_cache[5 + 8 * 0] = (h->cbp_table[top_xy] & 0x4000) >> 12; nnz_cache[5 + 8 * 0] = (h->cbp_table[top_xy] & 0x4000) >> 12;
...@@ -4314,7 +4314,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -4314,7 +4314,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
h->mb_x = lf_x_start = 0; h->mb_x = lf_x_start = 0;
decode_finish_row(h); decode_finish_row(h);
++h->mb_y; ++h->mb_y;
if (FIELD_OR_MBAFF_PICTURE) { if (FIELD_OR_MBAFF_PICTURE(h)) {
++h->mb_y; ++h->mb_y;
if (FRAME_MBAFF(h) && h->mb_y < h->mb_height) if (FRAME_MBAFF(h) && h->mb_y < h->mb_height)
predict_field_decoding_flag(h); predict_field_decoding_flag(h);
...@@ -4361,7 +4361,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -4361,7 +4361,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
h->mb_x = lf_x_start = 0; h->mb_x = lf_x_start = 0;
decode_finish_row(h); decode_finish_row(h);
++h->mb_y; ++h->mb_y;
if (FIELD_OR_MBAFF_PICTURE) { if (FIELD_OR_MBAFF_PICTURE(h)) {
++h->mb_y; ++h->mb_y;
if (FRAME_MBAFF(h) && h->mb_y < h->mb_height) if (FRAME_MBAFF(h) && h->mb_y < h->mb_height)
predict_field_decoding_flag(h); predict_field_decoding_flag(h);
......
...@@ -81,10 +81,10 @@ ...@@ -81,10 +81,10 @@
#define LBOT 0 #define LBOT 0
#define LEFT(i) 0 #define LEFT(i) 0
#endif #endif
#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF(h) || FIELD_PICTURE(h)) #define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
#ifndef CABAC #ifndef CABAC
#define CABAC h->pps.cabac #define CABAC(h) h->pps.cabac
#endif #endif
#define CHROMA (h->sps.chroma_format_idc) #define CHROMA (h->sps.chroma_format_idc)
...@@ -911,7 +911,7 @@ static av_always_inline void write_back_motion_list(H264Context *h, ...@@ -911,7 +911,7 @@ static av_always_inline void write_back_motion_list(H264Context *h,
AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); 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 + 2 * b_stride, mv_src + 8 * 2);
AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); 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 uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8 * h->mb_xy
: h->mb2br_xy[h->mb_xy]]; : h->mb2br_xy[h->mb_xy]];
uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]];
...@@ -950,7 +950,7 @@ static av_always_inline void write_back_motion(H264Context *h, int mb_type) ...@@ -950,7 +950,7 @@ static av_always_inline void write_back_motion(H264Context *h, int mb_type)
if (USES_LIST(mb_type, 1)) if (USES_LIST(mb_type, 1))
write_back_motion_list(h, 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 (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) {
if (IS_8X8(mb_type)) { if (IS_8X8(mb_type)) {
uint8_t *direct_table = &h->direct_table[4 * h->mb_xy]; uint8_t *direct_table = &h->direct_table[4 * h->mb_xy];
direct_table[1] = h->sub_mb_type[1] >> 1; direct_table[1] = h->sub_mb_type[1] >> 1;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* @author Michael Niedermayer <michaelni@gmx.at> * @author Michael Niedermayer <michaelni@gmx.at>
*/ */
#define CABAC 1 #define CABAC(h) 1
#define UNCHECKED_BITSTREAM_READER 1 #define UNCHECKED_BITSTREAM_READER 1
#include "config.h" #include "config.h"
...@@ -2310,7 +2310,7 @@ decode_intra_mb: ...@@ -2310,7 +2310,7 @@ decode_intra_mb:
} }
} }
if (h->top_type && !IS_8x8DCT(h->top_type)){ if (h->top_type && !IS_8x8DCT(h->top_type)){
uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4+8* 0], top_empty); AV_WN32A(&nnz_cache[4+8* 0], top_empty);
AV_WN32A(&nnz_cache[4+8* 5], top_empty); AV_WN32A(&nnz_cache[4+8* 5], top_empty);
AV_WN32A(&nnz_cache[4+8*10], top_empty); AV_WN32A(&nnz_cache[4+8*10], top_empty);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* @author Michael Niedermayer <michaelni@gmx.at> * @author Michael Niedermayer <michaelni@gmx.at>
*/ */
#define CABAC 0 #define CABAC(h) 0
#define UNCHECKED_BITSTREAM_READER 1 #define UNCHECKED_BITSTREAM_READER 1
#include "internal.h" #include "internal.h"
......
...@@ -497,7 +497,7 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u ...@@ -497,7 +497,7 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u
if (IS_INTRA(mb_type | h->cur_pic.mb_type[mbn_xy])) { if (IS_INTRA(mb_type | h->cur_pic.mb_type[mbn_xy])) {
AV_WN64A(bS, 0x0003000300030003ULL); AV_WN64A(bS, 0x0003000300030003ULL);
} else { } else {
if (!CABAC && IS_8x8DCT(h->cur_pic.mb_type[mbn_xy])) { if (!CABAC(h) && IS_8x8DCT(h->cur_pic.mb_type[mbn_xy])) {
bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]); bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]);
bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]); bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]);
bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]); bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]);
......
...@@ -544,7 +544,7 @@ static void fill_decode_caches(H264Context *h, int mb_type) ...@@ -544,7 +544,7 @@ static void fill_decode_caches(H264Context *h, int mb_type)
AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]); AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]);
} }
} else { } else {
uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040; uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty); AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty);
AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty); AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty);
AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty); AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty);
...@@ -575,11 +575,11 @@ static void fill_decode_caches(H264Context *h, int mb_type) ...@@ -575,11 +575,11 @@ static void fill_decode_caches(H264Context *h, int mb_type)
nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz_cache[3 + 8 * 6 + 2 * 8 * i] =
nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz_cache[3 + 8 * 7 + 2 * 8 * i] =
nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz_cache[3 + 8 * 11 + 2 * 8 * i] =
nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC && !IS_INTRA(mb_type) ? 0 : 64; nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 64;
} }
} }
if (CABAC) { if (CABAC(h)) {
// top_cbp // top_cbp
if (top_type) if (top_type)
h->top_cbp = h->cbp_table[top_xy]; h->top_cbp = h->cbp_table[top_xy];
...@@ -688,7 +688,7 @@ static void fill_decode_caches(H264Context *h, int mb_type) ...@@ -688,7 +688,7 @@ static void fill_decode_caches(H264Context *h, int mb_type)
AV_ZERO32(mv_cache[2 + 8 * 0]); AV_ZERO32(mv_cache[2 + 8 * 0]);
AV_ZERO32(mv_cache[2 + 8 * 2]); AV_ZERO32(mv_cache[2 + 8 * 2]);
if (CABAC) { if (CABAC(h)) {
if (USES_LIST(top_type, list)) { if (USES_LIST(top_type, list)) {
const int b_xy = h->mb2br_xy[top_xy]; const int b_xy = h->mb2br_xy[top_xy];
AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]); AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]);
......
...@@ -325,7 +325,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx, ...@@ -325,7 +325,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
if (!slice_param) if (!slice_param)
return -1; return -1;
slice_param->slice_data_bit_offset = get_bits_count(&h->gb) + 8; /* bit buffer started beyond nal_unit_type */ slice_param->slice_data_bit_offset = get_bits_count(&h->gb) + 8; /* bit buffer started beyond nal_unit_type */
slice_param->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE) * h->mb_width + h->mb_x; slice_param->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + h->mb_x;
slice_param->slice_type = ff_h264_get_slice_type(h); slice_param->slice_type = ff_h264_get_slice_type(h);
slice_param->direct_spatial_mv_pred_flag = h->slice_type == AV_PICTURE_TYPE_B ? h->direct_spatial_mv_pred : 0; slice_param->direct_spatial_mv_pred_flag = h->slice_type == AV_PICTURE_TYPE_B ? h->direct_spatial_mv_pred : 0;
slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l0_active_minus1 = h->list_count > 0 ? h->ref_count[0] - 1 : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment