Mercurial > libavcodec.hg
comparison parser.c @ 4146:c09e31f70a30 libavcodec
use AVRational and ff_frame_rate_tab for frame_rate
author | bcoudurier |
---|---|
date | Sun, 05 Nov 2006 19:24:23 +0000 |
parents | daae66c03857 |
children | 2205aefb22b7 |
comparison
equal
deleted
inserted
replaced
4145:a5fca6fd5e4c | 4146:c09e31f70a30 |
---|---|
223 | 223 |
224 typedef struct ParseContext1{ | 224 typedef struct ParseContext1{ |
225 ParseContext pc; | 225 ParseContext pc; |
226 /* XXX/FIXME PC1 vs. PC */ | 226 /* XXX/FIXME PC1 vs. PC */ |
227 /* MPEG2 specific */ | 227 /* MPEG2 specific */ |
228 int frame_rate; | 228 AVRational frame_rate; |
229 int progressive_sequence; | 229 int progressive_sequence; |
230 int width, height; | 230 int width, height; |
231 | 231 |
232 /* XXX: suppress that, needed by MPEG4 */ | 232 /* XXX: suppress that, needed by MPEG4 */ |
233 MpegEncContext *enc; | 233 MpegEncContext *enc; |
294 #endif | 294 #endif |
295 | 295 |
296 return 0; | 296 return 0; |
297 } | 297 } |
298 | 298 |
299 /* XXX: merge with libavcodec ? */ | |
300 #define MPEG1_FRAME_RATE_BASE 1001 | |
301 | |
302 static const int frame_rate_tab[16] = { | |
303 0, | |
304 24000, | |
305 24024, | |
306 25025, | |
307 30000, | |
308 30030, | |
309 50050, | |
310 60000, | |
311 60060, | |
312 // Xing's 15fps: (9) | |
313 15015, | |
314 // libmpeg3's "Unofficial economy rates": (10-13) | |
315 5005, | |
316 10010, | |
317 12012, | |
318 15015, | |
319 // random, just to avoid segfault !never encode these | |
320 25025, | |
321 25025, | |
322 }; | |
323 | |
324 #ifdef CONFIG_MPEGVIDEO_PARSER | 299 #ifdef CONFIG_MPEGVIDEO_PARSER |
300 | |
301 extern const AVRational ff_frame_rate_tab[]; | |
302 | |
325 //FIXME move into mpeg12.c | 303 //FIXME move into mpeg12.c |
326 static void mpegvideo_extract_headers(AVCodecParserContext *s, | 304 static void mpegvideo_extract_headers(AVCodecParserContext *s, |
327 AVCodecContext *avctx, | 305 AVCodecContext *avctx, |
328 const uint8_t *buf, int buf_size) | 306 const uint8_t *buf, int buf_size) |
329 { | 307 { |
351 if (bytes_left >= 7) { | 329 if (bytes_left >= 7) { |
352 pc->width = (buf[0] << 4) | (buf[1] >> 4); | 330 pc->width = (buf[0] << 4) | (buf[1] >> 4); |
353 pc->height = ((buf[1] & 0x0f) << 8) | buf[2]; | 331 pc->height = ((buf[1] & 0x0f) << 8) | buf[2]; |
354 avcodec_set_dimensions(avctx, pc->width, pc->height); | 332 avcodec_set_dimensions(avctx, pc->width, pc->height); |
355 frame_rate_index = buf[3] & 0xf; | 333 frame_rate_index = buf[3] & 0xf; |
356 pc->frame_rate = avctx->time_base.den = frame_rate_tab[frame_rate_index]; | 334 pc->frame_rate.den = avctx->time_base.den = ff_frame_rate_tab[frame_rate_index].num; |
357 avctx->time_base.num = MPEG1_FRAME_RATE_BASE; | 335 pc->frame_rate.num = avctx->time_base.num = ff_frame_rate_tab[frame_rate_index].den; |
358 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; | 336 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; |
359 avctx->codec_id = CODEC_ID_MPEG1VIDEO; | 337 avctx->codec_id = CODEC_ID_MPEG1VIDEO; |
360 avctx->sub_id = 1; | 338 avctx->sub_id = 1; |
361 } | 339 } |
362 break; | 340 break; |
376 | 354 |
377 pc->width |=(horiz_size_ext << 12); | 355 pc->width |=(horiz_size_ext << 12); |
378 pc->height |=( vert_size_ext << 12); | 356 pc->height |=( vert_size_ext << 12); |
379 avctx->bit_rate += (bit_rate_ext << 18) * 400; | 357 avctx->bit_rate += (bit_rate_ext << 18) * 400; |
380 avcodec_set_dimensions(avctx, pc->width, pc->height); | 358 avcodec_set_dimensions(avctx, pc->width, pc->height); |
381 avctx->time_base.den = pc->frame_rate * (frame_rate_ext_n + 1); | 359 avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1); |
382 avctx->time_base.num = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1); | 360 avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1); |
383 avctx->codec_id = CODEC_ID_MPEG2VIDEO; | 361 avctx->codec_id = CODEC_ID_MPEG2VIDEO; |
384 avctx->sub_id = 2; /* forces MPEG2 */ | 362 avctx->sub_id = 2; /* forces MPEG2 */ |
385 } | 363 } |
386 break; | 364 break; |
387 case 0x8: /* picture coding extension */ | 365 case 0x8: /* picture coding extension */ |