Ticket #738: vbr.2.diff
| File vbr.2.diff, 3.3 KB (added by , 20 years ago) |
|---|
-
libavcodec/avcodec.h
837 837 int frame_size; 838 838 int frame_number; ///< audio or video frame number 839 839 int real_pict_num; ///< returns the real picture number of previous encoded frame 840 int total_frames; ///< Total number of frames provided by some VBR headers 840 841 841 842 /** 842 843 * number of frames the decoded output will be delayed relative to -
libavcodec/mpegaudiodec.c
169 169 SCALE_GEN(4.0 / 9.0), /* 9 steps */ 170 170 }; 171 171 172 static const int side_info_size[2][2] = { 173 {32,17}, /* MPEG 1 */ 174 {17,9} /* MPEG 2/2.5 */ 175 }; 176 172 177 static MPA_INT window[512] __attribute__((aligned(16))); 173 178 174 179 /* layer 1 unscaling */ … … 2549 2554 MPADecodeContext *s = avctx->priv_data; 2550 2555 uint32_t header; 2551 2556 int out_size; 2557 int offset; 2552 2558 OUT_INT *out_samples = data; 2553 2559 2554 2560 retry: … … 2572 2578 avctx->channels = s->nb_channels; 2573 2579 avctx->bit_rate = s->bit_rate; 2574 2580 avctx->sub_id = s->layer; 2581 avctx->total_frames=0; 2575 2582 switch(s->layer) { 2576 2583 case 1: 2577 2584 avctx->frame_size = 384; … … 2587 2594 break; 2588 2595 } 2589 2596 2597 /* look for Xing or Info VBR header */ 2598 offset = HEADER_SIZE + side_info_size[s->lsf][s->mode == MPA_MONO ? 1 : 0]; 2599 2600 if ((buf[offset] == 'X' && buf[offset+1] == 'i' && buf[offset+2] == 'n' && buf[offset+3] == 'g') || 2601 (buf[offset] == 'I' && buf[offset+1] == 'n' && buf[offset+2] == 'f' && buf[offset+3] == 'o')) { 2602 uint32_t vbr_flags = (buf[offset+4] << 24) | (buf[offset+5] << 16) | (buf[offset+6] << 8) | buf[offset+7]; 2603 2604 /* Look for frame count */ 2605 if (vbr_flags & 0x0001) 2606 avctx->total_frames=(buf[offset+8] << 24) | (buf[offset+9] << 16) | (buf[offset+10] << 8) | buf[offset+11]; 2607 } 2608 2590 2609 if(s->frame_size<=0 || s->frame_size > buf_size){ 2591 2610 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); 2592 2611 return -1; -
libavformat/utils.c
1550 1550 st->start_time = 0; 1551 1551 st->duration = duration; 1552 1552 } 1553 if (st->codec->total_frames) 1554 st->duration = av_rescale(st->codec->total_frames * st->codec->frame_size / st->codec->sample_rate, st->time_base.den, st->time_base.num); 1553 1555 } 1554 1556 } 1555 1557 } … … 1643 1645 if (st->duration == AV_NOPTS_VALUE || 1644 1646 st->duration < duration) 1645 1647 st->duration = duration; 1648 if (st->codec->total_frames) 1649 st->duration = av_rescale(st->codec->total_frames * st->codec->frame_size / st->codec->sample_rate, st->time_base.den, st->time_base.num); 1646 1650 } 1647 1651 } 1648 1652 av_free_packet(pkt); … … 2110 2114 if (s->iformat) { 2111 2115 /* no default bitrate if decoding */ 2112 2116 st->codec->bit_rate = 0; 2117 st->codec->total_frames = 0; 2113 2118 } 2114 2119 st->index = s->nb_streams; 2115 2120 st->id = id;
