]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '0638b99cdba52554691fc668d9e477bc184c7a33'
authorMatthieu Bouron <matthieu.bouron@gmail.com>
Fri, 17 Mar 2017 12:31:03 +0000 (13:31 +0100)
committerMatthieu Bouron <matthieu.bouron@gmail.com>
Fri, 17 Mar 2017 12:31:03 +0000 (13:31 +0100)
* commit '0638b99cdba52554691fc668d9e477bc184c7a33':
aiff: Skip padding byte for odd-sized chunks

Also removes to odd-size checks from get_aiff_header and get_meta to use
the generic path introduced by the original commit.

Merged-by: Matthieu Bouron <matthieu.bouron@gmail.com>
1  2 
libavformat/aiffdec.c

index 9e7a39c4edcf23b9cc1c16e8ca82f35d82ca7cef,3c45c61b1a8c8bd46a85fe12b9632a2cee233865..3bbe4a07bd6844d5130f4ae16130fd966b95bd28
@@@ -299,41 -260,21 +299,45 @@@ static int aiff_read_header(AVFormatCon
          case MKTAG('w', 'a', 'v', 'e'):
              if ((uint64_t)size > (1<<30))
                  return -1;
 -            st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
 -            if (!st->codecpar->extradata)
 +            if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
                  return AVERROR(ENOMEM);
 -            st->codecpar->extradata_size = size;
 -            avio_read(pb, st->codecpar->extradata, size);
 +            if (   (st->codecpar->codec_id == AV_CODEC_ID_QDMC || st->codecpar->codec_id == AV_CODEC_ID_QDM2)
 +                && size>=12*4 && !st->codecpar->block_align) {
 +                st->codecpar->block_align = AV_RB32(st->codecpar->extradata+11*4);
 +                aiff->block_duration = AV_RB32(st->codecpar->extradata+9*4);
 +            } else if (st->codecpar->codec_id == AV_CODEC_ID_QCELP) {
 +                char rate = 0;
 +                if (size >= 25)
 +                    rate = st->codecpar->extradata[24];
 +                switch (rate) {
 +                case 'H': // RATE_HALF
 +                    st->codecpar->block_align = 17;
 +                    break;
 +                case 'F': // RATE_FULL
 +                default:
 +                    st->codecpar->block_align = 35;
 +                }
 +                aiff->block_duration = 160;
 +                st->codecpar->bit_rate = (int64_t)st->codecpar->sample_rate * (st->codecpar->block_align << 3) /
 +                                         aiff->block_duration;
 +            }
              break;
 +        case MKTAG('C','H','A','N'):
 +            if(ff_mov_read_chan(s, pb, st, size) < 0)
 +                return AVERROR_INVALIDDATA;
 +            break;
 +        case 0:
 +            if (offset > 0 && st->codecpar->block_align) // COMM && SSND
 +                goto got_sound;
          default: /* Jump */
-             if (size & 1)   /* Always even aligned */
-                 size++;
              avio_skip(pb, size);
          }
+         /* Skip required padding byte for odd-sized chunks. */
+         if (size & 1) {
+             filesize--;
+             avio_skip(pb, 1);
+         }
      }
  
  got_sound: