~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/mpeg4videodec.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
};
47
47
 
48
48
/**
49
 
 * predicts the ac.
 
49
 * Predict the ac.
50
50
 * @param n block index (0-3 are luma, 4-5 are chroma)
51
51
 * @param dir the ac prediction direction
52
52
 */
55
55
{
56
56
    int i;
57
57
    int16_t *ac_val, *ac_val1;
58
 
    int8_t * const qscale_table= s->current_picture.qscale_table;
 
58
    int8_t * const qscale_table = s->current_picture.f.qscale_table;
59
59
 
60
60
    /* find prediction */
61
61
    ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
343
343
}
344
344
 
345
345
/**
346
 
 * decodes the next video packet.
 
346
 * Decode the next video packet.
347
347
 * @return <0 if something went wrong
348
348
 */
349
349
int mpeg4_decode_video_packet_header(MpegEncContext *s)
376
376
    if(s->pict_type == AV_PICTURE_TYPE_B){
377
377
        int mb_x = 0, mb_y = 0;
378
378
 
379
 
        while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) {
 
379
        while (s->next_picture.f.mbskip_table[s->mb_index2xy[mb_num]]) {
380
380
            if (!mb_x) ff_thread_await_progress((AVFrame*)s->next_picture_ptr, mb_y++, 0);
381
381
            mb_num++;
382
382
            if (++mb_x == s->mb_width) mb_x = 0;
439
439
}
440
440
 
441
441
/**
442
 
 * gets the average motion vector for a GMC MB.
 
442
 * Get the average motion vector for a GMC MB.
443
443
 * @param n either 0 for the x component or 1 for y
444
444
 * @return the average MV for a GMC MB
445
445
 */
485
485
}
486
486
 
487
487
/**
488
 
 * decodes the dc value.
 
488
 * Decode the dc value.
489
489
 * @param n block index (0-3 are luma, 4-5 are chroma)
490
490
 * @param dir_ptr the prediction direction will be stored here
491
491
 * @return the quantized dc
520
520
 
521
521
        if (code > 8){
522
522
            if(get_bits1(&s->gb)==0){ /* marker */
523
 
                if(s->error_recognition>=2){
 
523
                if(s->err_recognition&AV_EF_BITSTREAM){
524
524
                    av_log(s->avctx, AV_LOG_ERROR, "dc marker bit missing\n");
525
525
                    return -1;
526
526
                }
532
532
}
533
533
 
534
534
/**
535
 
 * decodes first partition.
 
535
 * Decode first partition.
536
536
 * @return number of MBs decoded or <0 if an error occurred
537
537
 */
538
538
static int mpeg4_decode_partition_a(MpegEncContext *s){
570
570
                }while(cbpc == 8);
571
571
 
572
572
                s->cbp_table[xy]= cbpc & 3;
573
 
                s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
 
573
                s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
574
574
                s->mb_intra = 1;
575
575
 
576
576
                if(cbpc & 4) {
577
577
                    ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
578
578
                }
579
 
                s->current_picture.qscale_table[xy]= s->qscale;
 
579
                s->current_picture.f.qscale_table[xy]= s->qscale;
580
580
 
581
581
                s->mbintra_table[xy]= 1;
