[FFmpeg-cvslog] aiff: add support for XA ADPCM
ffmpeg | branch: master | Misty De Meo | Wed Jan 3 19:14:22 2018 +1100| [fde057dfb25e2b6917fc896a0b2dfec0f336b1ce] | committer: Michael Niedermayer aiff: add support for XA ADPCM Certain AIFF files encode XA ADPCM compressed audio using a chunk with the tag `APCM`. Aside from this custom chunk type, they're otherwise standard AIFF files. I've only observed these files in the Sega Saturn game Sonic Jam so far. Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fde057dfb25e2b6917fc896a0b2dfec0f336b1ce --- libavformat/aiffdec.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 99e05c78ec..a6c180fc8d 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -325,6 +325,13 @@ static int aiff_read_header(AVFormatContext *s) if(ff_mov_read_chan(s, pb, st, size) < 0) return AVERROR_INVALIDDATA; break; +case MKTAG('A','P','C','M'): /* XA ADPCM compressed sound chunk */ +st->codecpar->codec_id = AV_CODEC_ID_ADPCM_XA; +aiff->data_end = avio_tell(pb) + size; +offset = avio_tell(pb) + 8; +/* This field is unknown and its data seems to be irrelevant */ +avio_rb32(pb); +st->codecpar->block_align = avio_rb32(pb); case 0: if (offset > 0 && st->codecpar->block_align) // COMM && SSND goto got_sound; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] aiff: add explicit goto got_sound
ffmpeg | branch: master | Misty De Meo | Fri Jan 5 20:06:49 2018 +1100| [bfe397e4313c640e2f05c90a2ff1541f50524094] | committer: Michael Niedermayer aiff: add explicit goto got_sound Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bfe397e4313c640e2f05c90a2ff1541f50524094 --- Changelog | 1 + libavformat/aiffdec.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Changelog b/Changelog index 56a3d684d6..2f92638d36 100644 --- a/Changelog +++ b/Changelog @@ -34,6 +34,7 @@ version : - entropy video filter - hilbert audio filter source - aiir audio filter +- aiff: add support for CD-ROM XA ADPCM version 3.4: diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index a6c180fc8d..e87fbc5661 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -332,6 +332,9 @@ static int aiff_read_header(AVFormatContext *s) /* This field is unknown and its data seems to be irrelevant */ avio_rb32(pb); st->codecpar->block_align = avio_rb32(pb); + +goto got_sound; +break; case 0: if (offset > 0 && st->codecpar->block_align) // COMM && SSND goto got_sound; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] adpcm: consume remainder after consuming XA chunks
ffmpeg | branch: master | Misty De Meo | Fri Jan 5 20:06:48 2018 +1100| [94e6b5ac3914c391912b717e6aba2cb40cc717b7] | committer: Michael Niedermayer adpcm: consume remainder after consuming XA chunks Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94e6b5ac3914c391912b717e6aba2cb40cc717b7 --- libavcodec/adpcm.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index be206c55ba..cd3bbd33c2 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1115,6 +1115,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int16_t *out1 = samples_p[1]; int samples_per_block = 28 * (3 - avctx->channels) * 4; int sample_offset = 0; +int bytes_remaining; while (bytestream2_get_bytes_left(&gb) >= 128) { if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb), &c->status[0], &c->status[1], @@ -1123,6 +1124,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, bytestream2_skipu(&gb, 128); sample_offset += samples_per_block; } +/* Less than a full block of data left, e.g. when reading from + * 2324 byte per sector XA; the remainder is padding */ +bytes_remaining = bytestream2_get_bytes_left(&gb); +if (bytes_remaining > 0) { +bytestream2_skip(&gb, bytes_remaining); +} break; } case AV_CODEC_ID_ADPCM_IMA_EA_EACS: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Add Sega FILM muxer
ffmpeg | branch: master | Misty De Meo | Mon Apr 2 10:53:30 2018 -0700| [187ff5a10864f16b7872eca722e844e8f04ec57b] | committer: Josh de Kock Add Sega FILM muxer Signed-off-by: Josh de Kock > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=187ff5a10864f16b7872eca722e844e8f04ec57b --- Changelog | 1 + doc/general.texi | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/segafilmenc.c | 398 ++ libavformat/version.h | 2 +- 6 files changed, 403 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 200866d873..74c410a8e2 100644 --- a/Changelog +++ b/Changelog @@ -52,6 +52,7 @@ version : - E-AC-3 dependent frames support - bitstream filter for extracting E-AC-3 core - Haivision SRT protocol via libsrt +- segafilm muxer version 3.4: diff --git a/doc/general.texi b/doc/general.texi index 41c6a59e99..2583006b14 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -559,7 +559,7 @@ library: @item SAP @tab X @tab X @item SBG @tab @tab X @item SDP @tab @tab X -@item Sega FILM/CPK @tab @tab X +@item Sega FILM/CPK @tab X @tab X @tab Used in many Sega Saturn console games. @item Silicon Graphics Movie@tab @tab X @item Sierra SOL@tab @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index af0823a7db..3eeca5091d 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -462,6 +462,7 @@ OBJS-$(CONFIG_SDR2_DEMUXER) += sdr2.o OBJS-$(CONFIG_SDS_DEMUXER) += sdsdec.o OBJS-$(CONFIG_SDX_DEMUXER) += sdxdec.o OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o +OBJS-$(CONFIG_SEGAFILM_MUXER)+= segafilmenc.o OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o OBJS-$(CONFIG_SHORTEN_DEMUXER) += shortendec.o rawdec.o OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d8d733735a..d582778b3b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -362,6 +362,7 @@ extern AVInputFormat ff_sdr2_demuxer; extern AVInputFormat ff_sds_demuxer; extern AVInputFormat ff_sdx_demuxer; extern AVInputFormat ff_segafilm_demuxer; +extern AVOutputFormat ff_segafilm_muxer; extern AVOutputFormat ff_segment_muxer; extern AVOutputFormat ff_stream_segment_muxer; extern AVInputFormat ff_shorten_demuxer; diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c new file mode 100644 index 00..86c0ab0d1c --- /dev/null +++ b/libavformat/segafilmenc.c @@ -0,0 +1,398 @@ +/* + * Sega FILM Format (CPK) Muxer + * Copyright (C) 2003 The FFmpeg project + * Copyright (C) 2018 Misty De Meo + * + * 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 + * Sega FILM (.cpk) file muxer + * @author Misty De Meo + * + * @see For more information regarding the Sega FILM file format, visit: + * http://wiki.multimedia.cx/index.php?title=Sega_FILM + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" +#include "avio_internal.h" + +typedef struct FILMPacket { +int audio; +int keyframe; +int32_t pts; +int32_t duration; +int32_t size; +int32_t index; +struct FILMPacket *next; +} FILMPacket; + +typedef struct FILMOutputContext { +const AVClass *class; +int audio_index; +int video_index; +int64_t stab_pos; +FILMPacket *start; +FILMPacket *last; +int64_t packet_count; +} FILMOutputContext; + +static int film_write_packet_to_header(AVFormatContext *format_context, FILMPacket *pkt) +{ +AVIOContext *pb = format_context->pb; +/* The bits in these two 32-bit integers contain info about the contents of this sample */ +int32_t info1 = 0; +int32_t info2 = 0; + +if (pkt->audio) { +/* Always the same, carries no more information than "this is audio" */ +info1 = 0x; +info2 = 1; +} else { +info1 = pkt->pts; +info2 = pkt->duration; +/* The top
[FFmpeg-cvslog] Sega FILM: set dts and duration when demuxing
ffmpeg | branch: master | Misty De Meo | Sun Apr 8 18:27:25 2018 -0700| [d64183ea5da9c5248578d0bc4ffcbeddfc6c3555] | committer: Michael Niedermayer Sega FILM: set dts and duration when demuxing Reviewed-by: Kyle Swanson Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d64183ea5da9c5248578d0bc4ffcbeddfc6c3555 --- libavformat/segafilm.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 4c0cca0140..e72c26b144 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -270,6 +270,8 @@ static int film_read_packet(AVFormatContext *s, FilmDemuxContext *film = s->priv_data; AVIOContext *pb = s->pb; film_sample *sample; +film_sample *next_sample = NULL; +int next_sample_id; int ret = 0; if (film->current_sample >= film->sample_count) @@ -277,6 +279,20 @@ static int film_read_packet(AVFormatContext *s, sample = &film->sample_table[film->current_sample]; +/* Find the next sample from the same stream, assuming there is one; + * this is used to calculate the duration below */ +next_sample_id = film->current_sample + 1; +while (next_sample == NULL) { +if (next_sample_id >= film->sample_count) +break; + +next_sample = &film->sample_table[next_sample_id]; +if (next_sample->stream != sample->stream) { +next_sample = NULL; +next_sample_id++; +} +} + /* position the stream (will probably be there anyway) */ avio_seek(pb, sample->sample_offset, SEEK_SET); @@ -285,8 +301,11 @@ static int film_read_packet(AVFormatContext *s, ret = AVERROR(EIO); pkt->stream_index = sample->stream; +pkt->dts = sample->pts; pkt->pts = sample->pts; pkt->flags |= sample->keyframe ? AV_PKT_FLAG_KEY : 0; +if (next_sample != NULL) +pkt->duration = next_sample->pts - sample->pts; film->current_sample++; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog