Mercurial > libavcodec.hg
diff mpegvideo.c @ 231:840cd25bf259 libavcodec
- Fixes on RTP and GOB headers for H.263.
- RTP callback system implemented for H.263/H.263+.
- Bug fix on DC coefficients of H.263.
- H.263 decoder now returns PTS on picture number.
author | pulento |
---|---|
date | Sat, 09 Feb 2002 16:59:56 +0000 |
parents | ba9cd6fb6f0e |
children | b640ec5948b0 |
line wrap: on
line diff
--- a/mpegvideo.c Sat Feb 09 01:25:06 2002 +0000 +++ b/mpegvideo.c Sat Feb 09 16:59:56 2002 +0000 @@ -264,6 +264,8 @@ s->gop_size = avctx->gop_size; s->rtp_mode = avctx->rtp_mode; s->rtp_payload_size = avctx->rtp_payload_size; + if (avctx->rtp_callback) + s->rtp_callback = avctx->rtp_callback; s->avctx = avctx; if (s->gop_size <= 1) { @@ -868,7 +870,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) { - int mb_x, mb_y, wrap, last_gob; + int mb_x, mb_y, wrap, last_gob, pdif = 0; UINT8 *ptr; int i, motion_x, motion_y; @@ -919,7 +921,7 @@ s->mv_dir = MV_DIR_FORWARD; /* Get the GOB height based on picture height */ - if (s->out_format == FMT_H263 && s->h263_plus) { + if (s->out_format == FMT_H263 && !s->h263_pred && !s->h263_msmpeg4) { if (s->height <= 400) s->gob_index = 1; else if (s->height <= 800) @@ -930,16 +932,17 @@ for(mb_y=0; mb_y < s->mb_height; mb_y++) { /* Put GOB header based on RTP MTU */ - if (!mb_y) { - s->ptr_lastgob = s->pb.buf_ptr; - s->ptr_last_mb_line = s->pb.buf_ptr; - } else if (s->out_format == FMT_H263 && s->h263_plus) { - last_gob = h263_encode_gob_header(s, mb_y); - if (last_gob) { - //fprintf(stderr,"\nLast GOB size: %d", last_gob); - s->first_gob_line = 1; - } else - s->first_gob_line = 0; + /* TODO: Put all this stuff in a separate generic function */ + if (s->rtp_mode) { + if (!mb_y) { + s->ptr_lastgob = s->pb.buf; + s->ptr_last_mb_line = s->pb.buf; + } else if (s->out_format == FMT_H263 && !s->h263_pred && !s->h263_msmpeg4 && !(mb_y % s->gob_index)) { + last_gob = h263_encode_gob_header(s, mb_y); + if (last_gob) { + s->first_gob_line = 1; + } + } } for(mb_x=0; mb_x < s->mb_width; mb_x++) { @@ -1046,14 +1049,18 @@ MPV_decode_mb(s, s->block); } - /* Obtain average MB line size for RTP */ - if (!mb_y) - s->mb_line_avgsize = s->pb.buf_ptr - s->ptr_last_mb_line; - else - s->mb_line_avgsize = (s->mb_line_avgsize + s->pb.buf_ptr - s->ptr_last_mb_line) >> 1; - //fprintf(stderr, "\nMB line: %d\tSize: %u\tAvg. Size: %u", s->mb_y, - // (s->pb.buf_ptr - s->ptr_last_mb_line), s->mb_line_avgsize); - s->ptr_last_mb_line = s->pb.buf_ptr; + /* Obtain average GOB size for RTP */ + if (s->rtp_mode) { + if (!mb_y) + s->mb_line_avgsize = s->pb.buf_ptr - s->ptr_last_mb_line; + else if (!(mb_y % s->gob_index)) { + s->mb_line_avgsize = (s->mb_line_avgsize + s->pb.buf_ptr - s->ptr_last_mb_line) >> 1; + s->ptr_last_mb_line = s->pb.buf_ptr; + } + //fprintf(stderr, "\nMB line: %d\tSize: %u\tAvg. Size: %u", s->mb_y, + // (s->pb.buf_ptr - s->ptr_last_mb_line), s->mb_line_avgsize); + s->first_gob_line = 0; + } } if (s->h263_msmpeg4) @@ -1061,6 +1068,18 @@ //if (s->gob_number) // fprintf(stderr,"\nNumber of GOB: %d", s->gob_number); + + /* Send the last GOB if RTP */ + if (s->rtp_mode) { + flush_put_bits(&s->pb); + pdif = s->pb.buf_ptr - s->ptr_lastgob; + /* Call the RTP callback to send the last GOB */ + if (s->rtp_callback) + s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); + s->ptr_lastgob = s->pb.buf_ptr; + //fprintf(stderr,"\nGOB: %2d size: %d (last)", s->gob_number, pdif); + } + } static int dct_quantize_c(MpegEncContext *s,