582
582
                for(i=0; i<6; i++){
592
592
                s->pred_dir_table[xy]= dir;
593
593
            }else{ /* P/S_TYPE */
594
594
                int mx, my, pred_x, pred_y, bits;
595
 
                int16_t * const mot_val= s->current_picture.motion_val[0][s->block_index[0]];
 
595
                int16_t * const mot_val = s->current_picture.f.motion_val[0][s->block_index[0]];
596
596
                const int stride= s->b8_stride*2;
597
597
 
598
598
try_again:
604
604
                if(bits&0x10000){
605
605
                    /* skip mb */
606
606
                    if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
607
 
                        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
 
607
                        s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
608
608
                        mx= get_amv(s, 0);
609
609
                        my= get_amv(s, 1);
610
610
                    }else{
611
 
                        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
 
611
                        s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
612
612
                        mx=my=0;
613
613
                    }
614
614
                    mot_val[0       ]= mot_val[2       ]=
634
634
                s->mb_intra = ((cbpc & 4) != 0);
635
635
 
636
636
                if(s->mb_intra){
637
 
                    s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
 
637
                    s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
638
638
                    s->mbintra_table[xy]= 1;
639
639
                    mot_val[0       ]= mot_val[2       ]=
640
640
                    mot_val[0+stride]= mot_val[2+stride]= 0;
660
660
                            my = h263_decode_motion(s, pred_y, s->f_code);
661
661
                            if (my >= 0xffff)
662
662
                                return -1;
663
 
                            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
 
663
                            s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
664
664
                        } else {
665
665
                            mx = get_amv(s, 0);
666
666
                            my = get_amv(s, 1);
667
 
                            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
 
667
                            s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
668
668
                        }
669
669
 
670
670
                        mot_val[0       ]= mot_val[2       ] =
673
673
                        mot_val[1+stride]= mot_val[3+stride]= my;
674
674
                    } else {
675
675
                        int i;
676
 
                        s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
 
676
                        s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
677
677
                        for(i=0;i<4;i++) {
678
678
                            int16_t *mot_val= h263_pred_motion(s, i, 0, &pred_x, &pred_y);
679
679
                            mx = h263_decode_motion(s, pred_x, s->f_code);
725
725
                }
726
726
 
727
727
                s->cbp_table[xy]|= cbpy<<2;
728
 
                s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
 
728
                s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
729
729
            }else{ /* P || S_TYPE */
730
 
                if(IS_INTRA(s->current_picture.mb_type[xy])){
 
730
                if (IS_INTRA(s->current_picture.f.mb_type[xy])) {
731
731
                    int dir=0,i;
732
732
                    int ac_pred = get_bits1(&s->gb);
733
733
                    int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
740
740
                    if(s->cbp_table[xy] & 8) {
741
741
                        ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
742
742
                    }
743
 
                    s->current_picture.qscale_table[xy]= s->qscale;
 
743
                    s->current_picture.f.qscale_table[xy] = s->qscale;
744
744
 
745
745
                    for(i=0; i<6; i++){
746
746
                        int dc_pred_dir;
754
754
                    }
755
755
                    s->cbp_table[xy]&= 3; //remove dquant
756
756
                    s->cbp_table[xy]|= cbpy<<2;
757
 
                    s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
 
757
                    s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
758
758
                    s->pred_dir_table[xy]= dir;
759
 
                }else if(IS_SKIP(s->current_picture.mb_type[xy])){
760
 
                    s->current_picture.qscale_table[xy]= s->qscale;
 
759
                } else if (IS_SKIP(s->current_picture.f.mb_type[xy])) {
 
760
                    s->current_picture.f.qscale_table[xy] = s->qscale;
761
761
                    s->cbp_table[xy]= 0;
762
762
                }else{
763
763
                    int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
770
770
                    if(s->cbp_table[xy] & 8) {
771
771
                        ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
772
772
                    }
773
 
                    s->current_picture.qscale_table[xy]= s->qscale;
 
773
                    s->current_picture.f.qscale_table[xy] = s->qscale;
774
774
 
775
775
                    s->cbp_table[xy]&= 3; //remove dquant
776
776
                    s->cbp_table[xy]|= (cbpy^0xf)<<2;
784
784
}
785
785
 
786
786
/**
787
 
 * decodes the first & second partition
 
787
 * Decode the first and second partition.
788
788
 * @return <0 if error (and sets error type in the error_status_table)
789
789
 */
790
790
int ff_mpeg4_decode_partitions(MpegEncContext *s)
791
791
{
792
792
    int mb_num;
793
 
    const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (DC_ERROR|MV_ERROR) : MV_ERROR;
794
 
    const int part_a_end  = s->pict_type==AV_PICTURE_TYPE_I ? (DC_END  |MV_END)   : MV_END;
 
793
    const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_ERROR|ER_MV_ERROR) : ER_MV_ERROR;
 
794
    const int part_a_end  = s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_END  |ER_MV_END)   : ER_MV_END;
795
795
 
796
796
    mb_num= mpeg4_decode_partition_a(s);
797
797
    if(mb_num<0){
826
826
 
827
827
    if( mpeg4_decode_partition_b(s, mb_num) < 0){
828
828
        if(s->pict_type==AV_PICTURE_TYPE_P)
829
 
            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, DC_ERROR);
 
829
            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_DC_ERROR);
830
830
        return -1;
831
831
    }else{
832
832
        if(s->pict_type==AV_PICTURE_TYPE_P)
833
 
            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, DC_END);
 
