~medibuntu-maintainers/mplayer/medibuntu.natty

« back to all changes in this revision

Viewing changes to libavcodec/svq3.c

  • Committer: Gauvain Pocentek
  • Date: 2010-09-25 09:39:02 UTC
  • mfrom: (66.1.6 maverick)
  • Revision ID: gauvain@images-20100925093902-9q2akz3ls3qzhaaw
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* merge from debian, remaining changes:
  - build depend against, lame, x264, xvid
* debian/patches/60eval-api.patch, backport patch from upstream to
  unbreak compilation for eval.h move not yet in 0.6
* gmplayer is gone now, please see smplayer as alternative frontend.
  LP: #503537, #493088, #467534, #467524, #460326, #390399, #285570,
      #208680, #118709, #513065, #459595, #455913, #179918, #65165.
* enable the mencoder package
* sort build depends alphabetically
* enable dvdnav support, Closes: #582508, #488226, LP: #611749
* prepare new upload
* no longer build mplayer-gui, it doesn't build anymore with shared
  swscale
* merge from debian/experimental, remaining changes:
  - build depend against, lame, x264, xvid
  - enable mencoder and mplayer-gui
* ensure that quilt patches are actually applied
* New Upstream Version, LP: #539315
* Build (against) again the System FFmpeg 
* tighten dependency on FFmpeg 0.6
* remove patches merged upstream
* remove 22disable-xscreensaver.patch
* refresh patches
* readd x264, xvid and mp3lame support, LP: #606125
* remove old parallel building mechanism, fixes FTBFS
* New upstream version
* compile against internal ffmpeg for now, LP: #587203, #588097
* recompile for directfb transtion, LP: #587163
* remove patches that were merged upstream
* avoid removing DOCS/html directory. it is included in release
  tarball
* convert to source Format: 3.0 (quilt)
* refreshed patches
* remove files that are included in upstream tarball
* rework debian/rules file
  - support parallel building
  - merge build rules for mplayer and mencoder package
  - remove unreferenced COMMON_CONFIGURE_FLAGS macro
  - rename DEB_BUILD_CONFIGURE -> CONFIGURE_FLAGS
  - don't build documentation - release tarballs have them prebuilt
  - build HTML documentation only if not already avaiable in the build
    tree
  - remove remaining references to debian/strip.sh from debian/rules
* remove copied vdpau headers
* copy in mencoder.c from upstream
* enable mplayer-gui (Closes: #579925) and mencoder packages. 
  (Closes: #396954, #400940, #580168)
* Fix rtsp vulnerability. Patch applied by DSA. Closes: #581245
* Fix another integer overflow, Closes: #524805
* prepare new upload
* sync libao2/ao_pulse.c with svn r30062, Closes: #558196, #580113
* make configure use pkg-config for fribidi checks. Closes: #582784,
  LP: #556200
* document 23mplayer-debug-printf.patch
* avoid mentioning of GTK frontend in mplayer description
* improve package descriptions of mplayer-doc and mplayer-dbg
* medium urgency because of fixed security issue
* fix SVN_VERION regex in debian rules to unbreak get-orig-source
  target. Closes: #582369
* forcefully disable arts support. Closes: #581225
* Remove mencoder from Depends in mplayer-dbg package.
* new upstream snapshot from rc3 branch.
* remove patches applied upstream:
  
  - 24_enable_fontconfig_by_default.diff
  - 30_add_gmplayer_man_rules.diff
  - 40_improve_desktop_file.patch
  - 41_fix_forcedsubsonly.patch
  - 50_fix_crashes_with_invalid_SDPs.patch
  - 50_fix_initial_volume_setting_pulse_output.patch
  - 61-malloc-bsd.patch
  - 62-disable-vidix-on-kfreebsd-amd64.patch
  - 63-sys-kd-include.patch
* don't install apport hook
* gross hack to avoid building mplayer-nogui and mplayer-gui packages
* add md5sum to remove to avoid spurious conffile prompt, Closes: #568272
* Make mplayer build on kFreeBSD (backports from upstream), Closes: #578622
  - Revert obscure hack that disables the malloc.h check on certain BSD
    platforms. 
  - disable vidix on kFreeBSD-amd64
  - rename 'struct keypad' -> 'struct m_keypad' to avoid FTBFS on
    kFreeBSD/amd64
* enable fontconfig by default. (Closes: #573257)

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 * correctly decodes this file:
40
40
 *  http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov
41
41
 */
 
42
#include "internal.h"
 
43
#include "dsputil.h"
 
44
#include "avcodec.h"
 
45
#include "mpegvideo.h"
 
46
#include "h264.h"
 
47
 
 
48
#include "h264data.h" //FIXME FIXME FIXME
 
49
 
 
50
#include "h264_mvpred.h"
 
51
#include "golomb.h"
 
52
#include "rectangle.h"
 
53
#include "vdpau_internal.h"
42
54
 
43
55
#if CONFIG_ZLIB
44
56
#include <zlib.h>
47
59
#include "svq1.h"
48
60
 
49
61
/**
50
 
 * @file libavcodec/svq3.c
 
62
 * @file
51
63
 * svq3 decoder.
52
64
 */
53
65
 
114
126
};
115
127
 
116
128
 
117
 
static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp)
 
129
void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp)
118
130
{
119
131
    const int qmul = svq3_dequant_coeff[qp];
120
132
#define stride 16
151
163
}
152
164
#undef stride
153
165
 
