Mercurial > libavcodec.hg
changeset 1278:483db104bb7b libavcodec
truncated h263 decoding support / H263-ES "demuxer"
author | michaelni |
---|---|
date | Thu, 22 May 2003 14:12:22 +0000 |
parents | f3152eb76f1a |
children | 77aafc141a39 |
files | h263.c h263dec.c |
diffstat | 2 files changed, 87 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/h263.c Wed May 21 17:50:57 2003 +0000 +++ b/h263.c Thu May 22 14:12:22 2003 +0000 @@ -3902,10 +3902,21 @@ /* most is hardcoded. should extend to handle all h263 streams */ int h263_decode_picture_header(MpegEncContext *s) { - int format, width, height; - - /* picture start code */ - if (get_bits_long(&s->gb, 22) != 0x20) { + int format, width, height, i; + uint32_t startcode; + + align_get_bits(&s->gb); + + startcode= get_bits(&s->gb, 22-8); + + for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>0; i--) { + startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF; + + if(startcode == 0x20) + break; + } + + if (startcode != 0x20) { fprintf(stderr, "Bad picture start code\n"); return -1; } @@ -3988,15 +3999,26 @@ s->h263_aic = 1; } - skip_bits(&s->gb, 7); - /* these are the 7 bits: (in order of appearence */ - /* Deblocking Filter */ - /* Slice Structured */ - /* Reference Picture Selection */ - /* Independent Segment Decoding */ - /* Alternative Inter VLC */ - /* Modified Quantization */ - /* Prevent start code emulation */ + if (get_bits1(&s->gb) != 0) { + fprintf(stderr, "Deblocking Filter not supported\n"); + } + if (get_bits1(&s->gb) != 0) { + fprintf(stderr, "Slice Structured not supported\n"); + } + if (get_bits1(&s->gb) != 0) { + fprintf(stderr, "Reference Picture Selection not supported\n"); + } + if (get_bits1(&s->gb) != 0) { + fprintf(stderr, "Independent Segment Decoding not supported\n"); + } + if (get_bits1(&s->gb) != 0) { + fprintf(stderr, "Alternative Inter VLC not supported\n"); + } + if (get_bits1(&s->gb) != 0) { + fprintf(stderr, "Modified Quantization not supported\n"); + } + + skip_bits(&s->gb, 1); /* Prevent start code emulation */ skip_bits(&s->gb, 3); /* Reserved */ } else if (ufep != 0) { @@ -4072,6 +4094,18 @@ s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } + if(s->avctx->debug&FF_DEBUG_PICT_INFO){ + printf("qp:%d %c size:%d rnd:%d %s %s %s %s\n", + s->qscale, av_get_pict_type_char(s->pict_type), + s->gb.size_in_bits, 1-s->no_rounding, + s->mv_type == MV_TYPE_8X8 ? "ADV" : "", + s->umvplus ? "UMV" : "", + s->h263_long_vectors ? "LONG" : "", + s->h263_plus ? "+" : "" + ); + } + + return 0; }
--- a/h263dec.c Wed May 21 17:50:57 2003 +0000 +++ b/h263dec.c Thu May 22 14:12:22 2003 +0000 @@ -341,6 +341,42 @@ return END_NOT_FOUND; } +static int h263_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){ + ParseContext *pc= &s->parse_context; + int vop_found, i; + uint32_t state; + + vop_found= pc->frame_start_found; + state= pc->state; + + i=0; + if(!vop_found){ + for(i=0; i<buf_size; i++){ + state= (state<<8) | buf[i]; + if(state>>(32-22) == 0x20){ + i++; + vop_found=1; + break; + } + } + } + + if(vop_found){ + for(; i<buf_size; i++){ + state= (state<<8) | buf[i]; + if(state>>(32-22) == 0x20){ + pc->frame_start_found=0; + pc->state=-1; + return i-3; + } + } + } + pc->frame_start_found= vop_found; + pc->state= state; + + return END_NOT_FOUND; +} + /** * draws an line from (ex, ey) -> (sx, sy). * @param w width of the image @@ -440,6 +476,8 @@ if(s->codec_id==CODEC_ID_MPEG4){ next= mpeg4_find_frame_end(s, buf, buf_size); + }else if(s->codec_id==CODEC_ID_H263){ + next= h263_find_frame_end(s, buf, buf_size); }else{ fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); return -1; @@ -753,6 +791,7 @@ #ifdef PRINT_FRAME_TIME printf("%Ld\n", rdtsc()-time); #endif + return get_consumed_bytes(s, buf_size); } @@ -784,7 +823,7 @@ NULL, ff_h263_decode_end, ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, }; AVCodec msmpeg4v1_decoder = {