833
            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_DC_END);
834
834
    }
835
835
 
836
836
    return 0;
837
837
}
838
838
 
839
839
/**
840
 
 * decodes a block.
 
840
 * Decode a block.
841
841
 * @return <0 if an error occurred
842
842
 */
843
843
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
934
934
                }; SKIP_CACHE(re, &s->gb, 1);
935
935
 
936
936
                last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
937
 
                run=   SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
 
937
                run=   SHOW_UBITS(re, &s->gb, 6);
938
938
                SKIP_COUNTER(re, &s->gb, 1+1+6);
939
939
                UPDATE_CACHE(re, &s->gb);
940
940
 
951
951
                }; SKIP_CACHE(re, &s->gb, 5);
952
952
 
953
953
                level=  level * qmul + qadd;
954
 
                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_CACHE(re, &s->gb, 1);
 
954
                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
955
955
                SKIP_COUNTER(re, &s->gb, 1+11+5+1);
956
956
 
957
957
                i+= run + 1;
968
968
                    /* third escape */
969
969
                    SKIP_CACHE(re, &s->gb, 2);
970
970
                    last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
971
 
                    run=   SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
 
971
                    run=   SHOW_UBITS(re, &s->gb, 6);
972
972
                    SKIP_COUNTER(re, &s->gb, 2+1+6);
973
973
                    UPDATE_CACHE(re, &s->gb);
974
974
 
985
985
                        if(SHOW_UBITS(re, &s->gb, 1)==0){
986
986
                            av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in 3. esc\n");
987
987
                            return -1;
988
 
                        }; LAST_SKIP_CACHE(re, &s->gb, 1);
 
988
                        }
989
989
 
990
990
                        SKIP_COUNTER(re, &s->gb, 1+12+1);
991
991
                    }
992
992
 
993
 
#if 0
994
 
                    if(s->error_recognition >= FF_ER_COMPLIANT){
995
 
                        const int abs_level= FFABS(level);
996
 
                        if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
997
 
                            const int run1= run - rl->max_run[last][abs_level] - 1;
998
 
                            if(abs_level <= rl->max_level[last][run]){
999
 
                                av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
1000
 
                                return -1;
1001
 
                            }
1002
 
                            if(s->error_recognition > FF_ER_COMPLIANT){
1003
 
                                if(abs_level <= rl->max_level[last][run]*2){
1004
 
                                    av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
1005
 
                                    return -1;
1006
 
                                }
1007
 
                                if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
1008
 
                                    av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
1009
 
                                    return -1;
1010
 
                                }
1011
 
                            }
1012
 
                        }
1013
 
                    }
1014
 
#endif
1015
993
                    if (level>0) level= level * qmul + qadd;
1016
994
                    else         level= level * qmul - qadd;
1017
995
 
1018
996
                    if((unsigned)(level + 2048) > 4095){
1019
 
                        if(s->error_recognition > FF_ER_COMPLIANT){
 
997
                        if(s->err_recognition & AV_EF_BITSTREAM){
1020
998
                            if(level > 2560 || level<-2560){
1021
999
                                av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
1022
1000
                                return -1;
1091
1069
    int cbp, mb_type;
1092
1070
    const int xy= s->mb_x + s->mb_y*s->mb_stride;
1093
1071
 
1094
 
    mb_type= s->current_picture.mb_type[xy];
 
1072
    mb_type = s->current_picture.f.mb_type[xy];
1095
1073
    cbp = s->cbp_table[xy];
1096
1074
 
1097
1075
    s->use_intra_dc_vlc= s->qscale < s->intra_dc_threshold;
1098
1076
 
1099
 
    if(s->current_picture.qscale_table[xy] != s->qscale){
1100
 
        ff_set_qscale(s, s->current_picture.qscale_table[xy] );
 
1077
    if (s->current_picture.f.qscale_table[xy] != s->qscale) {
 
1078
        ff_set_qscale(s, s->current_picture.f.qscale_table[xy]);
1101
1079
    }
1102
1080
 
1103
1081
    if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
1104
1082
        int i;
1105
1083
        for(i=0; i<4; i++){
1106
 
            s->mv[0][i][0] = s->current_picture.motion_val[0][ s->block_index[i] ][0];
1107
 
            s->mv[0][i][1] = s->current_picture.motion_val[0][ s->block_index[i] ][1];
 
1084
            s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0];
 
1085
            s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1];
1108
1086
        }
1109
1087
        s->mb_intra = IS_INTRA(mb_type);
1110
1088
 
1122
1100
                s->mb_skipped = 1;
1123
1101
            }
1124
1102
        }else if(s->mb_intra){
1125
 
            s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
 
1103
            s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]);
