Mercurial > libavformat.hg
comparison mpeg.c @ 820:feca73904e67 libavformat
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
author | michael |
---|---|
date | Sun, 17 Jul 2005 22:24:36 +0000 |
parents | 411b75055a43 |
children | 66cc656ea404 |
comparison
equal
deleted
inserted
replaced
819:a6c035e7f429 | 820:feca73904e67 |
---|---|
358 goto fail; | 358 goto fail; |
359 st->priv_data = stream; | 359 st->priv_data = stream; |
360 | 360 |
361 av_set_pts_info(st, 64, 1, 90000); | 361 av_set_pts_info(st, 64, 1, 90000); |
362 | 362 |
363 switch(st->codec.codec_type) { | 363 switch(st->codec->codec_type) { |
364 case CODEC_TYPE_AUDIO: | 364 case CODEC_TYPE_AUDIO: |
365 if (st->codec.codec_id == CODEC_ID_AC3) { | 365 if (st->codec->codec_id == CODEC_ID_AC3) { |
366 stream->id = ac3_id++; | 366 stream->id = ac3_id++; |
367 } else if (st->codec.codec_id == CODEC_ID_DTS) { | 367 } else if (st->codec->codec_id == CODEC_ID_DTS) { |
368 stream->id = dts_id++; | 368 stream->id = dts_id++; |
369 } else if (st->codec.codec_id == CODEC_ID_PCM_S16BE) { | 369 } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) { |
370 stream->id = lpcm_id++; | 370 stream->id = lpcm_id++; |
371 for(j = 0; j < 4; j++) { | 371 for(j = 0; j < 4; j++) { |
372 if (lpcm_freq_tab[j] == st->codec.sample_rate) | 372 if (lpcm_freq_tab[j] == st->codec->sample_rate) |
373 break; | 373 break; |
374 } | 374 } |
375 if (j == 4) | 375 if (j == 4) |
376 goto fail; | 376 goto fail; |
377 if (st->codec.channels > 8) | 377 if (st->codec->channels > 8) |
378 return -1; | 378 return -1; |
379 stream->lpcm_header[0] = 0x0c; | 379 stream->lpcm_header[0] = 0x0c; |
380 stream->lpcm_header[1] = (st->codec.channels - 1) | (j << 4); | 380 stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4); |
381 stream->lpcm_header[2] = 0x80; | 381 stream->lpcm_header[2] = 0x80; |
382 stream->lpcm_align = st->codec.channels * 2; | 382 stream->lpcm_align = st->codec->channels * 2; |
383 } else { | 383 } else { |
384 stream->id = mpa_id++; | 384 stream->id = mpa_id++; |
385 } | 385 } |
386 | 386 |
387 /* This value HAS to be used for VCD (see VCD standard, p. IV-7). | 387 /* This value HAS to be used for VCD (see VCD standard, p. IV-7). |
389 stream->max_buffer_size = 4 * 1024; | 389 stream->max_buffer_size = 4 * 1024; |
390 s->audio_bound++; | 390 s->audio_bound++; |
391 break; | 391 break; |
392 case CODEC_TYPE_VIDEO: | 392 case CODEC_TYPE_VIDEO: |
393 stream->id = mpv_id++; | 393 stream->id = mpv_id++; |
394 if (st->codec.rc_buffer_size) | 394 if (st->codec->rc_buffer_size) |
395 stream->max_buffer_size = 6*1024 + st->codec.rc_buffer_size/8; | 395 stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8; |
396 else | 396 else |
397 stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default | 397 stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default |
398 #if 0 | 398 #if 0 |
399 /* see VCD standard, p. IV-7*/ | 399 /* see VCD standard, p. IV-7*/ |
400 stream->max_buffer_size = 46 * 1024; | 400 stream->max_buffer_size = 46 * 1024; |
420 for(i=0;i<ctx->nb_streams;i++) { | 420 for(i=0;i<ctx->nb_streams;i++) { |
421 int codec_rate; | 421 int codec_rate; |
422 st = ctx->streams[i]; | 422 st = ctx->streams[i]; |
423 stream = (StreamInfo*) st->priv_data; | 423 stream = (StreamInfo*) st->priv_data; |
424 | 424 |
425 if(st->codec.rc_max_rate || stream->id==VIDEO_ID) | 425 if(st->codec->rc_max_rate || stream->id==VIDEO_ID) |
426 codec_rate= st->codec.rc_max_rate; | 426 codec_rate= st->codec->rc_max_rate; |
427 else | 427 else |
428 codec_rate= st->codec.bit_rate; | 428 codec_rate= st->codec->bit_rate; |
429 | 429 |
430 if(!codec_rate) | 430 if(!codec_rate) |
431 codec_rate= (1<<21)*8*50/ctx->nb_streams; | 431 codec_rate= (1<<21)*8*50/ctx->nb_streams; |
432 | 432 |
433 bitrate += codec_rate; | 433 bitrate += codec_rate; |
1071 PacketDesc *next_pkt= stream->premux_packet; | 1071 PacketDesc *next_pkt= stream->premux_packet; |
1072 | 1072 |
1073 /* for subtitle, a single PES packet must be generated, | 1073 /* for subtitle, a single PES packet must be generated, |
1074 so we flush after every single subtitle packet */ | 1074 so we flush after every single subtitle packet */ |
1075 if(s->packet_size > avail_data && !flush | 1075 if(s->packet_size > avail_data && !flush |
1076 && st->codec.codec_type != CODEC_TYPE_SUBTITLE) | 1076 && st->codec->codec_type != CODEC_TYPE_SUBTITLE) |
1077 return 0; | 1077 return 0; |
1078 if(avail_data==0) | 1078 if(avail_data==0) |
1079 continue; | 1079 continue; |
1080 assert(avail_data>0); | 1080 assert(avail_data>0); |
1081 | 1081 |
1181 AVStream *st = ctx->streams[stream_index]; | 1181 AVStream *st = ctx->streams[stream_index]; |
1182 StreamInfo *stream = st->priv_data; | 1182 StreamInfo *stream = st->priv_data; |
1183 int64_t pts, dts; | 1183 int64_t pts, dts; |
1184 PacketDesc *pkt_desc; | 1184 PacketDesc *pkt_desc; |
1185 const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE); | 1185 const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE); |
1186 const int is_iframe = st->codec.codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY); | 1186 const int is_iframe = st->codec->codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY); |
1187 | 1187 |
1188 pts= pkt->pts; | 1188 pts= pkt->pts; |
1189 dts= pkt->dts; | 1189 dts= pkt->dts; |
1190 | 1190 |
1191 if(pts != AV_NOPTS_VALUE) pts += preload; | 1191 if(pts != AV_NOPTS_VALUE) pts += preload; |
1632 } | 1632 } |
1633 /* no stream found: add a new stream */ | 1633 /* no stream found: add a new stream */ |
1634 st = av_new_stream(s, startcode); | 1634 st = av_new_stream(s, startcode); |
1635 if (!st) | 1635 if (!st) |
1636 goto skip; | 1636 goto skip; |
1637 st->codec.codec_type = type; | 1637 st->codec->codec_type = type; |
1638 st->codec.codec_id = codec_id; | 1638 st->codec->codec_id = codec_id; |
1639 if (codec_id != CODEC_ID_PCM_S16BE) | 1639 if (codec_id != CODEC_ID_PCM_S16BE) |
1640 st->need_parsing = 1; | 1640 st->need_parsing = 1; |
1641 found: | 1641 found: |
1642 if(st->discard >= AVDISCARD_ALL) | 1642 if(st->discard >= AVDISCARD_ALL) |
1643 goto skip; | 1643 goto skip; |
1651 get_byte(&s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */ | 1651 get_byte(&s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */ |
1652 b1 = get_byte(&s->pb); /* quant (2), freq(2), reserved(1), channels(3) */ | 1652 b1 = get_byte(&s->pb); /* quant (2), freq(2), reserved(1), channels(3) */ |
1653 get_byte(&s->pb); /* dynamic range control (0x80 = off) */ | 1653 get_byte(&s->pb); /* dynamic range control (0x80 = off) */ |
1654 len -= 3; | 1654 len -= 3; |
1655 freq = (b1 >> 4) & 3; | 1655 freq = (b1 >> 4) & 3; |
1656 st->codec.sample_rate = lpcm_freq_tab[freq]; | 1656 st->codec->sample_rate = lpcm_freq_tab[freq]; |
1657 st->codec.channels = 1 + (b1 & 7); | 1657 st->codec->channels = 1 + (b1 & 7); |
1658 st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * 2; | 1658 st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * 2; |
1659 } | 1659 } |
1660 av_new_packet(pkt, len); | 1660 av_new_packet(pkt, len); |
1661 get_buffer(&s->pb, pkt->data, pkt->size); | 1661 get_buffer(&s->pb, pkt->data, pkt->size); |
1662 pkt->pts = pts; | 1662 pkt->pts = pts; |
1663 pkt->dts = dts; | 1663 pkt->dts = dts; |