[FFmpeg-devel] [PATCH] avcodec/truemotion2: Avoid duplicating array, fix memleak

2020-08-29 Thread Andreas Rheinhardt
TrueMotion 2.0 uses Huffmann trees. To parse them, the decoder allocates
arrays for the codes, their lengths and their value; afterwards a VLC
table is initialized using these values. If everything up to this point
succeeds, a new buffer of the same size as the already allocated arrays
for the values is allocated and upon success the values are copied into
the new array; all the old arrays are then freed. Yet if allocating the
new array fails, the old arrays get freed, but the VLC table doesn't.

This leak is fixed by not allocating a new array at all; instead the old
array is simply reused, ensuring that nothing can fail after the
creation of the VLC table.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/truemotion2.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index d90a8baff3..a1d4eea340 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -200,8 +200,6 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes 
*code)
 
 /* convert codes to vlc_table */
 if (res >= 0) {
-int i;
-
 res = init_vlc(&code->vlc, huff.max_bits, huff.max_num,
huff.lens, sizeof(int), sizeof(int),
huff.bits, sizeof(uint32_t), sizeof(uint32_t), 0);
@@ -210,13 +208,8 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes 
*code)
 else {
 code->bits = huff.max_bits;
 code->length = huff.max_num;
-code->recode = av_malloc_array(code->length, sizeof(int));
-if (!code->recode) {
-res = AVERROR(ENOMEM);
-goto out;
-}
-for (i = 0; i < code->length; i++)
-code->recode[i] = huff.nums[i];
+code->recode = huff.nums;
+huff.nums = NULL;
 }
 }
 
-- 
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/4][VERSION 2] avcodec: add ADPCM IMA MOFLEX decoder

2020-08-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 26 ++
 libavcodec/allcodecs.c  |  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/codec_id.h   |  1 +
 libavcodec/utils.c  |  2 ++
 6 files changed, 38 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ca2e8a2530..191c4e0a7c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -866,6 +866,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_MOFLEX_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
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 1366932352..71e37efde7 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -210,6 +210,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
 case AV_CODEC_ID_ADPCM_PSX:
 case AV_CODEC_ID_ADPCM_MTAF:
 case AV_CODEC_ID_ADPCM_ARGO:
+case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
 avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
 break;
 case AV_CODEC_ID_ADPCM_IMA_WS:
@@ -774,6 +775,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 case AV_CODEC_ID_ADPCM_4XM:
 case AV_CODEC_ID_ADPCM_AGM:
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
+case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;  break;
 case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8;   break;
 case AV_CODEC_ID_ADPCM_IMA_SMJPEG:  header_size = 4 * ch;  break;
