diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-08 13:18:42 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2003-01-08 13:18:42 +0000 |
commit | 6f1c8d4eafabd914b87e9171bf4d04f4ef9160ea (patch) | |
tree | e70be493d1222b10f96aa5efac01c0ec0d5bcc97 /src/libffmpeg/libavcodec/h263dec.c | |
parent | 1fb58a63872660424777d41389e426dc90f1b660 (diff) | |
download | xine-lib-6f1c8d4eafabd914b87e9171bf4d04f4ef9160ea.tar.gz xine-lib-6f1c8d4eafabd914b87e9171bf4d04f4ef9160ea.tar.bz2 |
syncing ffmpeg (with some compilation fixes)
- fixes wma bugs
- mace, huffyuv and mp3 decoders imported (but not enabled)
tested: wma (v1 and v2), mpeg4, msmpeg4 v1, v2 and v3, divx3, divx4, divx5, xvid and
dv decoders. everything looks fine.
CVS patchset: 3828
CVS date: 2003/01/08 13:18:42
Diffstat (limited to 'src/libffmpeg/libavcodec/h263dec.c')
-rw-r--r-- | src/libffmpeg/libavcodec/h263dec.c | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/src/libffmpeg/libavcodec/h263dec.c b/src/libffmpeg/libavcodec/h263dec.c index 1f8fb44a8..93a14a06e 100644 --- a/src/libffmpeg/libavcodec/h263dec.c +++ b/src/libffmpeg/libavcodec/h263dec.c @@ -40,7 +40,7 @@ static inline long long rdtsc() } #endif -static int h263_decode_init(AVCodecContext *avctx) +int ff_h263_decode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; @@ -55,6 +55,8 @@ static int h263_decode_init(AVCodecContext *avctx) s->quant_precision=5; s->progressive_sequence=1; s->decode_mb= ff_h263_decode_mb; + s->low_delay= 1; + avctx->pix_fmt= PIX_FMT_YUV420P; /* select sub codec */ switch(avctx->codec->id) { @@ -64,7 +66,7 @@ static int h263_decode_init(AVCodecContext *avctx) case CODEC_ID_MPEG4: s->time_increment_bits = 4; /* default value for broken headers */ s->h263_pred = 1; - s->has_b_frames = 1; //default, might be overriden in the vol header during header parsing + s->low_delay = 0; //default, might be overriden in the vol header during header parsing break; case CODEC_ID_MSMPEG4V1: s->h263_msmpeg4 = 1; @@ -112,7 +114,7 @@ static int h263_decode_init(AVCodecContext *avctx) return 0; } -static int h263_decode_end(AVCodecContext *avctx) +int ff_h263_decode_end(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; @@ -249,7 +251,7 @@ static int decode_slice(MpegEncContext *s){ && (s->workaround_bugs&FF_BUG_AUTODETECT) && s->gb.size*8 - get_bits_count(&s->gb) >=0 && s->gb.size*8 - get_bits_count(&s->gb) < 48 - && !s->resync_marker +// && !s->resync_marker && !s->data_partitioning){ const int bits_count= get_bits_count(&s->gb); @@ -342,13 +344,13 @@ static int mpeg4_find_frame_end(MpegEncContext *s, UINT8 *buf, int buf_size){ return -1; } -static int h263_decode_frame(AVCodecContext *avctx, +int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int ret,i; - AVVideoFrame *pict = data; + AVFrame *pict = data; float new_aspect; #ifdef PRINT_FRAME_TIME @@ -415,9 +417,11 @@ retry: if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix return -1; } - + /* let's go :-) */ - if (s->h263_msmpeg4) { + if (s->msmpeg4_version==5) { + ret= ff_wmv2_decode_picture_header(s); + } else if (s->msmpeg4_version) { ret = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { if(s->avctx->extradata_size && s->picture_number==0){ @@ -430,25 +434,23 @@ retry: if(s->flags& CODEC_FLAG_LOW_DELAY) s->low_delay=1; - - s->has_b_frames= !s->low_delay; } else if (s->h263_intel) { ret = intel_h263_decode_picture_header(s); } else { ret = h263_decode_picture_header(s); } - avctx->has_b_frames= s->has_b_frames; + avctx->has_b_frames= !s->low_delay; if(s->workaround_bugs&FF_BUG_AUTODETECT){ if(s->avctx->fourcc == ff_get_fourcc("XVIX")) s->workaround_bugs|= FF_BUG_XVID_ILACE; - +#if 0 if(s->avctx->fourcc == ff_get_fourcc("MP4S")) s->workaround_bugs|= FF_BUG_AC_VLC; if(s->avctx->fourcc == ff_get_fourcc("M4S2")) s->workaround_bugs|= FF_BUG_AC_VLC; - +#endif if(s->avctx->fourcc == ff_get_fourcc("UMP4")){ s->workaround_bugs|= FF_BUG_UMP4; s->workaround_bugs|= FF_BUG_AC_VLC; @@ -464,6 +466,9 @@ retry: if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->padding_bug_score= 256*256*256*64; + if(s->xvid_build && s->xvid_build<=3) + s->padding_bug_score= 256*256*256*64; + if(s->xvid_build && s->xvid_build<=1) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; @@ -531,7 +536,7 @@ retry: s->current_picture.key_frame= s->pict_type == I_TYPE; /* skip b frames if we dont have reference frames */ - if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); + if(s->last_picture.data[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); /* skip everything if we are in a hurry>=5 */ @@ -635,7 +640,6 @@ retry: } if(num_end_markers || error){ fprintf(stderr, "concealing errors\n"); -//printf("type:%d\n", s->pict_type); ff_error_resilience(s); } } @@ -676,20 +680,33 @@ retry: } #endif - if(s->pict_type==B_TYPE || (!s->has_b_frames)){ - *pict= *(AVVideoFrame*)&s->current_picture; + + if(s->pict_type==B_TYPE || s->low_delay){ + *pict= *(AVFrame*)&s->current_picture; } else { - *pict= *(AVVideoFrame*)&s->last_picture; + *pict= *(AVFrame*)&s->last_picture; + } + + if(avctx->debug&FF_DEBUG_QP){ + int8_t *qtab= pict->qscale_table; + int x,y; + + for(y=0; y<s->mb_height; y++){ + for(x=0; x<s->mb_width; x++){ + printf("%2d ", qtab[x + y*s->mb_width]); + } + printf("\n"); + } + printf("\n"); } /* Return the Picture timestamp as the frame number */ /* we substract 1 because it is added on utils.c */ avctx->frame_number = s->picture_number - 1; - /* dont output the last pic after seeking - note we allready added +1 for the current pix in MPV_frame_end(s) */ - if(s->num_available_buffers>=2 || (!s->has_b_frames)) - *data_size = sizeof(AVVideoFrame); + /* dont output the last pic after seeking */ + if(s->last_picture.data[0] || s->low_delay) + *data_size = sizeof(AVFrame); #ifdef PRINT_FRAME_TIME printf("%Ld\n", rdtsc()-time); #endif @@ -701,10 +718,10 @@ AVCodec mpeg4_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_MPEG4, sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, }; @@ -713,10 +730,10 @@ AVCodec h263_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_H263, sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, }; @@ -725,10 +742,10 @@ AVCodec msmpeg4v1_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_MSMPEG4V1, sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, }; @@ -737,10 +754,10 @@ AVCodec msmpeg4v2_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_MSMPEG4V2, sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, }; @@ -749,10 +766,10 @@ AVCodec msmpeg4v3_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_MSMPEG4V3, sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, }; @@ -761,22 +778,10 @@ AVCodec wmv1_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_WMV1, sizeof(MpegEncContext), - h263_decode_init, - NULL, - h263_decode_end, - h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, -}; - -AVCodec wmv2_decoder = { - "wmv2", - CODEC_TYPE_VIDEO, - CODEC_ID_WMV2, - sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, }; @@ -785,10 +790,10 @@ AVCodec h263i_decoder = { CODEC_TYPE_VIDEO, CODEC_ID_H263I, sizeof(MpegEncContext), - h263_decode_init, + ff_h263_decode_init, NULL, - h263_decode_end, - h263_decode_frame, + ff_h263_decode_end, + ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, }; |