1126
1104
        }else if(!s->mb_intra){
1127
1105
//            s->mcsel= 0; //FIXME do we need to init that
1128
1106
 
1135
1113
        }
1136
1114
    } else { /* I-Frame */
1137
1115
        s->mb_intra = 1;
1138
 
        s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
 
1116
        s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]);
1139
1117
    }
1140
1118
 
1141
1119
    if (!IS_SKIP(mb_type)) {
1188
1166
                s->mv_dir = MV_DIR_FORWARD;
1189
1167
                s->mv_type = MV_TYPE_16X16;
1190
1168
                if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
1191
 
                    s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
 
1169
                    s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
1192
1170
                    s->mcsel=1;
1193
1171
                    s->mv[0][0][0]= get_amv(s, 0);
1194
1172
                    s->mv[0][0][1]= get_amv(s, 1);
1195
1173
 
1196
1174
                    s->mb_skipped = 0;
1197
1175
                }else{
1198
 
                    s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
 
1176
                    s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
1199
1177
                    s->mcsel=0;
1200
1178
                    s->mv[0][0][0] = 0;
1201
1179
                    s->mv[0][0][1] = 0;
1230
1208
        s->mv_dir = MV_DIR_FORWARD;
1231
1209
        if ((cbpc & 16) == 0) {
1232
1210
            if(s->mcsel){
1233
 
                s->current_picture.mb_type[xy]= MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
 
1211
                s->current_picture.f.mb_type[xy] = MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
1234
1212
                /* 16x16 global motion prediction */
1235
1213
                s->mv_type = MV_TYPE_16X16;
1236
1214
                mx= get_amv(s, 0);
1238
1216
                s->mv[0][0][0] = mx;
1239
1217
                s->mv[0][0][1] = my;
1240
1218
            }else if((!s->progressive_sequence) && get_bits1(&s->gb)){
1241
 
                s->current_picture.mb_type[xy]= MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED;
 
1219
                s->current_picture.f.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED;
1242
1220
                /* 16x8 field motion prediction */
1243
1221
                s->mv_type= MV_TYPE_FIELD;
1244
1222
 
1260
1238
                    s->mv[0][i][1] = my;
1261
1239
                }
1262
1240
            }else{
1263
 
                s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
 
1241
                s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
1264
1242
                /* 16x16 motion prediction */
1265
1243
                s->mv_type = MV_TYPE_16X16;
1266
1244
                h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
1277
1255
                s->mv[0][0][1] = my;
1278
1256
            }
1279
1257
        } else {
1280
 
            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
 
1258
            s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
1281
1259
            s->mv_type = MV_TYPE_8X8;
1282
1260
            for(i=0;i<4;i++) {
1283
1261
                mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
1314
1292
        }
1315
1293
 
1316
1294
        /* if we skipped it in the future P Frame than skip it now too */
1317
 
        s->mb_skipped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
 
1295
        s->mb_skipped = s->next_picture.f.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
1318
1296
 
1319
1297
        if(s->mb_skipped){
1320
1298
                /* skip mb */
1327
1305
            s->mv[0][0][1] = 0;
1328
1306
            s->mv[1][0][0] = 0;
1329
1307
            s->mv[1][0][1] = 0;
1330
 
            s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
 
1308
            s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
1331
1309
            goto end;
1332
1310
        }
1333
1311
 
1433
1411
            s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
1434
1412
            mb_type |= ff_mpeg4_set_direct_mv(s, mx, my);
1435
1413
        }
1436
 
        s->current_picture.mb_type[xy]= mb_type;
 
1414
        s->current_picture.f.mb_type[xy] = mb_type;