@@ -1298,6 +1300,29 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
+for (channel = 0; channel < avctx->channels; channel++) {
+cs = &c->status[channel];
+cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
+cs->predictor  = sign_extend(bytestream2_get_le16u(&gb), 16);
+if (cs->step_index > 88u){
+av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
+   channel, cs->step_index);
+return AVERROR_INVALIDDATA;
+}
+}
+
+for (int subframe = 0; subframe < nb_samples / 256; subframe++) {
+for (channel = 0; channel < avctx->channels; channel++) {
+samples = samples_p[channel] + 256 * subframe;
+for (n = 0; n < 256; n += 2) {
+int v = bytestream2_get_byteu(&gb);
+*samples++ = adpcm_ima_expand_nibble(&c->status[channel], 
v & 0x0F, 3);
+*samples++ = adpcm_ima_expand_nibble(&c->status[channel], 
v >> 4  , 3);
+}
+}
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
 for (channel = 0; channel < avctx->channels; channel++) {
 cs = &c->status[channel];
@@ -2107,6 +2132,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_MOFLEX,  sample_fmts_s16p, 
adpcm_ima_moflex,  "ADPCM IMA MobiClip MOFLEX");
 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");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 729d2fd9ad..084a289c9e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -619,6 +619,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_moflex_decoder;
 extern AVCodec ff_adpcm_ima_mtf_decoder;
 extern AVCodec ff_adpcm_ima_oki_decoder;
 extern AVCodec ff_adpcm_ima_qt_encoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..b5bc5c3c71 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2376,6 +2376,13 @@ static const AVCodecD

[FFmpeg-devel] [PATCH 4/4][VERSION 2] avformat: add moflex demuxer

2020-08-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/moflex.c | 358 +++
 3 files changed, 360 insertions(+)
 create mode 100644 libavformat/moflex.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..1e0ac317e5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -319,6 +319,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o 
replaygain.o
 OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
 movenchint.o mov_chan.o rtp.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..28331facb9 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -249,6 +249,7 @@ extern AVInputFormat  ff_mlv_demuxer;
 extern AVInputFormat  ff_mm_demuxer;
 extern AVInputFormat  ff_mmf_demuxer;
 extern AVOutputFormat ff_mmf_muxer;
+extern AVInputFormat  ff_moflex_demuxer;
 extern AVInputFormat  ff_mov_demuxer;
 extern AVOutputFormat ff_mov_muxer;
 extern AVOutputFormat ff_mp2_muxer;
diff --git a/libavformat/moflex.c b/libavformat/moflex.c
new file mode 100644
index 00..3761837895
--- /dev/null
+++ b/libavformat/moflex.c
@@ -0,0 +1,358 @@
+/*
+ * MOFLEX 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 "libavcodec/bytestream.h"
+
+#include "avformat.h"
+#include "internal.h"
+
+typedef struct BitReader {
+unsigned last;
+unsigned pos;
+} BitReader;
+
+typedef struct MOFLEXDemuxContext {
+unsigned size;
+int64_t pos;
+int64_t ts;
+int flags;
+int in_block;
+
+BitReader br;
+} MOFLEXDemuxContext;
+
+static int pop(BitReader *br, AVIOContext *pb)
+{
+if (avio_feof(pb))
+return AVERROR_EOF;
+
+if ((br->pos & 7) == 0)
+br->last = (unsigned)avio_r8(pb) << 24U;
+else
+br->last <<= 1;
+
+br->pos++;
+return !!(br->last & 0x8000);
+}
+
+static int pop_int(BitReader *br, AVIOContext *pb, int n)
+{
+int value = 0;
+
+for (int i = 0; i < n; i++) {
+int ret = pop(br, pb);
+
+if (ret < 0)
+return ret;
+value = 2 * value + ret;
+}
+
+return value;
+}
+
+static int pop_length(BitReader *br, AVIOContext *pb)
+{
+int ret, n = 1;
+
+while ((ret = pop(br, pb)) == 0)
+n++;
+
+if (ret < 0)
+return ret;
+return n;
+}
+
+static int read_var_byte(AVFormatContext *s, unsigned *out)
+{
+AVIOContext *pb = s->pb;
+unsigned value = 0, data;
+
+data = avio_r8(pb);
+if (!(data & 0x80)) {
+*out = data;
+return 0;
+}
+
+value = (data & 0x7F) << 7;
+data = avio_r8(pb);
+if (!(data & 0x80)) {
+value |= data;
+*out = value;
+return 0;
+}
+
+value = ((data & 0x7F) | value) << 7;
+data = avio_r8(pb);
+if (!(data & 0x80)) {
+value |= data;
+*out = value;
+return 0;
+}
+
+value = (((data & 0x7F) | value) << 7) | avio_r8(pb);
+*out = value;
+
+return 0;
+}
+
+static int moflex_probe(const AVProbeData *p)
+{
+GetByteContext gb;
+int score = 0;
+
+bytestream2_init(&gb, p->buf, p->buf_size);
+
+if (bytestream2_get_be16(&gb) != 0x4C32)
+return 0;
+score += 10;
+
+bytestream2_skip(&gb, 10);
+if (bytestream2_get_be16(&gb) == 0)
+return 0;
+score += 5;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int type = bytestream2_get_byte(&gb);
+int size = bytestream2_get_byte(&gb);
+
+if (type == 0) {
+score += 5 * (size == 0);
+break;
+}
+if ((type == 1 && size == 12) ||
+(type == 2 && size ==  6) ||
+(type == 3 && size == 13) ||
+(type == 4 && size ==  2))
+score += 20;
+bytestream2_skip(&gb, size)

[FFmpeg-devel] [PATCH 2/4][VERSION 2] avcodec: add FastAudio decoder

2020-08-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/codec_desc.c |   7 ++
 libavcodec/codec_id.h   |   1 +
 libavcodec/fastaudio.c  | 200 
 libavcodec/utils.c  |   2 +
 6 files changed, 212 insertions(+)
 create mode 100644 libavcodec/fastaudio.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 191c4e0a7c..6f75f26c84 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -317,6 +317,7 @@ OBJS-$(CONFIG_ESCAPE124_DECODER)   += escape124.o
 OBJS-$(CONFIG_ESCAPE130_DECODER)   += escape130.o
 OBJS-$(CONFIG_EVRC_DECODER)+= evrcdec.o acelp_vectors.o lsp.o
 OBJS-$(CONFIG_EXR_DECODER) += exr.o exrdsp.o
+OBJS-$(CONFIG_FASTAUDIO_DECODER)   += fastaudio.o
 OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1.o
 OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
 OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 084a289c9e..3920eb37ce 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -430,6 +430,7 @@ extern AVCodec ff_dst_decoder;
 extern AVCodec ff_eac3_encoder;
 extern AVCodec ff_eac3_decoder;
 extern AVCodec ff_evrc_decoder;
+extern AVCodec ff_fastaudio_decoder;
 extern AVCodec ff_ffwavesynth_decoder;
 extern AVCodec ff_flac_encoder;
 extern AVCodec ff_flac_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index b5bc5c3c71..9a3eaf7d98 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3130,6 +3130,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("CRI HCA"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_FASTAUDIO,
+.type  = AVMEDIA_TYPE_AUDIO,
+.name  = "fastaudio",
+.long_name = NULL_IF_CONFIG_SMALL("MobiClip FastAudio"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+},
 
 /* subtitle codecs */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index aac1174f28..aac7f63eb6 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -504,6 +504,7 @@ enum AVCodecID {
 AV_CODEC_ID_MPEGH_3D_AUDIO,
 AV_CODEC_ID_SIREN,
 AV_CODEC_ID_HCA,
+AV_CODEC_ID_FASTAUDIO,
 
 /* subtitle codecs */
 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000,  ///< A dummy ID pointing at 
the start of subtitle codecs.
diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c
new file mode 100644
index 00..bd9e28ec0f
--- /dev/null
+++ b/libavcodec/fastaudio.c
@@ -0,0 +1,200 @@
+/*
+ * MOFLEX Fast Audio decoder
+ * 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 "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+#include "mathops.h"
+
+typedef struct ChannelItems {
+float f[8];
+float last;
+} ChannelItems;
+
+typedef struct FastAudioContext {
+float table[8][64];
+
+ChannelItems *ch;
+} FastAudioContext;
+
+static av_cold int fastaudio_init(AVCodecContext *avctx)
+{
+FastAudioContext *s = avctx->priv_data;
+
+avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+
+for (int i = 0; i < 8; i++)
+s->table[0][i] = (i - 159.5f) / 160.f;
+for (int i = 0; i < 11; i++)
+s->table[0][i + 8] = (i - 37.5f) / 40.f;
+for (int i = 0; i < 27; i++)
+s->table[0][i + 8 + 11] = (i - 13.f) / 20.f;
+for (int i = 0; i < 11; i++)
+s->table[0][i + 8 + 11 + 27] = (i + 27.5f) / 40.f;
+for (int i = 0; i < 7; i++)
+s->table[0][i + 8 + 11 + 27 + 11] = (i + 152.5f) / 160.f;
+
+memcpy(s->table[1], s->table[0], sizeof(s->table[0]));
+
+for (int i = 0; i < 7; i++)
+s->table[2][i] = (i - 33.5f) / 40.f;
+for (int i = 0; i < 25; i++)
+s->table[2][i + 7] = (i - 13.f) / 20.f;
+
+for (int i = 0; i < 32; i++)
+s->table[3][i] = -s->table[2][31 - i];
+
+for (int i = 0; i < 16; i++)
+s->table[4][i] = i * 0.22f / 3.f - 0.6f;
+
+for (int i = 0; i < 16; i++)
+s->table[5][i] = i * 0.20f / 3.f - 0.3f;
+
+for (int

[FFmpeg-devel] [PATCH 3/4][VERSION 2] avcodec: add MobiClip video decoder

2020-08-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/codec_desc.c |7 +
 libavcodec/codec_id.h   |1 +
 libavcodec/mobiclip.c   | 1371 +++
 5 files changed, 1381 insertions(+)
 create mode 100644 libavcodec/mobiclip.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6f75f26c84..97fbe6b7a9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -453,6 +453,7 @@ OBJS-$(CONFIG_MJPEG_VAAPI_ENCODER) += 
vaapi_encode_mjpeg.o
 OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o
 OBJS-$(CONFIG_MLP_ENCODER) += mlpenc.o mlp.o
 OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
+OBJS-$(CONFIG_MOBICLIP_DECODER)+= mobiclip.o
 OBJS-$(CONFIG_MOTIONPIXELS_DECODER)+= motionpixels.o
 OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o
 OBJS-$(CONFIG_MOVTEXT_ENCODER) += movtextenc.o ass_split.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 3920eb37ce..8a4b3fb178 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -186,6 +186,7 @@ extern AVCodec ff_mjpeg_encoder;
 extern AVCodec ff_mjpeg_decoder;
 extern AVCodec ff_mjpegb_decoder;
 extern AVCodec ff_mmvideo_decoder;
+extern AVCodec ff_mobiclip_decoder;
 extern AVCodec ff_motionpixels_decoder;
 extern AVCodec ff_mpeg1video_encoder;
 extern AVCodec ff_mpeg1video_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9a3eaf7d98..ceef244ebf 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1784,6 +1784,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_MOBICLIP,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "mobiclip",
+.long_name = NULL_IF_CONFIG_SMALL("MobiClip Video"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index aac7f63eb6..19d5014bb4 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -296,6 +296,7 @@ enum AVCodecID {
 AV_CODEC_ID_MV30,
 AV_CODEC_ID_NOTCHLC,
 AV_CODEC_ID_PFM,
+AV_CODEC_ID_MOBICLIP,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
new file mode 100644
index 00..c6eb481874
--- /dev/null
+++ b/libavcodec/mobiclip.c
@@ -0,0 +1,1371 @@
+/*
+ * MobiClip Video decoder
+ * Copyright (c) 2017 Adib Surani
+ * 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 
+
+#include "libavutil/avassert.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "bswapdsp.h"
+#include "get_bits.h"
+#include "internal.h"
+
+static const uint8_t zigzag8x8_tab[] =
+{
+0x00, 0x01, 0x08, 0x10, 0x09, 0x02, 0x03, 0x0A, 0x11, 0x18, 0x20, 0x19,
+0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13, 0x1A, 0x21, 0x28, 0x30, 0x29, 0x22,
+0x1B, 0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1C, 0x23, 0x2A, 0x31, 0x38,
+0x39, 0x32, 0x2B, 0x24, 0x1D, 0x16, 0x0F, 0x17, 0x1E, 0x25, 0x2C, 0x33,
+0x3A, 0x3B, 0x34, 0x2D, 0x26, 0x1F, 0x27, 0x2E, 0x35, 0x3C, 0x3D, 0x36,
+0x2F, 0x37, 0x3E, 0x3F
+};
+
+static const uint8_t zigzag4x4_tab[] =
+{
+0x00, 0x04, 0x01, 0x02, 0x05, 0x08, 0x0C, 0x09, 0x06, 0x03, 0x07, 0x0A,
+0x0D, 0x0E, 0x0B, 0x0F
+};
+
+static const uint8_t quant4x4_tab[][16] =
+{
+{ 10, 13, 13, 10, 16, 10, 13, 13, 13, 13, 16, 10, 16, 13, 13, 16 },
+{ 11, 14, 14, 11, 18, 11, 14, 14, 14, 14, 18, 11, 18, 14, 14, 18 },
+{ 13, 16, 16, 13, 20, 13, 16, 16, 16, 16, 20, 13, 20, 16, 16, 20 },
+{ 14, 18, 18, 14, 23, 14, 18, 18, 18, 18, 23, 14, 23, 18, 18, 23 },
+{ 16, 20, 20, 16, 25, 16, 20, 20, 20, 20, 25, 16, 25, 20, 20, 25 },
+{ 18, 23, 23, 18, 29, 18, 23, 23, 23, 23, 29, 18, 29, 23, 23, 29 },
+};
+
+static const uint8_t quant8x8_tab[][64] =
+{
+{ 20, 19, 19, 25, 18, 25, 19, 24, 24, 19, 20, 18, 32, 18, 20, 19, 19, 24, 
24, 19, 19, 25, 18, 2

Re: [FFmpeg-devel] [PATCH v5 2/2] libavformat/mxfenc: color_range should be inclusive

2020-08-29 Thread Tomas Härdin
mån 2020-08-24 klockan 12:02 +0100 skrev Harry Mallon:
> > On 24 Aug 2020, at 09:30, Tomas Härdin  wrote:
> > 
> > tor 2020-08-20 klockan 14:58 +0100 skrev Harry Mallon:
> > > MXF CDCI color range was being set to (1 > > 1
> > > for full range but it should be (1 > > a valid value.
> > 
> > Grammar here is a bit strange. Do you mean 0 is a valid value?
> > Looks OK
> > besides this
> 
> Sorry, it is meant to read ‘as 0 is a valid value’. Shall I change in
> a new version?
> 
> Thanks for being attentive and speedy with my patches btw. Sending
> things into FFMPEG has been pretty painless. :)

Both patches pushed. This was being held up by fate-cfhd-1 being broken

/Tomas

___
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 v2 2/2] docs: muxers: document ADTS muxer options

2020-08-29 Thread Marvin Scholz
---
 doc/muxers.texi | 25 +
 1 file changed, 25 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 813b4678f4..ae8dcdd145 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -19,6 +19,31 @@ enabled demuxers and muxers.
 
 A description of some of the currently available muxers follows.
 
+@anchor{adts}
+@section adts
+
+Audio Data Transport Stream muxer.
+
+The ADTS format is used for streaming AAC audio over the internet
+and in the TS format.
+
+@subsection Options
+
+It accepts the following options:
+
+@table @option
+@item write_id3v2
+Enable ID3v2 tags writing when set to 1. Default is 0 (disabled).
+
+@item write_apetag
+Enable APE tags writing when set to 1. Default is 0 (disabled).
+
+@item write_mpeg2
+Switch to writing ADTS headers with the MPEG ID set to 1, for MPEG2,
+instead of the default of 0 for MPEG4. Default is 0 (disabled).
+
+@end table
+
 @anchor{aiff}
 @section aiff
 
-- 
2.24.3 (Apple Git-128)

___
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 v2 1/2] adtsenc: Add ability to write MPEG2 ID

2020-08-29 Thread Marvin Scholz
---
 libavformat/adtsenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 9e285752eb..44ff5a70ee 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -40,6 +40,7 @@ typedef struct ADTSContext {
 int pce_size;
 int apetag;
 int id3v2tag;
+int mpeg_id;
 uint8_t pce_data[MAX_PCE_SIZE];
 } ADTSContext;
 
@@ -136,7 +137,7 @@ static int adts_write_frame_header(ADTSContext *ctx,
 
 /* adts_fixed_header */
 put_bits(&pb, 12, 0xfff);   /* syncword */
-put_bits(&pb, 1, 0);/* ID */
+put_bits(&pb, 1, ctx->mpeg_id); /* ID */
 put_bits(&pb, 2, 0);/* layer */
 put_bits(&pb, 1, 1);/* protection_absent */
 put_bits(&pb, 2, ctx->objecttype); /* profile_objecttype */
@@ -214,6 +215,7 @@ static int adts_write_trailer(AVFormatContext *s)
 static const AVOption options[] = {
 { "write_id3v2",  "Enable ID3v2 tag writing", OFFSET(id3v2tag), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, ENC},
 { "write_apetag", "Enable APE tag writing",   OFFSET(apetag),   
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, ENC},
+{ "write_mpeg2",  "Use MPE2 ID when writing", OFFSET(mpeg_id),  
AV_OPT_TYPE_BOOL,  {.i64 = 0}, 0, 1, ENC, "mpeg_id"},
 { NULL },
 };
 
-- 
2.24.3 (Apple Git-128)

___
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] avcodec/truemotion2: Avoid duplicating array, fix memleak

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> TrueMotion 2.0 uses Huffmann trees. To parse them, the decoder allocates
> arrays for the codes, their lengths and their value; afterwards a VLC
> table is initialized using these values. If everything up to this point
> succeeds, a new buffer of the same size as the already allocated arrays
> for the values is allocated and upon success the values are copied into
> the new array; all the old arrays are then freed. Yet if allocating the
> new array fails, the old arrays get freed, but the VLC table doesn't.
>
> This leak is fixed by not allocating a new array at all; instead the old
> array is simply reused, ensuring that nothing can fail after the
> creation of the VLC table.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/truemotion2.c | 11 ++-
>  1 file changed, 2 insertions(+), 9 deletions(-)
>

probably ok
___
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 v2 1/2] adtsenc: Add ability to write MPEG2 ID

2020-08-29 Thread Kieran Kunhya
On Sat, 29 Aug 2020 at 13:27, Marvin Scholz  wrote:

> ---
>  libavformat/adtsenc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>

Ok
___
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] avformat/rtsp: fix infinite loop with udp transport

2020-08-29 Thread Andriy Gelman
Hi Zhao,

