diff mbox series

[FFmpeg-devel,164/281] voc: convert to new channel layout API

Message ID 20220113020026.590-16-jamrial@gmail.com
State New
Headers show
Series New channel layout API
Related show

Commit Message

James Almer Jan. 13, 2022, 2 a.m. UTC
From: Vittorio Giovara <vittorio.giovara@gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/voc_packet.c | 9 ++++++---
 libavformat/vocenc.c     | 9 +++++----
 2 files changed, 11 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/voc_packet.c b/libavformat/voc_packet.c
index e5ae0be1de..a7ce2707a0 100644
--- a/libavformat/voc_packet.c
+++ b/libavformat/voc_packet.c
@@ -72,7 +72,8 @@  ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
                 if (sample_rate)
                     par->sample_rate = sample_rate;
                 avpriv_set_pts_info(st, 64, 1, par->sample_rate);
-                par->channels = channels;
+                par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+                par->ch_layout.nb_channels = channels;
                 par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
             } else
                 avio_skip(pb, 1);
@@ -103,7 +104,9 @@  ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
                 par->sample_rate = avio_rl32(pb);
                 avpriv_set_pts_info(st, 64, 1, par->sample_rate);
                 par->bits_per_coded_sample = avio_r8(pb);
-                par->channels = avio_r8(pb);
+                channels = avio_r8(pb);
+                par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+                par->ch_layout.nb_channels = channels;
             } else
                 avio_skip(pb, 6);
             tmp_codec = avio_rl16(pb);
@@ -140,7 +143,7 @@  ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
         }
     }
 
-    par->bit_rate = (int64_t)par->sample_rate * par->channels * par->bits_per_coded_sample;
+    par->bit_rate = (int64_t)par->sample_rate * par->ch_layout.nb_channels * par->bits_per_coded_sample;
 
     if (max_size <= 0)
         max_size = 2048;
diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
index 798b463a82..59c2bbba7b 100644
--- a/libavformat/vocenc.c
+++ b/libavformat/vocenc.c
@@ -63,16 +63,17 @@  static int voc_write_packet(AVFormatContext *s, AVPacket *pkt)
             avio_wl24(pb, pkt->size + 12);
             avio_wl32(pb, par->sample_rate);
             avio_w8(pb, par->bits_per_coded_sample);
-            avio_w8(pb, par->channels);
+            avio_w8(pb, par->ch_layout.nb_channels);
             avio_wl16(pb, par->codec_tag);
             avio_wl32(pb, 0);
         } else {
-            if (s->streams[0]->codecpar->channels > 1) {
+            if (s->streams[0]->codecpar->ch_layout.nb_channels > 1) {
                 avio_w8(pb, VOC_TYPE_EXTENDED);
                 avio_wl24(pb, 4);
-                avio_wl16(pb, 65536-(256000000 + par->sample_rate*par->channels/2)/(par->sample_rate*par->channels));
+                avio_wl16(pb, 65536 - (256000000 + par->sample_rate * par->ch_layout.nb_channels / 2) /
+                                      (par->sample_rate * par->ch_layout.nb_channels));
                 avio_w8(pb, par->codec_tag);
-                avio_w8(pb, par->channels - 1);
+                avio_w8(pb, par->ch_layout.nb_channels - 1);
             }
             avio_w8(pb, VOC_TYPE_VOICE_DATA);
             avio_wl24(pb, pkt->size + 2);