Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1421:340c90faa1dc libavcodec
mpeg2 encoding
author | michaelni |
---|---|
date | Mon, 25 Aug 2003 22:47:32 +0000 |
parents | 8edad1e372d1 |
children | efeed6e29f9b |
comparison
equal
deleted
inserted
replaced
1420:ff0220970711 | 1421:340c90faa1dc |
---|---|
32 | 32 |
33 #ifdef USE_FASTMEMCPY | 33 #ifdef USE_FASTMEMCPY |
34 #include "fastmemcpy.h" | 34 #include "fastmemcpy.h" |
35 #endif | 35 #endif |
36 | 36 |
37 //#undef NDEBUG | 37 #undef NDEBUG |
38 //#include <assert.h> | 38 #include <assert.h> |
39 | 39 |
40 #ifdef CONFIG_ENCODERS | 40 #ifdef CONFIG_ENCODERS |
41 static void encode_picture(MpegEncContext *s, int picture_number); | 41 static void encode_picture(MpegEncContext *s, int picture_number); |
42 #endif //CONFIG_ENCODERS | 42 #endif //CONFIG_ENCODERS |
43 static void dct_unquantize_mpeg1_c(MpegEncContext *s, | 43 static void dct_unquantize_mpeg1_c(MpegEncContext *s, |
189 #ifdef CONFIG_ENCODERS | 189 #ifdef CONFIG_ENCODERS |
190 s->dct_quantize= dct_quantize_c; | 190 s->dct_quantize= dct_quantize_c; |
191 #endif | 191 #endif |
192 | 192 |
193 #ifdef HAVE_MMX | 193 #ifdef HAVE_MMX |
194 MPV_common_init_mmx(s); | 194 MPV_common_init_mmx(s); //FIXME dont pass mpegenccontext to these, rather use dspcontext |
195 #endif | 195 #endif |
196 #ifdef ARCH_ALPHA | 196 #ifdef ARCH_ALPHA |
197 MPV_common_init_axp(s); | 197 MPV_common_init_axp(s); |
198 #endif | 198 #endif |
199 #ifdef HAVE_MLIB | 199 #ifdef HAVE_MLIB |
277 CHECKED_ALLOCZ(pic->mb_mean , mb_array_size * sizeof(int8_t)) | 277 CHECKED_ALLOCZ(pic->mb_mean , mb_array_size * sizeof(int8_t)) |
278 CHECKED_ALLOCZ(pic->mb_cmp_score, mb_array_size * sizeof(int32_t)) | 278 CHECKED_ALLOCZ(pic->mb_cmp_score, mb_array_size * sizeof(int32_t)) |
279 } | 279 } |
280 | 280 |
281 CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check | 281 CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check |
282 CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t)) | 282 CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t)+3) //+3 for mpeg2 SIMD >>1 |
283 CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(int)) | 283 CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(int)) |
284 pic->mb_type= pic->mb_type_base + s->mb_stride+1; | 284 pic->mb_type= pic->mb_type_base + s->mb_stride+1; |
285 if(s->out_format == FMT_H264){ | 285 if(s->out_format == FMT_H264){ |
286 for(i=0; i<2; i++){ | 286 for(i=0; i<2; i++){ |
287 CHECKED_ALLOCZ(pic->motion_val[i], 2 * 16 * s->mb_num * sizeof(uint16_t)) | 287 CHECKED_ALLOCZ(pic->motion_val[i], 2 * 16 * s->mb_num * sizeof(uint16_t)) |
422 CHECKED_ALLOCZ(s->mb_type , mb_array_size * sizeof(uint8_t)) //needed for encoding | 422 CHECKED_ALLOCZ(s->mb_type , mb_array_size * sizeof(uint8_t)) //needed for encoding |
423 } | 423 } |
424 | 424 |
425 CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t)) | 425 CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t)) |
426 | 426 |
427 if (s->out_format == FMT_H263 || s->encoding) { | 427 if (s->out_format == FMT_H263 || s->encoding || 1) { |
428 int size; | 428 int size; |
429 | 429 |
430 /* MV prediction */ | 430 /* MV prediction */ |
431 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); | 431 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); |
432 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(int16_t)); | 432 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(int16_t)); |
579 s->chroma_elim_threshold= avctx->chroma_elim_threshold; | 579 s->chroma_elim_threshold= avctx->chroma_elim_threshold; |
580 s->strict_std_compliance= avctx->strict_std_compliance; | 580 s->strict_std_compliance= avctx->strict_std_compliance; |
581 s->data_partitioning= avctx->flags & CODEC_FLAG_PART; | 581 s->data_partitioning= avctx->flags & CODEC_FLAG_PART; |
582 s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; | 582 s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; |
583 s->mpeg_quant= avctx->mpeg_quant; | 583 s->mpeg_quant= avctx->mpeg_quant; |
584 | 584 |
585 if (s->gop_size <= 1) { | 585 if (s->gop_size <= 1) { |
586 s->intra_only = 1; | 586 s->intra_only = 1; |
587 s->gop_size = 12; | 587 s->gop_size = 12; |
588 } else { | 588 } else { |
589 s->intra_only = 0; | 589 s->intra_only = 0; |
616 if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){ | 616 if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){ |
617 fprintf(stderr, "data partitioning not supporetd by codec\n"); | 617 fprintf(stderr, "data partitioning not supporetd by codec\n"); |
618 return -1; | 618 return -1; |
619 } | 619 } |
620 | 620 |
621 if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO){ | 621 if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){ |
622 fprintf(stderr, "b frames not supporetd by codec\n"); | 622 fprintf(stderr, "b frames not supporetd by codec\n"); |
623 return -1; | 623 return -1; |
624 } | 624 } |
625 | 625 /* |
626 if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too | 626 if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too |
627 fprintf(stderr, "mpeg2 style quantization not supporetd by codec\n"); | 627 fprintf(stderr, "mpeg2 style quantization not supporetd by codec\n"); |
628 return -1; | 628 return -1; |
629 } | 629 } |
630 | 630 */ |
631 if(s->codec_id==CODEC_ID_MJPEG){ | 631 if(s->codec_id==CODEC_ID_MJPEG){ |
632 s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x | 632 s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x |
633 s->inter_quant_bias= 0; | 633 s->inter_quant_bias= 0; |
634 }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO){ | 634 }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO){ |
635 s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x | 635 s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x |
636 s->inter_quant_bias= 0; | 636 s->inter_quant_bias= 0; |
637 }else{ | 637 }else{ |
638 s->intra_quant_bias=0; | 638 s->intra_quant_bias=0; |
639 s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x | 639 s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x |
649 switch(avctx->codec->id) { | 649 switch(avctx->codec->id) { |
650 case CODEC_ID_MPEG1VIDEO: | 650 case CODEC_ID_MPEG1VIDEO: |
651 s->out_format = FMT_MPEG1; | 651 s->out_format = FMT_MPEG1; |
652 s->low_delay= 0; //s->max_b_frames ? 0 : 1; | 652 s->low_delay= 0; //s->max_b_frames ? 0 : 1; |
653 avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1); | 653 avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1); |
654 break; | |
655 case CODEC_ID_MPEG2VIDEO: | |
656 s->out_format = FMT_MPEG1; | |
657 s->low_delay= 0; //s->max_b_frames ? 0 : 1; | |
658 avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1); | |
659 s->rtp_mode= 1; // mpeg2 must have slices | |
660 if(s->rtp_payload_size == 0) s->rtp_payload_size= 256*256*256; | |
654 break; | 661 break; |
655 case CODEC_ID_LJPEG: | 662 case CODEC_ID_LJPEG: |
656 case CODEC_ID_MJPEG: | 663 case CODEC_ID_MJPEG: |
657 s->out_format = FMT_MJPEG; | 664 s->out_format = FMT_MJPEG; |
658 s->intra_only = 1; /* force intra only for jpeg */ | 665 s->intra_only = 1; /* force intra only for jpeg */ |
818 }else if(s->out_format == FMT_H263){ | 825 }else if(s->out_format == FMT_H263){ |
819 s->intra_matrix[j] = | 826 s->intra_matrix[j] = |
820 s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; | 827 s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; |
821 }else | 828 }else |
822 #endif | 829 #endif |
823 { /* mpeg1 */ | 830 { /* mpeg1/2 */ |
824 s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i]; | 831 s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i]; |
825 s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; | 832 s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; |
826 } | 833 } |
827 if(s->avctx->intra_matrix) | 834 if(s->avctx->intra_matrix) |
828 s->intra_matrix[j] = s->avctx->intra_matrix[i]; | 835 s->intra_matrix[j] = s->avctx->intra_matrix[i]; |
1000 if(s->current_picture_ptr) | 1007 if(s->current_picture_ptr) |
1001 pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; | 1008 pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; |
1002 | 1009 |
1003 if( alloc_picture(s, (Picture*)pic, 0) < 0) | 1010 if( alloc_picture(s, (Picture*)pic, 0) < 0) |
1004 return -1; | 1011 return -1; |
1012 assert(pic->data[0]); | |
1005 | 1013 |
1006 s->current_picture_ptr= &s->picture[i]; | 1014 s->current_picture_ptr= &s->picture[i]; |
1007 } | 1015 } |
1008 | 1016 |
1009 s->current_picture_ptr->pict_type= s->pict_type; | 1017 s->current_picture_ptr->pict_type= s->pict_type; |
1046 s->hurry_up= s->avctx->hurry_up; | 1054 s->hurry_up= s->avctx->hurry_up; |
1047 s->error_resilience= avctx->error_resilience; | 1055 s->error_resilience= avctx->error_resilience; |
1048 | 1056 |
1049 /* set dequantizer, we cant do it during init as it might change for mpeg4 | 1057 /* set dequantizer, we cant do it during init as it might change for mpeg4 |
1050 and we cant do it in the header decode as init isnt called for mpeg4 there yet */ | 1058 and we cant do it in the header decode as init isnt called for mpeg4 there yet */ |
1051 if(s->out_format == FMT_H263){ | 1059 if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO) |
1052 if(s->mpeg_quant) | 1060 s->dct_unquantize = s->dct_unquantize_mpeg2; |
1053 s->dct_unquantize = s->dct_unquantize_mpeg2; | 1061 else if(s->out_format == FMT_H263) |
1054 else | 1062 s->dct_unquantize = s->dct_unquantize_h263; |
1055 s->dct_unquantize = s->dct_unquantize_h263; | 1063 else |
1056 }else | |
1057 s->dct_unquantize = s->dct_unquantize_mpeg1; | 1064 s->dct_unquantize = s->dct_unquantize_mpeg1; |
1058 | 1065 |
1059 #ifdef HAVE_XVMC | 1066 #ifdef HAVE_XVMC |
1060 if(s->avctx->xvmc_acceleration) | 1067 if(s->avctx->xvmc_acceleration) |
1061 return XVMC_field_start(s, avctx); | 1068 return XVMC_field_start(s, avctx); |
1072 //just to make sure that all data is rendered. | 1079 //just to make sure that all data is rendered. |
1073 if(s->avctx->xvmc_acceleration){ | 1080 if(s->avctx->xvmc_acceleration){ |
1074 XVMC_field_end(s); | 1081 XVMC_field_end(s); |
1075 }else | 1082 }else |
1076 #endif | 1083 #endif |
1077 if(s->codec_id!=CODEC_ID_SVQ1 && s->codec_id != CODEC_ID_MPEG1VIDEO){ | 1084 if(s->codec_id!=CODEC_ID_SVQ1 && s->out_format != FMT_MPEG1){ |
1078 if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { | 1085 if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { |
1079 draw_edges(s->current_picture.data[0], s->linesize , s->h_edge_pos , s->v_edge_pos , EDGE_WIDTH ); | 1086 draw_edges(s->current_picture.data[0], s->linesize , s->h_edge_pos , s->v_edge_pos , EDGE_WIDTH ); |
1080 draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); | 1087 draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); |
1081 draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); | 1088 draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); |
1082 } | 1089 } |
2343 0,dmv_pix_op, | 2350 0,dmv_pix_op, |
2344 s->mv[dir][2][0],s->mv[dir][2][1],16); | 2351 s->mv[dir][2][0],s->mv[dir][2][1],16); |
2345 } | 2352 } |
2346 } | 2353 } |
2347 break; | 2354 break; |
2348 | 2355 default: |
2356 printf("X"); | |
2349 } | 2357 } |
2350 } | 2358 } |
2351 | 2359 |
2352 | 2360 |
2353 /* put block[] to dest[] */ | 2361 /* put block[] to dest[] */ |
2521 | 2529 |
2522 /* skip dequant / idct if we are really late ;) */ | 2530 /* skip dequant / idct if we are really late ;) */ |
2523 if(s->hurry_up>1) return; | 2531 if(s->hurry_up>1) return; |
2524 | 2532 |
2525 /* add dct residue */ | 2533 /* add dct residue */ |
2526 if(s->encoding || !( s->mpeg2 || s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO | 2534 if(s->encoding || !( s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO |
2527 || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){ | 2535 || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){ |
2528 add_dequant_dct(s, block[0], 0, dest_y, dct_linesize); | 2536 add_dequant_dct(s, block[0], 0, dest_y, dct_linesize); |
2529 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize); | 2537 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize); |
2530 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); | 2538 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); |
2531 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); | 2539 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); |
2550 ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr); | 2558 ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr); |
2551 } | 2559 } |
2552 #endif | 2560 #endif |
2553 } else { | 2561 } else { |
2554 /* dct only in intra block */ | 2562 /* dct only in intra block */ |
2555 if(s->encoding || !(s->mpeg2 || s->codec_id==CODEC_ID_MPEG1VIDEO)){ | 2563 if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){ |
2556 put_dct(s, block[0], 0, dest_y, dct_linesize); | 2564 put_dct(s, block[0], 0, dest_y, dct_linesize); |
2557 put_dct(s, block[1], 1, dest_y + 8, dct_linesize); | 2565 put_dct(s, block[1], 1, dest_y + 8, dct_linesize); |
2558 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); | 2566 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); |
2559 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); | 2567 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); |
2560 | 2568 |
2995 } | 3003 } |
2996 }else{ | 3004 }else{ |
2997 for(i=0;i<6;i++) { | 3005 for(i=0;i<6;i++) { |
2998 if(!skip_dct[i]){ | 3006 if(!skip_dct[i]){ |
2999 int overflow; | 3007 int overflow; |
3008 START_TIMER; | |
3000 s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow); | 3009 s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow); |
3010 STOP_TIMER("dct_quant"); | |
3001 // FIXME we could decide to change to quantizer instead of clipping | 3011 // FIXME we could decide to change to quantizer instead of clipping |
3002 // JS: I don't think that would be a good idea it could lower quality instead | 3012 // JS: I don't think that would be a good idea it could lower quality instead |
3003 // of improve it. Just INTRADC clipping deserves changes in quantizer | 3013 // of improve it. Just INTRADC clipping deserves changes in quantizer |
3004 if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); | 3014 if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); |
3005 }else | 3015 }else |
3021 } | 3031 } |
3022 | 3032 |
3023 /* huffman encode */ | 3033 /* huffman encode */ |
3024 switch(s->codec_id){ //FIXME funct ptr could be slightly faster | 3034 switch(s->codec_id){ //FIXME funct ptr could be slightly faster |
3025 case CODEC_ID_MPEG1VIDEO: | 3035 case CODEC_ID_MPEG1VIDEO: |
3036 case CODEC_ID_MPEG2VIDEO: | |
3026 mpeg1_encode_mb(s, s->block, motion_x, motion_y); break; | 3037 mpeg1_encode_mb(s, s->block, motion_x, motion_y); break; |
3027 #ifdef CONFIG_RISKY | 3038 #ifdef CONFIG_RISKY |
3028 case CODEC_ID_MPEG4: | 3039 case CODEC_ID_MPEG4: |
3029 mpeg4_encode_mb(s, s->block, motion_x, motion_y); break; | 3040 mpeg4_encode_mb(s, s->block, motion_x, motion_y); break; |
3030 case CODEC_ID_MSMPEG4V2: | 3041 case CODEC_ID_MSMPEG4V2: |
3314 s->current_picture.mc_mb_var_sum = 0; | 3325 s->current_picture.mc_mb_var_sum = 0; |
3315 | 3326 |
3316 #ifdef CONFIG_RISKY | 3327 #ifdef CONFIG_RISKY |
3317 /* we need to initialize some time vars before we can encode b-frames */ | 3328 /* we need to initialize some time vars before we can encode b-frames */ |
3318 // RAL: Condition added for MPEG1VIDEO | 3329 // RAL: Condition added for MPEG1VIDEO |
3319 if (s->codec_id == CODEC_ID_MPEG1VIDEO || (s->h263_pred && !s->h263_msmpeg4)) | 3330 //FIXME figure out why mpeg1/2 need this !!! |
3331 if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4)) | |
3320 ff_set_mpeg4_time(s, s->picture_number); | 3332 ff_set_mpeg4_time(s, s->picture_number); |
3321 #endif | 3333 #endif |
3322 | 3334 |
3323 s->scene_change_score=0; | 3335 s->scene_change_score=0; |
3324 | 3336 |
3560 s->mb_x = mb_x; | 3572 s->mb_x = mb_x; |
3561 ff_update_block_index(s); | 3573 ff_update_block_index(s); |
3562 | 3574 |
3563 /* write gob / video packet header */ | 3575 /* write gob / video packet header */ |
3564 #ifdef CONFIG_RISKY | 3576 #ifdef CONFIG_RISKY |
3565 if(s->rtp_mode){ | 3577 if(s->rtp_mode && mb_y + mb_x>0){ |
3566 int current_packet_size, is_gob_start; | 3578 int current_packet_size, is_gob_start; |
3567 | 3579 |
3568 current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob; | 3580 current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob; |
3569 is_gob_start=0; | 3581 is_gob_start=0; |
3570 | 3582 |
3571 if(s->codec_id==CODEC_ID_MPEG4){ | 3583 if(s->codec_id==CODEC_ID_MPEG4){ |
3572 if(current_packet_size >= s->rtp_payload_size | 3584 if(current_packet_size >= s->rtp_payload_size){ |
3573 && s->mb_y + s->mb_x>0){ | |
3574 | 3585 |
3575 if(s->partitioned_frame){ | 3586 if(s->partitioned_frame){ |
3576 ff_mpeg4_merge_partitions(s); | 3587 ff_mpeg4_merge_partitions(s); |
3577 ff_mpeg4_init_partitions(s); | 3588 ff_mpeg4_init_partitions(s); |
3578 } | 3589 } |
3586 ff_mpeg4_clean_buffers(s); | 3597 ff_mpeg4_clean_buffers(s); |
3587 is_gob_start=1; | 3598 is_gob_start=1; |
3588 } | 3599 } |
3589 }else if(s->codec_id==CODEC_ID_MPEG1VIDEO){ | 3600 }else if(s->codec_id==CODEC_ID_MPEG1VIDEO){ |
3590 if( current_packet_size >= s->rtp_payload_size | 3601 if( current_packet_size >= s->rtp_payload_size |
3591 && s->mb_y + s->mb_x>0 && s->mb_skip_run==0){ | 3602 && s->mb_skip_run==0){ |
3603 ff_mpeg1_encode_slice_header(s); | |
3604 ff_mpeg1_clean_buffers(s); | |
3605 is_gob_start=1; | |
3606 } | |
3607 }else if(s->codec_id==CODEC_ID_MPEG2VIDEO){ | |
3608 if( ( current_packet_size >= s->rtp_payload_size || mb_x==0) | |
3609 && s->mb_skip_run==0){ | |
3592 ff_mpeg1_encode_slice_header(s); | 3610 ff_mpeg1_encode_slice_header(s); |
3593 ff_mpeg1_clean_buffers(s); | 3611 ff_mpeg1_clean_buffers(s); |
3594 is_gob_start=1; | 3612 is_gob_start=1; |
3595 } | 3613 } |
3596 }else{ | 3614 }else{ |
3597 if(current_packet_size >= s->rtp_payload_size | 3615 if(current_packet_size >= s->rtp_payload_size |
3598 && s->mb_x==0 && s->mb_y>0 && s->mb_y%s->gob_index==0){ | 3616 && s->mb_x==0 && s->mb_y%s->gob_index==0){ |
3599 | 3617 |
3600 h263_encode_gob_header(s, mb_y); | 3618 h263_encode_gob_header(s, mb_y); |
3601 is_gob_start=1; | 3619 is_gob_start=1; |
3602 } | 3620 } |
3603 } | 3621 } |
3998 /* note: block[0] is assumed to be positive */ | 4016 /* note: block[0] is assumed to be positive */ |
3999 block[0] = (block[0] + (q >> 1)) / q; | 4017 block[0] = (block[0] + (q >> 1)) / q; |
4000 start_i = 1; | 4018 start_i = 1; |
4001 last_non_zero = 0; | 4019 last_non_zero = 0; |
4002 qmat = s->q_intra_matrix[qscale]; | 4020 qmat = s->q_intra_matrix[qscale]; |
4003 if(s->mpeg_quant || s->codec_id== CODEC_ID_MPEG1VIDEO) | 4021 if(s->mpeg_quant) |
4004 bias= 1<<(QMAT_SHIFT-1); | 4022 bias= 1<<(QMAT_SHIFT-1); |
4005 length = s->intra_ac_vlc_length; | 4023 length = s->intra_ac_vlc_length; |
4006 last_length= s->intra_ac_vlc_last_length; | 4024 last_length= s->intra_ac_vlc_last_length; |
4007 } else { | 4025 } else { |
4008 start_i = 0; | 4026 start_i = 0; |
4527 MPV_encode_end, | 4545 MPV_encode_end, |
4528 }; | 4546 }; |
4529 | 4547 |
4530 #ifdef CONFIG_RISKY | 4548 #ifdef CONFIG_RISKY |
4531 | 4549 |
4550 AVCodec mpeg2video_encoder = { | |
4551 "mpeg2video", | |
4552 CODEC_TYPE_VIDEO, | |
4553 CODEC_ID_MPEG2VIDEO, | |
4554 sizeof(MpegEncContext), | |
4555 MPV_encode_init, | |
4556 MPV_encode_picture, | |
4557 MPV_encode_end, | |
4558 }; | |
4559 | |
4532 AVCodec h263_encoder = { | 4560 AVCodec h263_encoder = { |
4533 "h263", | 4561 "h263", |
4534 CODEC_TYPE_VIDEO, | 4562 CODEC_TYPE_VIDEO, |
4535 CODEC_ID_H263, | 4563 CODEC_ID_H263, |
4536 sizeof(MpegEncContext), | 4564 sizeof(MpegEncContext), |