Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: patched-ffmpeg-mt/libavcodec/h263dec.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * H.263 decoder 2 * H.263 decoder
3 * Copyright (c) 2001 Fabrice Bellard 3 * Copyright (c) 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> 4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 * 5 *
6 * This file is part of FFmpeg. 6 * This file is part of FFmpeg.
7 * 7 *
8 * FFmpeg is free software; you can redistribute it and/or 8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if(v==0x7F && bits_left<=8) 283 if(v==0x7F && bits_left<=8)
284 s->padding_bug_score--; 284 s->padding_bug_score--;
285 else if(v==0x7F && ((get_bits_count(&s->gb)+8)&8) && bits_left<=16) 285 else if(v==0x7F && ((get_bits_count(&s->gb)+8)&8) && bits_left<=16)
286 s->padding_bug_score+= 4; 286 s->padding_bug_score+= 4;
287 else 287 else
288 s->padding_bug_score++; 288 s->padding_bug_score++;
289 } 289 }
290 } 290 }
291 291
292 if(s->workaround_bugs&FF_BUG_AUTODETECT){ 292 if(s->workaround_bugs&FF_BUG_AUTODETECT){
293 if(s->padding_bug_score > -2 && !s->data_partitioning /*&& (s->divx_vers ion || !s->resync_marker)*/) 293 if(s->padding_bug_score > -2 && !s->data_partitioning /*&& (s->divx_vers ion>=0 || !s->resync_marker)*/)
294 s->workaround_bugs |= FF_BUG_NO_PADDING; 294 s->workaround_bugs |= FF_BUG_NO_PADDING;
295 else 295 else
296 s->workaround_bugs &= ~FF_BUG_NO_PADDING; 296 s->workaround_bugs &= ~FF_BUG_NO_PADDING;
297 } 297 }
298 298
299 // handle formats which don't have unique end markers 299 // handle formats which don't have unique end markers
300 if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME pe rhaps solve this more cleanly 300 if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME pe rhaps solve this more cleanly
301 int left= get_bits_left(&s->gb); 301 int left= get_bits_left(&s->gb);
302 int max_extra=7; 302 int max_extra=7;
303 303
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size); 421 if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
422 422
423 /* skip if the header was thrashed */ 423 /* skip if the header was thrashed */
424 if (ret < 0){ 424 if (ret < 0){
425 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); 425 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
426 return -1; 426 return -1;
427 } 427 }
428 428
429 avctx->has_b_frames= !s->low_delay; 429 avctx->has_b_frames= !s->low_delay;
430 430
431 if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){ 431 if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
432 if(s->stream_codec_tag == AV_RL32("XVID") || 432 if(s->stream_codec_tag == AV_RL32("XVID") ||
433 s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") || 433 s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
434 s->codec_tag == AV_RL32("RMP4")) 434 s->codec_tag == AV_RL32("RMP4"))
435 s->xvid_build= -1; 435 s->xvid_build= 0;
436 #if 0 436 #if 0
437 if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_pa rameters==1 437 if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_pa rameters==1
438 && s->padding_bug_score > 0 && s->low_delay) // XVID with modified fo urcc 438 && s->padding_bug_score > 0 && s->low_delay) // XVID with modified fo urcc
439 s->xvid_build= -1; 439 s->xvid_build= 0;
440 #endif 440 #endif
441 } 441 }
442 442
443 if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){ 443 if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
444 if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_pa rameters==0) 444 if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_pa rameters==0)
445 s->divx_version= 400; //divx 4 445 s->divx_version= 400; //divx 4
446 } 446 }
447 447
448 if(s->xvid_build && s->divx_version){ 448 if(s->xvid_build>=0 && s->divx_version>=0){
449 s->divx_version= 449 s->divx_version=
450 s->divx_build= 0; 450 s->divx_build= -1;
451 } 451 }
452 452
453 if(s->workaround_bugs&FF_BUG_AUTODETECT){ 453 if(s->workaround_bugs&FF_BUG_AUTODETECT){
454 if(s->codec_tag == AV_RL32("XVIX")) 454 if(s->codec_tag == AV_RL32("XVIX"))
455 s->workaround_bugs|= FF_BUG_XVID_ILACE; 455 s->workaround_bugs|= FF_BUG_XVID_ILACE;
456 456
457 if(s->codec_tag == AV_RL32("UMP4")){ 457 if(s->codec_tag == AV_RL32("UMP4")){
458 s->workaround_bugs|= FF_BUG_UMP4; 458 s->workaround_bugs|= FF_BUG_UMP4;
459 } 459 }
460 460
461 if(s->divx_version>=500 && s->divx_build<1814){ 461 if(s->divx_version>=500 && s->divx_build<1814){
462 s->workaround_bugs|= FF_BUG_QPEL_CHROMA; 462 s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
463 } 463 }
464 464
465 if(s->divx_version>502 && s->divx_build<1814){ 465 if(s->divx_version>502 && s->divx_build<1814){
466 s->workaround_bugs|= FF_BUG_QPEL_CHROMA2; 466 s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
467 } 467 }
468 468
469 if(s->xvid_build && s->xvid_build<=3) 469 if(s->xvid_build<=3U)
470 s->padding_bug_score= 256*256*256*64; 470 s->padding_bug_score= 256*256*256*64;
471 471
472 if(s->xvid_build && s->xvid_build<=1) 472 if(s->xvid_build<=1U)
473 s->workaround_bugs|= FF_BUG_QPEL_CHROMA; 473 s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
474 474
475 if(s->xvid_build && s->xvid_build<=12) 475 if(s->xvid_build<=12U)
476 s->workaround_bugs|= FF_BUG_EDGE; 476 s->workaround_bugs|= FF_BUG_EDGE;
477 477
478 if(s->xvid_build && s->xvid_build<=32) 478 if(s->xvid_build<=32U)
479 s->workaround_bugs|= FF_BUG_DC_CLIP; 479 s->workaround_bugs|= FF_BUG_DC_CLIP;
480 480
481 #define SET_QPEL_FUNC(postfix1, postfix2) \ 481 #define SET_QPEL_FUNC(postfix1, postfix2) \
482 s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ 482 s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
483 s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ 483 s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
484 s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; 484 s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
485 485
486 if(s->lavc_build && s->lavc_build<4653) 486 if(s->lavc_build<4653U)
487 s->workaround_bugs|= FF_BUG_STD_QPEL; 487 s->workaround_bugs|= FF_BUG_STD_QPEL;
488 488
489 if(s->lavc_build && s->lavc_build<4655) 489 if(s->lavc_build<4655U)
490 s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE; 490 s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
491 491
492 if(s->lavc_build && s->lavc_build<4670){ 492 if(s->lavc_build<4670U){
493 s->workaround_bugs|= FF_BUG_EDGE; 493 s->workaround_bugs|= FF_BUG_EDGE;
494 } 494 }
495 495
496 if(s->lavc_build && s->lavc_build<=4712) 496 if(s->lavc_build<=4712U)
497 s->workaround_bugs|= FF_BUG_DC_CLIP; 497 s->workaround_bugs|= FF_BUG_DC_CLIP;
498 498
499 if(s->divx_version) 499 if(s->divx_version>=0)
500 s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE; 500 s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
501 //printf("padding_bug_score: %d\n", s->padding_bug_score); 501 //printf("padding_bug_score: %d\n", s->padding_bug_score);
502 if(s->divx_version==501 && s->divx_build==20020416) 502 if(s->divx_version==501 && s->divx_build==20020416)
503 s->padding_bug_score= 256*256*256*64; 503 s->padding_bug_score= 256*256*256*64;
504 504
505 if(s->divx_version && s->divx_version<500){ 505 if(s->divx_version<500U){
506 s->workaround_bugs|= FF_BUG_EDGE; 506 s->workaround_bugs|= FF_BUG_EDGE;
507 } 507 }
508 508
509 if(s->divx_version) 509 if(s->divx_version>=0)
510 s->workaround_bugs|= FF_BUG_HPEL_CHROMA; 510 s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
511 #if 0 511 #if 0
512 if(s->divx_version==500) 512 if(s->divx_version==500)
513 s->padding_bug_score= 256*256*256*64; 513 s->padding_bug_score= 256*256*256*64;
514 514
515 /* very ugly XVID padding bug detection FIXME/XXX solve this differently 515 /* very ugly XVID padding bug detection FIXME/XXX solve this differently
516 * Let us hope this at least works. 516 * Let us hope this at least works.
517 */ 517 */
518 if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version= =0 518 if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version= =-1
519 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) 519 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0)
520 s->workaround_bugs|= FF_BUG_NO_PADDING; 520 s->workaround_bugs|= FF_BUG_NO_PADDING;
521 521
522 if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the versi on num but a 4609 file seems ok 522 if(s->lavc_build<4609U) //FIXME not sure about the version num but a 460 9 file seems ok
523 s->workaround_bugs|= FF_BUG_NO_PADDING; 523 s->workaround_bugs|= FF_BUG_NO_PADDING;
524 #endif 524 #endif
525 } 525 }
526 526
527 if(s->workaround_bugs& FF_BUG_STD_QPEL){ 527 if(s->workaround_bugs& FF_BUG_STD_QPEL){
528 SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) 528 SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
529 SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) 529 SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
530 SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) 530 SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
531 SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) 531 SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
532 SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) 532 SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
(...skipping 14 matching lines...) Expand all
547 547
548 #if 0 // dump bits per frame / qp / complexity 548 #if 0 // dump bits per frame / qp / complexity
549 { 549 {
550 static FILE *f=NULL; 550 static FILE *f=NULL;
551 if(!f) f=fopen("rate_qp_cplx.txt", "w"); 551 if(!f) f=fopen("rate_qp_cplx.txt", "w");
552 fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale); 552 fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale);
553 } 553 }
554 #endif 554 #endif
555 555
556 #if HAVE_MMX 556 #if HAVE_MMX
557 if(s->codec_id == CODEC_ID_MPEG4 && s->xvid_build && avctx->idct_algo == FF_ IDCT_AUTO && (mm_flags & FF_MM_MMX)){ 557 if(s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (mm_flags & FF_MM_MMX)){
558 avctx->idct_algo= FF_IDCT_XVIDMMX; 558 avctx->idct_algo= FF_IDCT_XVIDMMX;
559 avctx->coded_width= 0; // force reinit 559 avctx->coded_width= 0; // force reinit
560 // dsputil_init(&s->dsp, avctx); 560 // dsputil_init(&s->dsp, avctx);
561 s->picture_number=0; 561 s->picture_number=0;
562 } 562 }
563 #endif 563 #endif
564 564
565 /* After H263 & mpeg4 header decode we have the height, width,*/ 565 /* After H263 & mpeg4 header decode we have the height, width,*/
566 /* and other parameters. So then we could init the picture */ 566 /* and other parameters. So then we could init the picture */
567 /* FIXME: By the way H263 decoder is evolving it should have */ 567 /* FIXME: By the way H263 decoder is evolving it should have */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab; 616 s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
617 s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; 617 s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
618 } 618 }
619 619
620 if(MPV_frame_start(s, avctx) < 0) 620 if(MPV_frame_start(s, avctx) < 0)
621 return -1; 621 return -1;
622 622
623 if (!s->divx_packed) ff_thread_finish_setup(avctx); 623 if (!s->divx_packed) ff_thread_finish_setup(avctx);
624 624
625 if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP _HWACCEL_VDPAU)) { 625 if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP _HWACCEL_VDPAU)) {
626 ff_vdpau_mpeg4_decode_picture(s, buf, buf_size); 626 ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb. buffer);
627 goto frame_end; 627 goto frame_end;
628 } 628 }
629 629
630 if (avctx->hwaccel) { 630 if (avctx->hwaccel) {
631 if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0) 631 if (avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer) < 0)
632 return -1; 632 return -1;
633 } 633 }
634 634
635 ff_er_frame_start(s); 635 ff_er_frame_start(s);
636 636
637 //the second part of the wmv2 header contains the MB skip bits which are sto red in current_picture->mb_type 637 //the second part of the wmv2 header contains the MB skip bits which are sto red in current_picture->mb_type
638 //which is not available before MPV_frame_start() 638 //which is not available before MPV_frame_start()
639 if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){ 639 if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
640 ret = ff_wmv2_decode_secondary_picture_header(s); 640 ret = ff_wmv2_decode_secondary_picture_header(s);
641 if(ret<0) return ret; 641 if(ret<0) return ret;
(...skipping 19 matching lines...) Expand all
661 661
662 decode_slice(s); 662 decode_slice(s);
663 } 663 }
664 664
665 if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==FF_I_TYPE) 665 if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==FF_I_TYPE)
666 if(!CONFIG_MSMPEG4_DECODER || msmpeg4_decode_ext_header(s, buf_size) < 0 ){ 666 if(!CONFIG_MSMPEG4_DECODER || msmpeg4_decode_ext_header(s, buf_size) < 0 ){
667 s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; 667 s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR;
668 } 668 }
669 669
670 assert(s->bitstream_buffer_size==0); 670 assert(s->bitstream_buffer_size==0);
671 frame_end:
671 /* divx 5.01+ bistream reorder stuff */ 672 /* divx 5.01+ bistream reorder stuff */
672 if(s->codec_id==CODEC_ID_MPEG4 && s->divx_packed){ 673 if(s->codec_id==CODEC_ID_MPEG4 && s->divx_packed){
673 int current_pos= get_bits_count(&s->gb)>>3; 674 int current_pos= get_bits_count(&s->gb)>>3;
674 int startcode_found=0; 675 int startcode_found=0;
675 676
676 if(buf_size - current_pos > 5){ 677 if(buf_size - current_pos > 5){
677 int i; 678 int i;
678 for(i=current_pos; i<buf_size-3; i++){ 679 for(i=current_pos; i<buf_size-3; i++){
679 if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ 680 if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
680 startcode_found=1; 681 startcode_found=1;
681 break; 682 break;
682 } 683 }
683 } 684 }
684 } 685 }
685 if(s->gb.buffer == s->bitstream_buffer && buf_size>7 && s->xvid_build){ //xvid style 686 if(s->gb.buffer == s->bitstream_buffer && buf_size>7 && s->xvid_build>=0 ){ //xvid style
686 startcode_found=1; 687 startcode_found=1;
687 current_pos=0; 688 current_pos=0;
688 } 689 }
689 690
690 if(startcode_found){ 691 if(startcode_found){
691 av_fast_malloc( 692 av_fast_malloc(
692 &s->bitstream_buffer, 693 &s->bitstream_buffer,
693 &s->allocated_bitstream_buffer_size, 694 &s->allocated_bitstream_buffer_size,
694 buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE); 695 buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
695 if (!s->bitstream_buffer) 696 if (!s->bitstream_buffer)
696 return AVERROR(ENOMEM); 697 return AVERROR(ENOMEM);
697 memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_po s); 698 memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_po s);
698 s->bitstream_buffer_size= buf_size - current_pos; 699 s->bitstream_buffer_size= buf_size - current_pos;
699 } 700 }
700 } 701 }
701 702
702 intrax8_decoded: 703 intrax8_decoded:
703 ff_er_frame_end(s); 704 ff_er_frame_end(s);
704 705
705 frame_end:
706 if (avctx->hwaccel) { 706 if (avctx->hwaccel) {
707 if (avctx->hwaccel->end_frame(avctx) < 0) 707 if (avctx->hwaccel->end_frame(avctx) < 0)
708 return -1; 708 return -1;
709 } 709 }
710 710
711 MPV_frame_end(s); 711 MPV_frame_end(s);
712 712
713 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); 713 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
714 assert(s->current_picture.pict_type == s->pict_type); 714 assert(s->current_picture.pict_type == s->pict_type);
715 if (s->pict_type == FF_B_TYPE || s->low_delay) { 715 if (s->pict_type == FF_B_TYPE || s->low_delay) {
(...skipping 21 matching lines...) Expand all
737 sizeof(MpegEncContext), 737 sizeof(MpegEncContext),
738 ff_h263_decode_init, 738 ff_h263_decode_init,
739 NULL, 739 NULL,
740 ff_h263_decode_end, 740 ff_h263_decode_end,
741 ff_h263_decode_frame, 741 ff_h263_decode_frame,
742 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_ DELAY, 742 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_ DELAY,
743 .flush= ff_mpeg_flush, 743 .flush= ff_mpeg_flush,
744 .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), 744 .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
745 .pix_fmts= ff_hwaccel_pixfmt_list_420, 745 .pix_fmts= ff_hwaccel_pixfmt_list_420,
746 }; 746 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698