]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pcm-mpeg.c
flacdec: allow mid-stream channel layout change
[ffmpeg] / libavcodec / pcm-mpeg.c
index 3604013e08f519a9a1fe538f33f09edec4ffe69a..b5af6493b72a4435822747aefa68e918b8e6c254 100644 (file)
@@ -70,13 +70,14 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
     /* get the sample depth and derive the sample format from it */
     avctx->bits_per_coded_sample = bits_per_samples[header[3] >> 6];
     if (!avctx->bits_per_coded_sample) {
-        av_log(avctx, AV_LOG_ERROR, "unsupported sample depth (0)\n");
+        av_log(avctx, AV_LOG_ERROR, "reserved sample depth (0)\n");
         return -1;
     }
     avctx->sample_fmt = avctx->bits_per_coded_sample == 16 ? AV_SAMPLE_FMT_S16 :
                                                              AV_SAMPLE_FMT_S32;
+    avctx->bits_per_raw_sample = avctx->bits_per_coded_sample;
 
-    /* get the sample rate. Not all values are known or exist. */
+    /* get the sample rate. Not all values are used. */
     switch (header[2] & 0x0f) {
     case 1:
         avctx->sample_rate = 48000;
@@ -89,13 +90,13 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
         break;
     default:
         avctx->sample_rate = 0;
-        av_log(avctx, AV_LOG_ERROR, "unsupported sample rate (%d)\n",
+        av_log(avctx, AV_LOG_ERROR, "reserved sample rate (%d)\n",
                header[2] & 0x0f);
         return -1;
     }
 
     /*
-     * get the channel number (and mapping). Not all values are known or exist.
+     * get the channel number (and mapping). Not all values are used.
      * It must be noted that the number of channels in the MPEG stream can
      * differ from the actual meaningful number, e.g. mono audio still has two
      * channels, one being empty.
@@ -103,17 +104,17 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
     avctx->channel_layout  = channel_layouts[channel_layout];
     avctx->channels        =        channels[channel_layout];
     if (!avctx->channels) {
-        av_log(avctx, AV_LOG_ERROR, "unsupported channel configuration (%d)\n",
+        av_log(avctx, AV_LOG_ERROR, "reserved channel configuration (%d)\n",
                channel_layout);
         return -1;
     }
 
-    avctx->bit_rate = avctx->channels * avctx->sample_rate *
+    avctx->bit_rate = FFALIGN(avctx->channels, 2) * avctx->sample_rate *
                       avctx->bits_per_coded_sample;
 
     if (avctx->debug & FF_DEBUG_PICT_INFO)
         av_dlog(avctx,
-                "pcm_bluray_parse_header: %d channels, %d bits per sample, %d kHz, %d kbit\n",
+                "pcm_bluray_parse_header: %d channels, %d bits per sample, %d Hz, %d bit/s\n",
                 avctx->channels, avctx->bits_per_coded_sample,
                 avctx->sample_rate, avctx->bit_rate);
     return 0;
@@ -310,13 +311,13 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,
     if (avctx->debug & FF_DEBUG_BITSTREAM)
         av_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n",
                 retval, buf_size);
-    return retval;
+    return retval + 4;
 }
 
 AVCodec ff_pcm_bluray_decoder = {
     .name           = "pcm_bluray",
     .type           = AVMEDIA_TYPE_AUDIO,
-    .id             = CODEC_ID_PCM_BLURAY,
+    .id             = AV_CODEC_ID_PCM_BLURAY,
     .priv_data_size = sizeof(PCMBRDecode),
     .init           = pcm_bluray_decode_init,
     .decode         = pcm_bluray_decode_frame,