Sophie

Sophie

distrib > Mageia > 9 > aarch64 > media > tainted-updates-src > by-pkgid > 87f6abd9731100975df9ce2bba2ea34a > files > 11

mplayer-1.5-12.1.mga9.tainted.src.rpm

Index: av_helpers.c
===================================================================
--- av_helpers.c	(revision 38410)
+++ av_helpers.c	(working copy)
@@ -116,38 +116,39 @@
 {
     void *orig_src = src;
     int bps = av_get_bytes_per_sample(ctx->sample_fmt);
-    int planar = ctx->channels > 1 && av_sample_fmt_is_planar(ctx->sample_fmt);
+    int channels = ctx->channels > 0 ? ctx->channels : ctx->ch_layout.nb_channels;
+    int planar = channels > 1 && av_sample_fmt_is_planar(ctx->sample_fmt);
     int isac3 = ctx->codec->id == AV_CODEC_ID_AC3;
     int n;
     int got;
     AVPacket pkt;
     AVFrame *frame = av_frame_alloc();
-    if ((ctx->channels == 6 || ctx->channels == 5) &&
+    if ((channels == 6 || channels == 5) &&
         (isac3 || !strcmp(ctx->codec->name,"libfaac"))) {
         reorder_channel_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
                             isac3 ? AF_CHANNEL_LAYOUT_LAVC_DEFAULT : AF_CHANNEL_LAYOUT_AAC_DEFAULT,
-                            ctx->channels,
+                            channels,
                             src_len / bps, bps);
     }
-    frame->nb_samples = src_len / ctx->channels / bps;
+    frame->nb_samples = src_len / channels / bps;
     if (planar) {
         // TODO: this is horribly inefficient.
         int ch;
         src = av_mallocz(src_len);
-        for (ch = 0; ch < ctx->channels; ch++) {
+        for (ch = 0; ch < channels; ch++) {
             uint8_t *tmps = (uint8_t *)orig_src + ch*bps;
-            uint8_t *tmpd = (uint8_t *)src + ch*src_len/ctx->channels;
+            uint8_t *tmpd = (uint8_t *)src + ch*src_len/channels;
             int s;
             for (s = 0; s < frame->nb_samples; s++) {
                 memcpy(tmpd, tmps, bps);
-                tmps += ctx->channels * bps;
+                tmps += channels * bps;
                 tmpd += bps;
             }
         }
     }
     frame->format = ctx->sample_fmt;
-    frame->channels = ctx->channels;
-    n = avcodec_fill_audio_frame(frame, ctx->channels, ctx->sample_fmt, src, src_len, 1);
+    frame->channels = channels;
+    n = avcodec_fill_audio_frame(frame, channels, ctx->sample_fmt, src, src_len, 1);
     if (n < 0) return 0;
     n = avcodec_send_frame(ctx, frame);
     av_init_packet(&pkt);