Revision 307eb248

View differences:

libavcodec/avcodec.h
341 341
#define CODEC_FLAG2_FASTPSKIP     0x00000100 ///< H.264 fast pskip
342 342
#define CODEC_FLAG2_AUD           0x00000200 ///< H.264 access unit delimiters
343 343
#define CODEC_FLAG2_BRDO          0x00000400 ///< b-frame rate-distortion optimization
344
#define CODEC_FLAG2_INTRA_VLC     0x00000800 ///< use MPEG-2 intra VLC table
344 345

  
345 346
/* Unsupported options :
346 347
 *              Syntax Arithmetic coding (SAC)
libavcodec/mpeg12.c
95 95
static uint8_t fcode_tab[MAX_MV*2+1];
96 96

  
97 97
static uint8_t  uni_mpeg1_ac_vlc_len [64*64*2];
98
static uint8_t  uni_mpeg2_ac_vlc_len [64*64*2];
98 99

  
99 100
/* simple include everything table for dc, first byte is bits number next 3 are code*/
100 101
static uint32_t mpeg1_lum_dc_uni[512];
......
166 167

  
167 168
            if (code < 111 /* rl->n */) {
168 169
                /* store the vlc & sign at once */
169
                len=   mpeg1_vlc[code][1]+1;
170
                bits= (mpeg1_vlc[code][0]<<1) + sign;
170
                len=   rl->table_vlc[code][1]+1;
171
                bits= (rl->table_vlc[code][0]<<1) + sign;
171 172
            } else {
172
                len=  mpeg1_vlc[111/*rl->n*/][1]+6;
173
                bits= mpeg1_vlc[111/*rl->n*/][0]<<6;
173
                len=  rl->table_vlc[111/*rl->n*/][1]+6;
174
                bits= rl->table_vlc[111/*rl->n*/][0]<<6;
174 175

  
175 176
                bits|= run;
176 177
                if (alevel < 128) {
......
766 767

  
767 768
        done=1;
768 769
        init_rl(&rl_mpeg1, 1);
770
        if(s->intra_vlc_format)
771
            init_rl(&rl_mpeg2, 1);
769 772

  
770 773
        for(i=0; i<64; i++)
771 774
        {
......
774 777
        }
775 778

  
776 779
        init_uni_ac_vlc(&rl_mpeg1, uni_mpeg1_ac_vlc_len);
780
        if(s->intra_vlc_format)
781
            init_uni_ac_vlc(&rl_mpeg2, uni_mpeg2_ac_vlc_len);
777 782

  
778 783
        /* build unified dc encoding tables */
779 784
        for(i=-255; i<256; i++)
......
840 845
        s->min_qcoeff=-2047;
841 846
        s->max_qcoeff= 2047;
842 847
    }
843
    s->intra_ac_vlc_length=
848
    if (s->intra_vlc_format) {
849
        s->intra_ac_vlc_length=
850
        s->intra_ac_vlc_last_length= uni_mpeg2_ac_vlc_len;
851
    } else {
852
        s->intra_ac_vlc_length=
853
        s->intra_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
854
    }
844 855
    s->inter_ac_vlc_length=
845
    s->intra_ac_vlc_last_length=
846 856
    s->inter_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
847 857
}
848 858

  
......
889 899
{
890 900
    int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign;
891 901
    int code, component;
892
//    RLTable *rl = &rl_mpeg1;
902
    const uint16_t (*table_vlc)[2] = rl_mpeg1.table_vlc;
893 903

  
894 904
    last_index = s->block_last_index[n];
895 905

  
......
901 911
        encode_dc(s, diff, component);
902 912
        s->last_dc[component] = dc;
903 913
        i = 1;
904
/*
905 914
        if (s->intra_vlc_format)
906
            rl = &rl_mpeg2;
907
        else
908
            rl = &rl_mpeg1;
909
*/
915
            table_vlc = rl_mpeg2.table_vlc;
910 916
    } else {
911 917
        /* encode the first coefficient : needs to be done here because
912 918
           it is handled slightly differently */
......
941 947
            MASK_ABS(sign, alevel)
942 948
            sign&=1;
943 949

  
944
//            code = get_rl_index(rl, 0, run, alevel);
945 950
            if (alevel <= mpeg1_max_level[0][run]){
946 951
                code= mpeg1_index_run[0][run] + alevel - 1;
947 952
                /* store the vlc & sign at once */
948
                put_bits(&s->pb, mpeg1_vlc[code][1]+1, (mpeg1_vlc[code][0]<<1) + sign);
953
                put_bits(&s->pb, table_vlc[code][1]+1, (table_vlc[code][0]<<1) + sign);
949 954
            } else {
950 955
                /* escape seems to be pretty rare <5% so i dont optimize it */
951
                put_bits(&s->pb, mpeg1_vlc[111/*rl->n*/][1], mpeg1_vlc[111/*rl->n*/][0]);
956
                put_bits(&s->pb, table_vlc[111][1], table_vlc[111][0]);
952 957
                /* escape: only clip in this case */
953 958
                put_bits(&s->pb, 6, run);
954 959
                if(s->codec_id == CODEC_ID_MPEG1VIDEO){
......
969 974
        }
970 975
    }
971 976
    /* end of block */
972
    put_bits(&s->pb, 2, 0x2);
977
    put_bits(&s->pb, table_vlc[112][1], table_vlc[112][0]);
973 978
}
974 979
#endif //CONFIG_ENCODERS
975 980

  
libavcodec/mpegvideo.c
991 991
    s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
992 992
    s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
993 993
    s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
994
    s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC);
