diff mbox series

[FFmpeg-devel,08/15] avformat/pcmdec: Beautify pcm_read_header

Message ID 20210224115341.794293-8-andreas.rheinhardt@gmail.com
State Accepted
Commit 3d79ce0c29fbaca70ac3f0ac5c2e46c860bd59f9
Headers show
Series [FFmpeg-devel,01/15] avformat/movenc: Remove always true check | expand

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 Feb. 24, 2021, 11:53 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/pcmdec.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index cd3e7b2e8f..9b552936ac 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -36,18 +36,19 @@  typedef struct PCMAudioDemuxerContext {
 static int pcm_read_header(AVFormatContext *s)
 {
     PCMAudioDemuxerContext *s1 = s->priv_data;
+    AVCodecParameters *par;
     AVStream *st;
     uint8_t *mime_type = NULL;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
+    par = st->codecpar;
 
-
-    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codecpar->codec_id    = s->iformat->raw_codec_id;
-    st->codecpar->sample_rate = s1->sample_rate;
-    st->codecpar->channels    = s1->channels;
+    par->codec_type  = AVMEDIA_TYPE_AUDIO;
+    par->codec_id    = s->iformat->raw_codec_id;
+    par->sample_rate = s1->sample_rate;
+    par->channels    = s1->channels;
 
     av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
     if (mime_type && s->iformat->mime_type) {
@@ -61,7 +62,7 @@  static int pcm_read_header(AVFormatContext *s)
                 if (!channels)
                     sscanf(options, " channels=%d", &channels);
                 if (!little_endian) {
-                     char val[14]; /* sizeof("little-endian") == 14 */
+                     char val[sizeof("little-endian")];
                      if (sscanf(options, " endianness=%13s", val) == 1) {
                          little_endian = strcmp(val, "little-endian") == 0;
                      }
@@ -74,24 +75,22 @@  static int pcm_read_header(AVFormatContext *s)
                 av_freep(&mime_type);
                 return AVERROR_INVALIDDATA;
             }
-            st->codecpar->sample_rate = rate;
+            par->sample_rate = rate;
             if (channels > 0)
-                st->codecpar->channels = channels;
+                par->channels = channels;
             if (little_endian)
-                st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+                par->codec_id = AV_CODEC_ID_PCM_S16LE;
         }
     }
     av_freep(&mime_type);
 
-    st->codecpar->bits_per_coded_sample =
-        av_get_bits_per_sample(st->codecpar->codec_id);
+    par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
 
-    av_assert0(st->codecpar->bits_per_coded_sample > 0);
+    av_assert0(par->bits_per_coded_sample > 0);
 
-    st->codecpar->block_align =
-        st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
+    par->block_align = par->bits_per_coded_sample * par->channels / 8;
 
-    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, par->sample_rate);
     return 0;
 }