154
 
static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp,
 
166
void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp,
155
167
                            int dc)
156
168
{
157
169
    const int qmul = svq3_dequant_coeff[qp];
466
478
        */
467
479
 
468
480
        for (m = 0; m < 2; m++) {
469
 
            if (s->mb_x > 0 && h->intra4x4_pred_mode[mb_xy - 1][0] != -1) {
 
481
            if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {
470
482
                for (i = 0; i < 4; i++) {
471
483
                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride];
472
484
                }
477
489
            }
478
490
            if (s->mb_y > 0) {
479
491
                memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
480
 
                memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[mb_xy - s->mb_stride][4] == -1) ? PART_NOT_AVAILABLE : 1, 4);
 
492
                memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
481
493
 
482
494
                if (s->mb_x < (s->mb_width - 1)) {
483
495
                    *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4];
484
496
                    h->ref_cache[m][scan8[0] + 4 - 1*8] =
485
 
                        (h->intra4x4_pred_mode[mb_xy - s->mb_stride + 1][0] == -1 ||
486
 
                         h->intra4x4_pred_mode[mb_xy - s->mb_stride    ][4] == -1) ? PART_NOT_AVAILABLE : 1;
 
497
                        (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||
 
498
                         h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride    ]  ] == -1) ? PART_NOT_AVAILABLE : 1;
487
499
                }else
488
500
                    h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
489
501
                if (s->mb_x > 0) {
490
502
                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1];
491
 
                    h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[mb_xy - s->mb_stride - 1][3] == -1) ? PART_NOT_AVAILABLE : 1;
 
503
                    h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1;
492
504
                }else
493
505
                    h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;
494
506
            }else
528
540
        if (mb_type == 8) {
529
541
            if (s->mb_x > 0) {
530
542
                for (i = 0; i < 4; i++) {
531
 
                    h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[mb_xy - 1][i];
 
543
                    h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6-i];
532
544
                }
533
545
                if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) {
534
546
                    h->left_samples_available = 0x5F5F;
535
547
                }
536
548
            }
537
549
            if (s->mb_y > 0) {
538
 
                h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][4];
539
 
                h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][5];
540
 
                h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][6];
541
 
                h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][3];
 
550
                h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+0];
 
551
                h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+1];
 
552
                h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+2];
 
553
                h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+3];
542
554
 
543
555
                if (h->intra4x4_pred_mode_cache[4+8*0] == -1) {
544
556
                    h->top_samples_available = 0x33FF;
571
583
            }
572
584
        }
573
585
 
574
 
        write_back_intra_pred_mode(h);
 
586
        ff_h264_write_back_intra_pred_mode(h);
575
587
 
576
588
        if (mb_type == 8) {
577
 
            check_intra4x4_pred_mode(h);
 
589
            ff_h264_check_intra4x4_pred_mode(h);
578
590
 
579
591
            h->top_samples_available  = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
580
592
            h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
592
604
        dir = i_mb_type_info[mb_type - 8].pred_mode;
593
605
        dir = (dir >> 1) ^ 3*(dir & 1) ^ 1;
594
606
 
595
 
        if ((h->intra16x16_pred_mode = check_intra_pred_mode(h, dir)) == -1){
 
607
        if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir)) == -1){
596
608
            av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n");
597
609
            return -1;
598
610
        }
612
624
        }
613
625
    }
614
626
    if (!IS_INTRA4x4(mb_type)) {
615
 
        memset(h->intra4x4_pred_mode[mb_xy], DC_PRED, 8);
 
627
        memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy], DC_PRED, 8);
616
628
    }
617
629
    if (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE) {
618
630
        memset(h->non_zero_count_cache + 8, 0, 4*9*sizeof(uint8_t));
685
697
    s->current_picture.mb_type[mb_xy] = mb_type;
686
698
 
687
699
    if (IS_INTRA(mb_type)) {
688
 
        h->chroma_pred_mode = check_intra_pred_mode(h, DC_PRED8x8);
 
700
        h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8);
689
701
    }
690
702
 
691
703
    return 0;
762
774
 
763
775
    /* reset intra predictors and invalidate motion vector references */
764
776
    if (s->mb_x > 0) {
765
 
        memset(h->intra4x4_pred_mode[mb_xy - 1], -1, 4*sizeof(int8_t));
766
 
        memset(h->intra4x4_pred_mode[mb_xy - s->mb_x], -1, 8*sizeof(int8_t)*s->mb_x);
 
777
        memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - 1      ]+3, -1, 4*sizeof(int8_t));
 
778
        memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_x]  , -1, 8*sizeof(int8_t)*s->mb_x);
767
779
    }
768
780
    if (s->mb_y > 0) {
769
 
        memset(h->intra4x4_pred_mode[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x));
 
781
        memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x));
770
782
 
