Mercurial > libavcodec.hg
comparison mpeg12.c @ 8538:35f1b87d908f libavcodec
Factorise setting of avctx->pix_fmt.
author | cehoyos |
---|---|
date | Tue, 06 Jan 2009 15:16:33 +0000 |
parents | e76576f38ade |
children | 01ec89cc9a10 |
comparison
equal
deleted
inserted
replaced
8537:93a3020d9636 | 8538:35f1b87d908f |
---|---|
1210 for(i=0;i<64;i++){ | 1210 for(i=0;i<64;i++){ |
1211 matrix[new_perm[i]] = temp_matrix[old_perm[i]]; | 1211 matrix[new_perm[i]] = temp_matrix[old_perm[i]]; |
1212 } | 1212 } |
1213 } | 1213 } |
1214 | 1214 |
1215 static enum PixelFormat mpeg_set_pixelformat(AVCodecContext *avctx){ | |
1216 Mpeg1Context *s1 = avctx->priv_data; | |
1217 MpegEncContext *s = &s1->mpeg_enc_ctx; | |
1218 | |
1219 if(avctx->xvmc_acceleration) | |
1220 return avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); | |
1221 else{ | |
1222 if(s->chroma_format < 2) | |
1223 return PIX_FMT_YUV420P; | |
1224 else if(s->chroma_format == 2) | |
1225 return PIX_FMT_YUV422P; | |
1226 else | |
1227 return PIX_FMT_YUV444P; | |
1228 } | |
1229 } | |
1230 | |
1215 /* Call this function when we know all parameters. | 1231 /* Call this function when we know all parameters. |
1216 * It may be called in different places for MPEG-1 and MPEG-2. */ | 1232 * It may be called in different places for MPEG-1 and MPEG-2. */ |
1217 static int mpeg_decode_postinit(AVCodecContext *avctx){ | 1233 static int mpeg_decode_postinit(AVCodecContext *avctx){ |
1218 Mpeg1Context *s1 = avctx->priv_data; | 1234 Mpeg1Context *s1 = avctx->priv_data; |
1219 MpegEncContext *s = &s1->mpeg_enc_ctx; | 1235 MpegEncContext *s = &s1->mpeg_enc_ctx; |
1286 s->avctx->sample_aspect_ratio= | 1302 s->avctx->sample_aspect_ratio= |
1287 ff_mpeg2_aspect[s->aspect_ratio_info]; | 1303 ff_mpeg2_aspect[s->aspect_ratio_info]; |
1288 } | 1304 } |
1289 }//MPEG-2 | 1305 }//MPEG-2 |
1290 | 1306 |
1291 if(avctx->xvmc_acceleration){ | 1307 avctx->pix_fmt = mpeg_set_pixelformat(avctx); |
1292 avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); | |
1293 }else{ | |
1294 if(s->chroma_format < 2){ | |
1295 avctx->pix_fmt = PIX_FMT_YUV420P; | |
1296 }else | |
1297 if(s->chroma_format == 2){ | |
1298 avctx->pix_fmt = PIX_FMT_YUV422P; | |
1299 }else | |
1300 if(s->chroma_format > 2){ | |
1301 avctx->pix_fmt = PIX_FMT_YUV444P; | |
1302 } | |
1303 } | |
1304 //until then pix_fmt may be changed right after codec init | 1308 //until then pix_fmt may be changed right after codec init |
1305 if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ) | 1309 if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ) |
1306 if( avctx->idct_algo == FF_IDCT_AUTO ) | 1310 if( avctx->idct_algo == FF_IDCT_AUTO ) |
1307 avctx->idct_algo = FF_IDCT_SIMPLE; | 1311 avctx->idct_algo = FF_IDCT_SIMPLE; |
1308 | 1312 |
2067 s->width = avctx->coded_width; | 2071 s->width = avctx->coded_width; |
2068 s->height = avctx->coded_height; | 2072 s->height = avctx->coded_height; |
2069 avctx->has_b_frames= 0; //true? | 2073 avctx->has_b_frames= 0; //true? |
2070 s->low_delay= 1; | 2074 s->low_delay= 1; |
2071 | 2075 |
2072 if(avctx->xvmc_acceleration){ | 2076 avctx->pix_fmt = mpeg_set_pixelformat(avctx); |
2073 avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); | |
2074 }else{ | |
2075 avctx->pix_fmt = PIX_FMT_YUV420P; | |
2076 } | |
2077 | 2077 |
2078 if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ) | 2078 if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ) |
2079 if( avctx->idct_algo == FF_IDCT_AUTO ) | 2079 if( avctx->idct_algo == FF_IDCT_AUTO ) |
2080 avctx->idct_algo = FF_IDCT_SIMPLE; | 2080 avctx->idct_algo = FF_IDCT_SIMPLE; |
2081 | 2081 |