diff mbox series

[FFmpeg-devel,3/7] avformat/dss: Set values known during read_header in read_header

Message ID HE1PR0301MB21543C7E8D551F95DA0EAD058F7B9@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit ef8c8b4163e5ff156b6511eda9cdfdb0828ee8dc
Headers show
Series [FFmpeg-devel,1/7] avformat/utils: Check allocations for failure
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 1, 2021, 9:26 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/dss.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/dss.c b/libavformat/dss.c
index 468de3fe84..0b6d68af99 100644
--- a/libavformat/dss.c
+++ b/libavformat/dss.c
@@ -144,6 +144,8 @@  static int dss_read_header(AVFormatContext *s)
     if (ctx->audio_codec == DSS_ACODEC_DSS_SP) {
         st->codecpar->codec_id    = AV_CODEC_ID_DSS_SP;
         st->codecpar->sample_rate = 11025;
+        s->bit_rate = 8 * (DSS_FRAME_SIZE - 1) * st->codecpar->sample_rate
+                        * 512 / (506 * 264);
     } else if (ctx->audio_codec == DSS_ACODEC_G723_1) {
         st->codecpar->codec_id    = AV_CODEC_ID_G723_1;
         st->codecpar->sample_rate = 8000;
@@ -206,7 +208,6 @@  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);
 
@@ -219,8 +220,6 @@  static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
     } else
         read_size = DSS_FRAME_SIZE;
 
-    ctx->packet_size = DSS_FRAME_SIZE - 1;
-
     ret = av_new_packet(pkt, DSS_FRAME_SIZE);
     if (ret < 0)
         return ret;
@@ -228,7 +227,6 @@  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->codecpar->sample_rate * 512 / (506 * pkt->duration);
 
     if (ctx->counter < read_size) {
         ret = avio_read(s->pb, ctx->dss_sp_buf + buff_offset,