1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '95eb35f30513e335990ad0d5dca6ddc318477291'

* commit '95eb35f30513e335990ad0d5dca6ddc318477291':
  h264: move the ref lists variables into the per-slice context

Conflicts:
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_direct.c
	libavcodec/h264_mb.c
	libavcodec/h264_picture.c
	libavcodec/h264_refs.c
	libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-03-21 14:59:58 +01:00
commit cc2cfdc497
17 changed files with 223 additions and 212 deletions

View File

@ -228,10 +228,10 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->slice_type += 5; slice->slice_type += 5;
slice->luma_log2_weight_denom = sl->luma_log2_weight_denom; slice->luma_log2_weight_denom = sl->luma_log2_weight_denom;
slice->chroma_log2_weight_denom = sl->chroma_log2_weight_denom; slice->chroma_log2_weight_denom = sl->chroma_log2_weight_denom;
if (h->list_count > 0) if (sl->list_count > 0)
slice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1; slice->num_ref_idx_l0_active_minus1 = sl->ref_count[0] - 1;
if (h->list_count > 1) if (sl->list_count > 1)
slice->num_ref_idx_l1_active_minus1 = h->ref_count[1] - 1; slice->num_ref_idx_l1_active_minus1 = sl->ref_count[1] - 1;
slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2; slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice->slice_beta_offset_div2 = h->slice_beta_offset / 2; slice->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice->Reserved8Bits = 0; slice->Reserved8Bits = 0;
@ -239,8 +239,8 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
for (list = 0; list < 2; list++) { for (list = 0; list < 2; list++) {
unsigned i; unsigned i;
for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) { for (i = 0; i < FF_ARRAY_ELEMS(slice->RefPicList[list]); i++) {
if (list < h->list_count && i < h->ref_count[list]) { if (list < sl->list_count && i < sl->ref_count[list]) {
const H264Picture *r = &h->ref_list[list][i]; const H264Picture *r = &sl->ref_list[list][i];
unsigned plane; unsigned plane;
unsigned index; unsigned index;
if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO) if (ctx->workaround & FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
@ -447,6 +447,7 @@ static int dxva2_h264_decode_slice(AVCodecContext *avctx,
static int dxva2_h264_end_frame(AVCodecContext *avctx) static int dxva2_h264_end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
H264SliceContext *sl = &h->slice_ctx[0];
struct dxva2_picture_context *ctx_pic = struct dxva2_picture_context *ctx_pic =
h->cur_pic_ptr->hwaccel_picture_private; h->cur_pic_ptr->hwaccel_picture_private;
int ret; int ret;
@ -458,7 +459,7 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
&ctx_pic->qm, sizeof(ctx_pic->qm), &ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer); commit_bitstream_and_slice_buffer);
if (!ret) if (!ret)
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
return ret; return ret;
} }

View File

@ -75,13 +75,13 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
* differ between slices. We take the easy approach and ignore * differ between slices. We take the easy approach and ignore
* it for now. If this turns out to have any relevance in * it for now. If this turns out to have any relevance in
* practice then correct remapping should be added. */ * practice then correct remapping should be added. */
if (ref >= h->ref_count[0]) if (ref >= sl->ref_count[0])
ref = 0; ref = 0;
if (!h->ref_list[0][ref].f.data[0]) { if (!sl->ref_list[0][ref].f.data[0]) {
av_log(h->avctx, AV_LOG_DEBUG, "Reference not available for error concealing\n"); av_log(h->avctx, AV_LOG_DEBUG, "Reference not available for error concealing\n");
ref = 0; ref = 0;
} }
if ((h->ref_list[0][ref].reference&3) != 3) { if ((sl->ref_list[0][ref].reference&3) != 3) {
av_log(h->avctx, AV_LOG_DEBUG, "Reference invalid\n"); av_log(h->avctx, AV_LOG_DEBUG, "Reference invalid\n");
return; return;
} }
@ -95,11 +95,12 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
ff_h264_hl_decode_mb(h, &h->slice_ctx[0]); ff_h264_hl_decode_mb(h, &h->slice_ctx[0]);
} }
void ff_h264_draw_horiz_band(H264Context *h, int y, int height) void ff_h264_draw_horiz_band(H264Context *h, H264SliceContext *sl,
int y, int height)
{ {
AVCodecContext *avctx = h->avctx; AVCodecContext *avctx = h->avctx;
AVFrame *cur = &h->cur_pic.f; AVFrame *cur = &h->cur_pic.f;
AVFrame *last = h->ref_list[0][0].f.data[0] ? &h->ref_list[0][0].f : NULL; AVFrame *last = sl->ref_list[0][0].f.data[0] ? &sl->ref_list[0][0].f : NULL;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int vshift = desc->log2_chroma_h; int vshift = desc->log2_chroma_h;
const int field_pic = h->picture_structure != PICT_FRAME; const int field_pic = h->picture_structure != PICT_FRAME;
@ -1033,7 +1034,7 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl)
for (list = 0; list < 2; list++) { for (list = 0; list < 2; list++) {
sl->luma_weight_flag[list] = 0; sl->luma_weight_flag[list] = 0;
sl->chroma_weight_flag[list] = 0; sl->chroma_weight_flag[list] = 0;
for (i = 0; i < h->ref_count[list]; i++) { for (i = 0; i < sl->ref_count[list]; i++) {
int luma_weight_flag, chroma_weight_flag; int luma_weight_flag, chroma_weight_flag;
luma_weight_flag = get_bits1(&h->gb); luma_weight_flag = get_bits1(&h->gb);
@ -1117,9 +1118,10 @@ void ff_h264_flush_change(H264Context *h)
ff_h264_reset_sei(h); ff_h264_reset_sei(h);
h->recovery_frame = -1; h->recovery_frame = -1;
h->frame_recovered = 0; h->frame_recovered = 0;
h->list_count = 0;
h->current_slice = 0; h->current_slice = 0;
h->mmco_reset = 1; h->mmco_reset = 1;
for (i = 0; i < h->nb_slice_ctx; i++)
h->slice_ctx[i].list_count = 0;
} }
/* forget old pics after a seek */ /* forget old pics after a seek */
@ -1324,8 +1326,8 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
if (ref_count[0]-1 > max[0] || ref_count[1]-1 > max[1]){ if (ref_count[0]-1 > max[0] || ref_count[1]-1 > max[1]){
av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", ref_count[0]-1, max[0], ref_count[1]-1, max[1]); av_log(h->avctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n", ref_count[0]-1, max[0], ref_count[1]-1, max[1]);
h->ref_count[0] = h->ref_count[1] = 0; sl->ref_count[0] = sl->ref_count[1] = 0;
h->list_count = 0; sl->list_count = 0;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -1338,12 +1340,12 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
ref_count[0] = ref_count[1] = 0; ref_count[0] = ref_count[1] = 0;
} }
if (list_count != h->list_count || if (list_count != sl->list_count ||
ref_count[0] != h->ref_count[0] || ref_count[0] != sl->ref_count[0] ||
ref_count[1] != h->ref_count[1]) { ref_count[1] != sl->ref_count[1]) {
h->ref_count[0] = ref_count[0]; sl->ref_count[0] = ref_count[0];
h->ref_count[1] = ref_count[1]; sl->ref_count[1] = ref_count[1];
h->list_count = list_count; sl->list_count = list_count;
return 1; return 1;
} }
@ -1701,7 +1703,7 @@ again:
if (err < 0 || err == SLICE_SKIPED) { if (err < 0 || err == SLICE_SKIPED) {
if (err < 0) if (err < 0)
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n"); av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
h->ref_count[0] = h->ref_count[1] = h->list_count = 0; sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
} else if (err == SLICE_SINGLETHREAD) { } else if (err == SLICE_SINGLETHREAD) {
/* Slice could not be decoded in parallel mode, copy down /* Slice could not be decoded in parallel mode, copy down
* NAL unit stuff to context 0 and restart. Note that * NAL unit stuff to context 0 and restart. Note that
@ -1875,7 +1877,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->flags2 & CODEC_FLAG2_CHUNKS) if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1); decode_postinit(h, 1);
ff_h264_field_end(h, 0); ff_h264_field_end(h, &h->slice_ctx[0], 0);
/* Wait for second field. */ /* Wait for second field. */
*got_frame = 0; *got_frame = 0;

View File

@ -401,6 +401,17 @@ typedef struct H264SliceContext {
int map_col_to_list0[2][16 + 32]; int map_col_to_list0[2][16 + 32];
int map_col_to_list0_field[2][2][16 + 32]; int map_col_to_list0_field[2][2][16 + 32];
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
unsigned int list_count;
H264Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
* Reordered version of default_ref_list
* according to picture reordering in slice header */
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
/** /**
* non zero coeff count cache. * non zero coeff count cache.
* is 64 if not available. * is 64 if not available.
@ -492,16 +503,7 @@ typedef struct H264Context {
int picture_structure; int picture_structure;
int first_field; int first_field;
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
unsigned int list_count;
uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type
H264Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs.
* Reordered version of default_ref_list
* according to picture reordering in slice header */
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
// data partitioning // data partitioning
GetBitContext intra_gb; GetBitContext intra_gb;
@ -834,7 +836,7 @@ int ff_h264_alloc_tables(H264Context *h);
*/ */
int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl); int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl);
int ff_h264_decode_ref_pic_list_reordering(H264Context *h); int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl);
void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl); void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl);
void ff_h264_remove_all_refs(H264Context *h); void ff_h264_remove_all_refs(H264Context *h);
@ -1148,7 +1150,7 @@ static inline int get_avc_nalsize(H264Context *h, const uint8_t *buf,
return nalsize; return nalsize;
} }
int ff_h264_field_end(H264Context *h, int in_setup); int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src); int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
void ff_h264_unref_picture(H264Context *h, H264Picture *pic); void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
@ -1156,7 +1158,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
int ff_h264_context_init(H264Context *h); int ff_h264_context_init(H264Context *h);
int ff_h264_set_parameter_from_sps(H264Context *h); int ff_h264_set_parameter_from_sps(H264Context *h);
void ff_h264_draw_horiz_band(H264Context *h, int y, int height); void ff_h264_draw_horiz_band(H264Context *h, H264SliceContext *sl, int y, int height);
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc); int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc);
int ff_pred_weight_table(H264Context *h, H264SliceContext *sl); int ff_pred_weight_table(H264Context *h, H264SliceContext *sl);
int ff_set_ref_count(H264Context *h, H264SliceContext *sl); int ff_set_ref_count(H264Context *h, H264SliceContext *sl);

