Commit 55215383 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'f42485db'

* commit 'f42485db':
  h264: use a separate GetBitContext for slice data

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_parser.c
	libavcodec/h264_slice.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 727b2023 f42485db
...@@ -1010,9 +1010,9 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) ...@@ -1010,9 +1010,9 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl)
sl->use_weight = 0; sl->use_weight = 0;
sl->use_weight_chroma = 0; sl->use_weight_chroma = 0;
sl->luma_log2_weight_denom = get_ue_golomb(&h->gb); sl->luma_log2_weight_denom = get_ue_golomb(&sl->gb);
if (h->sps.chroma_format_idc) if (h->sps.chroma_format_idc)
sl->chroma_log2_weight_denom = get_ue_golomb(&h->gb); sl->chroma_log2_weight_denom = get_ue_golomb(&sl->gb);
if (sl->luma_log2_weight_denom > 7U) { if (sl->luma_log2_weight_denom > 7U) {
av_log(h->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", sl->luma_log2_weight_denom); av_log(h->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", sl->luma_log2_weight_denom);
...@@ -1032,10 +1032,10 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) ...@@ -1032,10 +1032,10 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl)
for (i = 0; i < sl->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(&sl->gb);
if (luma_weight_flag) { if (luma_weight_flag) {
sl->luma_weight[i][list][0] = get_se_golomb(&h->gb); sl->luma_weight[i][list][0] = get_se_golomb(&sl->gb);
sl->luma_weight[i][list][1] = get_se_golomb(&h->gb); sl->luma_weight[i][list][1] = get_se_golomb(&sl->gb);
if (sl->luma_weight[i][list][0] != luma_def || if (sl->luma_weight[i][list][0] != luma_def ||
sl->luma_weight[i][list][1] != 0) { sl->luma_weight[i][list][1] != 0) {
sl->use_weight = 1; sl->use_weight = 1;
...@@ -1047,12 +1047,12 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) ...@@ -1047,12 +1047,12 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl)
} }
if (h->sps.chroma_format_idc) { if (h->sps.chroma_format_idc) {
chroma_weight_flag = get_bits1(&h->gb); chroma_weight_flag = get_bits1(&sl->gb);
if (chroma_weight_flag) { if (chroma_weight_flag) {
int j; int j;
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
sl->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb); sl->chroma_weight[i][list][j][0] = get_se_golomb(&sl->gb);
sl->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb); sl->chroma_weight[i][list][j][1] = get_se_golomb(&sl->gb);
if (sl->chroma_weight[i][list][j][0] != chroma_def || if (sl->chroma_weight[i][list][j][0] != chroma_def ||
sl->chroma_weight[i][list][j][1] != 0) { sl->chroma_weight[i][list][j][1] != 0) {
sl->use_weight_chroma = 1; sl->use_weight_chroma = 1;
...@@ -1307,13 +1307,13 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl) ...@@ -1307,13 +1307,13 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
max[0] = max[1] = h->picture_structure == PICT_FRAME ? 15 : 31; max[0] = max[1] = h->picture_structure == PICT_FRAME ? 15 : 31;
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) if (sl->slice_type_nos == AV_PICTURE_TYPE_B)
sl->direct_spatial_mv_pred = get_bits1(&h->gb); sl->direct_spatial_mv_pred = get_bits1(&sl->gb);
num_ref_idx_active_override_flag = get_bits1(&h->gb); num_ref_idx_active_override_flag = get_bits1(&sl->gb);
if (num_ref_idx_active_override_flag) { if (num_ref_idx_active_override_flag) {
ref_count[0] = get_ue_golomb(&h->gb) + 1; ref_count[0] = get_ue_golomb(&sl->gb) + 1;
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
ref_count[1] = get_ue_golomb(&h->gb) + 1; ref_count[1] = get_ue_golomb(&sl->gb) + 1;
} else } else
// full range is spec-ok in this case, even for frames // full range is spec-ok in this case, even for frames
ref_count[1] = 1; ref_count[1] = 1;
...@@ -1569,7 +1569,7 @@ again: ...@@ -1569,7 +1569,7 @@ again:
idr_cleared = 1; idr_cleared = 1;
h->has_recovery_point = 1; h->has_recovery_point = 1;
case NAL_SLICE: case NAL_SLICE:
init_get_bits(&hx->gb, ptr, bit_length); init_get_bits(&sl->gb, ptr, bit_length);
if ((err = ff_h264_decode_slice_header(hx, sl, h))) if ((err = ff_h264_decode_slice_header(hx, sl, h)))
break; break;
......
...@@ -335,6 +335,7 @@ typedef struct H264Picture { ...@@ -335,6 +335,7 @@ typedef struct H264Picture {
typedef struct H264SliceContext { typedef struct H264SliceContext {
struct H264Context *h264; struct H264Context *h264;
GetBitContext gb;
int slice_num; int slice_num;
int slice_type; int slice_type;
......
...@@ -718,12 +718,12 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) ...@@ -718,12 +718,12 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
down the code */ down the code */
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
if (sl->mb_skip_run == -1) if (sl->mb_skip_run == -1)
sl->mb_skip_run = get_ue_golomb_long(&h->gb); sl->mb_skip_run = get_ue_golomb_long(&sl->gb);
if (sl->mb_skip_run--) { if (sl->mb_skip_run--) {
if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) { if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) {
if (sl->mb_skip_run == 0) if (sl->mb_skip_run == 0)
h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&sl->gb);
} }
decode_mb_skip(h, sl); decode_mb_skip(h, sl);
return 0; return 0;
...@@ -731,12 +731,12 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) ...@@ -731,12 +731,12 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
} }
if (FRAME_MBAFF(h)) { if (FRAME_MBAFF(h)) {
if ((sl->mb_y & 1) == 0) if ((sl->mb_y & 1) == 0)
h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&sl->gb);
} }
sl->prev_mb_skipped = 0; sl->prev_mb_skipped = 0;
mb_type= get_ue_golomb(&h->gb); mb_type= get_ue_golomb(&sl->gb);
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
if(mb_type < 23){ if(mb_type < 23){
partition_count= b_mb_type_info[mb_type].partition_count; partition_count= b_mb_type_info[mb_type].partition_count;
...@@ -778,12 +778,12 @@ decode_intra_mb: ...@@ -778,12 +778,12 @@ decode_intra_mb:
h->sps.bit_depth_luma; h->sps.bit_depth_luma;
// We assume these blocks are very rare so we do not optimize it. // We assume these blocks are very rare so we do not optimize it.
sl->intra_pcm_ptr = align_get_bits(&h->gb); sl->intra_pcm_ptr = align_get_bits(&sl->gb);
if (get_bits_left(&h->gb) < mb_size) { if (get_bits_left(&sl->gb) < mb_size) {
av_log(h->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n"); av_log(h->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
skip_bits_long(&h->gb, mb_size); skip_bits_long(&sl->gb, mb_size);
// In deblocking, the quantizer is 0 // In deblocking, the quantizer is 0
h->cur_pic.qscale_table[mb_xy] = 0; h->cur_pic.qscale_table[mb_xy] = 0;
...@@ -807,7 +807,7 @@ decode_intra_mb: ...@@ -807,7 +807,7 @@ decode_intra_mb:
if(IS_INTRA4x4(mb_type)){ if(IS_INTRA4x4(mb_type)){
int i; int i;
int di = 1; int di = 1;
if(dct8x8_allowed && get_bits1(&h->gb)){ if(dct8x8_allowed && get_bits1(&sl->gb)){
mb_type |= MB_TYPE_8x8DCT; mb_type |= MB_TYPE_8x8DCT;
di = 4; di = 4;
} }
...@@ -816,8 +816,8 @@ decode_intra_mb: ...@@ -816,8 +816,8 @@ decode_intra_mb:
for(i=0; i<16; i+=di){ for(i=0; i<16; i+=di){
int mode = pred_intra_mode(h, sl, i); int mode = pred_intra_mode(h, sl, i);
if(!get_bits1(&h->gb)){ if(!get_bits1(&sl->gb)){
const int rem_mode= get_bits(&h->gb, 3); const int rem_mode= get_bits(&sl->gb, 3);
mode = rem_mode + (rem_mode >= mode); mode = rem_mode + (rem_mode >= mode);
} }
...@@ -835,7 +835,7 @@ decode_intra_mb: ...@@ -835,7 +835,7 @@ decode_intra_mb:
return -1; return -1;
} }
if(decode_chroma){ if(decode_chroma){
pred_mode= ff_h264_check_intra_pred_mode(h, sl, get_ue_golomb_31(&h->gb), 1); pred_mode= ff_h264_check_intra_pred_mode(h, sl, get_ue_golomb_31(&sl->gb), 1);
if(pred_mode < 0) if(pred_mode < 0)
return -1; return -1;
sl->chroma_pred_mode = pred_mode; sl->chroma_pred_mode = pred_mode;
...@@ -847,7 +847,7 @@ decode_intra_mb: ...@@ -847,7 +847,7 @@ decode_intra_mb:
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
for(i=0; i<4; i++){ for(i=0; i<4; i++){
sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb); sl->sub_mb_type[i]= get_ue_golomb_31(&sl->gb);
if(sl->sub_mb_type[i] >=13){ if(sl->sub_mb_type[i] >=13){
av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y); av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y);
return -1; return -1;
...@@ -865,7 +865,7 @@ decode_intra_mb: ...@@ -865,7 +865,7 @@ decode_intra_mb:
}else{ }else{
av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_P); //FIXME SP correct ? av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_P); //FIXME SP correct ?
for(i=0; i<4; i++){ for(i=0; i<4; i++){
sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb); sl->sub_mb_type[i]= get_ue_golomb_31(&sl->gb);
if(sl->sub_mb_type[i] >=4){ if(sl->sub_mb_type[i] >=4){
av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y); av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y);
return -1; return -1;
...@@ -884,9 +884,9 @@ decode_intra_mb: ...@@ -884,9 +884,9 @@ decode_intra_mb:
if(ref_count == 1){ if(ref_count == 1){
tmp= 0; tmp= 0;
}else if(ref_count == 2){ }else if(ref_count == 2){
tmp= get_bits1(&h->gb)^1; tmp= get_bits1(&sl->gb)^1;
}else{ }else{
tmp= get_ue_golomb_31(&h->gb); tmp= get_ue_golomb_31(&sl->gb);
if(tmp>=ref_count){ if(tmp>=ref_count){
av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp);
return -1; return -1;
...@@ -920,8 +920,8 @@ decode_intra_mb: ...@@ -920,8 +920,8 @@ decode_intra_mb:
const int index= 4*i + block_width*j; const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &sl->mv_cache[list][ scan8[index] ]; int16_t (* mv_cache)[2]= &sl->mv_cache[list][ scan8[index] ];
pred_motion(h, sl, index, block_width, list, sl->ref_cache[list][ scan8[index] ], &mx, &my); pred_motion(h, sl, index, block_width, list, sl->ref_cache[list][ scan8[index] ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&sl->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&sl->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){ if(IS_SUB_8X8(sub_mb_type)){
...@@ -959,9 +959,9 @@ decode_intra_mb: ...@@ -959,9 +959,9 @@ decode_intra_mb:
if(local_ref_count[list]==1){ if(local_ref_count[list]==1){
val= 0; val= 0;
} else if(local_ref_count[list]==2){ } else if(local_ref_count[list]==2){
val= get_bits1(&h->gb)^1; val= get_bits1(&sl->gb)^1;
}else{ }else{
val= get_ue_golomb_31(&h->gb); val= get_ue_golomb_31(&sl->gb);
if (val >= local_ref_count[list]){ if (val >= local_ref_count[list]){
av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
return -1; return -1;
...@@ -973,8 +973,8 @@ decode_intra_mb: ...@@ -973,8 +973,8 @@ decode_intra_mb:
for (list = 0; list < sl->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(&sl->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&sl->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(sl->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4); fill_rectangle(sl->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
...@@ -989,9 +989,9 @@ decode_intra_mb: ...@@ -989,9 +989,9 @@ decode_intra_mb:
if(local_ref_count[list] == 1) { if(local_ref_count[list] == 1) {
val= 0; val= 0;
} else if(local_ref_count[list] == 2) { } else if(local_ref_count[list] == 2) {
val= get_bits1(&h->gb)^1; val= get_bits1(&sl->gb)^1;
}else{ }else{
val= get_ue_golomb_31(&h->gb); val= get_ue_golomb_31(&sl->gb);
if (val >= local_ref_count[list]){ if (val >= local_ref_count[list]){
av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
return -1; return -1;
...@@ -1007,8 +1007,8 @@ decode_intra_mb: ...@@ -1007,8 +1007,8 @@ decode_intra_mb:
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, sl, 8*i, list, sl->ref_cache[list][scan8[0] + 16*i], &mx, &my); pred_16x8_motion(h, sl, 8*i, list, sl->ref_cache[list][scan8[0] + 16*i], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&sl->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&sl->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
val= pack16to32(mx,my); val= pack16to32(mx,my);
...@@ -1026,9 +1026,9 @@ decode_intra_mb: ...@@ -1026,9 +1026,9 @@ decode_intra_mb:
if(local_ref_count[list]==1){ if(local_ref_count[list]==1){
val= 0; val= 0;
} else if(local_ref_count[list]==2){ } else if(local_ref_count[list]==2){
val= get_bits1(&h->gb)^1; val= get_bits1(&sl->gb)^1;
}else{ }else{
val= get_ue_golomb_31(&h->gb); val= get_ue_golomb_31(&sl->gb);
if (val >= local_ref_count[list]){ if (val >= local_ref_count[list]){
av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
return -1; return -1;
...@@ -1044,8 +1044,8 @@ decode_intra_mb: ...@@ -1044,8 +1044,8 @@ decode_intra_mb:
unsigned int val; unsigned int val;
if(IS_DIR(mb_type, i, list)){ if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, sl, i*4, list, sl->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); pred_8x16_motion(h, sl, i*4, list, sl->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
mx += get_se_golomb(&h->gb); mx += get_se_golomb(&sl->gb);
my += get_se_golomb(&h->gb); my += get_se_golomb(&sl->gb);
tprintf(h->avctx, "final mv:%d %d\n", mx, my); tprintf(h->avctx, "final mv:%d %d\n", mx, my);
val= pack16to32(mx,my); val= pack16to32(mx,my);
...@@ -1061,7 +1061,7 @@ decode_intra_mb: ...@@ -1061,7 +1061,7 @@ decode_intra_mb:
write_back_motion(h, sl, mb_type); write_back_motion(h, sl, mb_type);
if(!IS_INTRA16x16(mb_type)){ if(!IS_INTRA16x16(mb_type)){
cbp= get_ue_golomb(&h->gb); cbp= get_ue_golomb(&sl->gb);
if(decode_chroma){ if(decode_chroma){
if(cbp > 47){ if(cbp > 47){
...@@ -1086,7 +1086,7 @@ decode_intra_mb: ...@@ -1086,7 +1086,7 @@ decode_intra_mb:
} }
if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){
mb_type |= MB_TYPE_8x8DCT*get_bits1(&h->gb); mb_type |= MB_TYPE_8x8DCT*get_bits1(&sl->gb);
} }
sl->cbp= sl->cbp=
h->cbp_table[mb_xy]= cbp; h->cbp_table[mb_xy]= cbp;
...@@ -1096,7 +1096,7 @@ decode_intra_mb: ...@@ -1096,7 +1096,7 @@ decode_intra_mb:
int i4x4, i8x8, chroma_idx; int i4x4, i8x8, chroma_idx;
int dquant; int dquant;
int ret; int ret;
GetBitContext *gb = &h->gb; GetBitContext *gb = &sl->gb;
const uint8_t *scan, *scan8x8; const uint8_t *scan, *scan8x8;
const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8); const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
...@@ -1108,7 +1108,7 @@ decode_intra_mb: ...@@ -1108,7 +1108,7 @@ decode_intra_mb:
scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0; scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
} }
dquant= get_se_golomb(&h->gb); dquant= get_se_golomb(&sl->gb);
sl->qscale += dquant; sl->qscale += dquant;
......
...@@ -138,7 +138,7 @@ static int scan_mmco_reset(AVCodecParserContext *s) ...@@ -138,7 +138,7 @@ static int scan_mmco_reset(AVCodecParserContext *s)
sl->slice_type_nos = s->pict_type & 3; sl->slice_type_nos = s->pict_type & 3;
if (h->pps.redundant_pic_cnt_present) if (h->pps.redundant_pic_cnt_present)
get_ue_golomb(&h->gb); // redundant_pic_count get_ue_golomb(&sl->gb); // redundant_pic_count
if (ff_set_ref_count(h, sl) < 0) if (ff_set_ref_count(h, sl) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -146,13 +146,13 @@ static int scan_mmco_reset(AVCodecParserContext *s) ...@@ -146,13 +146,13 @@ 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 < sl->list_count; list++) { for (list = 0; list < sl->list_count; list++) {
if (get_bits1(&h->gb)) { if (get_bits1(&sl->gb)) {
int index; int index;
for (index = 0; ; index++) { for (index = 0; ; index++) {
unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&h->gb); unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&sl->gb);
if (reordering_of_pic_nums_idc < 3) if (reordering_of_pic_nums_idc < 3)
get_ue_golomb(&h->gb); get_ue_golomb(&sl->gb);
else if (reordering_of_pic_nums_idc > 3) { else if (reordering_of_pic_nums_idc > 3) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"illegal reordering_of_pic_nums_idc %d\n", "illegal reordering_of_pic_nums_idc %d\n",
...@@ -175,10 +175,10 @@ static int scan_mmco_reset(AVCodecParserContext *s) ...@@ -175,10 +175,10 @@ static int scan_mmco_reset(AVCodecParserContext *s)
(h->pps.weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B)) (h->pps.weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B))
ff_pred_weight_table(h, sl); ff_pred_weight_table(h, sl);
if (get_bits1(&h->gb)) { // adaptive_ref_pic_marking_mode_flag if (get_bits1(&sl->gb)) { // adaptive_ref_pic_marking_mode_flag
int i; int i;
for (i = 0; i < MAX_MMCO_COUNT; i++) { for (i = 0; i < MAX_MMCO_COUNT; i++) {
MMCOOpcode opcode = get_ue_golomb_31(&h->gb); MMCOOpcode opcode = get_ue_golomb_31(&sl->gb);
if (opcode > (unsigned) MMCO_LONG) { if (opcode > (unsigned) MMCO_LONG) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"illegal memory management control operation %d\n", "illegal memory management control operation %d\n",
...@@ -191,10 +191,10 @@ static int scan_mmco_reset(AVCodecParserContext *s) ...@@ -191,10 +191,10 @@ static int scan_mmco_reset(AVCodecParserContext *s)
return 1; return 1;
if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG)
get_ue_golomb(&h->gb); get_ue_golomb(&sl->gb);
if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||
opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG)
get_ue_golomb_31(&h->gb); get_ue_golomb_31(&sl->gb);
} }
} }
...@@ -215,6 +215,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -215,6 +215,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
{ {
H264ParseContext *p = s->priv_data; H264ParseContext *p = s->priv_data;
H264Context *h = &p->h; H264Context *h = &p->h;
H264SliceContext *sl = &h->slice_ctx[0];
int buf_index, next_avc; int buf_index, next_avc;
unsigned int pps_id; unsigned int pps_id;
unsigned int slice_type; unsigned int slice_type;
...@@ -298,14 +299,15 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -298,14 +299,15 @@ static inline int parse_nal_units(AVCodecParserContext *s,
h->prev_poc_lsb = 0; h->prev_poc_lsb = 0;
/* fall through */ /* fall through */
case NAL_SLICE: case NAL_SLICE:
get_ue_golomb_long(&h->gb); // skip first_mb_in_slice init_get_bits(&sl->gb, ptr, 8 * dst_length);
slice_type = get_ue_golomb_31(&h->gb); get_ue_golomb_long(&sl->gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&sl->gb);
s->pict_type = golomb_to_pict_type[slice_type % 5]; s->pict_type = golomb_to_pict_type[slice_type % 5];
if (h->sei_recovery_frame_cnt >= 0) { if (h->sei_recovery_frame_cnt >= 0) {
/* key frame, since recovery_frame_cnt is set */ /* key frame, since recovery_frame_cnt is set */
s->key_frame = 1; s->key_frame = 1;
} }
pps_id = get_ue_golomb(&h->gb); pps_id = get_ue_golomb(&sl->gb);
if (pps_id >= MAX_PPS_COUNT) { if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"pps_id %u out of range\n", pps_id); "pps_id %u out of range\n", pps_id);
...@@ -323,7 +325,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -323,7 +325,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
return -1; return -1;
} }
h->sps = *h->sps_buffers[h->pps.sps_id]; h->sps = *h->sps_buffers[h->pps.sps_id];
h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num); h->frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num);
if(h->sps.ref_frame_count <= 1 && h->pps.ref_count[0] <= 1 && s->pict_type == AV_PICTURE_TYPE_I) if(h->sps.ref_frame_count <= 1 && h->pps.ref_count[0] <= 1 && s->pict_type == AV_PICTURE_TYPE_I)
s->key_frame = 1; s->key_frame = 1;
...@@ -363,30 +365,30 @@ static inline int parse_nal_units(AVCodecParserContext *s, ...@@ -363,30 +365,30 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (h->sps.frame_mbs_only_flag) { if (h->sps.frame_mbs_only_flag) {
h->picture_structure = PICT_FRAME; h->picture_structure = PICT_FRAME;
} else { } else {
if (get_bits1(&h->gb)) { // field_pic_flag if (get_bits1(&sl->gb)) { // field_pic_flag
h->picture_structure = PICT_TOP_FIELD + get_bits1(&h->gb); // bottom_field_flag h->picture_structure = PICT_TOP_FIELD + get_bits1(&sl->gb); // bottom_field_flag
} else { } else {
h->picture_structure = PICT_FRAME; h->picture_structure = PICT_FRAME;
} }
} }
if (h->nal_unit_type == NAL_IDR_SLICE) if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&h->gb); /* idr_pic_id */ get_ue_golomb(&sl->gb); /* idr_pic_id */
if (h->sps.poc_type == 0) { if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb); h->poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && if (h->pps.pic_order_present == 1 &&
h->picture_structure == PICT_FRAME) h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&h->gb); h->delta_poc_bottom = get_se_golomb(&sl->gb);
} }
if (h->sps.poc_type == 1 && if (h->sps.poc_type == 1 &&
!h->sps.delta_pic_order_always_zero_flag) { !h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&h->gb); h->delta_poc[0] = get_se_golomb(&sl->gb);
if (h->pps.pic_order_present == 1 && if (h->pps.pic_order_present == 1 &&
h->picture_structure == PICT_FRAME) h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&h->gb); h->delta_poc[1] = get_se_golomb(&sl->gb);
} }
/* Decode POC of this picture. /* Decode POC of this picture.
......
...@@ -221,11 +221,11 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) ...@@ -221,11 +221,11 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
for (i = 0; i < sl->ref_count[list]; i++) for (i = 0; i < sl->ref_count[list]; i++)
COPY_PICTURE(&sl->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(&sl->gb)) { // ref_pic_list_modification_flag_l[01]
int pred = h->curr_pic_num; int pred = h->curr_pic_num;
for (index = 0; ; index++) { for (index = 0; ; index++) {
unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&h->gb); unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&sl->gb);
unsigned int pic_id; unsigned int pic_id;
int i; int i;
H264Picture *ref = NULL; H264Picture *ref = NULL;
...@@ -241,7 +241,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) ...@@ -241,7 +241,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
switch (modification_of_pic_nums_idc) { switch (modification_of_pic_nums_idc) {
case 0: case 0:
case 1: { case 1: {
const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1; const unsigned int abs_diff_pic_num = get_ue_golomb(&sl->gb) + 1;
int frame_num; int frame_num;
if (abs_diff_pic_num > h->max_pic_num) { if (abs_diff_pic_num > h->max_pic_num) {
...@@ -272,7 +272,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) ...@@ -272,7 +272,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl)
} }
case 2: { case 2: {
int long_idx; int long_idx;
pic_id = get_ue_golomb(&h->gb); // long_term_pic_idx pic_id = get_ue_golomb(&sl->gb); // long_term_pic_idx
long_idx = pic_num_extract(h, pic_id, &pic_structure); long_idx = pic_num_extract(h, pic_id, &pic_structure);
......
...@@ -1296,7 +1296,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1296,7 +1296,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab; h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab; h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
first_mb_in_slice = get_ue_golomb_long(&h->gb); first_mb_in_slice = get_ue_golomb_long(&sl->gb);
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)) {
...@@ -1313,7 +1313,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1313,7 +1313,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
} }
} }
slice_type = get_ue_golomb_31(&h->gb); slice_type = get_ue_golomb_31(&sl->gb);
if (slice_type > 9) { if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d\n", "slice type %d too large at %d\n",
...@@ -1348,7 +1348,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1348,7 +1348,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
// to make a few old functions happy, it's wrong though // to make a few old functions happy, it's wrong though
h->pict_type = sl->slice_type; h->pict_type = sl->slice_type;
pps_id = get_ue_golomb(&h->gb); pps_id = get_ue_golomb(&sl->gb);
if (pps_id >= MAX_PPS_COUNT) { if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id); av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -1504,7 +1504,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1504,7 +1504,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
ff_h264_init_dequant_tables(h); ff_h264_init_dequant_tables(h);
} }
frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num); frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num);
if (!first_slice) { if (!first_slice) {
if (h0->frame_num != frame_num) { if (h0->frame_num != frame_num) {
av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n", av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n",
...@@ -1525,10 +1525,10 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1525,10 +1525,10 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n"); av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
return -1; return -1;
} }
field_pic_flag = get_bits1(&h->gb); field_pic_flag = get_bits1(&sl->gb);
if (field_pic_flag) { if (field_pic_flag) {
bottom_field_flag = get_bits1(&h->gb); bottom_field_flag = get_bits1(&sl->gb);
picture_structure = PICT_TOP_FIELD + bottom_field_flag; picture_structure = PICT_TOP_FIELD + bottom_field_flag;
} else { } else {
picture_structure = PICT_FRAME; picture_structure = PICT_FRAME;
...@@ -1769,26 +1769,26 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1769,26 +1769,26 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
} }
if (h->nal_unit_type == NAL_IDR_SLICE) if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&h->gb); /* idr_pic_id */ get_ue_golomb(&sl->gb); /* idr_pic_id */
if (h->sps.poc_type == 0) { if (h->sps.poc_type == 0) {
h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb); h->poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc_bottom = get_se_golomb(&h->gb); h->delta_poc_bottom = get_se_golomb(&sl->gb);
} }
if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) { if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
h->delta_poc[0] = get_se_golomb(&h->gb); h->delta_poc[0] = get_se_golomb(&sl->gb);
if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME)
h->delta_poc[1] = get_se_golomb(&h->gb); h->delta_poc[1] = get_se_golomb(&sl->gb);
} }
ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc); ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
if (h->pps.redundant_pic_cnt_present) if (h->pps.redundant_pic_cnt_present)
sl->redundant_pic_count = get_ue_golomb(&h->gb); sl->redundant_pic_count = get_ue_golomb(&sl->gb);
ret = ff_set_ref_count(h, sl); ret = ff_set_ref_count(h, sl);
if (ret < 0) if (ret < 0)
...@@ -1831,7 +1831,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1831,7 +1831,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
// further down the line. This may break decoding if the first slice is // further down the line. This may break decoding if the first slice is
// corrupt, thus we only do this if frame-mt is enabled. // corrupt, thus we only do this if frame-mt is enabled.
if (h->nal_ref_idc) { if (h->nal_ref_idc) {
ret = ff_h264_decode_ref_pic_marking(h0, &h->gb, ret = ff_h264_decode_ref_pic_marking(h0, &sl->gb,
!(h->avctx->active_thread_type & FF_THREAD_FRAME) || !(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
h0->current_slice == 0); h0->current_slice == 0);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
...@@ -1852,7 +1852,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1852,7 +1852,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
ff_h264_direct_ref_list_init(h, sl); ff_h264_direct_ref_list_init(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) { if (sl->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
tmp = get_ue_golomb_31(&h->gb); tmp = get_ue_golomb_31(&sl->gb);
if (tmp > 2) { if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp); av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -1861,7 +1861,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1861,7 +1861,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
} }
sl->last_qscale_diff = 0; sl->last_qscale_diff = 0;
tmp = h->pps.init_qp + get_se_golomb(&h->gb); tmp = h->pps.init_qp + get_se_golomb(&sl->gb);
if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) { if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp); av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -1871,16 +1871,16 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1871,16 +1871,16 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale); sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
// FIXME qscale / qp ... stuff // FIXME qscale / qp ... stuff
if (sl->slice_type == AV_PICTURE_TYPE_SP) if (sl->slice_type == AV_PICTURE_TYPE_SP)
get_bits1(&h->gb); /* sp_for_switch_flag */ get_bits1(&sl->gb); /* sp_for_switch_flag */
if (sl->slice_type == AV_PICTURE_TYPE_SP || if (sl->slice_type == AV_PICTURE_TYPE_SP ||
sl->slice_type == AV_PICTURE_TYPE_SI) sl->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&h->gb); /* slice_qs_delta */ get_se_golomb(&sl->gb); /* slice_qs_delta */
sl->deblocking_filter = 1; sl->deblocking_filter = 1;
sl->slice_alpha_c0_offset = 0; sl->slice_alpha_c0_offset = 0;
sl->slice_beta_offset = 0; sl->slice_beta_offset = 0;
if (h->pps.deblocking_filter_parameters_present) { if (h->pps.deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&h->gb); tmp = get_ue_golomb_31(&sl->gb);
if (tmp > 2) { if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", tmp); "deblocking_filter_idc %u out of range\n", tmp);
...@@ -1891,8 +1891,8 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1891,8 +1891,8 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
sl->deblocking_filter ^= 1; // 1<->0 sl->deblocking_filter ^= 1; // 1<->0
if (sl->deblocking_filter) { if (sl->deblocking_filter) {
sl->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2; sl->slice_alpha_c0_offset = get_se_golomb(&sl->gb) * 2;
sl->slice_beta_offset = get_se_golomb(&h->gb) * 2; sl->slice_beta_offset = get_se_golomb(&sl->gb) * 2;
if (sl->slice_alpha_c0_offset > 12 || if (sl->slice_alpha_c0_offset > 12 ||
sl->slice_alpha_c0_offset < -12 || sl->slice_alpha_c0_offset < -12 ||
sl->slice_beta_offset > 12 || sl->slice_beta_offset > 12 ||
...@@ -2418,12 +2418,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2418,12 +2418,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (h->pps.cabac) { if (h->pps.cabac) {
/* realign */ /* realign */
align_get_bits(&h->gb); align_get_bits(&sl->gb);
/* init cabac */ /* init cabac */
ff_init_cabac_decoder(&sl->cabac, ff_init_cabac_decoder(&sl->cabac,
h->gb.buffer + get_bits_count(&h->gb) / 8, sl->gb.buffer + get_bits_count(&sl->gb) / 8,
(get_bits_left(&h->gb) + 7) / 8); (get_bits_left(&sl->gb) + 7) / 8);
ff_h264_init_cabac_states(h, sl); ff_h264_init_cabac_states(h, sl);
...@@ -2482,7 +2482,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2482,7 +2482,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (eos || sl->mb_y >= h->mb_height) { if (eos || sl->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(&sl->gb), sl->gb.size_in_bits);
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1,
sl->mb_y, ER_MB_END); sl->mb_y, ER_MB_END);
if (sl->mb_x > lf_x_start) if (sl->mb_x > lf_x_start)
...@@ -2527,10 +2527,10 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2527,10 +2527,10 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
} }
if (sl->mb_y >= h->mb_height) { if (sl->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(&sl->gb), sl->gb.size_in_bits);
if ( get_bits_left(&h->gb) == 0 if ( get_bits_left(&sl->gb) == 0
|| get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { || get_bits_left(&sl->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y,
sl->mb_x - 1, sl->mb_y, ER_MB_END); sl->mb_x - 1, sl->mb_y, ER_MB_END);
...@@ -2544,11 +2544,11 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2544,11 +2544,11 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
} }
} }
if (get_bits_left(&h->gb) <= 0 && sl->mb_skip_run <= 0) { if (get_bits_left(&sl->gb) <= 0 && sl->mb_skip_run <= 0) {
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(&sl->gb), sl->gb.size_in_bits);
if (get_bits_left(&h->gb) == 0) { if (get_bits_left(&sl->gb) == 0) {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y,
sl->mb_x - 1, sl->mb_y, ER_MB_END); sl->mb_x - 1, sl->mb_y, ER_MB_END);
if (sl->mb_x > lf_x_start) if (sl->mb_x > lf_x_start)
......
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