[FFmpeg-devel] [PATCH 5/5] mlpenc: clean up
Signed-off-by: Jai Luthra --- On Fri, Jan 24, 2020 at 02:25:20PM +0100, Paul B Mahol wrote: > This is not cleanup, this adds new line of code without proper explanation. My bad, I was testing something and forgot to remove that line. Fixed now. libavcodec/mlpenc.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 0e7a9b7640..347a43248c 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -94,8 +94,8 @@ typedef struct BestOffset { int16_t max; } BestOffset; -#define HUFF_OFFSET_MIN-16384 -#define HUFF_OFFSET_MAX 16383 +#define HUFF_OFFSET_MIN(-16384) +#define HUFF_OFFSET_MAX( 16383) /** Number of possible codebooks (counting "no codebooks") */ #define NUM_CODEBOOKS 4 @@ -808,7 +808,7 @@ static void write_major_sync(MLPEncodeContext *ctx, uint8_t *buf, int buf_size) static void write_restart_header(MLPEncodeContext *ctx, PutBitContext *pb) { RestartHeader *rh = ctx->cur_restart_header; -int32_t lossless_check = xor_32_to_8(rh->lossless_check_data); +uint8_t lossless_check = xor_32_to_8(rh->lossless_check_data); unsigned int start_count = put_bits_count(pb); PutBitContext tmpb; uint8_t checksum; @@ -1017,12 +1017,10 @@ static void write_block_data(MLPEncodeContext *ctx, PutBitContext *pb) codebook_index [ch] = cp->codebook - 1; sign_huff_offset[ch] = cp->huff_offset; -sign_shift = lsb_bits[ch] - 1; +sign_shift = lsb_bits[ch] + (cp->codebook ? 2 - cp->codebook : -1); -if (cp->codebook > 0) { +if (cp->codebook > 0) sign_huff_offset[ch] -= 7 << lsb_bits[ch]; -sign_shift += 3 - cp->codebook; -} /* Unsign if needed. */ if (sign_shift >= 0) @@ -1032,7 +1030,6 @@ static void write_block_data(MLPEncodeContext *ctx, PutBitContext *pb) for (i = 0; i < dp->blocksize; i++) { for (ch = rh->min_channel; ch <= rh->max_channel; ch++) { int32_t sample = *sample_buffer++ >> dp->quant_step_size[ch]; - sample -= sign_huff_offset[ch]; if (codebook_index[ch] >= 0) { @@ -1252,7 +1249,7 @@ static void input_data_internal(MLPEncodeContext *ctx, const uint8_t *samples, uint32_t abs_sample; int32_t sample; -sample = is24 ? *samples_32++ >> 8 : *samples_16++ << 8; +sample = is24 ? *samples_32++ >> 8 : *samples_16++ * 256U; /* TODO Find out if number_sbits can be used for negative values. */ abs_sample = FFABS(sample); @@ -1795,7 +1792,7 @@ static void determine_bits(MLPEncodeContext *ctx) #define SAMPLE_MAX(bitdepth) ((1 << (bitdepth - 1)) - 1) #define SAMPLE_MIN(bitdepth) (~SAMPLE_MAX(bitdepth)) -#define MSB_MASK(bits) (-1u << bits) +#define MSB_MASK(bits) (-(1u << (bits))) /** Applies the filter to the current samples, and saves the residual back * into the samples buffer. If the filter is too bad and overflows the @@ -1899,8 +1896,8 @@ static void generate_2_noise_channels(MLPEncodeContext *ctx) for (i = 0; i < ctx->number_of_samples; i++) { uint16_t seed_shr7 = seed >> 7; -*sample_buffer++ = ((int8_t)(seed >> 15)) << rh->noise_shift; -*sample_buffer++ = ((int8_t) seed_shr7) << rh->noise_shift; +*sample_buffer++ = ((int8_t)(seed >> 15)) * (1 << rh->noise_shift); +*sample_buffer++ = ((int8_t) seed_shr7) * (1 << rh->noise_shift); seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5); @@ -2275,7 +2272,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (restart_frame) { set_major_params(ctx); if (ctx->min_restart_interval != ctx->max_restart_interval) -process_major_frame(ctx); +process_major_frame(ctx); } if (ctx->min_restart_interval == ctx->max_restart_interval) -- 2.25.0 ___ 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] lavc/dvdsubenc: accept palette from options
On Sat, Jan 25, 2020 at 01:24 AM Carl Eugen Hoyos wrote: >> static const AVOption options[] = { >> +{"palette", "set the global palette", OFFSET(palette_str), >> AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SE }, > > What happens if invalid values are passed as palette? The string is parsed until it hits something invalid (i.e. anything except for space, comma, or hex number) and all remaining palette colors are set to black. The same happens if you pass fewer than 16 values. This is what dvdsubdec does too. In fact, this entire patch is basically copy+paste from there. ___ 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] lavc/dvdsubenc: accept palette from options
Michael Kuron (12020-01-25): > In fact, this entire patch is > basically copy+paste from there. Then please fix the patch so that the same code is used, not a copy of it. Otherwise, enhancements or fixes would have to be duplicated too. 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".
[FFmpeg-devel] [PATCH] lavc/dvdsubenc: accept palette from options
Previously, the default palette would always be used. Now, we can accept a custom palette, just like dvdsubdec does. Signed-off-by: Michael Kuron --- doc/decoders.texi | 2 +- doc/encoders.texi | 8 libavcodec/Makefile| 1 + libavcodec/dvdsub.c| 35 +++ libavcodec/dvdsub.h| 29 + libavcodec/dvdsubdec.c | 23 +++ libavcodec/dvdsubenc.c | 9 - 7 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 libavcodec/dvdsub.c create mode 100644 libavcodec/dvdsub.h diff --git a/doc/decoders.texi b/doc/decoders.texi index 0582b018b0..83515ae363 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -280,7 +280,7 @@ palette is stored in the IFO file, and therefore not available when reading from dumped VOB files. The format for this option is a string containing 16 24-bits hexadecimal -numbers (without 0x prefix) separated by comas, for example @code{0d00ee, +numbers (without 0x prefix) separated by commas, for example @code{0d00ee, ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, 7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. diff --git a/doc/encoders.texi b/doc/encoders.texi index eefd124751..a04f9f1b62 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3116,6 +3116,14 @@ and they can also be used in Matroska files. @subsection Options @table @option +@item palette +Specify the global palette used by the bitmaps. + +The format for this option is a string containing 16 24-bits hexadecimal +numbers (without 0x prefix) separated by commas, for example @code{0d00ee, +ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, +7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. + @item even_rows_fix When set to 1, enable a work-around that makes the number of pixel rows even in all subtitles. This fixes a problem with some players that diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3cd73fbcc6..07a05bd10b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -283,6 +283,7 @@ OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o +OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsub.o OBJS-$(CONFIG_DVAUDIO_DECODER) += dvaudiodec.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_ENCODER) += dvenc.o dv.o dvdata.o diff --git a/libavcodec/dvdsub.c b/libavcodec/dvdsub.c new file mode 100644 index 00..687af43590 --- /dev/null +++ b/libavcodec/dvdsub.c @@ -0,0 +1,35 @@ +/* + * DVD subtitle decoding/encoding + * Copyright (c) 2005 Fabrice Bellard + * + * 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 "dvdsub.h" +#include "libavutil/avstring.h" +#include + +void ff_dvdsub_parse_palette(uint32_t *palette, char *p) +{ +int i; + +for (i=0; i<16; i++) { +palette[i] = strtoul(p, &p, 16); +while (*p == ',' || av_isspace(*p)) +p++; +} +} diff --git a/libavcodec/dvdsub.h b/libavcodec/dvdsub.h new file mode 100644 index 00..908589709a --- /dev/null +++ b/libavcodec/dvdsub.h @@ -0,0 +1,29 @@ +/* + * DVD subtitle decoding/encoding + * Copyright (c) 2005 Fabrice Bellard + * + * 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_DVDSUB_H +#define AVCODEC_DVDSUB_H + +#include + +void ff_dvdsub_parse_palette(
Re: [FFmpeg-devel] [PATCH] lavc/dvdsubenc: accept palette from options
Michael Kuron (12020-01-25): > Previously, the default palette would always be used. > Now, we can accept a custom palette, just like dvdsubdec does. > > Signed-off-by: Michael Kuron > --- > doc/decoders.texi | 2 +- > doc/encoders.texi | 8 > libavcodec/Makefile| 1 + > libavcodec/dvdsub.c| 35 +++ > libavcodec/dvdsub.h| 29 + > libavcodec/dvdsubdec.c | 23 +++ > libavcodec/dvdsubenc.c | 9 - > 7 files changed, 89 insertions(+), 18 deletions(-) > create mode 100644 libavcodec/dvdsub.c > create mode 100644 libavcodec/dvdsub.h Thanks for the update. In principle, we like to have two patches in this kind of cases: first update the existing code to make a separate function; second add the new feature. > > diff --git a/doc/decoders.texi b/doc/decoders.texi > index 0582b018b0..83515ae363 100644 > --- a/doc/decoders.texi > +++ b/doc/decoders.texi > @@ -280,7 +280,7 @@ palette is stored in the IFO file, and therefore not > available when reading > from dumped VOB files. > > The format for this option is a string containing 16 24-bits hexadecimal > -numbers (without 0x prefix) separated by comas, for example @code{0d00ee, > +numbers (without 0x prefix) separated by commas, for example @code{0d00ee, This is unrelated, but I personally think we can live with that. > ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, > 7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index eefd124751..a04f9f1b62 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -3116,6 +3116,14 @@ and they can also be used in Matroska files. > @subsection Options > > @table @option > +@item palette > +Specify the global palette used by the bitmaps. > + > +The format for this option is a string containing 16 24-bits hexadecimal > +numbers (without 0x prefix) separated by commas, for example @code{0d00ee, > +ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, > +7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. > + > @item even_rows_fix > When set to 1, enable a work-around that makes the number of pixel rows > even in all subtitles. This fixes a problem with some players that > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 3cd73fbcc6..07a05bd10b 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -283,6 +283,7 @@ OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o > OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o > OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o > OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o > +OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsub.o I suspect you need the same line for CONFIG_DVDSUB_DECODER. > OBJS-$(CONFIG_DVAUDIO_DECODER) += dvaudiodec.o > OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o > OBJS-$(CONFIG_DVVIDEO_ENCODER) += dvenc.o dv.o dvdata.o > diff --git a/libavcodec/dvdsub.c b/libavcodec/dvdsub.c > new file mode 100644 > index 00..687af43590 > --- /dev/null > +++ b/libavcodec/dvdsub.c > @@ -0,0 +1,35 @@ > +/* > + * DVD subtitle decoding/encoding > + * Copyright (c) 2005 Fabrice Bellard > + * > + * 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 "dvdsub.h" > +#include "libavutil/avstring.h" > +#include > + > +void ff_dvdsub_parse_palette(uint32_t *palette, char *p) const char * > +{ > +int i; > + > +for (i=0; i<16; i++) { Some spaces after comparisons. (This is not your code, but since it is moving now, we can clean the cosmetics at the same time.) > +palette[i] = strtoul(p, &p, 16); > +while (*p == ',' || av_isspace(*p)) > +p++; > +} > +} > diff --git a/libavcodec/dvdsub.h b/libavcodec/dvdsub.h > new file mode 100644 > index 00..908589709a > --- /dev/null > +++ b/libavcodec/dvdsub.h I think you can put this in internal.h. > @@ -0,0 +1,29 @@ > +/* > + * DVD subtitle decoding/encoding > + * Copyright (c) 2005 Fabrice Bellard > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify i
[FFmpeg-devel] [PATCH] lavc/dvdsubenc: accept palette from options
Previously, the default palette would always be used. Now, we can accept a custom palette, just like dvdsubdec does. Signed-off-by: Michael Kuron --- doc/decoders.texi | 2 +- doc/encoders.texi | 8 libavcodec/Makefile| 2 ++ libavcodec/dvdsub.c| 33 + libavcodec/dvdsubdec.c | 22 ++ libavcodec/dvdsubenc.c | 8 +++- libavcodec/internal.h | 2 ++ 7 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 libavcodec/dvdsub.c diff --git a/doc/decoders.texi b/doc/decoders.texi index 0582b018b0..83515ae363 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -280,7 +280,7 @@ palette is stored in the IFO file, and therefore not available when reading from dumped VOB files. The format for this option is a string containing 16 24-bits hexadecimal -numbers (without 0x prefix) separated by comas, for example @code{0d00ee, +numbers (without 0x prefix) separated by commas, for example @code{0d00ee, ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, 7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. diff --git a/doc/encoders.texi b/doc/encoders.texi index eefd124751..a04f9f1b62 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3116,6 +3116,14 @@ and they can also be used in Matroska files. @subsection Options @table @option +@item palette +Specify the global palette used by the bitmaps. + +The format for this option is a string containing 16 24-bits hexadecimal +numbers (without 0x prefix) separated by commas, for example @code{0d00ee, +ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1, +7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}. + @item even_rows_fix When set to 1, enable a work-around that makes the number of pixel rows even in all subtitles. This fixes a problem with some players that diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3cd73fbcc6..71ee8caeb3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -282,7 +282,9 @@ OBJS-$(CONFIG_DST_DECODER) += dstdec.o dsd.o OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o +OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsub.o OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o +OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsub.o OBJS-$(CONFIG_DVAUDIO_DECODER) += dvaudiodec.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_ENCODER) += dvenc.o dv.o dvdata.o diff --git a/libavcodec/dvdsub.c b/libavcodec/dvdsub.c new file mode 100644 index 00..a03ff27754 --- /dev/null +++ b/libavcodec/dvdsub.c @@ -0,0 +1,33 @@ +/* + * DVD subtitle decoding/encoding + * Copyright (c) 2005 Fabrice Bellard + * + * 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 "internal.h" +#include "libavutil/avstring.h" +#include + +void ff_dvdsub_parse_palette(uint32_t *palette, const char *p) +{ +for (int i = 0; i < 16; i++) { +palette[i] = strtoul(p, &p, 16); +while (*p == ',' || av_isspace(*p)) +p++; +} +} diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 741ea9fd1e..bf49788e1b 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -27,7 +27,6 @@ #include "libavutil/colorspace.h" #include "libavutil/opt.h" #include "libavutil/imgutils.h" -#include "libavutil/avstring.h" #include "libavutil/bswap.h" typedef struct DVDSubContext @@ -626,18 +625,6 @@ static int dvdsub_decode(AVCodecContext *avctx, return buf_size; } -static void parse_palette(DVDSubContext *ctx, char *p) -{ -int i; - -ctx->has_palette = 1; -for(i=0;i<16;i++) { -ctx->palette[i] = strtoul(p, &p, 16); -while(*p == ',' || av_isspace(*p)) -p++; -} -} - static int parse_ifo_palette(DVDSubContext *ctx, char *p) { FILE *ifo; @@ -719,7 +706,8 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx) break; if (strncmp("palette:", data, 8) == 0) { -parse_palette(ctx, data + 8); +ctx->has_palette = 1; +ff_dvdsub_parse_palette(ctx->palette, data + 8);
Re: [FFmpeg-devel] [PATCH] avformat/movenc: allow ISMV timescale to be user-set
On 25-01-2020 11:04 am, Gyan wrote: On 23-01-2020 05:56 pm, Gyan Doshi wrote: As per the PIFF standard, the timescale of 1000 is recommended but not mandatory, so don't override the user-set value. A warning is shown for non-recommended values. --- libavformat/movenc.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index fb44ee2c71..5bf434c325 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6389,6 +6389,8 @@ static int mov_init(AVFormatContext *s) } if (mov->video_track_timescale) { track->timescale = mov->video_track_timescale; + if (mov->mode == MODE_ISM && mov->video_track_timescale != 1000) + av_log(s, AV_LOG_WARNING, "Warning: some tools, like mp4split, assume a timescale of 1000 for ISMV.\n"); } else { track->timescale = st->time_base.den; while(track->timescale < 1) @@ -6486,10 +6488,14 @@ static int mov_init(AVFormatContext *s) } if (!track->height) track->height = st->codecpar->height; - /* The ism specific timescale isn't mandatory, but is assumed by - * some tools, such as mp4split. */ - if (mov->mode == MODE_ISM) - track->timescale = 1000; + /* The Protected Interoperable File Format (PIFF) standard, used by ISMV recommends but + doesn't mandate a track timescale of 10,000,000. The muxer allows a custom timescale + for video tracks, so if user-set, it isn't overwritten */ + if (mov->mode == MODE_ISM && + (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || + (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !mov->video_track_timescale))) { + track->timescale = 1000; + } avpriv_set_pts_info(st, 64, 1, track->timescale); Will push tonight. Pushed as 75d1d9eb349462bf72ed38004c06a53e0b79173c Gyan ___ 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] avutil/thread: fix strict_pthread_cond_timedwait
On Wed, 22 Jan 2020, Marton Balint wrote: Timeout error was assumed to be fatal which it is not. Applied. Regards, Marton Signed-off-by: Marton Balint --- libavutil/thread.h | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/libavutil/thread.h b/libavutil/thread.h index 65b97ef303..be5c4b1340 100644 --- a/libavutil/thread.h +++ b/libavutil/thread.h @@ -33,16 +33,19 @@ #include "log.h" +#define ASSERT_PTHREAD_ABORT(func, ret) do {\ +char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \ +av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \ + " failed with error: %s\n", \ + av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, \ +AVERROR(ret))); \ +abort();\ +} while (0) + #define ASSERT_PTHREAD_NORET(func, ...) do {\ int ret = func(__VA_ARGS__);\ -if (ret) { \ -char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \ -av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \ - " failed with error: %s\n", \ - av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, \ -AVERROR(ret))); \ -abort();\ -} \ +if (ret)\ +ASSERT_PTHREAD_ABORT(func, ret);\ } while (0) #define ASSERT_PTHREAD(func, ...) do { \ @@ -112,7 +115,10 @@ static inline int strict_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t static inline int strict_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { -ASSERT_PTHREAD(pthread_cond_timedwait, cond, mutex, abstime); +int ret = pthread_cond_timedwait(cond, mutex, abstime); +if (ret && ret != ETIMEDOUT) +ASSERT_PTHREAD_ABORT(pthread_cond_timedwait, ret); +return ret; } static inline int strict_pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) -- 2.16.4 ___ 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] [PATCH 1/4] avformat/udp: add newline after warning
On Thu, 16 Jan 2020, myp...@gmail.com wrote: On Thu, Jan 16, 2020 at 8:20 AM Marton Balint wrote: Signed-off-by: Marton Balint --- libavformat/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index f4ec148a2f..e42a069b24 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -861,7 +861,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) } else { av_log(h, AV_LOG_DEBUG, "end receive buffer size reported is %d\n", tmp); if(tmp < s->buffer_size) -av_log(h, AV_LOG_WARNING, "attempted to set receive buffer to size %d but it only ended up set as %d", s->buffer_size, tmp); +av_log(h, AV_LOG_WARNING, "attempted to set receive buffer to size %d but it only ended up set as %d\n", s->buffer_size, tmp); } /* make the socket non-blocking */ -- 2.16.4 LGTM Thanks applied patches 1-3. Will send a new patch for patch 4. Regards, Marton ___ 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] tools/target_dec_fuzzer: Sort threshold list alphabetically
This also removes the comments as they are hard to maintain together with sorted lists Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 54 ++- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index a3d784a019..79d8dab1b9 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -136,36 +136,32 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { maxpixels = maxpixels_per_frame * maxiteration; maxsamples = maxsamples_per_frame * maxiteration; switch (c->id) { -// Allows a small input to generate gigantic output -case AV_CODEC_ID_BINKVIDEO: maxpixels /= 32; break; -case AV_CODEC_ID_CFHD: maxpixels /= 128; break; -case AV_CODEC_ID_DIRAC: maxpixels /= 8192; break; -case AV_CODEC_ID_DST: maxsamples /= 8192; break; -case AV_CODEC_ID_DXV: maxpixels /= 32; break; +case AV_CODEC_ID_BINKVIDEO: maxpixels /= 32;break; +case AV_CODEC_ID_CFHD:maxpixels /= 128; break; +case AV_CODEC_ID_DIRAC: maxpixels /= 8192; break; +case AV_CODEC_ID_DST: maxsamples /= 8192; break; +case AV_CODEC_ID_DXV: maxpixels /= 32;break; case AV_CODEC_ID_FFWAVESYNTH: maxsamples /= 16384; break; -case AV_CODEC_ID_MSRLE: maxpixels /= 16; break; -case AV_CODEC_ID_QTRLE: maxpixels /= 16; break; -case AV_CODEC_ID_RASC: maxpixels /= 16; break; -case AV_CODEC_ID_SANM: maxpixels /= 16; break; -case AV_CODEC_ID_G2M: maxpixels /= 64; break; -case AV_CODEC_ID_GIF: maxpixels /= 16; break; -// Performs slow frame rescaling in C -case AV_CODEC_ID_GDV: maxpixels /= 512; break; -// Postprocessing in C -case AV_CODEC_ID_HNM4_VIDEO:maxpixels /= 128; break; -// Cliping in C, generally slow even with small input -case AV_CODEC_ID_INDEO4:maxpixels /= 128; break; -case AV_CODEC_ID_LSCR:maxpixels /= 16; break; -case AV_CODEC_ID_MOTIONPIXELS:maxpixels /= 256; break; -case AV_CODEC_ID_MSS2:maxpixels /= 16384; break; -case AV_CODEC_ID_MSZH:maxpixels /= 128; break; -case AV_CODEC_ID_SCPR:maxpixels /= 32;break; -case AV_CODEC_ID_SMACKVIDEO: maxpixels /= 64; break; -case AV_CODEC_ID_SNOW:maxpixels /= 128; break; -case AV_CODEC_ID_TGV: maxpixels /= 32;break; -case AV_CODEC_ID_TRUEMOTION2: maxpixels /= 1024; break; -case AV_CODEC_ID_VP7: maxpixels /= 256; break; -case AV_CODEC_ID_VP9: maxpixels /= 4096; break; +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_HNM4_VIDEO: maxpixels /= 128; break; +case AV_CODEC_ID_INDEO4: maxpixels /= 128; break; +case AV_CODEC_ID_LSCR:maxpixels /= 16;break; +case AV_CODEC_ID_MOTIONPIXELS:maxpixels /= 256; break; +case AV_CODEC_ID_MSRLE: maxpixels /= 16;break; +case AV_CODEC_ID_MSS2:maxpixels /= 16384; break; +case AV_CODEC_ID_MSZH:maxpixels /= 128; break; +case AV_CODEC_ID_QTRLE: maxpixels /= 16;break; +case AV_CODEC_ID_RASC:maxpixels /= 16;break; +case AV_CODEC_ID_SANM:maxpixels /= 16;break; +case AV_CODEC_ID_SCPR:maxpixels /= 32;break; +case AV_CODEC_ID_SMACKVIDEO: maxpixels /= 64;break; +case AV_CODEC_ID_SNOW:maxpixels /= 128; break; +case AV_CODEC_ID_TGV: maxpixels /= 32;break; +case AV_CODEC_ID_TRUEMOTION2: maxpixels /= 1024; break; +case AV_CODEC_ID_VP7: maxpixels /= 256; break; +case AV_CODEC_ID_VP9: maxpixels /= 4096; break; } -- 2.25.0 ___ 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] tools/target_dec_fuzzer: Add threshold for ALS
Fixes: Timeout (253sec -> 16sec) Fixes: 18668/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-6227155369590784 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 79d8dab1b9..ba72e5a65e 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -149,6 +149,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_INDEO4: maxpixels /= 128; break; case AV_CODEC_ID_LSCR:maxpixels /= 16;break; case AV_CODEC_ID_MOTIONPIXELS:maxpixels /= 256; break; +case AV_CODEC_ID_MP4ALS: maxsamples /= 65536; break; case AV_CODEC_ID_MSRLE: maxpixels /= 16;break; case AV_CODEC_ID_MSS2:maxpixels /= 16384; break; case AV_CODEC_ID_MSZH:maxpixels /= 128; break; -- 2.25.0 ___ 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 v5 1/2] avcodec: add decoder for argonaut games' adpcm codec
Adds support for the ADPCM variant used by some Argonaut Games' games, such as 'Croc! Legend of the Gobbos', and 'Croc 2'. Signed-off-by: Zane van Iperen --- Changelog | 1 + doc/general.texi| 1 + libavcodec/Makefile | 1 + libavcodec/adpcm.c | 67 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/version.h| 4 +-- 8 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 2ccd2645fc..c029d73c72 100644 --- a/Changelog +++ b/Changelog @@ -30,6 +30,7 @@ version : - MPEG-H 3D Audio support in mp4 - thistogram filter - freezeframes filter +- Argonaut Games ADPCM decoder version 4.2: diff --git a/doc/general.texi b/doc/general.texi index 4bd4b4f6b9..85db50462c 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1079,6 +1079,7 @@ following image formats are supported: @item ACELP.KELVIN @tab @tab X @item ADPCM 4X Movie @tab @tab X @item APDCM Yamaha AICA @tab @tab X +@item ADPCM Argonaut Games @tab @tab X @item ADPCM CDROM XA @tab @tab X @item ADPCM Creative Technology @tab @tab X @tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2 diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c1f35b40d8..a2fbb910a0 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -817,6 +817,7 @@ OBJS-$(CONFIG_ADPCM_ADX_ENCODER) += adxenc.o adx.o OBJS-$(CONFIG_ADPCM_AFC_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_AGM_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_AICA_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_ARGO_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_CT_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_DTK_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_EA_DECODER) += adpcm.o adpcm_data.o diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index ed16438e33..dad3da28d3 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -12,6 +12,7 @@ * EA ADPCM XAS decoder by Peter Ross (pr...@xvid.org) * MAXIS EA ADPCM decoder by Robert Marston (rmars...@gmail.com) * THP ADPCM decoder by Marco Gerards (mgera...@xs4all.nl) + * Argonaut Games ADPCM decoder by Zane van Iperen (z...@zanevaniperen.com) * * This file is part of FFmpeg. * @@ -148,6 +149,10 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) if (avctx->extradata && avctx->extradata_size >= 2) c->vqa_version = AV_RL16(avctx->extradata); break; +case AV_CODEC_ID_ADPCM_ARGO: +if (avctx->bits_per_coded_sample != 4) +return AVERROR_INVALIDDATA; +break; default: break; } @@ -169,6 +174,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) case AV_CODEC_ID_ADPCM_DTK: case AV_CODEC_ID_ADPCM_PSX: case AV_CODEC_ID_ADPCM_MTAF: +case AV_CODEC_ID_ADPCM_ARGO: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break; case AV_CODEC_ID_ADPCM_IMA_WS: @@ -546,6 +552,11 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_ } } +static inline int16_t adpcm_argo_expand_nibble(int nibble, int shift, int16_t prev0, int16_t prev1) +{ +return ((8 * prev0) - (4 * prev1) + (nibble * (1 << shift))) >> 2; +} + /** * Get the number of samples that will be decoded from the packet. * In one case, this is actually the maximum number of samples possible to @@ -584,6 +595,11 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, return 0; nb_samples = 64; break; +case AV_CODEC_ID_ADPCM_ARGO: +if (buf_size < 17 * ch) +return 0; +nb_samples = 32; +break; /* simple 4-bit adpcm */ case AV_CODEC_ID_ADPCM_CT: case AV_CODEC_ID_ADPCM_IMA_APC: @@ -1770,7 +1786,57 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } } break; +case AV_CODEC_ID_ADPCM_ARGO: +/* + * The format of each block: + * uint8_t left_control; + * uint4_t left_samples[nb_samples]; + * and if stereo + * uint8_t right_control; + * uint4_t right_samples[nb_samples]; + * + * Format of the control byte: + * MSB [DRRR] LSB + * S = (Shift Amount - 2) + * D = Decoder flag. + * R = Reserved + * + * Each block relies on the previous two samples of each channel. + * They should be 0 initially. + */ +for (channel = 0; channel < avctx->channels; channel++) { +int control, shift, sample, nibble; + +samples = samples_p[channel]; +cs = c->status + channel; +/* Get the control byte and dec
[FFmpeg-devel] [PATCH v5 2/2] avformat: add demuxer for argonaut games' ASF format
Adds support for the custom ASF container used by some Argonaut Games' games, such as 'Croc! Legend of the Gobbos', and 'Croc 2'. Can also handle the sample files in: https://samples.ffmpeg.org/game-formats/brender/part2.zip Signed-off-by: Zane van Iperen --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/argo_asf.c | 249 +++ libavformat/version.h| 4 +- 5 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 libavformat/argo_asf.c diff --git a/Changelog b/Changelog index c029d73c72..65ef01c77d 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ version : - thistogram filter - freezeframes filter - Argonaut Games ADPCM decoder +- Argonaut Games ASF demuxer version 4.2: diff --git a/libavformat/Makefile b/libavformat/Makefile index 52f29b1a6d..ba6ea8c4a6 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -99,6 +99,7 @@ OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o OBJS-$(CONFIG_APTX_HD_DEMUXER) += aptxdec.o rawdec.o OBJS-$(CONFIG_APTX_HD_MUXER) += rawenc.o OBJS-$(CONFIG_AQTITLE_DEMUXER) += aqtitledec.o subtitles.o +OBJS-$(CONFIG_ARGO_ASF_DEMUXER) += argo_asf.o OBJS-$(CONFIG_ASF_DEMUXER) += asfdec_f.o asf.o asfcrypt.o \ avlanguage.o OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \ diff --git a/libavformat/allformats.c b/libavformat/allformats.c index ff9bdb906f..fe74a32e47 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -60,6 +60,7 @@ extern AVOutputFormat ff_aptx_muxer; extern AVInputFormat ff_aptx_hd_demuxer; extern AVOutputFormat ff_aptx_hd_muxer; extern AVInputFormat ff_aqtitle_demuxer; +extern AVInputFormat ff_argo_asf_demuxer; extern AVInputFormat ff_asf_demuxer; extern AVOutputFormat ff_asf_muxer; extern AVInputFormat ff_asf_o_demuxer; diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c new file mode 100644 index 00..3339425244 --- /dev/null +++ b/libavformat/argo_asf.c @@ -0,0 +1,249 @@ +/* + * Argonaut Games ASF 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 ASF_TAG MKTAG('A', 'S', 'F', '\0') +#define ASF_FILE_HEADER_SIZE24 +#define ASF_CHUNK_HEADER_SIZE 20 + +typedef struct ArgoASFFileHeader { +uint32_tmagic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ +uint16_tversion_major; /*< File Major Version. */ +uint16_tversion_minor; /*< File Minor Version. */ +uint32_tnum_chunks; /*< No. chunks in the file. */ +uint32_tchunk_offset; /*< Offset to the first chunk from the start of the file. */ +int8_t name[8];/*< Name. */ +} ArgoASFFileHeader; + +typedef struct ArgoASFChunkHeader { +uint32_tnum_blocks; /*< No. blocks in the chunk. */ +uint32_tnum_samples;/*< No. samples per channel in a block. */ +uint32_tunk1; /*< Unknown */ +uint16_tsample_rate;/*< Sample rate. */ +uint16_tunk2; /*< Unknown. */ +uint32_tflags; /*< Stream flags. */ +} ArgoASFChunkHeader; + +enum { +ASF_CF_BITS_PER_SAMPLE = (1 << 0), /*< 16-bit if set, 8 otherwise. */ +ASF_CF_STEREO = (1 << 1), /*< Stereo if set, mono otherwise. */ +ASF_CF_ALWAYS1_1= (1 << 2), /*< Unknown, always seems to be set. */ +ASF_CF_ALWAYS1_2= (1 << 3), /*< Unknown, always seems to be set. */ + +ASF_CF_ALWAYS1 = ASF_CF_ALWAYS1_1 | ASF_CF_ALWAYS1_2, +ASF_CF_ALWAYS0 = ~(ASF_CF_BITS_PER_SAMPLE | ASF_CF_STEREO | ASF_CF_ALWAYS1) +}; + +typedef struct ArgoASFDemuxContext { +ArgoASFFileHeader fhdr; +ArgoASFChunkHeader ckhdr; +uint32_tblocks_read; +} ArgoASFDemuxContext; + +static void argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf) +{ +hdr->magic = AV_RL32(buf + 0); +hdr->version_major = A
[FFmpeg-devel] [PATCH v5 0/2] Argonaut Games ASF and ADPCM decoding support
Hi all, This patchset adds support for the ASF container and ADPCM variant used by some Argonaut Software games such as 'Croc! Legend of the Gobbos' and 'Croc 2'. It has been tested against: - ANISOUND/*.ASFfrom Croc 1 - music/*.asf from Croc 2 - FIGHT/SOUND/*.ASF from https://samples.ffmpeg.org/game-formats/brender/part2.zip v5: - greatly simplified the decoder - use s16p instead of s16 - use bytestream2_* and friends - integrate more tightly with the existing adpcm code v4: [6] - simplify probe function - fix a compile warning v3: [2][3][4][5] - ignore file extension in probe - reduce maximum possible probing score to 61 - returned the stolen empty line - move the decoder into adpcm.c with the existing ones - formatting fixes v2: [1] - change to use AV_RLxx() instead of relying on #pragma pack() - use MKTAG() - formatting fixes [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/255986.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256005.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256014.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256021.html [5]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256024.html [6]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-January/256129.html Zane Zane van Iperen (2): avcodec: add decoder for argonaut games' adpcm codec avformat: add demuxer for argonaut games' ASF format Changelog| 2 + doc/general.texi | 1 + libavcodec/Makefile | 1 + libavcodec/adpcm.c | 67 +++ libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/version.h | 4 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/argo_asf.c | 249 +++ libavformat/version.h| 4 +- 12 files changed, 335 insertions(+), 4 deletions(-) create mode 100644 libavformat/argo_asf.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".
[FFmpeg-devel] [PATCH 29/30] avformat/matroskaenc: Check BlockAdditional size before use
Don't read a 64bit number before having checked that the data is at least 8 bytes long. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 444032b431..8fc672a31f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2100,9 +2100,13 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { -additional_id = AV_RB64(side_data); -side_data += 8; -side_data_size -= 8; +if (side_data_size < 8) { +side_data_size = 0; +} else { +additional_id = AV_RB64(side_data); +side_data += 8; +side_data_size -= 8; +} } if ((side_data_size && additional_id == 1) || discard_padding) { -- 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] [PATCH 30/30] avformat/matroskaenc: Improve BlockAdditions
8ffcc826 added support for muxing BlockAdditions with BlockAddID equal to one. The restriction to BlockAddID == 1 probably resulted from a limitation to what was needed; yet over time this led to three occurences of "(side_data_size && additional_id == 1)". This commit changes this by setting side_data_size to 0 if additional_id != 1. It also stops hardcoding 1 for the value of BlockAddID to write; but it still upholds the requirement that it is 1. See below. Despite BlockAddID actually having a default value of 1, it is still written, because until very recently (namely dbc50f8a) our demuxer used a wrong default value of 0. Furthermore, use put_ebml_binary() to write the BlockAdditional element. (The Matroska specifications have evolved and now the BlockAddID 1 is reserved for the codec (as described in the codec's codec mapping), BlockMore elements with BlockAddID > 1 are now of a more codec-independent nature and require a BlockAdditionalMapping in the track's TrackEntry. Given that this muxer does not support writing said BlockAdditionalMapping yet (actually, none have been defined yet), we have to uphold the requirement that BlockAddID == 1.) Signed-off-by: Andreas Rheinhardt --- Btw: When writing BlockAdditions in Matroska mode, one also has to write the MaxBlockAdditionID in the corresponding TrackEntry. Yet we don't (and we don't have the information to do that reliably when writing the header). libavformat/matroskaenc.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 8fc672a31f..de3fff2043 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2046,7 +2046,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, uint8_t *data = NULL, *side_data = NULL; int offset = 0, size = pkt->size, side_data_size = 0; int64_t ts = track->write_dts ? pkt->dts : pkt->pts; -uint64_t additional_id = 0; +uint64_t additional_id; int64_t discard_padding = 0; uint8_t track_number = (mkv->is_dash ? mkv->dash_track_number : (pkt->stream_index + 1)); ebml_master block_group, block_additions, block_more; @@ -2100,16 +2100,16 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size); if (side_data) { -if (side_data_size < 8) { +// Only the Codec-specific BlockMore (id == 1) is currently supported. +if (side_data_size < 8 || (additional_id = AV_RB64(side_data)) != 1) { side_data_size = 0; } else { -additional_id = AV_RB64(side_data); side_data += 8; side_data_size -= 8; } } -if ((side_data_size && additional_id == 1) || discard_padding) { +if (side_data_size || discard_padding) { block_group = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, 0); blockid = MATROSKA_ID_BLOCK; } @@ -2133,17 +2133,18 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb, put_ebml_sint(pb, MATROSKA_ID_DISCARDPADDING, discard_padding); } -if (side_data_size && additional_id == 1) { +if (side_data_size) { block_additions = start_ebml_master(pb, MATROSKA_ID_BLOCKADDITIONS, 0); block_more = start_ebml_master(pb, MATROSKA_ID_BLOCKMORE, 0); -put_ebml_uint(pb, MATROSKA_ID_BLOCKADDID, 1); -put_ebml_id(pb, MATROSKA_ID_BLOCKADDITIONAL); -put_ebml_num(pb, side_data_size, 0); -avio_write(pb, side_data, side_data_size); +/* Until dbc50f8a our demuxer used a wrong default value + * of BlockAddID, so we write it unconditionally. */ +put_ebml_uint (pb, MATROSKA_ID_BLOCKADDID, additional_id); +put_ebml_binary(pb, MATROSKA_ID_BLOCKADDITIONAL, +side_data, side_data_size); end_ebml_master(pb, block_more); end_ebml_master(pb, block_additions); } -if ((side_data_size && additional_id == 1) || discard_padding) { +if (side_data_size || discard_padding) { end_ebml_master(pb, block_group); } } -- 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] [PATCH 1/2] avformat/dvenc: Replace write_trailer by deinit function
The old write_trailer only freed memory, so it is better to make a dedicated deinit function out of it. Given that this function will also be called when writing the header fails, one can also remove code that frees already allocated fifos when allocating another one fails. Signed-off-by: Andreas Rheinhardt --- There is something strange going on in this muxer: eafa8e85929 increased several limits for the number of audio streams to four, yet the initial check in dv_init_mux still makes sure that at most two audio streams exist. Has updating this (and probably also the comment for n_ast which still says that there are up to two stereo tracks allowed) simply been forgotten? libavformat/dvenc.c | 21 ++--- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index a7d1413eb2..b89ad4d1c8 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -364,10 +364,6 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) for (i=0; i < c->n_ast; i++) { if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc_array(100, MAX_AUDIO_FRAME_SIZE))) { -while (i > 0) { -i--; -av_fifo_freep(&c->audio_data[i]); -} goto bail_out; } } @@ -378,13 +374,6 @@ bail_out: return NULL; } -static void dv_delete_mux(DVMuxContext *c) -{ -int i; -for (i=0; i < c->n_ast; i++) -av_fifo_freep(&c->audio_data[i]); -} - static int dv_write_header(AVFormatContext *s) { AVRational rate; @@ -432,10 +421,12 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt) * Currently we simply drop the last frame. I don't know whether this * is the best strategy of all */ -static int dv_write_trailer(struct AVFormatContext *s) +static void dv_deinit(AVFormatContext *s) { -dv_delete_mux(s->priv_data); -return 0; +DVMuxContext *c = s->priv_data; + +for (int i = 0; i < c->n_ast; i++) +av_fifo_freep(&c->audio_data[i]); } AVOutputFormat ff_dv_muxer = { @@ -447,5 +438,5 @@ AVOutputFormat ff_dv_muxer = { .video_codec = AV_CODEC_ID_DVVIDEO, .write_header = dv_write_header, .write_packet = dv_write_packet, -.write_trailer = dv_write_trailer, +.deinit= dv_deinit, }; -- 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] [PATCH 2/2] avformat/dvenc: Don't zero unnecessarily
The muxing context has already been zeroed when it was allocated, hence it is unnecessary to do it again. Signed-off-by: Andreas Rheinhardt --- libavformat/dvenc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index b89ad4d1c8..c71e532771 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -305,9 +305,6 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) if (s->nb_streams > 5) return NULL; -c->n_ast = 0; -c->ast[0] = c->ast[1] = c->ast[2] = c->ast[3] = NULL; - /* We have to sort out where audio and where video stream is */ for (i=0; inb_streams; i++) { switch (s->streams[i]->codecpar->codec_type) { -- 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".