Mercurial > libavcodec.hg
comparison parser.c @ 2637:ef44d24680d1 libavcodec
switch to native time bases
| author | michael |
|---|---|
| date | Sat, 30 Apr 2005 21:43:59 +0000 |
| parents | e7f2b8fadfb0 |
| children | 1394b45a7bf4 |
comparison
equal
deleted
inserted
replaced
| 2636:2344c6713011 | 2637:ef44d24680d1 |
|---|---|
| 280 // random, just to avoid segfault !never encode these | 280 // random, just to avoid segfault !never encode these |
| 281 25025, | 281 25025, |
| 282 25025, | 282 25025, |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 //FIXME move into mpeg12.c | |
| 285 static void mpegvideo_extract_headers(AVCodecParserContext *s, | 286 static void mpegvideo_extract_headers(AVCodecParserContext *s, |
| 286 AVCodecContext *avctx, | 287 AVCodecContext *avctx, |
| 287 const uint8_t *buf, int buf_size) | 288 const uint8_t *buf, int buf_size) |
| 288 { | 289 { |
| 289 ParseContext1 *pc = s->priv_data; | 290 ParseContext1 *pc = s->priv_data; |
| 309 if (bytes_left >= 7) { | 310 if (bytes_left >= 7) { |
| 310 pc->width = (buf[0] << 4) | (buf[1] >> 4); | 311 pc->width = (buf[0] << 4) | (buf[1] >> 4); |
| 311 pc->height = ((buf[1] & 0x0f) << 8) | buf[2]; | 312 pc->height = ((buf[1] & 0x0f) << 8) | buf[2]; |
| 312 avcodec_set_dimensions(avctx, pc->width, pc->height); | 313 avcodec_set_dimensions(avctx, pc->width, pc->height); |
| 313 frame_rate_index = buf[3] & 0xf; | 314 frame_rate_index = buf[3] & 0xf; |
| 314 pc->frame_rate = avctx->frame_rate = frame_rate_tab[frame_rate_index]; | 315 pc->frame_rate = avctx->time_base.den = frame_rate_tab[frame_rate_index]; |
| 315 avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE; | 316 avctx->time_base.num = MPEG1_FRAME_RATE_BASE; |
| 316 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; | 317 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; |
| 317 avctx->codec_id = CODEC_ID_MPEG1VIDEO; | 318 avctx->codec_id = CODEC_ID_MPEG1VIDEO; |
| 318 avctx->sub_id = 1; | 319 avctx->sub_id = 1; |
| 319 } | 320 } |
| 320 break; | 321 break; |
| 334 | 335 |
| 335 pc->width |=(horiz_size_ext << 12); | 336 pc->width |=(horiz_size_ext << 12); |
| 336 pc->height |=( vert_size_ext << 12); | 337 pc->height |=( vert_size_ext << 12); |
| 337 avctx->bit_rate += (bit_rate_ext << 18) * 400; | 338 avctx->bit_rate += (bit_rate_ext << 18) * 400; |
| 338 avcodec_set_dimensions(avctx, pc->width, pc->height); | 339 avcodec_set_dimensions(avctx, pc->width, pc->height); |
| 339 avctx->frame_rate = pc->frame_rate * (frame_rate_ext_n + 1); | 340 avctx->time_base.den = pc->frame_rate * (frame_rate_ext_n + 1); |
| 340 avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1); | 341 avctx->time_base.num = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1); |
| 341 avctx->codec_id = CODEC_ID_MPEG2VIDEO; | 342 avctx->codec_id = CODEC_ID_MPEG2VIDEO; |
| 342 avctx->sub_id = 2; /* forces MPEG2 */ | 343 avctx->sub_id = 2; /* forces MPEG2 */ |
| 343 } | 344 } |
| 344 break; | 345 break; |
| 345 case 0x8: /* picture coding extension */ | 346 case 0x8: /* picture coding extension */ |
| 404 to have the full timing information. The time take by this | 405 to have the full timing information. The time take by this |
| 405 function should be negligible for uncorrupted streams */ | 406 function should be negligible for uncorrupted streams */ |
| 406 mpegvideo_extract_headers(s, avctx, buf, buf_size); | 407 mpegvideo_extract_headers(s, avctx, buf, buf_size); |
| 407 #if 0 | 408 #if 0 |
| 408 printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", | 409 printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", |
| 409 s->pict_type, (double)avctx->frame_rate / avctx->frame_rate_base, s->repeat_pict); | 410 s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict); |
| 410 #endif | 411 #endif |
| 411 | 412 |
| 412 *poutbuf = (uint8_t *)buf; | 413 *poutbuf = (uint8_t *)buf; |
| 413 *poutbuf_size = buf_size; | 414 *poutbuf_size = buf_size; |
| 414 return next; | 415 return next; |
