[FFmpeg-cvslog] af_pan: comment a tricky piece of code.

Nicolas George git at videolan.org
Wed Feb 15 20:12:36 CET 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Wed Feb 15 19:41:41 2012 +0100| [bd5080b1b00032c656c6e5893755a92cb0221a2d] | committer: Nicolas George

af_pan: comment a tricky piece of code.

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

 libavfilter/af_pan.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index 9f293a6..119111d 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -64,14 +64,17 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
     int len, i, channel_id = 0;
     int64_t layout, layout0;
 
+    /* try to parse a channel name, e.g. "FL" */
     if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {
         layout0 = layout = av_get_channel_layout(buf);
+        /* channel_id <- first set bit in layout */
         for (i = 32; i > 0; i >>= 1) {
             if (layout >= (int64_t)1 << i) {
                 channel_id += i;
                 layout >>= i;
             }
         }
+        /* reject layouts that are not a single channel */
         if (channel_id >= MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)
             return AVERROR(EINVAL);
         *rchannel = channel_id;
@@ -79,6 +82,7 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
         *arg += len;
         return 0;
     }
+    /* try to parse a channel number, e.g. "c2" */
     if (sscanf(*arg, " c%d %n", &channel_id, &len) &&
         channel_id >= 0 && channel_id < MAX_CHANNELS) {
         *rchannel = channel_id;



More information about the ffmpeg-cvslog mailing list