On Tue, 25. Aug 01:17, Zhao Zhili wrote:
> Ping again.
> 
> > On Aug 17, 2020, at 8:05 AM, zhilizhao  wrote:
> > 
> > Please help review the patch, thanks!
> > 
> >> On Aug 6, 2020, at 4:50 PM, quinkbl...@foxmail.com wrote:
> >> 
> >> From: Zhao Zhili 
> >> 
> >> User report: 
> >> http://ffmpeg.org/pipermail/ffmpeg-user/2020-August/049494.html
> >> 
> >> server:
> >> ./ffmpeg -i test.mp4 -c copy -f rtsp -rtsp_transport udp  
> >> rtsp://localhost:12345/live.sdp
> >> 
> >> client:
> >> ./ffmpeg_g -y -rtsp_flags listen -timeout 100 -i 
> >> rtsp://localhost:12345/live.sdp -c copy test.mp4
> >> ---
> >> libavformat/rtsp.c | 5 +
> >> 1 file changed, 5 insertions(+)
> >> 
> >> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> >> index 5d8491b74b..0fb9fde6b4 100644
> >> --- a/libavformat/rtsp.c
> >> +++ b/libavformat/rtsp.c
> >> @@ -2051,6 +2051,11 @@ static int udp_read_packet(AVFormatContext *s, 
> >> RTSPStream **prtsp_st,
> >>if ((ret = parse_rtsp_message(s)) < 0) {
> >>return ret;
> >>}
> >> +/* Since there is no way to detect eof of udp streams, 
> >> break
> >> + * the loop in teardown state to prevent run into 
> >> infinite.
> >> + */
> >> +if (rt->state == RTSP_STATE_IDLE)
> >> +return AVERROR_EOF;
> >>}
> >> #endif
> >>} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {

Currently when the stream finishes a BYE message is not sent from the server.  

You can ensure that the message is sent by adding the send_bye option with the
flag:
"-rtpflags send_bye"

This will also fix the problem.

What I think is more confusing is that "-rtp_flags send_bye" is also valid on
the command line but will have no effect..

-- 
Andriy
___
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 04/13] avcodec/mss3: Remove unnecessary free of unallocated packet

