Mercurial > libavcodec.hg
comparison mpeg12.c @ 5210:b52fd9b223bb libavcodec
add proper ff_ prefix to new extern symbols
author | aurel |
---|---|
date | Thu, 05 Jul 2007 09:21:55 +0000 |
parents | 430f60820b21 |
children | 4e7308c09d2e |
comparison
equal
deleted
inserted
replaced
5209:2ac10c5e5885 | 5210:b52fd9b223bb |
---|---|
76 static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = { | 76 static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = { |
77 PIX_FMT_XVMC_MPEG2_IDCT, | 77 PIX_FMT_XVMC_MPEG2_IDCT, |
78 PIX_FMT_XVMC_MPEG2_MC, | 78 PIX_FMT_XVMC_MPEG2_MC, |
79 -1}; | 79 -1}; |
80 | 80 |
81 uint8_t static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; | 81 uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; |
82 | 82 |
83 static void init_2d_vlc_rl(RLTable *rl, int use_static) | 83 static void init_2d_vlc_rl(RLTable *rl, int use_static) |
84 { | 84 { |
85 int i; | 85 int i; |
86 | 86 |
120 rl->rl_vlc[0][i].level= level; | 120 rl->rl_vlc[0][i].level= level; |
121 rl->rl_vlc[0][i].run= run; | 121 rl->rl_vlc[0][i].run= run; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 void common_init(MpegEncContext *s) | 125 void ff_mpeg12_common_init(MpegEncContext *s) |
126 { | 126 { |
127 | 127 |
128 s->y_dc_scale_table= | 128 s->y_dc_scale_table= |
129 s->c_dc_scale_table= mpeg2_dc_scale_table[s->intra_dc_precision]; | 129 s->c_dc_scale_table= mpeg2_dc_scale_table[s->intra_dc_precision]; |
130 | 130 |
155 | 155 |
156 if (!done) { | 156 if (!done) { |
157 done = 1; | 157 done = 1; |
158 | 158 |
159 init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12, | 159 init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12, |
160 vlc_dc_lum_bits, 1, 1, | 160 ff_mpeg12_vlc_dc_lum_bits, 1, 1, |
161 vlc_dc_lum_code, 2, 2, 1); | 161 ff_mpeg12_vlc_dc_lum_code, 2, 2, 1); |
162 init_vlc(&dc_chroma_vlc, DC_VLC_BITS, 12, | 162 init_vlc(&dc_chroma_vlc, DC_VLC_BITS, 12, |
163 vlc_dc_chroma_bits, 1, 1, | 163 ff_mpeg12_vlc_dc_chroma_bits, 1, 1, |
164 vlc_dc_chroma_code, 2, 2, 1); | 164 ff_mpeg12_vlc_dc_chroma_code, 2, 2, 1); |
165 init_vlc(&mv_vlc, MV_VLC_BITS, 17, | 165 init_vlc(&mv_vlc, MV_VLC_BITS, 17, |
166 &mbMotionVectorTable[0][1], 2, 1, | 166 &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1, |
167 &mbMotionVectorTable[0][0], 2, 1, 1); | 167 &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 1); |
168 init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36, | 168 init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36, |
169 &mbAddrIncrTable[0][1], 2, 1, | 169 &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1, |
170 &mbAddrIncrTable[0][0], 2, 1, 1); | 170 &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 1); |
171 init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64, | 171 init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64, |
172 &mbPatTable[0][1], 2, 1, | 172 &ff_mpeg12_mbPatTable[0][1], 2, 1, |
173 &mbPatTable[0][0], 2, 1, 1); | 173 &ff_mpeg12_mbPatTable[0][0], 2, 1, 1); |
174 | 174 |
175 init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, | 175 init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, |
176 &table_mb_ptype[0][1], 2, 1, | 176 &table_mb_ptype[0][1], 2, 1, |
177 &table_mb_ptype[0][0], 2, 1, 1); | 177 &table_mb_ptype[0][0], 2, 1, 1); |
178 init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, | 178 init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, |
179 &table_mb_btype[0][1], 2, 1, | 179 &table_mb_btype[0][1], 2, 1, |
180 &table_mb_btype[0][0], 2, 1, 1); | 180 &table_mb_btype[0][0], 2, 1, 1); |
181 init_rl(&rl_mpeg1, static_rl_table_store[0]); | 181 init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]); |
182 init_rl(&rl_mpeg2, static_rl_table_store[1]); | 182 init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]); |
183 | 183 |
184 init_2d_vlc_rl(&rl_mpeg1, 1); | 184 init_2d_vlc_rl(&ff_rl_mpeg1, 1); |
185 init_2d_vlc_rl(&rl_mpeg2, 1); | 185 init_2d_vlc_rl(&ff_rl_mpeg2, 1); |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 static inline int get_dmv(MpegEncContext *s) | 189 static inline int get_dmv(MpegEncContext *s) |
190 { | 190 { |
665 DCTELEM *block, | 665 DCTELEM *block, |
666 int n) | 666 int n) |
667 { | 667 { |
668 int level, dc, diff, i, j, run; | 668 int level, dc, diff, i, j, run; |
669 int component; | 669 int component; |
670 RLTable *rl = &rl_mpeg1; | 670 RLTable *rl = &ff_rl_mpeg1; |
671 uint8_t * const scantable= s->intra_scantable.permutated; | 671 uint8_t * const scantable= s->intra_scantable.permutated; |
672 const uint16_t *quant_matrix= s->intra_matrix; | 672 const uint16_t *quant_matrix= s->intra_matrix; |
673 const int qscale= s->qscale; | 673 const int qscale= s->qscale; |
674 | 674 |
675 /* DC coef */ | 675 /* DC coef */ |
737 static inline int mpeg1_decode_block_inter(MpegEncContext *s, | 737 static inline int mpeg1_decode_block_inter(MpegEncContext *s, |
738 DCTELEM *block, | 738 DCTELEM *block, |
739 int n) | 739 int n) |
740 { | 740 { |
741 int level, i, j, run; | 741 int level, i, j, run; |
742 RLTable *rl = &rl_mpeg1; | 742 RLTable *rl = &ff_rl_mpeg1; |
743 uint8_t * const scantable= s->intra_scantable.permutated; | 743 uint8_t * const scantable= s->intra_scantable.permutated; |
744 const uint16_t *quant_matrix= s->inter_matrix; | 744 const uint16_t *quant_matrix= s->inter_matrix; |
745 const int qscale= s->qscale; | 745 const int qscale= s->qscale; |
746 | 746 |
747 { | 747 { |
813 } | 813 } |
814 | 814 |
815 static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n) | 815 static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n) |
816 { | 816 { |
817 int level, i, j, run; | 817 int level, i, j, run; |
818 RLTable *rl = &rl_mpeg1; | 818 RLTable *rl = &ff_rl_mpeg1; |
819 uint8_t * const scantable= s->intra_scantable.permutated; | 819 uint8_t * const scantable= s->intra_scantable.permutated; |
820 const int qscale= s->qscale; | 820 const int qscale= s->qscale; |
821 | 821 |
822 { | 822 { |
823 OPEN_READER(re, &s->gb); | 823 OPEN_READER(re, &s->gb); |
887 static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, | 887 static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, |
888 DCTELEM *block, | 888 DCTELEM *block, |
889 int n) | 889 int n) |
890 { | 890 { |
891 int level, i, j, run; | 891 int level, i, j, run; |
892 RLTable *rl = &rl_mpeg1; | 892 RLTable *rl = &ff_rl_mpeg1; |
893 uint8_t * const scantable= s->intra_scantable.permutated; | 893 uint8_t * const scantable= s->intra_scantable.permutated; |
894 const uint16_t *quant_matrix; | 894 const uint16_t *quant_matrix; |
895 const int qscale= s->qscale; | 895 const int qscale= s->qscale; |
896 int mismatch; | 896 int mismatch; |
897 | 897 |
968 static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, | 968 static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, |
969 DCTELEM *block, | 969 DCTELEM *block, |
970 int n) | 970 int n) |
971 { | 971 { |
972 int level, i, j, run; | 972 int level, i, j, run; |
973 RLTable *rl = &rl_mpeg1; | 973 RLTable *rl = &ff_rl_mpeg1; |
974 uint8_t * const scantable= s->intra_scantable.permutated; | 974 uint8_t * const scantable= s->intra_scantable.permutated; |
975 const int qscale= s->qscale; | 975 const int qscale= s->qscale; |
976 OPEN_READER(re, &s->gb); | 976 OPEN_READER(re, &s->gb); |
977 i = -1; | 977 i = -1; |
978 | 978 |
1057 block[0] = dc << (3 - s->intra_dc_precision); | 1057 block[0] = dc << (3 - s->intra_dc_precision); |
1058 dprintf(s->avctx, "dc=%d\n", block[0]); | 1058 dprintf(s->avctx, "dc=%d\n", block[0]); |
1059 mismatch = block[0] ^ 1; | 1059 mismatch = block[0] ^ 1; |
1060 i = 0; | 1060 i = 0; |
1061 if (s->intra_vlc_format) | 1061 if (s->intra_vlc_format) |
1062 rl = &rl_mpeg2; | 1062 rl = &ff_rl_mpeg2; |
1063 else | 1063 else |
1064 rl = &rl_mpeg1; | 1064 rl = &ff_rl_mpeg1; |
1065 | 1065 |
1066 { | 1066 { |
1067 OPEN_READER(re, &s->gb); | 1067 OPEN_READER(re, &s->gb); |
1068 /* now quantify & encode AC coefs */ | 1068 /* now quantify & encode AC coefs */ |
1069 for(;;) { | 1069 for(;;) { |
1133 dc = s->last_dc[component]; | 1133 dc = s->last_dc[component]; |
1134 dc += diff; | 1134 dc += diff; |
1135 s->last_dc[component] = dc; | 1135 s->last_dc[component] = dc; |
1136 block[0] = dc << (3 - s->intra_dc_precision); | 1136 block[0] = dc << (3 - s->intra_dc_precision); |
1137 if (s->intra_vlc_format) | 1137 if (s->intra_vlc_format) |
1138 rl = &rl_mpeg2; | 1138 rl = &ff_rl_mpeg2; |
1139 else | 1139 else |
1140 rl = &rl_mpeg1; | 1140 rl = &ff_rl_mpeg1; |
1141 | 1141 |
1142 { | 1142 { |
1143 OPEN_READER(re, &s->gb); | 1143 OPEN_READER(re, &s->gb); |
1144 /* now quantify & encode AC coefs */ | 1144 /* now quantify & encode AC coefs */ |
1145 for(;;) { | 1145 for(;;) { |
1206 MPV_decode_defaults(s2); | 1206 MPV_decode_defaults(s2); |
1207 | 1207 |
1208 s->mpeg_enc_ctx.avctx= avctx; | 1208 s->mpeg_enc_ctx.avctx= avctx; |
1209 s->mpeg_enc_ctx.flags= avctx->flags; | 1209 s->mpeg_enc_ctx.flags= avctx->flags; |
1210 s->mpeg_enc_ctx.flags2= avctx->flags2; | 1210 s->mpeg_enc_ctx.flags2= avctx->flags2; |
1211 common_init(&s->mpeg_enc_ctx); | 1211 ff_mpeg12_common_init(&s->mpeg_enc_ctx); |
1212 init_vlcs(); | 1212 init_vlcs(); |
1213 | 1213 |
1214 s->mpeg_enc_ctx_allocated = 0; | 1214 s->mpeg_enc_ctx_allocated = 0; |
1215 s->mpeg_enc_ctx.picture_number = 0; | 1215 s->mpeg_enc_ctx.picture_number = 0; |
1216 s->repeat_field = 0; | 1216 s->repeat_field = 0; |
1271 //mpeg1 fps | 1271 //mpeg1 fps |
1272 avctx->time_base.den= ff_frame_rate_tab[s->frame_rate_index].num; | 1272 avctx->time_base.den= ff_frame_rate_tab[s->frame_rate_index].num; |
1273 avctx->time_base.num= ff_frame_rate_tab[s->frame_rate_index].den; | 1273 avctx->time_base.num= ff_frame_rate_tab[s->frame_rate_index].den; |
1274 //mpeg1 aspect | 1274 //mpeg1 aspect |
1275 avctx->sample_aspect_ratio= av_d2q( | 1275 avctx->sample_aspect_ratio= av_d2q( |
1276 1.0/mpeg1_aspect[s->aspect_ratio_info], 255); | 1276 1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255); |
1277 | 1277 |
1278 }else{//mpeg2 | 1278 }else{//mpeg2 |
1279 //mpeg2 fps | 1279 //mpeg2 fps |
1280 av_reduce( | 1280 av_reduce( |
1281 &s->avctx->time_base.den, | 1281 &s->avctx->time_base.den, |
1286 //mpeg2 aspect | 1286 //mpeg2 aspect |
1287 if(s->aspect_ratio_info > 1){ | 1287 if(s->aspect_ratio_info > 1){ |
1288 if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0) ){ | 1288 if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0) ){ |
1289 s->avctx->sample_aspect_ratio= | 1289 s->avctx->sample_aspect_ratio= |
1290 av_div_q( | 1290 av_div_q( |
1291 mpeg2_aspect[s->aspect_ratio_info], | 1291 ff_mpeg2_aspect[s->aspect_ratio_info], |
1292 (AVRational){s->width, s->height} | 1292 (AVRational){s->width, s->height} |
1293 ); | 1293 ); |
1294 }else{ | 1294 }else{ |
1295 s->avctx->sample_aspect_ratio= | 1295 s->avctx->sample_aspect_ratio= |
1296 av_div_q( | 1296 av_div_q( |
1297 mpeg2_aspect[s->aspect_ratio_info], | 1297 ff_mpeg2_aspect[s->aspect_ratio_info], |
1298 (AVRational){s1->pan_scan.width, s1->pan_scan.height} | 1298 (AVRational){s1->pan_scan.width, s1->pan_scan.height} |
1299 ); | 1299 ); |
1300 } | 1300 } |
1301 }else{ | 1301 }else{ |
1302 s->avctx->sample_aspect_ratio= | 1302 s->avctx->sample_aspect_ratio= |
1303 mpeg2_aspect[s->aspect_ratio_info]; | 1303 ff_mpeg2_aspect[s->aspect_ratio_info]; |
1304 } | 1304 } |
1305 }//mpeg2 | 1305 }//mpeg2 |
1306 | 1306 |
1307 if(avctx->xvmc_acceleration){ | 1307 if(avctx->xvmc_acceleration){ |
1308 avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); | 1308 avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); |