994 995

  
995 996
    if(avctx->rc_max_rate && !avctx->rc_buffer_size){
996 997
        av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
......
1075 1076
        return -1;
1076 1077
    }
1077 1078

  
1079
    if((s->flags2 & CODEC_FLAG2_INTRA_VLC) && s->codec_id != CODEC_ID_MPEG2VIDEO){
1080
        av_log(avctx, AV_LOG_ERROR, "intra vlc table not supported by codec\n");
1081
        return -1;
1082
    }
1083

  
1078 1084
    if(s->avctx->thread_count > 1 && s->codec_id != CODEC_ID_MPEG4
1079 1085
       && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO
1080 1086
       && (s->codec_id != CODEC_ID_H263P || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))){
libavcodec/utils.c
740 740
{"partb8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_B8X8, INT_MIN, INT_MAX, V|E, "partitions"},
741 741
{"sc_factor", NULL, OFFSET(scenechange_factor), FF_OPT_TYPE_INT, 6, 0, INT_MAX, V|E},
742 742
{"mv0_threshold", NULL, OFFSET(mv0_threshold), FF_OPT_TYPE_INT, 256, 0, INT_MAX, V|E},
743
{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
743 744
{NULL},
744 745
};
745 746

  
tests/ffmpeg.regression.ref
7 7
747312 ./data/a-mpeg2.mpg
8 8
f5b8b9c2a5e162b6c01d6b299d03b117 *./data/out.yuv
9 9
stddev:  7.69 PSNR:30.39 bytes:7602176
10
218ef56c1909d66e77c87cd98c9868e8 *./data/a-mpeg2ivlc.mpg
11
737935 ./data/a-mpeg2ivlc.mpg
12
f5b8b9c2a5e162b6c01d6b299d03b117 *./data/out.yuv
13
stddev:  7.69 PSNR:30.39 bytes:7602176
10 14
a34af358ee5b5dab19d37ee29f1927b2 *./data/a-mpeg2.mpg
11 15
748099 ./data/a-mpeg2.mpg
12 16
555f76a5df78088411b83f5faf334762 *./data/out.yuv
......
19 23
820348 ./data/a-mpeg2thread.mpg
20 24
6b820ffc74de50cc863b41d51f72c22b *./data/out.yuv
21 25
stddev:  7.64 PSNR:30.45 bytes:7602176
26
a88c3fc28a6e62351c1b71235e7916a7 *./data/a-mpeg2threadivlc.mpg
27
810646 ./data/a-mpeg2threadivlc.mpg
28
6b820ffc74de50cc863b41d51f72c22b *./data/out.yuv
29
stddev:  7.64 PSNR:30.45 bytes:7602176
22 30
edb3e58ea66de2e9b32713daf9b5c3f1 *./data/a-mpeg2reuse.mpg
23 31
2119706 ./data/a-mpeg2reuse.mpg
24 32
1dab2eaca5320fe01afbe9596b2bd6cc *./data/out.yuv
tests/regression.sh
179 179
# mpeg2 decoding
180 180
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
181 181

  
182
# mpeg2 encoding using intra vlc
183
file=${outfile}mpeg2ivlc.mpg
184
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -flags2 +ivlc $file
185

  
186
# mpeg2 decoding
187
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
188

  
182 189
# mpeg2 encoding
183 190
file=${outfile}mpeg2.mpg
184 191
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -idct int -dct int -f mpeg1video $file
......
203 210
# mpeg2 decoding
204 211
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
205 212

  
213
# mpeg2 encoding interlaced using intra vlc
214
file=${outfile}mpeg2threadivlc.mpg
215
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2 $file
216

  
217
# mpeg2 decoding
218
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
219

  
206 220
# mpeg2 encoding interlaced
207 221
file=${outfile}mpeg2reuse.mpg
208 222
do_ffmpeg $file -y -sameq -me_threshold 256 -mb_threshold 1024 -i ${outfile}mpeg2thread.mpg -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4 $file
tests/rotozoom.regression.ref
7 7
199396 ./data/a-mpeg2.mpg
8 8
94581e9516461557b194aeefaaba3835 *./data/out.yuv
9 9
stddev:  4.97 PSNR:34.18 bytes:7602176
10
356a07f0872b371acb2eebd9b0225786 *./data/a-mpeg2ivlc.mpg
11
198603 ./data/a-mpeg2ivlc.mpg
12
94581e9516461557b194aeefaaba3835 *./data/out.yuv
13
stddev:  4.97 PSNR:34.18 bytes:7602176
10 14
374bd257b96328935926b350b0c5cada *./data/a-mpeg2.mpg
11 15
198338 ./data/a-mpeg2.mpg
12 16
f464b420ae24c1e453df8d3e5ef9140d *./data/out.yuv
......
19 23
183955 ./data/a-mpeg2thread.mpg
20 24
38441603e2201ddb01632ba3411a6bb8 *./data/out.yuv
21 25
stddev:  4.76 PSNR:34.56 bytes:7602176
26
0c414c53b9418e6566680ed1d85d5a3b *./data/a-mpeg2threadivlc.mpg
27
183095 ./data/a-mpeg2threadivlc.mpg
28
38441603e2201ddb01632ba3411a6bb8 *./data/out.yuv
29
stddev:  4.76 PSNR:34.56 bytes:7602176
22 30
c9f6617461caee57ccb6d438761527c8 *./data/a-mpeg2reuse.mpg
23 31
396729 ./data/a-mpeg2reuse.mpg
24 32
b10aec71132301cad001070e8ad46b7d *./data/out.yuv

Also available in: Unified diff