2020-08-29 Thread Andreas Rheinhardt
The packet will only be allocated a few lines below.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mss3.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
index 113af5ba37..a301675ec2 100644
--- a/libavcodec/mss3.c
+++ b/libavcodec/mss3.c
@@ -844,7 +844,6 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
 b_width * b_height);
 if (!c->dct_coder[i].prev_dc) {
 av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
-av_frame_free(&c->pic);
 while (i >= 0) {
 av_freep(&c->dct_coder[i].prev_dc);
 i--;
-- 
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 01/13] avcodec/cinepakenc: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cinepakenc.c | 36 ++--
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index 6024df0fba..cc125ed39e 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -171,22 +171,22 @@ static av_cold int cinepak_encode_init(AVCodecContext 
*avctx)
 if (!(s->last_frame = av_frame_alloc()))
 return AVERROR(ENOMEM);
 if (!(s->best_frame = av_frame_alloc()))
-goto enomem;
+return AVERROR(ENOMEM);
 if (!(s->scratch_frame = av_frame_alloc()))
-goto enomem;
+return AVERROR(ENOMEM);
 if (avctx->pix_fmt == AV_PIX_FMT_RGB24)
 if (!(s->input_frame = av_frame_alloc()))
-goto enomem;
+return AVERROR(ENOMEM);
 
 if (!(s->codebook_input = av_malloc_array((avctx->pix_fmt == 
AV_PIX_FMT_RGB24 ? 6 : 4) * (avctx->width * avctx->height) >> 2, 
sizeof(*s->codebook_input
-goto enomem;
+return AVERROR(ENOMEM);
 
 if (!(s->codebook_closest = av_malloc_array((avctx->width * avctx->height) 
>> 2, sizeof(*s->codebook_closest
-goto enomem;
+return AVERROR(ENOMEM);;
 
 for (x = 0; x < (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 4 : 3); x++)
 if (!(s->pict_bufs[x] = av_malloc((avctx->pix_fmt == AV_PIX_FMT_RGB24 
? 6 : 4) * (avctx->width * avctx->height) >> 2)))
-goto enomem;
+return AVERROR(ENOMEM);
 
 mb_count = avctx->width * avctx->height / MB_AREA;
 
@@ -199,13 +199,13 @@ static av_cold int cinepak_encode_init(AVCodecContext 
*avctx)
 frame_buf_size = CVID_HEADER_SIZE + s->max_max_strips * strip_buf_size;
 
 if (!(s->strip_buf = av_malloc(strip_buf_size)))
-goto enomem;
+return AVERROR(ENOMEM);
 
 if (!(s->frame_buf = av_malloc(frame_buf_size)))
-goto enomem;
+return AVERROR(ENOMEM);
 
 if (!(s->mb = av_malloc_array(mb_count, sizeof(mb_info
-goto enomem;
+return AVERROR(ENOMEM);
 
 av_lfg_init(&s->randctx, 1);
 s->avctx  = avctx;
@@ -252,23 +252,6 @@ static av_cold int cinepak_encode_init(AVCodecContext 
*avctx)
 s->max_strips = s->max_max_strips;
 
 return 0;
-
-enomem:
-av_frame_free(&s->last_frame);
-av_frame_free(&s->best_frame);
-av_frame_free(&s->scratch_frame);
-if (avctx->pix_fmt == AV_PIX_FMT_RGB24)
-av_frame_free(&s->input_frame);
-av_freep(&s->codebook_input);
-av_freep(&s->codebook_closest);
-av_freep(&s->strip_buf);
-av_freep(&s->frame_buf);
-av_freep(&s->mb);
-
-for (x = 0; x < (avctx->pix_fmt == AV_PIX_FMT_RGB24 ? 4 : 3); x++)
-av_freep(&s->pict_bufs[x]);
-
-return AVERROR(ENOMEM);
 }
 
 static int64_t calculate_mode_score(CinepakEncContext *s, int h,
@@ -1206,4 +1189,5 @@ AVCodec ff_cinepak_encoder = {
 .close  = cinepak_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, 
AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE },
 .priv_class = &cinepak_class,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 03/13] avcodec/interplayvideo: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/interplayvideo.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index 274641c3d1..58400b6ace 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -1160,7 +1160,6 @@ static void 
ipvideo_decode_format_11_opcodes(IpvideoContext *s, AVFrame *frame)
 static av_cold int ipvideo_decode_init(AVCodecContext *avctx)
 {
 IpvideoContext *s = avctx->priv_data;
-int ret;
 
 s->avctx = avctx;
 
@@ -1175,8 +1174,7 @@ static av_cold int ipvideo_decode_init(AVCodecContext 
*avctx)
 s->prev_decode_frame = av_frame_alloc();
 if (!s->last_frame || !s->second_last_frame ||
 !s->cur_decode_frame || !s->prev_decode_frame) {
-ret = AVERROR(ENOMEM);
-goto error;
+return AVERROR(ENOMEM);
 }
 
 s->cur_decode_frame->width   = avctx->width;
@@ -1187,12 +1185,6 @@ static av_cold int ipvideo_decode_init(AVCodecContext 
*avctx)
 s->prev_decode_frame->format = avctx->pix_fmt;
 
 return 0;
-error:
-av_frame_free(&s->last_frame);
-av_frame_free(&s->second_last_frame);
-av_frame_free(&s->cur_decode_frame);
-av_frame_free(&s->prev_decode_frame);
-return ret;
 }
 
 static int ipvideo_decode_frame(AVCodecContext *avctx,
@@ -1381,4 +1373,5 @@ AVCodec ff_interplay_video_decoder = {
 .close  = ipvideo_decode_end,
 .decode = ipvideo_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_PARAM_CHANGE,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 05/13] avcodec/mss3: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mss3.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
index a301675ec2..74f4b5e671 100644
--- a/libavcodec/mss3.c
+++ b/libavcodec/mss3.c
@@ -844,19 +844,13 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx)
 b_width * b_height);
 if (!c->dct_coder[i].prev_dc) {
 av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
-while (i >= 0) {
-av_freep(&c->dct_coder[i].prev_dc);
-i--;
-}
 return AVERROR(ENOMEM);
 }
 }
 
 c->pic = av_frame_alloc();
-if (!c->pic) {
-mss3_decode_end(avctx);
+if (!c->pic)
 return AVERROR(ENOMEM);
-}
 
 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
@@ -875,4 +869,5 @@ AVCodec ff_msa1_decoder = {
 .close  = mss3_decode_end,
 .decode = mss3_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 02/13] avcodec/eacmv: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/eacmv.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c
index 6f39d72b88..b239acffda 100644
--- a/libavcodec/eacmv.c
+++ b/libavcodec/eacmv.c
@@ -50,11 +50,8 @@ static av_cold int cmv_decode_init(AVCodecContext *avctx){
 
 s->last_frame  = av_frame_alloc();
 s->last2_frame = av_frame_alloc();
-if (!s->last_frame || !s->last2_frame) {
-av_frame_free(&s->last_frame);
-av_frame_free(&s->last2_frame);
+if (!s->last_frame || !s->last2_frame)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -243,4 +240,5 @@ AVCodec ff_eacmv_decoder = {
 .close  = cmv_decode_end,
 .decode = cmv_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 13/13] avcodec/truemotion1: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/truemotion1.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index b6481cbd7c..94782fef4b 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -491,10 +491,8 @@ static av_cold int truemotion1_decode_init(AVCodecContext 
*avctx)
 /* there is a vertical predictor for each pixel in a line; each vertical
  * predictor is 0 to start with */
 av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * 
sizeof(unsigned int));
-if (!s->vert_pred) {
-av_frame_free(&s->frame);
+if (!s->vert_pred)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -922,4 +920,5 @@ AVCodec ff_truemotion1_decoder = {
 .close  = truemotion1_decode_end,
 .decode = truemotion1_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 06/13] avcodec/roqvideodec: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideodec.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
index a0c293f2f0..dd045ed5eb 100644
--- a/libavcodec/roqvideodec.c
+++ b/libavcodec/roqvideodec.c
@@ -184,11 +184,8 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
 
 s->last_frame= av_frame_alloc();
 s->current_frame = av_frame_alloc();
-if (!s->current_frame || !s->last_frame) {
-av_frame_free(&s->current_frame);
-av_frame_free(&s->last_frame);
+if (!s->current_frame || !s->last_frame)
 return AVERROR(ENOMEM);
-}
 
 avctx->pix_fmt = AV_PIX_FMT_YUVJ444P;
 avctx->color_range = AVCOL_RANGE_JPEG;
@@ -248,4 +245,5 @@ AVCodec ff_roq_decoder = {
 .close  = roq_decode_end,
 .decode = roq_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 07/13] avcodec/roqvideoenc: Cleanup generically after init failure

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideoenc.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index ac05123dc6..dc6a63099d 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -1004,10 +1004,8 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
 
 enc->last_frame= av_frame_alloc();
 enc->current_frame = av_frame_alloc();
-if (!enc->last_frame || !enc->current_frame) {
-roq_encode_end(avctx);
+if (!enc->last_frame || !enc->current_frame)
 return AVERROR(ENOMEM);
-}
 
 enc->tmpData  = av_malloc(sizeof(RoqTempdata));
 
@@ -1024,10 +1022,8 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
 av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
 
 if (!enc->tmpData || !enc->this_motion4 || !enc->last_motion4 ||
-!enc->this_motion8 || !enc->last_motion8) {
-roq_encode_end(avctx);
+!enc->this_motion8 || !enc->last_motion8)
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -1135,4 +1131,5 @@ AVCodec ff_roq_encoder = {
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ444P,
 AV_PIX_FMT_NONE },
 .priv_class = &roq_class,
+.caps_internal= FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
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 12/13] avcodec/y41penc: Remove empty close function

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/y41penc.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c
index 63752e2b44..d7d301fab5 100644
--- a/libavcodec/y41penc.c
+++ b/libavcodec/y41penc.c
@@ -75,11 +75,6 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 return 0;
 }
 
-static av_cold int y41p_encode_close(AVCodecContext *avctx)
-{
-return 0;
-}
-
 AVCodec ff_y41p_encoder = {
 .name = "y41p",
 .long_name= NULL_IF_CONFIG_SMALL("Uncompressed YUV 4:1:1 12-bit"),
@@ -87,7 +82,6 @@ AVCodec ff_y41p_encoder = {
 .id   = AV_CODEC_ID_Y41P,
 .init = y41p_encode_init,
 .encode2  = y41p_encode_frame,
-.close= y41p_encode_close,
 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P,
  AV_PIX_FMT_NONE },
 };
-- 
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 08/13] avcodec/wnv1: Use LE bitstream reader, avoid copying packet, fix memleak

2020-08-29 Thread Andreas Rheinhardt
The Winnov WNV1 format is designed for a little-endian bitstream reader;
yet our decoder reversed every byte bitwise (in a buffer only
allocated for this purpose) to use a big-endian bitstream reader. This
commit stops this.

Two things needed to be done to achieve this: The codes in the table used
to initialize a VLC reader needed to be reversed bitwise (when
initializing a VLC in LE mode, it is expected that the first bit to be
read is in the least significant bit; with BE codes the first bit to be
read is the most significant bit of the code) and the following
expression needed to be adapted:

ff_reverse[get_bits(&w->gb, 8 - w->shift)]

But this is easy: When only the bits read are reversed, they coincide
with what a little-endian bitstream reader reads that reads the
original, not-reversed data. But ff_reverse always reverses the full
eight bits and this also performs a shift by (8 - (8 - w->shift)) on top
of reversing the bits read. So the above line needs to be changed to

get_bits(&w->gb, 8 - w->shift) << w->shift

and this also shows why the variable shift is named the way it is.

Finally, this also fixes a hypothetical memleak: For gigantic packets,
initializing a GetBitContext can fail and in this case, the buffer
containing the reversed data would leak.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wnv1.c | 28 +++-
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
index 915e9c7dc9..857807a951 100644
--- a/libavcodec/wnv1.c
+++ b/libavcodec/wnv1.c
@@ -24,10 +24,10 @@
  * Winnov WNV1 codec.
  */
 
+#define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "get_bits.h"
 #include "internal.h"
-#include "mathops.h"
 
 
 typedef struct WNV1Context {
@@ -36,9 +36,9 @@ typedef struct WNV1Context {
 } WNV1Context;
 
 static const uint16_t code_tab[16][2] = {
-{ 0x1FD, 9 }, { 0xFD, 8 }, { 0x7D, 7 }, { 0x3D, 6 }, { 0x1D, 5 }, { 0x0D, 
4 }, { 0x005, 3 },
+{ 0x17F, 9 }, { 0xBF, 8 }, { 0x5F, 7 }, { 0x2F, 6 }, { 0x17, 5 }, { 0x0B, 
4 }, { 0x005, 3 },
 { 0x000, 1 },
-{ 0x004, 3 }, { 0x0C, 4 }, { 0x1C, 5 }, { 0x3C, 6 }, { 0x7C, 7 }, { 0xFC, 
8 }, { 0x1FC, 9 }, { 0xFF, 8 }
+{ 0x01, 3 }, { 0x03, 4 }, { 0x07, 5 }, { 0x0F, 6 }, { 0x1F, 7 }, { 0x3F, 8 
}, { 0x07F, 9 }, { 0xFF, 8 }
 };
 
 #define CODE_VLC_BITS 9
@@ -50,7 +50,7 @@ static inline int wnv1_get_code(WNV1Context *w, int 
base_value)
 int v = get_vlc2(&w->gb, code_vlc.table, CODE_VLC_BITS, 1);
 
 if (v == 15)
-return ff_reverse[get_bits(&w->gb, 8 - w->shift)];
+return get_bits(&w->gb, 8 - w->shift) << w->shift;
 else
 return base_value + ((v - 7U) << w->shift);
 }
@@ -66,30 +66,17 @@ static int decode_frame(AVCodecContext *avctx,
 unsigned char *Y,*U,*V;
 int i, j, ret;
 int prev_y = 0, prev_u = 0, prev_v = 0;
-uint8_t *rbuf;
 
 if (buf_size < 8 + avctx->height * (avctx->width/2)/8) {
 av_log(avctx, AV_LOG_ERROR, "Packet size %d is too small\n", buf_size);
 return AVERROR_INVALIDDATA;
 }
 
-rbuf = av_malloc(buf_size + AV_INPUT_BUFFER_PADDING_SIZE);
-if (!rbuf) {
-av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
-return AVERROR(ENOMEM);
-}
-memset(rbuf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
-
-if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
-av_free(rbuf);
+if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
 return ret;
-}
 p->key_frame = 1;
 
-for (i = 8; i < buf_size; i++)
-rbuf[i] = ff_reverse[buf[i]];
-
-if ((ret = init_get_bits8(&l->gb, rbuf + 8, buf_size - 8)) < 0)
+if ((ret = init_get_bits8(&l->gb, buf + 8, buf_size - 8)) < 0)
 return ret;
 
 if (buf[2] >> 4 == 6)
@@ -127,7 +114,6 @@ static int decode_frame(AVCodecContext *avctx,
 
 
 *got_frame  = 1;
-av_free(rbuf);
 
 return buf_size;
 }
@@ -142,7 +128,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 code_vlc.table_allocated = 1 << CODE_VLC_BITS;
 init_vlc(&code_vlc, CODE_VLC_BITS, 16,
  &code_tab[0][1], 4, 2,
- &code_tab[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC);
+ &code_tab[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE);
 
 return 0;
 }
-- 
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 09/13] avcodec/wnv1: Move temporary variables from context to stack

2020-08-29 Thread Andreas Rheinhardt
Here it even leads to the complete removal of the context.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wnv1.c | 40 +---
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
index 857807a951..b5cd0f0f0c 100644
--- a/libavcodec/wnv1.c
+++ b/libavcodec/wnv1.c
@@ -30,11 +30,6 @@
 #include "internal.h"
 
 
-typedef struct WNV1Context {
-int shift;
-GetBitContext gb;
-} WNV1Context;
-
 static const uint16_t code_tab[16][2] = {
 { 0x17F, 9 }, { 0xBF, 8 }, { 0x5F, 7 }, { 0x2F, 6 }, { 0x17, 5 }, { 0x0B, 
4 }, { 0x005, 3 },
 { 0x000, 1 },
@@ -45,26 +40,26 @@ static const uint16_t code_tab[16][2] = {
 static VLC code_vlc;
 
 /* returns modified base_value */
-static inline int wnv1_get_code(WNV1Context *w, int base_value)
+static inline int wnv1_get_code(GetBitContext *gb, int shift, int base_value)
 {
-int v = get_vlc2(&w->gb, code_vlc.table, CODE_VLC_BITS, 1);
+int v = get_vlc2(gb, code_vlc.table, CODE_VLC_BITS, 1);
 
 if (v == 15)
-return get_bits(&w->gb, 8 - w->shift) << w->shift;
+return get_bits(gb, 8 - shift) << shift;
 else
-return base_value + ((v - 7U) << w->shift);
+return base_value + ((v - 7U) << shift);
 }
 
 static int decode_frame(AVCodecContext *avctx,
 void *data, int *got_frame,
 AVPacket *avpkt)
 {
-WNV1Context * const l = avctx->priv_data;
 const uint8_t *buf= avpkt->data;
 int buf_size  = avpkt->size;
 AVFrame * const p = data;
+GetBitContext gb;
 unsigned char *Y,*U,*V;
-int i, j, ret;
+int i, j, ret, shift;
 int prev_y = 0, prev_u = 0, prev_v = 0;
 
 if (buf_size < 8 + avctx->height * (avctx->width/2)/8) {
@@ -76,24 +71,24 @@ static int decode_frame(AVCodecContext *avctx,
 return ret;
 p->key_frame = 1;
 
-if ((ret = init_get_bits8(&l->gb, buf + 8, buf_size - 8)) < 0)
+if ((ret = init_get_bits8(&gb, buf + 8, buf_size - 8)) < 0)
 return ret;
 
 if (buf[2] >> 4 == 6)
-l->shift = 2;
+shift = 2;
 else {
-l->shift = 8 - (buf[2] >> 4);
-if (l->shift > 4) {
+shift = 8 - (buf[2] >> 4);
+if (shift > 4) {
 avpriv_request_sample(avctx,
   "Unknown WNV1 frame header value %i",
   buf[2] >> 4);
-l->shift = 4;
+shift = 4;
 }
-if (l->shift < 1) {
+if (shift < 1) {
 avpriv_request_sample(avctx,
   "Unknown WNV1 frame header value %i",
   buf[2] >> 4);
-l->shift = 1;
+shift = 1;
 }
 }
 
@@ -102,10 +97,10 @@ static int decode_frame(AVCodecContext *avctx,
 V = p->data[2];
 for (j = 0; j < avctx->height; j++) {
 for (i = 0; i < avctx->width / 2; i++) {
-Y[i * 2] = wnv1_get_code(l, prev_y);
-prev_u = U[i] = wnv1_get_code(l, prev_u);
-prev_y = Y[(i * 2) + 1] = wnv1_get_code(l, Y[i * 2]);
-prev_v = V[i] = wnv1_get_code(l, prev_v);
+Y[i * 2] = wnv1_get_code(&gb, shift, prev_y);
+prev_u = U[i] = wnv1_get_code(&gb, shift, prev_u);
+prev_y = Y[(i * 2) + 1] = wnv1_get_code(&gb, shift, Y[i * 2]);
+prev_v = V[i] = wnv1_get_code(&gb, shift, prev_v);
 }
 Y += p->linesize[0];
 U += p->linesize[1];
@@ -138,7 +133,6 @@ AVCodec ff_wnv1_decoder = {
 .long_name  = NULL_IF_CONFIG_SMALL("Winnov WNV1"),
 .type   = AVMEDIA_TYPE_VIDEO,
 .id = AV_CODEC_ID_WNV1,
-.priv_data_size = sizeof(WNV1Context),
 .init   = decode_init,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-- 
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 10/13] avcodec/bitstream: Remove outdated comment

2020-08-29 Thread Andreas Rheinhardt
The comment referred to the INIT_VLC_USE_STATIC flag which has been
removed in 2009 in 595324e143b57a52e2329eb47b84395c70f93087; the
function it referred to was removed even earlier in commit
83422c1940d963d395a64bee0cbb9c637192ce8c in 2008.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bitstream.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index d379dbc0e8..95e5092b44 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -266,9 +266,6 @@ static int build_table(VLC *vlc, int table_nb_bits, int 
nb_codes,
 
'wrap' and 'size' make it possible to use any memory configuration and types
(byte/word/long) to store the 'bits', 'codes', and 'symbols' tables.
-
-   'use_static' should be set to 1 for tables, which should be freed
-   with av_free_static(), 0 if ff_free_vlc() will be used.
 */
 int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
-- 
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 11/13] avcodec/yuv4enc: Remove empty functions

2020-08-29 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/yuv4enc.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c
index f21b1f36ce..63a7fae964 100644
--- a/libavcodec/yuv4enc.c
+++ b/libavcodec/yuv4enc.c
@@ -23,11 +23,6 @@
 #include "avcodec.h"
 #include "internal.h"
 
-static av_cold int yuv4_encode_init(AVCodecContext *avctx)
-{
-return 0;
-}
-
 static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
  const AVFrame *pic, int *got_packet)
 {
@@ -62,18 +57,11 @@ static int yuv4_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 return 0;
 }
 
-static av_cold int yuv4_encode_close(AVCodecContext *avctx)
-{
-return 0;
-}
-
 AVCodec ff_yuv4_encoder = {
 .name = "yuv4",
 .long_name= NULL_IF_CONFIG_SMALL("Uncompressed packed 4:2:0"),
 .type = AVMEDIA_TYPE_VIDEO,
 .id   = AV_CODEC_ID_YUV4,
-.init = yuv4_encode_init,
 .encode2  = yuv4_encode_frame,
-.close= yuv4_encode_close,
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, 
AV_PIX_FMT_NONE },
 };
-- 
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".

Re: [FFmpeg-devel] [PATCH 08/13] avcodec/wnv1: Use LE bitstream reader, avoid copying packet, fix memleak

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> The Winnov WNV1 format is designed for a little-endian bitstream reader;
> yet our decoder reversed every byte bitwise (in a buffer only
> allocated for this purpose) to use a big-endian bitstream reader. This
> commit stops this.
>
> Two things needed to be done to achieve this: The codes in the table used
> to initialize a VLC reader needed to be reversed bitwise (when
> initializing a VLC in LE mode, it is expected that the first bit to be
> read is in the least significant bit; with BE codes the first bit to be
> read is the most significant bit of the code) and the following
> expression needed to be adapted:
>
> ff_reverse[get_bits(&w->gb, 8 - w->shift)]
>
> But this is easy: When only the bits read are reversed, they coincide
> with what a little-endian bitstream reader reads that reads the
> original, not-reversed data. But ff_reverse always reverses the full
> eight bits and this also performs a shift by (8 - (8 - w->shift)) on top
> of reversing the bits read. So the above line needs to be changed to
>
> get_bits(&w->gb, 8 - w->shift) << w->shift
>
> and this also shows why the variable shift is named the way it is.
>
> Finally, this also fixes a hypothetical memleak: For gigantic packets,
> initializing a GetBitContext can fail and in this case, the buffer
> containing the reversed data would leak.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/wnv1.c | 28 +++-
>  1 file changed, 7 insertions(+), 21 deletions(-)
>

LGTM, nice.
___
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/13] avcodec/yuv4enc: Remove empty functions

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/yuv4enc.c | 12 
>  1 file changed, 12 deletions(-)
>

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".

Re: [FFmpeg-devel] [PATCH 01/13] avcodec/cinepakenc: Cleanup generically after init failure

2020-08-29 Thread Tomas Härdin
lör 2020-08-29 klockan 19:56 +0200 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/cinepakenc.c | 36 ++--
>  1 file changed, 10 insertions(+), 26 deletions(-)
> 
> diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
> index 6024df0fba..cc125ed39e 100644
> --- a/libavcodec/cinepakenc.c
> +++ b/libavcodec/cinepakenc.c

Looks good to me

/Tomas

___
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/13] avcodec/y41penc: Remove empty close function

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/y41penc.c | 6 --
>  1 file changed, 6 deletions(-)
>

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".

Re: [FFmpeg-devel] [PATCH 13/13] avcodec/truemotion1: Cleanup generically after init failure

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/truemotion1.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>

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".

Re: [FFmpeg-devel] [PATCH 03/13] avcodec/interplayvideo: Cleanup generically after init failure

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/interplayvideo.c | 11 ++-
>  1 file changed, 2 insertions(+), 9 deletions(-)
>

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".

Re: [FFmpeg-devel] [PATCH 02/13] avcodec/eacmv: Cleanup generically after init failure

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/eacmv.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

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".

Re: [FFmpeg-devel] [PATCH 09/13] avcodec/wnv1: Move temporary variables from context to stack

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Here it even leads to the complete removal of the context.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/wnv1.c | 40 +---
>  1 file changed, 17 insertions(+), 23 deletions(-)

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".

Re: [FFmpeg-devel] [PATCH 04/13] avcodec/mss3: Remove unnecessary free of unallocated packet

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> The packet will only be allocated a few lines below.
>

You mean frame?

> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mss3.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
> index 113af5ba37..a301675ec2 100644
> --- a/libavcodec/mss3.c
> +++ b/libavcodec/mss3.c
> @@ -844,7 +844,6 @@ static av_cold int mss3_decode_init(AVCodecContext
> *avctx)
>  b_width * b_height);
>  if (!c->dct_coder[i].prev_dc) {
>  av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
> -av_frame_free(&c->pic);
>  while (i >= 0) {
>  av_freep(&c->dct_coder[i].prev_dc);
>  i--;
> --
> 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] [PATCH] avcodec: add PhotoCD decoder

2020-08-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
Probably need to be applied on top of moflex v2 patch set.
---
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/codec_id.h   |   1 +
 libavcodec/photocd.c| 468 
 libavformat/img2.c  |   1 +
 6 files changed, 479 insertions(+)
 create mode 100644 libavcodec/photocd.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 97fbe6b7a9..98f31e246b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -541,6 +541,7 @@ OBJS-$(CONFIG_PGMYUV_DECODER)  += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGMYUV_ENCODER)  += pnmenc.o
 OBJS-$(CONFIG_PGSSUB_DECODER)  += pgssubdec.o
 OBJS-$(CONFIG_PGX_DECODER) += pgxdec.o
+OBJS-$(CONFIG_PHOTOCD_DECODER) += photocd.o
 OBJS-$(CONFIG_PICTOR_DECODER)  += pictordec.o cga_data.o
 OBJS-$(CONFIG_PIXLET_DECODER)  += pixlet.o
 OBJS-$(CONFIG_PJS_DECODER) += textdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 8a4b3fb178..f3572a47e3 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -241,6 +241,7 @@ extern AVCodec ff_pgm_decoder;
 extern AVCodec ff_pgmyuv_encoder;
 extern AVCodec ff_pgmyuv_decoder;
 extern AVCodec ff_pgx_decoder;
+extern AVCodec ff_photocd_decoder;
 extern AVCodec ff_pictor_decoder;
 extern AVCodec ff_pixlet_decoder;
 extern AVCodec ff_png_encoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index ceef244ebf..9e73dcba27 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1791,6 +1791,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("MobiClip Video"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_PHOTOCD,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "photocd",
+.long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 19d5014bb4..e4eca5d580 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -297,6 +297,7 @@ enum AVCodecID {
 AV_CODEC_ID_NOTCHLC,
 AV_CODEC_ID_PFM,
 AV_CODEC_ID_MOBICLIP,
+AV_CODEC_ID_PHOTOCD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
new file mode 100644
index 00..50584ac980
--- /dev/null
+++ b/libavcodec/photocd.c
@@ -0,0 +1,468 @@
+/*
+ * Kodak PhotoCD (a.k.a. ImagePac) image decoder
+ *
+ * Copyright (c) 1996-2002 Gerd Knorr
+ * Copyright (c) 2010 Kenneth Vermeirsch
+ * 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
+ */
+
+/**
+ * @file
+ * Kodak PhotoCD (a.k.a. ImagePac) image decoder
+ *
+ * Supports resolutions up to 3072x2048.
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "get_bits.h"
+#include "internal.h"
+
+typedef struct PhotoCDContext {
+AVClass *class;
+int  lowres;
+
+GetByteContext gb;
+int  thumbnails;  //* number of thumbnails; 0 for normal image */
+int  resolution;
+int  orientation;
+
+int  streampos;
+
+uint8_t  bits[256];
+uint16_t codes[256];
+uint8_t  syms[256];
+
+VLC  vlc[3];
+} PhotoCDContext;
+
+typedef struct ImageInfo {
+uint32_t start;
+uint16_t width, height;
+} ImageInfo;
+
+static const ImageInfo img_info[6] = {
+{8192,192, 128},
+{47104,   384, 256},
+{196608,  768, 512},
+{0,  1536, 1024},
+{0,  3072, 2048},
+{0,  6144, 4096},
+};
+
+static av_always_inline void interp_lowres(PhotoCDContext *s, AVFrame *picture,
+   int width, int height)
+{
+GetByteContext *gb = &s->gb;
+int start = s->streampos + img_info[2].start;
+uint8_t *ptr, *ptr1, *ptr2;
+uint8_t *dest;
+int fill;
+
+ptr  = picture->data[0];
+ptr1 = picture->data[1];
+  

Re: [FFmpeg-devel] [PATCH 05/13] avcodec/mss3: Cleanup generically after init failure

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mss3.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
>

LGTM

> diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
> index a301675ec2..74f4b5e671 100644
> --- a/libavcodec/mss3.c
> +++ b/libavcodec/mss3.c
> @@ -844,19 +844,13 @@ static av_cold int mss3_decode_init(AVCodecContext
> *avctx)
>  b_width * b_height);
>  if (!c->dct_coder[i].prev_dc) {
>  av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
> -while (i >= 0) {
> -av_freep(&c->dct_coder[i].prev_dc);
> -i--;
> -}
>  return AVERROR(ENOMEM);
>  }
>  }
>
>  c->pic = av_frame_alloc();
> -if (!c->pic) {
> -mss3_decode_end(avctx);
> +if (!c->pic)
>  return AVERROR(ENOMEM);
> -}
>
>  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
>
> @@ -875,4 +869,5 @@ AVCodec ff_msa1_decoder = {
>  .close  = mss3_decode_end,
>  .decode = mss3_decode_frame,
>  .capabilities   = AV_CODEC_CAP_DR1,
> +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 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] [PATCH 07/13] avcodec/roqvideoenc: Cleanup generically after init failure

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/roqvideoenc.c | 9 +++--
>  1 file changed, 3 insertions(+), 6 deletions(-)
>


LGTM

> diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
> index ac05123dc6..dc6a63099d 100644
> --- a/libavcodec/roqvideoenc.c
> +++ b/libavcodec/roqvideoenc.c
> @@ -1004,10 +1004,8 @@ static av_cold int roq_encode_init(AVCodecContext
> *avctx)
>
>  enc->last_frame= av_frame_alloc();
>  enc->current_frame = av_frame_alloc();
> -if (!enc->last_frame || !enc->current_frame) {
> -roq_encode_end(avctx);
> +if (!enc->last_frame || !enc->current_frame)
>  return AVERROR(ENOMEM);
> -}
>
>  enc->tmpData  = av_malloc(sizeof(RoqTempdata));
>
> @@ -1024,10 +1022,8 @@ static av_cold int roq_encode_init(AVCodecContext
> *avctx)
>  av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
>
>  if (!enc->tmpData || !enc->this_motion4 || !enc->last_motion4 ||
> -!enc->this_motion8 || !enc->last_motion8) {
> -roq_encode_end(avctx);
> +!enc->this_motion8 || !enc->last_motion8)
>  return AVERROR(ENOMEM);
> -}
>
>  return 0;
>  }
> @@ -1135,4 +1131,5 @@ AVCodec ff_roq_encoder = {
>  .pix_fmts = (const enum AVPixelFormat[]){
> AV_PIX_FMT_YUVJ444P,
>  AV_PIX_FMT_NONE },
>  .priv_class = &roq_class,
> +.caps_internal= FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 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] [PATCH 06/13] avcodec/roqvideodec: Cleanup generically after init failure

2020-08-29 Thread Paul B Mahol
On 8/29/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/roqvideodec.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
> index a0c293f2f0..dd045ed5eb 100644
> --- a/libavcodec/roqvideodec.c
> +++ b/libavcodec/roqvideodec.c
> @@ -184,11 +184,8 @@ static av_cold int roq_decode_init(AVCodecContext
> *avctx)
>
>  s->last_frame= av_frame_alloc();
>  s->current_frame = av_frame_alloc();
> -if (!s->current_frame || !s->last_frame) {
> -av_frame_free(&s->current_frame);
> -av_frame_free(&s->last_frame);
> +if (!s->current_frame || !s->last_frame)
>  return AVERROR(ENOMEM);
> -}
>
>  avctx->pix_fmt = AV_PIX_FMT_YUVJ444P;
>  avctx->color_range = AVCOL_RANGE_JPEG;
> @@ -248,4 +245,5 @@ AVCodec ff_roq_decoder = {
>  .close  = roq_decode_end,
>  .decode = roq_decode_frame,
>  .capabilities   = AV_CODEC_CAP_DR1,
> +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 2.20.1
>

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 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] avcodec: add PhotoCD decoder

2020-08-29 Thread Paul B Mahol
On 8/29/20, Paul B Mahol  wrote:
> Signed-Goff-by: Paul B Mahol 
> ---
> Probably need to be applied on top of moflex v2 patch set.
> ---

[...]

> +
> +static av_cold int photocd_decode_init(AVCodecContext *avctx)
> +{
> +avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> +avctx->colorspace  = AVCOL_SPC_BT709;
> +avctx->color_primaries = AVCOL_PRI_BT709;
> +avctx->color_trc   = AVCOL_TRC_IEC61966_2_4;
> +avctx->color_range = AVCOL_RANGE_MPEG;

Locally changed to JPEG color range, as that is much better looking.

> +
> +return 0;
> +}
> +
> +static av_cold int photocd_decode_close(AVCodecContext *avctx)
> +{
> +PhotoCDContext *s = avctx->priv_data;
> +
> +for (int i = 0; i < 3; i++)
> +ff_free_vlc(&s->vlc[i]);
> +
> +return 0;
> +}
> +
> +#define OFFSET(x) offsetof(PhotoCDContext, x)
> +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
> +
> +static const AVOption options[] = {
> +{ "lowres",  "Lower the decoding resolution by a power of two",
> +OFFSET(lowres), AV_OPT_TYPE_INT,  { .i64 = 0 }, 0, 4, VD },
> +{ NULL },
> +};
> +
> +static const AVClass photocd_class = {
> +.class_name = "photocd",
> +.item_name  = av_default_item_name,
> +.option = options,
> +.version= LIBAVUTIL_VERSION_INT,
> +};
> +
> +AVCodec ff_photocd_decoder = {
> +.name   = "photocd",
> +.type   = AVMEDIA_TYPE_VIDEO,
> +.id = AV_CODEC_ID_PHOTOCD,
> +.priv_data_size = sizeof (PhotoCDContext),
> +.priv_class = &photocd_class,
> +.init   = photocd_decode_init,
> +.close  = photocd_decode_close,
> +.decode = photocd_decode_frame,
> +.capabilities   = AV_CODEC_CAP_DR1,
> +.long_name  = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
> +};
> diff --git a/libavformat/img2.c b/libavformat/img2.c
> index d243d6c125..db37aa7228 100644
> --- a/libavformat/img2.c
> +++ b/libavformat/img2.c
> @@ -55,6 +55,7 @@ const IdStrMap ff_img_tags[] = {
>  { AV_CODEC_ID_TIFF,   "dng"  },
>  { AV_CODEC_ID_SGI,"sgi"  },
>  { AV_CODEC_ID_PTX,"ptx"  },
> +{ AV_CODEC_ID_PHOTOCD,"pcd"  },
>  { AV_CODEC_ID_PCX,"pcx"  },
>  { AV_CODEC_ID_QDRAW,  "pic"  },
>  { AV_CODEC_ID_QDRAW,  "pct"  },
> --
> 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/2] avcodec/cfhd: Replace a few literal numbers by named constants

2020-08-29 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cfhd.c | 8 
 libavcodec/cfhd.h | 4 
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 036df00f72..ea35f03869 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -593,20 +593,20 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 break;
 }
 s->planes = data == 2 ? 4 : 
av_pix_fmt_count_planes(s->coded_format);
-} else if (tag == -85) {
+} else if (tag == -DisplayHeight) {
 av_log(avctx, AV_LOG_DEBUG, "Cropped height %"PRIu16"\n", data);
 s->cropped_height = data;
-} else if (tag == -75) {
+} else if (tag == -PeakOffsetLow) {
 s->peak.offset &= ~0x;
 s->peak.offset |= (data & 0x);
 s->peak.base= gb;
 s->peak.level   = 0;
-} else if (tag == -76) {
+} else if (tag == -PeakOffsetHigh) {
 s->peak.offset &= 0x;
 s->peak.offset |= (data & 0xU)<<16;
 s->peak.base= gb;
 s->peak.level   = 0;
-} else if (tag == -74 && s->peak.offset) {
+} else if (tag == -PeakLevel && s->peak.offset) {
 s->peak.level = data;
 bytestream2_seek(&s->peak.base, s->peak.offset - 4, SEEK_CUR);
 } else
diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
index fdc6f1e546..8ea91270cd 100644
--- a/libavcodec/cfhd.h
+++ b/libavcodec/cfhd.h
@@ -83,10 +83,14 @@ enum CFHDParam {
 Precision=  70,
 InputFormat  =  71,
 BandCodingFlags  =  72,
+PeakLevel=  74,
+PeakOffsetLow=  75,
+PeakOffsetHigh   =  76,
 Version  =  79,
 BandSecondPass   =  82,
 PrescaleTable=  83,
 EncodedFormat=  84,
+DisplayHeight=  85,
 ChannelWidth = 104,
 ChannelHeight= 105,
 };
-- 
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/2] avcodec/cfhd: More strictly check tag order

2020-08-29 Thread Michael Niedermayer
This is based on the encoder and a small number of CFHD sample files
It should make the decoder more robust against crafted input.
Due to the lack of a proper specification it is possible that this
may be too strict and may need to be tuned as files not following this
ordering are found.

Signed-off-by: Michael Niedermayer 
---
 libavcodec/cfhd.c | 66 +++
 libavcodec/cfhd.h |  3 +++
 2 files changed, 69 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index ea35f03869..1e88e651ae 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -361,6 +361,64 @@ static int alloc_buffers(AVCodecContext *avctx)
 return 0;
 }
 
+static int handle_tag_order(CFHDContext *s, int tag, int data)
+{
+int atag = abs(tag);
+// We do not restrict tags outside the enum
+if (atag >= LastTag)
+return 0;
+
+if (s->previous_marker == 0x) {
+if (tag >= 1 && tag <= 23 || atag >= 63 && atag <= 66 || atag >= 68 && 
atag <= 71 || atag >= 79 && atag <= 81 || atag >= 83 && atag <= 85 || atag >= 
91 && atag <= 93) {
+;
+} else if (tag == BitstreamMarker && data == 0x1a4a) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0x1a4a) {
+if (tag >= 25 && tag <= 36) {
+;
+} else if (tag == BitstreamMarker && data == 0xf0f) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xf0f) {
+if (tag != BitstreamMarker || data != 0x1b4b)
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0x1b4b) {
+if (tag != BitstreamMarker || data != 0xd0d)
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xd0d) {
+if (tag >= 37 && tag <= 47) {
+;
+} else if (tag == BitstreamMarker && data == 0xe0e) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xe0e) {
+if (tag >= 48 && tag <= 56 || tag == BandCodingFlags) {
+;
+} else if (-tag >= 74 && -tag <= 76) {
+;
+} else if (tag == BitstreamMarker && (data == 0xc0c || data == 0xe0e)) 
{
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xc0c) {
+if (tag == 1 || tag == 24 || tag == 62) {
+;
+} else if (tag == BitstreamMarker && (data == 0xd0d || data == 
0x1a4a)) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else
+return AVERROR_INVALIDDATA;
+
+if (tag == BitstreamMarker)
+s->previous_marker = data;
+return 0;
+}
+
 static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
 {
@@ -374,6 +432,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 
 init_frame_defaults(s);
 s->planes = av_pix_fmt_count_planes(s->coded_format);
+s->previous_marker = 0x;
 
 bytestream2_init(&gb, avpkt->data, avpkt->size);
 
@@ -385,6 +444,13 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 uint16_t abstag = abs(tag);
 int8_t abs_tag8 = abs(tag8);
 uint16_t data   = bytestream2_get_be16(&gb);
+
+ret = handle_tag_order(s, tag, data);
+if (ret < 0) {
+av_log(avctx, AV_LOG_DEBUG, "Unexpected TAG %d data %X in %X\n", 
tag, data, s->previous_marker);
+return ret;
+}
+
 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
 av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 
16) | data);
 } else if (tag == SampleFlags) {
diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
index 8ea91270cd..c46ab01c17 100644
--- a/libavcodec/cfhd.h
+++ b/libavcodec/cfhd.h
@@ -93,6 +93,7 @@ enum CFHDParam {
 DisplayHeight=  85,
 ChannelWidth = 104,
 ChannelHeight= 105,
+LastTag,
 };
 
 #define VLC_BITS   9
@@ -184,6 +185,8 @@ typedef struct CFHDContext {
 Plane plane[4];
 Peak peak;
 
+int previous_marker;
+
 CFHDDSPContext dsp;
 } CFHDContext;
 
-- 
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 1/2] avcodec/cfhd: Replace a few literal numbers by named constants

2020-08-29 Thread Paul B Mahol
LGTM

On 8/29/20, Michael Niedermayer  wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cfhd.c | 8 
>  libavcodec/cfhd.h | 4 
>  2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 036df00f72..ea35f03869 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -593,20 +593,20 @@ static int cfhd_decode(AVCodecContext *avctx, void
> *data, int *got_frame,
>  break;
>  }
>  s->planes = data == 2 ? 4 :
> av_pix_fmt_count_planes(s->coded_format);
> -} else if (tag == -85) {
> +} else if (tag == -DisplayHeight) {
>  av_log(avctx, AV_LOG_DEBUG, "Cropped height %"PRIu16"\n",
> data);
>  s->cropped_height = data;
> -} else if (tag == -75) {
> +} else if (tag == -PeakOffsetLow) {
>  s->peak.offset &= ~0x;
>  s->peak.offset |= (data & 0x);
>  s->peak.base= gb;
>  s->peak.level   = 0;
> -} else if (tag == -76) {
> +} else if (tag == -PeakOffsetHigh) {
>  s->peak.offset &= 0x;
>  s->peak.offset |= (data & 0xU)<<16;
>  s->peak.base= gb;
>  s->peak.level   = 0;
> -} else if (tag == -74 && s->peak.offset) {
> +} else if (tag == -PeakLevel && s->peak.offset) {
>  s->peak.level = data;
>  bytestream2_seek(&s->peak.base, s->peak.offset - 4, SEEK_CUR);
>  } else
> diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
> index fdc6f1e546..8ea91270cd 100644
> --- a/libavcodec/cfhd.h
> +++ b/libavcodec/cfhd.h
> @@ -83,10 +83,14 @@ enum CFHDParam {
>  Precision=  70,
>  InputFormat  =  71,
>  BandCodingFlags  =  72,
> +PeakLevel=  74,
> +PeakOffsetLow=  75,
> +PeakOffsetHigh   =  76,
>  Version  =  79,
>  BandSecondPass   =  82,
>  PrescaleTable=  83,
>  EncodedFormat=  84,
> +DisplayHeight=  85,
>  ChannelWidth = 104,
>  ChannelHeight= 105,
>  };
> --
> 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 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 2/2] avcodec/cfhd: More strictly check tag order

2020-08-29 Thread Paul B Mahol
On 8/29/20, Michael Niedermayer  wrote:
> This is based on the encoder and a small number of CFHD sample files
> It should make the decoder more robust against crafted input.
> Due to the lack of a proper specification it is possible that this
> may be too strict and may need to be tuned as files not following this
> ordering are found.
>

Breaks decoding of this and similar files:

https://samples.ffmpeg.org/V-codecs/CFHD/MT_BeartoothHighway_1min_Cineform.avi

It is too strict as our encoder does not implement 3d transforms.
___
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 2/2] avcodec/cfhd: More strictly check tag order

2020-08-29 Thread Michael Niedermayer
On Sat, Aug 29, 2020 at 11:00:13PM +0200, Paul B Mahol wrote:
> On 8/29/20, Michael Niedermayer  wrote:
> > This is based on the encoder and a small number of CFHD sample files
> > It should make the decoder more robust against crafted input.
> > Due to the lack of a proper specification it is possible that this
> > may be too strict and may need to be tuned as files not following this
> > ordering are found.
> >
> 
> Breaks decoding of this and similar files:
> 
> https://samples.ffmpeg.org/V-codecs/CFHD/MT_BeartoothHighway_1min_Cineform.avi
> 
> It is too strict as our encoder does not implement 3d transforms.

fixed this and the othert files in that directory (will post a new patch
in a moment)

also subsequently after this patch somethig to check not just for
fields not being in the wrong place we also should probably check for
mandatory fields being not missing.
I assume for this too guessing from files & sdk & any other implementation
is the only option we have

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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 v2] avcodec/cfhd: More strictly check tag order

2020-08-29 Thread Michael Niedermayer
This is based on the encoder and a small number of CFHD sample files
It should make the decoder more robust against crafted input.
Due to the lack of a proper specification it is possible that this
may be too strict and may need to be tuned as files not following this
ordering are found.

Signed-off-by: Michael Niedermayer 
---
 libavcodec/cfhd.c | 66 +++
 libavcodec/cfhd.h |  3 +++
 2 files changed, 69 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index ea35f03869..c36edb9ef8 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -361,6 +361,64 @@ static int alloc_buffers(AVCodecContext *avctx)
 return 0;
 }
 
+static int handle_tag_order(CFHDContext *s, int tag, int data)
+{
+int atag = abs(tag);
+// We do not restrict tags outside the enum
+if (atag >= LastTag)
+return 0;
+
+if (s->previous_marker == 0x) {
+if (tag >= 1 && tag <= 17 || tag >= 19 && tag <= 23 || atag >= 63 && 
atag <= 66 || atag >= 68 && atag <= 71 || atag == 73 || atag >= 79 && atag <= 
81 || atag >= 83 && atag <= 85 || atag >= 91 && atag <= 93) {
+;
+} else if (tag == BitstreamMarker && data == 0x1a4a) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0x1a4a) {
+if (tag >= 25 && tag <= 36) {
+;
+} else if (tag == BitstreamMarker && data == 0xf0f) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xf0f) {
+if (tag != BitstreamMarker || data != 0x1b4b)
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0x1b4b) {
+if (tag != BitstreamMarker || data != 0xd0d)
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xd0d) {
+if (tag >= 37 && tag <= 47) {
+;
+} else if (tag == BitstreamMarker && data == 0xe0e) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xe0e) {
+if (tag >= 48 && tag <= 56 || tag == BandCodingFlags) {
+;
+} else if (-tag >= 74 && -tag <= 76) {
+;
+} else if (tag == BitstreamMarker && (data == 0xc0c || data == 0xe0e)) 
{
+;
+} else
+return AVERROR_INVALIDDATA;
+} else if (s->previous_marker == 0xc0c) {
+if (tag == 1 || tag == 18 || tag == 24 || tag == 62 ) {
+;
+} else if (tag == BitstreamMarker && (data == 0xd0d || data == 
0x1a4a)) {
+;
+} else
+return AVERROR_INVALIDDATA;
+} else
+return AVERROR_INVALIDDATA;
+
+if (tag == BitstreamMarker)
+s->previous_marker = data;
+return 0;
+}
+
 static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
 {
@@ -374,6 +432,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 
 init_frame_defaults(s);
 s->planes = av_pix_fmt_count_planes(s->coded_format);
+s->previous_marker = 0x;
 
 bytestream2_init(&gb, avpkt->data, avpkt->size);
 
@@ -385,6 +444,13 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 uint16_t abstag = abs(tag);
 int8_t abs_tag8 = abs(tag8);
 uint16_t data   = bytestream2_get_be16(&gb);
+
+ret = handle_tag_order(s, tag, data);
+if (ret < 0) {
+av_log(avctx, AV_LOG_DEBUG, "Unexpected TAG %d data %X in %X\n", 
tag, data, s->previous_marker);
+return ret;
+}
+
 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
 av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 
16) | data);
 } else if (tag == SampleFlags) {
diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h
index 8ea91270cd..c46ab01c17 100644
--- a/libavcodec/cfhd.h
+++ b/libavcodec/cfhd.h
@@ -93,6 +93,7 @@ enum CFHDParam {
 DisplayHeight=  85,
 ChannelWidth = 104,
 ChannelHeight= 105,
+LastTag,
 };
 
 #define VLC_BITS   9
@@ -184,6 +185,8 @@ typedef struct CFHDContext {
 Plane plane[4];
 Peak peak;
 
+int previous_marker;
+
 CFHDDSPContext dsp;
 } CFHDContext;
 
-- 
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] doc/decoders: Clear up description of ac3's drc_scale option

