Re: [FFmpeg-devel] [PATCH 1/3] avcodec/dxva2_hevc: add support for parsing HEVC Range Extension data
> On March 13, 2020 3:46 PM Hendrik Leppkes wrote: > > > On Fri, Mar 13, 2020 at 11:25 AM Steve Lhomme wrote: > > > > Mimick the existing structure and add the extra fields from the Range > > Extension > > in a wrapping structure. > > > > The FF_DXVA2_WORKAROUND_HEVC_REXT is set by the decoder user to signal the > > selected decoder is expecting this extended structure rather than the > > default > > one. > > --- > > libavcodec/d3d11va.h| 1 + > > libavcodec/dxva2.h | 1 + > > libavcodec/dxva2_hevc.c | 79 ++--- > > 3 files changed, 76 insertions(+), 5 deletions(-) > > > > diff --git a/libavcodec/d3d11va.h b/libavcodec/d3d11va.h > > index 6816b6c1e6..68a69c372d 100644 > > --- a/libavcodec/d3d11va.h > > +++ b/libavcodec/d3d11va.h > > @@ -47,6 +47,7 @@ > > > > #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for > > Direct3D11 and old UVD/UVD+ ATI video cards > > #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for > > Direct3D11 and old Intel GPUs with ClearVideo interface > > +#define FF_DXVA2_WORKAROUND_HEVC_REXT 4 ///< Signal the D3D11VA > > decoder is using the HEVC Rext picture structure > > > > /** > > * This structure is used to provides the necessary configurations and data > > diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h > > index 22c93992f2..024999239d 100644 > > --- a/libavcodec/dxva2.h > > +++ b/libavcodec/dxva2.h > > @@ -47,6 +47,7 @@ > > > > #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for > > DXVA2 and old UVD/UVD+ ATI video cards > > #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for > > DXVA2 and old Intel GPUs with ClearVideo interface > > +#define FF_DXVA2_WORKAROUND_HEVC_REXT 4 ///< Signal the DXVA2 > > decoder is using the HEVC Rext picture structure > > > > /** > > * This structure is used to provides the necessary configurations and data > > diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c > > index dbb701fb1c..98b3e74bd7 100644 > > --- a/libavcodec/dxva2_hevc.c > > +++ b/libavcodec/dxva2_hevc.c > > @@ -26,10 +26,47 @@ > > #include "hevc_data.h" > > #include "hevcdec.h" > > > > +#pragma pack(push, 1) > > +typedef struct > > +{ > > +DXVA_PicParams_HEVC main; > > + > > +// HEVC Range Extension > > +__C89_NAMELESS union { > > +__C89_NAMELESS struct { > > +UINT32 transform_skip_rotation_enabled_flag : 1; > > +UINT32 transform_skip_context_enabled_flag : 1; > > +UINT32 implicit_rdpcm_enabled_flag : 1; > > +UINT32 explicit_rdpcm_enabled_flag : 1; > > +UINT32 extended_precision_processing_flag : 1; > > +UINT32 intra_smoothing_disabled_flag : 1; > > +UINT32 high_precision_offsets_enabled_flag : 1; > > +UINT32 persistent_rice_adaptation_enabled_flag : 1; > > +UINT32 cabac_bypass_alignment_enabled_flag : 1; > > +UINT32 cross_component_prediction_enabled_flag : 1; > > +UINT32 chroma_qp_offset_list_enabled_flag : 1; > > +UINT32 BitDepthLuma16 : 1; // TODO merge in ReservedBits5 if > > not needed > > +UINT32 BitDepthChroma16 : 1; // TODO merge in ReservedBits5 if > > not needed > > +UINT32 ReservedBits8 : 19; > > +}; > > +UINT32 dwRangeExtensionFlags; > > +}; > > + > > +UCHAR diff_cu_chroma_qp_offset_depth; > > +UCHAR chroma_qp_offset_list_len_minus1; > > +UCHAR log2_sao_offset_scale_luma; > > +UCHAR log2_sao_offset_scale_chroma; > > +UCHAR log2_max_transform_skip_block_size_minus2; > > +CHAR cb_qp_offset_list[6]; > > +CHAR cr_qp_offset_list[6]; > > + > > +} DXVA_PicParams_HEVC_Rext; > > +#pragma pack(pop) > > + > > Where is this struct specified? I don't see it in the latest released > Windows SDK. It is not. It is reversed engineered from the existing structure and wild guessing based on the HEVC Range Extension specs. The bits/fields are in the same order as the specs. Then I tested some GUIDs that output non 4:2:0 pixel formats on an Intel GPU that is known to decoder HEVC Range Extension. Apparently NVIDIA doesn't provide DXVA GUIDs that output non 4:2:0 pixel formats on GPUs that supposedly decode HEVC 444 (likley nvdec only). AMD doesn't have such GPUs AFAIK. So for now it's Intel only. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avformat: add fwse demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/fwse.c | 88 3 files changed, 90 insertions(+) create mode 100644 libavformat/fwse.c diff --git a/libavformat/Makefile b/libavformat/Makefile index f84becd30a..cd3e9163f5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -198,6 +198,7 @@ OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o OBJS-$(CONFIG_FRAMEMD5_MUXER)+= hashenc.o framehash.o OBJS-$(CONFIG_FRM_DEMUXER) += frmdec.o OBJS-$(CONFIG_FSB_DEMUXER) += fsb.o +OBJS-$(CONFIG_FWSE_DEMUXER) += fwse.o OBJS-$(CONFIG_GIF_MUXER) += gif.o OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 08012ea208..d275c1017b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -156,6 +156,7 @@ extern AVOutputFormat ff_framehash_muxer; extern AVOutputFormat ff_framemd5_muxer; extern AVInputFormat ff_frm_demuxer; extern AVInputFormat ff_fsb_demuxer; +extern AVInputFormat ff_fwse_demuxer; extern AVInputFormat ff_g722_demuxer; extern AVOutputFormat ff_g722_muxer; extern AVInputFormat ff_g723_1_demuxer; diff --git a/libavformat/fwse.c b/libavformat/fwse.c new file mode 100644 index 00..00e2e13b11 --- /dev/null +++ b/libavformat/fwse.c @@ -0,0 +1,88 @@ +/* + * FWSE demuxer + * Copyright (c) 2020 Paul B Mahol + * + * 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 + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" +#include "pcm.h" + +static int fwse_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != MKTAG('F','W','S','E')) +return 0; +if (AV_RL32(p->buf+4) != 2 && AV_RL32(p->buf+4) != 3) +return 0; +if (AV_RL32(p->buf+16) != 1 && AV_RL32(p->buf+16) != 2) +return 0; + +return AVPROBE_SCORE_MAX / 4 * 3; +} + +static int fwse_read_header(AVFormatContext *s) +{ +unsigned start_offset, version; +AVIOContext *pb = s->pb; +AVCodecParameters *par; +AVStream *st; + +avio_skip(pb, 4); +version = avio_rl32(pb); +if (version != 2 && version != 3) +return AVERROR_INVALIDDATA; +avio_skip(pb, 4); +start_offset = avio_rl32(pb); + +st = avformat_new_stream(s, NULL); +if (!st) +return AVERROR(ENOMEM); + +par = st->codecpar; +par->codec_type = AVMEDIA_TYPE_AUDIO; +par->codec_id= AV_CODEC_ID_ADPCM_IMA_MTF; +par->format = AV_SAMPLE_FMT_S16; +par->channels= avio_rl32(pb); +if (par->channels != 1 && par->channels != 2) +return AVERROR_INVALIDDATA; +if (par->channels == 1) +par->channel_layout = AV_CH_LAYOUT_MONO; +else if (par->channels == 2) +par->channel_layout = AV_CH_LAYOUT_STEREO; +st->duration = avio_rl32(pb); +par->sample_rate = avio_rl32(pb); +if (par->sample_rate <= 0 || par->sample_rate > INT_MAX) +return AVERROR_INVALIDDATA; + +par->block_align = 1; +avio_skip(pb, start_offset - avio_tell(pb)); + +avpriv_set_pts_info(st, 64, 1, par->sample_rate); + +return 0; +} + +AVInputFormat ff_fwse_demuxer = { +.name = "fwse", +.long_name = NULL_IF_CONFIG_SMALL("Capcom's MT Framework sound"), +.read_probe = fwse_probe, +.read_header= fwse_read_header, +.read_packet= ff_pcm_read_packet, +.extensions = "fwse", +}; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/5] avformat: add fwse demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/fwse.c | 88 3 files changed, 90 insertions(+) create mode 100644 libavformat/fwse.c diff --git a/libavformat/Makefile b/libavformat/Makefile index f84becd30a..cd3e9163f5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -198,6 +198,7 @@ OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o OBJS-$(CONFIG_FRAMEMD5_MUXER)+= hashenc.o framehash.o OBJS-$(CONFIG_FRM_DEMUXER) += frmdec.o OBJS-$(CONFIG_FSB_DEMUXER) += fsb.o +OBJS-$(CONFIG_FWSE_DEMUXER) += fwse.o OBJS-$(CONFIG_GIF_MUXER) += gif.o OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 08012ea208..d275c1017b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -156,6 +156,7 @@ extern AVOutputFormat ff_framehash_muxer; extern AVOutputFormat ff_framemd5_muxer; extern AVInputFormat ff_frm_demuxer; extern AVInputFormat ff_fsb_demuxer; +extern AVInputFormat ff_fwse_demuxer; extern AVInputFormat ff_g722_demuxer; extern AVOutputFormat ff_g722_muxer; extern AVInputFormat ff_g723_1_demuxer; diff --git a/libavformat/fwse.c b/libavformat/fwse.c new file mode 100644 index 00..00e2e13b11 --- /dev/null +++ b/libavformat/fwse.c @@ -0,0 +1,88 @@ +/* + * FWSE demuxer + * Copyright (c) 2020 Paul B Mahol + * + * 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 + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" +#include "pcm.h" + +static int fwse_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != MKTAG('F','W','S','E')) +return 0; +if (AV_RL32(p->buf+4) != 2 && AV_RL32(p->buf+4) != 3) +return 0; +if (AV_RL32(p->buf+16) != 1 && AV_RL32(p->buf+16) != 2) +return 0; + +return AVPROBE_SCORE_MAX / 4 * 3; +} + +static int fwse_read_header(AVFormatContext *s) +{ +unsigned start_offset, version; +AVIOContext *pb = s->pb; +AVCodecParameters *par; +AVStream *st; + +avio_skip(pb, 4); +version = avio_rl32(pb); +if (version != 2 && version != 3) +return AVERROR_INVALIDDATA; +avio_skip(pb, 4); +start_offset = avio_rl32(pb); + +st = avformat_new_stream(s, NULL); +if (!st) +return AVERROR(ENOMEM); + +par = st->codecpar; +par->codec_type = AVMEDIA_TYPE_AUDIO; +par->codec_id= AV_CODEC_ID_ADPCM_IMA_MTF; +par->format = AV_SAMPLE_FMT_S16; +par->channels= avio_rl32(pb); +if (par->channels != 1 && par->channels != 2) +return AVERROR_INVALIDDATA; +if (par->channels == 1) +par->channel_layout = AV_CH_LAYOUT_MONO; +else if (par->channels == 2) +par->channel_layout = AV_CH_LAYOUT_STEREO; +st->duration = avio_rl32(pb); +par->sample_rate = avio_rl32(pb); +if (par->sample_rate <= 0 || par->sample_rate > INT_MAX) +return AVERROR_INVALIDDATA; + +par->block_align = 1; +avio_skip(pb, start_offset - avio_tell(pb)); + +avpriv_set_pts_info(st, 64, 1, par->sample_rate); + +return 0; +} + +AVInputFormat ff_fwse_demuxer = { +.name = "fwse", +.long_name = NULL_IF_CONFIG_SMALL("Capcom's MT Framework sound"), +.read_probe = fwse_probe, +.read_header= fwse_read_header, +.read_packet= ff_pcm_read_packet, +.extensions = "fwse", +}; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/5] avcodec: add ADPCM IMA MTF decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/adpcm.c | 33 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 +++ 5 files changed, 43 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a3326a45e7..b50a26907f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -843,6 +843,7 @@ OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_IMA_MTF_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_OKI_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER) += adpcmenc.o adpcm_data.o diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 4f5980f7d5..e9abddc43c 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -89,6 +89,11 @@ static const int8_t zork_index_table[8] = { -1, -1, -1, 1, 4, 7, 10, 12, }; +static const int8_t mtf_index_table[16] = { + 8, 6, 4, 2, -1, -1, -1, -1, +-1, -1, -1, -1, 2, 4, 6, 8, +}; + /* end of tables */ typedef struct ADPCMDecodeContext { @@ -304,6 +309,22 @@ static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t return (int16_t)c->predictor; } +static inline int16_t adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nibble) +{ +int step_index, step, delta, predictor; + +step = ff_adpcm_step_table[c->step_index]; + +delta = step * (2 * nibble - 15); +predictor = c->predictor + delta; + +step_index = c->step_index + mtf_index_table[(unsigned)nibble]; +c->predictor = av_clip_int16(predictor >> 4); +c->step_index = av_clip(step_index, 0, 88); + +return (int16_t)c->predictor; +} + static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) { int nibble, step_index, predictor, sign, delta, diff, step, shift; @@ -700,6 +721,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, case AV_CODEC_ID_ADPCM_IMA_SSI: case AV_CODEC_ID_ADPCM_IMA_APM: case AV_CODEC_ID_ADPCM_IMA_ALP: +case AV_CODEC_ID_ADPCM_IMA_MTF: nb_samples = buf_size * 2 / ch; break; } @@ -1956,6 +1978,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v); } break; +case AV_CODEC_ID_ADPCM_IMA_MTF: +for (n = nb_samples / 2; n > 0; n--) { +for (channel = 0; channel < avctx->channels; channel++) { +int v = bytestream2_get_byteu(&gb); +*samples++ = adpcm_ima_mtf_expand_nibble(&c->status[channel], v >> 4); +samples[st] = adpcm_ima_mtf_expand_nibble(&c->status[channel], v & 0x0F); +} +samples += avctx->channels; +} +break; default: av_assert0(0); // unsupported codec_id should not happen } @@ -2027,6 +2059,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, sample_fmts_s16, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, sample_fmts_s16, adpcm_ima_iss, "ADPCM IMA Funcom ISS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_MTF, sample_fmts_s16, adpcm_ima_mtf, "ADPCM IMA Capcom's MT Framework"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_OKI, sample_fmts_s16, adpcm_ima_oki, "ADPCM IMA Dialogic OKI"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, "ADPCM IMA QuickTime"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16, adpcm_ima_rad, "ADPCM IMA Radical"); diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f4cf180716..379c5f7b81 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -608,6 +608,7 @@ extern AVCodec ff_adpcm_ima_dk4_decoder; extern AVCodec ff_adpcm_ima_ea_eacs_decoder; extern AVCodec ff_adpcm_ima_ea_sead_decoder; extern AVCodec ff_adpcm_ima_iss_decoder; +extern AVCodec ff_adpcm_ima_mtf_decoder; extern AVCodec ff_adpcm_ima_oki_decoder; extern AVCodec ff_adpcm_ima_qt_encoder; extern AVCodec ff_adpcm_ima_qt_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index aca3825fd3..9ac97a122b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -553,6 +553,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_ZORK, AV_CODEC_ID_ADPCM_IMA_APM, AV_CODEC_ID_ADPCM_IMA_ALP, +AV_CODEC_ID_ADPCM_IMA_MTF, /* AMR */
[FFmpeg-devel] [PATCH 3/5] avcodec: add derf dpcm decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 +++ libavcodec/dpcm.c | 32 libavcodec/utils.c | 1 + 6 files changed, 43 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b50a26907f..a88643b7d2 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -265,6 +265,7 @@ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o dcahuff.o \ dcaadpcm.o OBJS-$(CONFIG_DDS_DECODER) += dds.o +OBJS-$(CONFIG_DERF_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o diractab.o \ dirac_arith.o dirac_dwt.o dirac_vlc.o OBJS-$(CONFIG_DFA_DECODER) += dfa.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 379c5f7b81..6046b15164 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -569,6 +569,7 @@ extern AVCodec ff_pcm_vidc_encoder; extern AVCodec ff_pcm_vidc_decoder; /* DPCM codecs */ +extern AVCodec ff_derf_dpcm_decoder; extern AVCodec ff_gremlin_dpcm_decoder; extern AVCodec ff_interplay_dpcm_decoder; extern AVCodec ff_roq_dpcm_encoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9ac97a122b..e9c658fddc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -571,6 +571,7 @@ enum AVCodecID { AV_CODEC_ID_SDX2_DPCM = 0x14800, AV_CODEC_ID_GREMLIN_DPCM, +AV_CODEC_ID_DERF_DPCM, /* audio codecs */ AV_CODEC_ID_MP2 = 0x15000, diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index df3671765a..130e08c1f2 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2415,6 +2415,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("DPCM Gremlin"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_DERF_DPCM, +.type = AVMEDIA_TYPE_AUDIO, +.name = "derf_dpcm", +.long_name = NULL_IF_CONFIG_SMALL("DPCM Xilam DERF"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +}, /* audio codecs */ { diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index 5958081b66..069bf1dcd8 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -49,6 +49,21 @@ typedef struct DPCMContext { const int8_t *sol_table;///< delta table for SOL_DPCM } DPCMContext; +static const int32_t derf_steps[96] = { +0, 1, 2, 3, 4, 5, 6, 7, +8, 9, 10, 11, 12, 13, 14, 16, +17, 19, 21, 23, 25, 28, 31, 34, +37, 41, 45, 50, 55, 60, 66, 73, +80, 88, 97, 107, 118, 130, 143, 157, +173, 190, 209, 230, 253, 279, 307, 337, +371, 408, 449, 494, 544, 598, 658, 724, +796, 876, 963, 1060, 1166, 1282, 1411, 1552, +1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, +3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, +7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, +16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767, +}; + static const int16_t interplay_delta_table[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -225,6 +240,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, else out = buf_size; break; +case AV_CODEC_ID_DERF_DPCM: case AV_CODEC_ID_GREMLIN_DPCM: case AV_CODEC_ID_SDX2_DPCM: out = buf_size; @@ -372,6 +388,21 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, } } break; + +case AV_CODEC_ID_DERF_DPCM: { +int idx = 0; + +while (output_samples < samples_end) { +uint8_t n = bytestream2_get_byteu(&gb); +int index = FFMIN(n & 0x7f, 95); + +s->sample[idx] += (n & 0x80 ? -1: 1) * derf_steps[index]; +s->sample[idx] = av_clip_int16(s->sample[idx]); +*output_samples++ = s->sample[idx]; +idx ^= stereo; +} +} +break; } *got_frame_ptr = 1; @@ -391,6 +422,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ .capabilities = AV_CODEC_CAP_DR1, \ } +DPCM_DECODER(AV_CODEC_ID_DERF_DPCM, derf_dpcm, "DPCM Xilam DERF"); DPCM_DECODER(AV_CODEC_ID_GREMLIN_DPCM, gremlin_dpcm, "DPCM Gremlin"); DPCM_DECODER(AV_CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay"); DPCM_DECODER(AV_CODEC_ID_ROQ_DPCM, roq_dpcm, "DPCM id RoQ"); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c4dc136d3c..66bfdaf4f8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1478,6 +1478,7 @@ int av_get
[FFmpeg-devel] [PATCH 5/5] avcodec/allcodecs: move sdx2 to correct place
Signed-off-by: Paul B Mahol --- libavcodec/allcodecs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 6046b15164..71e14c73e3 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -275,7 +275,6 @@ extern AVCodec ff_s302m_decoder; extern AVCodec ff_sanm_decoder; extern AVCodec ff_scpr_decoder; extern AVCodec ff_screenpresso_decoder; -extern AVCodec ff_sdx2_dpcm_decoder; extern AVCodec ff_sgi_encoder; extern AVCodec ff_sgi_decoder; extern AVCodec ff_sgirle_decoder; @@ -574,6 +573,7 @@ extern AVCodec ff_gremlin_dpcm_decoder; extern AVCodec ff_interplay_dpcm_decoder; extern AVCodec ff_roq_dpcm_encoder; extern AVCodec ff_roq_dpcm_decoder; +extern AVCodec ff_sdx2_dpcm_decoder; extern AVCodec ff_sol_dpcm_decoder; extern AVCodec ff_xan_dpcm_decoder; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/5] avformat: add derf demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/derf.c | 79 3 files changed, 81 insertions(+) create mode 100644 libavformat/derf.c diff --git a/libavformat/Makefile b/libavformat/Makefile index cd3e9163f5..27615cd746 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -151,6 +151,7 @@ OBJS-$(CONFIG_DASH_DEMUXER) += dash.o dashdec.o OBJS-$(CONFIG_DAUD_DEMUXER) += dauddec.o OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o +OBJS-$(CONFIG_DERF_DEMUXER) += derf.o OBJS-$(CONFIG_DFA_DEMUXER) += dfa.o OBJS-$(CONFIG_DHAV_DEMUXER) += dhav.o OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d275c1017b..af10def88b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -113,6 +113,7 @@ extern AVOutputFormat ff_data_muxer; extern AVInputFormat ff_daud_demuxer; extern AVOutputFormat ff_daud_muxer; extern AVInputFormat ff_dcstr_demuxer; +extern AVInputFormat ff_derf_demuxer; extern AVInputFormat ff_dfa_demuxer; extern AVInputFormat ff_dhav_demuxer; extern AVInputFormat ff_dirac_demuxer; diff --git a/libavformat/derf.c b/libavformat/derf.c new file mode 100644 index 00..58bbf5b791 --- /dev/null +++ b/libavformat/derf.c @@ -0,0 +1,79 @@ +/* + * DERF demuxer + * Copyright (c) 2020 Paul B Mahol + * + * 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 + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" +#include "pcm.h" + +static int derf_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != MKTAG('D','E','R','F')) +return 0; +if (AV_RL32(p->buf+4) != 1 && AV_RL32(p->buf+4) != 2) +return 0; + +return AVPROBE_SCORE_MAX / 3 * 2; +} + +static int derf_read_header(AVFormatContext *s) +{ +unsigned data_size; +AVIOContext *pb = s->pb; +AVCodecParameters *par; +AVStream *st; + +avio_skip(pb, 4); + +st = avformat_new_stream(s, NULL); +if (!st) +return AVERROR(ENOMEM); + +par = st->codecpar; +par->codec_type = AVMEDIA_TYPE_AUDIO; +par->codec_id= AV_CODEC_ID_DERF_DPCM; +par->format = AV_SAMPLE_FMT_S16; +par->channels= avio_rl32(pb); +if (par->channels != 1 && par->channels != 2) +return AVERROR_INVALIDDATA; +if (par->channels == 1) +par->channel_layout = AV_CH_LAYOUT_MONO; +else if (par->channels == 2) +par->channel_layout = AV_CH_LAYOUT_STEREO; +data_size = avio_rl32(pb); +st->duration = data_size / par->channels; +par->sample_rate = 22050; +par->block_align = 1; + +avpriv_set_pts_info(st, 64, 1, par->sample_rate); + +return 0; +} + +AVInputFormat ff_derf_demuxer = { +.name = "derf", +.long_name = NULL_IF_CONFIG_SMALL("Xilam DERF"), +.read_probe = derf_probe, +.read_header= derf_read_header, +.read_packet= ff_pcm_read_packet, +.read_seek = ff_pcm_read_seek, +.extensions = "adp", +}; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/5] avformat: add derf demuxer
Paul B Mahol: > Signed-off-by: Paul B Mahol > --- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/derf.c | 79 > 3 files changed, 81 insertions(+) > create mode 100644 libavformat/derf.c > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index cd3e9163f5..27615cd746 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -151,6 +151,7 @@ OBJS-$(CONFIG_DASH_DEMUXER) += dash.o > dashdec.o > OBJS-$(CONFIG_DAUD_DEMUXER) += dauddec.o > OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o > OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o > +OBJS-$(CONFIG_DERF_DEMUXER) += derf.o > OBJS-$(CONFIG_DFA_DEMUXER) += dfa.o > OBJS-$(CONFIG_DHAV_DEMUXER) += dhav.o > OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index d275c1017b..af10def88b 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -113,6 +113,7 @@ extern AVOutputFormat ff_data_muxer; > extern AVInputFormat ff_daud_demuxer; > extern AVOutputFormat ff_daud_muxer; > extern AVInputFormat ff_dcstr_demuxer; > +extern AVInputFormat ff_derf_demuxer; > extern AVInputFormat ff_dfa_demuxer; > extern AVInputFormat ff_dhav_demuxer; > extern AVInputFormat ff_dirac_demuxer; > diff --git a/libavformat/derf.c b/libavformat/derf.c > new file mode 100644 > index 00..58bbf5b791 > --- /dev/null > +++ b/libavformat/derf.c > @@ -0,0 +1,79 @@ > +/* > + * DERF demuxer > + * Copyright (c) 2020 Paul B Mahol > + * > + * 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 > + */ > + > +#include "libavutil/intreadwrite.h" > +#include "avformat.h" > +#include "internal.h" > +#include "pcm.h" > + > +static int derf_probe(const AVProbeData *p) > +{ > +if (AV_RL32(p->buf) != MKTAG('D','E','R','F')) > +return 0; > +if (AV_RL32(p->buf+4) != 1 && AV_RL32(p->buf+4) != 2) > +return 0; > + > +return AVPROBE_SCORE_MAX / 3 * 2; > +} > + > +static int derf_read_header(AVFormatContext *s) > +{ > +unsigned data_size; > +AVIOContext *pb = s->pb; > +AVCodecParameters *par; > +AVStream *st; > + > +avio_skip(pb, 4); > + > +st = avformat_new_stream(s, NULL); > +if (!st) > +return AVERROR(ENOMEM); > + > +par = st->codecpar; > +par->codec_type = AVMEDIA_TYPE_AUDIO; > +par->codec_id= AV_CODEC_ID_DERF_DPCM; > +par->format = AV_SAMPLE_FMT_S16; > +par->channels= avio_rl32(pb); > +if (par->channels != 1 && par->channels != 2) > +return AVERROR_INVALIDDATA; > +if (par->channels == 1) > +par->channel_layout = AV_CH_LAYOUT_MONO; > +else if (par->channels == 2) > +par->channel_layout = AV_CH_LAYOUT_STEREO; > +data_size = avio_rl32(pb); > +st->duration = data_size / par->channels; Won't the reported duration be wrong if the file is trimmed? (Is this how it is supposed to be?) > +par->sample_rate = 22050; > +par->block_align = 1; > + > +avpriv_set_pts_info(st, 64, 1, par->sample_rate); > + > +return 0; > +} > + > +AVInputFormat ff_derf_demuxer = { > +.name = "derf", > +.long_name = NULL_IF_CONFIG_SMALL("Xilam DERF"), > +.read_probe = derf_probe, > +.read_header= derf_read_header, > +.read_packet= ff_pcm_read_packet, > +.read_seek = ff_pcm_read_seek, > +.extensions = "adp", > +}; > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] scale_vulkan: add support for RGB->YUV conversions
Patch attached. >From b0febb1dc4263d7c144cae968247053b405b864e Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 15 Mar 2020 10:30:34 + Subject: [PATCH] scale_vulkan: add support for RGB->YUV conversions --- libavfilter/vf_scale_vulkan.c | 298 +++--- libavfilter/vulkan.c | 12 ++ libavfilter/vulkan.h | 5 + 3 files changed, 252 insertions(+), 63 deletions(-) diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c index 1534f2d716..5293d7671b 100644 --- a/libavfilter/vf_scale_vulkan.c +++ b/libavfilter/vf_scale_vulkan.c @@ -20,6 +20,7 @@ #include "vulkan.h" #include "scale_eval.h" #include "internal.h" +#include "colorspace.h" #define CGROUPS (int [3]){ 32, 32, 1 } @@ -36,22 +37,67 @@ typedef struct ScaleVulkanContext { int initialized; FFVkExecContext *exec; VulkanPipeline *pl; +FFVkBuffer params_buf; /* Shader updators, must be in the main filter struct */ VkDescriptorImageInfo input_images[3]; VkDescriptorImageInfo output_images[3]; +VkDescriptorBufferInfo params_desc; enum ScalerFunc scaler; -char *output_format_string; +char *out_format_string; +enum AVColorRange out_range; char *w_expr; char *h_expr; } ScaleVulkanContext; static const char scale_bilinear[] = { -C(0, void scale_bilinear(int idx, ivec2 pos)) +C(0, vec4 scale_bilinear(int idx, ivec2 pos)) C(0, { ) C(1, const vec2 npos = (vec2(pos) + 0.5f) / imageSize(output_img[idx]); ) -C(1, imageStore(output_img[idx], pos, texture(input_img[idx], npos)); ) +C(1, return texture(input_img[idx], npos); ) +C(0, } ) +}; + +static const char rgb2yuv[] = { +C(0, vec4 rgb2yuv(vec4 src, int fullrange) ) +C(0, { ) +C(1, src *= yuv_matrix; ) +C(1, if (fullrange == 1) { ) +C(2, src += vec4(0.0, 0.5, 0.5, 0.0); ) +C(1, } else { ) +C(2, src *= vec4(219.0 / 255.0, 224.0 / 255.0, 224.0 / 255.0, 1.0); ) +C(2, src += vec4(16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 0.0); ) +C(1, } ) +C(1, return src;) +C(0, } ) +}; + +static const char write_nv12[] = { +C(0, void write_nv12(vec4 src, ivec2 pos) ) +C(0, { ) +C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));) +C(1, pos /= ivec2(2); ) +C(1, imageStore(output_img[1], pos, vec4(src.g, src.b, 0.0, 0.0)); ) +C(0, } ) +}; + +static const char write_420[] = { +C(0, void write_420(vec4 src, ivec2 pos)) +C(0, { ) +C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));) +C(1, pos /= ivec2(2); ) +C(1, imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0));) +C(1, imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0));) +C(0, } ) +}; + +static const char write_444[] = { +C(0, void write_444(vec4 src, ivec2 pos)) +C(0, { ) +C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));) +C(1, imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0));) +C(1, imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0));) C(0, } ) }; @@ -103,6 +149,16 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) }, }; +VulkanDescriptorSetBinding desc_b = { +.name= "params", +.type= VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, +.mem_quali = "readonly", +.mem_layout = "std430", +.stages = VK_SHADER_STAGE_COMPUTE_BIT, +.upda
Re: [FFmpeg-devel] [PATCH 4/5] avformat: add derf demuxer
On 3/15/20, Andreas Rheinhardt wrote: > Paul B Mahol: >> Signed-off-by: Paul B Mahol >> --- >> libavformat/Makefile | 1 + >> libavformat/allformats.c | 1 + >> libavformat/derf.c | 79 >> 3 files changed, 81 insertions(+) >> create mode 100644 libavformat/derf.c >> >> diff --git a/libavformat/Makefile b/libavformat/Makefile >> index cd3e9163f5..27615cd746 100644 >> --- a/libavformat/Makefile >> +++ b/libavformat/Makefile >> @@ -151,6 +151,7 @@ OBJS-$(CONFIG_DASH_DEMUXER) += dash.o >> dashdec.o >> OBJS-$(CONFIG_DAUD_DEMUXER) += dauddec.o >> OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o >> OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o >> +OBJS-$(CONFIG_DERF_DEMUXER) += derf.o >> OBJS-$(CONFIG_DFA_DEMUXER) += dfa.o >> OBJS-$(CONFIG_DHAV_DEMUXER) += dhav.o >> OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o >> diff --git a/libavformat/allformats.c b/libavformat/allformats.c >> index d275c1017b..af10def88b 100644 >> --- a/libavformat/allformats.c >> +++ b/libavformat/allformats.c >> @@ -113,6 +113,7 @@ extern AVOutputFormat ff_data_muxer; >> extern AVInputFormat ff_daud_demuxer; >> extern AVOutputFormat ff_daud_muxer; >> extern AVInputFormat ff_dcstr_demuxer; >> +extern AVInputFormat ff_derf_demuxer; >> extern AVInputFormat ff_dfa_demuxer; >> extern AVInputFormat ff_dhav_demuxer; >> extern AVInputFormat ff_dirac_demuxer; >> diff --git a/libavformat/derf.c b/libavformat/derf.c >> new file mode 100644 >> index 00..58bbf5b791 >> --- /dev/null >> +++ b/libavformat/derf.c >> @@ -0,0 +1,79 @@ >> +/* >> + * DERF demuxer >> + * Copyright (c) 2020 Paul B Mahol >> + * >> + * 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 >> + */ >> + >> +#include "libavutil/intreadwrite.h" >> +#include "avformat.h" >> +#include "internal.h" >> +#include "pcm.h" >> + >> +static int derf_probe(const AVProbeData *p) >> +{ >> +if (AV_RL32(p->buf) != MKTAG('D','E','R','F')) >> +return 0; >> +if (AV_RL32(p->buf+4) != 1 && AV_RL32(p->buf+4) != 2) >> +return 0; >> + >> +return AVPROBE_SCORE_MAX / 3 * 2; >> +} >> + >> +static int derf_read_header(AVFormatContext *s) >> +{ >> +unsigned data_size; >> +AVIOContext *pb = s->pb; >> +AVCodecParameters *par; >> +AVStream *st; >> + >> +avio_skip(pb, 4); >> + >> +st = avformat_new_stream(s, NULL); >> +if (!st) >> +return AVERROR(ENOMEM); >> + >> +par = st->codecpar; >> +par->codec_type = AVMEDIA_TYPE_AUDIO; >> +par->codec_id= AV_CODEC_ID_DERF_DPCM; >> +par->format = AV_SAMPLE_FMT_S16; >> +par->channels= avio_rl32(pb); >> +if (par->channels != 1 && par->channels != 2) >> +return AVERROR_INVALIDDATA; >> +if (par->channels == 1) >> +par->channel_layout = AV_CH_LAYOUT_MONO; >> +else if (par->channels == 2) >> +par->channel_layout = AV_CH_LAYOUT_STEREO; >> +data_size = avio_rl32(pb); >> +st->duration = data_size / par->channels; > > Won't the reported duration be wrong if the file is trimmed? (Is this > how it is supposed to be?) Yes. > >> +par->sample_rate = 22050; >> +par->block_align = 1; >> + >> +avpriv_set_pts_info(st, 64, 1, par->sample_rate); >> + >> +return 0; >> +} >> + >> +AVInputFormat ff_derf_demuxer = { >> +.name = "derf", >> +.long_name = NULL_IF_CONFIG_SMALL("Xilam DERF"), >> +.read_probe = derf_probe, >> +.read_header= derf_read_header, >> +.read_packet= ff_pcm_read_packet, >> +.read_seek = ff_pcm_read_seek, >> +.extensions = "adp", >> +}; >> > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "
Re: [FFmpeg-devel] [PATCH 07/17] avformat/webmdashenc: Remove write_trailer
Andreas Rheinhardt: > It doesn't do anything: All allocated blocks have already been freed in > write_header. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/webmdashenc.c | 7 --- > 1 file changed, 7 deletions(-) > > diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c > index 26b8727304..d2f0e0ec4d 100644 > --- a/libavformat/webmdashenc.c > +++ b/libavformat/webmdashenc.c > @@ -550,12 +550,6 @@ static int > webm_dash_manifest_write_packet(AVFormatContext *s, AVPacket *pkt) > return AVERROR_EOF; > } > > -static int webm_dash_manifest_write_trailer(AVFormatContext *s) > -{ > -free_adaptation_sets(s); > -return 0; > -} > - > #define OFFSET(x) offsetof(WebMDashMuxContext, x) > static const AVOption options[] = { > { "adaptation_sets", "Adaptation sets. Syntax: id=0,streams=0,1,2 > id=1,streams=3,4 and so on", OFFSET(adaptation_sets), AV_OPT_TYPE_STRING, { 0 > }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, > @@ -585,7 +579,6 @@ AVOutputFormat ff_webm_dash_manifest_muxer = { > .priv_data_size= sizeof(WebMDashMuxContext), > .write_header = webm_dash_manifest_write_header, > .write_packet = webm_dash_manifest_write_packet, > -.write_trailer = webm_dash_manifest_write_trailer, > .priv_class= &webm_dash_class, > }; > #endif > Ping. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 07/17] avformat/webmdashenc: Remove write_trailer
lgtm On 12/26/19, Andreas Rheinhardt wrote: > It doesn't do anything: All allocated blocks have already been freed in > write_header. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/webmdashenc.c | 7 --- > 1 file changed, 7 deletions(-) > > diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c > index 26b8727304..d2f0e0ec4d 100644 > --- a/libavformat/webmdashenc.c > +++ b/libavformat/webmdashenc.c > @@ -550,12 +550,6 @@ static int > webm_dash_manifest_write_packet(AVFormatContext *s, AVPacket *pkt) > return AVERROR_EOF; > } > > -static int webm_dash_manifest_write_trailer(AVFormatContext *s) > -{ > -free_adaptation_sets(s); > -return 0; > -} > - > #define OFFSET(x) offsetof(WebMDashMuxContext, x) > static const AVOption options[] = { > { "adaptation_sets", "Adaptation sets. Syntax: id=0,streams=0,1,2 > id=1,streams=3,4 and so on", OFFSET(adaptation_sets), AV_OPT_TYPE_STRING, { > 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, > @@ -585,7 +579,6 @@ AVOutputFormat ff_webm_dash_manifest_muxer = { > .priv_data_size= sizeof(WebMDashMuxContext), > .write_header = webm_dash_manifest_write_header, > .write_packet = webm_dash_manifest_write_packet, > -.write_trailer = webm_dash_manifest_write_trailer, > .priv_class= &webm_dash_class, > }; > #endif > -- > 2.20.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] new patch
let me now any progress? On Tuesday, February 18, 2020, 6:41:08 PM GMT+3:30, Mostafa Namazi fard wrote: I found this patch useful for prevent crash in http live stream.I'm using ffmpeg in my application for show http live when remote address send invalid data ffmpeg crash in this part and after my change it was fixed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/dxva2_hevc: add support for parsing HEVC Range Extension data
On Sun, Mar 15, 2020 at 8:12 AM Steve Lhomme wrote: > > Where is this struct specified? I don't see it in the latest released > > Windows SDK. > > It is not. It is reversed engineered from the existing structure and wild > guessing based on the HEVC Range Extension specs. The bits/fields are in the > same order as the specs. Then I tested some GUIDs that output non 4:2:0 pixel > formats on an Intel GPU that is known to decoder HEVC Range Extension. > > Apparently NVIDIA doesn't provide DXVA GUIDs that output non 4:2:0 pixel > formats on GPUs that supposedly decode HEVC 444 (likley nvdec only). AMD > doesn't have such GPUs AFAIK. > > So for now it's Intel only. That seems very hackish for something thats otherwise cleanly based on official specifications only. Maybe try to get them to release specs for this instead? - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC] Question Regarding Parsing Files with Sections of Unknown Length and No Delimiters
Hello, I am dealing dealing with a video (gif-like) file format in which there are compressed (entropy coded) segments of unknown length. However, the length of the uncompressed segment of the file is already known. Please check the previous mail by thread if context is required. There are no markers that indicate the end of these segments, and these segments are present at the end of the file. One additional problem is that the frames of the video are interleaved, which means that the parser will have to be provided with the whole pixel data/frame data at once, and cannot be broken into individual frames. I have been trying to figure out how to do go about parsing the file, and I have come up with the following approaches: 1. Decompress the compressed segment in the parser itself, and supply that in the output buffer. 2. Keep providing the input buffer of arbitrary length as a packet to the decoder. The decoder will decompress the stream and process it accordingly. The decoder will keep an internal buffer. It will return AVERROR(EAGAIN) until the full compressed bitstream has been decoded and AVFrames can be generated. In this case the parser will not do much aside from finding the start of the file stream and returning the buffer. I think approach 2 will be better in this case because error handling cannot be done well in the parser. What do you suggest? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/5] avformat/mpeg: Don't use unintialized value
On Sun, Jan 19, 2020 at 02:43:00PM +, Andreas Rheinhardt wrote: > Michael Niedermayer: > > On Tue, Oct 22, 2019 at 03:16:45PM +0200, Andreas Rheinhardt wrote: > >> vobsub_read_packet() didn't check whether an index in array of AVPackets > >> was valid and therefore used uninitialized values. > >> > >> Signed-off-by: Andreas Rheinhardt > >> --- > >> Actually I only wanted to use Valgrind to check for memleaks... > >> > >> libavformat/mpeg.c | 4 > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c > >> index 73ade71d95..474afd06b9 100644 > >> --- a/libavformat/mpeg.c > >> +++ b/libavformat/mpeg.c > >> @@ -930,6 +930,10 @@ static int vobsub_read_packet(AVFormatContext *s, > >> AVPacket *pkt) > >> FFDemuxSubtitlesQueue *tmpq = &vobsub->q[i]; > >> int64_t ts; > >> av_assert0(tmpq->nb_subs); > >> + > >> +if (tmpq->current_sub_idx >= tmpq->nb_subs) > >> +continue; > > > > How can this issue be reproduced ? > > > > thx > > > > [...] > > Read a VobSub subtitle till the end: > ffmpeg -i -c copy -f null - does not reproduce ./ffmpeg -i fate/sub/vobsub.idx -c copy -f null - Output file #0 does not contain any stream code does not execute ./ffmpeg -i fate/sub/vobsub.idx -c copy -map s -f null - the if does not execute iam obviously doing something wrong, can you provide a unambigous testcase? Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Take away the freedom of one citizen and you will be jailed, take away the freedom of all citizens and you will be congratulated by your peers in Parliament. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 07/17] avformat/webmdashenc: Remove write_trailer
On 3/15/2020 8:53 AM, Paul B Mahol wrote: > lgtm Applied. > > On 12/26/19, Andreas Rheinhardt wrote: >> It doesn't do anything: All allocated blocks have already been freed in >> write_header. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavformat/webmdashenc.c | 7 --- >> 1 file changed, 7 deletions(-) >> >> diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c >> index 26b8727304..d2f0e0ec4d 100644 >> --- a/libavformat/webmdashenc.c >> +++ b/libavformat/webmdashenc.c >> @@ -550,12 +550,6 @@ static int >> webm_dash_manifest_write_packet(AVFormatContext *s, AVPacket *pkt) >> return AVERROR_EOF; >> } >> >> -static int webm_dash_manifest_write_trailer(AVFormatContext *s) >> -{ >> -free_adaptation_sets(s); >> -return 0; >> -} >> - >> #define OFFSET(x) offsetof(WebMDashMuxContext, x) >> static const AVOption options[] = { >> { "adaptation_sets", "Adaptation sets. Syntax: id=0,streams=0,1,2 >> id=1,streams=3,4 and so on", OFFSET(adaptation_sets), AV_OPT_TYPE_STRING, { >> 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, >> @@ -585,7 +579,6 @@ AVOutputFormat ff_webm_dash_manifest_muxer = { >> .priv_data_size= sizeof(WebMDashMuxContext), >> .write_header = webm_dash_manifest_write_header, >> .write_packet = webm_dash_manifest_write_packet, >> -.write_trailer = webm_dash_manifest_write_trailer, >> .priv_class= &webm_dash_class, >> }; >> #endif >> -- >> 2.20.1 >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] QP table API
Quoting Lynne (2020-03-10 19:54:45) > Mar 10, 2020, 17:45 by an...@khirnov.net: > > > - do we want per-plane quantizers in each block? The original patch > > didn't have them. Do we want separate AC/DC quantizers? Anything else? > > > > No per plane quantizers in each block. > You dropped the global ac/dc quant for the luma/chroma planes. > I'd like them back because with those you can completely express the > quantizers of AV1. What code is going to export (or otherwise deal with) those? I'd rather not add fields that are completely unused. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 18/18] h264_ps: pass AVCodecContext as void* where possible
Quoting Michael Niedermayer (2020-03-13 23:29:12) > On Fri, Mar 13, 2020 at 11:28:50AM +0100, Anton Khirnov wrote: > > Makes sure it is only used for logging and nothing else. > > --- > > libavcodec/h264_ps.c | 18 +- > > 1 file changed, 9 insertions(+), 9 deletions(-) > > > > diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c > > index 1951bb1161..4ef25aa514 100644 > > --- a/libavcodec/h264_ps.c > > +++ b/libavcodec/h264_ps.c > > @@ -104,14 +104,14 @@ static void remove_sps(H264ParamSets *s, int id) > > av_buffer_unref(&s->sps_list[id]); > > } > > > > -static inline int decode_hrd_parameters(GetBitContext *gb, AVCodecContext > > *avctx, > > +static inline int decode_hrd_parameters(GetBitContext *gb, void *logctx, > > this is a double sided sword > while fields of logctx cannot be used its after this possible to pass > wrong things as logctx Right, but that should be easily noticeable since it will crash on dereferencing the AVClass. I consider the danger of people accessing the AVCodecContext inappropriately to be bigger (since it's done in many places already). But we might want to consider something like typedef AVClass* AVLogger -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 01/18] mpeg4videodec: do not copy a range of fields at once
Quoting Carl Eugen Hoyos (2020-03-14 13:42:33) > Am Sa., 14. März 2020 um 12:58 Uhr schrieb Paul B Mahol : > > > > On 3/14/20, Carl Eugen Hoyos wrote: > > > Am Fr., 13. März 2020 um 11:30 Uhr schrieb Anton Khirnov > > > : > > > > > > Am I really the only one who finds the code more "fragile" after this > > > change? > > > > Elaborate how it is "fragile"? > > Because new fields might be forgotten. Not all fields are necessarily to be copied. Whether to copy any given field is a decision that should be done explicitly when it is added. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Reimbursement request
On date Tuesday 2020-03-10 01:59:17 +0100, Carl Eugen Hoyos wrote: > Hi! > > The Chemnitzer Linuxtage were canceled yesterday because of the Coronavirus. > I request reimbursement of €138,86 for the flight to Germany I had > booked last month. > > Thank you, Carl Eugen Approved on my side, given that Carl already tried to get refund several times and at the time there were no travel restrictions to Germany, so there might be no legal way to get a travel refund from the airline company since the event was cancelled. @Carl in case you manage to get travel refund from the airline company keep me updated, but I feel like you should not jump through the hoops to get it. Attending events should be considered a service for the project, and thus we should cover expenses in cases as this one, to ease and foster participation rather than discouraging developers to attend (which would happen in case they have to spend money which cannot be refunded). Regards, Stefano ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/7] avcodec: add derf dpcm decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 +++ libavcodec/dpcm.c | 32 libavcodec/utils.c | 1 + 6 files changed, 43 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b50a26907f..a88643b7d2 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -265,6 +265,7 @@ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o dcahuff.o \ dcaadpcm.o OBJS-$(CONFIG_DDS_DECODER) += dds.o +OBJS-$(CONFIG_DERF_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o diractab.o \ dirac_arith.o dirac_dwt.o dirac_vlc.o OBJS-$(CONFIG_DFA_DECODER) += dfa.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 379c5f7b81..6046b15164 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -569,6 +569,7 @@ extern AVCodec ff_pcm_vidc_encoder; extern AVCodec ff_pcm_vidc_decoder; /* DPCM codecs */ +extern AVCodec ff_derf_dpcm_decoder; extern AVCodec ff_gremlin_dpcm_decoder; extern AVCodec ff_interplay_dpcm_decoder; extern AVCodec ff_roq_dpcm_encoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9ac97a122b..e9c658fddc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -571,6 +571,7 @@ enum AVCodecID { AV_CODEC_ID_SDX2_DPCM = 0x14800, AV_CODEC_ID_GREMLIN_DPCM, +AV_CODEC_ID_DERF_DPCM, /* audio codecs */ AV_CODEC_ID_MP2 = 0x15000, diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index df3671765a..130e08c1f2 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2415,6 +2415,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("DPCM Gremlin"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_DERF_DPCM, +.type = AVMEDIA_TYPE_AUDIO, +.name = "derf_dpcm", +.long_name = NULL_IF_CONFIG_SMALL("DPCM Xilam DERF"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +}, /* audio codecs */ { diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index 5958081b66..069bf1dcd8 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -49,6 +49,21 @@ typedef struct DPCMContext { const int8_t *sol_table;///< delta table for SOL_DPCM } DPCMContext; +static const int32_t derf_steps[96] = { +0, 1, 2, 3, 4, 5, 6, 7, +8, 9, 10, 11, 12, 13, 14, 16, +17, 19, 21, 23, 25, 28, 31, 34, +37, 41, 45, 50, 55, 60, 66, 73, +80, 88, 97, 107, 118, 130, 143, 157, +173, 190, 209, 230, 253, 279, 307, 337, +371, 408, 449, 494, 544, 598, 658, 724, +796, 876, 963, 1060, 1166, 1282, 1411, 1552, +1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, +3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, +7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, +16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767, +}; + static const int16_t interplay_delta_table[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -225,6 +240,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, else out = buf_size; break; +case AV_CODEC_ID_DERF_DPCM: case AV_CODEC_ID_GREMLIN_DPCM: case AV_CODEC_ID_SDX2_DPCM: out = buf_size; @@ -372,6 +388,21 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data, } } break; + +case AV_CODEC_ID_DERF_DPCM: { +int idx = 0; + +while (output_samples < samples_end) { +uint8_t n = bytestream2_get_byteu(&gb); +int index = FFMIN(n & 0x7f, 95); + +s->sample[idx] += (n & 0x80 ? -1: 1) * derf_steps[index]; +s->sample[idx] = av_clip_int16(s->sample[idx]); +*output_samples++ = s->sample[idx]; +idx ^= stereo; +} +} +break; } *got_frame_ptr = 1; @@ -391,6 +422,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ .capabilities = AV_CODEC_CAP_DR1, \ } +DPCM_DECODER(AV_CODEC_ID_DERF_DPCM, derf_dpcm, "DPCM Xilam DERF"); DPCM_DECODER(AV_CODEC_ID_GREMLIN_DPCM, gremlin_dpcm, "DPCM Gremlin"); DPCM_DECODER(AV_CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay"); DPCM_DECODER(AV_CODEC_ID_ROQ_DPCM, roq_dpcm, "DPCM id RoQ"); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c4dc136d3c..66bfdaf4f8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1478,6 +1478,7 @@ int av_get
[FFmpeg-devel] [PATCH 4/7] avformat: add derf demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/derf.c | 79 3 files changed, 81 insertions(+) create mode 100644 libavformat/derf.c diff --git a/libavformat/Makefile b/libavformat/Makefile index cd3e9163f5..27615cd746 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -151,6 +151,7 @@ OBJS-$(CONFIG_DASH_DEMUXER) += dash.o dashdec.o OBJS-$(CONFIG_DAUD_DEMUXER) += dauddec.o OBJS-$(CONFIG_DAUD_MUXER)+= daudenc.o OBJS-$(CONFIG_DCSTR_DEMUXER) += dcstr.o +OBJS-$(CONFIG_DERF_DEMUXER) += derf.o OBJS-$(CONFIG_DFA_DEMUXER) += dfa.o OBJS-$(CONFIG_DHAV_DEMUXER) += dhav.o OBJS-$(CONFIG_DIRAC_DEMUXER) += diracdec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d275c1017b..af10def88b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -113,6 +113,7 @@ extern AVOutputFormat ff_data_muxer; extern AVInputFormat ff_daud_demuxer; extern AVOutputFormat ff_daud_muxer; extern AVInputFormat ff_dcstr_demuxer; +extern AVInputFormat ff_derf_demuxer; extern AVInputFormat ff_dfa_demuxer; extern AVInputFormat ff_dhav_demuxer; extern AVInputFormat ff_dirac_demuxer; diff --git a/libavformat/derf.c b/libavformat/derf.c new file mode 100644 index 00..58bbf5b791 --- /dev/null +++ b/libavformat/derf.c @@ -0,0 +1,79 @@ +/* + * DERF demuxer + * Copyright (c) 2020 Paul B Mahol + * + * 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 + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" +#include "pcm.h" + +static int derf_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != MKTAG('D','E','R','F')) +return 0; +if (AV_RL32(p->buf+4) != 1 && AV_RL32(p->buf+4) != 2) +return 0; + +return AVPROBE_SCORE_MAX / 3 * 2; +} + +static int derf_read_header(AVFormatContext *s) +{ +unsigned data_size; +AVIOContext *pb = s->pb; +AVCodecParameters *par; +AVStream *st; + +avio_skip(pb, 4); + +st = avformat_new_stream(s, NULL); +if (!st) +return AVERROR(ENOMEM); + +par = st->codecpar; +par->codec_type = AVMEDIA_TYPE_AUDIO; +par->codec_id= AV_CODEC_ID_DERF_DPCM; +par->format = AV_SAMPLE_FMT_S16; +par->channels= avio_rl32(pb); +if (par->channels != 1 && par->channels != 2) +return AVERROR_INVALIDDATA; +if (par->channels == 1) +par->channel_layout = AV_CH_LAYOUT_MONO; +else if (par->channels == 2) +par->channel_layout = AV_CH_LAYOUT_STEREO; +data_size = avio_rl32(pb); +st->duration = data_size / par->channels; +par->sample_rate = 22050; +par->block_align = 1; + +avpriv_set_pts_info(st, 64, 1, par->sample_rate); + +return 0; +} + +AVInputFormat ff_derf_demuxer = { +.name = "derf", +.long_name = NULL_IF_CONFIG_SMALL("Xilam DERF"), +.read_probe = derf_probe, +.read_header= derf_read_header, +.read_packet= ff_pcm_read_packet, +.read_seek = ff_pcm_read_seek, +.extensions = "adp", +}; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/7] avcodec: add ADPCM IMA MTF decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/adpcm.c | 33 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 +++ 5 files changed, 43 insertions(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a3326a45e7..b50a26907f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -843,6 +843,7 @@ OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_IMA_MTF_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_OKI_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER) += adpcmenc.o adpcm_data.o diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 4f5980f7d5..e9abddc43c 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -89,6 +89,11 @@ static const int8_t zork_index_table[8] = { -1, -1, -1, 1, 4, 7, 10, 12, }; +static const int8_t mtf_index_table[16] = { + 8, 6, 4, 2, -1, -1, -1, -1, +-1, -1, -1, -1, 2, 4, 6, 8, +}; + /* end of tables */ typedef struct ADPCMDecodeContext { @@ -304,6 +309,22 @@ static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t return (int16_t)c->predictor; } +static inline int16_t adpcm_ima_mtf_expand_nibble(ADPCMChannelStatus *c, int nibble) +{ +int step_index, step, delta, predictor; + +step = ff_adpcm_step_table[c->step_index]; + +delta = step * (2 * nibble - 15); +predictor = c->predictor + delta; + +step_index = c->step_index + mtf_index_table[(unsigned)nibble]; +c->predictor = av_clip_int16(predictor >> 4); +c->step_index = av_clip(step_index, 0, 88); + +return (int16_t)c->predictor; +} + static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) { int nibble, step_index, predictor, sign, delta, diff, step, shift; @@ -700,6 +721,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, case AV_CODEC_ID_ADPCM_IMA_SSI: case AV_CODEC_ID_ADPCM_IMA_APM: case AV_CODEC_ID_ADPCM_IMA_ALP: +case AV_CODEC_ID_ADPCM_IMA_MTF: nb_samples = buf_size * 2 / ch; break; } @@ -1956,6 +1978,16 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_zork_expand_nibble(&c->status[n % avctx->channels], v); } break; +case AV_CODEC_ID_ADPCM_IMA_MTF: +for (n = nb_samples / 2; n > 0; n--) { +for (channel = 0; channel < avctx->channels; channel++) { +int v = bytestream2_get_byteu(&gb); +*samples++ = adpcm_ima_mtf_expand_nibble(&c->status[channel], v >> 4); +samples[st] = adpcm_ima_mtf_expand_nibble(&c->status[channel], v & 0x0F); +} +samples += avctx->channels; +} +break; default: av_assert0(0); // unsupported codec_id should not happen } @@ -2027,6 +2059,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, sample_fmts_s16, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, sample_fmts_s16, adpcm_ima_iss, "ADPCM IMA Funcom ISS"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_MTF, sample_fmts_s16, adpcm_ima_mtf, "ADPCM IMA Capcom's MT Framework"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_OKI, sample_fmts_s16, adpcm_ima_oki, "ADPCM IMA Dialogic OKI"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, "ADPCM IMA QuickTime"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_RAD, sample_fmts_s16, adpcm_ima_rad, "ADPCM IMA Radical"); diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f4cf180716..379c5f7b81 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -608,6 +608,7 @@ extern AVCodec ff_adpcm_ima_dk4_decoder; extern AVCodec ff_adpcm_ima_ea_eacs_decoder; extern AVCodec ff_adpcm_ima_ea_sead_decoder; extern AVCodec ff_adpcm_ima_iss_decoder; +extern AVCodec ff_adpcm_ima_mtf_decoder; extern AVCodec ff_adpcm_ima_oki_decoder; extern AVCodec ff_adpcm_ima_qt_encoder; extern AVCodec ff_adpcm_ima_qt_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index aca3825fd3..9ac97a122b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -553,6 +553,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_ZORK, AV_CODEC_ID_ADPCM_IMA_APM, AV_CODEC_ID_ADPCM_IMA_ALP, +AV_CODEC_ID_ADPCM_IMA_MTF, /* AMR */
[FFmpeg-devel] [PATCH 5/7] avcodec/allcodecs: move sdx2 to correct place
Signed-off-by: Paul B Mahol --- libavcodec/allcodecs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 6046b15164..71e14c73e3 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -275,7 +275,6 @@ extern AVCodec ff_s302m_decoder; extern AVCodec ff_sanm_decoder; extern AVCodec ff_scpr_decoder; extern AVCodec ff_screenpresso_decoder; -extern AVCodec ff_sdx2_dpcm_decoder; extern AVCodec ff_sgi_encoder; extern AVCodec ff_sgi_decoder; extern AVCodec ff_sgirle_decoder; @@ -574,6 +573,7 @@ extern AVCodec ff_gremlin_dpcm_decoder; extern AVCodec ff_interplay_dpcm_decoder; extern AVCodec ff_roq_dpcm_encoder; extern AVCodec ff_roq_dpcm_decoder; +extern AVCodec ff_sdx2_dpcm_decoder; extern AVCodec ff_sol_dpcm_decoder; extern AVCodec ff_xan_dpcm_decoder; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/7] avformat: add fwse demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/fwse.c | 88 3 files changed, 90 insertions(+) create mode 100644 libavformat/fwse.c diff --git a/libavformat/Makefile b/libavformat/Makefile index f84becd30a..cd3e9163f5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -198,6 +198,7 @@ OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o OBJS-$(CONFIG_FRAMEMD5_MUXER)+= hashenc.o framehash.o OBJS-$(CONFIG_FRM_DEMUXER) += frmdec.o OBJS-$(CONFIG_FSB_DEMUXER) += fsb.o +OBJS-$(CONFIG_FWSE_DEMUXER) += fwse.o OBJS-$(CONFIG_GIF_MUXER) += gif.o OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 08012ea208..d275c1017b 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -156,6 +156,7 @@ extern AVOutputFormat ff_framehash_muxer; extern AVOutputFormat ff_framemd5_muxer; extern AVInputFormat ff_frm_demuxer; extern AVInputFormat ff_fsb_demuxer; +extern AVInputFormat ff_fwse_demuxer; extern AVInputFormat ff_g722_demuxer; extern AVOutputFormat ff_g722_muxer; extern AVInputFormat ff_g723_1_demuxer; diff --git a/libavformat/fwse.c b/libavformat/fwse.c new file mode 100644 index 00..00e2e13b11 --- /dev/null +++ b/libavformat/fwse.c @@ -0,0 +1,88 @@ +/* + * FWSE demuxer + * Copyright (c) 2020 Paul B Mahol + * + * 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 + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" +#include "pcm.h" + +static int fwse_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != MKTAG('F','W','S','E')) +return 0; +if (AV_RL32(p->buf+4) != 2 && AV_RL32(p->buf+4) != 3) +return 0; +if (AV_RL32(p->buf+16) != 1 && AV_RL32(p->buf+16) != 2) +return 0; + +return AVPROBE_SCORE_MAX / 4 * 3; +} + +static int fwse_read_header(AVFormatContext *s) +{ +unsigned start_offset, version; +AVIOContext *pb = s->pb; +AVCodecParameters *par; +AVStream *st; + +avio_skip(pb, 4); +version = avio_rl32(pb); +if (version != 2 && version != 3) +return AVERROR_INVALIDDATA; +avio_skip(pb, 4); +start_offset = avio_rl32(pb); + +st = avformat_new_stream(s, NULL); +if (!st) +return AVERROR(ENOMEM); + +par = st->codecpar; +par->codec_type = AVMEDIA_TYPE_AUDIO; +par->codec_id= AV_CODEC_ID_ADPCM_IMA_MTF; +par->format = AV_SAMPLE_FMT_S16; +par->channels= avio_rl32(pb); +if (par->channels != 1 && par->channels != 2) +return AVERROR_INVALIDDATA; +if (par->channels == 1) +par->channel_layout = AV_CH_LAYOUT_MONO; +else if (par->channels == 2) +par->channel_layout = AV_CH_LAYOUT_STEREO; +st->duration = avio_rl32(pb); +par->sample_rate = avio_rl32(pb); +if (par->sample_rate <= 0 || par->sample_rate > INT_MAX) +return AVERROR_INVALIDDATA; + +par->block_align = 1; +avio_skip(pb, start_offset - avio_tell(pb)); + +avpriv_set_pts_info(st, 64, 1, par->sample_rate); + +return 0; +} + +AVInputFormat ff_fwse_demuxer = { +.name = "fwse", +.long_name = NULL_IF_CONFIG_SMALL("Capcom's MT Framework sound"), +.read_probe = fwse_probe, +.read_header= fwse_read_header, +.read_packet= ff_pcm_read_packet, +.extensions = "fwse", +}; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 11/18] h264dec: do not abort if decoding extradata fails
On 3/13/2020 7:28 AM, Anton Khirnov wrote: > Such errors are not necessarily fatal and decoding might still be > possible, e.g. it happens for MVC streams where we do not handle the > subset SPS thus failing to parse its corresponding PPS. > --- > libavcodec/h264dec.c | 12 > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c > index 9331070f33..79663d8083 100644 > --- a/libavcodec/h264dec.c > +++ b/libavcodec/h264dec.c > @@ -417,10 +417,14 @@ static av_cold int h264_decode_init(AVCodecContext > *avctx) > ret = ff_h264_decode_extradata(avctx->extradata, > avctx->extradata_size, > &h->ps, &h->is_avc, > &h->nal_length_size, > avctx->err_recognition, avctx); > -if (ret < 0) { > -h264_decode_end(avctx); > -return ret; > -} > + if (ret < 0) { > + av_log(avctx, AV_LOG_WARNING, "Error decoding the > extradata\n"); > + if (avctx->err_recognition & AV_EF_EXPLODE) { > + h264_decode_end(avctx); > + return ret; > + } > + ret = 0; > + } > } > } LGTM. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/7] avcodec: add CRI HCA decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/hca_data.h | 128 ++ libavcodec/hcadec.c | 373 6 files changed, 511 insertions(+) create mode 100644 libavcodec/hca_data.h create mode 100644 libavcodec/hcadec.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a88643b7d2..c1c9a44f2b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -367,6 +367,7 @@ OBJS-$(CONFIG_H264_V4L2M2M_DECODER)+= v4l2_m2m_dec.o OBJS-$(CONFIG_H264_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o +OBJS-$(CONFIG_HCA_DECODER) += hcadec.o OBJS-$(CONFIG_HCOM_DECODER)+= hcom.o OBJS-$(CONFIG_HEVC_DECODER)+= hevcdec.o hevc_mvs.o \ hevc_cabac.o hevc_refs.o hevcpred.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 71e14c73e3..b3184af954 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -432,6 +432,7 @@ extern AVCodec ff_g723_1_decoder; extern AVCodec ff_g729_decoder; extern AVCodec ff_gsm_decoder; extern AVCodec ff_gsm_ms_decoder; +extern AVCodec ff_hca_decoder; extern AVCodec ff_hcom_decoder; extern AVCodec ff_iac_decoder; extern AVCodec ff_ilbc_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e9c658fddc..6e03cb5902 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -668,6 +668,7 @@ enum AVCodecID { AV_CODEC_ID_ACELP_KELVIN, AV_CODEC_ID_MPEGH_3D_AUDIO, AV_CODEC_ID_SIREN, +AV_CODEC_ID_HCA, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 130e08c1f2..ece6eadae4 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3079,6 +3079,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Siren"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_HCA, +.type = AVMEDIA_TYPE_AUDIO, +.name = "hca", +.long_name = NULL_IF_CONFIG_SMALL("CRI HCA"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +}, /* subtitle codecs */ { diff --git a/libavcodec/hca_data.h b/libavcodec/hca_data.h new file mode 100644 index 00..a2831381b9 --- /dev/null +++ b/libavcodec/hca_data.h @@ -0,0 +1,128 @@ +/* + * 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_HCA_DATA_H +#define AVCODEC_HCA_DATA_H + +#include + +static const uint8_t max_bits_table[] = { +0, 2, 3, 3, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, +}; + +static const uint8_t quant_spectrum_bits[] = +{ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0, +2,2,2,2,2,2,3,3,0,0,0,0,0,0,0,0, +2,2,3,3,3,3,3,3,0,0,0,0,0,0,0,0, +3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4, +3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4, +3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4, +3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4, +}; + +static const int8_t quant_spectrum_value[] = +{ ++0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0, ++0,+0,+1,-1,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0,+0, ++0,+0,+1,+1,-1,-1,+2,-2,+0,+0,+0,+0,+0,+0,+0,+0, ++0,+0,+1,-1,+2,-2,+3,-3,+0,+0,+0,+0,+0,+0,+0,+0, ++0,+0,+1,+1,-1,-1,+2,+2,-2,-2,+3,+3,-3,-3,+4,-4, ++0,+0,+1,+1,-1,-1,+2,+2,-2,-2,+3,-3,+4,-4,+5,-5, ++0,+0,+1,+1,-1,-1,+2,-2,+3,-3,+4,-4,+5,-5,+6,-6, ++0,+0,+1,-1,+2,-2,+3,-3,+4,-4,+5,-5,+6,-6,+7,-7, +}; + +static const uint8_t scale_table[] = +{ +14, 14, 14, 14, 14, 14, 13, 13, +13, 13, 13, 13, 12, 12, 12, 12, +12, 12, 11, 11, 11, 11, 11, 11, +10, 10, 10, 10, 10, 10, 10, 9, +9, 9, 9, 9, 9, 8, 8, 8, +8, 8, 8, 7, 6, 6, 5, 4, +4, 4, 3, 3, 3, 2, 2, 2, +2, 0, 0, 0, 0, 0, 0, 0, +}; + +static const uint32_t window[128] = +{ + 0x3A3504F0,0x3B0183B8,0x3B70C538,0x3BBB9268,0x3C04A809,0x3C3082
[FFmpeg-devel] [PATCH 7/7] avformat: add hca demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/hca.c| 144 +++ 3 files changed, 146 insertions(+) create mode 100644 libavformat/hca.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 27615cd746..5196f998ed 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -224,6 +224,7 @@ OBJS-$(CONFIG_H263_MUXER)+= rawenc.o OBJS-$(CONFIG_H264_DEMUXER) += h264dec.o rawdec.o OBJS-$(CONFIG_H264_MUXER)+= rawenc.o OBJS-$(CONFIG_HASH_MUXER)+= hashenc.o +OBJS-$(CONFIG_HCA_DEMUXER) += hca.o OBJS-$(CONFIG_HCOM_DEMUXER) += hcom.o pcm.o OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o OBJS-$(CONFIG_HEVC_DEMUXER) += hevcdec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index af10def88b..39d2c352f5 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -182,6 +182,7 @@ extern AVOutputFormat ff_h263_muxer; extern AVInputFormat ff_h264_demuxer; extern AVOutputFormat ff_h264_muxer; extern AVOutputFormat ff_hash_muxer; +extern AVInputFormat ff_hca_demuxer; extern AVInputFormat ff_hcom_demuxer; extern AVOutputFormat ff_hds_muxer; extern AVInputFormat ff_hevc_demuxer; diff --git a/libavformat/hca.c b/libavformat/hca.c new file mode 100644 index 00..000833f55d --- /dev/null +++ b/libavformat/hca.c @@ -0,0 +1,144 @@ +/* + * HCA demuxer + * Copyright (c) 2016 Paul B Mahol + * + * 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 + */ + +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" + +static int hca_probe(const AVProbeData *p) +{ +if (AV_RL32(p->buf) != MKTAG('H', 'C', 'A', 0)) +return 0; + +return AVPROBE_SCORE_MAX / 3; +} + +static int hca_read_header(AVFormatContext *s) +{ +AVCodecParameters *par; +AVIOContext *pb = s->pb; +AVStream *st; +uint32_t chunk; +uint16_t version; +uint32_t block_count; +uint16_t block_size; +int ath_type; + +avio_skip(pb, 4); +version = avio_rb16(pb); +ath_type = version < 0x200 ? 1 : 0; +s->internal->data_offset = avio_rb16(pb); + +if (avio_rl32(pb) != MKTAG('f', 'm', 't', 0)) +return AVERROR_INVALIDDATA; + +st = avformat_new_stream(s, NULL); +if (!st) +return AVERROR(ENOMEM); + +par = st->codecpar; +par->codec_type = AVMEDIA_TYPE_AUDIO; +par->codec_id= AV_CODEC_ID_HCA; +par->codec_tag = 0; +par->channels= avio_r8(pb); +par->sample_rate = avio_rb24(pb); +block_count = avio_rb32(pb); +avio_skip(pb, 4); +if (ff_alloc_extradata(par, 12) < 0) +return AVERROR(ENOMEM); +memset(par->extradata, 0, 12); + +chunk = avio_rl32(pb); +if (chunk == MKTAG('c', 'o', 'm', 'p')) { +block_size = avio_rb16(pb); +avio_read(pb, par->extradata, 8); +avio_skip(pb, 2); +} else if (chunk == MKTAG('d', 'e', 'c', 0)) { +int count1, count2, count3, enable; + +block_size = avio_rb16(pb); +par->extradata[0] = avio_r8(pb); +par->extradata[1] = avio_r8(pb); +count1 = avio_r8(pb); +count2 = avio_r8(pb); +count3 = avio_r8(pb); +enable = avio_r8(pb); +par->extradata[2] = FFMAX(count3 >> 4, 1); +par->extradata[3] = count3 & 0xf; +par->extradata[4] = count1 + 1; +par->extradata[5] = (enable ? count2 : count1) + 1; +par->extradata[6] = par->extradata[4] - par->extradata[5]; +} else { +return AVERROR_INVALIDDATA; +} + +if (block_size < 8) { +return AVERROR_INVALIDDATA; +} +par->block_align = block_size; +st->duration = 1024 * block_count; + +while (avio_tell(pb) < s->internal->data_offset && !avio_feof(pb)) { +chunk = avio_rl32(pb) & 0x7f7f7f7f; + +if (chunk == MKTAG('v', 'b', 'r', 0)) { +avio_skip(pb, 4); +} else if (chunk == MKTAG('a', 't', 'h', 0)) { +ath_type = avio_rb16(pb); +} else if (chunk == MKTAG('l', 'o', 'o', 'p')) { +avio_skip(pb, 12); +} else if (chunk == MKTAG('
[FFmpeg-devel] [FFMPEG-DEVEL][PATCH][RFC] JPEG-XL : Image Format Parser
From Varun Gupta # This line is ignored. From: Varun Gupta Reply-To: Subject: [FFMPEG-DEVEL][PATCH][RFC] JPEG-XL : Image Format Parser In-Reply-To: ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 6/7] avcodec: add CRI HCA decoder
Paul B Mahol: > +#include "libavutil/avassert.h" I don't see an assert. > +frame->nb_samples = 1024; If this codec has a fixed number of samples per frame, you should add it to the list in get_audio_frame_duration() in libavcodec/utils.c. Haven't checked the rest. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] ffmpeg: explicitly handle sub2video subpicture initialization
On Thu, Mar 12, 2020 at 1:42 AM Jan Ekström wrote: > > Each time the sub2video structure is initialized, the sub2video > subpicture is initialized together with the first received heartbeat. > The heartbeat's PTS is utilized as the subpicture start time. > > Additionally, add some documentation on the stages. > --- > fftools/ffmpeg.c| 22 +++--- > fftools/ffmpeg.h| 3 ++- > fftools/ffmpeg_filter.c | 8 +++- > 3 files changed, 24 insertions(+), 9 deletions(-) > This patch was originally posted on Feb 26, 2019. It was then pinged 3rd of March, 2019 (https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190226001220.27888-1-jee...@gmail.com/). I decided then to not push it in due to lack of tests for the exact case which Michael mentioned. Thus while I anyone is free to review this and I would be much obliged for such, now that: - this thing has FATE tests at least making sure that anything which touches the results of those would be noticed (and then either the tests or the code gets adjusted depending on which is correct) - the PGS subtitle sample was uploaded yesterday into the FATE system. I would like to start pushing this set in during tomorrow, barring anyone finding issues with the code until then. Best regards, Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] JPEG-XL : Image Format Parser
From: Varun Gupta --- libavcodec/avcodec.h| 1 + libavcodec/jpeg-xl.h| 180 + libavcodec/jpeg-xl_parser.c | 707 3 files changed, 888 insertions(+) create mode 100644 libavcodec/jpeg-xl.h create mode 100644 libavcodec/jpeg-xl_parser.c diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 5a0fc3405c..ecfa2e0009 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -463,6 +463,7 @@ enum AVCodecID { AV_CODEC_ID_MVDV, AV_CODEC_ID_MVHA, AV_CODEC_ID_CDTOONS, +AV_CODEC_ID_JPEGXL, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/jpeg-xl.h b/libavcodec/jpeg-xl.h new file mode 100644 index 00..7a5b5a351d --- /dev/null +++ b/libavcodec/jpeg-xl.h @@ -0,0 +1,180 @@ +/* + * JPEG-XL format definitions + * Copyright (c) 2020 Varun Gupta + * + * 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 + * JPEG-XL format definitions. + */ + +#ifndef AVCODEC_JPEG_XL_H +#define AVCODEC_JPEG_XL_H + +#include + +#define JPEG_XL_SIG_FF0xff +#define JPEG_XL_SIG_TYPE 0x0a + +typedef enum ColourSpace { +kRGB = 0, +kGrey, +kXYB, +kUnknown, +kXYZ +} ColourSpace; + +typedef enum Primaries { +kSRGB = 1, +kCustomPrimary = 2, +k2100 = 9, +kP3 = 11 +} Primaries; + +typedef enum RenderingIntent { +kPerceptual = 0, +kRelative, +kSaturation, +kAbsolute +} RenderingIntent; + +typedef enum WhitePoint { +kD65 = 1, +kCustom = 2, +kE = 10, +kDCI = 11 +} WhitePoint; + +typedef enum TransferFunction { +k709 = 1, +kUnknownTransferFunction = 2, +kLinear = 8, +kSRGBTransferFunction = 13, +kPQ = 16, +kDCITransferFunction = 17, +kHLG = 18 +} TransferFunction; + +typedef struct Customxy { +unsigned int x; +unsigned int y; +} Customxy; + +typedef struct ExtraChannelInfo { +unsigned int meaning; +float red; +float green; +float blue; +float solidity; +} ExtraChannelInfo; + +typedef enum JPEGXLParseStates { +JPEGXL_SIG = 1, +JPEGXL_SIZE_HEADER, +JPEGXL_IMAGE_METADATA, +JPEGXL_PREVIEW_HEADER, +JPEGXL_ANIMATION_HEADER, +JPEGXL_ICC_CODEC, +JPEGXL_PREVIEW_FRAME, +JPEGXL_FRAMES +} jpegxl_states; + +typedef struct ColourEncoding { +unsigned int all_default; +unsigned int received_icc; +unsigned int opaque_icc; +ColourSpace colour_space; +WhitePoint white_point; +Customxy white; +Primaries primaries; +Customxy red; +Customxy green; +Customxy blue; +unsigned int have_gamma; +unsigned long int gamma; +TransferFunction transfer_function; +RenderingIntent rendering_intent; +} ColourEncoding; + +typedef struct ImageMetadata2 { +unsigned int all_default; +unsigned int have_preview; +unsigned int have_animation; +unsigned int orientation_minus_1; +unsigned int depth_bits; +unsigned int depth_shift; +unsigned int num_extra_channels; +unsigned int extra_channel_bits; +ExtraChannelInfo* extra_channel_info; +} ImageMetadata2; + +typedef struct SizeHeader { +unsigned long int ysize_div8_minus_1; +unsigned long int ysize_minus_1; +unsigned long int xsize_div8_minus_1; +unsigned long int xsize_minus_1; +} SizeHeader; + +typedef struct PreviewHeader { +unsigned long int ysize_div8_minus_1; +unsigned long int ysize_minus_1; +unsigned long int xsize_div8_minus_1; +unsigned long int xsize_minus_1; +} PreviewHeader; + +typedef struct ImageMetadata { +unsigned int all_default; +unsigned int have_icc; +unsigned int bits_per_sample; +unsigned int alpha_bits; +unsigned int target_nits_div50; +ColourEncoding colour_encoding; +ImageMetadata2 m2; +} ImageMetadata; + +typedef struct AnimationHeader { +unsigned int composite_still; +unsigned long int tps_numerator_minus_1; +unsigned int tps_denominator_minus_1; +unsigned long int num_loops; +unsigned int have_timecodes; +} AnimationHeader; + +static int checkIfValueInColourSpace (unsigned int value) { +return value >=0 && value <= 4; +} + +static int checkIfValueInPrimaries
Re: [FFmpeg-devel] [PATCH 1/3] ffmpeg: explicitly handle sub2video subpicture initialization
Jan Ekström (12020-03-15): > This patch was originally posted on Feb 26, 2019. It was then pinged > 3rd of March, 2019 > (https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190226001220.27888-1-jee...@gmail.com/). > I decided then to not push it in due to lack of tests for the exact > case which Michael mentioned. Sorry, I intented to review this series, but things were a little hectic. I'll get on with it soon. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 7/7] avformat: add hca demuxer
Paul B Mahol: > Signed-off-by: Paul B Mahol > --- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/hca.c| 144 +++ > 3 files changed, 146 insertions(+) > create mode 100644 libavformat/hca.c > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 27615cd746..5196f998ed 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -224,6 +224,7 @@ OBJS-$(CONFIG_H263_MUXER)+= rawenc.o > OBJS-$(CONFIG_H264_DEMUXER) += h264dec.o rawdec.o > OBJS-$(CONFIG_H264_MUXER)+= rawenc.o > OBJS-$(CONFIG_HASH_MUXER)+= hashenc.o > +OBJS-$(CONFIG_HCA_DEMUXER) += hca.o > OBJS-$(CONFIG_HCOM_DEMUXER) += hcom.o pcm.o > OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o > OBJS-$(CONFIG_HEVC_DEMUXER) += hevcdec.o rawdec.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index af10def88b..39d2c352f5 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -182,6 +182,7 @@ extern AVOutputFormat ff_h263_muxer; > extern AVInputFormat ff_h264_demuxer; > extern AVOutputFormat ff_h264_muxer; > extern AVOutputFormat ff_hash_muxer; > +extern AVInputFormat ff_hca_demuxer; > extern AVInputFormat ff_hcom_demuxer; > extern AVOutputFormat ff_hds_muxer; > extern AVInputFormat ff_hevc_demuxer; > diff --git a/libavformat/hca.c b/libavformat/hca.c > new file mode 100644 > index 00..000833f55d > --- /dev/null > +++ b/libavformat/hca.c > @@ -0,0 +1,144 @@ > +/* > + * HCA demuxer > + * Copyright (c) 2016 Paul B Mahol 2016? > + * > + * 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 > + */ > + > +#include "libavutil/intreadwrite.h" > +#include "avformat.h" > +#include "internal.h" > + > +static int hca_probe(const AVProbeData *p) > +{ > +if (AV_RL32(p->buf) != MKTAG('H', 'C', 'A', 0)) > +return 0; Based upon read_header below, there are several tests that could be added here, namely MKTAG('f', 'm', 't', 0) at offset 8, chunk at offset 24, block_size at 28. > + > +return AVPROBE_SCORE_MAX / 3; > +} > + > +static int hca_read_header(AVFormatContext *s) > +{ > +AVCodecParameters *par; > +AVIOContext *pb = s->pb; > +AVStream *st; > +uint32_t chunk; > +uint16_t version; > +uint32_t block_count; > +uint16_t block_size; > +int ath_type; What is this used for? Right now it's a write-only variable. Same goes for version if ath_type is removed. > + > +avio_skip(pb, 4); > +version = avio_rb16(pb); > +ath_type = version < 0x200 ? 1 : 0; > +s->internal->data_offset = avio_rb16(pb); > + > +if (avio_rl32(pb) != MKTAG('f', 'm', 't', 0)) > +return AVERROR_INVALIDDATA; > + > +st = avformat_new_stream(s, NULL); > +if (!st) > +return AVERROR(ENOMEM); > + > +par = st->codecpar; > +par->codec_type = AVMEDIA_TYPE_AUDIO; > +par->codec_id= AV_CODEC_ID_HCA; > +par->codec_tag = 0; > +par->channels= avio_r8(pb); > +par->sample_rate = avio_rb24(pb); > +block_count = avio_rb32(pb); > +avio_skip(pb, 4); > +if (ff_alloc_extradata(par, 12) < 0) > +return AVERROR(ENOMEM); Why don't you forward the error? > +memset(par->extradata, 0, 12); > + > +chunk = avio_rl32(pb); > +if (chunk == MKTAG('c', 'o', 'm', 'p')) { > +block_size = avio_rb16(pb); > +avio_read(pb, par->extradata, 8); > +avio_skip(pb, 2); > +} else if (chunk == MKTAG('d', 'e', 'c', 0)) { > +int count1, count2, count3, enable; > + > +block_size = avio_rb16(pb); > +par->extradata[0] = avio_r8(pb); > +par->extradata[1] = avio_r8(pb); > +count1 = avio_r8(pb); > +count2 = avio_r8(pb); > +count3 = avio_r8(pb); > +enable = avio_r8(pb); > +par->extradata[2] = FFMAX(count3 >> 4, 1); > +par->extradata[3] = count3 & 0xf; > +par->extradata[4] = count1 + 1; > +par->extradata[5] = (enable ? count2 : count1) + 1; > +par->extradata[6] = par->extradata[4] - par->extradata[5]; > +} else { > +return AVERROR_INVALI
[FFmpeg-devel] [PATCH 2/4] tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264
This combination skips allocating large padding which can read out of array Fixes: 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 2487b6ca94..c835293c6a 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -202,7 +202,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (flags & 8) ctx->err_recognition |= AV_EF_EXPLODE; } -if (flags & 0x10) +if ((flags & 0x10) && c->id != AV_CODEC_ID_H264) ctx->flags2 |= AV_CODEC_FLAG2_FAST; if (flags & 0x40) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] tools/target_dec_fuzzer: Adjust max_pixels for AV_CODEC_ID_HAP
Fixes: Timeout (170sec -> 6sec) Fixes: 20956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5713643025203200 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index c835293c6a..09b87c276d 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -148,6 +148,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_G2M: maxpixels /= 64;break; case AV_CODEC_ID_GDV: maxpixels /= 512; break; case AV_CODEC_ID_GIF: maxpixels /= 16;break; +case AV_CODEC_ID_HAP: maxpixels /= 128; break; case AV_CODEC_ID_HNM4_VIDEO: maxpixels /= 128; break; case AV_CODEC_ID_IFF_ILBM:maxpixels /= 128; break; case AV_CODEC_ID_INDEO4: maxpixels /= 128; break; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avcodec/ffwavesynth: Fix integer overflow in computation of ddphi
Fixes: signed integer overflow: 1302123111085380114 - -8319005078741256972 cannot be represented in type 'long' Fixes: 20991/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5148554161291264 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ffwavesynth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index b9c63abb8d..998e1a4ad6 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -281,7 +281,7 @@ static int wavesynth_parse_extradata(AVCodecContext *avc) dphi1 = frac64(f1, (int64_t)avc->sample_rate << 16); dphi2 = frac64(f2, (int64_t)avc->sample_rate << 16); in->dphi0 = dphi1; -in->ddphi = (dphi2 - dphi1) / dt; +in->ddphi = (int64_t)(dphi2 - (uint64_t)dphi1) / dt; if (phi & 0x8000) { phi &= ~0x8000; if (phi >= i) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/4] avformat/asfdec_f: Fix overflow check in get_tag()
Fixes: signed integer overflow: 2 * 1210064928 cannot be represented in type 'int' Fixes: 20873/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5761116909338624 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/asfdec_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 57dc3b09b9..3f19747d78 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -321,7 +321,7 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len, int int64_t off = avio_tell(s->pb); #define LEN 22 -if ((unsigned)len >= (UINT_MAX - LEN) / 2) +if ((unsigned)len >= (INT_MAX - LEN) / 2) return; if (!asf->export_xmp && !strncmp(key, "xmp", 3)) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 12/18] h264_sei: use a separate reader for the individual SEI messages
On 3/13/2020 7:28 AM, Anton Khirnov wrote: > This tells the parsing functions the payload size and prevents them from > overreading. > --- > libavcodec/h264_sei.c | 30 +++--- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c > index a565feabe2..a2452141ca 100644 > --- a/libavcodec/h264_sei.c > +++ b/libavcodec/h264_sei.c > @@ -407,9 +407,9 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext > *gb, > int master_ret = 0; > > while (get_bits_left(gb) > 16 && show_bits(gb, 16)) { > +GetBitContext gb_payload; > int type = 0; > unsigned size = 0; > -unsigned next; > int ret = 0; > > do { > @@ -429,35 +429,38 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext > *gb, > type, 8*size, get_bits_left(gb)); > return AVERROR_INVALIDDATA; > } > -next = get_bits_count(gb) + 8 * size; > + > +ret = init_get_bits8(&gb_payload, gb->buffer + get_bits_count(gb) / > 8, size); > +if (ret < 0) > +return ret; > > switch (type) { > case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI > -ret = decode_picture_timing(&h->picture_timing, gb, ps, logctx); > +ret = decode_picture_timing(&h->picture_timing, &gb_payload, ps, > logctx); > break; > case H264_SEI_TYPE_USER_DATA_REGISTERED: > -ret = decode_registered_user_data(h, gb, logctx, size); > +ret = decode_registered_user_data(h, &gb_payload, logctx, size); > break; > case H264_SEI_TYPE_USER_DATA_UNREGISTERED: > -ret = decode_unregistered_user_data(&h->unregistered, gb, > logctx, size); > +ret = decode_unregistered_user_data(&h->unregistered, > &gb_payload, logctx, size); > break; > case H264_SEI_TYPE_RECOVERY_POINT: > -ret = decode_recovery_point(&h->recovery_point, gb, logctx); > +ret = decode_recovery_point(&h->recovery_point, &gb_payload, > logctx); > break; > case H264_SEI_TYPE_BUFFERING_PERIOD: > -ret = decode_buffering_period(&h->buffering_period, gb, ps, > logctx); > +ret = decode_buffering_period(&h->buffering_period, &gb_payload, > ps, logctx); > break; > case H264_SEI_TYPE_FRAME_PACKING: > -ret = decode_frame_packing_arrangement(&h->frame_packing, gb); > +ret = decode_frame_packing_arrangement(&h->frame_packing, > &gb_payload); > break; > case H264_SEI_TYPE_DISPLAY_ORIENTATION: > -ret = decode_display_orientation(&h->display_orientation, gb); > +ret = decode_display_orientation(&h->display_orientation, > &gb_payload); > break; > case H264_SEI_TYPE_GREEN_METADATA: > -ret = decode_green_metadata(&h->green_metadata, gb); > +ret = decode_green_metadata(&h->green_metadata, &gb_payload); > break; > case H264_SEI_TYPE_ALTERNATIVE_TRANSFER: > -ret = decode_alternative_transfer(&h->alternative_transfer, gb); > +ret = decode_alternative_transfer(&h->alternative_transfer, > &gb_payload); > break; > default: > av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); > @@ -467,10 +470,7 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext > *gb, > if (ret < 0) > master_ret = ret; > > -skip_bits_long(gb, next - get_bits_count(gb)); > - > -// FIXME check bits here > -align_get_bits(gb); > +skip_bits_long(gb, 8 * size); > } > > return master_ret; LGTM. May be worth adding an EXPLODE err_recognition check and a warning/error message (depending on if we abort or not) in case get_bits_left < 0. I noticed this is the case for the sample in fate-h264-attachment-631, where a seemingly incorrect SPS in extradata makes the buffering period SEI function read more bits than available. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avdevice: Add support for Solaris/NetBSD audio - sunau
It's expected this will primarily be used on NetBSD as most Solarish platforms seem to prefer either OSS or PulseAudio now. The OSS support in FFmpeg has some problems on NetBSD due to implementation differences between OSSv4 and NetBSD's OSS emulation layer. Using the relatively well documented native API, cross-referencing with illumos documentation to maintain compatibility, we can get much better results with higher quality recording and playback without the problems caused by non-blocking I/O and reading from the device with the incorrect number of channels. Signed-off-by: Nia Alarie --- configure| 4 ++ doc/general.texi | 1 + doc/indevs.texi | 29 doc/outdevs.texi | 11 libavdevice/Makefile | 2 + libavdevice/alldevices.c | 2 + libavdevice/sunau.c | 102 + libavdevice/sunau.h | 48 ++ libavdevice/sunau_dec.c | 138 +++ libavdevice/sunau_enc.c | 114 10 files changed, 451 insertions(+) create mode 100644 libavdevice/sunau.c create mode 100644 libavdevice/sunau.h create mode 100644 libavdevice/sunau_dec.c create mode 100644 libavdevice/sunau_enc.c diff --git a/configure b/configure index 6ceb0c7af4..29a2b38629 100755 --- a/configure +++ b/configure @@ -2129,6 +2129,7 @@ HEADERS_LIST=" sys_resource_h sys_select_h sys_soundcard_h +sys_audioio_h sys_time_h sys_un_h sys_videoio_h @@ -3375,6 +3376,8 @@ opengl_outdev_deps="opengl" opengl_outdev_suggest="sdl2" oss_indev_deps_any="sys_soundcard_h" oss_outdev_deps_any="sys_soundcard_h" +sunau_indev_deps_any="sys_audioio_h" +sunau_outdev_deps_any="sys_audioio_h" pulse_indev_deps="libpulse" pulse_outdev_deps="libpulse" sdl2_outdev_deps="sdl2" @@ -6082,6 +6085,7 @@ check_headers libcrystalhd/libcrystalhd_if.h check_headers malloc.h check_headers net/udplite.h check_headers poll.h +check_headers sys/audioio.h check_headers sys/param.h check_headers sys/resource.h check_headers sys/select.h diff --git a/doc/general.texi b/doc/general.texi index 3684847ac1..2231a1442f 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1382,6 +1382,7 @@ performance on systems without hardware floating point support). @item OSS @tab X @tab X @item PulseAudio@tab X @tab X @item SDL @tab@tab X +@item Sun Audio @tab@tab X @item Video4Linux2 @tab X @tab X @item VfW capture @tab X @tab @item X11 grabbing @tab X @tab diff --git a/doc/indevs.texi b/doc/indevs.texi index 6f5afaf344..c55dcb6329 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -1285,6 +1285,35 @@ Set the number of channels. Default is 2. @end table +@section sunau + +Solaris/NetBSD audio input device. + +The filename to provide to the input device is the device node +representing the Sun input device, and is usually set to +@file{/dev/audio0}. + +For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the +command: +@example +ffmpeg -f sunau -i /dev/audio0 /tmp/oss.wav +@end example + +@subsection Options + +@table @option + +@item buffer_samples +Set the size of the audio buffer in samples. Default is 32. + +@item sample_rate +Set the sample rate in Hz. Default is 48000. + +@item channels +Set the number of channels. Default is 2. + +@end table + @section video4linux2, v4l2 Video4Linux2 input video device. diff --git a/doc/outdevs.texi b/doc/outdevs.texi index 60606eb6e7..5a327adbb0 100644 --- a/doc/outdevs.texi +++ b/doc/outdevs.texi @@ -395,6 +395,17 @@ ffmpeg -i INPUT -c:v rawvideo -pix_fmt yuv420p -window_size qcif -f sdl "SDL out sndio audio output device. +@section sunau + +Solaris/NetBSD audio output device. + +@subsection Options +@table @option + +@item buffer_samples +Set the size of the audio buffer in samples. Default is 32. +@end table + @section v4l2 Video4Linux2 output device. diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 6ea62b914e..51d703d824 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -43,6 +43,8 @@ OBJS-$(CONFIG_PULSE_OUTDEV) += pulse_audio_enc.o \ OBJS-$(CONFIG_SDL2_OUTDEV) += sdl2.o OBJS-$(CONFIG_SNDIO_INDEV) += sndio_dec.o sndio.o OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_enc.o sndio.o +OBJS-$(CONFIG_SUNAU_INDEV) += sunau_dec.o sunau.o +OBJS-$(CONFIG_SUNAU_OUTDEV) += sunau_enc.o sunau.o OBJS-$(CONFIG_V4L2_INDEV)+= v4l2.o v4l2-common.o timefilter.o OBJS-$(CONFIG_V4L2_OUTDEV) += v4l2enc.o v4l2-common.o OBJS-$(CONFIG_VFWCAP_INDEV) += vfwcap.o diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index 8633433254..c2fce8a4f3 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -49,6 +49,8 @@ extern AVOutputFormat ff_pulse_muxe
[FFmpeg-devel] [PATCH] hwcontext_opencl: include header file in HEADERS
This matches the inclusion of the other hwcontext_.h headers. The skipping of the header depending on build flags is already present. Signed-off-by: Daniel Playfair Cal: --- libavutil/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/Makefile b/libavutil/Makefile index a2dae8e89a..8feb029a3a 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -40,6 +40,7 @@ HEADERS = adler32.h \ hwcontext_dxva2.h \ hwcontext_qsv.h \ hwcontext_mediacodec.h\ + hwcontext_opencl.h\ hwcontext_vaapi.h \ hwcontext_videotoolbox.h \ hwcontext_vdpau.h \ -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/v4l2_m2m: fix setting the frame rate
v4l2 set the frame rate through frame intervals, not set frame rate directly. the frame rate and frame intervals are reciprocal. so in libavdevice/v4l2.c we can see the following code: tpf->numerator = framerate_q.den; tpf->denominator = framerate_q.num; Signed-off-by: Ming Qian --- libavcodec/v4l2_m2m_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index c9f1741bfd..5b954f4435 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -40,8 +40,8 @@ static inline void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, un struct v4l2_streamparm parm = { 0 }; parm.type = V4L2_TYPE_IS_MULTIPLANAR(s->output.type) ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT; -parm.parm.output.timeperframe.denominator = den; -parm.parm.output.timeperframe.numerator = num; +parm.parm.output.timeperframe.denominator = num; +parm.parm.output.timeperframe.numerator = den; if (ioctl(s->fd, VIDIOC_S_PARM, &parm) < 0) av_log(s->avctx, AV_LOG_WARNING, "Failed to set timeperframe"); -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/v4l2_buffers: don't prevent enqueue capture buffer to driver
the draining is set when the output port is finished, but it doesn't mean the capture port is finished. especially for decoder, there may be a stream buffer to store several frames. so the decoder still need capture buffer even if the draining is set. Signed-off-by: Ming Qian --- libavcodec/v4l2_buffers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c index dc1b9eaf24..02f23d954b 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -222,7 +222,7 @@ static void v4l2_free_buffer(void *opaque, uint8_t *unused) if (!atomic_load(&s->refcount)) sem_post(&s->refsync); } else { -if (s->draining) { +if (s->draining && V4L2_TYPE_IS_OUTPUT(avbuf->context->type)) { /* no need to queue more buffers to the driver */ avbuf->status = V4L2BUF_AVAILABLE; } -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/v4l2_m2m: handle the v4l2 eos event
when the last frame of capture is dequeueed, driver may send this V4L2_EVENT_EOS event, if this event is received, then we can set the capture port done Signed-off-by: Ming Qian --- libavcodec/v4l2_context.c | 5 + libavcodec/v4l2_m2m_dec.c | 10 ++ libavcodec/v4l2_m2m_enc.c | 22 ++ 3 files changed, 37 insertions(+) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 8110bbb555..c10862aa12 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -171,6 +171,11 @@ static int v4l2_handle_event(V4L2Context *ctx) return 0; } +if (evt.type == V4L2_EVENT_EOS) { +ctx->done = 1; +return 0; +} + if (evt.type != V4L2_EVENT_SOURCE_CHANGE) return 0; diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index d666edffe4..4862a4c0e5 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -123,6 +123,16 @@ static int v4l2_prepare_decoder(V4L2m2mContext *s) } } +memset(&sub, 0, sizeof(sub)); +sub.type = V4L2_EVENT_EOS; +ret = ioctl(s->fd, VIDIOC_SUBSCRIBE_EVENT, &sub); +if (ret < 0) { +av_log(s->avctx, AV_LOG_ERROR, +"the v4l2 driver does not support VIDIOC_SUBSCRIBE_EVENT\n" +"you must provide an eos event to finish encode\n"); +return ret; +} + return 0; } diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index 5b954f4435..3abdd47a4a 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -155,6 +155,24 @@ static int v4l2_check_b_frame_support(V4L2m2mContext *s) return AVERROR_PATCHWELCOME; } +static int v4l2_subscribe_eos_event(V4L2m2mContext *s) +{ +struct v4l2_event_subscription sub; +int ret; + +memset(&sub, 0, sizeof(sub)); +sub.type = V4L2_EVENT_EOS; +ret = ioctl(s->fd, VIDIOC_SUBSCRIBE_EVENT, &sub); +if (ret < 0) { +av_log(s->avctx, AV_LOG_ERROR, +"the v4l2 driver does not support VIDIOC_SUBSCRIBE_EVENT\n" +"you must provide an eos event to finish encode\n"); +return ret; +} + +return 0; +} + static int v4l2_prepare_encoder(V4L2m2mContext *s) { AVCodecContext *avctx = s->avctx; @@ -164,6 +182,10 @@ static int v4l2_prepare_encoder(V4L2m2mContext *s) /** * requirements */ +ret = v4l2_subscribe_eos_event(s); +if (ret) +return ret; + ret = v4l2_check_b_frame_support(s); if (ret) return ret; -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avcodec: add support for Cunning Developments' ADPCM
Signed-off-by: Zane van Iperen --- Changelog | 1 + doc/general.texi| 1 + libavcodec/Makefile | 1 + libavcodec/adpcm.c | 33 + libavcodec/adpcm_data.c | 13 + libavcodec/adpcm_data.h | 2 ++ libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 +++ libavcodec/version.h| 2 +- 10 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index d1572553a5..eeaa643e88 100644 --- a/Changelog +++ b/Changelog @@ -48,6 +48,7 @@ version : - AMQP 0-9-1 protocol (RabbitMQ) - Vulkan support - avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters +- Cunning Developments ADPCM decoder version 4.2: diff --git a/doc/general.texi b/doc/general.texi index 3684847ac1..a417e234ff 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1097,6 +1097,7 @@ following image formats are supported: @item ADPCM G.726@tab X @tab X @item ADPCM IMA AMV @tab @tab X @tab Used in AMV files +@item ADPCM IMA Cunning Developments @tab @tab X @item ADPCM IMA Electronic Arts EACS @tab @tab X @item ADPCM IMA Electronic Arts SEAD @tab @tab X @item ADPCM IMA Funcom @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a3326a45e7..fe8ddbc15e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -837,6 +837,7 @@ OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_APM_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_IMA_CUNNING_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 4f5980f7d5..ea944efb45 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -16,6 +16,7 @@ * Simon & Schuster Interactive ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com) * Ubisoft ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com) * High Voltage Software ALP decoder by Zane van Iperen (z...@zanevaniperen.com) + * Cunning Developments decoder by Zane van Iperen (z...@zanevaniperen.com) * * This file is part of FFmpeg. * @@ -104,6 +105,9 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) unsigned int max_channels = 2; switch(avctx->codec->id) { +case AV_CODEC_ID_ADPCM_IMA_CUNNING: +max_channels = 1; +break; case AV_CODEC_ID_ADPCM_DTK: case AV_CODEC_ID_ADPCM_EA: min_channels = 2; @@ -304,6 +308,26 @@ static inline int16_t adpcm_ima_alp_expand_nibble(ADPCMChannelStatus *c, int8_t return (int16_t)c->predictor; } +static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int8_t nibble) +{ +int step_index; +int predictor; +int step; + +nibble = sign_extend(nibble & 0xF, 4); + +step = ff_adpcm_ima_cunning_step_table[c->step_index]; +step_index = c->step_index + ff_adpcm_ima_cunning_index_table[abs(nibble)]; +step_index = av_clip(step_index, 0, 60); + +predictor = c->predictor + (step * nibble); + +c->predictor = av_clip_int16(predictor); +c->step_index = step_index; + +return (int16_t)c->predictor; +} + static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps) { int nibble, step_index, predictor, sign, delta, diff, step, shift; @@ -692,6 +716,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, /* simple 4-bit adpcm */ case AV_CODEC_ID_ADPCM_CT: case AV_CODEC_ID_ADPCM_IMA_APC: +case AV_CODEC_ID_ADPCM_IMA_CUNNING: case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: case AV_CODEC_ID_ADPCM_IMA_OKI: case AV_CODEC_ID_ADPCM_IMA_WS: @@ -1282,6 +1307,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, samples += avctx->channels; } break; +case AV_CODEC_ID_ADPCM_IMA_CUNNING: +while (bytestream2_get_bytes_left(&gb) > 0) { +int v = bytestream2_get_byteu(&gb); +*samples++ = adpcm_ima_cunning_expand_nibble(&c->status[0], v & 0x0F); +*samples++ = adpcm_ima_cunning_expand_nibble(&c->status[0], v >> 4); +} +break; case AV_CODEC_ID_ADPCM_IMA_OKI: while (bytestream2_get_bytes_left(&gb) > 0) { int v = bytestream2_get_byteu(&gb); @@ -2021,6 +2053,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16p, adpcm_ea_xas, ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16, adpcm_ima_apc,
[FFmpeg-devel] [PATCH 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks
Signed-off-by: Zane van Iperen --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/pp_bnk.c | 213 +++ libavformat/version.h| 2 +- 5 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 libavformat/pp_bnk.c diff --git a/Changelog b/Changelog index eeaa643e88..d84621f7d8 100644 --- a/Changelog +++ b/Changelog @@ -49,6 +49,7 @@ version : - Vulkan support - avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters - Cunning Developments ADPCM decoder +- Pro Pinball Series Soundbank demuxer version 4.2: diff --git a/libavformat/Makefile b/libavformat/Makefile index f84becd30a..1a9655ff40 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -425,6 +425,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o OBJS-$(CONFIG_PJS_DEMUXER) += pjsdec.o subtitles.o OBJS-$(CONFIG_PMP_DEMUXER) += pmpdec.o +OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o OBJS-$(CONFIG_PVA_DEMUXER) += pva.o OBJS-$(CONFIG_PVF_DEMUXER) += pvfdec.o pcm.o OBJS-$(CONFIG_QCP_DEMUXER) += qcp.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 08012ea208..04aab18687 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -338,6 +338,7 @@ extern AVInputFormat ff_pcm_u8_demuxer; extern AVOutputFormat ff_pcm_u8_muxer; extern AVInputFormat ff_pjs_demuxer; extern AVInputFormat ff_pmp_demuxer; +extern AVInputFormat ff_pp_bnk_demuxer; extern AVOutputFormat ff_psp_muxer; extern AVInputFormat ff_pva_demuxer; extern AVInputFormat ff_pvf_demuxer; diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c new file mode 100644 index 00..ba490f3084 --- /dev/null +++ b/libavformat/pp_bnk.c @@ -0,0 +1,213 @@ +/* + * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer. + * + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.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 + */ +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/avassert.h" + +#define FJBNK_MAX_READ_SIZE 4096 +#define FJBNK_FILE_HEADER_SIZE 20 +#define FJBNK_ENTRY_SIZE20 + +typedef struct PPBnkHeader { +uint32_tbank_id; +uint32_tsample_rate; +uint32_talways1; +uint32_tentry_count; +uint32_tunknown;/*< Possibly flags. 2 == music, 0 == sfx? */ +} PPBnkHeader; + +typedef struct PPBnkEntry { +uint32_tid; /*< Entry ID. Usually entry[i].id == entry[i-1].id + 1, but not always */ +uint32_tsize; /*< Size of the data in bytes. */ +uint32_tsample_rate;/*< Sample rate. */ +uint32_talways1_1; /*< Unknown, always seems to be 1. */ +uint32_talways1_2; /*< Unknown, always seems to be 1. */ +} PPBnkEntry; + +typedef struct PPBnkCtxEntry { +int64_t data_offset; +uint32_tdata_size; +} PPBnkCtxEntry; + +typedef struct PPBnkCtx { +int entry_count; +PPBnkCtxEntry *entries; +uint32_ti; +uint32_tbytes_read; +} PPBnkCtx; + +static void pp_bnk_parse_header(PPBnkHeader *hdr, const uint8_t *buf) +{ +hdr->bank_id= AV_RL32(buf + 0); +hdr->sample_rate= AV_RL32(buf + 4); +hdr->always1= AV_RL32(buf + 8); +hdr->entry_count= AV_RL32(buf + 12); +hdr->unknown= AV_RL32(buf + 16); +} + +static void pp_bnk_parse_entry(PPBnkEntry *e, const uint8_t *buf) +{ +e->id = AV_RL32(buf + 0); +e->size = AV_RL32(buf + 4); +e->sample_rate = AV_RL32(buf + 8); +e->always1_1= AV_RL32(buf + 12); +e->always1_2= AV_RL32(buf + 16); +} + +static int pp_bnk_read_header(AVFormatContext *s) +{ +int ret; +AVStream *st; +AVCodecParameters *par; +PPBnkCtx *ctx = s->priv_data; +uint8_t buf[FFMAX(FJBNK_FILE_HEADER_SIZE, FJBNK_ENTRY_SIZE)]; +PPBnkHeader hdr; + +if ((ret = avio_read(s->pb, buf, FJBNK_FILE_HEADER_SIZE)) < 0) +
[FFmpeg-devel] [PATCH 0/2] Pro Pinball Series Soundbank demuxer + decoder.
Adds support for the soundbank files used by the Pro Pinball series of games. Please ping for review. Zane van Iperen (2): avcodec: add support for Cunning Developments' ADPCM avformat: add demuxer for Pro Pinball Series' Soundbanks Changelog| 2 + doc/general.texi | 1 + libavcodec/Makefile | 1 + libavcodec/adpcm.c | 33 ++ libavcodec/adpcm_data.c | 13 +++ libavcodec/adpcm_data.h | 2 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/version.h | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/pp_bnk.c | 213 +++ libavformat/version.h| 2 +- 14 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 libavformat/pp_bnk.c -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".