Unified · Split
| @@ -12,6 +12,7 @@ version <next>: · 11 unmodified lines | ||
| 12 | 12 | - 16-bit support in selectivecolor filter |
| 13 | 13 | - OpenH264 decoder wrapper |
| 14 | 14 | - MediaCodec hwaccel |
| 15 | +- True Audio (TTA) muxer | |
| 15 | 16 | |
| 16 | 17 | |
| 17 | 18 | version 3.1: |
| @@ -509,7 +509,7 @@ library: · 508 unmodified lines | ||
| 509 | 509 | @tab Used on the Nintendo GameCube. |
| 510 | 510 | @item Tiertex Limited SEQ @tab @tab X |
| 511 | 511 | @tab Tiertex .seq files used in the DOS CD-ROM version of the game Flashback. |
| 512 | −@item True Audio @tab @tab X | |
| 512 | +@item True Audio @tab X @tab X | |
| 513 | 513 | @item VAG @tab @tab X |
| 514 | 514 | @tab Audio format used in many Sony PS2 games. |
| 515 | 515 | @item VC-1 test bitstream @tab X @tab X |
| @@ -471,6 +471,7 @@ OBJS-$(CONFIG_TMV_DEMUXER) += tmv.o · 470 unmodified lines | ||
| 471 | 471 | OBJS-$(CONFIG_TRUEHD_DEMUXER) += rawdec.o mlpdec.o |
| 472 | 472 | OBJS-$(CONFIG_TRUEHD_MUXER) += rawenc.o |
| 473 | 473 | OBJS-$(CONFIG_TTA_DEMUXER) += tta.o apetag.o img2.o |
| 474 | +OBJS-$(CONFIG_TTA_MUXER) += ttaenc.o apetag.o img2.o | |
| 474 | 475 | OBJS-$(CONFIG_TTY_DEMUXER) += tty.o sauce.o |
| 475 | 476 | OBJS-$(CONFIG_TXD_DEMUXER) += txd.o |
| 476 | 477 | OBJS-$(CONFIG_UNCODEDFRAMECRC_MUXER) += uncodedframecrcenc.o framehash.o |
| @@ -311,7 +311,7 @@ void av_register_all(void) · 310 unmodified lines | ||
| 311 | 311 | REGISTER_MUXER (MKVTIMESTAMP_V2, mkvtimestamp_v2); |
| 312 | 312 | REGISTER_DEMUXER (TMV, tmv); |
| 313 | 313 | REGISTER_MUXDEMUX(TRUEHD, truehd); |
| 314 | − REGISTER_DEMUXER (TTA, tta); | |
| 314 | + REGISTER_MUXDEMUX(TTA, tta); | |
| 315 | 315 | REGISTER_DEMUXER (TXD, txd); |
| 316 | 316 | REGISTER_DEMUXER (TTY, tty); |
| 317 | 317 | REGISTER_MUXER (UNCODEDFRAMECRC, uncodedframecrc); |
| @@ -0,0 +1,149 @@ | ||
| 1 | +/* | |
| 2 | + * True Audio (TTA) muxer | |
| 3 | + * Copyright (c) 2016 James Almer | |
| 4 | + * | |
| 5 | + * This file is part of FFmpeg. | |
| 6 | + * | |
| 7 | + * FFmpeg is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public | |
| 9 | + * License as published by the Free Software Foundation; either | |
| 10 | + * version 2.1 of the License, or (at your option) any later version. | |
| 11 | + * | |
| 12 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 | + * Lesser General Public License for more details. | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU Lesser General Public | |
| 18 | + * License along with FFmpeg; if not, write to the Free Software | |
| 19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + */ | |
| 21 | + | |
| 22 | +#include "libavutil/crc.h" | |
| 23 | +#include "libavutil/intreadwrite.h" | |
| 24 | + | |
| 25 | +#include "apetag.h" | |
| 26 | +#include "avformat.h" | |
| 27 | +#include "avio_internal.h" | |
| 28 | +#include "internal.h" | |
| 29 | + | |
| 30 | +typedef struct TTAMuxContext { | |
| 31 | + AVIOContext *seek_table; | |
| 32 | + AVIOContext *data; | |
| 33 | + uint32_t nb_samples; | |
| 34 | + int frame_size; | |
| 35 | + int last_frame; | |
| 36 | +} TTAMuxContext; | |
| 37 | + | |
| 38 | +static int tta_write_header(AVFormatContext *s) | |
| 39 | +{ | |
| 40 | + TTAMuxContext *tta = s->priv_data; | |
| 41 | + AVCodecParameters *par = s->streams[0]->codecpar; | |
| 42 | + int ret; | |
| 43 | + | |
| 44 | + if (s->nb_streams != 1) { | |
| 45 | + av_log(s, AV_LOG_ERROR, "Only one stream is supported\n"); | |
| 46 | + return AVERROR(EINVAL); | |
| 47 | + } | |
| 48 | + if (par->codec_id != AV_CODEC_ID_TTA) { | |
| 49 | + av_log(s, AV_LOG_ERROR, "Unsupported codec\n"); | |
| 50 | + return AVERROR(EINVAL); | |
| 51 | + } | |
| 52 | + if (par->extradata && par->extradata_size < 22) { | |
| 53 | + av_log(s, AV_LOG_ERROR, "Invalid TTA extradata\n"); | |
| 54 | + return AVERROR_INVALIDDATA; | |
| 55 | + } | |
| 56 | + | |
| 57 | + if ((ret = avio_open_dyn_buf(&tta->seek_table)) < 0) | |
| 58 | + return ret; | |
| 59 | + if ((ret = avio_open_dyn_buf(&tta->data)) < 0) { | |
| 60 | + ffio_free_dyn_buf(&tta->seek_table); | |
| 61 | + return ret; | |
| 62 | + } | |
| 63 | + | |
| 64 | + /* Ignore most extradata information if present. It can be innacurate | |
| 65 | + if for example remuxing from Matroska */ | |
| 66 | + ffio_init_checksum(s->pb, ff_crcEDB88320_update, UINT32_MAX); | |
| 67 | + ffio_init_checksum(tta->seek_table, ff_crcEDB88320_update, UINT32_MAX); | |
| 68 | + avio_write(s->pb, "TTA1", 4); | |
| 69 | + avio_wl16(s->pb, par->extradata ? AV_RL16(par->extradata + 4) : 1); | |
| 70 | + avio_wl16(s->pb, par->channels); | |
| 71 | + avio_wl16(s->pb, par->bits_per_raw_sample); | |
| 72 | + avio_wl32(s->pb, par->sample_rate); | |
| 73 | + /* Prevent overflow */ | |
| 74 | + if (par->sample_rate > 0x7FFFFFu) { | |
| 75 | + av_log(s, AV_LOG_ERROR, "Sample rate too large\n"); | |
| 76 | + return AVERROR(EINVAL); | |
| 77 | + } | |
| 78 | + tta->frame_size = par->sample_rate * 256 / 245; | |
| 79 | + avpriv_set_pts_info(s->streams[0], 64, 1, par->sample_rate); | |
| 80 | + | |
| 81 | + return 0; | |
| 82 | +} | |
| 83 | + | |
| 84 | +static int tta_write_packet(AVFormatContext *s, AVPacket *pkt) | |
| 85 | +{ | |
| 86 | + TTAMuxContext *tta = s->priv_data; | |
| 87 | + | |
| 88 | + avio_write(tta->data, pkt->data, pkt->size); | |
| 89 | + avio_wl32(tta->seek_table, pkt->size); | |
| 90 | + tta->nb_samples += pkt->duration; | |
| 91 | + | |
| 92 | + if (tta->frame_size != pkt->duration) { | |
| 93 | + if (tta->last_frame) { | |
| 94 | + /* Two frames with a different duration than the default frame | |
| 95 | + size means the TTA stream comes from a faulty container, and | |
| 96 | + there's no way the last frame duration will be correct. */ | |
| 97 | + av_log(s, AV_LOG_ERROR, "Invalid frame durations\n"); | |
| 98 | + | |
| 99 | + return AVERROR_INVALIDDATA; | |
| 100 | + } | |
| 101 | + /* First frame with a different duration than the default frame size. | |
| 102 | + Assume it's the last frame in the stream and continue. */ | |
| 103 | + tta->last_frame++; | |
| 104 | + } | |
| 105 | + | |
| 106 | + return 0; | |
| 107 | +} | |
| 108 | + | |
| 109 | +static int tta_write_trailer(AVFormatContext *s) | |
| 110 | +{ | |
| 111 | + TTAMuxContext *tta = s->priv_data; | |
| 112 | + uint8_t *ptr; | |
| 113 | + unsigned int crc; | |
| 114 | + int size; | |
| 115 | + | |
| 116 | + avio_wl32(s->pb, tta->nb_samples); | |
| 117 | + crc = ffio_get_checksum(s->pb) ^ UINT32_MAX; | |
| 118 | + avio_wl32(s->pb, crc); | |
| 119 | + | |
| 120 | + /* Write Seek table */ | |
| 121 | + crc = ffio_get_checksum(tta->seek_table) ^ UINT32_MAX; | |
| 122 | + avio_wl32(tta->seek_table, crc); | |
| 123 | + size = avio_close_dyn_buf(tta->seek_table, &ptr); | |
| 124 | + avio_write(s->pb, ptr, size); | |
| 125 | + av_free(ptr); | |
| 126 | + | |
| 127 | + /* Write audio data */ | |
| 128 | + size = avio_close_dyn_buf(tta->data, &ptr); | |
| 129 | + avio_write(s->pb, ptr, size); | |
| 130 | + av_free(ptr); | |
| 131 | + | |
| 132 | + ff_ape_write_tag(s); | |
| 133 | + avio_flush(s->pb); | |
| 134 | + | |
| 135 | + return 0; | |
| 136 | +} | |
| 137 | + | |
| 138 | +AVOutputFormat ff_tta_muxer = { | |
| 139 | + .name = "tta", | |
| 140 | + .long_name = NULL_IF_CONFIG_SMALL("TTA (True Audio)"), | |
| 141 | + .mime_type = "audio/x-tta", | |
| 142 | + .extensions = "tta", | |
| 143 | + .priv_data_size = sizeof(TTAMuxContext), | |
| 144 | + .audio_codec = AV_CODEC_ID_TTA, | |
| 145 | + .video_codec = AV_CODEC_ID_NONE, | |
| 146 | + .write_header = tta_write_header, | |
| 147 | + .write_packet = tta_write_packet, | |
| 148 | + .write_trailer = tta_write_trailer, | |
| 149 | +}; | |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) |
| 33 | 33 | // Also please add any ticket numbers that you belive might be affected here |
| 34 | 34 | #define LIBAVFORMAT_VERSION_MAJOR 57 |
| 35 | −#define LIBAVFORMAT_VERSION_MINOR 44 | |
| 35 | +#define LIBAVFORMAT_VERSION_MINOR 45 | |
| 36 | 36 | #define LIBAVFORMAT_VERSION_MICRO 100 |
| 37 | 37 | |
| 38 | 38 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| @@ -154,8 +154,8 @@ FATE_ACODEC-$(call ENCDEC, WAVPACK, WV) += fate-acodec-wavpack · 153 unmodified lines | ||
| 154 | 154 | fate-acodec-wavpack: FMT = wv |
| 155 | 155 | fate-acodec-wavpack: CODEC = wavpack -compression_level 1 |
| 156 | 156 | |
| 157 | −FATE_ACODEC-$(call ENCDEC, TTA, MATROSKA) += fate-acodec-tta | |
| 158 | −fate-acodec-tta: FMT = matroska | |
| 157 | +FATE_ACODEC-$(call ENCDEC, TTA, TTA) += fate-acodec-tta | |
| 158 | +fate-acodec-tta: FMT = tta | |
| 159 | 159 | |
| 160 | 160 | FATE_ACODEC += $(FATE_ACODEC-yes) |
| 161 | 161 | |
| @@ -15,6 +15,7 @@ FATE_LAVF-$(call ENCDEC, GIF, IMAGE2) += gif · 14 unmodified lines | ||
| 15 | 15 | FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, GXF) += gxf |
| 16 | 16 | FATE_LAVF-$(call ENCDEC, PCM_S16LE, IRCAM) += ircam |
| 17 | 17 | FATE_LAVF-$(call ENCDEC, MJPEG, IMAGE2) += jpg |
| 18 | +FATE_LAVF-$(call ENCMUX, TTA, MATROSKA_AUDIO) += mka | |
| 18 | 19 | FATE_LAVF-$(call ENCDEC2, MPEG4, MP2, MATROSKA) += mkv |
| 19 | 20 | FATE_LAVF-$(call ENCDEC, ADPCM_YAMAHA, MMF) += mmf |
| 20 | 21 | FATE_LAVF-$(call ENCDEC2, MPEG4, PCM_ALAW, MOV) += mov ismv |
| @@ -44,6 +45,7 @@ FATE_LAVF-$(call ENCDEC, FLV, SWF) += swf · 23 unmodified lines | ||
| 44 | 45 | FATE_LAVF-$(call ENCDEC, TARGA, IMAGE2) += tga |
| 45 | 46 | FATE_LAVF-$(call ENCDEC, TIFF, IMAGE2) += tiff |
| 46 | 47 | FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, MP2, MPEGTS) += ts |
| 48 | +FATE_LAVF-$(call ENCDEC, TTA, TTA) += tta | |
| 47 | 49 | FATE_LAVF-$(call ENCDEC, PCM_U8, VOC) += voc |
| 48 | 50 | FATE_LAVF-$(call ENCDEC, PCM_S16LE, VOC) += voc_s16 |
| 49 | 51 | FATE_LAVF-$(call ENCDEC, PCM_S16LE, WAV) += wav |
| @@ -145,6 +145,10 @@ if [ -n "$do_nut" ] ; then · 144 unmodified lines | ||
| 145 | 145 | do_lavf nut "" "-acodec mp2 -ab 64k -ar 44100 -threads 1" |
| 146 | 146 | fi |
| 147 | 147 | |
| 148 | +if [ -n "$do_mka" ] ; then | |
| 149 | +do_audio_only mka "" "-c:a tta" | |
| 150 | +fi | |
| 151 | + | |
| 148 | 152 | if [ -n "$do_mkv" ] ; then |
| 149 | 153 | do_lavf mkv "" "-acodec mp2 -ab 64k -vcodec mpeg4 \ |
| 150 | 154 | -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap -threads 1" |
| @@ -350,6 +354,10 @@ if [ -n "$do_sox" ] ; then · 199 unmodified lines | ||
| 350 | 354 | do_audio_only sox |
| 351 | 355 | fi |
| 352 | 356 | |
| 357 | +if [ -n "$do_tta" ] ; then | |
| 358 | +do_audio_only tta | |
| 359 | +fi | |
| 360 | + | |
| 353 | 361 | if [ -n "$do_caf" ] ; then |
| 354 | 362 | do_audio_only caf |
| 355 | 363 | fi |
| @@ -1,4 +1,4 @@ | ||
| 1 | −6c260836d7a32e4bd714453a3546c0d5 *tests/data/fate/acodec-tta.matroska | |
| 2 | −331148 tests/data/fate/acodec-tta.matroska | |
| 1 | +847d065f082ac94825728b5f1af853eb *tests/data/fate/acodec-tta.tta | |
| 2 | +330583 tests/data/fate/acodec-tta.tta | |
| 3 | 3 | 95e54b261530a1bcf6de6fe3b21dc5f6 *tests/data/fate/acodec-tta.out.wav |
| 4 | 4 | stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +b2e3746787b885d0191a1a26f3faa58f *./tests/data/lavf/lavf.mka | |
| 2 | +43654 ./tests/data/lavf/lavf.mka | |
| 3 | +./tests/data/lavf/lavf.mka CRC=0x3a1da17e | |
| @@ -0,0 +1,3 @@ | ||
| 1 | +f2721d06704ac43d89fdd25835b43598 *./tests/data/lavf/lavf.tta | |
| 2 | +43200 ./tests/data/lavf/lavf.tta | |
| 3 | +./tests/data/lavf/lavf.tta CRC=0x3a1da17e | |