2020-08-29 Thread Aman Verma
On Fri, Aug 28, 2020 at 11:15 PM Jim DeLaHunt  wrote:
> I don't know anything about the AC-3 format or the ac3 decoder in
> FFmpeg. However, I can read technical writing. I don't understand what
> you are trying to say differently with this change. But even more, I
> don't understand what the existing documentation is trying to say.
> I like that you are adding the information that the default value of
> -drc_scale is 1. That is not presently documented. Good.
>
> It looks like the other changes are to change "factor" to "number", and
> to convert a sentence "This factor is applied exponentially." to a
> dashed phrase "---exponentially---". I don't feel strongly that this
> makes things worth, but I also don't see how this makes things clearer.
>
> However, both the old and the new text leave me with a lot of questions.
> No doubt some of my questions are due to my ignorance of the AC-3 format
> and of the ac3 decoder code in FFmpeg. But some are due to the text
> leaving a lot of information unstated.

That is a fair judgement, I mostly reworded it because I didn't like the
sentence structure and I didn't look too closely at the source beyond
finding the default value. Looking at it now, it seems that the comments
in ac3dec_fixed.c, ac3dec_float.c, and ac3dec.h claim that the value is
applied as a linear scaler, contradicting the claims in the CLI
documentation [1][2][3].