View File

@ -2051,8 +2051,8 @@ decode_intra_mb:
return 0; return 0;
} }
local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h); local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(h);
local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h); local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(h);
fill_decode_caches(h, sl, mb_type); fill_decode_caches(h, sl, mb_type);
@ -2118,7 +2118,7 @@ decode_intra_mb:
} }
} }
for( list = 0; list < h->list_count; list++ ) { for( list = 0; list < sl->list_count; list++ ) {
for( i = 0; i < 4; i++ ) { for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(sl->sub_mb_type[i])) continue; if(IS_DIRECT(sl->sub_mb_type[i])) continue;
if(IS_DIR(sl->sub_mb_type[i], 0, list)){ if(IS_DIR(sl->sub_mb_type[i], 0, list)){
@ -2141,7 +2141,7 @@ decode_intra_mb:
if(dct8x8_allowed) if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h, sl); dct8x8_allowed = get_dct8x8_allowed(h, sl);
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<4; i++){ for(i=0; i<4; i++){
sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1]; sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1];
if(IS_DIRECT(sl->sub_mb_type[i])){ if(IS_DIRECT(sl->sub_mb_type[i])){
@ -2205,7 +2205,7 @@ decode_intra_mb:
} else { } else {
int list, i; int list, i;
if(IS_16X16(mb_type)){ if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
int ref; int ref;
if (local_ref_count[list] > 1) { if (local_ref_count[list] > 1) {
@ -2219,7 +2219,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
int mx,my,mpx,mpy; int mx,my,mpx,mpy;
pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my);
@ -2232,7 +2232,7 @@ decode_intra_mb:
} }
} }
else if(IS_16X8(mb_type)){ else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
int ref; int ref;
@ -2249,7 +2249,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
int mx,my,mpx,mpy; int mx,my,mpx,mpy;
@ -2267,7 +2267,7 @@ decode_intra_mb:
} }
}else{ }else{
av_assert2(IS_8X16(mb_type)); av_assert2(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ //FIXME optimize if(IS_DIR(mb_type, i, list)){ //FIXME optimize
int ref; int ref;
@ -2284,7 +2284,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
int mx,my,mpx,mpy; int mx,my,mpx,mpy;

View File

@ -794,8 +794,8 @@ decode_intra_mb:
return 0; return 0;
} }
local_ref_count[0] = h->ref_count[0] << MB_MBAFF(h); local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(h);
local_ref_count[1] = h->ref_count[1] << MB_MBAFF(h); local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(h);
fill_decode_neighbors(h, sl, mb_type); fill_decode_neighbors(h, sl, mb_type);
fill_decode_caches(h, sl, mb_type); fill_decode_caches(h, sl, mb_type);
@ -875,7 +875,7 @@ decode_intra_mb:
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
int ref_count = IS_REF0(mb_type) ? 1 : local_ref_count[list]; int ref_count = IS_REF0(mb_type) ? 1 : local_ref_count[list];
for(i=0; i<4; i++){ for(i=0; i<4; i++){
if(IS_DIRECT(sl->sub_mb_type[i])) continue; if(IS_DIRECT(sl->sub_mb_type[i])) continue;
@ -903,7 +903,7 @@ decode_intra_mb:
if(dct8x8_allowed) if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h, sl); dct8x8_allowed = get_dct8x8_allowed(h, sl);
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<4; i++){ for(i=0; i<4; i++){
if(IS_DIRECT(sl->sub_mb_type[i])) { if(IS_DIRECT(sl->sub_mb_type[i])) {
sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ]; sl->ref_cache[list][ scan8[4*i] ] = sl->ref_cache[list][ scan8[4*i]+1 ];
@ -953,7 +953,7 @@ decode_intra_mb:
int list, mx, my, i; int list, mx, my, i;
//FIXME we should set ref_idx_l? to 0 if we use that later ... //FIXME we should set ref_idx_l? to 0 if we use that later ...
if(IS_16X16(mb_type)){ if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
if(local_ref_count[list]==1){ if(local_ref_count[list]==1){
@ -970,7 +970,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
if(IS_DIR(mb_type, 0, list)){ if(IS_DIR(mb_type, 0, list)){
pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&h->gb);
@ -982,7 +982,7 @@ decode_intra_mb:
} }
} }
else if(IS_16X8(mb_type)){ else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
@ -1002,7 +1002,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
@ -1019,7 +1019,7 @@ decode_intra_mb:
} }
}else{ }else{
av_assert2(IS_8X16(mb_type)); av_assert2(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ //FIXME optimize if(IS_DIR(mb_type, i, list)){ //FIXME optimize
@ -1039,7 +1039,7 @@ decode_intra_mb:
fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
} }
} }
for(list=0; list<h->list_count; list++){ for (list = 0; list < sl->list_count; list++) {
for(i=0; i<2; i++){ for(i=0; i<2; i++){
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){

View File

@ -34,11 +34,12 @@
#include <assert.h> #include <assert.h>
static int get_scale_factor(H264Context *const h, int poc, int poc1, int i) static int get_scale_factor(H264Context *const h, H264SliceContext *sl,
int poc, int poc1, int i)
{ {
int poc0 = h->ref_list[0][i].poc; int poc0 = sl->ref_list[0][i].poc;
int td = av_clip_int8(poc1 - poc0); int td = av_clip_int8(poc1 - poc0);
if (td == 0 || h->ref_list[0][i].long_ref) { if (td == 0 || sl->ref_list[0][i].long_ref) {
return 256; return 256;
} else { } else {
int tb = av_clip_int8(poc - poc0); int tb = av_clip_int8(poc - poc0);
@ -52,29 +53,30 @@ void ff_h264_direct_dist_scale_factor(H264Context *const h,
{ {
const int poc = FIELD_PICTURE(h) ? h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD] const int poc = FIELD_PICTURE(h) ? h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD]
: h->cur_pic_ptr->poc; : h->cur_pic_ptr->poc;
const int poc1 = h->ref_list[1][0].poc; const int poc1 = sl->ref_list[1][0].poc;
int i, field; int i, field;
if (FRAME_MBAFF(h)) if (FRAME_MBAFF(h))
for (field = 0; field < 2; field++) { for (field = 0; field < 2; field++) {
const int poc = h->cur_pic_ptr->field_poc[field]; const int poc = h->cur_pic_ptr->field_poc[field];
const int poc1 = h->ref_list[1][0].field_poc[field]; const int poc1 = sl->ref_list[1][0].field_poc[field];
for (i = 0; i < 2 * h->ref_count[0]; i++) for (i = 0; i < 2 * sl->ref_count[0]; i++)
sl->dist_scale_factor_field[field][i ^ field] = sl->dist_scale_factor_field[field][i ^ field] =
get_scale_factor(h, poc, poc1, i + 16); get_scale_factor(h, sl, poc, poc1, i + 16);
} }
for (i = 0; i < h->ref_count[0]; i++) for (i = 0; i < sl->ref_count[0]; i++)
sl->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i); sl->dist_scale_factor[i] = get_scale_factor(h, sl, poc, poc1, i);
} }
static void fill_colmap(H264Context *h, int map[2][16 + 32], int list, static void fill_colmap(H264Context *h, H264SliceContext *sl,
int map[2][16 + 32], int list,
int field, int colfield, int mbafi) int field, int colfield, int mbafi)
{ {
H264Picture *const ref1 = &h->ref_list[1][0]; H264Picture *const ref1 = &sl->ref_list[1][0];
int j, old_ref, rfield; int j, old_ref, rfield;
int start = mbafi ? 16 : 0; int start = mbafi ? 16 : 0;
int end = mbafi ? 16 + 2 * h->ref_count[0] : h->ref_count[0]; int end = mbafi ? 16 + 2 * sl->ref_count[0] : sl->ref_count[0];
int interl = mbafi || h->picture_structure != PICT_FRAME; int interl = mbafi || h->picture_structure != PICT_FRAME;
/* bogus; fills in for missing frames */ /* bogus; fills in for missing frames */
@ -91,8 +93,8 @@ static void fill_colmap(H264Context *h, int map[2][16 + 32], int list,
poc = (poc & ~3) + rfield + 1; poc = (poc & ~3) + rfield + 1;
for (j = start; j < end; j++) { for (j = start; j < end; j++) {
if (4 * h->ref_list[0][j].frame_num + if (4 * sl->ref_list[0][j].frame_num +
(h->ref_list[0][j].reference & 3) == poc) { (sl->ref_list[0][j].reference & 3) == poc) {
int cur_ref = mbafi ? (j - 16) ^ field : j; int cur_ref = mbafi ? (j - 16) ^ field : j;
if (ref1->mbaff) if (ref1->mbaff)
map[list][2 * old_ref + (rfield ^ field) + 16] = cur_ref; map[list][2 * old_ref + (rfield ^ field) + 16] = cur_ref;
@ -107,17 +109,17 @@ static void fill_colmap(H264Context *h, int map[2][16 + 32], int list,
void ff_h264_direct_ref_list_init(H264Context *const h, H264SliceContext *sl) void ff_h264_direct_ref_list_init(H264Context *const h, H264SliceContext *sl)
{ {
H264Picture *const ref1 = &h->ref_list[1][0]; H264Picture *const ref1 = &sl->ref_list[1][0];
H264Picture *const cur = h->cur_pic_ptr; H264Picture *const cur = h->cur_pic_ptr;
int list, j, field; int list, j, field;
int sidx = (h->picture_structure & 1) ^ 1; int sidx = (h->picture_structure & 1) ^ 1;
int ref1sidx = (ref1->reference & 1) ^ 1; int ref1sidx = (ref1->reference & 1) ^ 1;
for (list = 0; list < 2; list++) { for (list = 0; list < 2; list++) {
cur->ref_count[sidx][list] = h->ref_count[list]; cur->ref_count[sidx][list] = sl->ref_count[list];
for (j = 0; j < h->ref_count[list]; j++) for (j = 0; j < sl->ref_count[list]; j++)
cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + cur->ref_poc[sidx][list][j] = 4 * sl->ref_list[list][j].frame_num +
(h->ref_list[list][j].reference & 3); (sl->ref_list[list][j].reference & 3);
} }
if (h->picture_structure == PICT_FRAME) { if (h->picture_structure == PICT_FRAME) {
@ -130,25 +132,25 @@ void ff_h264_direct_ref_list_init(H264Context *const h, H264SliceContext *sl)
sl->col_fieldoff = 0; sl->col_fieldoff = 0;
if (h->picture_structure == PICT_FRAME) { if (h->picture_structure == PICT_FRAME) {
int cur_poc = h->cur_pic_ptr->poc; int cur_poc = h->cur_pic_ptr->poc;
int *col_poc = h->ref_list[1]->field_poc; int *col_poc = sl->ref_list[1]->field_poc;
sl->col_parity = (FFABS(col_poc[0] - cur_poc) >= sl->col_parity = (FFABS(col_poc[0] - cur_poc) >=
FFABS(col_poc[1] - cur_poc)); FFABS(col_poc[1] - cur_poc));
ref1sidx = ref1sidx =
sidx = sl->col_parity; sidx = sl->col_parity;
// FL -> FL & differ parity // FL -> FL & differ parity
} else if (!(h->picture_structure & h->ref_list[1][0].reference) && } else if (!(h->picture_structure & sl->ref_list[1][0].reference) &&
!h->ref_list[1][0].mbaff) { !sl->ref_list[1][0].mbaff) {
sl->col_fieldoff = 2 * h->ref_list[1][0].reference - 3; sl->col_fieldoff = 2 * sl->ref_list[1][0].reference - 3;
} }
if (sl->slice_type_nos != AV_PICTURE_TYPE_B || sl->direct_spatial_mv_pred) if (sl->slice_type_nos != AV_PICTURE_TYPE_B || sl->direct_spatial_mv_pred)
return; return;
for (list = 0; list < 2; list++) { for (list = 0; list < 2; list++) {
fill_colmap(h, sl->map_col_to_list0, list, sidx, ref1sidx, 0); fill_colmap(h, sl, sl->map_col_to_list0, list, sidx, ref1sidx, 0);
if (FRAME_MBAFF(h)) if (FRAME_MBAFF(h))
for (field = 0; field < 2; field++) for (field = 0; field < 2; field++)
fill_colmap(h, sl->map_col_to_list0_field[field], list, field, fill_colmap(h, sl, sl->map_col_to_list0_field[field], list, field,
field, 1); field, 1);
} }
} }
@ -188,9 +190,9 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
int mv[2]; int mv[2];
int list; int list;
assert(h->ref_list[1][0].reference & 3); assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, &h->ref_list[1][0], await_reference_mb_row(h, &sl->ref_list[1][0],
h->mb_y + !!IS_INTERLACED(*mb_type)); h->mb_y + !!IS_INTERLACED(*mb_type));
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \ #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
@ -231,7 +233,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
else else
mv[list] = AV_RN32A(C); mv[list] = AV_RN32A(C);
} }
av_assert2(ref[list] < (h->ref_count[list] << !!FRAME_MBAFF(h))); av_assert2(ref[list] < (sl->ref_count[list] << !!FRAME_MBAFF(h)));
} else { } else {
int mask = ~(MB_TYPE_L0 << (2 * list)); int mask = ~(MB_TYPE_L0 << (2 * list));
mv[list] = 0; mv[list] = 0;
@ -259,7 +261,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
return; return;
} }
if (IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (IS_INTERLACED(sl->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (h->mb_y & ~1) + sl->col_parity; mb_y = (h->mb_y & ~1) + sl->col_parity;
mb_xy = h->mb_x + mb_xy = h->mb_x +
@ -274,8 +276,8 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = h->mb_y & ~1; mb_y = h->mb_y & ~1;
mb_xy = (h->mb_y & ~1) * h->mb_stride + h->mb_x; mb_xy = (h->mb_y & ~1) * h->mb_stride + h->mb_x;
mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[0] = sl->ref_list[1][0].mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + h->mb_stride]; mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride; b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6; b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) != if (IS_INTERLACED(mb_type_col[0]) !=
@ -295,7 +297,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
} else { // AFR/FR -> AFR/FR } else { // AFR/FR -> AFR/FR
single_col: single_col:
mb_type_col[0] = mb_type_col[0] =
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy];
sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */ sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */
if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) { if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) {
@ -315,12 +317,12 @@ single_col:
} }
} }
await_reference_mb_row(h, &h->ref_list[1][0], mb_y); await_reference_mb_row(h, &sl->ref_list[1][0], mb_y);
l1mv0 = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]]; l1mv0 = (void*)&sl->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]]; l1mv1 = (void*)&sl->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &h->ref_list[1][0].ref_index[0][4 * mb_xy]; l1ref0 = &sl->ref_list[1][0].ref_index[0][4 * mb_xy];
l1ref1 = &h->ref_list[1][0].ref_index[1][4 * mb_xy]; l1ref1 = &sl->ref_list[1][0].ref_index[1][4 * mb_xy];
if (!b8_stride) { if (!b8_stride) {
if (h->mb_y & 1) { if (h->mb_y & 1) {
l1ref0 += 2; l1ref0 += 2;
@ -347,7 +349,7 @@ single_col:
(uint8_t)ref[0], 1); (uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8,
(uint8_t)ref[1], 1); (uint8_t)ref[1], 1);
if (!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref && if (!IS_INTRA(mb_type_col[y8]) && !sl->ref_list[1][0].long_ref &&
((l1ref0[xy8] == 0 && ((l1ref0[xy8] == 0 &&
FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][0]) <= 1 &&
FFABS(l1mv0[xy4][1]) <= 1) || FFABS(l1mv0[xy4][1]) <= 1) ||
@ -378,7 +380,7 @@ single_col:
fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
if (!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].long_ref &&
((l1ref0[0] == 0 && ((l1ref0[0] == 0 &&
FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][0]) <= 1 &&
FFABS(l1mv0[0][1]) <= 1) || FFABS(l1mv0[0][1]) <= 1) ||
@ -416,7 +418,7 @@ single_col:
assert(b8_stride == 2); assert(b8_stride == 2);
/* col_zero_flag */ /* col_zero_flag */
if (!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && if (!IS_INTRA(mb_type_col[0]) && !sl->ref_list[1][0].long_ref &&
(l1ref0[i8] == 0 || (l1ref0[i8] == 0 ||
(l1ref0[i8] < 0 && (l1ref0[i8] < 0 &&
l1ref1[i8] == 0 && l1ref1[i8] == 0 &&
@ -472,12 +474,12 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
unsigned int sub_mb_type; unsigned int sub_mb_type;
int i8, i4; int i8, i4;
assert(h->ref_list[1][0].reference & 3); assert(sl->ref_list[1][0].reference & 3);
await_reference_mb_row(h, &h->ref_list[1][0], await_reference_mb_row(h, &sl->ref_list[1][0],
h->mb_y + !!IS_INTERLACED(*mb_type)); h->mb_y + !!IS_INTERLACED(*mb_type));
if (IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (IS_INTERLACED(sl->ref_list[1][0].mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
mb_y = (h->mb_y & ~1) + sl->col_parity; mb_y = (h->mb_y & ~1) + sl->col_parity;
mb_xy = h->mb_x + mb_xy = h->mb_x +
@ -492,8 +494,8 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR
mb_y = h->mb_y & ~1; mb_y = h->mb_y & ~1;
mb_xy = h->mb_x + (h->mb_y & ~1) * h->mb_stride; mb_xy = h->mb_x + (h->mb_y & ~1) * h->mb_stride;
mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[0] = sl->ref_list[1][0].mb_type[mb_xy];
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + h->mb_stride]; mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy + h->mb_stride];
b8_stride = 2 + 4 * h->mb_stride; b8_stride = 2 + 4 * h->mb_stride;
b4_stride *= 6; b4_stride *= 6;
if (IS_INTERLACED(mb_type_col[0]) != if (IS_INTERLACED(mb_type_col[0]) !=
@ -516,7 +518,7 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
} else { // AFR/FR -> AFR/FR } else { // AFR/FR -> AFR/FR
single_col: single_col:
mb_type_col[0] = mb_type_col[0] =
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[1] = sl->ref_list[1][0].mb_type[mb_xy];
sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 |
MB_TYPE_DIRECT2; /* B_SUB_8x8 */ MB_TYPE_DIRECT2; /* B_SUB_8x8 */
@ -539,12 +541,12 @@ single_col:
} }
} }
await_reference_mb_row(h, &h->ref_list[1][0], mb_y); await_reference_mb_row(h, &sl->ref_list[1][0], mb_y);
l1mv0 = (void*)&h->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]]; l1mv0 = (void*)&sl->ref_list[1][0].motion_val[0][h->mb2b_xy[mb_xy]];
l1mv1 = (void*)&h->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]]; l1mv1 = (void*)&sl->ref_list[1][0].motion_val[1][h->mb2b_xy[mb_xy]];
l1ref0 = &h->ref_list[1][0].ref_index[0][4 * mb_xy]; l1ref0 = &sl->ref_list[1][0].ref_index[0][4 * mb_xy];
l1ref1 = &h->ref_list[1][0].ref_index[1][4 * mb_xy]; l1ref1 = &sl->ref_list[1][0].ref_index[1][4 * mb_xy];
if (!b8_stride) { if (!b8_stride) {
if (h->mb_y & 1) { if (h->mb_y & 1) {
l1ref0 += 2; l1ref0 += 2;
@ -565,7 +567,7 @@ single_col:
map_col_to_list0[1] = sl->map_col_to_list0_field[h->mb_y & 1][1]; map_col_to_list0[1] = sl->map_col_to_list0_field[h->mb_y & 1][1];
dist_scale_factor = sl->dist_scale_factor_field[h->mb_y & 1]; dist_scale_factor = sl->dist_scale_factor_field[h->mb_y & 1];
} }
ref_offset = (h->ref_list[1][0].mbaff << 4) & (mb_type_col[0] >> 3); ref_offset = (sl->ref_list[1][0].mbaff << 4) & (mb_type_col[0] >> 3);
if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) { if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) {
int y_shift = 2 * !IS_INTERLACED(*mb_type); int y_shift = 2 * !IS_INTERLACED(*mb_type);

View File

@ -370,7 +370,7 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1; int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1;
edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4; edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4;
h->h264dsp.h264_loop_filter_strength(bS, sl->non_zero_count_cache, sl->ref_cache, sl->mv_cache, h->h264dsp.h264_loop_filter_strength(bS, sl->non_zero_count_cache, sl->ref_cache, sl->mv_cache,
h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h)); sl->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE(h));
} }
if( IS_INTRA(left_type) ) if( IS_INTRA(left_type) )
AV_WN64A(bS[0][0], 0x0004000400040004ULL); AV_WN64A(bS[0][0], 0x0004000400040004ULL);
@ -445,7 +445,7 @@ static int check_mv(H264Context *h, H264SliceContext *sl, long b_idx, long bn_id
v = sl->mv_cache[0][b_idx][0] - sl->mv_cache[0][bn_idx][0] + 3 >= 7U | v = sl->mv_cache[0][b_idx][0] - sl->mv_cache[0][bn_idx][0] + 3 >= 7U |
FFABS(sl->mv_cache[0][b_idx][1] - sl->mv_cache[0][bn_idx][1]) >= mvy_limit; FFABS(sl->mv_cache[0][b_idx][1] - sl->mv_cache[0][bn_idx][1]) >= mvy_limit;
if(h->list_count==2){ if (sl->list_count == 2) {
if(!v) if(!v)
v = sl->ref_cache[1][b_idx] != sl->ref_cache[1][bn_idx] | v = sl->ref_cache[1][b_idx] != sl->ref_cache[1][bn_idx] |
sl->mv_cache[1][b_idx][0] - sl->mv_cache[1][bn_idx][0] + 3 >= 7U | sl->mv_cache[1][b_idx][0] - sl->mv_cache[1][bn_idx][0] + 3 >= 7U |

View File

@ -61,7 +61,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
if (list0) { if (list0) {
int ref_n = sl->ref_cache[0][scan8[n]]; int ref_n = sl->ref_cache[0][scan8[n]];
H264Picture *ref = &h->ref_list[0][ref_n]; H264Picture *ref = &sl->ref_list[0][ref_n];
// Error resilience puts the current picture in the ref list. // Error resilience puts the current picture in the ref list.
// Don't try to wait on these as it will cause a deadlock. // Don't try to wait on these as it will cause a deadlock.
@ -77,7 +77,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
if (list1) { if (list1) {
int ref_n = sl->ref_cache[1][scan8[n]]; int ref_n = sl->ref_cache[1][scan8[n]];
H264Picture *ref = &h->ref_list[1][ref_n]; H264Picture *ref = &sl->ref_list[1][ref_n];
if (ref->tf.progress->data != h->cur_pic.tf.progress->data || if (ref->tf.progress->data != h->cur_pic.tf.progress->data ||
(ref->reference & 3) != h->picture_structure) { (ref->reference & 3) != h->picture_structure) {
@ -164,11 +164,11 @@ static void await_references(H264Context *h, H264SliceContext *sl)
} }
} }
for (list = h->list_count - 1; list >= 0; list--) for (list = sl->list_count - 1; list >= 0; list--)
for (ref = 0; ref < 48 && nrefs[list]; ref++) { for (ref = 0; ref < 48 && nrefs[list]; ref++) {
int row = refs[list][ref]; int row = refs[list][ref];
if (row >= 0) { if (row >= 0) {
H264Picture *ref_pic = &h->ref_list[list][ref]; H264Picture *ref_pic = &sl->ref_list[list][ref];
int ref_field = ref_pic->reference - 1; int ref_field = ref_pic->reference - 1;
int ref_field_picture = ref_pic->field_picture; int ref_field_picture = ref_pic->field_picture;
int pic_height = 16 * h->mb_height >> ref_field_picture; int pic_height = 16 * h->mb_height >> ref_field_picture;
@ -349,7 +349,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl,
y_offset += 8 * (h->mb_y >> MB_FIELD(h)); y_offset += 8 * (h->mb_y >> MB_FIELD(h));
if (list0) { if (list0) {
H264Picture *ref = &h->ref_list[0][sl->ref_cache[0][scan8[n]]]; H264Picture *ref = &sl->ref_list[0][sl->ref_cache[0][scan8[n]]];
mc_dir_part(h, sl, ref, n, square, height, delta, 0, mc_dir_part(h, sl, ref, n, square, height, delta, 0,
dest_y, dest_cb, dest_cr, x_offset, y_offset, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_op, chroma_op, pixel_shift, chroma_idc); qpix_op, chroma_op, pixel_shift, chroma_idc);
@ -359,7 +359,7 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl,
} }
if (list1) { if (list1) {
H264Picture *ref = &h->ref_list[1][sl->ref_cache[1][scan8[n]]]; H264Picture *ref = &sl->ref_list[1][sl->ref_cache[1][scan8[n]]];
mc_dir_part(h, sl, ref, n, square, height, delta, 1, mc_dir_part(h, sl, ref, n, square, height, delta, 1,
dest_y, dest_cb, dest_cr, x_offset, y_offset, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_op, chroma_op, pixel_shift, chroma_idc); qpix_op, chroma_op, pixel_shift, chroma_idc);
@ -411,11 +411,11 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
int refn0 = sl->ref_cache[0][scan8[n]]; int refn0 = sl->ref_cache[0][scan8[n]];
int refn1 = sl->ref_cache[1][scan8[n]]; int refn1 = sl->ref_cache[1][scan8[n]];
mc_dir_part(h, sl, &h->ref_list[0][refn0], n, square, height, delta, 0, mc_dir_part(h, sl, &sl->ref_list[0][refn0], n, square, height, delta, 0,
dest_y, dest_cb, dest_cr, dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put, x_offset, y_offset, qpix_put, chroma_put,
pixel_shift, chroma_idc); pixel_shift, chroma_idc);
mc_dir_part(h, sl, &h->ref_list[1][refn1], n, square, height, delta, 1, mc_dir_part(h, sl, &sl->ref_list[1][refn1], n, square, height, delta, 1,
tmp_y, tmp_cb, tmp_cr, tmp_y, tmp_cb, tmp_cr,
x_offset, y_offset, qpix_put, chroma_put, x_offset, y_offset, qpix_put, chroma_put,
pixel_shift, chroma_idc); pixel_shift, chroma_idc);
@ -456,7 +456,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
} else { } else {
int list = list1 ? 1 : 0; int list = list1 ? 1 : 0;
int refn = sl->ref_cache[list][scan8[n]]; int refn = sl->ref_cache[list][scan8[n]];
H264Picture *ref = &h->ref_list[list][refn]; H264Picture *ref = &sl->ref_list[list][refn];
mc_dir_part(h, sl, ref, n, square, height, delta, list, mc_dir_part(h, sl, ref, n, square, height, delta, list,
dest_y, dest_cb, dest_cr, x_offset, y_offset, dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_put, chroma_put, pixel_shift, chroma_idc); qpix_put, chroma_put, pixel_shift, chroma_idc);
@ -490,7 +490,7 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s
if (refn >= 0) { if (refn >= 0) {
const int mx = (sl->mv_cache[list][scan8[0]][0] >> 2) + 16 * h->mb_x + 8; const int mx = (sl->mv_cache[list][scan8[0]][0] >> 2) + 16 * h->mb_x + 8;
const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * h->mb_y; const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * h->mb_y;
uint8_t **src = h->ref_list[list][refn].f.data; uint8_t **src = sl->ref_list[list][refn].f.data;
int off = mx * (1<< pixel_shift) + int off = mx * (1<< pixel_shift) +
(my + (h->mb_x & 3) * 4) * sl->mb_linesize + (my + (h->mb_x & 3) * 4) * sl->mb_linesize +
(64 << pixel_shift); (64 << pixel_shift);

View File

@ -64,7 +64,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4); h->vdsp.prefetch(dest_y + (h->mb_x & 3) * 4 * h->linesize + (64 << PIXEL_SHIFT), h->linesize, 4);
h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2); h->vdsp.prefetch(dest_cb + (h->mb_x & 7) * h->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2);
h->list_counts[mb_xy] = h->list_count; h->list_counts[mb_xy] = sl->list_count;
if (!SIMPLE && MB_FIELD(h)) { if (!SIMPLE && MB_FIELD(h)) {
linesize = sl->mb_linesize = h->linesize * 2; linesize = sl->mb_linesize = h->linesize * 2;
@ -77,7 +77,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
} }
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
int list; int list;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (!USES_LIST(mb_type, list)) if (!USES_LIST(mb_type, list))
continue; continue;
if (IS_16X16(mb_type)) { if (IS_16X16(mb_type)) {
@ -289,7 +289,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
h->linesize, 4); h->linesize, 4);
} }
h->list_counts[mb_xy] = h->list_count; h->list_counts[mb_xy] = sl->list_count;
if (!SIMPLE && MB_FIELD(h)) { if (!SIMPLE && MB_FIELD(h)) {
linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize * 2; linesize = sl->mb_linesize = sl->mb_uvlinesize = h->linesize * 2;
@ -299,7 +299,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
dest[p] -= h->linesize * 15; dest[p] -= h->linesize * 15;
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
int list; int list;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (!USES_LIST(mb_type, list)) if (!USES_LIST(mb_type, list))
continue; continue;
if (IS_16X16(mb_type)) { if (IS_16X16(mb_type)) {

View File

@ -606,7 +606,7 @@ static void fill_decode_caches(H264Context *h, H264SliceContext *sl, int mb_type
if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) { if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) {
int list; int list;
int b_stride = h->b_stride; int b_stride = h->b_stride;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
int8_t *ref_cache = &sl->ref_cache[list][scan8[0]]; int8_t *ref_cache = &sl->ref_cache[list][scan8[0]];
int8_t *ref = h->cur_pic.ref_index[list]; int8_t *ref = h->cur_pic.ref_index[list];
int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]]; int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]];

View File

@ -145,7 +145,7 @@ static int scan_mmco_reset(AVCodecParserContext *s)
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
int list; int list;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (get_bits1(&h->gb)) { if (get_bits1(&h->gb)) {
int index; int index;
for (index = 0; ; index++) { for (index = 0; ; index++) {
@ -161,7 +161,7 @@ static int scan_mmco_reset(AVCodecParserContext *s)
} else } else
break; break;
if (index >= h->ref_count[list]) { if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"reference count %d overflow\n", index); "reference count %d overflow\n", index);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View File

@ -152,7 +152,7 @@ void ff_h264_set_erpic(ERPicture *dst, H264Picture *src)
#endif /* CONFIG_ERROR_RESILIENCE */ #endif /* CONFIG_ERROR_RESILIENCE */
} }
int ff_h264_field_end(H264Context *h, int in_setup) int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
{ {
AVCodecContext *const avctx = h->avctx; AVCodecContext *const avctx = h->avctx;
int err = 0; int err = 0;
@ -197,26 +197,26 @@ int ff_h264_field_end(H264Context *h, int in_setup)
* causes problems for the first MB line, too. * causes problems for the first MB line, too.
*/ */
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) { if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
int use_last_pic = h->last_pic_for_ec.f.buf[0] && !h->ref_count[0]; int use_last_pic = h->last_pic_for_ec.f.buf[0] && !sl->ref_count[0];
ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr); ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr);
if (use_last_pic) { if (use_last_pic) {
ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec); ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec);
COPY_PICTURE(&h->ref_list[0][0], &h->last_pic_for_ec); COPY_PICTURE(&sl->ref_list[0][0], &h->last_pic_for_ec);
} else if (h->ref_count[0]) { } else if (sl->ref_count[0]) {
ff_h264_set_erpic(&h->er.last_pic, &h->ref_list[0][0]); ff_h264_set_erpic(&h->er.last_pic, &sl->ref_list[0][0]);
} else } else
ff_h264_set_erpic(&h->er.last_pic, NULL); ff_h264_set_erpic(&h->er.last_pic, NULL);
if (h->ref_count[1]) if (sl->ref_count[1])
ff_h264_set_erpic(&h->er.next_pic, &h->ref_list[1][0]); ff_h264_set_erpic(&h->er.next_pic, &sl->ref_list[1][0]);
h->er.ref_count = h->ref_count[0]; h->er.ref_count = sl->ref_count[0];
ff_er_frame_end(&h->er); ff_er_frame_end(&h->er);
if (use_last_pic) if (use_last_pic)
memset(&h->ref_list[0][0], 0, sizeof(h->last_pic_for_ec)); memset(&sl->ref_list[0][0], 0, sizeof(h->last_pic_for_ec));
} }
#endif /* CONFIG_ERROR_RESILIENCE */ #endif /* CONFIG_ERROR_RESILIENCE */

View File

@ -138,8 +138,8 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
h->long_ref, 16, 1, h->picture_structure); h->long_ref, 16, 1, h->picture_structure);
av_assert0(len <= 32); av_assert0(len <= 32);
if (len < h->ref_count[list]) if (len < sl->ref_count[list])
memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (h->ref_count[list] - len)); memset(&h->default_ref_list[list][len], 0, sizeof(H264Picture) * (sl->ref_count[list] - len));
lens[list] = len; lens[list] = len;
} }
@ -162,18 +162,18 @@ int ff_h264_fill_default_ref_list(H264Context *h, H264SliceContext *sl)
h-> long_ref, 16, 1, h->picture_structure); h-> long_ref, 16, 1, h->picture_structure);
av_assert0(len <= 32); av_assert0(len <= 32);
if (len < h->ref_count[0]) if (len < sl->ref_count[0])
memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (h->ref_count[0] - len)); memset(&h->default_ref_list[0][len], 0, sizeof(H264Picture) * (sl->ref_count[0] - len));
} }
#ifdef TRACE #ifdef TRACE
for (i = 0; i < h->ref_count[0]; i++) { for (i = 0; i < sl->ref_count[0]; i++) {
tprintf(h->avctx, "List0: %s fn:%d 0x%p\n", tprintf(h->avctx, "List0: %s fn:%d 0x%p\n",
(h->default_ref_list[0][i].long_ref ? "LT" : "ST"), (h->default_ref_list[0][i].long_ref ? "LT" : "ST"),
h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].pic_id,
h->default_ref_list[0][i].f.data[0]); h->default_ref_list[0][i].f.data[0]);
} }
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
for (i = 0; i < h->ref_count[1]; i++) { for (i = 0; i < sl->ref_count[1]; i++) {
tprintf(h->avctx, "List1: %s fn:%d 0x%p\n", tprintf(h->avctx, "List1: %s fn:%d 0x%p\n",
(h->default_ref_list[1][i].long_ref ? "LT" : "ST"), (h->default_ref_list[1][i].long_ref ? "LT" : "ST"),
h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].pic_id,
@ -210,16 +210,16 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure)
return pic_num; return pic_num;
} }
int ff_h264_decode_ref_pic_list_reordering(H264Context *h) int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
{ {
int list, index, pic_structure, i; int list, index, pic_structure, i;
print_short_term(h); print_short_term(h);
print_long_term(h); print_long_term(h);
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
for (i = 0; i < h->ref_count[list]; i++) for (i = 0; i < sl->ref_count[list]; i++)
COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]); COPY_PICTURE(&sl->ref_list[list][i], &h->default_ref_list[list][i]);
if (get_bits1(&h->gb)) { // ref_pic_list_modification_flag_l[01] if (get_bits1(&h->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num; int pred = h->curr_pic_num;
@ -233,7 +233,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
if (modification_of_pic_nums_idc == 3) if (modification_of_pic_nums_idc == 3)
break; break;
if (index >= h->ref_count[list]) { if (index >= sl->ref_count[list]) {
av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n"); av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
return -1; return -1;
} }
@ -302,39 +302,39 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
if (i < 0) { if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"reference picture missing during reorder\n"); "reference picture missing during reorder\n");
memset(&h->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME memset(&sl->ref_list[list][index], 0, sizeof(H264Picture)); // FIXME
} else { } else {
for (i = index; i + 1 < h->ref_count[list]; i++) { for (i = index; i + 1 < sl->ref_count[list]; i++) {
if (ref->long_ref == h->ref_list[list][i].long_ref && if (ref->long_ref == sl->ref_list[list][i].long_ref &&
ref->pic_id == h->ref_list[list][i].pic_id) ref->pic_id == sl->ref_list[list][i].pic_id)
break; break;
} }
for (; i > index; i--) { for (; i > index; i--) {
COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]); COPY_PICTURE(&sl->ref_list[list][i], &sl->ref_list[list][i - 1]);
} }
COPY_PICTURE(&h->ref_list[list][index], ref); COPY_PICTURE(&sl->ref_list[list][index], ref);
if (FIELD_PICTURE(h)) { if (FIELD_PICTURE(h)) {
pic_as_field(&h->ref_list[list][index], pic_structure); pic_as_field(&sl->ref_list[list][index], pic_structure);
} }
} }
} }
} }
} }
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
for (index = 0; index < h->ref_count[list]; index++) { for (index = 0; index < sl->ref_count[list]; index++) {
if ( !h->ref_list[list][index].f.buf[0] if ( !sl->ref_list[list][index].f.buf[0]
|| (!FIELD_PICTURE(h) && (h->ref_list[list][index].reference&3) != 3)) { || (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) {
int i; int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc); av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++) for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN; h->last_pocs[i] = INT_MIN;
if (h->default_ref_list[list][0].f.buf[0] if (h->default_ref_list[list][0].f.buf[0]
&& !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3)) && !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3))
COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]); COPY_PICTURE(&sl->ref_list[list][index], &h->default_ref_list[list][0]);
else else
return -1; return -1;
} }
av_assert0(av_buffer_get_ref_count(h->ref_list[list][index].f.buf[0]) > 0); av_assert0(av_buffer_get_ref_count(sl->ref_list[list][index].f.buf[0]) > 0);
} }
} }
@ -344,10 +344,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl) void ff_h264_fill_mbaff_ref_list(H264Context *h, H264SliceContext *sl)
{ {
int list, i, j; int list, i, j;
for (list = 0; list < h->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
for (i = 0; i < h->ref_count[list]; i++) { for (i = 0; i < sl->ref_count[list]; i++) {
H264Picture *frame = &h->ref_list[list][i]; H264Picture *frame = &sl->ref_list[list][i];
H264Picture *field = &h->ref_list[list][16 + 2 * i]; H264Picture *field = &sl->ref_list[list][16 + 2 * i];
COPY_PICTURE(field, frame); COPY_PICTURE(field, frame);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
field[0].f.linesize[j] <<= 1; field[0].f.linesize[j] <<= 1;
@ -498,7 +498,8 @@ void ff_h264_remove_all_refs(H264Context *h)
h->short_ref_count = 0; h->short_ref_count = 0;
memset(h->default_ref_list, 0, sizeof(h->default_ref_list)); memset(h->default_ref_list, 0, sizeof(h->default_ref_list));
memset(h->ref_list, 0, sizeof(h->ref_list)); for (i = 0; i < h->nb_slice_ctx; i++)
memset(h->slice_ctx[i].ref_list, 0, sizeof(h->slice_ctx[i].ref_list));
} }
/** /**

View File

@ -897,20 +897,20 @@ static void implicit_weight_table(H264Context *h, H264SliceContext *sl, int fiel
} else { } else {
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1]; cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1];
} }
if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF(h) && if (sl->ref_count[0] == 1 && sl->ref_count[1] == 1 && !FRAME_MBAFF(h) &&
h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2 * cur_poc) { sl->ref_list[0][0].poc + sl->ref_list[1][0].poc == 2 * cur_poc) {
sl->use_weight = 0; sl->use_weight = 0;
sl->use_weight_chroma = 0; sl->use_weight_chroma = 0;
return; return;
} }
ref_start = 0; ref_start = 0;
ref_count0 = h->ref_count[0]; ref_count0 = sl->ref_count[0];
ref_count1 = h->ref_count[1]; ref_count1 = sl->ref_count[1];
} else { } else {
cur_poc = h->cur_pic_ptr->field_poc[field]; cur_poc = h->cur_pic_ptr->field_poc[field];
ref_start = 16; ref_start = 16;
ref_count0 = 16 + 2 * h->ref_count[0]; ref_count0 = 16 + 2 * sl->ref_count[0];
ref_count1 = 16 + 2 * h->ref_count[1]; ref_count1 = 16 + 2 * sl->ref_count[1];
} }
sl->use_weight = 2; sl->use_weight = 2;
@ -919,11 +919,11 @@ static void implicit_weight_table(H264Context *h, H264SliceContext *sl, int fiel
sl->chroma_log2_weight_denom = 5; sl->chroma_log2_weight_denom = 5;
for (ref0 = ref_start; ref0 < ref_count0; ref0++) { for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
int poc0 = h->ref_list[0][ref0].poc; int poc0 = sl->ref_list[0][ref0].poc;
for (ref1 = ref_start; ref1 < ref_count1; ref1++) { for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
int w = 32; int w = 32;
if (!h->ref_list[0][ref0].long_ref && !h->ref_list[1][ref1].long_ref) { if (!sl->ref_list[0][ref0].long_ref && !sl->ref_list[1][ref1].long_ref) {
int poc1 = h->ref_list[1][ref1].poc; int poc1 = sl->ref_list[1][ref1].poc;
int td = av_clip_int8(poc1 - poc0); int td = av_clip_int8(poc1 - poc0);
if (td) { if (td) {
int tb = av_clip_int8(cur_poc - poc0); int tb = av_clip_int8(cur_poc - poc0);
@ -1304,7 +1304,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
if (first_mb_in_slice == 0) { // FIXME better field boundary detection if (first_mb_in_slice == 0) { // FIXME better field boundary detection
if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
ff_h264_field_end(h, 1); ff_h264_field_end(h, sl, 1);
} }
h0->current_slice = 0; h0->current_slice = 0;
@ -1801,15 +1801,15 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
if (slice_type != AV_PICTURE_TYPE_I && if (slice_type != AV_PICTURE_TYPE_I &&
(h0->current_slice == 0 || (h0->current_slice == 0 ||
slice_type != h0->last_slice_type || slice_type != h0->last_slice_type ||
memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) { memcmp(h0->last_ref_count, sl->ref_count, sizeof(sl->ref_count)))) {
ff_h264_fill_default_ref_list(h, sl); ff_h264_fill_default_ref_list(h, sl);
} }
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
ret = ff_h264_decode_ref_pic_list_reordering(h); ret = ff_h264_decode_ref_pic_list_reordering(h, sl);
if (ret < 0) { if (ret < 0) {
h->ref_count[1] = h->ref_count[0] = 0; sl->ref_count[1] = sl->ref_count[0] = 0;
return ret; return ret;
} }
} }
@ -1950,7 +1950,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
6 * (h->sps.bit_depth_luma - 8); 6 * (h->sps.bit_depth_luma - 8);
h0->last_slice_type = slice_type; h0->last_slice_type = slice_type;
memcpy(h0->last_ref_count, h0->ref_count, sizeof(h0->last_ref_count)); memcpy(h0->last_ref_count, sl->ref_count, sizeof(h0->last_ref_count));
sl->slice_num = ++h0->current_slice; sl->slice_num = ++h0->current_slice;
if (sl->slice_num) if (sl->slice_num)
@ -1964,13 +1964,13 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
int id_list[16]; int id_list[16];
int *ref2frm = h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j]; int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
id_list[i] = 60; id_list[i] = 60;
if (j < h->list_count && i < h->ref_count[j] && if (j < sl->list_count && i < sl->ref_count[j] &&
h->ref_list[j][i].f.buf[0]) { sl->ref_list[j][i].f.buf[0]) {
int k; int k;
AVBuffer *buf = h->ref_list[j][i].f.buf[0]->buffer; AVBuffer *buf = sl->ref_list[j][i].f.buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++) for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f.buf[0]->buffer == buf) { if (h->short_ref[k]->f.buf[0]->buffer == buf) {
id_list[i] = k; id_list[i] = k;
@ -1987,12 +1987,12 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
ref2frm[0] = ref2frm[0] =
ref2frm[1] = -1; ref2frm[1] = -1;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (h->ref_list[j][i].reference & 3); ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3);
ref2frm[18 + 0] = ref2frm[18 + 0] =
ref2frm[18 + 1] = -1; ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++) for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] + ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(h->ref_list[j][i].reference & 3); (sl->ref_list[j][i].reference & 3);
} }
h0->au_pps_id = pps_id; h0->au_pps_id = pps_id;
@ -2012,7 +2012,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
pps_id, h->frame_num, pps_id, h->frame_num,
h->cur_pic_ptr->field_poc[0], h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1], h->cur_pic_ptr->field_poc[1],
h->ref_count[0], h->ref_count[1], sl->ref_count[0], sl->ref_count[1],
sl->qscale, sl->qscale,
h->deblocking_filter, h->deblocking_filter,
h->slice_alpha_c0_offset, h->slice_beta_offset, h->slice_alpha_c0_offset, h->slice_beta_offset,
@ -2057,7 +2057,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h,
if (USES_LIST(top_type, list)) { if (USES_LIST(top_type, list)) {
const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
const int b8_xy = 4 * top_xy + 2; const int b8_xy = 4 * top_xy + 2;
int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); int (*ref2frm)[64] = (void*)(sl->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]); AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]);
ref_cache[0 - 1 * 8] = ref_cache[0 - 1 * 8] =
ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]]; ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]];
@ -2072,7 +2072,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h,
if (USES_LIST(left_type[LTOP], list)) { if (USES_LIST(left_type[LTOP], list)) {
const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3;
const int b8_xy = 4 * left_xy[LTOP] + 1; const int b8_xy = 4 * left_xy[LTOP] + 1;
int (*ref2frm)[64] =(void*)( h->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); int (*ref2frm)[64] =(void*)( sl->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]); AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]);
AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]); AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]);
AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]); AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]);
@ -2105,7 +2105,7 @@ static av_always_inline void fill_filter_caches_inter(H264Context *h,
{ {
int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy]; int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy];
int (*ref2frm)[64] = (void*)(h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2)); int (*ref2frm)[64] = (void*)(sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(h) ? 20 : 2));
uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101; uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101;
uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101; uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101;
AV_WN32A(&ref_cache[0 * 8], ref01); AV_WN32A(&ref_cache[0 * 8], ref01);
@ -2203,7 +2203,7 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type)
fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy, fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy,
top_type, left_type, mb_xy, 0); top_type, left_type, mb_xy, 0);
if (h->list_count == 2) if (sl->list_count == 2)
fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy, fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy,
top_type, left_type, mb_xy, 1); top_type, left_type, mb_xy, 1);
@ -2288,7 +2288,7 @@ static void loop_filter(H264Context *h, H264SliceContext *sl, int start_x, int e
mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride; mb_xy = h->mb_xy = mb_x + mb_y * h->mb_stride;
sl->slice_num = h->slice_table[mb_xy]; sl->slice_num = h->slice_table[mb_xy];
mb_type = h->cur_pic.mb_type[mb_xy]; mb_type = h->cur_pic.mb_type[mb_xy];
h->list_count = h->list_counts[mb_xy]; sl->list_count = h->list_counts[mb_xy];
if (FRAME_MBAFF(h)) if (FRAME_MBAFF(h))
h->mb_mbaff = h->mb_mbaff =
@ -2354,7 +2354,7 @@ static void predict_field_decoding_flag(H264Context *h, H264SliceContext *sl)
/** /**
* Draw edges and report progress for the last MB row. * Draw edges and report progress for the last MB row.
*/ */
static void decode_finish_row(H264Context *h) static void decode_finish_row(H264Context *h, H264SliceContext *sl)
{ {
int top = 16 * (h->mb_y >> FIELD_PICTURE(h)); int top = 16 * (h->mb_y >> FIELD_PICTURE(h));
int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h); int pic_height = 16 * h->mb_height >> FIELD_PICTURE(h);
@ -2376,7 +2376,7 @@ static void decode_finish_row(H264Context *h)
top = 0; top = 0;
} }
ff_h264_draw_horiz_band(h, top, height); ff_h264_draw_horiz_band(h, sl, top, height);
if (h->droppable || h->er.error_occurred) if (h->droppable || h->er.error_occurred)
return; return;
@ -2385,7 +2385,8 @@ static void decode_finish_row(H264Context *h)
h->picture_structure == PICT_BOTTOM_FIELD); h->picture_structure == PICT_BOTTOM_FIELD);
} }
static void er_add_slice(H264Context *h, int startx, int starty, static void er_add_slice(H264Context *h, H264SliceContext *sl,
int startx, int starty,
int endx, int endy, int status) int endx, int endy, int status)
{ {
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
@ -2453,7 +2454,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if ((h->workaround_bugs & FF_BUG_TRUNCATED) && if ((h->workaround_bugs & FF_BUG_TRUNCATED) &&
h->cabac.bytestream > h->cabac.bytestream_end + 2) { h->cabac.bytestream > h->cabac.bytestream_end + 2) {
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1,
h->mb_y, ER_MB_END); h->mb_y, ER_MB_END);
if (h->mb_x >= lf_x_start) if (h->mb_x >= lf_x_start)
loop_filter(h, sl, lf_x_start, h->mb_x + 1); loop_filter(h, sl, lf_x_start, h->mb_x + 1);
@ -2466,7 +2467,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
"error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n", "error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n",
h->mb_x, h->mb_y, h->mb_x, h->mb_y,
h->cabac.bytestream_end - h->cabac.bytestream); h->cabac.bytestream_end - h->cabac.bytestream);
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x,
h->mb_y, ER_MB_ERROR); h->mb_y, ER_MB_ERROR);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
@ -2474,7 +2475,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (++h->mb_x >= h->mb_width) { if (++h->mb_x >= h->mb_width) {
loop_filter(h, sl, lf_x_start, h->mb_x); loop_filter(h, sl, lf_x_start, h->mb_x);
h->mb_x = lf_x_start = 0; h->mb_x = lf_x_start = 0;
decode_finish_row(h); decode_finish_row(h, sl);
++h->mb_y; ++h->mb_y;
if (FIELD_OR_MBAFF_PICTURE(h)) { if (FIELD_OR_MBAFF_PICTURE(h)) {
++h->mb_y; ++h->mb_y;
@ -2486,7 +2487,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (eos || h->mb_y >= h->mb_height) { if (eos || h->mb_y >= h->mb_height) {
tprintf(h->avctx, "slice end %d %d\n", tprintf(h->avctx, "slice end %d %d\n",
get_bits_count(&h->gb), h->gb.size_in_bits); get_bits_count(&h->gb), h->gb.size_in_bits);
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x - 1,
h->mb_y, ER_MB_END); h->mb_y, ER_MB_END);
if (h->mb_x > lf_x_start) if (h->mb_x > lf_x_start)
loop_filter(h, sl, lf_x_start, h->mb_x); loop_filter(h, sl, lf_x_start, h->mb_x);
@ -2513,7 +2514,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (ret < 0) { if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"error while decoding MB %d %d\n", h->mb_x, h->mb_y); "error while decoding MB %d %d\n", h->mb_x, h->mb_y);
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x,
h->mb_y, ER_MB_ERROR); h->mb_y, ER_MB_ERROR);
return ret; return ret;
} }
@ -2521,7 +2522,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (++h->mb_x >= h->mb_width) { if (++h->mb_x >= h->mb_width) {
loop_filter(h, sl, lf_x_start, h->mb_x); loop_filter(h, sl, lf_x_start, h->mb_x);
h->mb_x = lf_x_start = 0; h->mb_x = lf_x_start = 0;
decode_finish_row(h); decode_finish_row(h, sl);
++h->mb_y; ++h->mb_y;
if (FIELD_OR_MBAFF_PICTURE(h)) { if (FIELD_OR_MBAFF_PICTURE(h)) {
++h->mb_y; ++h->mb_y;
@ -2534,12 +2535,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if ( get_bits_left(&h->gb) == 0 if ( get_bits_left(&h->gb) == 0
|| get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y,
h->mb_x - 1, h->mb_y, ER_MB_END); h->mb_x - 1, h->mb_y, ER_MB_END);
return 0; return 0;
} else { } else {
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y,
h->mb_x, h->mb_y, ER_MB_END); h->mb_x, h->mb_y, ER_MB_END);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -2552,14 +2553,14 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
get_bits_count(&h->gb), h->gb.size_in_bits); get_bits_count(&h->gb), h->gb.size_in_bits);
if (get_bits_left(&h->gb) == 0) { if (get_bits_left(&h->gb) == 0) {
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y,
h->mb_x - 1, h->mb_y, ER_MB_END); h->mb_x - 1, h->mb_y, ER_MB_END);
if (h->mb_x > lf_x_start) if (h->mb_x > lf_x_start)
loop_filter(h, sl, lf_x_start, h->mb_x); loop_filter(h, sl, lf_x_start, h->mb_x);
return 0; return 0;
} else { } else {
er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x, er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x,
h->mb_y, ER_MB_ERROR); h->mb_y, ER_MB_ERROR);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;

View File

@ -198,7 +198,7 @@ static void fill_vaapi_plain_pred_weight_table(H264Context *h,
*luma_weight_flag = sl->luma_weight_flag[list]; *luma_weight_flag = sl->luma_weight_flag[list];
*chroma_weight_flag = sl->chroma_weight_flag[list]; *chroma_weight_flag = sl->chroma_weight_flag[list];
for (i = 0; i < h->ref_count[list]; i++) { for (i = 0; i < sl->ref_count[list]; i++) {
/* VA API also wants the inferred (default) values, not /* VA API also wants the inferred (default) values, not
only what is available in the bitstream (7.4.3.2). */ only what is available in the bitstream (7.4.3.2). */
if (sl->luma_weight_flag[list]) { if (sl->luma_weight_flag[list]) {
@ -293,6 +293,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
{ {
struct vaapi_context * const vactx = avctx->hwaccel_context; struct vaapi_context * const vactx = avctx->hwaccel_context;
H264Context * const h = avctx->priv_data; H264Context * const h = avctx->priv_data;
H264SliceContext *sl = &h->slice_ctx[0];
int ret; int ret;
av_dlog(avctx, "vaapi_h264_end_frame()\n"); av_dlog(avctx, "vaapi_h264_end_frame()\n");
@ -304,7 +305,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
if (ret < 0) if (ret < 0)
goto finish; goto finish;
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
finish: finish:
ff_vaapi_common_end_frame(avctx); ff_vaapi_common_end_frame(avctx);
@ -331,8 +332,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
slice_param->first_mb_in_slice = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * 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(sl); slice_param->slice_type = ff_h264_get_slice_type(sl);
slice_param->direct_spatial_mv_pred_flag = sl->slice_type == AV_PICTURE_TYPE_B ? sl->direct_spatial_mv_pred : 0; slice_param->direct_spatial_mv_pred_flag = sl->slice_type == AV_PICTURE_TYPE_B ? sl->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 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0;
slice_param->num_ref_idx_l1_active_minus1 = h->list_count > 1 ? h->ref_count[1] - 1 : 0; slice_param->num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc; slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp; slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter; slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
@ -341,8 +342,8 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
slice_param->luma_log2_weight_denom = sl->luma_log2_weight_denom; slice_param->luma_log2_weight_denom = sl->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = sl->chroma_log2_weight_denom; slice_param->chroma_log2_weight_denom = sl->chroma_log2_weight_denom;
fill_vaapi_RefPicList(slice_param->RefPicList0, h->ref_list[0], h->list_count > 0 ? h->ref_count[0] : 0); fill_vaapi_RefPicList(slice_param->RefPicList0, sl->ref_list[0], sl->list_count > 0 ? sl->ref_count[0] : 0);
fill_vaapi_RefPicList(slice_param->RefPicList1, h->ref_list[1], h->list_count > 1 ? h->ref_count[1] : 0); fill_vaapi_RefPicList(slice_param->RefPicList1, sl->ref_list[1], sl->list_count > 1 ? sl->ref_count[1] : 0);
fill_vaapi_plain_pred_weight_table(h, 0, fill_vaapi_plain_pred_weight_table(h, 0,
&slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0, &slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,

View File

@ -500,7 +500,7 @@ void ff_vdpau_h264_picture_complete(H264Context *h)
memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0])); memcpy(render->info.h264.scaling_lists_8x8[0], h->pps.scaling_matrix8[0], sizeof(render->info.h264.scaling_lists_8x8[0]));
memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0])); memcpy(render->info.h264.scaling_lists_8x8[1], h->pps.scaling_matrix8[3], sizeof(render->info.h264.scaling_lists_8x8[0]));
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, &h->slice_ctx[0], 0, h->avctx->height);
render->bitstream_buffers_used = 0; render->bitstream_buffers_used = 0;
} }
#endif /* CONFIG_H264_VDPAU_DECODER */ #endif /* CONFIG_H264_VDPAU_DECODER */

View File

@ -198,6 +198,7 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
static int vdpau_h264_end_frame(AVCodecContext *avctx) static int vdpau_h264_end_frame(AVCodecContext *avctx)
{ {
H264Context *h = avctx->priv_data; H264Context *h = avctx->priv_data;
H264SliceContext *sl = &h->slice_ctx[0];
H264Picture *pic = h->cur_pic_ptr; H264Picture *pic = h->cur_pic_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private; struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
int val; int val;
@ -206,7 +207,7 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
if (val < 0) if (val < 0)
return val; return val;
ff_h264_draw_horiz_band(h, 0, h->avctx->height); ff_h264_draw_horiz_band(h, sl, 0, h->avctx->height);
return 0; return 0;
} }