Added AMR-NB and AMR-WB decoders to FFMPEG, not needed for AMR files, though, since Core Audio handles them
This commit is contained in:
parent
fe90454d23
commit
ab97f832ed
10 changed files with 6295 additions and 3 deletions
|
@ -7,6 +7,13 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
830C4B5B180C3434007674D6 /* amr.h in Headers */ = {isa = PBXBuildFile; fileRef = 830C4B56180C3434007674D6 /* amr.h */; };
|
||||
830C4B5C180C3434007674D6 /* amrnbdata.h in Headers */ = {isa = PBXBuildFile; fileRef = 830C4B57180C3434007674D6 /* amrnbdata.h */; };
|
||||
830C4B5D180C3434007674D6 /* amrnbdec.c in Sources */ = {isa = PBXBuildFile; fileRef = 830C4B58180C3434007674D6 /* amrnbdec.c */; };
|
||||
830C4B5E180C3434007674D6 /* amrwbdata.h in Headers */ = {isa = PBXBuildFile; fileRef = 830C4B59180C3434007674D6 /* amrwbdata.h */; };
|
||||
830C4B5F180C3434007674D6 /* amrwbdec.c in Sources */ = {isa = PBXBuildFile; fileRef = 830C4B5A180C3434007674D6 /* amrwbdec.c */; };
|
||||
830C4B61180C343C007674D6 /* amr.c in Sources */ = {isa = PBXBuildFile; fileRef = 830C4B60180C343C007674D6 /* amr.c */; };
|
||||
830C4B63180C3580007674D6 /* amrwbdec_mips.h in Headers */ = {isa = PBXBuildFile; fileRef = 830C4B62180C3580007674D6 /* amrwbdec_mips.h */; };
|
||||
830F0BD117FC4FB900042E8F /* allcodecs.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0B8F17FC4FB900042E8F /* allcodecs.c */; };
|
||||
830F0BD217FC4FB900042E8F /* avcodec.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0B9017FC4FB900042E8F /* avcodec.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
830F0BD517FC4FB900042E8F /* fft.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0B9317FC4FB900042E8F /* fft.c */; };
|
||||
|
@ -436,6 +443,13 @@
|
|||
/* Begin PBXFileReference section */
|
||||
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
32DBCF5E0370ADEE00C91783 /* FFMPEG_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFMPEG_Prefix.pch; sourceTree = "<group>"; };
|
||||
830C4B56180C3434007674D6 /* amr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amr.h; sourceTree = "<group>"; };
|
||||
830C4B57180C3434007674D6 /* amrnbdata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amrnbdata.h; sourceTree = "<group>"; };
|
||||
830C4B58180C3434007674D6 /* amrnbdec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = amrnbdec.c; sourceTree = "<group>"; };
|
||||
830C4B59180C3434007674D6 /* amrwbdata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amrwbdata.h; sourceTree = "<group>"; };
|
||||
830C4B5A180C3434007674D6 /* amrwbdec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = amrwbdec.c; sourceTree = "<group>"; };
|
||||
830C4B60180C343C007674D6 /* amr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = amr.c; sourceTree = "<group>"; };
|
||||
830C4B62180C3580007674D6 /* amrwbdec_mips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amrwbdec_mips.h; sourceTree = "<group>"; };
|
||||
830F0B8F17FC4FB900042E8F /* allcodecs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = allcodecs.c; sourceTree = "<group>"; };
|
||||
830F0B9017FC4FB900042E8F /* avcodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avcodec.h; sourceTree = "<group>"; };
|
||||
830F0B9317FC4FB900042E8F /* fft.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fft.c; sourceTree = "<group>"; };
|
||||
|
@ -943,6 +957,11 @@
|
|||
830F0B8E17FC4FB900042E8F /* libavcodec */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
830C4B56180C3434007674D6 /* amr.h */,
|
||||
830C4B57180C3434007674D6 /* amrnbdata.h */,
|
||||
830C4B58180C3434007674D6 /* amrnbdec.c */,
|
||||
830C4B59180C3434007674D6 /* amrwbdata.h */,
|
||||
830C4B5A180C3434007674D6 /* amrwbdec.c */,
|
||||
838491161807D1D900E7332D /* tta.c */,
|
||||
838491171807D1D900E7332D /* ttadata.c */,
|
||||
838491181807D1D900E7332D /* ttadata.h */,
|
||||
|
@ -1195,6 +1214,7 @@
|
|||
830F0BAD17FC4FB900042E8F /* libavformat */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
830C4B60180C343C007674D6 /* amr.c */,
|
||||
838491141807D1D200E7332D /* tta.c */,
|
||||
838491121807D06100E7332D /* spdifdec.c */,
|
||||
838490FE1807C58500E7332D /* aacdec.c */,
|
||||
|
@ -1394,6 +1414,7 @@
|
|||
830F0D0417FC80B400042E8F /* mips */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
830C4B62180C3580007674D6 /* amrwbdec_mips.h */,
|
||||
830F0D0517FC80B400042E8F /* lsp_mips.h */,
|
||||
);
|
||||
path = mips;
|
||||
|
@ -1560,6 +1581,7 @@
|
|||
830F0C4917FC7CA300042E8F /* asf.h in Headers */,
|
||||
830F0DCA17FC931700042E8F /* pcm.h in Headers */,
|
||||
830F0CCC17FC7F1E00042E8F /* celp_filters.h in Headers */,
|
||||
830C4B5C180C3434007674D6 /* amrnbdata.h in Headers */,
|
||||
830F0D5117FC880E00042E8F /* time_.h in Headers */,
|
||||
830F0BD717FC4FB900042E8F /* get_bits.h in Headers */,
|
||||
830F0C2417FC527400042E8F /* atomic.h in Headers */,
|
||||
|
@ -1572,6 +1594,7 @@
|
|||
833C37D118032D4800CBA602 /* dirac_dwt.h in Headers */,
|
||||
8393B80318052BC200913C76 /* mpegaudiodecheader.h in Headers */,
|
||||
838490901807BC9400E7332D /* dca.h in Headers */,
|
||||
830C4B5E180C3434007674D6 /* amrwbdata.h in Headers */,
|
||||
830F0D7917FC8C7300042E8F /* mpeg4audio.h in Headers */,
|
||||
830F0C3A17FC554D00042E8F /* des.h in Headers */,
|
||||
830F0BF117FC4FB900042E8F /* avi.h in Headers */,
|
||||
|
@ -1591,6 +1614,7 @@
|
|||
830F0C4A17FC7CA300042E8F /* avio_internal.h in Headers */,
|
||||
830F0C7017FC7DB100042E8F /* pixdesc.h in Headers */,
|
||||
833C37C318032CF600CBA602 /* dirac_arith.h in Headers */,
|
||||
830C4B63180C3580007674D6 /* amrwbdec_mips.h in Headers */,
|
||||
830F0CF717FC7F1E00042E8F /* rnd_avg.h in Headers */,
|
||||
830F0D4117FC848D00042E8F /* sha.h in Headers */,
|
||||
830F0CEE17FC7F1E00042E8F /* mpeg12data.h in Headers */,
|
||||
|
@ -1606,6 +1630,7 @@
|
|||
830F0CF117FC7F1E00042E8F /* ratecontrol.h in Headers */,
|
||||
830F0C1417FC500B00042E8F /* fft-internal.h in Headers */,
|
||||
830F0D8E17FC8E8B00042E8F /* sbr.h in Headers */,
|
||||
830C4B5B180C3434007674D6 /* amr.h in Headers */,
|
||||
833C37B218032AEF00CBA602 /* diracdsp.h in Headers */,
|
||||
830F0C3D17FC554D00042E8F /* internal.h in Headers */,
|
||||
833C37D718032EA500CBA602 /* idct_xvid.h in Headers */,
|
||||
|
@ -1760,14 +1785,17 @@
|
|||
830F0D5917FC893E00042E8F /* codec_desc.c in Sources */,
|
||||
830F0DBE17FC922C00042E8F /* h264chroma_init.c in Sources */,
|
||||
830F0BF217FC4FB900042E8F /* avio.c in Sources */,
|
||||
830C4B5F180C3434007674D6 /* amrwbdec.c in Sources */,
|
||||
838490DC1807C47E00E7332D /* g723_1.c in Sources */,
|
||||
830F0CE217FC7F1E00042E8F /* frame_thread_encoder.c in Sources */,
|
||||
830C4B61180C343C007674D6 /* amr.c in Sources */,
|
||||
838491151807D1D200E7332D /* tta.c in Sources */,
|
||||
8393B80118052BC200913C76 /* mpegaudiodec.c in Sources */,
|
||||
830F0C3817FC554D00042E8F /* buffer.c in Sources */,
|
||||
8384905C1807AF0100E7332D /* ac3_parser.c in Sources */,
|
||||
830F0C6B17FC7DB100042E8F /* bprint.c in Sources */,
|
||||
830F0BE017FC4FB900042E8F /* simple_idct.c in Sources */,
|
||||
830C4B5D180C3434007674D6 /* amrnbdec.c in Sources */,
|
||||
838490991807BC9C00E7332D /* dtsdec.c in Sources */,
|
||||
830F0D6917FC8A3D00042E8F /* avpicture.c in Sources */,
|
||||
8393B80518052BC200913C76 /* mpegaudiodsp_data.c in Sources */,
|
||||
|
|
|
@ -393,8 +393,8 @@
|
|||
#define CONFIG_ALAC_ENCODER 0
|
||||
#define CONFIG_ALAC_DECODER 0
|
||||
#define CONFIG_ALS_DECODER 0
|
||||
#define CONFIG_AMRNB_DECODER 0
|
||||
#define CONFIG_AMRWB_DECODER 0
|
||||
#define CONFIG_AMRNB_DECODER 1
|
||||
#define CONFIG_AMRWB_DECODER 1
|
||||
#define CONFIG_APE_DECODER 1
|
||||
#define CONFIG_ATRAC1_DECODER 0
|
||||
#define CONFIG_ATRAC3_DECODER 1
|
||||
|
@ -718,7 +718,7 @@
|
|||
#define CONFIG_AIFF_MUXER 0
|
||||
#define CONFIG_AIFF_DEMUXER 0
|
||||
#define CONFIG_AMR_MUXER 0
|
||||
#define CONFIG_AMR_DEMUXER 0
|
||||
#define CONFIG_AMR_DEMUXER 1
|
||||
#define CONFIG_ANM_DEMUXER 0
|
||||
#define CONFIG_APC_DEMUXER 0
|
||||
#define CONFIG_APE_DEMUXER 1
|
||||
|
|
70
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amr.h
Normal file
70
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amr.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Shared functions between AMR codecs
|
||||
*
|
||||
* Copyright (c) 2010 Marcelo Galvao Povoa
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AMR_H
|
||||
#define AVCODEC_AMR_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
#ifdef AMR_USE_16BIT_TABLES
|
||||
#define R_TABLE_TYPE uint16_t
|
||||
#else
|
||||
#define R_TABLE_TYPE uint8_t
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Fill the frame structure variables from bitstream by parsing the
|
||||
* given reordering table that uses the following format:
|
||||
*
|
||||
* Each field (16 bits) in the AMR Frame is stored as:
|
||||
* - one byte for the number of bits in the field
|
||||
* - one byte for the field index
|
||||
* - then, one byte for each bit of the field (from most-significant to least)
|
||||
* of the position of that bit in the AMR frame.
|
||||
*
|
||||
* @param out pointer to the frame struct
|
||||
* @param size the size in bytes of the frame struct
|
||||
* @param data input bitstream after the frame header
|
||||
* @param ord_table the reordering table as above
|
||||
*/
|
||||
static inline void ff_amr_bit_reorder(uint16_t *out, int size,
|
||||
const uint8_t *data,
|
||||
const R_TABLE_TYPE *ord_table)
|
||||
{
|
||||
int field_size;
|
||||
|
||||
memset(out, 0, size);
|
||||
while ((field_size = *ord_table++)) {
|
||||
int field = 0;
|
||||
int field_offset = *ord_table++;
|
||||
while (field_size--) {
|
||||
int bit = *ord_table++;
|
||||
field <<= 1;
|
||||
field |= data[bit >> 3] >> (bit & 7) & 1;
|
||||
}
|
||||
out[field_offset >> 1] = field;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_AMR_H */
|
1671
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrnbdata.h
Normal file
1671
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrnbdata.h
Normal file
File diff suppressed because it is too large
Load diff
1095
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrnbdec.c
Normal file
1095
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrnbdec.c
Normal file
File diff suppressed because it is too large
Load diff
1890
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrwbdata.h
Normal file
1890
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrwbdata.h
Normal file
File diff suppressed because it is too large
Load diff
1281
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrwbdec.c
Normal file
1281
Frameworks/FFMPEG/ffmpeg-minimal/libavcodec/amrwbdec.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2012
|
||||
* MIPS Technologies, Inc., California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Author: Nedeljko Babic (nbabic@mips.com)
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Reference: libavcodec/amrwbdec.c
|
||||
*/
|
||||
#ifndef AVCODEC_AMRWBDEC_MIPS_H
|
||||
#define AVCODEC_AMRWBDEC_MIPS_H
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_MIPSFPU && HAVE_INLINE_ASM
|
||||
void hb_fir_filter_mips(float *out, const float fir_coef[],
|
||||
float mem[], const float *in);
|
||||
#define hb_fir_filter hb_fir_filter_mips
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_AMRWBDEC_MIPS_H */
|
180
Frameworks/FFMPEG/ffmpeg-minimal/libavformat/amr.c
Normal file
180
Frameworks/FFMPEG/ffmpeg-minimal/libavformat/amr.c
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* amr file format
|
||||
* Copyright (c) 2001 ffmpeg project
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
Write and read amr data according to RFC3267, http://www.ietf.org/rfc/rfc3267.txt?number=3267
|
||||
|
||||
Only mono files are supported.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "avformat.h"
|
||||
#include "internal.h"
|
||||
|
||||
static const char AMR_header[] = "#!AMR\n";
|
||||
static const char AMRWB_header[] = "#!AMR-WB\n";
|
||||
|
||||
#if CONFIG_AMR_MUXER
|
||||
static int amr_write_header(AVFormatContext *s)
|
||||
{
|
||||
AVIOContext *pb = s->pb;
|
||||
AVCodecContext *enc = s->streams[0]->codec;
|
||||
|
||||
s->priv_data = NULL;
|
||||
|
||||
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
|
||||
avio_write(pb, AMR_header, sizeof(AMR_header) - 1); /* magic number */
|
||||
} else if (enc->codec_id == AV_CODEC_ID_AMR_WB) {
|
||||
avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic number */
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
avio_flush(pb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int amr_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
avio_write(s->pb, pkt->data, pkt->size);
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_AMR_MUXER */
|
||||
|
||||
static int amr_probe(AVProbeData *p)
|
||||
{
|
||||
// Only check for "#!AMR" which could be amr-wb, amr-nb.
|
||||
// This will also trigger multichannel files: "#!AMR_MC1.0\n" and
|
||||
// "#!AMR-WB_MC1.0\n" (not supported)
|
||||
|
||||
if (!memcmp(p->buf, AMR_header, 5))
|
||||
return AVPROBE_SCORE_MAX;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* amr input */
|
||||
static int amr_read_header(AVFormatContext *s)
|
||||
{
|
||||
AVIOContext *pb = s->pb;
|
||||
AVStream *st;
|
||||
uint8_t header[9];
|
||||
|
||||
avio_read(pb, header, 6);
|
||||
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
if (memcmp(header, AMR_header, 6)) {
|
||||
avio_read(pb, header + 6, 3);
|
||||
if (memcmp(header, AMRWB_header, 9)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b');
|
||||
st->codec->codec_id = AV_CODEC_ID_AMR_WB;
|
||||
st->codec->sample_rate = 16000;
|
||||
} else {
|
||||
st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r');
|
||||
st->codec->codec_id = AV_CODEC_ID_AMR_NB;
|
||||
st->codec->sample_rate = 8000;
|
||||
}
|
||||
st->codec->channels = 1;
|
||||
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
AVCodecContext *enc = s->streams[0]->codec;
|
||||
int read, size = 0, toc, mode;
|
||||
int64_t pos = avio_tell(s->pb);
|
||||
|
||||
if (url_feof(s->pb)) {
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
// FIXME this is wrong, this should rather be in a AVParset
|
||||
toc = avio_r8(s->pb);
|
||||
mode = (toc >> 3) & 0x0F;
|
||||
|
||||
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
|
||||
static const uint8_t packed_size[16] = {
|
||||
12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
size = packed_size[mode] + 1;
|
||||
} else if (enc->codec_id == AV_CODEC_ID_AMR_WB) {
|
||||
static const uint8_t packed_size[16] = {
|
||||
18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1
|
||||
};
|
||||
|
||||
size = packed_size[mode];
|
||||
}
|
||||
|
||||
if (!size || av_new_packet(pkt, size))
|
||||
return AVERROR(EIO);
|
||||
|
||||
/* Both AMR formats have 50 frames per second */
|
||||
s->streams[0]->codec->bit_rate = size*8*50;
|
||||
|
||||
pkt->stream_index = 0;
|
||||
pkt->pos = pos;
|
||||
pkt->data[0] = toc;
|
||||
pkt->duration = enc->codec_id == AV_CODEC_ID_AMR_NB ? 160 : 320;
|
||||
read = avio_read(s->pb, pkt->data + 1, size - 1);
|
||||
|
||||
if (read != size - 1) {
|
||||
av_free_packet(pkt);
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_AMR_DEMUXER
|
||||
AVInputFormat ff_amr_demuxer = {
|
||||
.name = "amr",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("3GPP AMR"),
|
||||
.read_probe = amr_probe,
|
||||
.read_header = amr_read_header,
|
||||
.read_packet = amr_read_packet,
|
||||
.flags = AVFMT_GENERIC_INDEX,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if CONFIG_AMR_MUXER
|
||||
AVOutputFormat ff_amr_muxer = {
|
||||
.name = "amr",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("3GPP AMR"),
|
||||
.mime_type = "audio/amr",
|
||||
.extensions = "amr",
|
||||
.audio_codec = AV_CODEC_ID_AMR_NB,
|
||||
.video_codec = AV_CODEC_ID_NONE,
|
||||
.write_header = amr_write_header,
|
||||
.write_packet = amr_write_packet,
|
||||
};
|
||||
#endif
|
15
Info.plist
15
Info.plist
|
@ -22,6 +22,21 @@
|
|||
<key>CFBundleTypeRole</key>
|
||||
<string>None</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>amr-wb</string>
|
||||
<string>amr</string>
|
||||
</array>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<false/>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>song.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>AMR Audio File</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
|
|
Loading…
Reference in a new issue