1437
1415
    } else { /* I-Frame */
1438
1416
        do{
1439
1417
            cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
1448
1426
intra:
1449
1427
        s->ac_pred = get_bits1(&s->gb);
1450
1428
        if(s->ac_pred)
1451
 
            s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED;
 
1429
            s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
1452
1430
        else
1453
 
            s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
 
1431
            s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
1454
1432
 
1455
1433
        cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
1456
1434
        if(cbpy<0){
1491
1469
        if(mpeg4_is_resync(s)){
1492
1470
            const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
1493
1471
 
1494
 
            if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]){
 
1472
            if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta]) {
1495
1473
                ff_thread_await_progress((AVFrame*)s->next_picture_ptr,
1496
1474
                                        (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0);
1497
1475
            }
1498
1476
 
1499
 
            if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta])
 
1477
            if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta])
1500
1478
                return SLICE_OK;
1501
1479
            return SLICE_END;
1502
1480
        }
1523
1501
    return 0;
1524
1502
}
1525
1503
 
 
1504
static int mpeg4_decode_profile_level(MpegEncContext * s, GetBitContext *gb){
 
1505
  int profile_and_level_indication;
 
1506
 
 
1507
  profile_and_level_indication = get_bits(gb, 8);
 
1508
 
 
1509
  s->avctx->profile = (profile_and_level_indication & 0xf0) >> 4;
 
1510
  s->avctx->level   = (profile_and_level_indication & 0x0f);
 
1511
 
 
1512
  // for Simple profile, level 0
 
1513
  if (s->avctx->profile == 0 && s->avctx->level == 8) {
 
1514
      s->avctx->level = 0;
 
1515
  }
 
1516
 
 
1517
  return 0;
 
1518
}
 
1519
 
1526
1520
static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
1527
1521
    int width, height, vo_ver_id;
1528
1522
 
1830
1824
}
1831
1825
 
1832
1826
/**
1833
 
 * decodes the user data stuff in the header.
 
1827
 * Decode the user data stuff in the header.
1834
1828
 * Also initializes divx/xvid/lavc_version/build.
1835
1829
 */
1836
1830
static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
1860
1854
        }
1861
1855
    }
1862
1856
 
1863
 
    /* ffmpeg detection */
 
1857
    /* libavcodec detection */
1864
1858
    e=sscanf(buf, "FFmpe%*[^b]b%d", &build)+3;
1865
1859
    if(e!=4)
1866
1860
        e=sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
1961
1955
    }
1962
1956
 
1963
1957
    if(s->avctx->time_base.num)
1964
 
        s->current_picture_ptr->pts= (s->time + s->avctx->time_base.num/2) / s->avctx->time_base.num;
 
1958
        s->current_picture_ptr->f.pts = (s->time + s->avctx->time_base.num / 2) / s->avctx->time_base.num;
1965
1959
    else
1966
 
        s->current_picture_ptr->pts= AV_NOPTS_VALUE;
 
1960
        s->current_picture_ptr->f.pts = AV_NOPTS_VALUE;
1967
1961
    if(s->avctx->debug&FF_DEBUG_PTS)
1968
 
        av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n", s->current_picture_ptr->pts);
 
1962
        av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n",
 
1963
               s->current_picture_ptr->f.pts);
1969
1964
 
1970
1965
    check_marker(gb, "before vop_coded");
1971
1966
 
2099
2094
}
2100
2095
 
2101
2096
/**
2102
 
 * decode mpeg4 headers
 
2097
 * Decode mpeg4 headers.
2103
2098
 * @return <0 if no VOP found (or a damaged one)
2104
2099
 *         FRAME_SKIPPED if a not coded VOP is found
2105
2100
 *         0 if a VOP is found
2106
2101
 */
2107
2102
int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
2108
2103
{
2109
 
    int startcode, v;
 
2104
    unsigned startcode, v;
2110
2105
 
2111
2106
    /* search next start code */
2112
2107
    align_get_bits(gb);
2176
2171
        else if(startcode == GOP_STARTCODE){
2177
2172
            mpeg4_decode_gop_header(s, gb);
2178
2173
        }
 
2174
        else if(startcode == VOS_STARTCODE){
 
2175
            mpeg4_decode_profile_level(s, gb);
 
2176
        }
2179
2177
        else if(startcode == VOP_STARTCODE){
2180
2178
            break;
2181
2179
        }
2236
2234
    return 0;
2237
2235
}
2238
2236
 
 
2237
static const AVProfile mpeg4_video_profiles[] = {
 
2238
    { FF_PROFILE_MPEG4_SIMPLE,                    "Simple Profile" },
 
2239
    { FF_PROFILE_MPEG4_SIMPLE_SCALABLE,           "Simple Scalable Profile" },
 
2240
    { FF_PROFILE_MPEG4_CORE,                      "Core Profile" },
 
2241
    { FF_PROFILE_MPEG4_MAIN,                      "Main Profile" },
 
2242
    { FF_PROFILE_MPEG4_N_BIT,                     "N-bit Profile" },
 
2243
    { FF_PROFILE_MPEG4_SCALABLE_TEXTURE,          "Scalable Texture Profile" },
 
2244
    { FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION,     "Simple Face Animation Profile" },
 
2245
    { FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE,    "Basic Animated Texture Profile" },
 
2246
    { FF_PROFILE_MPEG4_HYBRID,                    "Hybrid Profile" },
 
2247
    { FF_PROFILE_MPEG4_ADVANCED_REAL_TIME,        "Advanced Real Time Simple Profile" },
 
2248
    { FF_PROFILE_MPEG4_CORE_SCALABLE,             "Code Scalable Profile" },
 
2249
    { FF_PROFILE_MPEG4_ADVANCED_CODING,           "Advanced Coding Profile" },
 
2250
    { FF_PROFILE_MPEG4_ADVANCED_CORE,             "Advanced Core Profile" },
 
2251
    { FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE, "Advanced Scalable Texture Profile" },
 
2252
    { FF_PROFILE_MPEG4_SIMPLE_STUDIO,             "Simple Studio Profile" },
 
2253
    { FF_PROFILE_MPEG4_ADVANCED_SIMPLE,           "Advanced Simple Profile" },
 
2254
};
 
2255
 
2239
2256
AVCodec ff_mpeg4_decoder = {
2240
 
    "mpeg4",
2241
 
    AVMEDIA_TYPE_VIDEO,
2242
 
    CODEC_ID_MPEG4,
2243
 
    sizeof(MpegEncContext),
2244
 
    decode_init,
2245
 
    NULL,
2246
 
    ff_h263_decode_end,
2247
 
    ff_h263_decode_frame,
2248
 
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS,
 
2257
    .name           = "mpeg4",
 
2258
    .type           = AVMEDIA_TYPE_VIDEO,
 
2259
    .id             = CODEC_ID_MPEG4,
 
2260
    .priv_data_size = sizeof(MpegEncContext),
 
2261
    .init           = decode_init,
 
2262
    .close          = ff_h263_decode_end,
 
2263
    .decode         = ff_h263_decode_frame,
 
2264
    .capabilities   = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS,
2249
2265
    .flush= ff_mpeg_flush,
2250
2266
    .max_lowres= 3,
2251
2267
    .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
2252
2268
    .pix_fmts= ff_hwaccel_pixfmt_list_420,
 
2269
    .profiles = NULL_IF_CONFIG_SMALL(mpeg4_video_profiles),
2253
2270
    .update_thread_context= ONLY_IF_THREADS_ENABLED(ff_mpeg_update_thread_context)
2254
2271
};
2255
2272
 
2256
2273
 
2257
2274
#if CONFIG_MPEG4_VDPAU_DECODER
2258
2275
AVCodec ff_mpeg4_vdpau_decoder = {
2259
 
    "mpeg4_vdpau",
2260
 
    AVMEDIA_TYPE_VIDEO,
2261
 
    CODEC_ID_MPEG4,
2262
 
    sizeof(MpegEncContext),
2263
 
    decode_init,
2264
 
    NULL,
2265
 
    ff_h263_decode_end,
2266
 
    ff_h263_decode_frame,
2267
 
    CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
 
2276
    .name           = "mpeg4_vdpau",
 
2277
    .type           = AVMEDIA_TYPE_VIDEO,
 
2278
    .id             = CODEC_ID_MPEG4,
 
2279
    .priv_data_size = sizeof(MpegEncContext),
 
2280
    .init           = decode_init,
 
2281
    .close          = ff_h263_decode_end,
 
2282
    .decode         = ff_h263_decode_frame,
 
2283
    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
2268
2284
    .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 (VDPAU)"),
2269
2285
    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_VDPAU_MPEG4, PIX_FMT_NONE},
2270
2286
};