[FFmpeg-cvslog] avformat/dss: set bitrate

Michael Niedermayer git at videolan.org
Thu Feb 26 02:30:46 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Feb 24 14:57:39 2015 +0100| [626904b77797cf541bf95204a8939e9c8efe95f0] | committer: Michael Niedermayer

avformat/dss: set bitrate

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=626904b77797cf541bf95204a8939e9c8efe95f0
---

 libavformat/dss.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavformat/dss.c b/libavformat/dss.c
index 0992d68..ae5b24c 100644
--- a/libavformat/dss.c
+++ b/libavformat/dss.c
@@ -54,6 +54,8 @@ typedef struct DSSDemuxContext {
     int swap;
     int dss_sp_swap_byte;
     int8_t *dss_sp_buf;
+
+    int packet_size;
 } DSSDemuxContext;
 
 static int dss_probe(AVProbeData *p)
@@ -210,6 +212,7 @@ static void dss_sp_byte_swap(DSSDemuxContext *ctx,
 static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     DSSDemuxContext *ctx = s->priv_data;
+    AVStream *st = s->streams[0];
     int read_size, ret, offset = 0, buff_offset = 0;
     int64_t pos = avio_tell(s->pb);
 
@@ -223,6 +226,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
         read_size = DSS_FRAME_SIZE;
 
     ctx->counter -= read_size;
+    ctx->packet_size = DSS_FRAME_SIZE - 1;
 
     ret = av_new_packet(pkt, DSS_FRAME_SIZE);
     if (ret < 0)
@@ -231,6 +235,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->duration     = 264;
     pkt->pos = pos;
     pkt->stream_index = 0;
+    s->bit_rate = 8LL * ctx->packet_size * st->codec->sample_rate * 512 / (506 * pkt->duration);
 
     if (ctx->counter < 0) {
         int size2 = ctx->counter + read_size;
@@ -264,6 +269,7 @@ error_eof:
 static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     DSSDemuxContext *ctx = s->priv_data;
+    AVStream *st = s->streams[0];
     int size, byte, ret, offset;
     int64_t pos = avio_tell(s->pb);
 
@@ -277,6 +283,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     size = frame_size[byte & 3];
 
+    ctx->packet_size = size;
     ctx->counter -= size;
 
     ret = av_new_packet(pkt, size);
@@ -287,6 +294,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->data[0]  = byte;
     offset        = 1;
     pkt->duration = 240;
+    s->bit_rate = 8LL * size * st->codec->sample_rate * 512 / (506 * pkt->duration);
 
     pkt->stream_index = 0;
 



More information about the ffmpeg-cvslog mailing list