> What does it mean to "apply — exponentially — to" a number? What
> mathematical operation is that? This is not at all clear to me.

That definitely could have been made clearer haha. I was referring to a
function f(x,d) = x^d, where x is the number and d is the drc_scale
value. I think that is also what the original documentation meant.

> So, I'm not in a position to approve or reject this patch.  And fixing
> deficiencies in the ac3 decoder documentation overall is probably not
> the scope of change which you wanted to make.

For now, I'll revise the patch to only include the mention of the
default value but I will do a closer reading of the ac3dec source when I
have more time.

As an aside, am I supposed to submit the revised patch in reply to this
thread or should I submit it as a new thread? This is my first time
contributing to a project that uses mailing lists.

[1]: 
https://github.com/FFmpeg/FFmpeg/blob/5ff2ff6bd9cd9e08729060d330e381a09972c498/libavcodec/ac3dec_fixed.c#L159
[2]: 
https://github.com/FFmpeg/FFmpeg/blob/5ff2ff6bd9cd9e08729060d330e381a09972c498/libavcodec/ac3dec_float.c#L36
[3]: 
https://github.com/FFmpeg/FFmpeg/blob/5ff2ff6bd9cd9e08729060d330e381a09972c498/libavcodec/ac3dec.h#L175
___
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] doc/decoders: Clear up description of ac3's drc_scale option

