]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/nellymoserdec.c
aacenc: Fix bug in writing libavcodec_ident.
[ffmpeg] / libavcodec / nellymoserdec.c
index 7723c5827ba5a3229a5c1f19dae71193f9f4fdb3..2a1ec5b4cd7403e0ebb171bba62057f42d38a965 100644 (file)
@@ -41,7 +41,7 @@
 #include "fmtconvert.h"
 #include "sinewin.h"
 
-#define ALT_BITSTREAM_READER_LE
+#define BITSTREAM_READER_LE
 #include "get_bits.h"
 
 
@@ -154,6 +154,7 @@ static int decode_tag(AVCodecContext *avctx, void *data,
                       int *got_frame_ptr, AVPacket *avpkt)
 {
     const uint8_t *buf = avpkt->data;
+    const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL);
     int buf_size = avpkt->size;
     NellyMoserDecodeContext *s = avctx->priv_data;
     int blocks, i, ret;
@@ -161,10 +162,12 @@ static int decode_tag(AVCodecContext *avctx, void *data,
     float   *samples_flt;
 
     blocks     = buf_size / NELLY_BLOCK_LEN;
+
     if (blocks <= 0) {
         av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
         return AVERROR_INVALIDDATA;
     }
+
     if (buf_size % NELLY_BLOCK_LEN) {
         av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n",
                buf_size % NELLY_BLOCK_LEN);
@@ -176,6 +179,8 @@ static int decode_tag(AVCodecContext *avctx, void *data,
      * 22050 Hz - 4
      * 44100 Hz - 8
      */
+    if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks)
+        avctx->sample_rate= 11025*(blocks/2);
 
     /* get output buffer */
     s->frame.nb_samples = NELLY_SAMPLES * blocks;
@@ -187,7 +192,7 @@ static int decode_tag(AVCodecContext *avctx, void *data,
     samples_flt = (float   *)s->frame.data[0];
 
     for (i=0 ; i<blocks ; i++) {
-        if (avctx->sample_fmt == SAMPLE_FMT_FLT) {
+        if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
             nelly_decode_block(s, buf, samples_flt);
             samples_flt += NELLY_SAMPLES;
         } else {
@@ -221,7 +226,7 @@ AVCodec ff_nellymoser_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_tag,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE,
     .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
                                                       AV_SAMPLE_FMT_S16,