771
783
        if (s->mb_x > 0) {
772
 
            h->intra4x4_pred_mode[mb_xy - s->mb_stride - 1][3] = -1;
 
784
            h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] = -1;
773
785
        }
774
786
    }
775
787
 
784
796
    unsigned char *extradata;
785
797
    unsigned int size;
786
798
 
787
 
    if (decode_init(avctx) < 0)
 
799
    if(avctx->thread_count > 1){
 
800
        av_log(avctx, AV_LOG_ERROR, "SVQ3 does not support multithreaded decoding, patch welcome! (check latest SVN too)\n");
 
801
        return -1;
 
802
    }
 
803
 
 
804
    if (ff_h264_decode_init(avctx) < 0)
788
805
        return -1;
789
806
 
790
807
    s->flags  = avctx->flags;
791
808
    s->flags2 = avctx->flags2;
792
809
    s->unrestricted_mv = 1;
793
810
    h->is_complex=1;
 
811
    avctx->pix_fmt = avctx->codec->pix_fmts[0];
794
812
 
795
813
    if (!s->context_initialized) {
796
814
        s->width  = avctx->width;
805
823
 
806
824
        h->b_stride = 4*s->mb_width;
807
825
 
808
 
        alloc_tables(h);
 
826
        ff_h264_alloc_tables(h);
809
827
 
810
828
        /* prowl for the "SEQH" marker in the extradata */
811
829
        extradata = (unsigned char *)avctx->extradata;
819
837
        if (extradata && !memcmp(extradata, "SEQH", 4)) {
820
838
 
821
839
            GetBitContext gb;
 
840
            int frame_size_code;
822
841
 
823
842
            size = AV_RB32(&extradata[4]);
824
843
            init_get_bits(&gb, extradata + 8, size*8);
825
844
 
826
845
            /* 'frame size code' and optional 'width, height' */
827
 
            if (get_bits(&gb, 3) == 7) {
828
 
                skip_bits(&gb, 12);
829
 
                skip_bits(&gb, 12);
 
846
            frame_size_code = get_bits(&gb, 3);
 
847
            switch (frame_size_code) {
 
848
                case 0: avctx->width = 160; avctx->height = 120; break;
 
849
                case 1: avctx->width = 128; avctx->height =  96; break;
 
850
                case 2: avctx->width = 176; avctx->height = 144; break;
 
851
                case 3: avctx->width = 352; avctx->height = 288; break;
 
852
                case 4: avctx->width = 704; avctx->height = 576; break;
 
853
                case 5: avctx->width = 240; avctx->height = 180; break;
 
854
                case 6: avctx->width = 320; avctx->height = 240; break;
 
855
                case 7:
 
856
                    avctx->width  = get_bits(&gb, 12);
 
857
                    avctx->height = get_bits(&gb, 12);
 
858
                    break;
830
859
            }
831
860
 
832
861
            h->halfpel_flag  = get_bits1(&gb);
889
918
 
890
919
static int svq3_decode_frame(AVCodecContext *avctx,
891
920
                             void *data, int *data_size,
892
 
                             const uint8_t *buf, int buf_size)
 
921
                             AVPacket *avpkt)
893
922
{
 
923
    const uint8_t *buf = avpkt->data;
 
924
    int buf_size = avpkt->size;
894
925
    MpegEncContext *const s = avctx->priv_data;
895
926
    H264Context *const h = avctx->priv_data;
896
927
    int m, mb_type;
946
977
            s->next_p_frame_damaged = 0;
947
978
    }
948
979
 
949
 
    if (frame_start(h) < 0)
 
980
    if (ff_h264_frame_start(h) < 0)
950
981
        return -1;
951
982
 
952
983
    if (s->pict_type == FF_B_TYPE) {
1009
1040
            }
1010
1041
 
1011
1042
            if (mb_type != 0) {
1012
 
                hl_decode_mb (h);
 
1043
                ff_h264_hl_decode_mb (h);
1013
1044
            }
1014
1045
 
1015
1046
            if (s->pict_type != FF_B_TYPE && !s->low_delay) {
1029
1060
        *(AVFrame *) data = *(AVFrame *) &s->last_picture;
1030
1061
    }
1031
1062
 
1032
 
    avctx->frame_number = s->picture_number - 1;
1033
 
 
1034
1063
    /* Do not output the last pic after seeking. */
1035
1064
    if (s->last_picture_ptr || s->low_delay) {
1036
1065
        *data_size = sizeof(AVFrame);
1042
1071
 
1043
1072
AVCodec svq3_decoder = {
1044
1073
    "svq3",
1045
 
    CODEC_TYPE_VIDEO,
 
1074
    AVMEDIA_TYPE_VIDEO,
1046
1075
    CODEC_ID_SVQ3,
1047
1076
    sizeof(H264Context),
1048
1077
    svq3_decode_init,
1049
1078
    NULL,
1050
 
    decode_end,
 
1079
    ff_h264_decode_end,
1051
1080
    svq3_decode_frame,
1052
1081
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
1053
 
    .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3"),
1054
 
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_NONE},
 
1082
    .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"),
 
1083
    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_NONE},
1055
1084
};