2020-08-29 Thread Jim DeLaHunt

On 2020-08-29 15:10, Aman Verma wrote:

...As an aside, am I supposed to submit the revised patch in reply to 
this

thread or should I submit it as a new thread? This is my first time
contributing to a project that uses mailing lists.


The instructions are at 
, sections 6 
"Submitting patches" and 8 "Patch submission checklist". I found those 
instructions a bit of a jumble and hard to follow, so I just reread them 
all every step of the way. As far as I can tell they don't actually 
answer your question. But it is a common practice to use "git patch 
--in-reply-to=" to set the "In-reply-to" header to the 
message-ID of your original patch email.


You still need to have a review from someone with commit authority, 
which is not me. Good luck!



___
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 04/13] avcodec/mss3: Remove unnecessary free of unallocated packet

2020-08-29 Thread Andreas Rheinhardt
Paul B Mahol:
> On 8/29/20, Andreas Rheinhardt  wrote:
>> The packet will only be allocated a few lines below.
>>
> 
> You mean frame?
> 
Yes. Fixed locally. Thanks.

>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/mss3.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
>> index 113af5ba37..a301675ec2 100644
>> --- a/libavcodec/mss3.c
>> +++ b/libavcodec/mss3.c
>> @@ -844,7 +844,6 @@ static av_cold int mss3_decode_init(AVCodecContext
>> *avctx)
>>  b_width * b_height);
>>  if (!c->dct_coder[i].prev_dc) {
>>  av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
>> -av_frame_free(&c->pic);
>>  while (i >= 0) {
>>  av_freep(&c->dct_coder[i].prev_dc);
>>  i--;
>> --
>> 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".

Re: [FFmpeg-devel] [PATCH] avcodec: add PhotoCD decoder

2020-08-29 Thread Andreas Rheinhardt
Paul B Mahol:
> Signed-off-by: Paul B Mahol 
> ---
> Probably need to be applied on top of moflex v2 patch set.
> ---
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/codec_id.h   |   1 +
>  libavcodec/photocd.c| 468 
>  libavformat/img2.c  |   1 +
>  6 files changed, 479 insertions(+)
>  create mode 100644 libavcodec/photocd.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 97fbe6b7a9..98f31e246b 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -541,6 +541,7 @@ OBJS-$(CONFIG_PGMYUV_DECODER)  += pnmdec.o pnm.o
>  OBJS-$(CONFIG_PGMYUV_ENCODER)  += pnmenc.o
>  OBJS-$(CONFIG_PGSSUB_DECODER)  += pgssubdec.o
>  OBJS-$(CONFIG_PGX_DECODER) += pgxdec.o
> +OBJS-$(CONFIG_PHOTOCD_DECODER) += photocd.o
>  OBJS-$(CONFIG_PICTOR_DECODER)  += pictordec.o cga_data.o
>  OBJS-$(CONFIG_PIXLET_DECODER)  += pixlet.o
>  OBJS-$(CONFIG_PJS_DECODER) += textdec.o ass.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 8a4b3fb178..f3572a47e3 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -241,6 +241,7 @@ extern AVCodec ff_pgm_decoder;
>  extern AVCodec ff_pgmyuv_encoder;
>  extern AVCodec ff_pgmyuv_decoder;
>  extern AVCodec ff_pgx_decoder;
> +extern AVCodec ff_photocd_decoder;
>  extern AVCodec ff_pictor_decoder;
>  extern AVCodec ff_pixlet_decoder;
>  extern AVCodec ff_png_encoder;
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index ceef244ebf..9e73dcba27 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1791,6 +1791,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
>  .long_name = NULL_IF_CONFIG_SMALL("MobiClip Video"),
>  .props = AV_CODEC_PROP_LOSSY,
>  },
> +{
> +.id= AV_CODEC_ID_PHOTOCD,
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.name  = "photocd",
> +.long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
> +.props = AV_CODEC_PROP_LOSSY,
> +},
>  
>  /* various PCM "codecs" */
>  {
> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> index 19d5014bb4..e4eca5d580 100644
> --- a/libavcodec/codec_id.h
> +++ b/libavcodec/codec_id.h
> @@ -297,6 +297,7 @@ enum AVCodecID {
>  AV_CODEC_ID_NOTCHLC,
>  AV_CODEC_ID_PFM,
>  AV_CODEC_ID_MOBICLIP,
> +AV_CODEC_ID_PHOTOCD,
>  
>  /* various PCM "codecs" */
>  AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
> start of audio codecs
> diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
> new file mode 100644
> index 00..50584ac980
> --- /dev/null
> +++ b/libavcodec/photocd.c
> @@ -0,0 +1,468 @@
> +/*
> + * Kodak PhotoCD (a.k.a. ImagePac) image decoder
> + *
> + * Copyright (c) 1996-2002 Gerd Knorr
> + * Copyright (c) 2010 Kenneth Vermeirsch
> + * 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
> + */
> +
> +/**
> + * @file
> + * Kodak PhotoCD (a.k.a. ImagePac) image decoder
> + *
> + * Supports resolutions up to 3072x2048.
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/opt.h"
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "get_bits.h"
> +#include "internal.h"
> +
> +typedef struct PhotoCDContext {
> +AVClass *class;
> +int  lowres;
> +
> +GetByteContext gb;
> +int  thumbnails;  //* number of thumbnails; 0 for normal image */
> +int  resolution;
> +int  orientation;
> +
> +int  streampos;
> +
> +uint8_t  bits[256];
> +uint16_t codes[256];
> +uint8_t  syms[256];
> +
> +VLC  vlc[3];
> +} PhotoCDContext;
> +
> +typedef struct ImageInfo {
> +uint32_t start;
> +uint16_t width, height;
> +} ImageInfo;
> +
> +static const ImageInfo img_info[6] = {
> +{8192,192, 128},
> +{47104,   384, 256},
> +{196608,  768, 512},
> +{0,  1536, 1024},
> +{0,  3072, 2048},
> +{0,  6144, 4096},
> +};
> +
> +static av_always_inline void interp_lowres(PhotoCDContext *

Re: [FFmpeg-devel] [PATCH] avformat/rtsp: fix infinite loop with udp transport

2020-08-29 Thread Zhao Zhili


> On Aug 30, 2020, at 1:45 AM, Andriy Gelman  wrote:
> 
> Hi Zhao,
> 
> On Tue, 25. Aug 01:17, Zhao Zhili wrote:
>> Ping again.
>> 
>>> On Aug 17, 2020, at 8:05 AM, zhilizhao  wrote:
>>> 
>>> Please help review the patch, thanks!
>>> 
 On Aug 6, 2020, at 4:50 PM, quinkbl...@foxmail.com wrote:
 
 From: Zhao Zhili 
 
 User report: 
 http://ffmpeg.org/pipermail/ffmpeg-user/2020-August/049494.html
 
 server:
 ./ffmpeg -i test.mp4 -c copy -f rtsp -rtsp_transport udp  
 rtsp://localhost:12345/live.sdp
 
 client:
 ./ffmpeg_g -y -rtsp_flags listen -timeout 100 -i 
 rtsp://localhost:12345/live.sdp -c copy test.mp4
 ---
 libavformat/rtsp.c | 5 +
 1 file changed, 5 insertions(+)
 
 diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
 index 5d8491b74b..0fb9fde6b4 100644
 --- a/libavformat/rtsp.c
 +++ b/libavformat/rtsp.c
 @@ -2051,6 +2051,11 @@ static int udp_read_packet(AVFormatContext *s, 
 RTSPStream **prtsp_st,
   if ((ret = parse_rtsp_message(s)) < 0) {
   return ret;
   }
 +/* Since there is no way to detect eof of udp streams, 
 break
 + * the loop in teardown state to prevent run into 
 infinite.
 + */
 +if (rt->state == RTSP_STATE_IDLE)
 +return AVERROR_EOF;
   }
 #endif
   } else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
> 
> Currently when the stream finishes a BYE message is not sent from the server. 
>  
> 
> You can ensure that the message is sent by adding the send_bye option with the
> flag:
> "-rtpflags send_bye"
> 
> This will also fix the problem.

Thanks for your reply. It's a clean solution from the viewpoint of FFmpeg users.
However, I think FFmpeg should handle the case without BYE packets, even
without RTCP. The busy loop leads to high cpu usage. I'm not saying the patch
is the right solution, I'd like to hear other suggestions to fix the problem on 
the
rtsp receiver's side.

> 
> What I think is more confusing is that "-rtp_flags send_bye" is also valid on
> the command line but will have no effect..
> 
> -- 
> Andriy
> ___
> 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] doc/decoders: Clear up description of ac3's drc_scale option

2020-08-29 Thread Gyan Doshi



On 30-08-2020 05:18 am, Jim DeLaHunt wrote:

On 2020-08-29 15:10, Aman Verma wrote:

...As an aside, am I supposed to submit the revised patch in reply to 
this

thread or should I submit it as a new thread? This is my first time
contributing to a project that uses mailing lists.


The instructions are at 
, sections 6 
"Submitting patches" and 8 "Patch submission checklist". I found those 
instructions a bit of a jumble and hard to follow, so I just reread 
them all every step of the way. As far as I can tell they don't 
actually answer your question. But it is a common practice to use "git 
patch --in-reply-to=" to set the "In-reply-to" header to 
the message-ID of your original patch email.


You still need to have a review from someone with commit authority, 
which is not me. Good luck!


Submit a new patch with updated version number, and reply to using the 
message-id of the parent email.


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 04/13] avcodec/mss3: Remove unnecessary free of unallocated packet

2020-08-29 Thread Paul B Mahol
On 8/30/20, Andreas Rheinhardt  wrote:
> Paul B Mahol:
>> On 8/29/20, Andreas Rheinhardt  wrote:
>>> The packet will only be allocated a few lines below.
>>>
>>
>> You mean frame?
>>
> Yes. Fixed locally. Thanks.

LGTM

>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavcodec/mss3.c | 1 -
>>>  1 file changed, 1 deletion(-)
>>>
>>> diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c
>>> index 113af5ba37..a301675ec2 100644
>>> --- a/libavcodec/mss3.c
>>> +++ b/libavcodec/mss3.c
>>> @@ -844,7 +844,6 @@ static av_cold int mss3_decode_init(AVCodecContext
>>> *avctx)
>>>  b_width * b_height);
>>>  if (!c->dct_coder[i].prev_dc) {
>>>  av_log(avctx, AV_LOG_ERROR, "Cannot allocate buffer\n");
>>> -av_frame_free(&c->pic);
>>>  while (i >= 0) {
>>>  av_freep(&c->dct_coder[i].prev_dc);
>>>  i--;
>>> --
>>> 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".