comparison mpeg12.c @ 7623:0bd920dcb7a5 libavcodec

Untangle mpeg12.c and mdec.c so that mdec.c can be compiled separately.
author diego
date Tue, 19 Aug 2008 20:52:26 +0000
parents c15e728fd413
children 1d04f38681bd
comparison
equal deleted inserted replaced
7622:5a3907818652 7623:0bd920dcb7a5
37 37
38 //#undef NDEBUG 38 //#undef NDEBUG
39 //#include <assert.h> 39 //#include <assert.h>
40 40
41 41
42 #define DC_VLC_BITS 9
43 #define MV_VLC_BITS 9 42 #define MV_VLC_BITS 9
44 #define MBINCR_VLC_BITS 9 43 #define MBINCR_VLC_BITS 9
45 #define MB_PAT_VLC_BITS 9 44 #define MB_PAT_VLC_BITS 9
46 #define MB_PTYPE_VLC_BITS 6 45 #define MB_PTYPE_VLC_BITS 6
47 #define MB_BTYPE_VLC_BITS 6 46 #define MB_BTYPE_VLC_BITS 6
48 #define TEX_VLC_BITS 9
49 47
50 static inline int mpeg1_decode_block_inter(MpegEncContext *s, 48 static inline int mpeg1_decode_block_inter(MpegEncContext *s,
51 DCTELEM *block, 49 DCTELEM *block,
52 int n); 50 int n);
53 static inline int mpeg1_decode_block_intra(MpegEncContext *s, 51 static inline int mpeg1_decode_block_intra(MpegEncContext *s,
142 140
143 141
144 /******************************************/ 142 /******************************************/
145 /* decoding */ 143 /* decoding */
146 144
147 static VLC dc_lum_vlc;
148 static VLC dc_chroma_vlc;
149 static VLC mv_vlc; 145 static VLC mv_vlc;
150 static VLC mbincr_vlc; 146 static VLC mbincr_vlc;
151 static VLC mb_ptype_vlc; 147 static VLC mb_ptype_vlc;
152 static VLC mb_btype_vlc; 148 static VLC mb_btype_vlc;
153 static VLC mb_pat_vlc; 149 static VLC mb_pat_vlc;
154 150
155 static av_cold void init_vlcs(void) 151 av_cold void ff_init_vlcs(void)
156 { 152 {
157 static int done = 0; 153 static int done = 0;
158 154
159 if (!done) { 155 if (!done) {
160 done = 1; 156 done = 1;
618 l= INT_BIT - 5 - shift; 614 l= INT_BIT - 5 - shift;
619 val = (val<<l)>>l; 615 val = (val<<l)>>l;
620 return val; 616 return val;
621 } 617 }
622 618
623 static inline int decode_dc(GetBitContext *gb, int component)
624 {
625 int code, diff;
626
627 if (component == 0) {
628 code = get_vlc2(gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
629 } else {
630 code = get_vlc2(gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
631 }
632 if (code < 0){
633 av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n");
634 return 0xffff;
635 }
636 if (code == 0) {
637 diff = 0;
638 } else {
639 diff = get_xbits(gb, code);
640 }
641 return diff;
642 }
643
644 static inline int mpeg1_decode_block_intra(MpegEncContext *s, 619 static inline int mpeg1_decode_block_intra(MpegEncContext *s,
645 DCTELEM *block, 620 DCTELEM *block,
646 int n) 621 int n)
647 { 622 {
648 int level, dc, diff, i, j, run; 623 int level, dc, diff, i, j, run;
1218 1193
1219 s->mpeg_enc_ctx.avctx= avctx; 1194 s->mpeg_enc_ctx.avctx= avctx;
1220 s->mpeg_enc_ctx.flags= avctx->flags; 1195 s->mpeg_enc_ctx.flags= avctx->flags;
1221 s->mpeg_enc_ctx.flags2= avctx->flags2; 1196 s->mpeg_enc_ctx.flags2= avctx->flags2;
1222 ff_mpeg12_common_init(&s->mpeg_enc_ctx); 1197 ff_mpeg12_common_init(&s->mpeg_enc_ctx);
1223 init_vlcs(); 1198 ff_init_vlcs();
1224 1199
1225 s->mpeg_enc_ctx_allocated = 0; 1200 s->mpeg_enc_ctx_allocated = 0;
1226 s->mpeg_enc_ctx.picture_number = 0; 1201 s->mpeg_enc_ctx.picture_number = 0;
1227 s->repeat_field = 0; 1202 s->repeat_field = 0;
1228 s->mpeg_enc_ctx.codec_id= avctx->codec->id; 1203 s->mpeg_enc_ctx.codec_id= avctx->codec->id;
2510 .flush= ff_mpeg_flush, 2485 .flush= ff_mpeg_flush,
2511 .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video XvMC (X-Video Motion Compensation)"), 2486 .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video XvMC (X-Video Motion Compensation)"),
2512 }; 2487 };
2513 2488
2514 #endif 2489 #endif
2515
2516 /* this is ugly i know, but the alternative is too make
2517 hundreds of vars global and prefix them with ff_mpeg1_
2518 which is far uglier. */
2519 #include "mdec.c"