Mercurial > libavcodec.hg
diff mpeg12.c @ 1138:e10e841c9bf0 libavcodec
field pic decoding cleanup
author | michaelni |
---|---|
date | Sun, 16 Mar 2003 20:22:22 +0000 |
parents | 77ccf7fe3bd0 |
children | dde68a430ba9 |
line wrap: on
line diff
--- a/mpeg12.c Sat Mar 15 20:47:09 2003 +0000 +++ b/mpeg12.c Sun Mar 16 20:22:22 2003 +0000 @@ -229,7 +229,7 @@ put_bits(&s->pb, 4, s->aspect_ratio_info); put_bits(&s->pb, 4, s->frame_rate_index); - v = s->bit_rate / 400; + v = (s->bit_rate + 399) / 400; if (v > 0x3ffff) v = 0x3ffff; put_bits(&s->pb, 18, v); @@ -1803,7 +1803,8 @@ memset(s->last_mv, 0, sizeof(s->last_mv)); /* start frame decoding */ - if (s->first_slice && (s->first_field || s->picture_structure==PICT_FRAME)) { + if (s->first_slice) { + if(s->first_field || s->picture_structure==PICT_FRAME){ if(MPV_frame_start(s, avctx) < 0) return DECODE_SLICE_FATAL_ERROR; /* first check if we must repeat the frame */ @@ -1829,6 +1830,15 @@ s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } + }else{ //second field + int i; + for(i=0; i<4; i++){ + s->current_picture.data[i] = s->current_picture_ptr->data[i]; + if(s->picture_structure == PICT_BOTTOM_FIELD){ + s->current_picture.data[i] += s->current_picture_ptr->linesize[i]; + } + } + } } s->first_slice = 0; @@ -1865,27 +1875,8 @@ dprintf("ret=%d\n", ret); if (ret < 0) return -1; -//printf("%d %d\n", s->mb_x, s->mb_y); - //FIXME this isnt the most beautifull way to solve the problem ... - if(s->picture_structure!=PICT_FRAME){ - if(s->picture_structure == PICT_BOTTOM_FIELD){ - s->current_picture.data[0] += s->linesize; - s->current_picture.data[1] += s->uvlinesize; - s->current_picture.data[2] += s->uvlinesize; - } - s->linesize *= 2; - s->uvlinesize *= 2; - } + MPV_decode_mb(s, s->block); - if(s->picture_structure!=PICT_FRAME){ - s->linesize /= 2; - s->uvlinesize /= 2; - if(s->picture_structure == PICT_BOTTOM_FIELD){ - s->current_picture.data[0] -= s->linesize; - s->current_picture.data[1] -= s->uvlinesize; - s->current_picture.data[2] -= s->uvlinesize; - } - } if (++s->mb_x >= s->mb_width) { if(s->picture_structure==PICT_FRAME){ @@ -1945,7 +1936,7 @@ s->picture_number++; /* latency of 1 frame for I and P frames */ /* XXX: use another variable than picture_number */ - if (s->last_picture.data[0] == NULL) { + if (s->last_picture_ptr == NULL) { return DECODE_SLICE_OK; } else { *pict= *(AVFrame*)&s->last_picture; @@ -2196,7 +2187,7 @@ start_code <= SLICE_MAX_START_CODE) { /* skip b frames if we dont have reference frames */ - if(s2->last_picture.data[0]==NULL && s2->pict_type==B_TYPE) break; + if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break; /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s2->pict_type==B_TYPE) break; /* skip everything if we are in a hurry>=5 */