comparison mpegvideo.c @ 162:de80712db90b libavcodec

- Preliminary RTP friendly mode for H.263. - GOB headers for H.263 coding on RTP mode. - Improved GOB header detection for H.263 decoder.
author pulento
date Mon, 19 Nov 2001 02:13:14 +0000
parents 1e4a4af694d1
children 9ce215ee9216
comparison
equal deleted inserted replaced
161:7ce36cf13055 162:de80712db90b
247 s->bit_rate = avctx->bit_rate; 247 s->bit_rate = avctx->bit_rate;
248 s->frame_rate = avctx->frame_rate; 248 s->frame_rate = avctx->frame_rate;
249 s->width = avctx->width; 249 s->width = avctx->width;
250 s->height = avctx->height; 250 s->height = avctx->height;
251 s->gop_size = avctx->gop_size; 251 s->gop_size = avctx->gop_size;
252 s->rtp_mode = avctx->rtp_mode;
253 s->rtp_payload_size = avctx->rtp_payload_size;
254
252 if (s->gop_size <= 1) { 255 if (s->gop_size <= 1) {
253 s->intra_only = 1; 256 s->intra_only = 1;
254 s->gop_size = 12; 257 s->gop_size = 12;
255 } else { 258 } else {
256 s->intra_only = 0; 259 s->intra_only = 0;
274 return -1; 277 return -1;
275 s->out_format = FMT_H263; 278 s->out_format = FMT_H263;
276 break; 279 break;
277 case CODEC_ID_H263P: 280 case CODEC_ID_H263P:
278 s->out_format = FMT_H263; 281 s->out_format = FMT_H263;
282 s->rtp_mode = 1;
283 s->rtp_payload_size = 1200;
279 s->h263_plus = 1; 284 s->h263_plus = 1;
280 s->unrestricted_mv = 1; 285 s->unrestricted_mv = 1;
281 286
282 /* These are just to be sure */ 287 /* These are just to be sure */
283 s->umvplus = 0; 288 s->umvplus = 0;
817 emms_c(); 822 emms_c();
818 } 823 }
819 824
820 static void encode_picture(MpegEncContext *s, int picture_number) 825 static void encode_picture(MpegEncContext *s, int picture_number)
821 { 826 {
822 int mb_x, mb_y, wrap; 827 int mb_x, mb_y, wrap, last_gob;
823 UINT8 *ptr; 828 UINT8 *ptr;
824 int i, motion_x, motion_y; 829 int i, motion_x, motion_y;
825 830
826 s->picture_number = picture_number; 831 s->picture_number = picture_number;
827 if (!s->fixed_qscale) 832 if (!s->fixed_qscale)
867 s->last_mv[0][0][0] = 0; 872 s->last_mv[0][0][0] = 0;
868 s->last_mv[0][0][1] = 0; 873 s->last_mv[0][0][1] = 0;
869 s->mv_type = MV_TYPE_16X16; 874 s->mv_type = MV_TYPE_16X16;
870 s->mv_dir = MV_DIR_FORWARD; 875 s->mv_dir = MV_DIR_FORWARD;
871 876
877 /* Get the GOB height based on picture height */
878 if (s->out_format == FMT_H263 && s->h263_plus) {
879 if (s->height <= 400)
880 s->gob_index = 1;
881 else if (s->height <= 800)
882 s->gob_index = 2;
883 else
884 s->gob_index = 4;
885 }
886
872 for(mb_y=0; mb_y < s->mb_height; mb_y++) { 887 for(mb_y=0; mb_y < s->mb_height; mb_y++) {
888 /* Put GOB header based on RTP MTU */
889 if (!mb_y) {
890 s->ptr_lastgob = s->pb.buf_ptr;
891 s->ptr_last_mb_line = s->pb.buf_ptr;
892 } else if (s->out_format == FMT_H263 && s->h263_plus) {
893 last_gob = h263_encode_gob_header(s, mb_y);
894 if (last_gob) {
895 //fprintf(stderr,"\nLast GOB size: %d", last_gob);
896 s->first_gob_line = 1;
897 } else
898 s->first_gob_line = 0;
899 }
873 for(mb_x=0; mb_x < s->mb_width; mb_x++) { 900 for(mb_x=0; mb_x < s->mb_width; mb_x++) {
874 901
875 s->mb_x = mb_x; 902 s->mb_x = mb_x;
876 s->mb_y = mb_y; 903 s->mb_y = mb_y;
877 904
979 s->mv[0][0][0] = motion_x; 1006 s->mv[0][0][0] = motion_x;
980 s->mv[0][0][1] = motion_y; 1007 s->mv[0][0][1] = motion_y;
981 1008
982 MPV_decode_mb(s, s->block); 1009 MPV_decode_mb(s, s->block);
983 } 1010 }
984 } 1011 /* Obtain average MB line size for RTP */
1012 if (!mb_y)
1013 s->mb_line_avgsize = s->pb.buf_ptr - s->ptr_last_mb_line;
1014 else
1015 s->mb_line_avgsize = (s->mb_line_avgsize + s->pb.buf_ptr - s->ptr_last_mb_line) >> 1;
1016 //fprintf(stderr, "\nMB line: %d\tSize: %u\tAvg. Size: %u", s->mb_y,
1017 // (s->pb.buf_ptr - s->ptr_last_mb_line), s->mb_line_avgsize);
1018 s->ptr_last_mb_line = s->pb.buf_ptr;
1019 }
1020 //if (s->gob_number)
1021 // fprintf(stderr,"\nNumber of GOB: %d", s->gob_number);
985 } 1022 }
986 1023
987 static int dct_quantize(MpegEncContext *s, 1024 static int dct_quantize(MpegEncContext *s,
988 DCTELEM *block, int n, 1025 DCTELEM *block, int n,
989 int qscale) 1026 int qscale)